* @package misc * @link https://www.zentao.net */ class miscZen extends misc { /** * 打印 hello world。 * print hello world. * * @access public * @return string */ public function hello(): string { return 'hello world from hello()
'; } /** * 获取缓存文件。 * Get cache files. * * @param string $directory * @access protected * @return void */ protected function cleanCachaFiles(string $directory): void { $files = glob($directory . DS . '*.cache'); foreach($files as $file) $this->deleteExpiredFile($file); $subdirectories = glob($directory . DS . '*', GLOB_ONLYDIR); foreach($subdirectories as $subdirectory) $this->cleanCachaFiles($subdirectory); } /** * 删除过期文件。 * Delete expired file. * * @param string $file * @access protected * @return bool */ protected function deleteExpiredFile(string $file): bool { $content = file_get_contents($file); $content = unserialize($content); if(is_null($content['time'])) return false; if(time() > $content['time']) return unlink($file); return false; } }