示例#1
0
/**
 *删除非空目录
 */
function _remove_Dir($dirName)
{
    if (!is_dir($dirName)) {
        return false;
    }
    $handle = @opendir($dirName);
    while (($file = @readdir($handle)) !== false) {
        if ($file != '.' && $file != '..') {
            $dir = $dirName . '/' . $file;
            is_dir($dir) ? _remove_Dir($dir) : @unlink($dir);
        }
    }
    closedir($handle);
    return rmdir($dirName);
}
示例#2
0
//转换成硬路径,引用速度更快
require dirname(__FILE__) . '/includes/common.inc.php';
//删除相册目录
if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) {
    if (!!($_rows = _fetch_array("select tg_uniqid from tg_user where tg_username='******'username']}' limit 1"))) {
        //为了防止cookie伪造,还要比对一下唯一标示符uniqid()
        _uniqid($_rows['tg_uniqid'], $_COOKIE['uniqid']);
        //删除目录
        //取得这张图片的发布者
        if (!!($_rows = _fetch_array("select tg_dir from tg_dir where tg_id='{$_GET['id']}' limit 1"))) {
            $_html = array();
            $_html['url'] = $_rows['tg_dir'];
            $_html = _html($_html);
            //3、判断目录在磁盘中是否存在
            if (file_exists($_html['url'])) {
                if (_remove_Dir($_html['url'])) {
                    //1、删除目录里的数据库图片
                    _query("delete from tg_photo where tg_sid='{$_GET['id']}'");
                    //2、删除目录的数据库
                    _query("delete from tg_dir where tg_id='{$_GET['id']}'");
                    _close();
                    _location('目录删除成功', 'photo.php');
                } else {
                    _close();
                    _alert_back('目录删除失败');
                }
            }
        } else {
            _alert_back('不存在此目录');
        }
    } else {