本文整理汇总了PHP中CacheManager::setCacheSid方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheManager::setCacheSid方法的具体用法?PHP CacheManager::setCacheSid怎么用?PHP CacheManager::setCacheSid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheManager
的用法示例。
在下文中一共展示了CacheManager::setCacheSid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: custom
//.........这里部分代码省略.........
$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;
\Slim\Environment::mock($args);
include_once $tar;
$oldStatus = http_response_code();
$oldHeader = array_merge(array(), headers_list());
header_remove();
http_response_code(0);
$name = $com->getClassName();
try {
ob_start();
$obj = new $name();
if (isset($obj)) {
unset($obj);
}
$result['content'] = ob_get_contents();
CacheManager::setETag($result['content']);
$result['headers'] = array_merge(array(), self::http_parse_headers_short(headers_list()));
header_remove();
if (!isset($result['headers']['Cachesid'])) {
$newSid = CacheManager::getNextSid();
$result['headers']['Cachesid'] = $newSid;
}
ob_end_clean();
//header_remove();
$result['status'] = http_response_code();
} catch (Exception $e) {
error_log($e->getMessage());
header_remove();
$result['status'] = '500';
$result['content'] = '';
$result['headers'] = array();
}
$_SERVER['REQUEST_URI'] = $oldRequestURI;
$_SERVER['SCRIPT_NAME'] = $oldScriptName;
//$_SERVER['REDIRECT_URL'] = $oldRedirectURL;
\Slim\Environment::mock($oldArgs);
$_SERVER['REQUEST_METHOD'] = $oldArgs['REQUEST_METHOD'];
http_response_code($oldStatus);
header('Content-Type: text/html; charset=utf-8');
foreach ($oldHeader as $head) {
header($head);
}
CacheManager::setCacheSid($sid);
$targetSid = isset($result['headers']['Cachesid']) ? $result['headers']['Cachesid'] : null;
CacheManager::addPath($sid, $targetSid, $com->getTargetName(), $target, $method, $result['status']);
CacheManager::finishRequest($targetSid, $h . '/' . $com->getLocalPath(), $com->getTargetName(), $target, $result['content'], $result['status'], $method, $content);
CacheManager::cacheData($sid, $com->getTargetName(), $target, $result['content'], $result['status'], $method);
///Logger::Log('in<< '.$method.' '.$com->getClassName().$add, LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
}
$done = true;
break;
}
}
}
}
if (!$done) {
// creates a custom request
Logger::Log("--" . $method . ' ' . $target, LogLevel::DEBUG, false, dirname(__FILE__) . '/../calls.log');
$ch = Request_CreateRequest::createCustom($method, $target, $header, $content, $authbool, $sessiondelete)->get();
$content = curl_exec($ch);
// get the request result
$result = curl_getinfo($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
// splits the received header info, to create an entry
// in the $result['headers'] for each part of the header
$result['headers'] = self::http_parse_headers(substr($content, 0, $header_size));
// seperates the content part
$result['content'] = substr($content, $header_size);
// sets the received status code
$result['status'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
}
Logger::Log($target . ' ' . round(microtime(true) - $begin, 2) . 's', LogLevel::DEBUG, false, dirname(__FILE__) . '/../executionTime.log');
return $result;
}