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


PHP F3::checkRoute方法代码示例

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


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

示例1: received

 /**
 		Send HTTP/S request to another host; Forward headers received (if
 		QUIET variable is FALSE) and return content; Respect HTTP 30x
 		redirects if last argument is TRUE
 			@return mixed
 			@param $_pattern string
 			@param $_query string
 			@param $_reqhdrs array
 			@param $_follow boolean
 			@public
 	**/
 public static function http($_pattern, $_query = '', $_reqhdrs = array(), $_follow = TRUE)
 {
     // Check if valid route pattern
     list($_method, $_route) = F3::checkRoute($_pattern);
     // Valid URI pattern
     $_url = parse_url($_route);
     if (!$_url['path']) {
         // Set to Web root
         $_url['path'] = '/';
     }
     if ($_method != 'GET') {
         if ($_url['query']) {
             // Non-GET method; Query is distinct from URI
             $_query = $_url['query'];
             $_url['query'] = '';
         }
     } else {
         if ($_query) {
             // GET method; Query is integral part of URI
             $_url['query'] = $_query;
             $_query = '';
         }
     }
     // Set up host name and TCP port for socket connection
     if (preg_match('/https/', $_url['scheme'])) {
         if (!$_url['port']) {
             $_url['port'] = 443;
         }
         $_target = 'ssl://' . $_url['host'] . ':' . $_url['port'];
     } else {
         if (!$_url['port']) {
             $_url['port'] = 80;
         }
         $_target = $_url['host'] . ':' . $_url['port'];
     }
     $_socket = @fsockopen($_target, $_url['port'], $_errno, $_text);
     if (!$_socket) {
         // Can't establish connection
         trigger_error($_text);
         return FALSE;
     }
     // Send HTTP request
     fputs($_socket, $_method . ' ' . $_url['path'] . ($_url['query'] ? '?' . $_url['query'] : '') . ' ' . 'HTTP/1.0' . self::EOL . F3::HTTP_Host . ': ' . $_url['host'] . self::EOL . F3::HTTP_Agent . ': Mozilla/5.0 (' . 'compatible;' . F3::TEXT_Version . ')' . self::EOL . ($_reqhdrs ? implode(self::EOL, $_reqhdrs) . self::EOL : '') . ($_method != 'GET' ? 'Content-Type: ' . 'application/x-www-form-urlencoded' . self::EOL . 'Content-Length: ' . strlen($_query) . self::EOL : '') . F3::HTTP_AcceptEnc . ': deflate' . self::EOL . F3::HTTP_Connect . ': close' . self::EOL . self::EOL . $_query . self::EOL . self::EOL);
     $_found = FALSE;
     // Set connection timeout parameters
     stream_set_blocking($_socket, TRUE);
     stream_set_timeout($_socket, ini_get('default_socket_timeout'));
     $_info = stream_get_meta_data($_socket);
     // Get response
     while (!feof($_socket) && !$_info['timed_out']) {
         $_response .= fgets($_socket, 4096);
         // MDFK97
         $_info = stream_get_meta_data($_socket);
         if (!$_found) {
             $_rcvhdrs = strstr($_response, self::EOL . self::EOL, TRUE);
             if ($_rcvhdrs) {
                 $_found = TRUE;
                 // Split content from HTTP response headers
                 $_response = substr(strstr($_response, self::EOL . self::EOL), 4);
             }
         }
     }
     fclose($_socket);
     if ($_info['timed_out']) {
         trigger_error(self::TEXT_Timeout);
         return FALSE;
     }
     if ($_follow && preg_match('/HTTP\\/1\\.\\d\\s30\\d/', $_rcvhdrs)) {
         // Redirection
         preg_match('/' . F3::HTTP_Location . ':\\s(.+?)\\r\\n/', $_rcvhdrs, $_location);
         return self::http($_method . ' ' . $_location[1], $_query, $_reqhdrs);
     }
     if (PHP_SAPI != 'cli' && !headers_sent()) {
         // Forward HTTP response headers
         foreach (explode(self::EOL, $_rcvhdrs) as $_header) {
             F3::$global['HEADERS'][] = $_header;
             if (!F3::$global['QUIET'] && preg_match('/' . F3::HTTP_Content . '/', $_header)) {
                 header($_header);
             } elseif (preg_match('/' . F3::HTTP_Encoding . '.+deflate/', $_header)) {
                 $_response = gzuncompress($_response);
             }
         }
     }
     // Return content
     return $_response;
 }
开发者ID:seyyah,项目名称:f3kulmysql,代码行数:97,代码来源:expansion.php

示例2: received

 /**
 		Send HTTP/S request to another host; Forward headers received (if
 		QUIET variable is FALSE) and return content; Respect HTTP 30x
 		redirects if last argument is TRUE
 			@return mixed
 			@param $_pattern string
 			@param $_query string
 			@param $_reqhdrs array
 			@param $_follow boolean
 			@public
 	**/
 public static function http($_pattern, $_query = '', $_reqhdrs = array(), $_follow = TRUE)
 {
     // Check if valid route pattern
     list($_method, $_route) = F3::checkRoute($_pattern);
     // Content divider
     $_div = chr(0);
     // Determine if page is in cache
     $_hash = 'url.' . F3::hashCode($_pattern);
     $_cached = Cache::cached($_hash);
     if ($_cached) {
         // Retrieve from cache
         $_buffer = Cache::fetch($_hash);
         $_rcvhdrs = strstr($_buffer, $_div, TRUE);
         $_response = substr(strstr($_buffer, $_div), 1);
         // Find out if cache is stale
         $_expires = NULL;
         foreach (explode(self::EOL, $_rcvhdrs) as $_hdr) {
             if (preg_match('/^' . F3::HTTP_Expires . ':(.+)/', $_hdr, $_match)) {
                 $_expires = strtotime($_match[1]);
                 break;
             }
         }
         if (!is_null($_expires) && time() < $_expires) {
             // Cached page is still fresh
             foreach (explode(self::EOL, $_rcvhdrs) as $_hdr) {
                 F3::$global['HEADERS'][] = $_hdr;
                 if (preg_match('/' . F3::HTTP_Content . '/', $_hdr)) {
                     // Forward HTTP header
                     header($_hdr);
                 }
             }
             return $_response;
         }
     }
     $_url = parse_url($_route);
     if (!$_url['path']) {
         // Set to Web root
         $_url['path'] = '/';
     }
     if ($_method != 'GET') {
         if ($_url['query']) {
             // Non-GET method; Query is distinct from URI
             $_query = $_url['query'];
             $_url['query'] = '';
         }
     } else {
         if ($_query) {
             // GET method; Query is integral part of URI
             $_url['query'] = $_query;
             $_query = '';
         }
     }
     // Set up host name and TCP port for socket connection
     if (preg_match('/https/', $_url['scheme'])) {
         if (!$_url['port']) {
             $_url['port'] = 443;
         }
         $_target = 'ssl://' . $_url['host'] . ':' . $_url['port'];
     } else {
         if (!$_url['port']) {
             $_url['port'] = 80;
         }
         $_target = $_url['host'] . ':' . $_url['port'];
     }
     $_socket = @fsockopen($_target, $_url['port'], $_errno, $_text);
     if (!$_socket) {
         // Can't establish connection
         trigger_error($_text);
         return FALSE;
     }
     // Send HTTP request
     fputs($_socket, $_method . ' ' . $_url['path'] . ($_url['query'] ? '?' . $_url['query'] : '') . ' ' . 'HTTP/1.0' . self::EOL . F3::HTTP_Host . ': ' . $_url['host'] . self::EOL . F3::HTTP_Agent . ': Mozilla/5.0 (' . 'compatible;' . F3::TEXT_AppName . ' ' . F3::TEXT_Version . ')' . self::EOL . ($_reqhdrs ? implode(self::EOL, $_reqhdrs) . self::EOL : '') . ($_method != 'GET' ? 'Content-Type: ' . 'application/x-www-form-urlencoded' . self::EOL . 'Content-Length: ' . strlen($_query) . self::EOL : '') . F3::HTTP_AcceptEnc . ': gzip' . self::EOL . ($_cached ? F3::HTTP_Cache . ': max-age=86400' . self::EOL : '') . F3::HTTP_Connect . ': close' . self::EOL . self::EOL . $_query . self::EOL . self::EOL);
     $_found = FALSE;
     $_expires = FALSE;
     $_gzip = FALSE;
     // Set connection timeout parameters
     stream_set_blocking($_socket, TRUE);
     stream_set_timeout($_socket, ini_get('default_socket_timeout'));
     $_info = stream_get_meta_data($_socket);
     // Get headers and response
     while (!feof($_socket) && !$_info['timed_out']) {
         $_response .= fgets($_socket, 4096);
         // MDFK97
         $_info = stream_get_meta_data($_socket);
         if (!$_found) {
             $_rcvhdrs = strstr($_response, self::EOL . self::EOL, TRUE);
             if ($_rcvhdrs) {
                 $_found = TRUE;
                 if (PHP_SAPI != 'cli' && !headers_sent()) {
//.........这里部分代码省略.........
开发者ID:seyyah,项目名称:f3kayOLD,代码行数:101,代码来源:expansion.php


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