本文整理汇总了PHP中UTF8::correct方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::correct方法的具体用法?PHP UTF8::correct怎么用?PHP UTF8::correct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::correct方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RefererURLBeautifier_handler
function RefererURLBeautifier_handler($target, $mother)
{
$keyword = false;
if (preg_match('/\\W(q|query|k|keyword|search|stext|nlia|aqa|wd)(?:=|%3D)([^&]+)/i', $mother['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[2]));
} else {
if (strpos($mother['host'], 'images.google.') !== false && preg_match('/%3Fsearch%3D([^&]+)/i', $mother['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[1]));
} else {
if (strpos($mother['host'], 'yahoo.') !== false && preg_match('/\\Wp=([^&]+)/i', $mother['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[1]));
} else {
if (preg_match('@/search/(?:\\w+/)*([^/?]+)@i', $mother['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[1]));
}
}
}
}
if (!UTF8::validate($keyword)) {
$keyword = UTF8::correct(UTF8::bring($keyword));
}
$keyword = UTF16UrlDecode($keyword);
$url = rawurldecode(substr($mother['url'], 7));
if (!UTF8::validate($url)) {
$url = UTF8::correct(UTF8::bring($url));
}
//return '<img src="http://'.$mother['host'].'/favicon.ico" width="16" height="16" alt="Favicon" onerror="this.parentNode.removeChild(this)" style="vertical-align: middle"/> ' . (($keyword) ? '<span style="font-weight: bold; color: #594">['.htmlspecialchars($keyword).']</span> ' . UTF8::lessenAsEm($url, 65 - UTF8::lengthAsEm($keyword)) : UTF8::lessenAsEm($url, 65));
return $keyword ? '<span style="font-weight: bold; color: #594">[' . htmlspecialchars($keyword) . ']</span> ' . htmlspecialchars(UTF8::lessenAsEm($url, 70 - UTF8::lengthAsEm($keyword))) : htmlspecialchars(UTF8::lessenAsEm($url, 70));
}
示例2: validateArray
public static function validateArray(&$array, &$rules)
{
// Workaround for non Fancy-URL user.
$cropArray = array();
foreach ($array as $name => $value) {
$doesHaveRequest = strpos($name, '?');
if ($doesHaveRequest !== false) {
$name = substr($name, $doesHaveRequest + 1);
}
$cropArray[$name] = $value;
}
$array = $cropArray;
foreach ($rules as $key => $rule) {
if (!isset($rule[0])) {
trigger_error("Validator: The type of '{$key}' is not defined", E_USER_WARNING);
continue;
}
if (isset($array[$key]) && ($rule[0] == 'file' || strlen($array[$key]) > 0)) {
$value =& $array[$key];
if (isset($rule['min'])) {
$rule[1] = $rule['min'];
}
if (isset($rule['max'])) {
$rule[2] = $rule['max'];
}
if (isset($rule['bypass'])) {
$rule[3] = $rule['bypass'];
}
switch ($rule[0]) {
case 'any':
if (isset($rule[1]) && strlen($value) < $rule[1]) {
return false;
}
if (isset($rule[2]) && strlen($value) > $rule[2]) {
return false;
}
break;
case 'bit':
$array[$key] = self::getBit($value);
break;
case 'bool':
$array[$key] = self::getBool($value);
break;
case 'number':
if (!self::number($value, isset($rule[1]) ? $rule[1] : null, isset($rule[2]) ? $rule[2] : null, isset($rule[3]) ? $rule[3] : false)) {
return false;
}
break;
case 'int':
if (!self::isInteger($value, isset($rule[1]) ? $rule[1] : -2147483648, isset($rule[2]) ? $rule[2] : 2147483647, isset($rule[3]) ? $rule[3] : false)) {
return false;
}
break;
case 'id':
if (!self::id($value, isset($rule[1]) ? $rule[1] : 1, isset($rule[2]) ? $rule[2] : 2147483647)) {
return false;
}
break;
case 'url':
case 'string':
if (!UTF8::validate($value)) {
$value = UTF8::bring($value);
if (!UTF8::validate($value)) {
return false;
}
}
$value = $array[$key] = UTF8::correct($value);
if (isset($rule[1]) && UTF8::length($value) < $rule[1]) {
return false;
}
if (isset($rule[2]) && UTF8::length($value) > $rule[2]) {
return false;
}
break;
case 'list':
if (!self::isList($value)) {
return false;
}
break;
case 'timestamp':
if (!self::timestamp($value)) {
return false;
}
break;
case 'period':
if (!self::period($value)) {
return false;
}
break;
case 'ip':
if (!self::ip($value)) {
return false;
}
break;
case 'phone':
if (!self::phone($value)) {
return false;
}
break;
case 'domain':
//.........这里部分代码省略.........
示例3: getPostPage
function getPostPage($url, $content) {
$this->responseText = '';
$this->HTTPRequest('POST', $url);
if (!$this->send($content)) {
return false;
}
return trim(UTF8::correct(UTF8::convert($this->responseText)));
}
示例4: makeResult
function makeResult($str) {
$this->buffer .= UTF8::correct($str).CRLF;
}
示例5: saveFeedItem
function saveFeedItem($feedId,$feedVisibility,$item){
global $database, $db, $event;
$db->query("SELECT id FROM {$database['prefix']}DeleteHistory WHERE feed='$feedId' and permalink='{$item['permalink']}'");
if ($db->numRows() > 0)
return false;
if ($item['written']>gmmktime()+86400)
return false;
$item['title']=$db->escape($db->lessen(UTF8::correct($item['title'])));
list($useRssOut) = Settings::gets('useRssOut');
list($feedCreated,$localFilter,$localFilterType) = Feed::gets($feedId, 'created,filter,filterType');
$tagString=$db->escape($db->lessen(UTF8::correct(implode(', ',$item['tags']))));
list($globalFilter,$blackFilter,$globalFilterType,$blackFilterType) = Settings::gets('filter,blackfilter,filterType,blackfilterType');
$filter = empty($globalFilter)?$localFilter:$globalFilter;
$filterType = empty($globalFilter)?$localFilterType:$globalFilterType;
if (!Validator::is_empty($filter)) {
$filtered = true;
$allowTags = explode(',', $filter);
if($filterType == 'tag' || $filterType == 'tag+title') {
foreach ($allowTags as $ftag) {
if (Validator::enum($ftag, $tagString)) {
$filtered = false;
break;
}
}
}
if($filtered && ($filterType == 'title' || $filterType == 'tag+title')) {
foreach ($allowTags as $ftag) {
if(strpos($item['title'],$ftag)!==false) {
$filtered = false;
break;
}
}
}
if ($filtered) return false;
}
if (!Validator::is_empty($blackFilter)) {
$filtered = false;
$denyTags = explode(',', $blackFilter);
if($blackFilterType == 'tag' || $blackFilterType == 'tag+title') {
foreach ($denyTags as $ftag) {
if (Validator::enum($ftag, $tagString)) {
$filtered = true;
break;
}
}
}
if($filtered && ($filterType == 'title' || $filterType == 'tag+title')) {
foreach ($denyTags as $ftag) {
if(strpos($item['title'],$ftag)!==false) {
$filtered = true;
break;
}
}
}
if ($filtered) return false;
}
if (preg_match('/\((.[^\)]+)\)$/Ui', trim($item['author']), $_matches)) $item['author'] = $_matches[1];
$item['author']=$db->escape($db->lessen(UTF8::correct($item['author'])));
$item['permalink']=$db->escape($db->lessen(UTF8::correct($item['permalink'])));
$item['description']=$db->escape($db->lessen(UTF8::correct(trim($item['description'])),65535));
$enclosures = array();
foreach($item['enclosures'] as $en) {
array_push($enclosures, $en['url']);
}
$enclosureString=$db->escape($db->lessen(UTF8::correct(implode('|',$enclosures))));
$deadLine=0;
$feedLife = Settings::get('archivePeriod');
if ($feedLife > 0) $deadLine=gmmktime()-($feedLife*86400);
requireComponent('Bloglounge.Data.FeedItems');
$oldTags = null;
$id = FeedItem::getIdByURL($item['permalink']);
if($id === false && isset($item['guid'])) {
$item['guid']=$db->escape($db->lessen(UTF8::correct($item['guid'])));
$id = FeedItem::getIdByURL($item['guid']);
}
$item['author'] = Feed::getAuthor($item, $feedId, $id);
$item['title'] = Feed::getTitle($item, $feedId, $id);
$affected = 0;
//.........这里部分代码省略.........
示例6: getRefererKeywordStatistics
function getRefererKeywordStatistics()
{
$more = false;
$refereres = getRefererLogsDB();
$keywordlist = array();
$record = array();
for ($i = 0; $i < sizeof($refereres); $i++) {
$record = $refereres[$i];
if ($i == 0) {
$referredend = $record['referred'];
}
$keyword = "";
if (preg_match('/\\W(q|query|k|keyword|search|stext|nlia|aqa|wd)(?:=|%3D)([^&]+)/i', $record['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[2]));
} else {
if (strpos($record['url'], 'yahoo.') !== false && preg_match('/\\Wp=([^&]+)/i', $record['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[1]));
} else {
if (preg_match('@/search/(?:\\w+/)*([^/?]+)@i', $record['url'], $matches)) {
$keyword = urldecode(rawurldecode($matches[1]));
}
}
}
if (!UTF8::validate($keyword)) {
$keyword = UTF8::correct(UTF8::bring($keyword));
}
if (array_key_exists($keyword, $keywordlist)) {
$keywordlist[$keyword]++;
} elseif ($keyword) {
$keywordlist[$keyword] = 1;
}
}
$referredstart = array_key_exists('referred', $record) ? $record['referred'] : '';
$keywordlist = RefererKeywordArraySort($keywordlist, 'desc');
$keywordkeys = array_keys($keywordlist);
$beforekeywordvalue = '';
$rank = 0;
$keywordArray = array();
for ($i = 0; $i < sizeof($keywordlist); $i++) {
$keywordkey = $keywordkeys[$i];
$keywordvalue = $keywordlist[$keywordkey];
$keywordkey = str_replace("\"", """, $keywordkeys[$i]);
if ($keywordvalue != $beforekeywordvalue) {
$rank++;
$beforekeywordvalue = $keywordvalue;
}
array_push($keywordArray, array('keyword' => $keywordkey, 'count' => $keywordvalue, 'total' => count($keywordlist), 'rank' => $rank, 'dateStart' => Timestamp::formatDate($referredstart), 'dateEnd' => Timestamp::formatDate($referredend)));
}
return $keywordArray;
}
示例7: saveFeedItem
function saveFeedItem($feedId, $item)
{
global $database;
$item = fireEvent('SaveFeedItem', $item);
$item['permalink'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct($item['permalink'])));
$item['author'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct($item['author'])));
$item['title'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct($item['title'])));
$item['description'] = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct($item['description']), 65535));
$tagString = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct(implode(', ', $item['tags']))));
$enclosureString = POD::escapeString(UTF8::lessenAsEncoding(UTF8::correct(implode('|', $item['enclosures']))));
if ($item['written'] > gmmktime() + 86400) {
return false;
}
$deadLine = 0;
$feedlife = POD::queryCell("SELECT feedlife FROM {$database['prefix']}FeedSettings");
if ($feedlife > 0) {
$deadLine = gmmktime() - $feedlife * 86400;
}
if ($id = POD::queryCell("SELECT id FROM {$database['prefix']}FeedItems WHERE permalink='{$item['permalink']}'") && $item['written'] != 0) {
$result = POD::query("UPDATE {$database['prefix']}FeedItems SET author = '{$item['author']}', title = '{$item['title']}', description = '{$item['description']}', tags = '{$tagString}', enclosure = '{$enclosureString}', written = {$item['written']} WHERE id = {$id}");
/*
TODO : 읽은글이 읽지않은 글로 표시되는 문제 원인이 찾아질때 까지 막아둠
if (POD::num_rows($result) > 0)
POD::query("DELETE FROM {$database['prefix']}FeedReads WHERE item = $id");
*/
} else {
if ($id != null) {
return false;
} else {
if ($item['written'] == 0) {
$item['written'] = gmmktime();
}
if ($item['written'] > $deadLine) {
$id = POD::queryCell("SELECT max(id) FROM {$database['prefix']}FeedItems");
if (!$id) {
$id = 0;
}
$id++;
POD::query("INSERT INTO {$database['prefix']}FeedItems VALUES({$id}, {$feedId}, '{$item['author']}', '{$item['permalink']}', '{$item['title']}', '{$item['description']}', '{$tagString}', '{$enclosureString}', {$item['written']})");
}
}
}
return true;
}
示例8: openFile
function openFile($filename, $correct = false) {
if (!$fp = fopen($filename, 'r'))
return false;
$p = xml_parser_create();
xml_set_object($p, $this);
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($p, 'o', 'c');
xml_set_character_data_handler($p, 'd');
xml_set_default_handler($p, 'x');
$this->struct = array();
$this->_cursor = &$this->struct;
$this->_path = array('');
$this->_cdata = false;
if ($correct) {
$remains = '';
while (!feof($fp)) {
$chunk = $remains . fread($fp, 10240);
$remains = '';
if (strlen($chunk) >= 10240) {
for ($c = 1; $c <= 4; $c++) {
switch ($chunk{strlen($chunk) - $c} & "\xC0") {
case "\x00":
case "\x40":
if ($c > 1) {
$remains = substr($chunk, strlen($chunk) - $c + 1);
$chunk = substr($chunk, 0, strlen($chunk) - $c + 1);
}
$c = 5;
break;
case "\xC0":
$remains = substr($chunk, strlen($chunk) - $c);
$chunk = substr($chunk, 0, strlen($chunk) - $c);
$c = 5;
break;
}
}
}
$xml = str_replace('&','&',UTF8::correct($chunk, '?'));
if (!xml_parse($p, $xml, false)) {
fclose($fp);
return $this->_error($p);
}
}
} else {
while (!feof($fp)) {
$xml = str_replace('&','&',fread($fp, 10240));
if (!xml_parse($p, $xml, false)) {
fclose($fp);
return $this->_error($p);
}
}
}
fclose($fp);
if (!xml_parse($p, '', true))
return $this->_error($p);
unset($this->_cursor);
unset($this->_cdata);
if (xml_get_error_code($p) != XML_ERROR_NONE)
return $this->_error($p);
xml_parser_free($p);
return true;
}