示例#1
0
/**
 * Remove dir
 * @param $path
 * @return bool
 */
function brs_removeDir($path)
{
    if (empty($path) && $path != '0') {
        return false;
    }
    if (file_exists($path) && is_dir($path)) {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle))) {
            if ($file != '.' && $file != '..') {
                // исключаем папки с назварием '.' и '..'
                $tmpPath = $path . '/' . $file;
                chmod($tmpPath, 0777);
                // если папка
                if (is_dir($tmpPath)) {
                    brs_removeDir($tmpPath);
                } else {
                    // удаляем файл
                    if (file_exists($tmpPath)) {
                        unlink($tmpPath);
                    }
                }
            }
        }
        closedir($dirHandle);
        // удаляем текущую папку
        if (file_exists($path)) {
            rmdir($path);
        }
    } else {
        echo "Deleting directory not exists or it's file!";
        return false;
    }
    return true;
}
示例#2
0
<?php

/**
 * Cotonti Plugin Banners
 * Banner rotation plugin with statistics
 *
 * @package Banners
 * @author Kalnov Alexey    <*****@*****.**>
 * @copyright  Portal30 Studio http://portal30.ru
 */
defined('COT_CODE') or die('Wrong URL.');
global $brs_files_dir;
require cot_incfile('brs', 'module');
// Удалить категорию с баннерами
if (file_exists($brs_files_dir)) {
    brs_removeDir($brs_files_dir);
}