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


PHP Strings::fixEncoding方法代码示例

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


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

示例1: __construct

 /**
  * Song constructor.
  * @param string $name
  * @param string $location
  * @param string $path
  * @param string $albumCover
  * @param string $artist
  * @param string $title
  * @param string $duration
  */
 public function __construct(string $name, string $location, string $path, string $albumCover, string $artist, string $title, string $duration)
 {
     $this->name = \Nette\Utils\Strings::fixEncoding($name);
     $this->location = $location;
     $this->albumCover = $albumCover;
     $this->author = $artist;
     $this->title = $title;
     $this->duration = $duration;
 }
开发者ID:ParalelniPolis,项目名称:bitcoinJukebox,代码行数:19,代码来源:Song.php

示例2: fetchSubtitles

 protected function fetchSubtitles($youtubeId, $cached)
 {
     $url = "https://report.khanovaskola.cz/api/1/subtitles/{$youtubeId}/cs" . ($cached ? '?cached=1' : '');
     $res = @file_get_contents($url);
     // was failing randomly
     if (!$res) {
         return NULL;
     }
     if ($cached) {
         $headers = $http_response_header;
         if (strpos($headers[0], 'HTTP/1.1 304') !== FALSE) {
             return $cached;
         }
     }
     $data = json_decode($res);
     if ($data->found) {
         return Strings::normalize(Strings::fixEncoding($data->subtitles));
     }
     return NULL;
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:20,代码来源:RemoteSubtitles.php

示例3: to

 /**
  * @param string $name
  * @param NULL|string $gender
  * @return bool|string
  */
 public function to($name, $gender = NULL)
 {
     $name = Strings::fixEncoding($name);
     $name = Strings::trim($name);
     $name = Strings::lower($name);
     $url = self::API_URL . '?name=' . urlencode($name);
     if ($this->type !== NULL) {
         $url .= '&type=' . urlencode($this->type);
     }
     if ($gender !== NULL) {
         $url .= '&gender=' . urlencode($gender);
     }
     return $this->cache->load($url, function ($dependencies) use($url) {
         $data = $this->simpleCurl->get($url);
         $json = self::parseJson($data);
         $result = $json->success ? $json->results[0] : FALSE;
         $this->cache->save($url, $result, $dependencies);
         return $result;
     });
 }
开发者ID:ondrs,项目名称:hi,代码行数:25,代码来源:Hi.php

示例4: createHttpRequest

 /**
  * Creates current HttpRequest object.
  * @return Request
  */
 public function createHttpRequest()
 {
     // DETECTS URI, base path and script path of the request.
     $url = new UrlScript();
     $url->scheme = !empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https' : 'http';
     $url->user = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '';
     $url->password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '';
     // host & port
     if ((isset($_SERVER[$tmp = 'HTTP_HOST']) || isset($_SERVER[$tmp = 'SERVER_NAME'])) && preg_match('#^([a-z0-9_.-]+|\\[[a-fA-F0-9:]+\\])(:\\d+)?\\z#', $_SERVER[$tmp], $pair)) {
         $url->host = strtolower($pair[1]);
         if (isset($pair[2])) {
             $url->port = (int) substr($pair[2], 1);
         } elseif (isset($_SERVER['SERVER_PORT'])) {
             $url->port = (int) $_SERVER['SERVER_PORT'];
         }
     }
     // path & query
     if (isset($_SERVER['REQUEST_URI'])) {
         // Apache, IIS 6.0
         $requestUrl = $_SERVER['REQUEST_URI'];
     } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
         // IIS 5.0 (PHP as CGI ?)
         $requestUrl = $_SERVER['ORIG_PATH_INFO'];
         if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') {
             $requestUrl .= '?' . $_SERVER['QUERY_STRING'];
         }
     } else {
         $requestUrl = '';
     }
     $requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']);
     $tmp = explode('?', $requestUrl, 2);
     $url->path = Strings::replace($tmp[0], $this->urlFilters['path']);
     $url->query = isset($tmp[1]) ? $tmp[1] : '';
     // normalized url
     $url->canonicalize();
     $url->path = Strings::fixEncoding($url->path);
     // detect script path
     if (isset($_SERVER['SCRIPT_NAME'])) {
         $script = $_SERVER['SCRIPT_NAME'];
     } elseif (isset($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_FILENAME']) && strncmp($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])) === 0) {
         $script = '/' . ltrim(strtr(substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])), '\\', '/'), '/');
     } else {
         $script = '/';
     }
     $path = strtolower($url->path) . '/';
     $script = strtolower($script) . '/';
     $max = min(strlen($path), strlen($script));
     for ($i = 0; $i < $max; $i++) {
         if ($path[$i] !== $script[$i]) {
             break;
         } elseif ($path[$i] === '/') {
             $url->scriptPath = substr($url->path, 0, $i + 1);
         }
     }
     // GET, POST, COOKIE
     $useFilter = !in_array(ini_get('filter.default'), array('', 'unsafe_raw')) || ini_get('filter.default_flags');
     parse_str($url->query, $query);
     if (!$query) {
         $query = $useFilter ? filter_input_array(INPUT_GET, FILTER_UNSAFE_RAW) : (empty($_GET) ? array() : $_GET);
     }
     $post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST);
     $cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE);
     $gpc = (bool) get_magic_quotes_gpc();
     $old = error_reporting(error_reporting() ^ E_NOTICE);
     // remove fucking quotes and check (and optionally convert) encoding
     if ($gpc || $this->encoding) {
         $utf = strcasecmp($this->encoding, 'UTF-8') === 0;
         $list = array(&$query, &$post, &$cookies);
         while (list($key, $val) = each($list)) {
             foreach ($val as $k => $v) {
                 unset($list[$key][$k]);
                 if ($gpc) {
                     $k = stripslashes($k);
                 }
                 if ($this->encoding && is_string($k) && (preg_match(self::NONCHARS, $k) || preg_last_error())) {
                     // invalid key -> ignore
                 } elseif (is_array($v)) {
                     $list[$key][$k] = $v;
                     $list[] =& $list[$key][$k];
                 } else {
                     if ($gpc && !$useFilter) {
                         $v = stripSlashes($v);
                     }
                     if ($this->encoding) {
                         if ($utf) {
                             $v = Strings::fixEncoding($v);
                         } else {
                             if (!Strings::checkEncoding($v)) {
                                 $v = iconv($this->encoding, 'UTF-8//IGNORE', $v);
                             }
                             $v = html_entity_decode($v, ENT_QUOTES, 'UTF-8');
                         }
                         $v = preg_replace(self::NONCHARS, '', $v);
                     }
                     $list[$key][$k] = $v;
                 }
//.........这里部分代码省略.........
开发者ID:svobodni,项目名称:web,代码行数:101,代码来源:RequestFactory.php

示例5: createAttachment

 /**
  * Creates file MIME part.
  * @return MimePart
  */
 private function createAttachment($file, $content, $contentType, $disposition)
 {
     $part = new MimePart();
     if ($content === NULL) {
         $content = @file_get_contents($file);
         // intentionally @
         if ($content === FALSE) {
             throw new Nette\FileNotFoundException("Unable to read file '{$file}'.");
         }
     } else {
         $content = (string) $content;
     }
     $part->setBody($content);
     $part->setContentType($contentType ? $contentType : finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content));
     $part->setEncoding(preg_match('#(multipart|message)/#A', $contentType) ? self::ENCODING_8BIT : self::ENCODING_BASE64);
     $part->setHeader('Content-Disposition', $disposition . '; filename="' . Strings::fixEncoding(basename($file)) . '"');
     return $part;
 }
开发者ID:norik16,项目名称:TripMap,代码行数:22,代码来源:Message.php

示例6: createHttpRequest

 /**
  * Creates current HttpRequest object.
  * @return Request
  */
 public function createHttpRequest()
 {
     // DETECTS URI, base path and script path of the request.
     $url = new UrlScript();
     $url->setScheme(!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https' : 'http');
     $url->setUser(isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '');
     $url->setPassword(isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '');
     // host & port
     if ((isset($_SERVER[$tmp = 'HTTP_HOST']) || isset($_SERVER[$tmp = 'SERVER_NAME'])) && preg_match('#^([a-z0-9_.-]+|\\[[a-f0-9:]+\\])(:\\d+)?\\z#i', $_SERVER[$tmp], $pair)) {
         $url->setHost(strtolower($pair[1]));
         if (isset($pair[2])) {
             $url->setPort(substr($pair[2], 1));
         } elseif (isset($_SERVER['SERVER_PORT'])) {
             $url->setPort($_SERVER['SERVER_PORT']);
         }
     }
     // path & query
     if (isset($_SERVER['REQUEST_URI'])) {
         // Apache, IIS 6.0
         $requestUrl = $_SERVER['REQUEST_URI'];
     } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
         // IIS 5.0 (PHP as CGI ?)
         $requestUrl = $_SERVER['ORIG_PATH_INFO'];
         if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') {
             $requestUrl .= '?' . $_SERVER['QUERY_STRING'];
         }
     } else {
         $requestUrl = '';
     }
     $requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']);
     $tmp = explode('?', $requestUrl, 2);
     $url->setPath(Strings::replace($tmp[0], $this->urlFilters['path']));
     $url->setQuery(isset($tmp[1]) ? $tmp[1] : '');
     // normalized url
     $url->canonicalize();
     $url->setPath(Strings::fixEncoding($url->getPath()));
     // detect script path
     if (isset($_SERVER['SCRIPT_NAME'])) {
         $script = $_SERVER['SCRIPT_NAME'];
     } elseif (isset($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_FILENAME']) && strncmp($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])) === 0) {
         $script = '/' . ltrim(strtr(substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])), '\\', '/'), '/');
     } else {
         $script = '/';
     }
     $path = strtolower($url->getPath()) . '/';
     $script = strtolower($script) . '/';
     $max = min(strlen($path), strlen($script));
     for ($i = 0; $i < $max; $i++) {
         if ($path[$i] !== $script[$i]) {
             break;
         } elseif ($path[$i] === '/') {
             $url->setScriptPath(substr($url->getPath(), 0, $i + 1));
         }
     }
     // GET, POST, COOKIE
     $useFilter = !in_array(ini_get('filter.default'), array('', 'unsafe_raw')) || ini_get('filter.default_flags');
     parse_str($url->getQuery(), $query);
     if (!$query) {
         $query = $useFilter ? filter_input_array(INPUT_GET, FILTER_UNSAFE_RAW) : (empty($_GET) ? array() : $_GET);
     }
     $post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST);
     $cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE);
     $gpc = (bool) get_magic_quotes_gpc();
     // remove fucking quotes, control characters and check encoding
     if ($gpc || !$this->binary) {
         $list = array(&$query, &$post, &$cookies);
         while (list($key, $val) = each($list)) {
             foreach ($val as $k => $v) {
                 unset($list[$key][$k]);
                 if ($gpc) {
                     $k = stripslashes($k);
                 }
                 if (!$this->binary && is_string($k) && (!preg_match(self::CHARS, $k) || preg_last_error())) {
                     // invalid key -> ignore
                 } elseif (is_array($v)) {
                     $list[$key][$k] = $v;
                     $list[] =& $list[$key][$k];
                 } else {
                     if ($gpc && !$useFilter) {
                         $v = stripSlashes($v);
                     }
                     if (!$this->binary && (!preg_match(self::CHARS, $v) || preg_last_error())) {
                         $v = '';
                     }
                     $list[$key][$k] = $v;
                 }
             }
         }
         unset($list, $key, $val, $k, $v);
     }
     // FILES and create FileUpload objects
     $files = array();
     $list = array();
     if (!empty($_FILES)) {
         foreach ($_FILES as $k => $v) {
             if (!$this->binary && is_string($k) && (!preg_match(self::CHARS, $k) || preg_last_error())) {
//.........这里部分代码省略.........
开发者ID:romanvlcek,项目名称:wifimap,代码行数:101,代码来源:RequestFactory.php

示例7: createHttpRequest

 /**
  * Creates current HttpRequest object.
  * @return Request
  */
 public function createHttpRequest()
 {
     // DETECTS URI, base path and script path of the request.
     $url = new UrlScript();
     $url->setScheme(!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https' : 'http');
     $url->setUser(isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '');
     $url->setPassword(isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '');
     // host & port
     if ((isset($_SERVER[$tmp = 'HTTP_HOST']) || isset($_SERVER[$tmp = 'SERVER_NAME'])) && preg_match('#^([a-z0-9_.-]+|\\[[a-f0-9:]+\\])(:\\d+)?\\z#i', $_SERVER[$tmp], $pair)) {
         $url->setHost(strtolower($pair[1]));
         if (isset($pair[2])) {
             $url->setPort(substr($pair[2], 1));
         } elseif (isset($_SERVER['SERVER_PORT'])) {
             $url->setPort($_SERVER['SERVER_PORT']);
         }
     }
     // path & query
     $requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
     $requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']);
     $tmp = explode('?', $requestUrl, 2);
     $path = Url::unescape($tmp[0], '%/?#');
     $path = Strings::fixEncoding(Strings::replace($path, $this->urlFilters['path']));
     $url->setPath($path);
     $url->setQuery(isset($tmp[1]) ? $tmp[1] : '');
     // detect script path
     $lpath = strtolower($path);
     $script = isset($_SERVER['SCRIPT_NAME']) ? strtolower($_SERVER['SCRIPT_NAME']) : '';
     if ($lpath !== $script) {
         $max = min(strlen($lpath), strlen($script));
         for ($i = 0; $i < $max && $lpath[$i] === $script[$i]; $i++) {
         }
         $path = $i ? substr($path, 0, strrpos($path, '/', $i - strlen($path) - 1) + 1) : '/';
     }
     $url->setScriptPath($path);
     // GET, POST, COOKIE
     $useFilter = !in_array(ini_get('filter.default'), array('', 'unsafe_raw')) || ini_get('filter.default_flags');
     $query = $url->getQueryParameters();
     $post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? array() : $_POST);
     $cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? array() : $_COOKIE);
     if (get_magic_quotes_gpc()) {
         $post = Helpers::stripslashes($post, $useFilter);
         $cookies = Helpers::stripslashes($cookies, $useFilter);
     }
     // remove invalid characters
     $reChars = '#^[' . self::CHARS . ']*+\\z#u';
     if (!$this->binary) {
         $list = array(&$query, &$post, &$cookies);
         while (list($key, $val) = each($list)) {
             foreach ($val as $k => $v) {
                 if (is_string($k) && (!preg_match($reChars, $k) || preg_last_error())) {
                     unset($list[$key][$k]);
                 } elseif (is_array($v)) {
                     $list[$key][$k] = $v;
                     $list[] =& $list[$key][$k];
                 } else {
                     $list[$key][$k] = (string) preg_replace('#[^' . self::CHARS . ']+#u', '', $v);
                 }
             }
         }
         unset($list, $key, $val, $k, $v);
     }
     $url->setQuery($query);
     // FILES and create FileUpload objects
     $files = array();
     $list = array();
     if (!empty($_FILES)) {
         foreach ($_FILES as $k => $v) {
             if (!$this->binary && is_string($k) && (!preg_match($reChars, $k) || preg_last_error())) {
                 continue;
             }
             $v['@'] =& $files[$k];
             $list[] = $v;
         }
     }
     while (list(, $v) = each($list)) {
         if (!isset($v['name'])) {
             continue;
         } elseif (!is_array($v['name'])) {
             if (get_magic_quotes_gpc()) {
                 $v['name'] = stripSlashes($v['name']);
             }
             if (!$this->binary && (!preg_match($reChars, $v['name']) || preg_last_error())) {
                 $v['name'] = '';
             }
             if ($v['error'] !== UPLOAD_ERR_NO_FILE) {
                 $v['@'] = new FileUpload($v);
             }
             continue;
         }
         foreach ($v['name'] as $k => $foo) {
             if (!$this->binary && is_string($k) && (!preg_match($reChars, $k) || preg_last_error())) {
                 continue;
             }
             $list[] = array('name' => $v['name'][$k], 'type' => $v['type'][$k], 'size' => $v['size'][$k], 'tmp_name' => $v['tmp_name'][$k], 'error' => $v['error'][$k], '@' => &$v['@'][$k]);
         }
     }
//.........这里部分代码省略.........
开发者ID:re1la2pse,项目名称:GromesProjekt,代码行数:101,代码来源:RequestFactory.php

示例8: createAttachment

 /**
  * @param $file
  * @param $content
  * @param $contentType
  * @param $disposition
  * @return array
  * @throws FileNotFoundException
  */
 private function createAttachment($file, $content, $contentType, $disposition)
 {
     if ($content === NULL) {
         $content = @file_get_contents($file);
         if ($content === FALSE) {
             throw new FileNotFoundException("Unable to read file '{$file}'.");
         }
     } else {
         $content = (string) $content;
     }
     $attachment = array('type' => $contentType ? $contentType : MimeTypeDetector::fromString($content), 'name' => Strings::fixEncoding(basename($file)), 'content' => rtrim(chunk_split(base64_encode($content), self::LINE_LENGTH, self::EOL)));
     return $attachment;
 }
开发者ID:nasext,项目名称:mandrill,代码行数:21,代码来源:MandrillMessage.php

示例9: jsonDump

 /**
  * Dump implementation for JSON.
  *
  * @param  mixed  variable to dump
  * @param  int    current recursion level
  *
  * @return string
  */
 private static function jsonDump(&$var, $level = 0)
 {
     if (is_bool($var) || is_null($var) || is_int($var) || is_float($var)) {
         return $var;
     } elseif (is_string($var)) {
         if (Debugger::$maxLen && strlen($var) > Debugger::$maxLen) {
             $var = substr($var, 0, Debugger::$maxLen) . " … ";
         }
         return Nette\Utils\Strings::fixEncoding($var);
     } elseif (is_array($var)) {
         static $marker;
         if ($marker === null) {
             $marker = uniqid("", true);
         }
         if (isset($var[$marker])) {
             return "…RECURSION…";
         } elseif ($level < Debugger::$maxDepth || !Debugger::$maxDepth) {
             $var[$marker] = true;
             $res = array();
             foreach ($var as $k => &$v) {
                 if ($k !== $marker) {
                     $res[self::jsonDump($k)] = self::jsonDump($v, $level + 1);
                 }
             }
             unset($var[$marker]);
             return $res;
         } else {
             return " … ";
         }
     } elseif (is_object($var)) {
         $arr = (array) $var;
         static $list = array();
         if (in_array($var, $list, true)) {
             return "…RECURSION…";
         } elseif ($level < Debugger::$maxDepth || !Debugger::$maxDepth) {
             $list[] = $var;
             $res = array("" => '(object) ' . get_class($var));
             foreach ($arr as $k => &$v) {
                 if ($k[0] === "") {
                     $k = substr($k, strrpos($k, "") + 1);
                 }
                 $res[self::jsonDump($k)] = self::jsonDump($v, $level + 1);
             }
             array_pop($list);
             return $res;
         } else {
             return " … ";
         }
     } elseif (is_resource($var)) {
         return "resource " . get_resource_type($var);
     } else {
         return "unknown type";
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:62,代码来源:FireLogger.php

示例10: createPostDigestExcerpt

 /**
  * Digest helper
  *
  * @param $postContent
  * @param int $length
  * @return string
  */
 public function createPostDigestExcerpt($postContent, $length = 135)
 {
     $postContent = strip_tags(strip_shortcodes($postContent));
     $postContent = \Nette\Utils\Strings::fixEncoding($postContent);
     return \Nette\Utils\Strings::truncate($postContent, $length);
 }
开发者ID:ntamvl,项目名称:planningelegance,代码行数:13,代码来源:Email.php

示例11: createAttachment

 /**
  * Creates file MIME part.
  *
  * @return MimePart
  */
 private function createAttachment($file, $content, $contentType, $disposition)
 {
     $part = new MimePart();
     if ($content === null) {
         $content = file_get_contents($file);
         if ($content === false) {
             throw new Nette\FileNotFoundException("Unable to read file '{$file}'.");
         }
     } else {
         $content = (string) $content;
     }
     $part->setBody($content);
     $part->setContentType($contentType ? $contentType : Nette\Utils\MimeTypeDetector::fromString($content));
     $part->setEncoding(preg_match('#(multipart|message)/#A', $contentType) ? self::ENCODING_8BIT : self::ENCODING_BASE64);
     $part->setHeader('Content-Disposition', $disposition . '; filename="' . Strings::fixEncoding(basename($file)) . '"');
     return $part;
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:22,代码来源:Message.php

示例12: createHttpRequest

 /**
  * Creates current HttpRequest object.
  * @return Request
  */
 public function createHttpRequest()
 {
     // DETECTS URI, base path and script path of the request.
     $url = new UrlScript();
     $url->setScheme(!empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off') ? 'https' : 'http');
     $url->setUser(isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '');
     $url->setPassword(isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '');
     // host & port
     if ((isset($_SERVER[$tmp = 'HTTP_HOST']) || isset($_SERVER[$tmp = 'SERVER_NAME'])) && preg_match('#^([a-z0-9_.-]+|\\[[a-f0-9:]+\\])(:\\d+)?\\z#i', $_SERVER[$tmp], $pair)) {
         $url->setHost(strtolower($pair[1]));
         if (isset($pair[2])) {
             $url->setPort((int) substr($pair[2], 1));
         } elseif (isset($_SERVER['SERVER_PORT'])) {
             $url->setPort((int) $_SERVER['SERVER_PORT']);
         }
     }
     // path & query
     $requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
     $requestUrl = preg_replace('#^\\w++://[^/]++#', '', $requestUrl);
     $requestUrl = Strings::replace($requestUrl, $this->urlFilters['url']);
     $tmp = explode('?', $requestUrl, 2);
     $path = Url::unescape($tmp[0], '%/?#');
     $path = Strings::fixEncoding(Strings::replace($path, $this->urlFilters['path']));
     $url->setPath($path);
     $url->setQuery(isset($tmp[1]) ? $tmp[1] : '');
     // detect script path
     $lpath = strtolower($path);
     $script = isset($_SERVER['SCRIPT_NAME']) ? strtolower($_SERVER['SCRIPT_NAME']) : '';
     if ($lpath !== $script) {
         $max = min(strlen($lpath), strlen($script));
         for ($i = 0; $i < $max && $lpath[$i] === $script[$i]; $i++) {
         }
         $path = $i ? substr($path, 0, strrpos($path, '/', $i - strlen($path) - 1) + 1) : '/';
     }
     $url->setScriptPath($path);
     // GET, POST, COOKIE
     $useFilter = !in_array(ini_get('filter.default'), ['', 'unsafe_raw']) || ini_get('filter.default_flags');
     $query = $url->getQueryParameters();
     $post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? [] : $_POST);
     $cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? [] : $_COOKIE);
     // remove invalid characters
     $reChars = '#^[' . self::CHARS . ']*+\\z#u';
     if (!$this->binary) {
         $list = [&$query, &$post, &$cookies];
         while (list($key, $val) = each($list)) {
             foreach ($val as $k => $v) {
                 if (is_string($k) && (!preg_match($reChars, $k) || preg_last_error())) {
                     unset($list[$key][$k]);
                 } elseif (is_array($v)) {
                     $list[$key][$k] = $v;
                     $list[] =& $list[$key][$k];
                 } else {
                     $list[$key][$k] = (string) preg_replace('#[^' . self::CHARS . ']+#u', '', $v);
                 }
             }
         }
         unset($list, $key, $val, $k, $v);
     }
     $url->setQuery($query);
     // FILES and create FileUpload objects
     $files = [];
     $list = [];
     if (!empty($_FILES)) {
         foreach ($_FILES as $k => $v) {
             if (!$this->binary && is_string($k) && (!preg_match($reChars, $k) || preg_last_error())) {
                 continue;
             }
             $v['@'] =& $files[$k];
             $list[] = $v;
         }
     }
     while (list(, $v) = each($list)) {
         if (!isset($v['name'])) {
             continue;
         } elseif (!is_array($v['name'])) {
             if (!$this->binary && (!preg_match($reChars, $v['name']) || preg_last_error())) {
                 $v['name'] = '';
             }
             if ($v['error'] !== UPLOAD_ERR_NO_FILE) {
                 $v['@'] = new FileUpload($v);
             }
             continue;
         }
         foreach ($v['name'] as $k => $foo) {
             if (!$this->binary && is_string($k) && (!preg_match($reChars, $k) || preg_last_error())) {
                 continue;
             }
             $list[] = ['name' => $v['name'][$k], 'type' => $v['type'][$k], 'size' => $v['size'][$k], 'tmp_name' => $v['tmp_name'][$k], 'error' => $v['error'][$k], '@' => &$v['@'][$k]];
         }
     }
     // HEADERS
     if (function_exists('apache_request_headers')) {
         $headers = apache_request_headers();
     } else {
         $headers = [];
         foreach ($_SERVER as $k => $v) {
//.........这里部分代码省略.........
开发者ID:slevomat,项目名称:http,代码行数:101,代码来源:RequestFactory.php

示例13: flashError

 private function flashError()
 {
     $message = $this->getMessageFail();
     if ($this->getShowDetails()) {
         $errors = $this->getErrorMessages();
         $message .= Strings::fixEncoding(empty($errors) ? '' : ' (' . implode(', ', $errors) . ')');
     }
     $this->presenter->flashMessage($message, 'danger');
 }
开发者ID:miloshavlicek,项目名称:usertask,代码行数:9,代码来源:UserTask.php

示例14: getEntityCache

 /**
  * @return \Nette\Caching\Cache
  */
 protected function getEntityCache()
 {
     if (!isset($this->entityCache)) {
         $this->entityCache = new Cache($this->cacheStorage, Strings::fixEncoding($this->getClassName() . "/" . $this->getEntityClassName()));
     }
     return $this->entityCache;
 }
开发者ID:fuca,项目名称:sportsclub,代码行数:10,代码来源:BaseService.php

示例15: getColsNamesInCsv

 /**
  * Funkce vracející počet řádků v CSV souboru
  * @param string $filename
  * @param string $delimiter = ','
  * @param string $enclosure  = '"'
  * @param string $escapeCharacter = '\\'
  * @return string[]
  */
 public static function getColsNamesInCsv($filename, $delimiter = ',', $enclosure = '"', $escapeCharacter = '\\')
 {
     $columnNames = self::getRowsFromCSV($filename, 1, $delimiter, $enclosure, $escapeCharacter, null, 0)[0];
     for ($i = count($columnNames) - 1; $i >= 0; $i--) {
         if (Strings::trim(Strings::fixEncoding($columnNames[$i])) == '') {
             unset($columnNames[$i]);
         }
     }
     return $columnNames;
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:18,代码来源:CsvImport.php


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