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


PHP StringUtil::isUTF8方法代码示例

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


在下文中一共展示了StringUtil::isUTF8方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseKeywords

 /**
  * Parses search keywords.
  * 
  * @param	string		$keywordString
  */
 protected function parseKeywords($keywordString)
 {
     // convert encoding if necessary
     if (!StringUtil::isUTF8($keywordString)) {
         $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
     }
     // remove bad wildcards
     $keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
     // remove search operators
     $keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
     if (mb_substr($keywordString, 0, 1) == '"' && mb_substr($keywordString, -1) == '"') {
         // phrases search
         $keywordString = StringUtil::trim(mb_substr($keywordString, 1, -1));
         if (!empty($keywordString)) {
             $this->keywords = array_merge($this->keywords, array(StringUtil::encodeHTML($keywordString)));
         }
     } else {
         // replace word delimiters by space
         $keywordString = str_replace(array('.', ','), ' ', $keywordString);
         $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
         if (!empty($keywords)) {
             $this->keywords = array_merge($this->keywords, $keywords);
         }
     }
 }
开发者ID:jacboy,项目名称:WCF,代码行数:30,代码来源:KeywordHighlighter.class.php

示例2: show

 /**
  * @see	\wcf\page\IPage::show()
  */
 public function show()
 {
     // check if active user is logged in
     if ($this->loginRequired && !WCF::getUser()->userID) {
         throw new PermissionDeniedException();
     }
     // check if current request URL matches the canonical URL
     if ($this->canonicalURL && empty($_POST)) {
         $canoncialURL = parse_url(preg_replace('~[?&]s=[a-f0-9]{40}~', '', $this->canonicalURL));
         // use $_SERVER['REQUEST_URI'] because it represents the URL used to access the site and not the internally rewritten one
         // IIS Rewrite-Module has a bug causing the REQUEST_URI to be ISO-encoded
         $requestURI = !empty($_SERVER['UNENCODED_URL']) ? $_SERVER['UNENCODED_URL'] : $_SERVER['REQUEST_URI'];
         $requestURI = preg_replace('~[?&]s=[a-f0-9]{40}~', '', $requestURI);
         if (!StringUtil::isUTF8($requestURI)) {
             $requestURI = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $requestURI);
         }
         // some webservers output lower-case encoding (e.g. %c3 instead of %C3)
         $requestURI = preg_replace_callback('~%(?P<encoded>[a-zA-Z0-9]{2})~', function ($matches) {
             return '%' . strtoupper($matches['encoded']);
         }, $requestURI);
         $requestURL = parse_url($requestURI);
         $redirect = false;
         if ($canoncialURL['path'] != $requestURL['path']) {
             $redirect = true;
         } else {
             if (isset($canoncialURL['query'])) {
                 if (!isset($requestURL['query'])) {
                     $redirect = true;
                 } else {
                     parse_str($canoncialURL['query'], $cQueryString);
                     parse_str($requestURL['query'], $rQueryString);
                     foreach ($cQueryString as $key => $value) {
                         if (!isset($rQueryString[$key]) || $rQueryString[$key] != $value) {
                             $redirect = true;
                             break;
                         }
                     }
                 }
             }
         }
         if ($redirect) {
             $redirectURL = $this->canonicalURL;
             if (!empty($requestURL['query'])) {
                 $queryString = $requestURL['query'];
                 parse_str($requestURL['query'], $rQueryString);
                 if (!empty($canoncialURL['query'])) {
                     parse_str($canoncialURL['query'], $cQueryString);
                     // clean query string
                     foreach ($cQueryString as $key => $value) {
                         if (isset($rQueryString[$key])) {
                             unset($rQueryString[$key]);
                         }
                     }
                 }
                 // drop route data from query
                 if (!URL_LEGACY_MODE) {
                     foreach ($rQueryString as $key => $value) {
                         if ($value === '') {
                             unset($rQueryString[$key]);
                         }
                     }
                 }
                 if (!empty($rQueryString)) {
                     $redirectURL .= (mb_strpos($redirectURL, '?') === false ? '?' : '&') . http_build_query($rQueryString, '', '&');
                 }
             }
             // force a permanent redirect as recommended by Google
             // https://support.google.com/webmasters/answer/6033086?hl=en#a_note_about_redirects
             @header('HTTP/1.0 301 Moved Permanently');
             HeaderUtil::redirect($redirectURL, false);
             exit;
         }
     }
     // sets the active menu item
     $this->setActiveMenuItem();
     // check modules
     $this->checkModules();
     // check permission
     $this->checkPermissions();
     // read data
     $this->readData();
     // assign variables
     $this->assignVariables();
     // call show event
     EventHandler::getInstance()->fireAction($this, 'show');
     // try to guess template name
     $classParts = explode('\\', get_class($this));
     if (empty($this->templateName)) {
         $className = preg_replace('~(Form|Page)$~', '', array_pop($classParts));
         // check if this an *Edit page and use the add-template instead
         if (substr($className, -4) == 'Edit') {
             $className = substr($className, 0, -4) . 'Add';
         }
         $this->templateName = lcfirst($className);
         // assign guessed template name
         WCF::getTPL()->assign('templateName', $this->templateName);
     }
//.........这里部分代码省略.........
开发者ID:nick-strohm,项目名称:WCF,代码行数:101,代码来源:AbstractPage.class.php

示例3: getRequestURI

 /**
  * Returns the URI of the current page.
  * 
  * @return	string
  */
 public static function getRequestURI()
 {
     if (URL_LEGACY_MODE) {
         // resolve path and query components
         $scriptName = $_SERVER['SCRIPT_NAME'];
         $pathInfo = RouteHandler::getPathInfo();
         if (empty($pathInfo)) {
             // bug fix if URL omits script name and path
             $scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
         }
         $path = str_replace('/index.php', '', str_replace($scriptName, '', $_SERVER['REQUEST_URI']));
         if (!StringUtil::isUTF8($path)) {
             $path = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $path);
         }
         $path = FileUtil::removeLeadingSlash($path);
         $baseHref = self::getTPL()->get('baseHref');
         if (!empty($path) && mb_strpos($path, '?') !== 0) {
             $baseHref .= 'index.php/';
         }
         return $baseHref . $path;
     } else {
         $url = preg_replace('~^(https?://[^/]+)(?:/.*)?$~', '$1', self::getTPL()->get('baseHref'));
         $url .= $_SERVER['REQUEST_URI'];
         return $url;
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:31,代码来源:WCF.class.php

示例4: getRequestURI

	/**
	 * Returns the request uri of the active request.
	 * 
	 * @return	string
	 */
	public static function getRequestURI() {
		$REQUEST_URI = '';
		
		$appendQueryString = true;
		if (!empty($_SERVER['ORIG_PATH_INFO']) && strpos($_SERVER['ORIG_PATH_INFO'], '.php') !== false) {
			$REQUEST_URI = $_SERVER['ORIG_PATH_INFO'];
		}
		else if (!empty($_SERVER['ORIG_SCRIPT_NAME'])) {
			$REQUEST_URI = $_SERVER['ORIG_SCRIPT_NAME'];
		}
		else if (!empty($_SERVER['SCRIPT_NAME']) && (isset($_SERVER['PATH_INFO']) && !empty($_SERVER['PATH_INFO']))) {
			$REQUEST_URI = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
		}
		else if (isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI'])) {
			$REQUEST_URI = $_SERVER['REQUEST_URI'];
			$appendQueryString = false;
		}
		else if (!empty($_SERVER['PHP_SELF'])) {
			$REQUEST_URI = $_SERVER['PHP_SELF'];
		}
		else if (!empty($_SERVER['PATH_INFO'])) {
			$REQUEST_URI = $_SERVER['PATH_INFO'];
		}
		if ($appendQueryString && !empty($_SERVER['QUERY_STRING'])) {
			$REQUEST_URI .= '?'.$_SERVER['QUERY_STRING'];
		}
		
		// fix encoding
		if (!StringUtil::isASCII($REQUEST_URI) && !StringUtil::isUTF8($REQUEST_URI)) {
			$REQUEST_URI = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $REQUEST_URI);
		}
		
		return StringUtil::substring(FileUtil::unifyDirSeperator($REQUEST_URI), 0, 255);
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:39,代码来源:UserUtil.class.php

示例5: getRequestURI

	/**
	 * Returns the URI of the current page.
	 *
	 * @return	string
	 */
	public static function getRequestURI() {
		// resolve path and query components
		$scriptName = $_SERVER['SCRIPT_NAME'];
		if (empty($_SERVER['PATH_INFO'])) {
			// bug fix if URL omits script name and path
			$scriptName = substr($scriptName, 0, strrpos($scriptName, '/'));
		}
		
		$path = str_replace('/index.php', '', str_replace($scriptName, '', $_SERVER['REQUEST_URI']));
		if (!StringUtil::isASCII($path) && !StringUtil::isUTF8($path)) {
			$path = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $path);
		}
		$path = FileUtil::removeLeadingSlash($path);
		$baseHref = self::getTPL()->get('baseHref');
		
		if (!empty($path) && StringUtil::indexOf($path, '?') !== 0) {
			$baseHref .= 'index.php/';
		}
		
		return $baseHref . $path;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:26,代码来源:WCF.class.php

示例6: drawText

	/**
	 * @see	wcf\system\image\adapter\IImageAdapter::drawText()
	 */
	public function drawText($string, $x, $y) {
		if (!StringUtil::isUTF8($string)) {
			throw new SystemException("Only UTF-8 encoded text can be written onto images"); // GD is buggy with UTF-8
		}
		
		// convert UTF-8 characters > 127 to their numeric representation, e.g. A -> &#65;
		$string = mb_encode_numericentity($string, array(0x0, 0xFFFF, 0, 0xFFF), 'UTF-8');
		
		imageString($this->image, 3, $x, $y, $string, $this->color);
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:13,代码来源:GDImageAdapter.class.php


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