mirror of
https://github.com/e107inc/e107.git
synced 2025-08-10 00:27:45 +02:00
EONE-10 (Task): Option to clear DB/Image cache added (Admin interface), Cache administration cleanup, phpDoc fixes
This commit is contained in:
@@ -12,6 +12,16 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin page - cache management
|
||||||
|
*
|
||||||
|
* @package e107
|
||||||
|
* @subpackage admin
|
||||||
|
* @version $Id$;
|
||||||
|
* @author e107 Inc
|
||||||
|
*/
|
||||||
|
|
||||||
require_once("../class2.php");
|
require_once("../class2.php");
|
||||||
if (!getperms("C"))
|
if (!getperms("C"))
|
||||||
{
|
{
|
||||||
@@ -24,72 +34,81 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
|
|||||||
$e_sub_cat = 'cache';
|
$e_sub_cat = 'cache';
|
||||||
|
|
||||||
require_once("auth.php");
|
require_once("auth.php");
|
||||||
require_once(e_HANDLER."cache_handler.php");
|
$ec = e107::getCache();
|
||||||
require_once(e_HANDLER."form_handler.php");
|
$frm = e107::getForm();
|
||||||
require_once(e_HANDLER."message_handler.php");
|
|
||||||
$ec = new ecache;
|
|
||||||
$frm = new e_form();
|
|
||||||
|
|
||||||
$emessage = eMessage::getInstance();
|
$emessage = eMessage::getInstance();
|
||||||
|
|
||||||
if ($pref['cachestatus'] == '2')
|
if (e107::getPref('cachestatus') == '2')
|
||||||
{
|
{
|
||||||
$pref['cachestatus'] = '1';
|
e107::getConfig()->set('cachestatus', 1)
|
||||||
save_prefs();
|
->save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_writable(e_CACHE_CONTENT))
|
if(!is_writable(e_CACHE_CONTENT))
|
||||||
{
|
{
|
||||||
$ns->tablerender(CACLAN_3, CACLAN_10."<br />(".$CACHE_DIRECTORY.")");
|
e107::getRender()->tablerender(CACLAN_3, CACLAN_10."<br />(".$CACHE_DIRECTORY.")");
|
||||||
require_once("footer.php");
|
require_once("footer.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['submit_cache']))
|
if (isset($_POST['submit_cache']))
|
||||||
{
|
{
|
||||||
if ($pref['cachestatus'] != $_POST['cachestatus'] || $pref['syscachestatus'] != $_POST['syscachestatus'])
|
e107::getConfig()->set('cachestatus', intval($_POST['cachestatus']))
|
||||||
|
->set('syscachestatus', intval($_POST['syscachestatus']))
|
||||||
|
->save(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['trigger_empty_cache']))
|
||||||
|
{
|
||||||
|
e107::getAdminLog()->logSuccess(CACLAN_6);
|
||||||
|
switch ($_POST['option_clear_cache'])
|
||||||
{
|
{
|
||||||
$pref['cachestatus'] = $_POST['cachestatus'] ? '1' : '0';
|
case 'empty_contentcache':
|
||||||
$pref['syscachestatus'] = $_POST['syscachestatus'] ? '1' : '0';
|
$ec->clear();
|
||||||
|
e107::getAdminLog()->flushMessages(CACLAN_5);
|
||||||
|
break;
|
||||||
|
|
||||||
save_prefs();
|
case 'empty_syscache':
|
||||||
$admin_log->log_event('CACHE_01', $pref['syscachestatus'].', '.$pref['cachestatus'], E_LOG_INFORMATIVE,'');
|
$ec->clear_sys();
|
||||||
|
e107::getAdminLog()->flushMessages(CACLAN_16);
|
||||||
|
break;
|
||||||
|
|
||||||
$ec->clear();
|
case 'empty_dbcache':
|
||||||
$ec->clear_sys();
|
admin_page_cache_erase(e_CACHE_DB, '*.php');
|
||||||
|
e107::getAdminLog()->flushMessages(CACLAN_24);
|
||||||
|
break;
|
||||||
|
|
||||||
$emessage->add(CACLAN_4, E_MESSAGE_SUCCESS);
|
case 'empty_imgcache':
|
||||||
}
|
admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin');
|
||||||
else
|
e107::getAdminLog()->flushMessages(CACLAN_25);
|
||||||
{
|
break;
|
||||||
$emessage->add(LAN_NO_CHANGE, E_MESSAGE_INFO);
|
|
||||||
|
// 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::getAdminLog()->flushMessages(CACLAN_26);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['empty_syscache']))
|
$syscache_files = glob(e_CACHE_CONTENT.'S_*.*');
|
||||||
{
|
$cache_files = glob(e_CACHE_CONTENT.'C_*.*');
|
||||||
$ec->clear_sys();
|
$imgcache_files = glob(e_CACHE_IMAGE.'*.cache.bin');
|
||||||
$admin_log->log_event('CACHE_02', $pref['syscachestatus'].', '.$pref['cachestatus'], E_LOG_INFORMATIVE, '');
|
$dbcache_files = glob(e_CACHE_DB.'*.php');
|
||||||
$emessage->add(CACLAN_15, E_MESSAGE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['empty_cache']))
|
|
||||||
{
|
|
||||||
$ec->clear();
|
|
||||||
$admin_log->log_event('CACHE_03', $pref['syscachestatus'].', '.$pref['cachestatus'], E_LOG_INFORMATIVE, '');
|
|
||||||
$emessage->add(CACLAN_6, E_MESSAGE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$syscache_files = glob(e_CACHE_CONTENT."S_*.*");
|
|
||||||
$cache_files = glob(e_CACHE_CONTENT."C_*.*");
|
|
||||||
|
|
||||||
$syscache_files_num = count($syscache_files);
|
$syscache_files_num = count($syscache_files);
|
||||||
$cache_files_num = count($cache_files);
|
$cache_files_num = count($cache_files);
|
||||||
|
$imgcache_files_num = count($imgcache_files);
|
||||||
|
$dbcache_files_num = count($dbcache_files);
|
||||||
|
|
||||||
$sys_count = CACLAN_17." ".$syscache_files_num." ".($syscache_files_num != 1 ? CACLAN_19 : CACLAN_18);
|
$syscache_label = CACLAN_17.' <strong>'.$syscache_files_num.' '.($syscache_files_num != 1 ? CACLAN_19 : CACLAN_18).'</strong>';
|
||||||
$nonsys_count = CACLAN_17." ".$cache_files_num." ".($cache_files_num != 1 ? CACLAN_19 : CACLAN_18);
|
$contentcache_label = CACLAN_17.' <strong>'.$cache_files_num.' '.($cache_files_num != 1 ? CACLAN_19 : CACLAN_18).'</strong>';
|
||||||
|
$imgcache_label = CACLAN_17.' <strong>'.$imgcache_files_num.' '.($imgcache_files_num != 1 ? CACLAN_19 : CACLAN_18).'</strong>';
|
||||||
|
$dbcache_label = CACLAN_17.' <strong>'.$dbcache_files_num.' '.($dbcache_files_num != 1 ? CACLAN_19 : CACLAN_18).'</strong>';
|
||||||
|
|
||||||
$text = "
|
$text = "
|
||||||
<form method='post' action='".e_SELF."'>
|
<form method='post' action='".e_SELF."'>
|
||||||
@@ -109,39 +128,76 @@ $text = "
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<strong>".CACLAN_11."</strong>: {$nonsys_count}
|
<strong>".CACLAN_11."</strong>: {$contentcache_label}
|
||||||
<div class='field-help'>".CACLAN_13."</div>
|
<div class='field-help'>".CACLAN_13."</div>
|
||||||
</td>
|
</td>
|
||||||
<td class='center middle'>
|
<td class='center middle'>
|
||||||
".$frm->radio('cachestatus', 1, ($pref['cachestatus']))."
|
".$frm->radio_switch('cachestatus', e107::getPref('cachestatus'))."
|
||||||
".$frm->label(LAN_ENABLED, 'cachestatus', 1)."
|
|
||||||
".$frm->radio('cachestatus', 0, (!$pref['cachestatus']))."
|
|
||||||
".$frm->label(LAN_DISABLED, 'cachestatus', 0)."
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<strong>".CACLAN_12."</strong>: {$sys_count}
|
<strong>".CACLAN_12."</strong>: {$syscache_label}
|
||||||
<div class='field-help'>".CACLAN_14."</div>
|
<div class='field-help'>".CACLAN_14."</div>
|
||||||
</td>
|
</td>
|
||||||
<td class='center middle'>
|
<td class='center middle'>
|
||||||
".$frm->radio('syscachestatus', 1, ($pref['syscachestatus']))."
|
".$frm->radio_switch('syscachestatus', e107::getPref('syscachestatus'))."
|
||||||
".$frm->label(LAN_ENABLED, 'syscachestatus', 1)."
|
</td>
|
||||||
".$frm->radio('syscachestatus', 0, (!$pref['syscachestatus']))."
|
</tr>
|
||||||
".$frm->label(LAN_DISABLED, 'syscachestatus', 0)."
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>".CACLAN_20."</strong>: {$dbcache_label}
|
||||||
|
<div class='field-help'>".CACLAN_21."</div>
|
||||||
|
</td>
|
||||||
|
<td class='center middle'>
|
||||||
|
".LAN_ENABLED."
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>".CACLAN_22."</strong>: {$imgcache_label}
|
||||||
|
<div class='field-help'>".CACLAN_23."</div>
|
||||||
|
</td>
|
||||||
|
<td class='center middle'>
|
||||||
|
".LAN_ENABLED."
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class='buttons-bar left'>
|
<div class='buttons-bar left'>
|
||||||
".$frm->admin_button('submit_cache', CACLAN_2, 'update f-right')."
|
".$frm->admin_button('submit_cache', CACLAN_2, 'update f-right')."
|
||||||
".$frm->admin_button('empty_cache', CACLAN_5, 'delete')."
|
".$frm->selectbox('option_clear_cache', array(
|
||||||
".$frm->admin_button('empty_syscache', CACLAN_16, 'delete')."
|
'empty_all' => CACLAN_26,
|
||||||
|
'empty_contentcache' => CACLAN_5,
|
||||||
|
'empty_syscache' => CACLAN_16,
|
||||||
|
'empty_dbcache' => CACLAN_24,
|
||||||
|
'empty_imgcache' => CACLAN_25,
|
||||||
|
))."
|
||||||
|
".$frm->admin_button('trigger_empty_cache', LAN_DELETE, 'delete')."
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>";
|
</form>";
|
||||||
|
|
||||||
$ns->tablerender(CACLAN_3, $emessage->render().$text);
|
e107::getRender()->tablerender(CACLAN_3, $emessage->render().$text);
|
||||||
|
|
||||||
require_once("footer.php");
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
@@ -8,10 +8,8 @@
|
|||||||
*
|
*
|
||||||
* Cache handler
|
* Cache handler
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/cache_handler.php,v $
|
* $URL$
|
||||||
* $Revision$
|
* $Id$
|
||||||
* $Date$
|
|
||||||
* $Author$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -23,9 +21,9 @@ define('CACHE_PREFIX','<?php exit;');
|
|||||||
* FIXME - pref independant cache handler, cache drivers
|
* FIXME - pref independant cache handler, cache drivers
|
||||||
*
|
*
|
||||||
* @package e107
|
* @package e107
|
||||||
* @category e107_handlers
|
* @subpackage e107_handlers
|
||||||
* @version $Revision$
|
* @version $Id$
|
||||||
* @author $Author$
|
* @author e107 Inc
|
||||||
*/
|
*/
|
||||||
class ecache {
|
class ecache {
|
||||||
|
|
||||||
|
@@ -2,16 +2,21 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Copyright (C) 2008-2010 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
|
* $URL$
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File/folder manipulation handler
|
||||||
*
|
*
|
||||||
*
|
* @package e107
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $
|
* @subpackage e107_handlers
|
||||||
* $Revision$
|
* @version $Id$
|
||||||
* $Date$
|
* @author e107 Inc.
|
||||||
* $Author$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -51,8 +56,17 @@ Note:
|
|||||||
|
|
||||||
class e_file
|
class e_file
|
||||||
{
|
{
|
||||||
public $dirFilter; // Array of directory names to ignore (in addition to any set by caller)
|
/**
|
||||||
public $fileFilter; // Array of file names to ignore (in addition to any set by caller)
|
* Array of directory names to ignore (in addition to any set by caller)
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $dirFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of file names to ignore (in addition to any set by caller)
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $fileFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines what array format should return get_files() method
|
* Defines what array format should return get_files() method
|
||||||
@@ -72,22 +86,34 @@ class e_file
|
|||||||
*/
|
*/
|
||||||
public $finfo = 'default';
|
public $finfo = 'default';
|
||||||
|
|
||||||
// Constructor
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->setDefaults();
|
$this->setDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default parameters
|
||||||
|
* @return e_file
|
||||||
|
*/
|
||||||
function setDefaults()
|
function setDefaults()
|
||||||
{
|
{
|
||||||
$this->dirFilter = array('/', 'CVS', '.svn'); // Default directory filter (exact matches only)
|
$this->dirFilter = array('/', 'CVS', '.svn'); // Default directory filter (exact matches only)
|
||||||
$this->fileFilter = array('^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^index\.html$','^null\.txt$','\.bak$','^.tmp'); // Default file filter (regex format)
|
$this->fileFilter = array('^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^index\.html$','^null\.txt$','\.bak$','^.tmp'); // Default file filter (regex format)
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set fileinfo mode
|
||||||
|
* @param string $val
|
||||||
|
* @return e_file
|
||||||
|
*/
|
||||||
public function setFileInfo($val='default')
|
public function setFileInfo($val='default')
|
||||||
{
|
{
|
||||||
$this->finfo = $val;
|
$this->finfo = $val;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,6 +221,12 @@ class e_file
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect file information
|
||||||
|
* @param string $path_to_file
|
||||||
|
* @param boolean $imgcheck
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function get_file_info($path_to_file, $imgcheck = true)
|
function get_file_info($path_to_file, $imgcheck = true)
|
||||||
{
|
{
|
||||||
$finfo = array();
|
$finfo = array();
|
||||||
@@ -219,9 +251,14 @@ class e_file
|
|||||||
return $finfo;
|
return $finfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// Get a list of directories matching $fmask, omitting any in the $omit array - same calling syntax as get_files()
|
* Get a list of directories matching $fmask, omitting any in the $omit array - same calling syntax as get_files()
|
||||||
// N.B. - no recursion - just looks in the specified directory.
|
* N.B. - no recursion - just looks in the specified directory.
|
||||||
|
* @param string $path
|
||||||
|
* @param strig $fmask
|
||||||
|
* @param string $omit
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function get_dirs($path, $fmask = '', $omit='standard')
|
function get_dirs($path, $fmask = '', $omit='standard')
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
@@ -256,9 +293,11 @@ class e_file
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a complete directory tree
|
||||||
// Delete a complete directory tree
|
* @param string $dir
|
||||||
|
* @return boolean success
|
||||||
|
*/
|
||||||
function rmtree($dir)
|
function rmtree($dir)
|
||||||
{
|
{
|
||||||
if (substr($dir, -1) != '/')
|
if (substr($dir, -1) != '/')
|
||||||
|
@@ -8,9 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
define("CACLAN_1", "Cache System Status");
|
define("CACLAN_1", "Cache System Status");
|
||||||
define("CACLAN_2", "Set cache status");
|
define("CACLAN_2", "Set cache status");
|
||||||
define("CACLAN_3", "Cache System");
|
define("CACLAN_3", "Cache Management");
|
||||||
define("CACLAN_4", "Cache status set");
|
define("CACLAN_4", "Cache status set");
|
||||||
define("CACLAN_5", "Empty Cache");
|
define("CACLAN_5", "Empty Content Cache");
|
||||||
define("CACLAN_6", "Cache Emptied");
|
define("CACLAN_6", "Cache Emptied");
|
||||||
|
|
||||||
define("CACLAN_10", "The cache directory is not writable. Please ensure this directory is set CHMOD 0777");
|
define("CACLAN_10", "The cache directory is not writable. Please ensure this directory is set CHMOD 0777");
|
||||||
@@ -25,5 +25,11 @@ define("CACLAN_17", "Currently contains");
|
|||||||
define("CACLAN_18", "file");
|
define("CACLAN_18", "file");
|
||||||
define("CACLAN_19", "files");
|
define("CACLAN_19", "files");
|
||||||
|
|
||||||
|
define("CACLAN_20", "DB Structure Cache");
|
||||||
|
define("CACLAN_21", "Database Structure cache contains system information about database tables structure, needed by various core routines. No actual content will be contained here.");
|
||||||
|
define("CACLAN_22", "Thumbnail cache");
|
||||||
|
define("CACLAN_23", "Thumbnail cache files contains binary image data. They are there to save a lot of server CPU work.");
|
||||||
|
define("CACLAN_24", "Empty DB Structure Cache");
|
||||||
|
define("CACLAN_25", "Empty Thumbnail Cache");
|
||||||
|
define("CACLAN_26", "Empty All Cache");
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user