示例#1
0
 function drop()
 {
     $backup_names = isset($_GET['backup_name']) ? trim($_GET['backup_name']) : '';
     if (!$backup_names) {
         $this->show_warning('no_backup_name');
         return;
     }
     $backup_names = explode(',', $backup_names);
     foreach ($backup_names as $backup_name) {
         is_dir($this->backup_path . $backup_name) && ecm_rmdir($this->backup_path . $backup_name);
     }
     $this->show_message('drop_ok');
 }
示例#2
0
 function clear()
 {
     $dir = dir($this->_cache_dir);
     while (false !== ($item = $dir->read())) {
         if ($item == '.' || $item == '..' || substr($item, 0, 1) == '.') {
             continue;
         }
         $item_path = $this->_cache_dir . '/' . $item;
         if (is_dir($item_path)) {
             ecm_rmdir($item_path);
         } else {
             _at(unlink, $item_path);
         }
     }
     return true;
 }
示例#3
0
/**
 * 清理系统所有编译文件,缓存文件、模板结构数据
 *
 * @author  wj
 * @param   void
 *
 * @return  void
 */
function clean_cache()
{
    /*清理缓存*/
    $cache_dirs = array(ROOT_PATH . '/temp/caches', ROOT_PATH . '/temp/compiled/mall/admin', ROOT_PATH . '/temp/compiled/mall/', ROOT_PATH . '/temp/compiled/store/admin', ROOT_PATH . '/temp/compiled/store', ROOT_PATH . '/temp/js', ROOT_PATH . '/temp/query_caches', ROOT_PATH . '/temp/tag_caches', ROOT_PATH . '/temp/style');
    foreach ($cache_dirs as $dir) {
        $d = dir($dir);
        if ($d) {
            while (false !== ($entry = $d->read())) {
                if ($entry != '.' && $entry != '..' && $entry != '.svn' && $entry != 'admin' && $entry != 'index.html') {
                    ecm_rmdir($dir . '/' . $entry);
                }
            }
            $d->close();
        }
    }
    /*主分类缓存数据*/
    if (is_file(ROOT_PATH . '/temp/query_caches/cache_category.php')) {
        unlink(ROOT_PATH . '/temp/query_caches/cache_category.php');
    }
    /*清除一个周前图片缓存并回收多余目录*/
    $expiry_time = strtotime('-1 week');
    $path = ROOT_PATH . '/temp/thumb';
    $d = dir($path);
    if ($d) {
        while (false !== ($entry = $d->read())) {
            if ($entry != '.' && $entry != '..' && $entry != '.svn' && is_dir($dir = $path . '/' . $entry)) {
                $sd = dir($dir);
                if ($sd) {
                    $left_dir_count = 0;
                    while (false !== ($entry = $sd->read())) {
                        if ($entry != '.' && $entry != '..' && is_dir($subdir = $dir . '/' . $entry)) {
                            $fsd = dir($subdir);
                            $left_file_count = 0;
                            while (false !== ($entry = $fsd->read())) {
                                if ($entry != '.' && $entry != '..' && $entry != 'index.htm' && is_file($file = $subdir . '/' . $entry)) {
                                    if (filemtime($file) < $expiry_time) {
                                        unlink($file);
                                    } else {
                                        $left_file_count++;
                                    }
                                }
                            }
                            $fsd->close();
                            if ($left_file_count == 0) {
                                //清除空目录
                                ecm_rmdir($subdir);
                            } else {
                                $left_dir_count++;
                            }
                        }
                    }
                    $sd->close();
                    if ($left_dir_count == 0) {
                        ecm_rmdir($dir);
                    }
                }
            }
        }
        $d->close();
    }
}