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); }
public static function raw($binary = true) { if (is_readable('php://input')) { $mode = $binary === true ? 'rb' : 'r'; if (PHP_VERSION_ID >= 50600) { return fopen('php://input', $mode); } $tmp = AppData::createTmp(); if (copy('php://input', $tmp)) { return fopen($tmp, $mode); } } return false; }