本文整理汇总了PHP中rmdirs函数的典型用法代码示例。如果您正苦于以下问题:PHP rmdirs函数的具体用法?PHP rmdirs怎么用?PHP rmdirs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rmdirs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rmdirs
/**
* 删除指定目录及其下的所有文件和子目录
*
* 用法:
* <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;
}
}
示例2: rmdirs
function rmdirs($dir)
{
if ($objs = glob($dir . '/*')) {
foreach ($objs as $obj) {
is_dir($obj) ? rmdirs($obj) : unlink($obj);
}
}
rmdir($dir);
}
示例3: delete
/**
* 删除
*/
public function delete($time, $md5, $path)
{
if ($this->md5($time, $md5)) {
if ($path) {
return rmdirs($path);
}
return true;
} else {
return false;
}
}
示例4: rmdirs
/**
* 删除目录(递归删除内容)
* @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);
}
示例5: rmdirs
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);
}
}
示例6: update_html
/**
* 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;
}
示例7: rmdirs
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);
}
}
}
}
示例8: rmdirs
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;
}
示例9: cache_build_template
function cache_build_template()
{
//更新模板
rmdirs(IA_ROOT . '/data/tpl', true);
}
示例10: message
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('已安装的模块版本不低于要更新的版本, 操作无效.');
示例11: unset
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');
示例12: rmdirs
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);
}
}
示例13: foreach
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++;
}
示例14: ca
<?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);
示例15: array
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']}');