当前位置: 首页>>代码示例>>PHP>>正文


PHP UTF8::bring方法代码示例

本文整理汇总了PHP中UTF8::bring方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::bring方法的具体用法?PHP UTF8::bring怎么用?PHP UTF8::bring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UTF8的用法示例。


在下文中一共展示了UTF8::bring方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
开发者ID:hinablue,项目名称:TextCube,代码行数:29,代码来源:index.php

示例2: open

		function open($xml, $encoding = null, $nsenabled = false) {
			if (!empty($encoding) && (strtolower($encoding) != 'utf-8') && !UTF8::validate($xml)) {
				if (preg_match('/^<\?xml[^<]*\s+encoding=["\']?([\w-]+)["\']?/', $xml, $matches)) {
					$encoding = $matches[1];
					$xml = preg_replace('/^(<\?xml[^<]*\s+encoding=)["\']?[\w-]+["\']?/', '$1"utf-8"', $xml, 1);
				}
				if (strcasecmp($encoding, 'utf-8')) {
					$xml = UTF8::bring($xml, $encoding);
					if ($xml === null) {
						$this->error = XML_ERROR_UNKNOWN_ENCODING;
						return false;
					}
				}
			} else {
				if (substr($xml, 0, 3) == "\xEF\xBB\xBF")
					$xml = substr($xml, 3);
			}			
			
			$xml = str_replace('&', '&amp;', $xml); // for parse error code 23 (&)

			$this->nsenabled = $nsenabled;
			$p = ($nsenabled) ? xml_parser_create_ns() : 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 (!xml_parse($p, $xml))
				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;
		}
开发者ID:ncloud,项目名称:bloglounge,代码行数:40,代码来源:LZ.PHP.XMLStruct.php

示例3: 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':
//.........这里部分代码省略.........
开发者ID:jinbonetwork,项目名称:collective-agreement-database,代码行数:101,代码来源:Validator.class.php

示例4: date

			$sp_booms = $skin->parseTag('boom_author', UTF8::clear($item['author']), $sp_booms);
			$sp_booms = $skin->parseTag('boom_date', (Validator::is_digit($item['written']) ? date('Y-m-d', $item['written']) : $item['written']), $sp_booms);

			$s_booms_rep .= $sp_booms;
			$sp_booms = '';
		}		
		$s_booms = $skin->dressOn('boom_rep', $src_booms_rep, $s_booms_rep, $src_booms);
	} else {
		$s_booms = '';
	}
	$skin->dress('boom', $s_booms);

	// ** 태그 클라우드
	$skin->dress('tagcloud', SkinElement::getTagCloud($skinConfig->tagCloudOrder, $skinConfig->tagCloudLimit));

	// ** 달력
	$skin->replace('calendar', SkinElement::getCalendarView((($searchType=='archive')&&!empty($searchKeyword)) ? substr($searchKeyword, 0, 6) : null));

	// ** 검색
	$searchTypeSelector = '<select name="type"><option value="all">'._t('전체').'</option><option value="tag"'.(($searchType=='tag')?' selected="selected"':'').'>'._t('태그').'</option><option value="blogURL"'.(($searchType=='blogURL')?' selected="selected"':'').'>'._t('블로그주소').'</option><option value="archive"'.(($searchType=='archive')?' selected="selected"':'').'>'._t('날짜지정').'</option></select>';
	$skin->replace('search_typeselect', $searchTypeSelector);
	$skin->replace('search_keyword', $searchKeyword);
	$src_search = $skin->cutSkinTag('search');

	$s_search = '<form action="'.$servicePath.'/" enctype="application/x-www-form-urlencoded" method="get">'.$src_search.'</form>';
	$skin->dress('search', $s_search);

	$skin->output = $skin->parseTagWithCondition('search_keyword', Korean::doesHaveFinalConsonant(UTF8::bring($searchKeyword)), '<span class="searchKeyword">"'.$searchKeyword.'"</span>', $skin->output);
	if(Validator::is_empty($searchKeyword)) $skin->dress('cond_search', '');			

?>
开发者ID:ncloud,项目名称:bloglounge,代码行数:31,代码来源:skin.begin.php

示例5: getFeedItems

		function getFeedItems($xml) {		
			if (preg_match('/^<\?xml[^<]*\s+encoding=["\']?([\w-]+)["\']?/', $xml, $matches)) // kor env
				$encoding = $matches[1];
			if (strcasecmp($encoding, 'euc-kr') == 0) {
				$xml = UTF8::bring($xml, $encoding);
				$xml = preg_replace('/^(<\?xml[^<]*\s+encoding=)["\']?[\w-]+["\']?/', '$1"utf-8"', $xml, 1);
			}

			$xmls=new XMLStruct();
			if (!$xmls->open($xml))
				return false;

			$items = array();

			if ($xmls->getAttribute('/rss','version')){ // rss element must have version attribute
				for ($i=1;$link=$xmls->getValue("/rss/channel/item[$i]/link");$i++){
					$item=array('permalink'=>rawurldecode($link));
					if (!$item['author']=$xmls->getValue("/rss/channel/item[$i]/author"))
						$item['author']=$xmls->getValue("/rss/channel/item[$i]/dc:creator");
					$item['title']=$xmls->getValue("/rss/channel/item[$i]/title");
					if (!$item['description']=$xmls->getValue("/rss/channel/item[$i]/content:encoded"))
						$item['description']=htmlspecialchars_decode($xmls->getValue("/rss/channel/item[$i]/description"));
					$item['tags']=array();
					for ($j=1;$tag=$xmls->getValue("/rss/channel/item[$i]/category[$j]");$j++)
						if (!empty($tag)) {
						//	array_push($item['tags'],$tag);
							$tags = explode('/', $tag); // allblog, blogkorea types
							foreach($tags as $tag) {
								array_push($item['tags'], trim($tag));
							}
						}

					for ($j=1;$tag=$xmls->getValue("/rss/channel/item[$i]/subject[$j]");$j++)
						if (!empty($tag))
							array_push($item['tags'],$tag);
					if ($youtubeTags = $xmls->getValue("/rss/channel/item[$i]/media:category")) { // for Youtube,Flickr Feed
						array_push($item['tags'], ''); // blank. first tag not equals category
						foreach (explode(' ', $youtubeTags) as $tag) {
							$tag = trim($tag);
							if(!empty($tag))
								array_push($item['tags'], $tag);
						}
					}

					$item['enclosures']=array();
					for ($j=1;$result=$xmls->getAttributes("/rss/channel/item[$i]/enclosure[$j]",array('url','type'));$j++) {
						if (!empty($result)) {
							array_push($item['enclosures'],array('url'=>$result[0],'type'=>$result[1]));
						}
					}
					$flickrContent=$xmls->getAttributes("/rss/channel/item[$i]/media:content[$j]",array('url','type')); // for flickr feed
					if(!empty($flickrContent)) {
							array_push($item['enclosures'],array('url'=>$flickrContent[0],'type'=>$flickrContent[1]));
					}	

					if ($xmls->getValue("/rss/channel/item[$i]/pubDate"))
						$item['written']=Feed::parseDate($xmls->getValue("/rss/channel/item[$i]/pubDate"));
					elseif ($xmls->getValue("/rss/channel/item[$i]/dc:date"))
						$item['written']=Feed::parseDate($xmls->getValue("/rss/channel/item[$i]/dc:date"));
					else
						$item['written']=0;
					if (!$item['generator']=$xmls->getValue("/rss/channel/generator")) {
						if (strpos($item['permalink'], 'tvpot.daum.net') !== false)
							$item['generator'] = 'Daum Tvpot';
						else 
							$item['generator'] = 'Unknown';
					}
					if (!$item['guid']=$xmls->getValue("/rss/channel/item[$i]/guid"))
						$item['guid'] = $item['permalink'];
					
					array_push($items, $item);
				}
			} elseif ($xmls->doesExist('/feed')){ // atom 0.3
				for ($i=1;$link=$xmls->getValue("/feed/entry[$i]/id");$i++){
					$item['enclosures']=array();

					for ($j=1;$rel=$xmls->getAttribute("/feed/entry[$i]/link[$j]",'rel');$j++){
						if ($rel=='alternate'){
							$link=$xmls->getAttribute("/feed/entry[$i]/link[$j]",'href');
						} else if($rel=='enclosure' || $rel=='image') { 
							$result = $xmls->getAttributes("/feed/entry[$i]/link[$j]",array('href','type'));
							if($result) {
								array_push($item['enclosures'],array('url'=>$result[0],'type'=>$result[1]));
							}
						}
					}

					$item=array('permalink'=>rawurldecode($link),'enclosures'=>$item['enclosures']);	

					$item['author']=$xmls->getValue("/feed/entry[$i]/author/name");
					$item['title']=$xmls->getValue("/feed/entry[$i]/title");
					if (!$item['description']=htmlspecialchars_decode($xmls->getValue("/feed/entry[$i]/content")))
						$item['description']=htmlspecialchars_decode($xmls->getValue("/feed/entry[$i]/summary"));
					$item['tags']=array();
					for ($j=1;$tag=$xmls->getValue("/feed/entry[$i]/dc:subject[$j]");$j++) {
						if (!empty($tag)) array_push($item['tags'],trim($tag));
					}
					for ($j=1;$tag=$xmls->getAttribute("/feed/entry[$i]/category[$j]", 'term');$j++) {
						if (!empty($tag)) array_push($item['tags'],trim($tag));
					}
//.........这里部分代码省略.........
开发者ID:ncloud,项目名称:bloglounge,代码行数:101,代码来源:LZ.PHP.Feeder.php

示例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("\"", "&quot;", $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;
}
开发者ID:hinablue,项目名称:TextCube,代码行数:50,代码来源:statistics_inc.php

示例7: getFeedItemsQuery

		function getFeedItemsQuery($searchType, $searchKeyword, $searchExtraValue,$viewDelete = false,$owner = 0) {	
			global $db, $database, $config;

			$sQuery = '';

			if (($searchType=='tag' || $searchType=='tag+group_category') && !Validator::is_empty($searchKeyword)) {		
				$tagIds = array();
				$tags = explode(',',$searchKeyword);

				if($tagResult = $db->queryAll('SELECT id FROM '.$database['prefix'].'Tags WHERE name IN ('.Func::implode_string(',',$tags).')')) {
					foreach($tagResult as $tagItem) array_push($tagIds, $tagItem['id']);
				}

				if (empty($tagIds)) {
					return array(null,0);
				} else {
					if($searchType == 'tag') {
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed")) WHERE r.tag IN ('.implode(',',$tagIds).')';
					} else if($searchType == 'tag+group_category') {
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND (r.type = "feed" || r.type = "group_category")) WHERE r.tag IN ('.implode(',',$tagIds).')';
					}
				}

			} else if ($searchType=='blogURL' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				$searchFeedId = $searchExtraValue;
				if(empty($searchFeedId)) {
					$searchFeedId = Feed::blogURL2Id('http://'.str_replace('http://', '', $searchKeyword));
				} 
				if(!empty($searchFeedId)) {
					$sQuery = ' WHERE i.feed = '.$searchFeedId;
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
				
			} else if ($searchType=='user' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				$searchFeedId = $searchExtraValue;
				if(empty($searchFeedId)) {

					if(is_numeric($searchKeyword)) {
						$user = User::getById($searchKeyword);
					} else {
						$user = User::getByloginId($searchKeyword);
					}		
					
					$searchFeedId = Feed::getIdListByOwner($user['id']);
				} 
				if(!empty($searchFeedId)) {
					$sQuery = ' WHERE i.feed IN ('.implode(",",$searchFeedId).')';
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
			} else if ($searchType=='author' && !Validator::is_empty($searchKeyword)){		
				$searchKeyword = UTF8::bring($searchKeyword);
				if(!empty($searchKeyword)) {
					$sQuery = ' WHERE i.author = "' . $searchKeyword . '"';
				} else {
					$sQuery = ' WHERE 1=0 ';
				}
			} else if ($searchType=='title+description' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.description LIKE "%'.$keyword.'%"';				
			}  else if ($searchType=='title' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.title LIKE "%'.$keyword.'%"';				
			} else if ($searchType=='description' && !Validator::is_empty($searchKeyword)){		
					$searchKeyword = UTF8::bring($searchKeyword);
					$keyword = $db->escape($searchKeyword);

					$sQuery =  ' WHERE i.description LIKE "%'.$keyword.'%"';				
			} else if ($searchType=='focus'){		
					$sQuery =  ' WHERE i.focus = "'.$searchKeyword.'"';		
			} else if ($searchType=='group') {
				requireComponent('Bloglounge.Data.Groups');	
				
				if(!empty($searchExtraValue)) {
					$tagId = $db->pick('SELECT id FROM '.$database['prefix'].'Tags WHERE name="'.$db->escape(urldecode($searchExtraValue)).'"');
					if($tagId) {
						$tagId = $tagId[0];
						$sQuery = ' LEFT JOIN '.$database['prefix'].'TagRelations r ON (r.item = i.id AND r.type = "group_category") ';
					}
				}

				if(!is_numeric($searchKeyword)) {
					$group = Group::getByName($searchKeyword);
					$searchKeyword = $group['id'];
				}
				
				if($searchKeyword) {	
					$feedIds = Group::getFeedIdList($searchKeyword);
					$sQuery .= ' WHERE i.feed IN (' . implode(',',$feedIds) .')';

					if($tagId) {
						$sQuery .= ' AND r.tag="'.$tagId.'"';
					}
//.........这里部分代码省略.........
开发者ID:ncloud,项目名称:bloglounge,代码行数:101,代码来源:Bloglounge.Data.FeedItems.php


注:本文中的UTF8::bring方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。