function removedir($dirname, $keepdir = FALSE) { $dirname = str_replace(array("\n", "\r", '..'), array('', '', ''), $dirname); 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) ? removedir($dir) : unlink($dir); } } closedir($handle); return !$keepdir ? @rmdir($dirname) ? TRUE : FALSE : TRUE; }
function removedir($dirname, $keepdir = FALSE) { $dirname = wipespecial($dirname); 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) ? removedir($dir) : unlink($dir); } } closedir($handle); return !$keepdir ? @rmdir($dirname) ? TRUE : FALSE : TRUE; }
static function removedir($name) { if (is_dir($name)) { if ($dir = opendir($name)) { while (($file = readdir($dir)) !== false) { $newpath = "{$name}/{$file}"; if (is_dir($newpath)) { if (substr($file, -1, 1) != ".") { removedir($newpath); } } else { unlink($newpath); } } closedir($dir); } if (substr($file, -1, 1) != ".") { rmdir($name); } } }
function removeDir($dir) { foreach (glob($dir . '/*') as $file) { if (is_dir($file)) { removedir($file); } else { unlink($file); } } if (is_dir($dir)) { rmdir($dir); } }
} } else { if ($do = 'mdelete') { $catid = $_G['gp_catid']; $pdnovelop = $_G['gp_pdnovelop']; if ($pdnovelop == 'move') { $toid = $_G['gp_toid']; if (empty($toid)) { cpmsg('category_notoid', 'action=pdnovel&operation=category&do=delete&catid=' . $catid, 'error'); } DB::query('UPDATE ' . DB::table('pdnovel_view') . (' SET catid = ' . $toid . " WHERE catid = {$catid};")); DB::query('DELETE FROM ' . DB::table('pdnovel_category') . (' WHERE catid = ' . $catid . ';')); pdnovelcache('pdnovelcategory', 'pdnovel'); cpmsg('category_delete_succeed', 'action=pdnovel&operation=category', 'succeed'); } else { if ($pdnovelop == 'delete') { $query = DB::query('SELECT novelid FROM ' . DB::table('pdnovel_view') . (' WHERE catid = ' . $catid . ';')); while ($pdnovel = DB::fetch($query)) { $pdnovelid = $pdnovel['pdnovelid']; DB::query('DELETE FROM ' . DB::table('pdnovel_chapter') . (' WHERE novelid=' . $novelid . ';')); removedir('pdnovel/file/' . floor($pdnovelid / 1000) . '/' . $pdnovelid); DB::query('DELETE FROM ' . DB::table('pdnovel_info') . (' WHERE pdnovelid=' . $pdnovelid . ';')); } DB::query('DELETE FROM ' . DB::table('category') . (' WHERE catid = ' . $catid . ';')); pdnovelcache('pdnovelcategory', 'pdnovel'); cpmsg('category_delete_succeed', 'action=pdnovel&operation=category', 'succeed'); } } } } }
// print_r($_SERVER); // проверяем на КЕШ /* * если у нас есть закешированная страница - выводим ее * иначе генерим и создаем кеш страницу */ // используем КЕШ сайта if (USE_KEH == 1) { // подключаем класс работы CONTENT require "classes/cache.class.php"; // если время с создания папки cache/index > 24 часов, удаляем ее if (get_date_last_modify_file_in_second(HOST . '/cache/index') > 86400) { /* * удаляем кеш */ removedir(HOST . "/cache/index"); } use_keh(); } // если печатаем страницу if (isset($_GET['action']) and $_GET['action'] == "print") { require HOST . "/ctrl/print/print.php"; exit; } if (DEBUG_SITE == 1) { error_reporting(E_ALL); ini_set('display_errors', 1); } if (DEBUG_SITE == 1) { // время $profiler->enterSection('center');
function remove_dir($dirname) { if (is_dir($dirname)) { $dir_handle = opendir($dirname); } if (!$dir_handle) { return false; } while ($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { if (!is_dir($dirname . "/" . $file)) { unlink($dirname . "/" . $file); } else { $a = $dirname . '/' . $file; removedir($a); } } } closedir($dir_handle); rmdir($dirname); return true; }
<?php /* [Discuz!] (C)2001-2007 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: cleanup_daily.inc.php 9806 2007-08-15 06:04:37Z cnteacher $ */ if (!defined('IN_DISCUZ')) { exit('Access Denied'); } $db->query("UPDATE {$tablepre}advertisements SET available='0' WHERE endtime>'0' AND endtime<='{$timestamp}'", 'UNBUFFERED'); if ($db->affected_rows()) { require_once DISCUZ_ROOT . './include/cache.func.php'; updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread')); } $db->query("TRUNCATE {$tablepre}searchindex"); $db->query("DELETE FROM {$tablepre}threadsmod WHERE dateline<'{$timestamp}'-31536000", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}subscriptions WHERE lastpost<'{$timestamp}'-7776000", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}forumrecommend WHERE expiration<'{$timestamp}'", 'UNBUFFERED'); if ($qihoo['status'] && $qihoo['relatedthreads']) { $db->query("DELETE FROM {$tablepre}relatedthreads WHERE expiration<'{$timestamp}'", 'UNBUFFERED'); } $db->query("UPDATE {$tablepre}trades SET closed='1' WHERE expiration<>0 AND expiration<'{$timestamp}'", 'UNBUFFERED'); $db->query("DELETE FROM {$tablepre}tradelog WHERE status=0 AND lastupdate<'" . ($timestamp - 5 * 86400) . "'", 'UNBUFFERED'); if ($cachethreadon) { removedir($cachethreaddir, TRUE); } if ($regstatus > 1) { $db->query("UPDATE {$tablepre}invites SET status='4' WHERE expiration<'{$timestamp}' AND status IN ('1', '3')"); }
} $md5 = md5_file(DISCUZ_ROOT . './' . $script); $discuzfiles = file(DISCUZ_ROOT . './data/discuzfiles.md5'); $md5datanew = array(); foreach ($discuzfiles as $line) { $md5file = trim(substr($line, 34)); $md5str = trim(substr($line, 0, 32)); $md5datanew[$md5file] = $md5str; } $md5datanew['./' . $script] = $md5; $fp = fopen(DISCUZ_ROOT . './data/discuzfiles.md5', 'wb'); foreach ($md5datanew as $key => $val) { fwrite($fp, $val . ' *' . $key . "\r\n"); } fclose($fp); if ($run) { include_once $script; dftp_delete($ftpid, $script); } dftp_close($ftpid); } exit(true); } } elseif ($operation == 'openbbs') { if (!($bbc = intval($bbc))) { removedir($packagepath); } DB::query("UPDATE " . DB::table('common_setting') . " SET svalue='{$bbc}' WHERE skey='bbclosed'"); updatecache('setting'); exit(true); }
function renptyoveDir($dirName) { if (!is_dir($dirName)) { @unlink($dirName); return false; } $handle = @opendir($dirName); while (($file = @readdir($handle)) !== false) { if (!($file != ".") && !($file != "..")) { $dir = $dirName . "/" . $file; is_dir($dir) ? removedir($dir) : unlink($dir); } } closedir($handle); return rmdir($dirName); }
function delete_all_cache() { require_once HOST . "/classes/cache.class.php"; // удаляем весь каталог removedir(HOST . "/cache"); // создаем новій каталог, устанавливаем права $flag = @mkdir(HOST . "/cache", "0700"); @chmod(HOST . "/cache", 0777); }
/** * Delete a directory and its whole content * * @author - Hugues Peeters * @param - $dirPath (String) - the path of the directory to delete * @return - no return ! */ function removeDir($dirPath) { /* Try to remove the directory. If it can not manage to remove it, * it's probable the directory contains some files or other directories, * and that we must first delete them to remove the original directory. */ if (!@rmdir($dirPath)) { chdir($dirPath); $handle = opendir($dirPath); while ($element = readdir($handle)) { if ($element == '.' || $element == '..') { continue; // skip current and parent directories } elseif (is_file($element)) { unlink($element); } elseif (is_dir($element)) { $dirToRemove[] = $dirPath . '/' . $element; } } closedir($handle); if (sizeof($dirToRemove) > 0) { foreach ($dirToRemove as $j) { removedir($j); } // recursivity } rmdir($dirPath); } }