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


PHP CacheManager::getTree方法代码示例

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


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

示例1: custom

 /**
  * performs a custom request
  *
  * @param string $method the request type (POST, DELETE, PUT, GET, ...) 
  * @param string $target the taget URL
  * @param string $header an array with header informations
  * @param string $content the request content/body
  *
  * @return an array with the request result (status, header, content)
  * - ['headers'] = an array of header informations e.g. ['headers']['Content-Type']
  * - ['content'] = the response content
  * - ['status'] = the status code e.g. 200,201,404,409,...
  */
 public static function custom($method, $target, $header, $content, $authbool = true, $sessiondelete = false)
 {
     $begin = microtime(true);
     $done = false;
     if (!CConfig::$onload && strpos($target, 'http://localhost/') === 0 && file_exists(dirname(__FILE__) . '/request_cconfig.json')) {
         if (self::$components === null) {
             self::$components = CConfig::loadStaticConfig('', '', dirname(__FILE__), 'request_cconfig.json');
         }
         $coms = self::$components->getLinks();
         if ($coms != null) {
             if (!is_array($coms)) {
                 $coms = array($coms);
             }
             $e = strlen(rtrim($_SERVER['DOCUMENT_ROOT'], '/'));
             $f = substr(str_replace("\\", "/", dirname(__FILE__)), $e);
             $g = substr(str_replace("\\", "/", $_SERVER['SCRIPT_FILENAME']), $e);
             $a = 0;
             for (; $a < strlen($g) && $a < strlen($f) && $f[$a] == $g[$a]; $a++) {
             }
             $h = substr(str_replace("\\", "/", $_SERVER['PHP_SELF']), 0, $a - 1);
             foreach ($coms as $com) {
                 if ($com->getPrefix() === null || $com->getLocalPath() == null || $com->getClassFile() == null || $com->getClassName() == null) {
                     Logger::Log('nodata: ' . $method . ' ' . $target, LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
                     continue;
                 }
                 $url = 'http://localhost' . $h . '/' . $com->getLocalPath();
                 if (strpos($target, $url . '/') === 0) {
                     $result = array();
                     $tar = dirname(__FILE__) . '/../' . $com->getLocalPath() . '/' . $com->getClassFile();
                     $tar = str_replace("\\", "/", $tar);
                     if (!file_exists($tar)) {
                         continue;
                     }
                     $add = substr($target, strlen($url));
                     $sid = CacheManager::getNextSid();
                     CacheManager::getTree($sid, $target, $method);
                     $cachedData = CacheManager::getCachedDataByURL($sid, $target, $method);
                     if ($cachedData !== null) {
                         $result['content'] = $cachedData->content;
                         $result['status'] = $cachedData->status;
                         ///Logger::Log('out>> '.$method.' '.$target, LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
                         CacheManager::cacheData($sid, $com->getTargetName(), $target, $result['content'], $result['status'], $method);
                     } else {
                         $args = array('REQUEST_METHOD' => $method, 'PATH_INFO' => $add, 'slim.input' => $content);
                         if (isset($_SERVER['HTTP_SESSION'])) {
                             $args['HTTP_SESSION'] = $_SERVER['HTTP_SESSION'];
                         }
                         if (isset($_SERVER['HTTP_USER'])) {
                             $args['HTTP_USER'] = $_SERVER['HTTP_USER'];
                         }
                         if ($authbool) {
                             if (isset($_SESSION['UID'])) {
                                 $args['HTTP_USER'] = $_SESSION['UID'];
                                 $_SERVER['HTTP_USER'] = $_SESSION['UID'];
                             }
                             if (isset($_SESSION['SESSION'])) {
                                 $args['HTTP_SESSION'] = $_SESSION['SESSION'];
                                 $_SERVER['HTTP_SESSION'] = $_SESSION['SESSION'];
                             }
                             if ($sessiondelete) {
                                 if (isset($_SERVER['REQUEST_TIME'])) {
                                     $args['HTTP_DATE'] = $_SERVER['REQUEST_TIME'];
                                     $_SERVER['HTTP_DATE'] = $_SERVER['REQUEST_TIME'];
                                 }
                             } else {
                                 if (isset($_SESSION['LASTACTIVE'])) {
                                     $args['HTTP_DATE'] = $_SESSION['LASTACTIVE'];
                                     $_SERVER['HTTP_DATE'] = $_SESSION['LASTACTIVE'];
                                 }
                             }
                         }
                         if (isset($_SERVER['HTTP_DATE'])) {
                             $args['HTTP_DATE'] = $_SERVER['HTTP_DATE'];
                         }
                         $oldArgs = array('REQUEST_METHOD' => \Slim\Environment::getInstance()->offsetGet('REQUEST_METHOD'), 'PATH_INFO' => \Slim\Environment::getInstance()->offsetGet('PATH_INFO'), 'slim.input' => \Slim\Environment::getInstance()->offsetGet('slim.input'), 'HTTP_DATE' => \Slim\Environment::getInstance()->offsetGet('HTTP_DATE'), 'HTTP_USER' => \Slim\Environment::getInstance()->offsetGet('HTTP_USER'), 'HTTP_SESSION' => \Slim\Environment::getInstance()->offsetGet('HTTP_SESSION'), 'REQUEST_TIME' => \Slim\Environment::getInstance()->offsetGet('REQUEST_TIME'));
                         $oldRequestURI = $_SERVER['REQUEST_URI'];
                         $oldScriptName = $_SERVER['SCRIPT_NAME'];
                         ///$oldRedirectURL = $_SERVER['REDIRECT_URL'];
                         ///echo "old: ".$_SERVER['REQUEST_URI']."\n";
                         $_SERVER['REQUEST_URI'] = substr($target, strlen('http://localhost/') - 1);
                         //$tar.$add;
                         ///$_SERVER['REDIRECT_URL']= substr($target,strlen('http://localhost/')-1);
                         ///echo "mein: ".substr($target,strlen('http://localhost/')-1)."\n";
                         $_SERVER['SCRIPT_NAME'] = $h . '/' . $com->getLocalPath() . '/' . $com->getClassFile();
                         //$tar;
                         $_SERVER['QUERY_STRING'] = '';
                         $_SERVER['REQUEST_METHOD'] = $method;
//.........这里部分代码省略.........
开发者ID:sawh,项目名称:ostepu-system,代码行数:101,代码来源:Request.php


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