Exemple #1
0
function del_dir($path)
{
    // 判断如果参数不是一个目录直接退出
    if (!file_exists($path)) {
        echo '不是目录或不存在';
        return false;
    }
    // 判断是一个目录就打开
    if (is_dir($path)) {
        $frs = opendir($path);
        // 打开一个路径的资源句柄
        while (($row = readdir($frs)) !== false) {
            // 循环资源句柄中的内容
            if ($row == '.' || $row == '..') {
                // 如果是'.' '..' 跳过
                continue;
            }
            if (!is_dir($path . '/' . $row)) {
                // 如果不是目录直接unlink删除
                //echo '删除了文件:'.$path.'/'.$row. '<br />';
                unlink($path . '/' . $row);
            }
            if (is_dir($path . '/' . $row)) {
                // 如果是一个目录,则调用del_dir函数自身,继续子文件的判断。
                del_dir($path . '/' . $row);
            }
        }
        closedir($frs);
        // 循环到一个目录为空退出循环后,关闭资源
        //echo '删除了目录:'. $path. '<br />';
        return rmdir($path);
        // 删除打开的目录
    }
}
 /**
  * 根据角色ID删除记录
  * 
  * @param int       $role_id        角色ID
  * @return bool
  */
 public function delByRoleId($role_id)
 {
     $this->where("roleid={$role_id}")->delete();
     del_dir($this->_cache_path);
     mk_dir($this->_cache_path, 0755);
     return true;
 }
 /**
  * 清除今日以前的临时文件
  *
  */
 public function clean()
 {
     if ($this->isPost() && $this->isAjax()) {
         if (C('TOKEN_ON') && !checkFormToken($_POST)) {
             die('hack attemp.');
         }
         @set_time_limit(3600);
         if (function_exists('ini_set')) {
             ini_set('max_execution_time', 3600);
             ini_set("memory_limit", "256M");
         }
         $localTimeObj = LocalTime::getInstance();
         $today = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
         $upload_path = DOC_ROOT_PATH . get_upload_path();
         $dir = $upload_path . 'temp/';
         $dirhandle = opendir($dir);
         while (($file = readdir($dirhandle)) !== false) {
             if ($file != "." && $file != "..") {
                 if (filemtime($dir . $file) < $today) {
                     if (is_dir($dir . $file)) {
                         del_dir($dir . $file);
                     } else {
                         @unlink($dir . $file);
                     }
                 }
             }
         }
         @closedir($dirhandle);
         $this->ajaxReturn('', buildFormToken(), 1);
     }
 }
Exemple #4
0
 public function del($id)
 {
     $info = $this->info($id);
     $dir = __ROOTDIR__ . '/lang/' . $info['lang'];
     if (is_dir($dir)) {
         @del_dir($dir);
     }
     if ($info['protection'] == 1) {
         return false;
     }
     return $this->model->table('lang')->where('id=' . intval($id))->delete();
 }
 /**
  * 清空指定缓存
  * @param int $key 缓存key
  * @return true/false
  */
 public function delCache($key)
 {
     $info = $this->getCache($key);
     if (empty($info)) {
         return;
     }
     $file = $info['dir'];
     if (is_dir($file)) {
         del_dir($file);
     } elseif (is_file($file)) {
         unlink($file);
     }
     return true;
 }
 /**
  * 删除
  */
 public function del()
 {
     $name = $this->in['name'];
     if (!$name) {
         show_json($this->L["username_can_not_null"], false);
     }
     if ($name == 'admin') {
         show_json($this->L['default_user_can_not_do'], false);
     }
     if ($this->sql->delete($name)) {
         del_dir(USER_PATH . $name . '/');
         show_json($this->L['success']);
     }
     show_json($this->L['error'], false);
 }
Exemple #7
0
/**
 * 遍历删除目录和目录下所有文件
 * @param string $dir 路径
 * @return bool
 */
function del_dir($dir)
{
    if (!is_dir($dir)) {
        return false;
    }
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file != "." && $file != "..") {
            is_dir("{$dir}/{$file}") ? del_dir("{$dir}/{$file}") : @unlink("{$dir}/{$file}");
        }
    }
    if (readdir($handle) == false) {
        closedir($handle);
        @rmdir($dir);
    }
}
        echo 1;
        die;
    }
    echo '删除文件失败!';
    die;
}
/*
		@function  		删除目录
		
		@var:$dirName  	原目录
			
		@return:   		成功=true
	*/
function del_dir($dirName)
{
    if (!file_exists($dirName)) {
        return false;
    }
    $dir = opendir($dirName);
Exemple #9
0
function del_dir($dir)
{
    $res = opendir($dir);
    if (!$res) {
        return;
    }
    while (($file = readdir($res)) !== false) {
        if ($file !== '.' && $file !== '..') {
            $f = $dir . '/' . $file;
            if (is_dir($f)) {
                del_dir($f);
            } else {
                unlink($f);
            }
        }
    }
    closedir($res);
    rmdir($dir);
}
Exemple #10
0
         if (isset($item_id) && $item_id == 'all') {
         } else {
             $sql = "UPDATE  " . $work_table . " SET accepted = 0\n                            WHERE c_id = {$course_id} AND id = '" . $item_id . "'";
             Database::query($sql);
             api_item_property_update($course_info, 'work', $item_id, 'invisible', api_get_user_id());
             Display::display_confirmation_message(get_lang('FileInvisible'));
         }
     }
 }
 /*	Delete dir command */
 if ($is_allowed_to_edit && !empty($_REQUEST['delete_dir'])) {
     $delete_dir_id = intval($_REQUEST['delete_dir']);
     $locked = api_resource_is_locked_by_gradebook($delete_dir_id, LINK_STUDENTPUBLICATION);
     if ($locked == false) {
         $work_to_delete = get_work_data_by_id($delete_dir_id);
         del_dir($delete_dir_id);
         // gets calendar_id from student_publication_assigment
         $sql = "SELECT add_to_calendar FROM {$TSTDPUBASG} WHERE c_id = {$course_id} AND publication_id ='{$delete_dir_id}'";
         $res = Database::query($sql);
         $calendar_id = Database::fetch_row($res);
         // delete from agenda if it exists
         if (!empty($calendar_id[0])) {
             $t_agenda = Database::get_course_table(TABLE_AGENDA);
             $sql = "DELETE FROM {$t_agenda} WHERE c_id = {$course_id} AND id ='" . $calendar_id[0] . "'";
             Database::query($sql);
         }
         $sql = "DELETE FROM {$TSTDPUBASG} WHERE c_id = {$course_id} AND publication_id ='{$delete_dir_id}'";
         Database::query($sql);
         $link_info = is_resource_in_course_gradebook(api_get_course_id(), 3, $delete_dir_id, api_get_session_id());
         $link_id = $link_info['id'];
         if ($link_info !== false) {
Exemple #11
0
function del_lang()
{
    $id = post('id');
    $obj = new varia();
    $obj->set_where('');
    $obj->set_where("var_id = {$id}");
    $one = $obj->get_one();
    if (count($one) > 0) {
        $arr = explode('{v}', $one['var_value']);
        $pack_name = $arr[0];
        $index_entrance = $arr[1];
        $admin_entrance = $arr[2];
        if ($index_entrance != 'index.php' && $admin_entrance != 'admin.php') {
            $obj->del();
            $table = array('article', 'att_art', 'att_goo', 'booking', 'cat_art', 'cat_goo', 'channel', 'comment', 'goods', 'link', 'menu', 'message', 'picture', 'research', 'varia');
            //以下表不处理:admin,safe,users
            for ($i = 0; $i < count($table); $i++) {
                $tab = substr($table[$i], 0, 3);
                $obj = new $table[$i]();
                $obj->set_where('');
                $obj->set_where($tab . "_lang = '{$pack_name}'");
                $obj->del();
            }
            if (file_exists($index_entrance)) {
                unlink($index_entrance);
            }
            if (file_exists($admin_entrance)) {
                unlink($admin_entrance);
            }
            if (file_exists('languages/' . $pack_name)) {
                del_dir('languages/' . $pack_name);
            }
            echo 1;
        }
    }
}
Exemple #12
0
 function del_dir($thisfolder, $folder)
 {
     $thisdir = get_dir_file_info($thisfolder);
     foreach ($thisdir as $f) {
         if (is_dir($f['server_path'])) {
             $main_app = str_replace('\\plugins\\' . $folder . '\\files', '', $f['server_path']);
             //echo "<span style='color:#f00'>Main_app: ".$main_app."  - ".$f['server_path']."</span><br/>";
             if (is_dir($main_app)) {
                 //$subfolder=get_dir_file_info($f['server_path']);
                 del_dir($f['server_path'], $folder);
                 if (@rmdir($main_app)) {
                     echo "<span style='color:#66ae61'>rmdir: " . $main_app . "</span><br/>";
                 }
             } else {
                 //$subfolder=get_dir_file_info($f['server_path']);
                 del_dir($f['server_path'], $folder);
             }
         } else {
             $new_loc = str_replace('\\plugins\\' . $folder . '\\files', '', $f['server_path']);
             if (file_exists($new_loc)) {
                 unlink($new_loc);
                 echo "<span style='color:#66ae61'>Deleted: " . $new_loc . "</span><br/>";
             } else {
                 echo "<span style='color:#f00'>Not found: " . $new_loc . "</span><br/>";
             }
         }
     }
 }
Exemple #13
0
/**
 * 删除目录及目录下的所以文件 清除缓存时可用到
 * @param $file 要删除的文件(含路径)
 * @return boolean 成功返回true,失败返回false;
 */
function del_dir($file)
{
    if (!file_exists($file)) {
        return true;
    }
    // 文件或目录不存在不需清除
    if (is_dir($file) && !is_link($file)) {
        foreach (glob($file . '/*') as $sf) {
            if (!del_dir($sf)) {
                return false;
            }
        }
        //删除目录
        return @rmdir($file);
    } else {
        //删除文件
        return @unlink($file);
    }
}
Exemple #14
0
/**
 * 清理缓存
 * 若成功则 code 为1 失败 code 为0
 */
function m__clearcache()
{
    //判断操作权限
    check_level("A04");
    $_POST = helper::sqlxss($_POST);
    if (isset($_POST['act']) && $_POST['act'] != '') {
        $act = $_POST['act'];
        $return = true;
        //清空全部缓存
        if ($act == 'whole') {
            $return = del_dir("../" . CACHE_NAME);
            if ($return) {
                logs('成功清空了全部缓存');
            }
        }
        //清空列表缓存
        if ($act == 'list') {
            $return = del_dir("../" . CACHE_NAME . "/list");
            if ($return) {
                logs('成功清空了列表缓存');
            }
        }
        //清空内容缓存
        if ($act == 'content') {
            $return = del_dir("../" . CACHE_NAME . "/content");
            if ($return) {
                logs('成功清空了内容缓存');
            }
        }
        //清空统计缓存
        if ($act == 'count') {
            $return = del_dir("../" . CACHE_NAME . "/count");
            if ($return) {
                logs('成功清空了统计缓存');
            }
        }
        $host = $_SERVER['HTTP_HOST'];
        //清空分类缓存
        if ($act == 'category') {
            $return = del_dir("../" . CACHE_NAME . "/" . $host . '_' . CACHE_PREFIX . "categories");
            if ($return) {
                logs('成功清空了分类缓存');
            }
        }
        //清空伪静态缓存
        if ($act == 'url_rewrite') {
            $return = del_dir("../" . CACHE_NAME . "/" . $host . '_' . CACHE_PREFIX . "url_config");
            if ($return) {
                logs('成功清空了伪静态缓存');
            }
        }
        //清空模型缓存
        if ($act == 'externs') {
            $return = del_dir("../" . CACHE_NAME . "/" . $host . '_' . CACHE_PREFIX . "externs");
            if ($return) {
                logs('成功清空了模型缓存');
            }
        }
        //清空正文内链接缓存
        if ($act == 'nlink') {
            $return = del_dir("../" . CACHE_NAME . "/" . CACHE_PREFIX . "nlink");
            if ($return) {
                logs('成功清空了内链缓存');
            }
        }
        sleep(1);
        if ($return) {
            die('{"code":"1","msg":"缓存清除成功"}');
        } else {
            die('{"code":"0","msg":"缓存清除失败,可能是 ' . CACHE_NAME . ' 文件目录没有读写权限!"}');
        }
    }
}
/**
 * 清除模版编译和缓存文件
 *
 * @access  public
 * @param   mix     $ext    模版文件名后缀
 * @return  void
 */
function clear_all_files($ext = '') {
    del_dir(ROOT_PATH . 'data/cache');
    @mkdir(ROOT_PATH . 'data/cache', 0777);
}
Exemple #16
0
function scan_dir($target_path, $dep, $Kala = false)
{
    if ($Kala) {
        $UID = $_SESSION['UID'];
        $qr = "select * from cats where UID=" . $UID;
        debug("query for category selection : " . $qr);
        $BCID = 0;
        $SCID = 0;
        $LCID = 0;
        $res = sql($qr);
        while ($row = mysql_fetch_array($res)) {
            if ($row['name'] == "تصاوير بزرگ محصولات") {
                $LCID = $row['CID'];
            } else {
                if ($row['name'] == "تصوير كوچك محصولات") {
                    $SCID = $row['CID'];
                } else {
                    if ($row['name'] == "بنرهاي محصولات") {
                        $BCID = $row['CID'];
                    }
                }
            }
        }
        debug("LCID is " . $LCID);
        debug("SCID is " . $SCID);
        debug("BCID is " . $BCID);
        $codeKala = basename(substr($target_path, 1));
        debug(" in kala mode , target that detected is " . $target_path);
        debug(" codeKala is : " . $codeKala);
        $dir = opendir($target_path);
        while ($file = readdir($dir)) {
            if ($file == SII || $file == LII || $file == BII) {
                debug("start directry parsing : file detected is :" . $file);
                $handele = opendir($target_path . PATCH_DIS . $file);
                while ($file2 = readdir($handele)) {
                    if ($file2 != '.' && $file2 != '..') {
                        if (!is_dir($target_path . PATCH_DIS . $file . PATCH_DIS . $file2)) {
                            debug(" scaned target and find this File / Dir  this file should not be . or .. or any other thing: " . $file2);
                            if (strtolower(getExtension($file2)) == 'jpg' || strtolower(getExtension($file2)) == 'jpeg' || strtolower(getExtension($file2)) == 'gif' || strtolower(getExtension($file2)) == 'png') {
                                // file2 is a valid image file
                                $UID = $_SESSION['UID'];
                                $qr = "select * from cats where UID=" . $UID;
                                debug("query for category selection : " . $qr);
                                $BCID = 0;
                                $SCID = 0;
                                $LCID = 0;
                                $res = sql($qr);
                                while ($row = mysql_fetch_array($res)) {
                                    if ($row['name'] == "تصاوير بزرگ محصولات") {
                                        $LCID = $row['CID'];
                                    } else {
                                        if ($row['name'] == "تصوير كوچك محصولات") {
                                            $SCID = $row['CID'];
                                        } else {
                                            if ($row['name'] == "بنرهاي محصولات") {
                                                $BCID = $row['CID'];
                                            }
                                        }
                                    }
                                }
                                debug("LCID is " . $LCID);
                                debug("SCID is " . $SCID);
                                debug("BCID is " . $BCID);
                                $codeKala = basename(substr($target_path, 1));
                                debug(" in kala mode , target that detected is " . $target_path);
                                debug(" codeKala is : " . $codeKala);
                                debug(" this file is an valid image that set in config file and can be moved to correct directory");
                                $is_smale_pic_and_should_go_away = false;
                                if ($file == BII) {
                                    $CCID = $BCID;
                                } elseif ($file == LII) {
                                    $CCID = $LCID;
                                } elseif ($file == SII) {
                                    $CCID = $SCID;
                                    $is_smale_pic_and_should_go_away = true;
                                }
                                debug(" CID is : " . $CCID);
                                debug(" File is : " . $file);
                                img_uploader($file2, $CCID, $target_path . PATCH_DIS . $file, $file, false, "it`s a group upload file", $codeKala);
                                if (is_file($target_path . PATCH_DIS . $file . PATCH_DIS . $file2)) {
                                    unlink($target_path . PATCH_DIS . $file . PATCH_DIS . $file2);
                                }
                                if ($is_smale_pic_and_should_go_away) {
                                    del_dir($target_path . PATCH_DIS . $file);
                                    break;
                                }
                            } else {
                                // file 2 is not a valid image file and should be delated
                                debug("this file is not an image and sould be deleted");
                                unlink($target_path . PATCH_DIS . $file . PATCH_DIS . $file2);
                                debug("file that should delete: " . $target_path . PATCH_DIS . $file . PATCH_DIS . $file2);
                            }
                        } else {
                            // file 2 is a directory
                            debug("this file is not a file and should be deleted all of directory ");
                            del_dir($target_path . PATCH_DIS . $file . PATCH_DIS . $file2);
                        }
                    }
                }
                closedir($handele);
            } else {
                if ($file != '.' && $file != '..') {
                    if (is_dir($target_path . PATCH_DIS . $file)) {
                        del_dir($target_path . PATCH_DIS . $file);
                    } else {
                        unlink($target_path . PATCH_DIS . $file);
                    }
                }
            }
        }
        del_dir($target_path);
        return;
    } else {
        $handel1 = opendir($target_path);
        while ($file = readdir($handel1)) {
            if ($file != "." && $file != ".." && $file != "__MACOSX" && $file != ".DS_Store") {
                if (is_dir($target_path . PATCH_DIS . $file)) {
                    // echo  $dep.$file."/<br>";
                    if (is_codeKala($file)) {
                        /// change !!!!
                        scan_dir($target_path . PATCH_DIS . $file, $dep . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", true);
                    } else {
                        scan_dir($target_path . PATCH_DIS . $file, $dep . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                    }
                    del_dir($target_path . PATCH_DIS . $file);
                } else {
                    unlink($target_path . PATCH_DIS . $file);
                }
            } else {
                if ($file != "." && $file != "..") {
                    if (is_dir($target_path . PATCH_DIS . $file)) {
                        //   echo "I find a dir ".$target_path.PATCH_DIS.$file."<br>";
                        del_dir($target_path . PATCH_DIS . $file);
                    } else {
                        //chmod($target_path.PATCH_DIS.$filename, "0777");
                        unlink($target_path . PATCH_DIS . $file);
                    }
                }
            }
        }
    }
}
Exemple #17
0
 public function upgrade()
 {
     $dir = __ROOTDIR__ . '/data/update/';
     if (!file_exists($dir . '/ver.xml')) {
         $this->msg('升级信息文件不存在!', 0);
         return;
     }
     $xml = file_get_contents($dir . '/ver.xml');
     $info = Xml::decode($xml);
     $time = $info['ver']['vertime'];
     if ($time != $this->config['ver_date']) {
         $this->msg('该更新包不适合当前版本!', 0);
         return;
     }
     if (!copy_dir($dir . '/update', __ROOTDIR__, true)) {
         $this->msg('移动文件失败!', 0);
         return;
     }
     if ($info['ver']['sql'] == '1') {
         model('update')->index();
     }
     del_dir($dir);
     $this->msg('升级成功!清空手动清空所有缓存!');
 }
Exemple #18
0
 function _remove()
 {
     $file_list = array($this->path_to . '/controller/debug.class.php', $this->path_to . '/lib/class/lessc.inc.class.php', $this->path_to . '/static/style/base.less', $this->path_to . '/static/js/lib/less-1.4.2.min.js', $this->path_to . '/static/js/lib/webuploader/webuploader.js', $this->path_to . '/static/style/skin/common.less', $this->path_to . '/static/js/Gruntfile.js', $this->path_to . '/static/js/package.json', $this->path_to . '/static/js/readme.txt', $this->path_to . '/todo.txt');
     $path_list = array($this->path_to . '/data/log', $this->path_to . '/data/thumb', $this->path_to . '/static/js/_dev', $this->path_to . '/static/js/app/update', $this->path_to . '/static/js/node_modules');
     foreach ($file_list as $val) {
         del_file($val);
     }
     echo '<br/>1.文件删除完成:';
     flush();
     mkdir($this->path_to . '/data/User');
     foreach ($path_list as $val) {
         del_dir($val);
     }
     echo '<br/>2.文件夹删除完成:';
     flush();
     $path = $this->path_to . '/static/style/skin/';
     $app_theme = array('default', 'metro', 'simple');
     $app_less = array('app_code_edit', 'app_desktop', 'app_editor', 'app_explorer', 'app_setting', 'button', 'config', 'dialog', 'filelist', 'right_menu', 'tree');
     foreach ($app_theme as $theme) {
         foreach ($app_less as $app) {
             $temp = $path . $theme . '/' . $app . '.less';
             del_file($temp);
         }
     }
     echo '<br/>3.less文件删除完成<hr/>';
     flush();
 }
Exemple #19
0
/**
 * Utility Function to remove a folder and its contents recursively.
 *
 * @param string $dir
 */
function del_dir($dir)
{
    if (is_dir($dir) && ($handle = opendir($dir))) {
        $array = array();
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . $file)) {
                    // Empty directory? Remove it
                    if (!@rmdir($dir . $file)) {
                        // Not empty? Delete the files inside it
                        del_dir($dir . $file . '/');
                    }
                } else {
                    @unlink($dir . $file);
                }
            }
        }
        closedir($handle);
        @rmdir($dir);
    }
}
Exemple #20
0
function clear_static()
{
    $type = post('type');
    if ($type == 'all') {
        del_dir('html');
    } elseif ($type == 'sheet') {
        del_dir_special('html', 'id-');
    } else {
        del_dir('html/' . $type);
    }
    echo 1;
}
 /**
  * 在线升级
  */
 public function init()
 {
     // 开始升级
     $do = I('get.do');
     $cover = I('cover', 0);
     if (empty($do)) {
         $this->message(L('upgradeing'), url('init', array('do' => 1, 'cover' => $cover)));
     }
     // 获取补丁列表
     $pathlist = $this->pathlist();
     if (empty($pathlist)) {
         $this->message(L('upgrade_success'), url('checkfile'));
     }
     // 创建缓存文件夹
     if (!file_exists(CACHE_PATH . 'upgrade')) {
         @mkdir(CACHE_PATH . 'upgrade');
     }
     foreach ($pathlist as $k => $v) {
         $release = str_replace('patch_R', '', basename($v, ".zip"));
         // 远程压缩包地址
         $upgradezip_url = $this->upgrade_path_base . $v;
         // 保存到本地地址
         $upgradezip_path = CACHE_PATH . 'upgrade' . DIRECTORY_SEPARATOR . $v;
         // 解压路径
         $upgradezip_source_path = CACHE_PATH . 'upgrade' . DIRECTORY_SEPARATOR . basename($v, ".zip");
         // 下载压缩包
         @file_put_contents($upgradezip_path, Http::doGet($upgradezip_url));
         // 解压缩
         $zip = new Zip();
         if ($zip->decompress($upgradezip_path, $upgradezip_source_path) == 0) {
             die("Error : unpack the failure.");
         }
         // 拷贝utf8/upload文件夹到根目录
         $copy_from = $upgradezip_source_path . DIRECTORY_SEPARATOR . $this->patch_charset . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR;
         $copy_to = ROOT_PATH;
         $this->copyfailnum = 0;
         $this->copydir($copy_from, $copy_to, $cover);
         // 检查文件操作权限,是否复制成功
         if ($this->copyfailnum > 0) {
             // 如果失败,终止操作
             $this->message(L('please_check_filepri'), url('index'));
         }
         // 执行sql
         // sql目录地址
         $sql_path = CACHE_PATH . 'upgrade' . DIRECTORY_SEPARATOR . basename($v, ".zip") . DIRECTORY_SEPARATOR . $this->patch_charset . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR;
         $file_list = glob($sql_path . '*');
         if (!empty($file_list)) {
             foreach ($file_list as $fk => $fv) {
                 $file_path = strtolower($fv);
                 if (in_array(substr($file_path, -3, 3), array('php', 'sql')) && substr($file_path, -10, 10) != 'config.php') {
                     if (substr($file_path, -3, 3) == 'sql') {
                         // 更新sql文件
                         $sqlData = Install::mysql($file_path, 'ecs_', C('DB_PREFIX'));
                         // 执行sql文件
                         $model = new EcModel();
                         if (is_array($sqlData)) {
                             foreach ($sqlData as $sql) {
                                 @$model->db->query($sql);
                             }
                         }
                     } elseif (strtolower(substr($file_list[$fk], -3, 3)) == 'php' && file_exists($file_path)) {
                         include $file_path;
                     }
                 }
             }
         }
         // 读取版本号写入version.php文件
         // 配置文件地址
         $configpath = CACHE_PATH . 'upgrade' . DIRECTORY_SEPARATOR . basename($v, ".zip") . DIRECTORY_SEPARATOR . $this->patch_charset . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . 'version.php';
         if (file_exists($configpath)) {
             $config = (include $configpath);
             // 版本文件地址
             $content = "<?php\ndefine('APPNAME', '" . $config['APPNAME'] . "');\ndefine('VERSION', '" . $config['VERSION'] . "');\ndefine('RELEASE', '" . $release . "');\ndefine('ECTOUCH_AUTH_KEY', '" . ECTOUCH_AUTH_KEY . "');";
             @file_put_contents(ROOT_PATH . 'data/version.php', $content);
         }
         // 删除文件
         @unlink($upgradezip_path);
         // 删除文件夹
         del_dir($upgradezip_source_path);
         // 提示语
         $tmp_k = $k + 1;
         if (!empty($pathlist[$tmp_k])) {
             $next_update = '<br />' . L('upgradeing') . basename($pathlist[$tmp_k], ".zip");
         } else {
             $next_update;
         }
         // 是否升级成功
         $this->message(basename($v, ".zip") . L('upgrade_success') . $next_update, url('init', array('do' => 1, 'cover' => $cover)));
     }
 }
Exemple #22
0
 public function clear_data()
 {
     $dir = __ROOTDIR__ . '/data/db_cache/';
     return del_dir($dir);
 }
 /**
  * 安装成功
  */
 public function success()
 {
     $appid = $this->appid();
     $config_file = './data/version.php';
     require $config_file;
     $content = "<?php\ndefine('APPNAME', '" . APPNAME . "');\ndefine('VERSION', '" . VERSION . "');\ndefine('RELEASE', '" . RELEASE . "');\ndefine('ECTOUCH_AUTH_KEY', '" . $appid . "');";
     @file_put_contents($config_file, $content);
     @fopen($this->lockFile, 'w');
     if (ECTOUCH_AUTH_KEY == '') {
         $site_info = site_info($appid);
         $this->cloud->data($site_info)->act('post.install');
     }
     //生成二维码
     $mobile_url = __URL__;
     //二维码内容
     $errorCorrectionLevel = 'L';
     // 纠错级别:L、M、Q、H
     $matrixPointSize = 7;
     // 点的大小:1到10
     $mobile_qr = 'data/cache/demo_qrcode.png';
     QRcode::png($mobile_url, ROOT_PATH . $mobile_qr, $errorCorrectionLevel, $matrixPointSize, 2);
     //二维码路径赋值
     $this->assign('mobile_qr', $mobile_url . '/' . $mobile_qr);
     $this->display('success');
     if (C('run_after_del')) {
         del_dir(BASE_PATH . 'apps/' . APP_NAME);
         if (is_dir('data/assets/' . APP_NAME)) {
             del_dir('data/assets/' . APP_NAME);
         }
     }
 }
Exemple #24
0
     } elseif ($urlpath && preg_match('~(\\w+)\\.plg$~i', $urlpath, $filename)) {
         $r = fopen($urlpath, 'r');
         ob_start();
         fpassthru($r);
         $file = ob_get_clean();
         $w = fopen(SERVDIR . '/cdata/plugins/' . $filename[1] . '.php', 'w');
         fwrite($w, $file);
         fclose($w);
     } else {
         $error = lang('File empty');
     }
 } elseif ($do == 'uninstall') {
     CSRFCheck();
     unlink(SERVDIR . '/cdata/plugins/' . $name . '.php');
     if (is_dir($name)) {
         del_dir(SERVDIR . '/cdata/plugins/' . $name);
     }
 }
 $CSRF = CSRFMake();
 echoheader('home', lang("Install plugins"), make_breadcrumbs('main=main/options:options=options/tools:plugins=Plugins', true));
 $list = array();
 foreach (read_dir(SERVDIR . '/cdata/plugins', array(), false) as $plugin) {
     if (preg_match('~\\.php$~i', $plugin)) {
         $r = fopen(SERVDIR . $plugin, 'r');
         $description = '-';
         fgets($r);
         if (preg_match('~// description: (.*)~i', fgets($r), $match)) {
             $description = $match[1];
         }
         fclose($r);
         $list[] = array('name' => str_replace(array('/cdata/plugins/', '.php'), '', $plugin), 'path' => $plugin, 'desc' => $description);
Exemple #25
0
 public function del_file()
 {
     $name = $_POST['name'];
     $this->alert_str($name, '', true);
     $dir = __ROOTDIR__ . '/plugins/' . $name;
     if (del_dir($dir)) {
         $this->msg('删除成功!');
     } else {
         $this->msg('删除失败!', 0);
     }
 }
 public function pathDeleteRecycle()
 {
     if ($_SERVER['HTTP_REFERER'] != $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) {
         if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
             if (!isset($this->in['list'])) {
                 if (!del_dir(USER_RECYCLE)) {
                     show_json($this->L['remove_fali'], false);
                 } else {
                     mkdir(USER_RECYCLE);
                     show_json($this->L['recycle_clear_success'], true);
                 }
                 return;
             }
             $list = json_decode($this->in['list'], true);
             $success = 0;
             $error = 0;
             foreach ($list as $val) {
                 $path_full = _DIR($val['path']);
                 if ($val['type'] == 'folder') {
                     if (del_dir($path_full)) {
                         $success++;
                     } else {
                         $error++;
                     }
                 } else {
                     if (del_file($path_full)) {
                         $success++;
                     } else {
                         $error++;
                     }
                 }
             }
             if (count($list) == 1) {
                 if ($success) {
                     show_json($this->L['remove_success']);
                 } else {
                     show_json($this->L['remove_fali'], false);
                 }
             } else {
                 $code = $error == 0 ? true : false;
                 show_json($this->L['remove_success'] . $success . 'success,' . $error . 'error', $code);
             }
         }
     } else {
         header('Location: 403.php');
     }
 }
Exemple #27
0
/**
 * 删除文件夹 传入参数编码为操作系统编码. win--gbk
 */
function del_dir($dir)
{
    if (!($dh = opendir($dir))) {
        return false;
    }
    while (($file = readdir($dh)) !== false) {
        if ($file != "." && $file != "..") {
            $fullpath = $dir . '/' . $file;
            if (!is_dir($fullpath)) {
                if (!unlink($fullpath)) {
                    // 删除不了,尝试修改文件权限
                    chmod($fullpath, 0777);
                    if (!unlink($fullpath)) {
                        return false;
                    }
                }
            } else {
                if (!del_dir($fullpath)) {
                    chmod($fullpath, 0777);
                    if (!del_dir($fullpath)) {
                        return false;
                    }
                }
            }
        }
    }
    closedir($dh);
    if (rmdir($dir)) {
        return true;
    } else {
        return false;
    }
}
Exemple #28
0
/**
 * To delete a folder for incoming parameter encoding for the operating system encoding win -. Gbk
 */
function del_dir($dir)
{
    if (!($dh = opendir($dir))) {
        return false;
    }
    while (($file = readdir($dh)) !== false) {
        if ($file != "." && $file != "..") {
            $fullpath = $dir . '/' . $file;
            if (!is_dir($fullpath)) {
                if (!unlink($fullpath)) {
                    // Not deleted, try to modify the file permissions
                    chmod($fullpath, 0777);
                    if (!unlink($fullpath)) {
                        return false;
                    }
                }
            } else {
                if (!del_dir($fullpath)) {
                    chmod($fullpath, 0777);
                    if (!del_dir($fullpath)) {
                        return false;
                    }
                }
            }
        }
    }
    closedir($dh);
    if (rmdir($dir)) {
        return true;
    } else {
        return false;
    }
}
 public function pathDeleteRecycle()
 {
     if (!isset($this->in['list'])) {
         if (!del_dir(USER_RECYCLE)) {
             show_json($this->L['remove_fali'], false);
         } else {
             mkdir(USER_RECYCLE);
             show_json($this->L['recycle_clear_success'], true);
         }
         return;
     }
     $list = json_decode($this->in['list'], true);
     $success = 0;
     $error = 0;
     foreach ($list as $val) {
         $path_full = _DIR($val['path']);
         if ($val['type'] == 'folder') {
             if (del_dir($path_full)) {
                 $success++;
             } else {
                 $error++;
             }
         } else {
             if (del_file($path_full)) {
                 $success++;
             } else {
                 $error++;
             }
         }
     }
     if (count($list) == 1) {
         if ($success) {
             show_json($this->L['remove_success']);
         } else {
             show_json($this->L['remove_fali'], false);
         }
     } else {
         $code = $error == 0 ? true : false;
         show_json($this->L['remove_success'] . $success . 'success,' . $error . 'error', $code);
     }
 }
Exemple #30
0
function del_dir($src)
{
    $dir = opendir($src);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                del_dir($src . '/' . $file);
            } else {
                unlink($src . '/' . $file);
            }
        }
    }
    closedir($dir);
}