From 286d8048a62a0d5e4c73c5a8a961b286e90fffb1 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Thu, 26 Apr 2012 01:33:33 +0000 Subject: [PATCH] Clear DB cache before e107_update and some cleanup in admin->cache code. --- e107_admin/cache.php | 40 +++++----------- e107_admin/update_routines.php | 26 ++++------- e107_handlers/cache_handler.php | 61 +++++++++++++++++++++++++ e107_handlers/media_class.php | 5 +- e107_plugins/gallery/includes/admin.php | 4 +- 5 files changed, 87 insertions(+), 49 deletions(-) diff --git a/e107_admin/cache.php b/e107_admin/cache.php index 47e40e569..e96c94e54 100644 --- a/e107_admin/cache.php +++ b/e107_admin/cache.php @@ -34,7 +34,7 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); $e_sub_cat = 'cache'; require_once("auth.php"); -$ec = e107::getCache(); + $frm = e107::getForm(); $emessage = eMessage::getInstance(); @@ -65,38 +65,38 @@ if (isset($_POST['trigger_empty_cache'])) switch ($_POST['option_clear_cache']) { case 'empty_contentcache': - $ec->clear(); + e107::getCache()->clearAll('content'); e107::getAdminLog()->flushMessages(CACLAN_5); break; case 'empty_syscache': - $ec->clear_sys(); + e107::getCache()->clearAll('system'); e107::getAdminLog()->flushMessages(CACLAN_16); break; case 'empty_dbcache': - admin_page_cache_erase(e_CACHE_DB, '*.php'); + e107::getCache()->clearAll('db'); e107::getAdminLog()->flushMessages(CACLAN_24); break; case 'empty_imgcache': - admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin'); + e107::getCache()->clearAll('image'); e107::getAdminLog()->flushMessages(CACLAN_25); break; // used in standard page output and internal JS includes case 'empty_browsercache': - e107::getConfig()->set('e_jslib_browser_cache', time())->save(false); + e107::getCache()->clearAll('browser'); e107::getAdminLog()->flushMessages(CACLAN_25); break; // all default: - $ec->clear(); - $ec->clear_sys(); - admin_page_cache_erase(e_CACHE_DB, '*.php'); - admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin'); - e107::getConfig()->set('e_jslib_browser_cache', time())->save(false); + e107::getCache()->clearAll('content'); + e107::getCache()->clearAll('system'); + e107::getCache()->clearAll('db'); + e107::getCache()->clearAll('image'); + e107::getCache()->clearAll('browser'); e107::getAdminLog()->flushMessages(CACLAN_26); break; } @@ -196,22 +196,4 @@ e107::getRender()->tablerender(CACLAN_3, $emessage->render().$text); require_once("footer.php"); -/** - * @param string $path - * @param string $mask - * @return void - */ -function admin_page_cache_erase($path, $mask) -{ - $fl = e107::getFile(false); - $fl->mode = 'fname'; - $files = $fl->get_files($path, $fmask); - if($files) - { - foreach ($files as $file) - { - unlink($path.$file); - } - } -} ?> \ No newline at end of file diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index cac524883..fad5c997a 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -273,6 +273,8 @@ function update_706_to_800($type='') $sql = e107::getDb(); $sql2 = e107::getDb('sql2'); $tp = e107::getParser(); + + e107::getCache()->clearAll('db'); // List of unwanted $pref values which can go $obs_prefs = array('frontpage_type','rss_feeds', 'log_lvcount', 'zone', 'upload_allowedfiletype', 'real', 'forum_user_customtitle', @@ -1033,23 +1035,15 @@ function update_706_to_800($type='') if($count != 1) { if ($just_check) return update_needed('Add Media-Manager Categories and Import existing images.'); - - $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_owner`, `media_cat_title`, `media_cat_diz`, `media_cat_class`) VALUES - (1, '_common', '_common', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253, '', 0), - (2, 'news', 'news', 'News', 'Will be available in the news area. ', 253, '', 0), - (3, 'page', 'page', 'Custom Pages', 'Available in the custom pages area of admin. ', 253, '', 0), - (4, 'gallery', 'gallery_1', 'Gallery 1', 'Available to the public at /gallery.php ', 0, '', 0), - (5, 'download', 'thumb', 'Download Thumbnails', 'Available to the downloads plugin', 253, '', 0), - (6, 'download', 'image', 'Download Images', 'Available to the downloads plugin', 253, '', 0), - (7, '_icon', '_icon_16', 'Icons 16px', 'Available where icons are used in admin. ', 253, '', 0), - (8, '_icon', '_icon_32', 'Icons 32px', 'Available where icons are used in admin. ', 253, '', 0), - (9, '_icon', '_icon_48', 'Icons 48px', 'Available where icons are used in admin. ', 253, '', 0), - (10, '_icon', '_icon_64', 'Icons 64px', 'Available where icons are used in admin. ', 253, '', 0); - - "; - - mysql_query($query); + + mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253, '', 0);"); + mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'news', 'news', 'News', 'Will be available in the news area. ', 253, '', 1);"); + mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'page', 'page', 'Custom Pages', 'Will be available in the custom pages area of admin. ', 253, '', 0);"); + mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_image', 'Download Images', '', 253, '', 0);"); + mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'download', 'download_thumb', 'Download Thumbnails', '', 253, '', 0);"); + mysql_query("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, 'gallery', 'gallery_1', 'Gallery', 'Visible to the public at /gallery.php', 0, '', 0);"); + $med->import('news_thumb', e_IMAGE.'newspost_images',"^thumb_"); $med->import('news',e_IMAGE.'newspost_images'); $med->import('page',e_IMAGE.'custom'); diff --git a/e107_handlers/cache_handler.php b/e107_handlers/cache_handler.php index 6adc1df26..4b8c74147 100644 --- a/e107_handlers/cache_handler.php +++ b/e107_handlers/cache_handler.php @@ -264,4 +264,65 @@ class ecache { return false; } } + + + // Clear Full Catche + /** + * @param string $type: content | system| browser | db | image + * @example clearAll('db'); + */ + + function clearAll($type) + { + + $path = null; + $mask = null; + + if($type =='content') + { + $this->clear(); + return; + } + + if($type == 'system') + { + $this->clear_sys(); + return; + } + + if($type == 'browser') + { + e107::getConfig()->set('e_jslib_browser_cache', time())->save(false); + return; + } + + if($type == 'db') + { + $path = e_CACHE_DB; + $mask = '*.php'; + } + + if($type == 'image') + { + $path = e_CACHE_IMAGE; + $mask = '*.cache\.bin'; + } + + if((null == $path) || (null == $mask)) + { + return; + } + + $fl = e107::getFile(false); + $fl->mode = 'fname'; + $files = $fl->get_files($path, $fmask); + if($files) + { + foreach ($files as $file) + { + unlink($path.$file); + } + } + } + } diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 0fa3891cd..69699adb9 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -30,7 +30,7 @@ class e_media * @param string $fmask [optional] filetypes eg. .jpg|.gif * @return e_media */ - public function import($cat,$epath,$fmask='') + public function import($cat='',$epath,$fmask='') { if(!vartrue($cat)){ return $this;} @@ -60,7 +60,7 @@ class e_media foreach($img_array as $f) { $fullpath = $tp->createConstants($f['path'].$f['fname'],1); - + // echo "
cat=".$cat; $insert = array( 'media_caption' => $f['fname'], 'media_description' => '', @@ -79,6 +79,7 @@ class e_media if(!$sql->db_Select('core_media','media_url',"media_url = '".$fullpath."' LIMIT 1")) { + if($sql->db_Insert("core_media",$insert)) { $mes->addSuccess("Imported Media: ".$f['fname']); diff --git a/e107_plugins/gallery/includes/admin.php b/e107_plugins/gallery/includes/admin.php index 31375536a..c41273dec 100644 --- a/e107_plugins/gallery/includes/admin.php +++ b/e107_plugins/gallery/includes/admin.php @@ -132,8 +132,8 @@ class gallery_cat_admin_ui extends e_admin_ui 'slideshow_auto' => array('title'=> 'Slide auto-start', 'type'=>'boolean', 'data' => 'integer','help' => 'When enabled image-rotation begins automatically when the page is loaded.'), 'slideshow_freq' => array('title'=> 'Slide frequency', 'type' => 'number', 'data' => 'integer', 'help'=>'When auto-start is enabled, this dictates how long a slides stays put before the next jump. '), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')), 'slideshow_circular' => array('title'=> 'Slide circular-mode', 'type' => 'boolean', 'data' => 'integer', 'help'=>'By default when the first/last slide is reached, calling prev/next does nothing. If you want the effect to continue enable this option.'), // - 'slideshow_effect' => array('title'=> 'Slide Effect', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of effect. '), // - 'slideshow_transition' => array('title'=> 'Slide Transition', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of transition. ') // + 'slideshow_effect' => array('title'=> 'Slide effect', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of effect. '), // + 'slideshow_transition' => array('title'=> 'Slide transition', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Type of transition. ') // );