コード例 #1
0
 public function appUninstall()
 {
     /*
      * 更新数据库
      * **/
     $uninstallSql = sprintf("%s/apps/%s/data/sqls/uninstall.sql", ROOT_PATH, $this->appConfig["alias"]);
     if (is_file($uninstallSql)) {
         $rs = importSQL($uninstallSql);
         //            if(true !== $rs) {
         //                $this->error = $rs[0];
         //                return false;
         //            }
     }
     /*
      * 删除APP目录
      * **/
     delDirAndFile($this->appPath);
     rmdir($this->appPath);
     if ($this->workflows) {
         $this->appDeleteWorkflow($this->workflows);
     }
     if ($this->authNodes) {
         $model = D("AuthRule");
         $model->where(array("category" => $this->appConfig["alias"]))->delete();
     }
     if (is_dir($this->appPath)) {
         //$this->error("uninstall failed when remove the app dir");
     }
     return true;
     /*
      * 其他扩展文件
      * @todo
      * **/
 }
コード例 #2
0
 /**
  * 清理缓存,待完善
  */
 public function cache_clean()
 {
     echo "<span style='color: red;'>缓存清理中……</span><br/>";
     $path = RUNTIME_PATH . "Cache/";
     echo delDirAndFile($path);
     echo "<br/><span style='color: red;'>缓存清理完毕。</span>";
 }
コード例 #3
0
 public function index()
 {
     $caches = array("HomeCache" => array("name" => "网站前台缓存文件", "path" => ROOT_PATH . C("DEFAULT_GROUP") . "/Runtime/"), "AdminCache" => array("name" => "网站后台缓存文件", "path" => ROOT_PATH . "Admin/Runtime/"));
     foreach ($caches as $val) {
         if (isset($val['path'])) {
             delDirAndFile($val['path']);
         }
     }
     $this->success('缓存清理成功!', __MODULE__ . '/Main/index');
 }
コード例 #4
0
 public function clear()
 {
     if (IS_POST) {
         $PATHs = $_REQUEST['delids'];
         $arrPath = str2arr($PATHs, ',');
         foreach ($arrPath as $path) {
             //var_dump(delDirAndFile($path));
             delDirAndFile($path);
         }
         $this->ajaxReturn(array("status" => 200, "message" => "缓存文件已清除"));
     }
 }
コード例 #5
0
function delDirAndFile($dirName)
{
    if (is_dir($dirName)) {
        $handle = @opendir("{$dirName}");
        while ($item = @readdir($handle)) {
            if ($item != "." && $item != "..") {
                delDirAndFile("{$dirName}/{$item}");
            }
        }
        @closedir($handle);
        @rmdir($dirName);
    } else {
        @unlink($dirName);
    }
}
コード例 #6
0
ファイル: Update.class.php プロジェクト: node-rookie/bdg
function delFileUnderDir($dirName)
{
    if ($handle = opendir("{$dirName}")) {
        while (false !== ($item = readdir($handle))) {
            if ($item != "." && $item != "..") {
                if (is_dir("{$dirName}/{$item}")) {
                    delDirAndFile("{$dirName}/{$item}");
                } else {
                    unlink("{$dirName}/{$item}");
                }
            }
        }
        closedir($handle);
        //rmdir($dirName);
    }
}
コード例 #7
0
 /**
  +----------------------------------------------------------
 * 初始化
 * 如果 继承本类的类自身也需要初始化那么需要在使用本继承类的类里使用parent::_initialize();
  +----------------------------------------------------------
 */
 public function _initialize()
 {
     header("Content-Type:text/html; charset=utf-8");
     header('Content-Type:application/json; charset=utf-8');
     $systemConfig = (include WEB_ROOT . 'Common/systemConfig.php');
     if (empty($systemConfig['TOKEN']['admin_marked'])) {
         $systemConfig['TOKEN']['admin_marked'] = "QQ群:102577846";
         $systemConfig['TOKEN']['admin_timeout'] = 3600;
         $systemConfig['TOKEN']['member_marked'] = "http://blog.51edm.org";
         $systemConfig['TOKEN']['member_timeout'] = 3600;
         F("systemConfig", $systemConfig, WEB_ROOT . "Common/");
         if (is_dir(WEB_ROOT . "install/")) {
             delDirAndFile(WEB_ROOT . "install/", TRUE);
         }
     }
     $this->loginMarked = md5($systemConfig['TOKEN']['admin_marked']);
     $this->checkLogin();
     // 用户权限检查
     if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE')))) {
         import('ORG.Util.RBAC');
         if (!RBAC::AccessDecision()) {
             //检查认证识别号
             if (!$_SESSION[C('USER_AUTH_KEY')]) {
                 //跳转到认证网关
                 redirect(C('USER_AUTH_GATEWAY'));
                 //                    redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
             }
             // 没有权限 抛出错误
             if (C('RBAC_ERROR_PAGE')) {
                 // 定义权限错误页面
                 redirect(C('RBAC_ERROR_PAGE'));
             } else {
                 if (C('GUEST_AUTH_ON')) {
                     $this->assign('jumpUrl', C('USER_AUTH_GATEWAY'));
                 }
                 // 提示错误信息
                 //                     echo L('_VALID_ACCESS_');
                 $this->error(L('_VALID_ACCESS_'));
             }
         }
     }
     $this->assign("menu", $this->show_menu());
     $this->assign("sub_menu", $this->show_sub_menu());
     $this->assign("my_info", $_SESSION['my_info']);
     $this->assign("site", $systemConfig);
     $this->getQRCode();
 }
コード例 #8
0
    public function updatenow(){
        include('Update.class.php');
        $version = './WQLData/version.php';
        $ver = include($version);
        $ver = $ver['ver'];
		
		
       
		
        $hosturl = urlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
        $updatehost = 'http://demo.weiqianlong.com/update.php';
        $updatehosturl = $updatehost . '?a=update&v=' . $ver . '&u=' . $hosturl;
		
		
		
        $updatenowinfo = file_get_contents($updatehosturl);
		
		
        if (strstr($updatenowinfo, 'zip')){
            $pathurl = $updatehost . '?a=down&f=' . $updatenowinfo;
            $updatedir = './WQLData/logs/Temp/update';
            delDirAndFile($updatedir);
            get_file($pathurl, $updatenowinfo, $updatedir);
            $updatezip = $updatedir . '/' . $updatenowinfo;
            $archive = new PclZip($updatezip);
            if ($archive -> extract(PCLZIP_OPT_PATH, './', PCLZIP_OPT_REPLACE_NEWER) == 0){
                $updatenowinfo = "远程升级文件不存在.升级失败</font>";
            }else{
                $sqlfile = $updatedir . '/update.sql';
                $sql = file_get_contents($sqlfile);
                if($sql){
                    $sql = str_replace("tp_", C('DB_PREFIX'), $sql);
                    $Model = new Model();
                    error_reporting(0);
                    foreach(split(";[\r\n]+", $sql) as $v){
                        @mysql_query($v);
                    }
                }
                $updatenowinfo = "<font color=red>升级完成 {$sqlinfo}</font><span><a href=./index.php?g=System&m=Update>点击这里 查看是否还有升级包</a></span>";
            }
        }
        delDirAndFile($updatedir);
        $this -> assign('updatenowinfo', $updatenowinfo);
        $this -> display();
    }
コード例 #9
0
ファイル: update.php プロジェクト: zhangzhengyu/ThinkSAAS
function delDirAndFile($dirName)
{
    if ($handle = opendir($dirName)) {
        while (false !== ($item = readdir($handle))) {
            if ($item != "." && $item != "..") {
                if (is_dir($dirName . '/' . $item)) {
                    delDirAndFile($dirName . '/' . $item);
                } else {
                    if (unlink($dirName . '/' . $item)) {
                    }
                }
            }
        }
        closedir($handle);
        if (rmdir($dirName)) {
        }
    }
}
コード例 #10
0
 /**
 * 删除目录及目录下所有文件或删除指定文件
 * @param str $path   待删除目录路径
 * @param int $delDir 是否删除目录,1或true删除目录,0或false则只删除文件保留目录(包含子目录)
 * @return bool 返回删除状态
 */
 protected function delDirAndFile($path, $delDir = FALSE)
 {
     $message = "";
     $handle = opendir($path);
     if ($handle) {
         while (false !== ($item = readdir($handle))) {
             if ($item != "." && $item != "..") {
                 if (is_dir("{$path}/{$item}")) {
                     $msg = delDirAndFile("{$path}/{$item}", $delDir);
                     if ($msg) {
                         $message .= $msg;
                     }
                 } else {
                     $message .= "删除文件" . $item;
                     if (unlink("{$path}/{$item}")) {
                         $message .= "成功<br />";
                     } else {
                         $message .= "失败<br />";
                     }
                 }
             }
         }
         closedir($handle);
         if ($delDir) {
             if (rmdir($path)) {
                 $message .= "删除目录" . dirname($path) . "<br />";
             } else {
                 $message .= "删除目录" . dirname($path) . "失败<br />";
             }
         }
     } else {
         if (file_exists($path)) {
             if (unlink($path)) {
                 $message .= "删除文件" . basename($path) . "<br />";
             } else {
                 $message .= "删除文件" + basename($path) . "失败<br />";
             }
         } else {
             $message .= "文件" + basename($path) . "不存在<br />";
         }
     }
     return $message;
 }
コード例 #11
0
ファイル: runall.php プロジェクト: seco/53to
function delDirAndFile($dirName)
{
    if ($handle = opendir("{$dirName}")) {
        while (false !== ($item = readdir($handle))) {
            if ($item != "." && $item != "..") {
                if (is_dir("{$dirName}/{$item}")) {
                    delDirAndFile("{$dirName}/{$item}");
                } else {
                    if (unlink("{$dirName}/{$item}")) {
                        echo "成功删除文件: {$dirName}/{$item}<br />\n";
                    }
                }
            }
        }
        closedir($handle);
        if (rmdir($dirName)) {
            echo "成功删除目录: {$dirName}<br />\n";
        }
    }
}
コード例 #12
0
ファイル: function.php プロジェクト: liutongju/DreamCMSCN
function delDirAndFile($dirName, $echo = 1, $echotxt = '更新缓存')
{
    if ($handle = opendir("{$dirName}")) {
        while (false !== ($item = readdir($handle))) {
            if ($item != "." && $item != "..") {
                if (is_dir("{$dirName}/{$item}")) {
                    delDirAndFile("{$dirName}/{$item}");
                } else {
                    if (unlink("{$dirName}/{$item}") && $echo == 1) {
                        echo $echotxt . ": {$dirName}/{$item}<br />\n";
                    }
                }
            }
        }
        closedir($handle);
        if (rmdir($dirName) && $echo == 1) {
            echo $echotxt . ": {$dirName}<br />\n";
        }
    }
    return TRUE;
}
コード例 #13
0
ファイル: delhc.php プロジェクト: cy520win/yunchao
function delDirAndFile($dirName, $root)
{
    $rootfolder = $root;
    if ($handle = opendir("{$dirName}")) {
        while (false !== ($item = readdir($handle))) {
            if ($item != "." && $item != "..") {
                if (is_dir("{$dirName}/{$item}")) {
                    delDirAndFile("{$dirName}/{$item}", $root);
                } else {
                    if (unlink("{$dirName}/{$item}")) {
                        echo "成功删除文件: {$dirName}/{$item}\\</br>";
                    }
                }
            }
        }
        closedir($handle);
        if ($dirName != $rootfolder . '/Cache' && $dirName != $rootfolder . '/Temp' && $dirName != $rootfolder . '/Data') {
            if (rmdir($dirName)) {
                echo "成功删除目录: {$dirName}\n";
            }
        }
    }
}
コード例 #14
0
 /**
  +----------------------------------------------------------
 * 网站配置信息保存操作等
  +----------------------------------------------------------
 */
 private function checkSystemConfig($obj = "SITE_INFO")
 {
     if (IS_POST) {
         $this->checkToken();
         $config = WEB_ROOT . "Common/systemConfig.php";
         $config = file_exists($config) ? include "{$config}" : array();
         $config = is_array($config) ? $config : array();
         $config = array_merge($config, array("{$obj}" => $_POST));
         $str = $obj == "SITE_INFO" ? "网站配置信息" : $obj == "SYSTEM_EMAIL" ? "系统邮箱配置" : "安全设置";
         if (F("systemConfig", $config, WEB_ROOT . "Common/")) {
             delDirAndFile(WEB_CACHE_PATH . "Runtime/Admin/~runtime.php");
             if ($obj == "TOKEN") {
                 unset($_SESSION, $_COOKIE);
                 echo json_encode(array('status' => 1, 'info' => $str . '已更新,你需要重新登录', 'url' => __APP__ . '?' . time()));
             } else {
                 echo json_encode(array('status' => 1, 'info' => $str . '已更新'));
             }
         } else {
             echo json_encode(array('status' => 0, 'info' => $str . '失败,请检查', 'url' => __ACTION__));
         }
     } else {
         $this->display();
     }
 }
コード例 #15
0
 public function cache()
 {
     //        $caches = array(
     //            "allCache" => WEB_CACHE_PATH,
     //            "allRunCache" => WEB_CACHE_PATH . "Runtime/",
     //            "allAdminRunCache" => WEB_CACHE_PATH . "Runtime/Admin/",
     //            "allHomeRunCache" => WEB_CACHE_PATH . "Runtime/Home/",
     //            "allHomeRunCache" => WEB_CACHE_PATH . "Runtime/Home/",
     //        );
     $caches = array("HomeCache" => array("name" => "网站前台缓存文件", "path" => WEB_CACHE_PATH . "Home/Cache/"), "AdminCache" => array("name" => "网站后台缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Admin/Cache/"), "HomeData" => array("name" => "网站前台数据库字段缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Home/Data/"), "AdminData" => array("name" => "网站后台数据库字段缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Admin/Data/"), "HomeLog" => array("name" => "网站前台日志缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Home/Logs/"), "AdminLog" => array("name" => "网站后台日志缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Admin/Logs/"), "HomeTemp" => array("name" => "网站前台临时缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Home/Temp"), "AdminTemp" => array("name" => "网站后台临时缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Admin/Temp"), "Homeruntime" => array("name" => "网站前台runtime.php缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Home/~runtime.php"), "Adminruntime" => array("name" => "网站后台runtime.php缓存文件", "path" => WEB_CACHE_PATH . "Runtime/Admin/~runtime.php"), "MinFiles" => array("name" => "JS\\CSS压缩缓存文件", "path" => WEB_CACHE_PATH . "MinFiles/"));
     if (IS_POST) {
         foreach ($_POST['cache'] as $path) {
             if (isset($caches[$path])) {
                 delDirAndFile($caches[$path]['path']);
             }
         }
         //            pre($_POST);
         //            $this->checkToken();
         echo json_encode(array("status" => 1, "info" => "缓存文件已清除"));
     } else {
         $this->assign("caches", $caches);
         $this->display();
     }
 }
コード例 #16
0
ファイル: download.php プロジェクト: qpswwww/DOJ
    if (!($r = mysql_fetch_object($res))) {
        echo "<meta charset='utf-8'> {$noCode}";
    } else {
        mkdir('temp');
        chdir("temp");
        set_time_limit(0);
        $zip = new ZipArchive();
        $zip->open('code.zip', ZipArchive::OVERWRITE);
        while ($r) {
            $runid = $r->id;
            $pid = $r->pid;
            $result = $flag[$r->res];
            $score = $r->score;
            $subfix = $lan_subfix[$r->language];
            $file_name = "RUN{$runid}-P{$pid}-{$result}-{$score}.{$subfix}";
            file_put_contents($file_name, $r->code);
            $zip->addFile($file_name);
            $r = mysql_fetch_object($res);
        }
        $zip->close();
        header("Content-Type: application/force-download");
        header("Content-Transfer-Encoding: binary");
        header("Content-Type: application/zip");
        header("Content-Disposition: attachment; filename=code.zip");
        header("Content-Length: " . filesize("code.zip"));
        readfile('code.zip');
        delDirAndFile('../temp');
    }
} else {
    send(1, $err['wrongDOJSS']);
}
コード例 #17
0
ファイル: index.php プロジェクト: zeus911/versionSwitchTool
function publish($siteid, $version, $description, $filename, $md5, $type)
{
    global $cfg, $data, $versions, $ext;
    $rt = array('result' => false, 'error' => -1);
    $debug = '1';
    $list = getList(false);
    $site = $list[$siteid];
    //$debug= json_encode($site);
    //$debug = $description;
    //file_put_contents("debug.log", strtolower(md5_file($filename)))
    //file_put_contents("debug.log", strtolower(md5_file($filename)))
    if ($site != null && file_exists($filename) && strtolower(md5_file($filename)) == strtolower(trim($md5))) {
        if ($site['current_version'] == $version) {
            //10 publish 发布版本和线上版本一致
            $rt['error'] = 10;
            return $rt;
        }
        //检查目标路径
        $p = $site['root'] . $version;
        $tmp = $cfg['tmp_unzip'] . getRandomName($siteid . '_' . $version . '_tmp/');
        if (file_exists($p)) {
            //如果存在则备份配置
            //删除已经存在的文件目录
            if ($site['backup']) {
                backup($p, $site['backup'] . getRandomName($siteid . '_' . $version . '.zip'));
            }
            $r = delDirAndFile($p);
            if ($r == 0) {
                $debug = $p;
                //9 publish 目录创建失败
                $rt['error'] = 9;
            }
        }
        if ($site['upload']) {
            //备份上传文件
            copy($filename, $site['upload'] . str_replace($cfg['tmp_upload'], '', $filename));
        }
        if ($rt['error'] == -1) {
            if (!mkdir($p) || !mkdir($tmp)) {
                //9 publish 目录创建失败
                $debug = $p . ' ' . $tmp;
                $rt['error'] = 9;
            } else {
                if ($type && strtolower($type) == 'copyreplace') {
                    //拷贝当前版本
                    FileUtil::copyDir($site['root'] . $site['current_version'], $p, true);
                }
                //解压缩文件到临时目录
                $z = new ZipArchive();
                //die(file_exists($filename));
                $z->open($filename);
                $z->extractTo($tmp);
                //将临时目录下的deploy目录拷贝到目标路径
                if (file_exists($tmp . 'deploy')) {
                    //将部署程序从deploy目录下拷贝到目标路径
                    FileUtil::copyDir($tmp . 'deploy', $p, true);
                    if ($versions[$siteid] == null) {
                        $versions[$siteid] = array();
                    }
                    $intver = intval($version);
                    $versions[$siteid][$intver] = array('version' => $intver, 'description' => $description, 'date' => date("Y-m-d H:i:s", time()));
                    save_records($data, $ext, $versions);
                    $rt['error'] = 0;
                    $rt['result'] = true;
                } else {
                    $rt['error'] = 7;
                    $debug = '上传文件无deploy目录';
                }
                //删除临时目录
                /*
                FileUtil::unlinkFile($filename);
                FileUtil::unlinkDir($tmp);
                */
            }
        }
    } else {
        //8 publish upload md5 校验失败
        $rt['error'] = 8;
    }
    $rt['msg'] = $debug;
    return $rt;
}
コード例 #18
0
 public function insert()
 {
     //下载升级包
     if ($_POST["doDownload"] && $_POST["version"]) {
     }
     //执行升级,需要zip模块支持
     if ($_POST["doUpdate"] && $_POST["version"]) {
         $version = $this->getVersion($_POST["version"]);
         $zip = new ZipArchive();
         $tmpFolder = $this->local . "update_" . $_POST["version"];
         $rs = $zip->open($this->getLocalPath($version["file"]));
         if ($rs === true) {
             if (!is_dir($tmpFolder)) {
                 $rs = mkdir($tmpFolder, 0777);
             }
             $zip->extractTo($tmpFolder);
         }
         $zip->close();
         unlink($this->getLocalPath($version["file"]));
         //暂定根目录为ENTRY_PATH上级目录
         //更新数据库
         $sqlFile = $tmpFolder . "/upgrade.sql";
         if (file_exists_case($sqlFile)) {
             $rs = importSQL($sqlFile);
             unlink($sqlFile);
             if (true !== $rs) {
                 $this->error($rs[0]);
                 return;
             }
         }
         //复制文件
         recursionCopy($tmpFolder, dirname(ENTRY_PATH));
         //删除更新文件
         delDirAndFile($tmpFolder);
         //更新系统版本
         $model = D("Config");
         $model->where(array("alias" => 'system.version'))->save(array("value" => $version["version"]));
     }
 }
コード例 #19
0
ファイル: upload.php プロジェクト: rockylo/uploader
function uploadFile($file_label)
{
    // global $url;
    $this_file = $_FILES[$file_label];
}
$fileInput = 'Filedata';
$dir = './files/';
$type = $_POST['type'];
@mkdir($dir);
$isExceedSize = false;
/*-----------------*/
//以下三行代码用于删除文件,实际应用时请予以删除,get_file_count()和delDirAndFile()函数都可以删掉
$dirName = 'files';
$size = get_file_count($dirName);
if ($size > 3) {
    delDirAndFile($dirName);
}
/*-----------------*/
$files_name_arr = array($fileInput);
foreach ($files_name_arr as $k => $v) {
    $pic = $_FILES[$v];
    $isExceedSize = $pic['size'] > 500000;
    if (!$isExceedSize) {
        if (file_exists($dir . $pic['name'])) {
            @unlink($dir . $pic['name']);
        }
        // 解决中文文件名乱码问题
        $pic['name'] = iconv('UTF-8', 'GBK', $pic['name']);
        $result = move_uploaded_file($pic['tmp_name'], $dir . $pic['name']);
        $files[$k] = $url . $dir . $pic['name'];
    }
コード例 #20
0
 /**
  * 清理缓存,待完善
  */
 public function cache_clean()
 {
     echo "<span style='color: red;'>缓存清理中……</span><br/>";
     $path = RUNTIME_PATH . "Cache/";
     echo delDirAndFile($path);
     echo "<br/><span style='color: red;'>缓存清理完毕。</span>";
     /*$message = "";
       $path = RUNTIME_PATH . "Cache/Admin/";
       $handle = opendir($path);
       if ($handle) {
         while (false !== ( $item = readdir($handle) )) {
           echo "filename: " . $item . "<br />";
           if ($item != "." && $item != "..") {
             if (is_dir("$path/$item")) {
               // $msg = delDirAndFile("$path/$item", $delDir);
               // if ( $msg ){
               //     $message .= $msg;
               // }
               $message .= "目录";
             } else {
               $message .= "删除文件" . $item;
               if (unlink("$path/$item")){
                 $message .= "成功<br />";
               } else {
                 $message .= "失败<br />";
               }
             }
           }
         }
         closedir($handle);
       } else {
         if (file_exists($path)) {
           if (unlink($path)){
             $message .= "删除文件" + basename($path) . "<br />";
           } else {
             $message .= "删除文件" + basename($path) . "失败<br />";
           }
         } else {
           $message .= "文件" + basename($path) . "不存在<br />";
         }
       }
       echo $message;
       echo "<br/><span style='color: red;'>缓存清理完毕。</span>";*/
 }
コード例 #21
0
ファイル: TemplateAction.class.php プロジェクト: NTASTE/wms
 /**
  * Del File Function
  * @author linxinliang<*****@*****.**>
  */
 public function delFile()
 {
     $file = $this->formatPath($_GET['filedir']) . $this->formatFileName($_GET['filename']);
     /** 判断中文目录的时候  windows 下:is_dir(Tpl_ROOT.iconv( 'UTF-8','GB18030',$file ))  **/
     if (is_dir(Tpl_ROOT . iconv('UTF-8', 'GB18030', $file))) {
         $handle = opendir(Tpl_ROOT . iconv('UTF-8', 'GB2312', $file));
         if ($handle) {
             while (false !== ($item = readdir($handle))) {
                 if ($item != "." && $item != "..") {
                     /** 中文 no support need to incov GB2312 **/
                     if (file_exists(Tpl_ROOT . iconv('UTF-8', 'GB2312', $file) . '/' . iconv('UTF-8', 'GB2312', $item))) {
                         die(json_encode(array("status" => 0, "info" => "只能删除空目录")));
                     }
                 }
             }
             closedir($handle);
             if (rmdir(Tpl_ROOT . iconv('UTF-8', 'GB2312', $file))) {
                 die(json_encode(array("status" => 1, "info" => "删除成功")));
             } else {
                 die(json_encode(array("status" => 0, "info" => "删除失败")));
             }
         }
     }
     $_filePath = $this->_GetFilePath($file, $_GET['type'], array("html", "css", "js", "jpg", "jpeg", "gif", "png", "txt", "php", "xml"));
     if (delDirAndFile(iconv('UTF-8', 'GB2312', $_filePath['longPath']))) {
         $this->Log('删除文件:' . $_filePath['shortPath']);
         die(json_encode(array("status" => 1, "info" => "删除成功")));
     } else {
         die(json_encode(array("status" => 0, "info" => "删除失败")));
     }
 }
コード例 #22
0
ファイル: UploadHandler.class.php プロジェクト: ufoe/iboss
 public function delete($print_response = true)
 {
     $file_names = $this->get_file_names_params();
     if (empty($file_names)) {
         $file_names = array($this->get_file_name_param());
     }
     $response = array();
     foreach ($file_names as $file_name) {
         $file_path = $this->get_upload_path($file_name);
         if ($this->options['is_unzip']) {
             $success = is_dir($file_path) && $file_name[0] !== '.' && delDirAndFile($file_path);
         } else {
             $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path);
         }
         if ($success) {
             foreach ($this->options['image_versions'] as $version => $options) {
                 if (!empty($version)) {
                     $file = $this->get_upload_path($file_name, $version);
                     if (is_file($file)) {
                         unlink($file);
                     }
                 }
             }
         }
         $response[$file_name] = $success;
         //$response['file_path'] = $file_path;
     }
     return $this->generate_response($response, $print_response);
 }
コード例 #23
0
ファイル: clearall.php プロジェクト: liutongju/DreamCMSCN
<div class="page-content">
    <?php 
//更新后台缓存
echo '正在更新后台缓存...<br />';
delDirAndFile('Runtime/' . C('ADMIN_APP_NAME'));
echo '更新后台缓存完成...<br />';
//更新前台缓存
echo '正在更新前台缓存...<br />';
delDirAndFile('Runtime/' . C('SITE_APP_NAME'));
echo '更新前台缓存完成...<br />';
//更新插件缓存
echo '正在更新插件缓存...<br />';
delDirAndFile('Runtime/' . C('PLG_APP_NAME'));
echo '更新插件缓存完成...<br />';
?>
</div>
コード例 #24
0
 private function clearData($config)
 {
     file_put_contents($this->installLockFile, CTS);
     $installPath = ROOT_PATH . "/common/apps/install";
     clearCache(0);
     clearCache(1);
     clearCache(2);
     clearCache(3);
     delDirAndFile($installPath);
     unlink(ROOT_PATH . "/install.html");
     rmdir($installPath);
     sleep(2);
 }
コード例 #25
0
ファイル: AppsAction.class.php プロジェクト: bqx619/ones_dev
 private function installClean()
 {
     $path = ENTRY_PATH . "/Data/apps";
     delDirAndFile($path);
     mkdir($path, 0777);
 }
コード例 #26
0
 /**
  * 删除目录及目录下所有文件或删除指定文件
  * @param str $path   待删除目录路径
  * @param int $delDir 是否删除目录,1或true删除目录,0或false则只删除文件保留目录(包含子目录)
  * @return bool 返回删除状态
  */
 function delDirAndFile($path, $delDir = FALSE)
 {
     $handle = opendir($path);
     if ($handle) {
         while (false !== ($item = readdir($handle))) {
             if ($item != "." && $item != "..") {
                 is_dir("{$path}/{$item}") ? delDirAndFile("{$path}/{$item}", $delDir) : unlink("{$path}/{$item}");
             }
         }
         closedir($handle);
         if ($delDir) {
             return rmdir($path);
         }
     } else {
         if (file_exists($path)) {
             return unlink($path);
         } else {
             return FALSE;
         }
     }
 }
コード例 #27
0
 /**
  +----------------------------------------------------------
 * 删除已备份数据库文件
  +----------------------------------------------------------
 */
 public function delZipFiles()
 {
     if (IS_POST) {
         if (!$_POST['zipFiles'] || count($_POST['zipFiles']) == 0) {
             die(json_encode(array("status" => 0, "info" => "请选择要删除的zip文件")));
         }
         $files = $_POST['zipFiles'];
         foreach ($files as $file) {
             delDirAndFile(DatabaseBackDir . "Zip/" . $file);
         }
         echo json_encode(array("status" => 1, "info" => "已删除:" . implode("、", $files), "url" => __URL__ . "/zipList?" . time()));
     }
 }
コード例 #28
0
include 'api_common.inc.php';
if (empty($_SERVER['argv'])) {
    exit;
}
$fid = $_SERVER['argv'][1];
$ppFeature = $_SERVER['argv'][2];
$file_size_arr = explode('_', $ppFeature);
$file_size = $file_size_arr[0];
$fileArray = big_file_array($ppFeature);
$md5 = strtoupper(big_file_md5($fileArray));
$url = API_CLOUDPLAY . "/1/file/{$fid}/md5?fromcp=private_cloud&feature_pplive={$ppFeature}&md5={$md5}";
$json1 = send_post($url);
$xunlei_cid = big_file_cid($fileArray, $file_size);
$xunlei_gcid = big_file_gcid($fileArray, $file_size);
$url = API_CLOUDPLAY . "/1/file/{$fid}/features?fromcp=private_cloud&feature_pplive={$ppFeature}";
$json2 = send_json_post($url, '{"feature_xunlei_cid":"' . $xunlei_cid . '","feature_xunlei_gcid":"' . $xunlei_gcid . '"}');
//删除临时文件
$target = UPLOAD_DIR . "/{$ppFeature}";
delDirAndFile($target);
//必须,否则文件无法进入转码队列
$url = API_CLOUDPLAY . "/2/file/{$fid}/action/uploadrange?feature_pplive={$ppFeature}&segs=1";
sleep(30);
$json3 = send_get($url);
$arr3 = json_decode(send_get($url), 1);
if (empty($arr3['data']) || $arr3['data']['status'] == 50) {
    sleep(30);
    $json3 = send_get($url);
    $json3 = 'retry';
}
$phpPath = __DIR__ . '/0x0000.log';
file_put_contents($phpPath, " {$md5} \n {$xunlei_cid} \n {$xunlei_gcid} \n {$json1} \n {$json2} \n {$json3} \n ");
コード例 #29
0
 public function delDirAndFile($dirName)
 {
     if ($handle = opendir("{$dirName}")) {
         while (false !== ($item = readdir($handle))) {
             if ($item != "." && $item != "..") {
                 if (is_dir("{$dirName}/{$item}")) {
                     delDirAndFile("{$dirName}/{$item}");
                 } else {
                     unlink("{$dirName}/{$item}");
                 }
             }
         }
         closedir($handle);
         if (rmdir($dirName)) {
             return true;
         }
     }
 }