public static function get() { if (self::$current !== null) { return self::$current; } $func = false; $verb = false; $args = null; $routes = array_filter(self::$httpRoutes); $pathinfo = \UtilsPath(); $httpMethod = $_SERVER['REQUEST_METHOD']; $verb = 'ANY ' . $pathinfo; $http = $httpMethod . ' ' . $pathinfo; if (isset($routes[$verb])) { $func = $routes[$verb]; } elseif (isset($routes[$http])) { $func = $routes[$http]; $verb = $http; } elseif (empty($routes) === false) { foreach ($routes as $key => $value) { if (strpos($key, ' re:') !== false && self::find($httpMethod, $key, $pathinfo, $args)) { $func = $value; $verb = $key; break; } } } if ($func !== false) { self::$current = array('controller' => $func, 'args' => $args); } else { self::$current = false; } $routes = self::$httpRoutes = null; return self::$current; }
public static function path($info = false) { if ($info === true) { return \UtilsPath(); } if (isset($_SERVER['REQUEST_URI'])) { return preg_replace('#\\?(.*)$#', '', $_SERVER['REQUEST_URI']); } return false; }
public function __construct($expires = 900, $lastModified = 0, $prefix = '') { $this->expires = $expires; if (AppData::createFolder('cache/output') === false) { return null; } $this->lastModified = $lastModified === 0 ? REQUEST_TIME + $this->expires : $lastModified; $filename = INPHINIT_PATH . 'storage/cache/output/~'; if (false === empty($prefix)) { $filename .= strlen($prefix) . '.' . sha1($prefix) . '_'; } $path = \UtilsPath(); $filename .= sha1($path) . '-' . strlen($path); $lastModify = $filename . '.1'; $this->cacheName = $filename; if (file_exists($filename) && file_exists($lastModify)) { $data = file_get_contents($lastModify); if ($data !== false && $data > REQUEST_TIME) { $this->isCache = true; header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $data) . ' GMT'); header('Etag: ' . sha1_file($filename)); if (self::match($data)) { Response::status(304); } else { App::on('ready', array($this, 'show')); } return null; } } $this->cacheTmp = AppData::createTmp(); $tmp = fopen($this->cacheTmp, 'wb'); if ($tmp === false) { return null; } $this->handle = $tmp; App::on('ready', array($this, 'finish')); App::buffer(array($this, 'write'), 1024); }