diff --git a/language/english.php b/language/english.php index c51ea7f37..e57d97ae3 100644 --- a/language/english.php +++ b/language/english.php @@ -1554,7 +1554,7 @@ 153 => 'You last emailed an article %1$d seconds ago. This site requires at least %2$d seconds between emailing articles.', 400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership 401 => 'Please enter Fullname', - 500 => 'The Template Cache has been successfully cleared.' + 500 => 'The Data, Template, Resource, and File Manager Cache has been successfully cleared.' ); ############################################################################### diff --git a/language/english_utf-8.php b/language/english_utf-8.php index 5ba0748fb..e0aed06ba 100644 --- a/language/english_utf-8.php +++ b/language/english_utf-8.php @@ -1555,7 +1555,7 @@ 153 => 'You last emailed an article %1$d seconds ago. This site requires at least %2$d seconds between emailing articles.', 400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership 401 => 'Please enter Fullname', - 500 => 'The Template Cache has been successfully cleared.' + 500 => 'The Data, Template, Resource, and File Manager Cache has been successfully cleared.' ); ############################################################################### diff --git a/language/japanese_utf-8.php b/language/japanese_utf-8.php index 2699f3b2e..fb0d6eacc 100644 --- a/language/japanese_utf-8.php +++ b/language/japanese_utf-8.php @@ -1556,7 +1556,7 @@ 153 => 'あなたは %1$d 秒前に友だちに記事を送信しています。次に送信する前に %2$d 秒以上あけてください。', 400 => '検証に通っていない必須のフィールドがあります。', 401 => '氏名を入力してください。', - 500 => 'テンプレートのキャッシュを削除しました。' + 500 => 'The Data, Template, Resource, and File Manager Cache has been successfully cleared.' ); ############################################################################### diff --git a/public_html/admin/clearctl.php b/public_html/admin/clearctl.php index a4fc64811..85a024f88 100644 --- a/public_html/admin/clearctl.php +++ b/public_html/admin/clearctl.php @@ -40,12 +40,72 @@ exit; } +// Clean directory +function clean_directory($dir, $leave_dirs = array(), $leave_files = array()) { + + foreach( glob("$dir/*") as $file ) { + if (is_dir($file)) { + if (!in_array(basename($file), $leave_dirs)) { + delete_files($file); // delete all sub directories and files in those directories + } + } elseif( !in_array(basename($file), $leave_files) ) { + unlink($file); + } + } +} + +// Delete all files in a directory and any sub directory +function delete_files($dir) { + + foreach(glob($dir . '/*') as $file) { + if (is_dir($file)) { + delete_files($file); + } else { + unlink($file); + } + } + rmdir($dir); +} + /* * Main processing */ -CTL_clearCache(); // Clearing Template Cache + +// Clearing Theme Template Cache +CTL_clearCache(); + +// Clearing Resource Cache (CSS, and Javascript concatenated and minified files) +Geeklog\Cache::clear(); + +// Clean out Data directory (includes things like temp uploaded plugin files, user batch files, etc...) +$leave_dirs = array('cache', 'layout_cache', 'layout_css'); +$leave_files = array('cacert.pem', 'README'); +clean_directory($_CONF['path_data'], $leave_dirs, $leave_files); + +// File Manager Thumbnail Files + +$leave_dirs = array(); +$leave_files = array('index.html'); +clean_directory($_CONF['path_images'] . '_thumbs/articles/', $leave_dirs, $leave_files); + +$leave_dirs = array(); +$leave_files = array('index.html'); +clean_directory($_CONF['path_images'] . '_thumbs/userphotos/', $leave_dirs, $leave_files); + +$leave_dirs = array(); +$leave_files = array('index.html'); +clean_directory($_CONF['path_images'] . '_thumbs/library/image/', $leave_dirs, $leave_files); + +$leave_dirs = array('Image'); +$leave_files = array(); +clean_directory($_CONF['path_images'] . '_thumbs/library/', $leave_dirs, $leave_files); + +$leave_dirs = array('articles', 'library', 'userphotos'); +$leave_files = array(); +clean_directory($_CONF['path_images'] . '_thumbs/', $leave_dirs, $leave_files); -Geeklog\Cache::clear(); // Clearing Resource Cache (CSS, and Javascript concatenated and minified files) +// Allow Plugins to clear any cached items +PLG_clearCache(); COM_redirect($_CONF['site_admin_url'] . '/index.php?msg=500'); diff --git a/system/lib-plugins.php b/system/lib-plugins.php index dc8290e3b..56ae67447 100644 --- a/system/lib-plugins.php +++ b/system/lib-plugins.php @@ -2315,6 +2315,27 @@ function PLG_getItemInfo($type, $id, $what, $uid = 0, $options = array()) return PLG_callFunctionForOnePlugin($function, $args); } +/** + * Asks each plugin tif they want to clear any cache of files they control + * Used by clear cache in Geeklog Administration + * + * @return array Plugins that cleared their cache files and if they where successful or not + */ +function PLG_clearCache() +{ + global $_PLUGINS; + + $plugin_cache_name = array(); + foreach ($_PLUGINS as $pi_name) { + $function = 'plugin_clearcache_' . $pi_name; + if (function_exists($function)) { + $plugin_cache_name[$pi_name] = $function(); // Should return true if success + } + } + + return $plugin_cache_name; +} + /** * Geeklog is about to perform an operation on a trackback or pingback comment * to one of the items under the plugin's control and asks for the plugin's