/** * 清空缓存 */ function sp_clear_cache() { $dirs = array(); // runtime/ $rootdirs = sp_scan_dir(RUNTIME_PATH . "*"); //$noneed_clear=array(".","..","Data"); $noneed_clear = array(".", ".."); $rootdirs = array_diff($rootdirs, $noneed_clear); foreach ($rootdirs as $dir) { if ($dir != "." && $dir != "..") { $dir = RUNTIME_PATH . $dir; if (is_dir($dir)) { //array_push ( $dirs, $dir ); $tmprootdirs = sp_scan_dir($dir . "/*"); foreach ($tmprootdirs as $tdir) { if ($tdir != "." && $tdir != "..") { $tdir = $dir . '/' . $tdir; if (is_dir($tdir)) { array_push($dirs, $tdir); } else { @unlink($tdir); } } } } else { @unlink($dir); } } } $dirtool = new \Think\Dir(""); foreach ($dirs as $dir) { $dirtool->delDir($dir); } }
/** * 删除备份 */ public function del() { if ((!isset($_GET['backup']) || empty($_GET['backup'])) && (!isset($_POST['backup']) || empty($_POST['backup']))) { $this->error('非法参数'); } $dir = new \Think\Dir(); $dir->delDir(SITE_PATH . $this->backup_path . $_GET['backup'] . '/'); $this->success('操作成功!'); }