Options -> DUI, select Unused images file that you want to delete then press delete button. 6. This is IMPORTANT step after delete unused images file you must Chmod monthly archives directory to previous value(most are 755). */ ### Load WP-Config File If This File Is Called Directly if (!function_exists('add_action')) { require_once('../../../wp-config.php'); } // Check an Unused image file function CheckUnusedImage($ImageFileName) { global $wpdb,$table_prefix; $result = intval($wpdb->get_var("SELECT COUNT(*) FROM ".$table_prefix."posts WHERE post_content LIKE '%/$ImageFileName%'")); return $result>0; } // Get list image file function GetImageFileName($ImageDir) { global $TotalImageCnt; $FileCnt = 0; $UnUsedImages = array(); if (is_dir($ImageDir)) { if ($DirHndl = opendir($ImageDir)) { $files = array(); while (($file = readdir($DirHndl))) { $path = pathinfo($file); if (eregi('(jpg)|(gif)|(png)|(jpeg)', $path['extension']) || eregi('(thumbnail)',$path['basename'])) $files[] = $file; } closedir($DirHndl); //print_r($files); if (count($files)) { foreach ($files as $fn) { if (!CheckUnusedImage($fn)) { $home = get_option('home'); $upload_path = get_option('upload_path'); $UnUsedImages[$FileCnt] = $fn.'::'.$home.'/'.$upload_path.'/'.$ImageDir.'/'.$fn; $FileCnt++; $TotalImageCnt++; } } } } } return $UnUsedImages; } // select directory function select_year_directory($year) { $Yeardirectory = array(); $month = array('01','02','03','04','05','06','07','08','09','10','11','12'); for ($i=0;$i<12;$i++) { $dir =getcwd(); if (is_dir($dir.'/'.$year.'/'.$month[$i])) { $Yeardirectory[$month[$i]] = GetImageFileName($year.'/'.$month[$i]); } } return $Yeardirectory; } // check image in directory function CheckInDir($Dir) { if ($dh = opendir($Dir)) { while ($el = readdir($dh)) { $path = $el; if (is_dir($path) && $el != '.' && $el != '..') { $year_result[$path] = select_year_directory($path); //echo $path.'
'; } } closedir($dh); } return $year_result; } //----------------------------------------------------------------------------------- // add management in option menu function add_DUI_option_menu() { if (function_exists('add_options_page')) { // is this check needed? add_options_page('DUI option', 'DUI', 8, basename(__FILE__), 'DUI_options'); } } // main option ----------- function DUI_options() { ?>

Delete Unused Images

'.$fdt[1].' Deleted
'; }else{ echo $fdt[0].'---> '.$fdt[1].' Cannot delete file.Please change directory premissions on '.$fdt[0].' to 777
'; } chdir("../../../"); } echo "
"; } } global $TotalImageCnt; chdir("../"); $upload_dir = get_option('upload_path'); chdir($upload_dir); $newdir = getcwd(); $TotalImageCnt=0; $result = CheckInDir($newdir); ?> There are total ".$TotalImageCnt." unused images file

"; ?>
$monthArr) { foreach ($monthArr as $month => $UnUsedImagesArr) { if (count($UnUsedImagesArr)<>0) { echo ''.$year.'/'.$month.'
'; foreach ($UnUsedImagesArr as $UnUsedImages) { $IMF = explode("::",$UnUsedImages); echo ''.$IMF[0]. '    View
'; } echo '
'; } // end if } } } ?>



www.BobHobby.com
Shouting at Cows »

What's exceptional about a primitive tribe like the Yacumo being... terrorized, and forced into doing something they don't... they don't normally do?