protected function _gc($maxlifetime) { foreach (glob("{$this->path}sess_*") as $filename) { if (\Sugi\File::modified($filename) + $maxlifetime < time()) { \Sugi\File::delete($filename); } } return true; }
/** * Add one file in the pack * * @param string $file * @return boolean - FALSE if the file is not found */ public function appendFile($file) { // Check the file is within default input path if ($mtime = File::modified($this->_input_path . $file)) { $file = $this->_input_path . $file; } elseif (!($mtime = File::exists($file))) { trigger_error("file {$file} does not exists"); return false; } // add a file to the pack $this->_files[] = $file; // last modified time of the pack will be the latest time $this->_lastmtime = max($mtime, $this->_lastmtime); return true; }
/** * Add some files in the pack (as a separate pack) * * @param array $files * @return boolean - FALSE if any file is missing */ public function append_files($files = array()) { $pack = array(); foreach ($files as $file) { // Check the file is within default input path if ($mtime = File::modified($this->_input_path . $file)) { $pack[] = $this->_input_path . $file; } elseif (!($mtime = File::exists($file))) { trigger_error("file {$file} does not exists"); return false; } else { $pack[] = $file; } $this->_lastmtime = max($mtime, $this->_lastmtime); } $this->_files[] = $pack; return true; }