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?
/*
Plugin Name: DUI
Version: 1.0
Plugin URI: http://www.bobhobby.com/2008/02/24/delete-unused-image-files-plugin-for-wordpress/
Author: Bob carret
Author URI: http://www.bobhobby.com/
Description: This plugin will delete UnUsed images file that was not referred by any post and page of wordpress
*/
/*
Copyright (c) 2008 www.bobhobby.com
Released under the GPL license
http://www.gnu.org/licenses/gpl.txt
Disclaimer:
Use at your own risk. No warranty expressed or implied is provided.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Requires : Wordpress 2.3.X or newer ,PHP 5 +
Usage :
1. Download plugin and unzip
2. Upload the plugin file to your WordPress plugins directory inside of wp-content.(i.e. www.YourDomain.com/blog/wp-content/plugin/dui/duixx.php)
3. Activate it from the plugins menu inside of WordPress.
4. Change Permissions monthly archives directory by Chmod to 777 with your favorite FTP Client Software(i.e. cuteFTP)
5. Go to Admin Control panal -> 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()
{
?>
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?