<?php
/*
* HelpCORE source file
* ====================
*
* CVS:
* ----
* $header$
*
* Purpose:
* --------
* Gives admins a cache-management interface
*
* Copyright:
* ----------
* Copyright (C) 2002-2003 Dennis Fleurbaaij <hide@address.com>
* Copyright (C) 2002-2005 IO Software <hide@address.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. 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., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
* Please note that this software is dual licensed. For the commercial use of this
* software you will need a Commercial License. Please see http://www.io-software.nl
* for the terms and conditions.
*
* For more information you can contact IO Software at http://www.io-software.nl
*/
if( ! include( '../coreapm/coreapm.php' ) )
{
die( 'Cannot include CORE APM' );
}
$GLOBALS['security']->secure( ADMIN );
$GLOBALS['cache']->no_cache = true;
$coreapm->start();
// Erase cache options
if( isset( $_GET['action'] ) )
{
switch( $_GET['action'] )
{
case 'page':
$GLOBALS['cache']->page_cache_erase();
break;
case 'select':
$GLOBALS['cache']->select_cache_erase();
break;
case 'all':
$GLOBALS['cache']->page_cache_erase();
$GLOBALS['cache']->select_cache_erase();
break;
default:
break;
}
header( 'location: ' . BASE_THIS_DIR . '/cache.php' );
die;
}
if( CACHE == true )
{
$status = '<span class="positiveText">' . text( 'enabled' ) . '</span>';
}
else
{
$status = '<span class="errorText">' . text( 'disabled' ) . '</span>';
}
// loop page cache dir
$page_cache_size = 0;
$page_cache_files = 0;
$overview = '';
if( ! ( $dp = opendir( CACHE_DIR . 'page_cache/' ) ) )
{
__FATAL__( __FILE__, __LINE__, __CLASS__, __FUNCTION__, 'Page cache dir ("'.CACHE_DIR . 'page_cache/")could not be opened! Most likely your install is corrupted.' );
}
while( $file = readdir( $dp ) )
{
if( ( $file == '.' ) || ( $file == '..' ) || ( $file == '.htaccess' ) || ( $file == 'CVS' ) )
{
continue;
}
$file_name = CACHE_DIR . 'page_cache/' . $file;
// count
$page_cache_files++;
$page_cache_size += filesize( $file_name );
}
closedir( $dp );
// Loop select cache
$select_cache_size = 0;
$select_cache_files = 0;
if( ! ( $dp = opendir( CACHE_DIR . 'select_cache/' ) ) )
{
__FATAL__( __FILE__, __LINE__, __CLASS__, __FUNCTION__, 'Select cache dir ("'.CACHE_DIR.'select_cache/") could not be opened! Most likely your install is corrupted.' );
}
while( $file = readdir( $dp ) )
{
if( ( $file == '.' ) || ( $file == '..' ) || ( $file == '.htaccess' ) || ( $file == 'CVS' ) )
{
continue;
}
$file_name = CACHE_DIR . 'select_cache/' . $file;
// count
$select_cache_files++;
$select_cache_size += filesize( $file_name );
}
closedir( $dp );
$GLOBALS['box']->add( text( 'cache' ),
$GLOBALS['template']->data( 'cache.tpl',
array (
'TEXT_CACHE_STATUS' => text( 'cache_status' ),
'CACHE_STATUS' => $status,
'TEXT_PAGE_CACHE_SIZE' => text( 'page_cache_size' ),
'TEXT_CACHE_SIZE_BYTES' => text( 'cache_size_bytes' ),
'PAGE_CACHE_SIZE_BYTES' => number_format( $page_cache_size ),
'TEXT_AMOUNT_FILES' => text( 'amount_of_files' ),
'PAGE_AMOUNT_FILES' => $page_cache_files,
'BASE_THIS_DIR' => BASE_THIS_DIR,
'TEXT_CLEAR_PAGE_CACHE' => text( 'clear_page_cache' ),
'TEXT_SELECT_CACHE_SIZE'=> text( 'select_cache_size' ),
'SELECT_CACHE_SIZE_BYTES'=>number_format( $select_cache_size ),
'SELECT_AMOUNT_FILES' => $select_cache_files,
'TEXT_CLEAR_SELECT_CACHE'=> text( 'clear_select_cache' )
) ) );
$coreapm->finish();
?>