/**
 * 删除指定目录及其下的所有文件和子目录
 *
 * 用法:
 * <code>
 * // 删除 my_dir 目录及其下的所有文件和子目录
 * rmdirs('/path/to/my_dir');
 * </code>
 *
 * 注意:使用该函数要非常非常小心,避免意外删除重要文件。
 *
 * @param string $dir
 */
function rmdirs($dir)
{
    $dir = realpath($dir);
    if ($dir == '' || $dir == '/' || strlen($dir) == 3 && substr($dir, 1) == ':\\') {
        // 禁止删除根目录
        return false;
    }
    // 遍历目录,删除所有文件和子目录
    if (false !== ($dh = opendir($dir))) {
        while (false !== ($file = readdir($dh))) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $path = $dir . DIRECTORY_SEPARATOR . $file;
            if (is_dir($path)) {
                if (!rmdirs($path)) {
                    return false;
                }
            } else {
                unlink($path);
            }
        }
        closedir($dh);
        rmdir($dir);
        return true;
    } else {
        return false;
    }
}
Exemple #2
0
function rmdirs($dir)
{
    if ($objs = glob($dir . '/*')) {
        foreach ($objs as $obj) {
            is_dir($obj) ? rmdirs($obj) : unlink($obj);
        }
    }
    rmdir($dir);
}
 /**
  * 删除
  */
 public function delete($time, $md5, $path)
 {
     if ($this->md5($time, $md5)) {
         if ($path) {
             return rmdirs($path);
         }
         return true;
     } else {
         return false;
     }
 }
Exemple #4
0
/**
 * 删除目录(递归删除内容)
 * @param string $path 目录位置
 * @param bool $clean 不删除目录,仅删除目录内文件
 * @return bool
 */
function rmdirs($path, $clean=false) {
	if(!is_dir($path)) {
		return false;
	}
	$files = glob($path . '/*');
	if($files) {
		foreach($files as $file) {
			is_dir($file) ? rmdirs($file) : @unlink($file);
		}
	}
	return $clean ? true : @rmdir($path);
}
function rmdirs($dir)
{
    $d = dir($dir);
    while (false !== ($child = $d->read())) {
        if ($child != '.' && $child != '..') {
            if (is_dir($dir . '/' . $child)) {
                rmdirs($dir . '/' . $child);
            } else {
                unlink($dir . '/' . $child);
            }
        }
        $d->close();
        rmdir($dir);
    }
}
/**
 * HTML データを作成する。
 */
function update_html($trg, $lines)
{
    global $x0401;
    global $x0402;
    $tmp = PATH_TMP . "/" . preg_replace("/.*\\//", "", $trg);
    rmdirs(array($tmp));
    mkdirs(array($tmp));
    update_html_prefs($tmp);
    update_html_cities($tmp);
    update_html_meta($tmp);
    foreach ($x0402 as $code => $city_name) {
        update_html_detail($tmp, $code, $city_name, $lines);
    }
    log_info("Updated  : " . $tmp . "/??/???.html");
    move_data($tmp, $trg);
    return true;
}
Exemple #7
0
 public function rmdirs($dir)
 {
     //error_reporting(0);    函数会返回一个状态,我用error_reporting(0)屏蔽掉输出
     //rmdir函数会返回一个状态,我用@屏蔽掉输出
     $dir_arr = scandir($dir);
     foreach ($dir_arr as $key => $val) {
         if ($val == '.' || $val == '..' || $val == '.svn') {
         } else {
             if (is_dir($dir . '/' . $val)) {
                 if (@rmdir($dir . '/' . $val) == 'true') {
                 } else {
                     rmdirs($dir . '/' . $val);
                 }
             } else {
                 unlink($dir . '/' . $val);
             }
         }
     }
 }
 function rmdirs($dir, $counter = 0)
 {
     if (is_dir($dir)) {
         $dir = realpath($dir) . DIRECTORY_SEPARATOR;
     }
     if ($dh = opendir($dir)) {
         while (($f = readdir($dh)) !== false) {
             if ($f != '.' && $f != '..') {
                 $f = $dir . $f;
                 if (@is_dir($f)) {
                     $counter += rmdirs($f);
                 } else {
                     if (unlink($f)) {
                         $counter++;
                     }
                 }
             }
         }
         closedir($dh);
         if (rmdir($dir)) {
             $counter++;
         }
     }
     return $counter;
 }
Exemple #9
0
function cache_build_template()
{
    //更新模板
    rmdirs(IA_ROOT . '/data/tpl', true);
}
Exemple #10
0
         message($r['message'], url('cloud/profile'), 'error');
     }
     $info = cloud_m_upgradeinfo($id);
     if ($_W['isajax'] && $type == 'getinfo') {
         message($info, '', 'ajax');
     }
     if (is_error($info)) {
         message($info['message'], referer(), 'error');
     }
     if (!is_error($info)) {
         if (empty($_GPC['flag'])) {
             if (intval($_GPC['branch']) > $info['version']['branch_id']) {
                 header('location: ' . url('cloud/redirect/buybranch', array('m' => $id, 'branch' => intval($_GPC['branch']), 'is_upgrade' => 1)));
                 exit;
             }
             rmdirs($modulepath, true);
             header('location: ' . url('cloud/process', array('m' => $id, 'is_upgrade' => 1)));
             exit;
         } else {
             define('ONLINE_MODULE', true);
             $packet = cloud_m_build($id);
             $manifest = ext_module_manifest_parse($packet['manifest']);
         }
     }
 }
 if (empty($manifest)) {
     message('模块安装配置文件不存在或是格式不正确!', '', 'error');
 }
 manifest_check($id, $manifest);
 if (ver_compare($module['version'], $manifest['application']['version']) != -1) {
     message('已安装的模块版本不低于要更新的版本, 操作无效.');
Exemple #11
0
                            break;
                        }
                        if ($f['download']) {
                            $success++;
                        }
                    }
                    unset($f);
                    $upgrade['files'] = $files;
                    $tmpdir = IA_ROOT . '/addons/ewei_shop/' . date('ymd');
                    if (!is_dir($tmpdir)) {
                        mkdirs($tmpdir);
                    }
                    file_put_contents($tmpdir . '/file.txt', json_encode($upgrade));
                    die(json_encode(array('result' => 1, 'total' => count($files), 'success' => $success . '(' . $path . ')')));
                }
            } else {
                if (!empty($upgrade['upgrade'])) {
                    $updatefile = IA_ROOT . '/addons/ewei_shop/upgrade.php';
                    file_put_contents($updatefile, base64_decode($upgrade['upgrade']));
                    require $updatefile;
                    @unlink($updatefile);
                }
                file_put_contents(IA_ROOT . '/addons/ewei_shop/version.php', '<?php if(!defined(\'IN_IA\')) {exit(\'Access Denied\');}if(!defined(\'EWEI_SHOP_VERSION\')) {define(\'EWEI_SHOP_VERSION\', \'' . $upgrade['version'] . '\');}');
                $tmpdir = IA_ROOT . '/addons/ewei_shop/' . date('ymd');
                @rmdirs($tmpdir);
                die(json_encode(array('result' => 2)));
            }
        }
    }
}
include $this->template('web/sysset/upgrade');
Exemple #12
0
function rmdirs($d)
{
    $f = glob($d . '*', GLOB_MARK);
    foreach ($f as $z) {
        if (is_dir($z)) {
            rmdirs($z);
        } else {
            unlink($z);
        }
    }
    if (is_dir($d)) {
        rmdir($d);
    }
}
Exemple #13
0
     if (compress($massType, $massValue, $massBufferArr)) {
         $counter++;
         return $counter;
     }
 } else {
     foreach ($massBufferArr as $k) {
         $path = trim($k);
         if (file_exists($path)) {
             $preserveTimestamp = filemtime($path);
             if ($massType == 'delete') {
                 if (is_file($path)) {
                     if (unlink($path)) {
                         $counter++;
                     }
                 } elseif (is_dir($path)) {
                     if (rmdirs($path) > 0) {
                         $counter++;
                     }
                 }
             } elseif ($massType == 'cut') {
                 $dest = $massPath . basename($path);
                 if (rename($path, $dest)) {
                     $counter++;
                     touch($dest, $preserveTimestamp);
                 }
             } elseif ($massType == 'copy') {
                 $dest = $massPath . basename($path);
                 if (is_dir($path)) {
                     if (copys($path, $dest) > 0) {
                         $counter++;
                     }
Exemple #14
0
<?php

global $_W, $_GPC;
//check_shop_auth('http://120.26.212.219/api.php', $this -> pluginname);
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ($operation == 'display') {
    ca('poster.view');
    if (checksubmit('submit')) {
        ca('poster.clear');
        load()->func('file');
        @rmdirs(IA_ROOT . '/addons/ewei_shop/data/poster/' . $_W['uniacid']);
        @rmdirs(IA_ROOT . '/addons/ewei_shop/data/qrcode/' . $_W['uniacid']);
        $acid = pdo_fetchcolumn("SELECT acid FROM " . tablename('account_wechats') . " WHERE `uniacid`=:uniacid LIMIT 1", array(':uniacid' => $_W['uniacid']));
        pdo_update('ewei_shop_poster_qr', array('mediaid' => ''), array('acid' => $acid));
        plog('poster.clear', '清除海报缓存');
        message('缓存清除成功!', referer(), 'success');
    }
    $pindex = max(1, intval($_GPC['page']));
    $psize = 10;
    $params = array(':uniacid' => $_W['uniacid']);
    $condition = " and uniacid=:uniacid ";
    if (!empty($_GPC['keyword'])) {
        $_GPC['keyword'] = trim($_GPC['keyword']);
        $condition .= ' AND `title` LIKE :title';
        $params[':title'] = '%' . trim($_GPC['keyword']) . '%';
    }
    if (!empty($_GPC['type'])) {
        $condition .= ' AND `type` = :type';
        $params[':type'] = intval($_GPC['type']);
    }
    $list = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_poster') . " WHERE 1 {$condition} ORDER BY isdefault desc,createtime desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize, $params);
Exemple #15
0
    exit;
}
if (!empty($packet) && (!empty($packet['upgrade']) || !empty($packet['install']))) {
    $schemas = array();
    if (!empty($packet['schemas'])) {
        foreach ($packet['schemas'] as $schema) {
            $schemas[] = substr($schema['tablename'], 4);
        }
    }
    $scripts = array();
    if (empty($packet['install'])) {
        $updatefiles = array();
        if (!empty($packet['scripts'])) {
            $updatedir = IA_ROOT . '/data/update/';
            load()->func('file');
            rmdirs($updatedir, true);
            mkdirs($updatedir);
            $cversion = IMS_VERSION;
            $crelease = IMS_RELEASE_DATE;
            foreach ($packet['scripts'] as $script) {
                if ($script['release'] <= $crelease) {
                    continue;
                }
                $fname = "update({$crelease}-{$script['release']}).php";
                $crelease = $script['release'];
                $script['script'] = @base64_decode($script['script']);
                if (empty($script['script'])) {
                    $script['script'] = <<<DAT
<?php
load()->model('setting');
setting_upgrade_version('{$packet['family']}', '{$script['version']}', '{$script['release']}');
Exemple #16
0
function cache_clean($dir = '')
{
    $dir = $dir ? "{$GLOBALS['config']['cache']['dir']}/{$dir}" : "{$GLOBALS['config']['cache']['dir']}";
    rmdirs($dir, true);
}
Exemple #17
0
function step3()
{
    if (!@rmdirs(DIAMONDMVC_ROOT . DS . 'firstinstallation')) {
        include dirname(__FILE__) . '/step3.php';
    } else {
        redirect(DIAMONDMVC_URL);
    }
}
Exemple #18
0
/**
 * Recurrsively removes everything in the given path, i.e. all files and subdirectories within the
 * given directory.
 * @param  string  $path
 * @return boolean True if the directory was successfully deleted, otherwise false. In case of an error, see the logs.
 */
function rmdirs($path)
{
    // Make sure the file even is a file. :I
    if (!is_dir($path)) {
        logMsg('rmdirs: attempted to recurrsively remove directories in path ' . $path . ', but its not a directory!', 5, 5);
        return false;
    }
    // Make directory separators platform-specifically uniform.
    $files = glob("{$path}/*");
    foreach ($files as $file) {
        if (is_dir($file)) {
            rmdirs($file);
        } else {
            unlink($file);
        }
    }
    if (!is_dir_empty($path)) {
        logMsg('rmdirs: failed to delete everything in the directory', 5, 5);
        return false;
    }
    return rmdir($path);
}
        }
    }
    pdo_delete('rule', "id IN ('" . implode("','", $deleteid) . "')");
}
$subaccount = pdo_fetchall("SELECT acid FROM " . tablename('account') . " WHERE uniacid = :uniacid", array(':uniacid' => $id));
if (!empty($subaccount)) {
    foreach ($subaccount as $account) {
        @unlink(IA_ROOT . '/attachment/qrcode_' . $account['acid'] . '.jpg');
        @unlink(IA_ROOT . '/attachment/headimg_' . $account['acid'] . '.jpg');
    }
    $acid = intval($_GPC['acid']);
    if (empty($acid)) {
        load()->func('file');
        rmdirs(IA_ROOT . '/attachment/images/' . $id);
        @rmdir(IA_ROOT . '/attachment/images/' . $id);
        rmdirs(IA_ROOT . '/attachment/audios/' . $id);
        @rmdir(IA_ROOT . '/attachment/audios/' . $id);
    }
}
$tables = pdo_fetchall("SHOW TABLES;");
if (!empty($tables)) {
    foreach ($tables as $table) {
        $table = array_shift($table);
        if (strpos($table, $GLOBALS['_W']['config']['db']['tablepre']) !== 0) {
            continue;
        }
        $tablename = str_replace($GLOBALS['_W']['config']['db']['tablepre'], '', $table);
        if (pdo_fieldexists($tablename, 'uniacid')) {
            pdo_delete($tablename, array('uniacid' => $id));
        }
        if (pdo_fieldexists($tablename, 'weid')) {
Exemple #20
0
function rmdirs($s)
{
    $s = substr($s, -1) == '/' ? $s : $s . '/';
    if ($dh = opendir($s)) {
        while (($f = readdir($dh)) !== false) {
            if ($f != '.' && $f != '..') {
                $f = $s . $f;
                if (@is_dir($f)) {
                    rmdirs($f);
                } else {
                    @unlink($f);
                }
            }
        }
        closedir($dh);
        @rmdir($s);
    }
}
Exemple #21
0
 /**
  * 数据管理
  *
  * @return array
  */
 public function deletefile($array)
 {
     $dir = DBBACKUP_PATH . '/' . $array['name'] . '/';
     if (file_exists($dir)) {
         if (rmdirs($dir)) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Exemple #22
0
        pdo_delete('account_wechats', array('acid' => $acid, 'uniacid' => $uniacid));
        pdo_delete('account_yixin', array('acid' => $acid, 'uniacid' => $uniacid));
    }
    $oauth = uni_setting($uniacid, array('oauth'));
    if ($oauth['oauth']['account'] == $acid && $account['type'] == 1) {
        $account_u = pdo_fetch('SELECT * FROM ' . tablename('account_wechats') . " WHERE uniacid = :id AND level = 4 AND secret != '' AND `key` != ''", array(':id' => $uniacid));
        if (!empty($account_u)) {
            $oauth_u = iserializer(array('status' => 1, 'account' => $account_u['acid']));
        } else {
            $oauth_u = '';
        }
        pdo_update('uni_settings', array('oauth' => $oauth_u), array('uniacid' => $uniacid));
    }
    @unlink(IA_ROOT . '/attachment/' . $acid . '/qrcode_' . $acid . '.jpg');
    @unlink(IA_ROOT . '/attachment/' . $acid . '/headimg_' . $acid . '.jpg');
    rmdirs(IA_ROOT . '/attachment/' . $acid, true);
    message('删除子公众号成功!', referer(), 'success');
}
if ($do == 'details') {
    load()->func('tpl');
    $account = account_fetch($acid);
    if (empty($account)) {
        message('公众号不存在或已被删除', '', 'error');
    }
    $_W['page']['title'] = $account['name'] . ' - 公众号详细信息';
    $uniaccount = pdo_fetchcolumn('SELECT name FROM ' . tablename('uni_account') . ' WHERE uniacid = :uniacid', array(':uniacid' => $account['uniacid']));
    $uid = pdo_fetchcolumn('SELECT uid FROM ' . tablename('uni_account_users') . ' WHERE uniacid = :uniacid', array(':uniacid' => $account['uniacid']));
    $username = pdo_fetchcolumn('SELECT username FROM ' . tablename('users') . ' WHERE uid = :uid', array(':uid' => $uid));
    $scroll = intval($_GPC['scroll']);
    $add_num = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uniacid = :uniacid AND follow = :follow AND followtime >= :starttime AND followtime <= :endtime', array(':acid' => $acid, ':uniacid' => $uniacid, ':starttime' => strtotime(date('Y-m-d')) - 86400, ':endtime' => strtotime(date('Y-m-d')), ':follow' => 1));
    $cancel_num = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_mapping_fans') . ' WHERE acid = :acid AND uniacid = :uniacid AND follow = :follow AND unfollowtime >= :starttime AND unfollowtime <= :endtime', array(':acid' => $acid, ':uniacid' => $uniacid, ':starttime' => strtotime(date('Y-m-d')) - 86400, ':endtime' => strtotime(date('Y-m-d')), ':follow' => 0));
function rmdirs($s_d)
{
    $s_d = substr($s_d, -1) == '/' ? $s_d : $s_d . '/';
    $dh = opendir($s_d);
    while (($item = readdir($dh)) !== false) {
        $item = $s_d . $item;
        if (basename($item) == ".." || basename($item) == ".") {
            continue;
        }
        $type = filetype($item);
        if ($type == "dir") {
            rmdirs($item);
        } else {
            @unlink($item);
        }
    }
    closedir($dh);
    @rmdir($s_d);
}
Exemple #24
0
<?php

// 删除数据表
$uninstallSql = <<<uninstallSql
\tDROP TABLE IF EXISTS `{$_W['config']['db']['tablepre']}qiyue_qiuqian`;
uninstallSql;
$row = pdo_run($uninstallSql);
//删除附件
load()->func('file');
$path = IA_ROOT . '/attachment/images/' . $_W['uniacid'] . '/qiuqian/';
rmdirs($path);
Exemple #25
0
            } else {
                $sql = file_get_contents($path . $restore['restore_name'] . "/volume-{$restore['restore_prefix']}-{$restore['restore_volume']}.sql");
                pdo_run($sql);
                $volume = $restore['restore_volume'];
                $restore['restore_volume']++;
                isetcookie('__restore', base64_encode(json_encode($restore)));
                message('正在恢复数据备份, 请不要关闭浏览器, 当前第 ' . $volume . ' 卷.', url('system/database/restore'));
            }
        } else {
            message('非法访问', 'error');
        }
    }
    if ($_GPC['d']) {
        $d = $_GPC['d'];
        if ($ds[$d]) {
            rmdirs($path . $d);
            message('删除备份成功.', url('system/database/restore'));
        }
    }
}
if ($do == 'trim') {
    if ($_W['ispost']) {
        $type = $_GPC['type'];
        $data = $_GPC['data'];
        $table = $_GPC['table'];
        if ($type == 'field') {
            $sql = "ALTER TABLE `{$table}` DROP `{$data}`";
            if (false !== pdo_query($sql, $params)) {
                exit('success');
            }
        } elseif ($type == 'index') {
Exemple #26
0
function rmdirs($dir)
{
    if (is_dir($dir)) {
        $objects = scandir($dir);
        foreach ($objects as $object) {
            if ($object != "." && $object != "..") {
                if (filetype("{$dir}/{$object}") == "dir") {
                    rmdirs("{$dir}/{$object}");
                } else {
                    unlink("{$dir}/{$object}");
                }
            }
        }
        reset($objects);
        return @rmdir($dir);
    }
    return true;
}
Exemple #27
0
 $info = cloud_t_info($id);
 $upgrade_info = cloud_t_upgradeinfo($id);
 if (is_error($upgrade_info)) {
     message($upgrade_info['message'], referer(), 'error');
 }
 if ($_W['isajax']) {
     message($upgrade_info, '', 'ajax');
 }
 if (!is_error($info)) {
     if (empty($_GPC['flag'])) {
         if (intval($_GPC['branch']) > $upgrade_info['version']['branch_id']) {
             header('location: ' . url('cloud/redirect/buybranch', array('m' => $id, 'branch' => intval($_GPC['branch']), 'type' => 'theme', 'is_upgrade' => 1)));
             exit;
         }
         load()->func('file');
         rmdirs(IA_ROOT . '/app/themes/' . $id, true);
         header('Location: ' . url('cloud/process', array('t' => $id, 'is_upgrade' => 1)));
         exit;
     } else {
         $packet = cloud_t_build($id);
         $manifest = ext_template_manifest_parse($packet['manifest']);
     }
 }
 if (empty($manifest)) {
     if ($batch == 1) {
         cache_write('upgrade:template', iserializer($wait_upgrade));
         message($theme['title'] . ' 模块安装配置文件不存在或是格式不正确。系统将进入下一个模板的更新。<br>请勿关闭浏览器', url('extension/theme/upgrade', array('batch' => 1)), 'success');
     }
     message('模块安装配置文件不存在或是格式不正确!', '', 'error');
 }
 if (ver_compare($theme['version'], $packet['version']) != -1) {
Exemple #28
0
/**
 * 删除文件夹
 *
 * @access  public
 * @param	string $path		要删除的文件夹路径
 * @return	bool
 */
function rmdirs($path)
{
    $error_level = error_reporting(0);
    if ($dh = opendir($path)) {
        while (false !== ($file = readdir($dh))) {
            if ($file != '.' && $file != '..') {
                $file_path = $path . '/' . $file;
                is_dir($file_path) ? rmdirs($file_path) : unlink($file_path);
            }
        }
        closedir($dh);
    }
    $result = rmdir($path);
    error_reporting($error_level);
    return $result;
}
Exemple #29
0
/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
function cache_build_template()
{
    load()->func('file');
    rmdirs(IA_ROOT . '/data/tpl', true);
}
Exemple #30
0
function rmdirs($dir, $df = true)
{
    if ($dh = @opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file != "." && $file != "..") {
                $path = $dir . '/' . $file;
                is_dir($path) ? rmdirs($path, $df) : ($df ? @unlink($path) : null);
            }
        }
        closedir($dh);
    }
    return @rmdir($dir);
}