function deldir($path){
static $count = 0;
	//不是目录,真接返回
	if(!is_dir($path)){
		return 0;
	}

	$dh = opendir($path);
	while(($row = readdir($dh)) != flase){
		if($row == '.' || $row == '..'){
			continue;
		}
		//判断是不是判断文件
		if(!is_dir($path.'/'.$row)){
			unlink($path.'/'.$row);
		}else{
			deldir($path.'/'.$row); //递归删除
		}

		if($count > 200){
			break;
		}
		$count++;
	}
	closedir($dh);
	rmdir($path);

	echo '删除了'.$path,'<br />';
	return true;
}
Esempio n. 2
0
function delete($dirname, $dirtype, $placeholder)
{
    $placeholder = str_replace("\r\n", "", $placeholder);
    //keng
    if ($od = opendir($dirname)) {
        while ($file = readdir($od)) {
            echo $file . ' ';
            if ($file == '..' || $file == '.') {
                continue;
            }
            if ($placeholder !== 0 && strcmp($file, $placeholder) == 0) {
                echo 'continue';
                continue;
            }
            if (is_dir('./' . $dirname . '/' . $file)) {
                if ($dirtype === 0) {
                    continue;
                } else {
                    deldir('./' . $dirname . '/' . $file);
                    continue;
                }
            }
            echo 'unlink ' . './' . $dirname . '/' . $file;
            unlink('./' . $dirname . '/' . $file);
        }
        closedir($od);
    }
}
Esempio n. 3
0
 function deldir($dir)
 {
     //先删除目录下的文件:
     $dh = opendir($dir);
     //如果传入的参数是目录,则使用opendir将该目录打开,将返回的句柄赋值给$dh
     while ($file = readdir($dh)) {
         //这里明确地测试返回值是否全等于(值和类型都相同)FALSE,否则任何目录项的名称求值为 FALSE 的都会导致循环停止(例如一个目录名为“0”)。
         if ($file != "." && $file != "..") {
             //在文件结构中,都会包含形如“.”和“..”的向上结构,但是它们不是文件或者文件夹
             $fullpath = $dir . "/" . $file;
             //当前文件$dir为文件目录+文件
             if (!is_dir($fullpath)) {
                 //如果传入的参数不是目录,则为文件,应将其删除
                 unlink($fullpath);
                 //删除文件
             } else {
                 deldir($fullpath);
                 //递归删除文件
             }
         }
     }
     closedir($dh);
     //删除当前文件夹:
     if (rmdir($dir)) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 4
0
 public function ajaxUpdateCache()
 {
     if (IS_AJAX) {
         $cachedir = RUNTIME_PATH . 'Cache';
         //Cache文件路径
         if (is_dir($cachedir)) {
             //打开Cache文件夹
             deldir($cachedir);
         }
         $tempdir = RUNTIME_PATH . '/Temp/';
         //Temp文件的路径
         if ($handle = opendir($tempdir)) {
             //打开Temp文件夹
             while (($item = readdir($handle)) !== false) {
                 //遍历Temp目录
                 unlink($tempdir . $item);
                 //删除遍历到的每一个文件
             }
             closedir($handle);
         }
         $this->ajaxReturn(array('status' => true, 'msg' => '更新完成'), 'JSON');
     } else {
         $this->ajaxReturn(array('status' => true, 'msg' => '更新失败'), 'JSON');
     }
 }
Esempio n. 5
0
 static function deleteFile($fullpath)
 {
     if (!is_dir($fullpath)) {
         unlink($fullpath);
     } else {
         deldir($fullpath);
     }
 }
 protected function deleteFiels($files)
 {
     foreach ($files as $item) {
         if (strlen($item['filename']) > 5) {
             deldir(WEB_ROOT . $item['filename']);
         }
     }
 }
Esempio n. 7
0
function removeFile($fullpath)
{
    if (is_file($fullpath)) {
        return unlink($fullpath);
    } elseif (is_dir($fullpath)) {
        return deldir($fullpath);
    }
}
Esempio n. 8
0
 public static function del($file, $type = 'php')
 {
     load::sys_func('file');
     if ($type == 'file') {
         @deldir(PATH_CACHE . $file);
     } else {
         @unlink(PATH_CACHE . $file . '.' . $type);
     }
 }
Esempio n. 9
0
function delete_old_process($link)
{
    $ret = sqlquery('SELECT * FROM `process` where 1', $link);
    while ($i = $ret->fetch(PDO::FETCH_ASSOC)) {
        if (!pstatus($i['pid'])) {
            sqlexec('DELETE FROM `process` where pid=?', array($i['pid']), $link);
            deldir('qqbot/' . $i['id']);
        }
    }
}
Esempio n. 10
0
 function remove($theme)
 {
     $theme_dir = ROOTDIR . 'themes/' . $theme;
     if (is_dir($theme_dir) && deldir($theme_dir)) {
         $setting_mdl =& loader::model('setting');
         $setting_mdl->remove_conf('theme_' . $theme, false);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 11
0
function dl_error($alert, $type, $olid, $ver, $addr, $action, $num = 0)
{
    global $checksum, $met_host, $met_file, $db, $url_array, $lang_retested, $lang_redownload, $lang_updaterr21, $lang_updaterr22;
    if ($action != 'error') {
        if ($action == 'dl') {
            $num = $num - 1;
            $conok = "olflie('{$olid}','{$ver}','dl','{$num}');";
        } else {
            $conok = "olupdate('{$olid}','{$ver}','{$action}');";
        }
        if ($action == 'dirpower') {
            echo "{$lang_updaterr21} &nbsp; <a href=\"javascript:void(0)\" onclick=\"olupdate('{$olid}','{$ver}','{$action}');\">{$lang_retested}</a><script type=\"text/javascript\">\n\t\t\txian('{$alert}');</script>";
            die;
        } else {
            echo "{$lang_updaterr21}<script type=\"text/javascript\">\n\t\t\talert('{$alert}');";
        }
        if ($action == 'check') {
            echo "olupdate('{$olid}','{$ver}','error');";
        } else {
            echo "var con;\t\t\n\t\t\tcon=confirm('{$lang_updaterr22}');\n\t\t\tif(con){\n\t\t\t\t{$conok}\n\t\t\t}else{\n\t\t\t\tolupdate('{$olid}','{$ver}','error');\n\t\t\t}\n\t\t\t";
        }
        echo "</script>";
        die;
    }
    if ($type == 1) {
        echo "<a href=\"http://{$met_host}/dl/olupdate.php\" onclick=\"return olupdate('cms','new','test');\">{$lang_retested}</a>";
    }
    if ($type == 2) {
        if ($addr) {
            deldir("../app/{$addr}/");
        }
        $query = "select * from {$met_app} where no={$olid} and download=1";
        $appver = $db->get_one($query);
        $verold = is_array($appver) ? $appver['ver'] : 0;
        echo "<a href='http://{$met_host}/dl/app.php' onclick=\"return olupdate('{$olid}','{$verold}','testc');\">{$lang_redownload}</a>";
    }
    $adminfile = $url_array[count($url_array) - 2];
    $str = file_get_contents(ROOTPATH_ADMIN . "/update/{$addr}/filelist.txt");
    $strs = explode('|', $str);
    foreach ($strs as $addrskey => $strsval) {
        $strsvalto = readmin($strsval, $adminfile, 2);
        $str = file_get_contents("../../{$strsvalto}");
        if ($str == 'metinfo' || $str == 'No Date') {
            unlink("../../{$strsvalto}");
        }
    }
    checksumdel($type);
    unlink("../../update.php");
    unlink("../../sql.sql");
    if ($addr) {
        deldir("../update/{$addr}/");
    }
    die;
}
Esempio n. 12
0
function deldir($dir)
{
    $current_dir = opendir($dir);
    while ($entryname = readdir($current_dir)) {
        if (is_dir("{$dir}/{$entryname}") and ($entryname != "." and $entryname != "..")) {
            deldir("{$dir}/{$entryname}");
        } elseif ($entryname != "." and $entryname != "..") {
            unlink("{$dir}/{$entryname}");
        }
    }
    closedir($current_dir);
}
Esempio n. 13
0
function deldir($d)
{
    $map = directory_map($d, TRUE);
    foreach ($map as $item) {
        if (is_file($d . $item)) {
            unlink($d . $item);
        } else {
            deldir($d . $item . '/');
        }
    }
    rmdir($d . '/');
}
Esempio n. 14
0
function delcache($dir)
{
  $handle = opendir($dir);
  while (false!==($FolderOrFile = readdir($handle)))
  {
     if($FolderOrFile != "." && $FolderOrFile != "..")
     { 
       if(is_dir("$dir/$FolderOrFile"))
       { deldir("$dir/$FolderOrFile"); }  // recursive
       else
       { unlink("$dir/$FolderOrFile"); }
     } 
  }
} 
Esempio n. 15
0
function deldir($dir)
{
    $dh = opendir($dir);
    while ($file = readdir($dh)) {
        if ($file != "." && $file != "..") {
            $fullpath = $dir . "/" . $file;
            if (!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                deldir($fullpath);
            }
        }
    }
}
Esempio n. 16
0
/**
 * @example 删除文件夹及所有自文件夹、文件
 */
function deldir($dir)
{
    //先删除目录下的文件:
    $dh = @opendir($dir);
    while ($file = @readdir($dh)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $dir . '/' . $file;
            !is_dir($fullpath) ? @unlink($fullpath) : deldir($fullpath);
        }
    }
    closedir($dh);
    //删除当前文件夹:
    return rmdir($dir) ? true : false;
}
 public function CacheClear()
 {
     $dir = ROOT . "/jycheck/Runtime/Cache/";
     $dh = opendir($dir);
     while ($file = readdir($dh)) {
         if ($file != "." && $file != "..") {
             $fullpath = $dir . "/" . $file;
             if (!is_dir($fullpath)) {
                 unlink($fullpath);
             } else {
                 deldir($fullpath);
             }
         }
     }
     $this->redirect('Index/welcome', '', 1, '缓存清除成功,1秒后跳转...');
 }
Esempio n. 18
0
 /**
  * Custom install method
  * @param int The id of the module
  * @param string The URL option
  * @param int The client id
  */
 function uninstall($id, $option, $client = 0)
 {
     global $database, $mosConfig_absolute_path;
     // Delete directories
     $path = $mosConfig_absolute_path . ($client == 'admin' ? '/administrator' : '') . '/templates/' . $id;
     $id = str_replace('..', '', $id);
     if (trim(id)) {
         if (is_dir($path)) {
             return deldir(mosPathName($path));
         } else {
             HTML_installer::showInstallMessage('Directory does not exist, cannot remove files', 'Uninstall -  error', $this->returnTo($option, 'template', $client));
         }
     } else {
         HTML_installer::showInstallMessage('Template id is empty, cannot remove files', 'Uninstall -  error', $this->returnTo($option, 'template', $client));
         exit;
     }
 }
Esempio n. 19
0
function deldir($dirName)
{
    $result = false;
    if (!is_dir($dirName)) {
        return false;
    }
    $handle = opendir($dirName);
    while (($file = readdir($handle)) !== false) {
        if ($file != '.' && $file != '..') {
            $dir = $dirName . DIRECTORY_SEPARATOR . $file;
            is_dir($dir) ? deldir($dir) : unlink($dir);
        }
    }
    closedir($handle);
    $result = rmdir($dirName) ? true : false;
    return $result;
}
Esempio n. 20
0
 public function del_DirAndFile($dir)
 {
     //先删除目录下的文件:
     // $dir = "E:/gis/Public/Filedownload/joinus-excel";
     $dh = opendir($dir);
     while (($file = readdir($dh)) !== false) {
         if ($file != "." && $file != "..") {
             $fullpath = $dir . $file;
             if (!is_dir($fullpath)) {
                 unlink($fullpath);
             } else {
                 deldir($fullpath);
             }
         }
     }
     closedir($dh);
 }
Esempio n. 21
0
function deldir($dir)
{
    $handle = opendir($dir);
    while (false !== ($FolderOrFile = readdir($handle))) {
        if ($FolderOrFile != "." && $FolderOrFile != "..") {
            if (@is_dir("{$dir}/{$FolderOrFile}")) {
                deldir("{$dir}/{$FolderOrFile}");
            } else {
                unlink("{$dir}/{$FolderOrFile}");
            }
        }
    }
    closedir($handle);
    if (rmdir($dir)) {
        $success = true;
    }
    return $success;
}
Esempio n. 22
0
 function rm($dir)
 {
     if (!is_dir($dir)) {
         return;
     }
     if ($current_dir = @opendir($dir)) {
         $separator = dir::separator();
         while ($entryname = readdir($current_dir)) {
             if (is_dir("{$dir}{$separator}{$entryname}") && ($entryname != "." && $entryname != "..")) {
                 deldir("{$dir}{$separator}{$entryname}");
             } elseif ($entryname != "." && $entryname != "..") {
                 unlink("{$dir}{$separator}{$entryname}");
             }
         }
         closedir($current_dir);
         rmdir($dir);
     }
 }
Esempio n. 23
0
 function deldir($dir)
 {
     $current_dir = opendir($dir);
     $old_umask = umask(0);
     while ($entryname = readdir($current_dir)) {
         if ($entryname != '.' and $entryname != '..') {
             if (is_dir($dir . $entryname)) {
                 deldir(mosPathName($dir . $entryname));
             } else {
                 @chmod($dir . $entryname, 0777);
                 unlink($dir . $entryname);
             }
         }
     }
     umask($old_umask);
     closedir($current_dir);
     return rmdir($dir);
 }
 function index()
 {
     import('ORG.Util.Pclzip');
     clearstatcache();
     $url = "http://www.damicms.com/update/dami_update.zip";
     $save_path = './Public/';
     $ext_path = './Public/uptmp/';
     @mk_dir($ext_path);
     $save_file = $save_path . "uptemp.zip";
     if (!file_exists($save_file) || filemtime($save_file) < time() - 6 * 3600) {
         ob_end_flush();
         //清空浏览器缓存
         echo '准备下载升级文件包....<br>';
         ob_flush();
         flush();
         self::get_damipacket($url, $save_file);
     }
     if (file_exists($save_file)) {
         ob_end_flush();
         //清空浏览器缓存
         echo '正在解压升级文件包....<br>';
         ob_flush();
         flush();
         $archive = new PclZip($save_file);
         if ($archive->extract(PCLZIP_OPT_PATH, $ext_path) == 0) {
             die("Error : " . $archive->errorInfo(true));
         } else {
             ob_end_flush();
             //清空浏览器缓存
             echo '解压缩已经完成,准备更新文件....<br>';
             ob_flush();
             flush();
             //遍历文件并更新
             self::up_file($ext_path);
             ob_end_flush();
             //清空浏览器缓存
             echo '恭喜您,所有文件升级完毕!';
             ob_flush();
             flush();
             //删除升级文件
             @deldir($ext_path);
         }
     }
 }
Esempio n. 25
0
 public function actionDeleteAll()
 {
     if (isset($_POST['date'])) {
         $date = $_POST['date'];
         $img_file = PC . '/epaper2/assets/article_img/' . $date;
         $result = "";
         if (!is_dir($img_file)) {
             header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4");
         } else {
             $dh = opendir($img_file);
             while ($file = readdir($dh)) {
                 if ($file != "." && $file != "..") {
                     $fullpath = $img_file . "/" . $file;
                     if (!is_dir($fullpath)) {
                         unlink($fullpath);
                     } else {
                         deldir($fullpath);
                     }
                 }
             }
             closedir($dh);
             //删除当前文件夹:
             if (rmdir($img_file)) {
                 // Article::model()->deleteAll('create_time=:create_time',array(':create_time'=>$date));
                 Coor::model()->deleteAll('create_time=:create_time', array(':create_time' => $date));
                 PageCount::model()->deleteAll('create_time=:create_time', array(':create_time' => $date));
                 Pname::model()->deleteAll('create_time=:create_time', array(':create_time' => $date));
                 $query = new EntityFieldQuery();
                 $query->entityCondition('entity_type', 'node')->entityCondition('bundle', '_xinwen')->fieldCondition('field_riq', 'value', $date);
                 $result = $query->execute();
                 if (isset($result['node'])) {
                     $news_items_nids = array_keys($result['node']);
                     node_delete_multiple($news_items_nids);
                 }
                 header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/5");
             } else {
                 header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4");
             }
         }
     } else {
         header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4");
     }
 }
Esempio n. 26
0
function deldir($dirname)
{
    if (file_exists($dirname)) {
        $dir = opendir($dirname);
        while ($filename = readdir($dir)) {
            if ($filename != "." && $filename != "..") {
                $file = $dirname . "/" . $filename;
                if (is_dir($file)) {
                    deldir($file);
                    //使用递归删除子目录
                } else {
                    @unlink($file);
                }
            }
        }
        closedir($dir);
        rmdir($dirname);
    }
}
Esempio n. 27
0
function cfile($files = ['js', 'css/img', 'images', 'plugin/js', 'plugin/css', 'doc'], $root = 'item')
{
    $root_dir = str_replace('\\', '/', __DIR__);
    // echo $root_dir."\n";
    // exit;
    if (is_dir($root)) {
        deldir($root);
    }
    foreach ($files as $v) {
        $path = $root_dir . '/' . $root . '/' . $v;
        // echo $path;exit;
        //第三个参数是“true”表示能创建多级目录,iconv防止中文目录乱码
        $res = mkdir(iconv("UTF-8", "GBK", $path), 0777, true);
        if (!$res) {
            echo "目录 {$path} 创建失败";
            exit;
        }
    }
}
/**
 * This function deletes an entire directory
 * @param	string	The directory path
 * @return boolean	True on success, false on failure
 */
function deldir($dir)
{
    $dh = opendir($dir);
    while ($file = readdir($dh)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $dir . '/' . $file;
            if (!is_dir($fullpath)) {
                unlink($fullpath);
            } else {
                deldir($fullpath);
            }
        }
    }
    closedir($dh);
    if (rmdir($dir)) {
        return true;
    }
    return false;
}
Esempio n. 29
0
function deldir($location)
{
    if (substr($location, -1) != "/") {
        $location = $location . "/";
    }
    $all = opendir($location);
    while ($file = readdir($all)) {
        if (is_dir($location . $file) && $file != ".." && $file != ".") {
            deldir($location . $file);
            rmdir($location . $file);
            unset($file);
        } elseif (!is_dir($location . $file)) {
            unlink($location . $file);
            unset($file);
        }
    }
    closedir($all);
    rmdir($location);
}
Esempio n. 30
0
function deldir($dir)
{
    $handle = opendir($dir);
    while (false !== ($FolderOrFile = readdir($handle))) {
        if ($FolderOrFile != "." && $FolderOrFile != "..") {
            if (@is_dir("{$dir}/{$FolderOrFile}")) {
                deldir("{$dir}/{$FolderOrFile}");
            } else {
                unlink("{$dir}/{$FolderOrFile}");
            }
        }
    }
    closedir($handle);
    if (rmdir($dir)) {
        // put mention into the admin log
        audit('', 'Image Manager', 'Removed Directory ' . $dir);
        $success = true;
    }
    return $success;
}