/** * Remove a directory and all its contents, including subdirectories. * * @param string $filePath The path to the file or directory to remove. * * @return void */ function rmrdir($filePath) { $objects = scandir($filePath); foreach ($objects as $object) { if ($object !== '.' && $object !== '..') { if (filetype($filePath . '/' . $object) === 'dir') { rmrdir($filePath . '/' . $object); } else { unlink($filePath . '/' . $object); } } } rmdir($filePath); }
function rmrdir($dir) { if (is_dir($dir)) { $handle = @opendir($dir); if ($handle) { for (; false !== ($readdir = @readdir($handle));) { if ($readdir != '.' && $readdir != '..') { $path = $dir . '/' . $readdir; if (is_dir($path)) { rmrdir($path); } if (is_file($path)) { unlink($path); } } } closedir($handle); } } }
// Show error echo 'mysqldump-php error: ' . $e->getMessage(); } } } // Delete old dump according to the constant if (DUMP_DURATION > 0) { // init arrays of dumps directory $dirs = []; // get all dump folder foreach (glob(DUMP_FOLDER . '/*', GLOB_ONLYDIR) as $fold) { $date_folder = DateTime::createFromFormat('Ymd_His', basename($fold)); $dirs[] = ["name" => $fold, "date" => $date_folder]; } // if number of folder is greater than the number of dump autorized if (count($dirs) > DUMP_DURATION) { // Sort files by date : older first usort($dirs, function ($a, $b) { return $b["date"] < $a["date"]; }); // drop the element from the array we don't want delete for ($i = 0; $i < DUMP_DURATION; $i++) { array_pop($dirs); } // for all elements who are in the array foreach ($dirs as $d) { // use rmrdir from perchten/rmrdir rmrdir($d['name']); } } }
<?php if (file_exists(INCLUDE_PATH . '/plugins/clickheat/libs/index.php')) { echo "Updating to phpMyVisites 2.4...\n <br/>Deleting the plugin clickheat (which contains a security issue)..."; @rmrdir(INCLUDE_PATH . '/plugins/clickheat/'); @unlink(INCLUDE_PATH . '/datas/thumbs.php'); @unlink(INCLUDE_PATH . '/config/plugin.php'); echo "<br><br><b><font size='13pt' color=red>Please remove the clickheat Javascript code from your pages if you were using clickheat!</font></b>"; }