2007-09-19 21:42:07 +02:00
< ? php
/* Copyright ( C ) 2007 Laurent Destailleur < eldy @ users . sourceforge . net >
*
* $Id $
* $Source $
*
* 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 . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
/**
\file htdocs / admin / tools / eaccelerator . php
\brief Page administration de eaccelerator
\version $Revision $
*/
require ( " ./pre.inc.php " );
$langs -> load ( " admin " );
if ( ! $user -> admin )
accessforbidden ();
2007-09-20 01:32:42 +02:00
/*
* Affichage page
*/
2007-09-19 21:42:07 +02:00
llxHeader ();
if ( ! function_exists ( 'eaccelerator_info' ))
{
print 'eAccelerator is not installed.' ;
llxfooter ( '$Date$ - $Revision$' );
exit ;
}
$info = eaccelerator_info ();
if ( isset ( $_POST [ 'caching' ])) {
if ( $info [ 'cache' ]) {
eaccelerator_caching ( false );
} else {
eaccelerator_caching ( true );
}
} else if ( isset ( $_POST [ 'optimizer' ]) && function_exists ( 'eaccelerator_optimizer' )) {
if ( $info [ 'optimizer' ]) {
eaccelerator_optimizer ( false );
} else {
eaccelerator_optimizer ( true );
}
} else if ( isset ( $_POST [ 'clear' ])) {
eaccelerator_clear ();
} else if ( isset ( $_POST [ 'clean' ])) {
eaccelerator_clean ();
} else if ( isset ( $_POST [ 'purge' ])) {
eaccelerator_purge ();
}
$info = eaccelerator_info ();
if ( ! is_array ( $info )) {
dolibarr_print_error ( '' , 'An error occured getting eAccelerator information, this is caused if eAccelerator isn\'t initalised properly' );
exit ;
}
2007-09-20 01:32:42 +02:00
2007-09-19 21:42:07 +02:00
function compare ( $x , $y )
{
global $sortby ;
if ( $x [ $sortby ] == $y [ $sortby ] )
return 0 ;
else if ( $x [ $sortby ] < $y [ $sortby ] )
return - 1 ;
else
return 1 ;
}
2007-09-20 01:32:42 +02:00
2007-09-19 21:42:07 +02:00
function revcompare ( $x , $y )
{
2007-09-20 01:32:42 +02:00
global $sortby , $langs ;
2007-09-19 21:42:07 +02:00
if ( $x [ $sortby ] == $y [ $sortby ] )
return 0 ;
else if ( $x [ $sortby ] < $y [ $sortby ] )
return 1 ;
else
return - 1 ;
}
2007-09-20 01:32:42 +02:00
function create_script_table ( $list )
{
global $sortby , $bc , $langs ;
$var = true ;
2007-09-19 21:42:07 +02:00
if ( isset ( $_GET [ 'order' ]) && ( $_GET [ 'order' ] == " asc " || $_GET [ 'order' ] == " desc " )) {
$order = $_GET [ 'order' ];
} else {
$order = " asc " ;
}
if ( isset ( $_GET [ 'sort' ])) {
switch ( $_GET [ 'sort' ]) {
case " mtime " :
case " size " :
case " reloads " :
case " hits " :
$sortby = $_GET [ 'sort' ];
( $order == " asc " ? uasort ( $list , 'compare' ) : uasort ( $list , 'revcompare' ));
break ;
default :
$sortby = " file " ;
( $order == " asc " ? uasort ( $list , 'compare' ) : uasort ( $list , 'revcompare' ));
}
}
?>
2007-09-20 01:32:42 +02:00
< table class = " noborder " >
2007-09-19 21:42:07 +02:00
< tr >
2007-09-20 01:32:42 +02:00
< th >< a href = " <?php print $_SERVER['PHP_SELF'] ?>?sort=file&order=<?php print ( $order == " asc " ? " desc " : " asc " )?> " >< ? php print $langs -> trans ( " Filename " ); ?> </a> <? if($sortby == "file") print ($order == "asc" ? "↓" : "↑")?></th>
< th >< a href = " <?php print $_SERVER['PHP_SELF'] ?>?sort=mtime&order=<?php print ( $order == " asc " ? " desc " : " asc " )?> " >< ? php print $langs -> trans ( " Date " ); ?> </a> <? if($sortby == "mtime") print ($order == "asc" ? "↓" : "↑")?></th>
< th >< a href = " <?php print $_SERVER['PHP_SELF'] ?>?sort=size&order=<?php print ( $order == " asc " ? " desc " : " asc " )?> " >< ? php print $langs -> trans ( " Size " ); ?> </a> <? if($sortby == "size") print ($order == "asc" ? "↓" : "↑")?></th>
< th >< a href = " <?php print $_SERVER['PHP_SELF'] ?>?sort=reloads&order=<?php print ( $order == " asc " ? " desc " : " asc " )?> " >< ? php print $langs -> trans ( " Reloads " ); ?> </a> <? if($sortby == "reloads") print ($order == "asc" ? "↓" : "↑")?></th>
< th >< a href = " <?php print $_SERVER['PHP_SELF'] ?>?sort=hits&order=<?php print ( $order == " asc " ? " desc " : " asc " )?> " >< ? php print $langs -> trans ( " Hits " ); ?> </a> <? if($sortby == "hits") print ($order == "asc" ? "↓" : "↑")?></th>
2007-09-19 21:42:07 +02:00
</ tr >
< ? php
switch ( $sortby ) {
case " mtime " :
case " size " :
case " reloads " :
case " hits " :
( $order == " asc " ? uasort ( $list , 'compare' ) : uasort ( $list , 'revcompare' ));
break ;
case " file " :
default :
$sortby = " file " ;
( $order == " asc " ? uasort ( $list , 'compare' ) : uasort ( $list , 'revcompare' ));
}
foreach ( $list as $script ) { ?>
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
< td >< ? php print dolibarr_trunc ( $script [ 'file' ], 80 , 'left' ); ?> </td>
< td align = " center " nowrap = " nowrap " >< ? php print dolibarr_print_date ( $script [ 'mtime' ], 'dayhour' ); ?> </td>
< td align = " right " nowrap = " nowrap " >< ? php print number_format ( $script [ 'size' ] / 1024 , 2 ); ?> KB</td>
< td align = " right " nowrap = " nowrap " >< ? php print $script [ 'reloads' ]; ?> (<?php print $script['usecount']; ?>)</td>
< td align = " right " nowrap = " nowrap " >< ? php print $script [ 'hits' ]; ?> </td>
2007-09-19 21:42:07 +02:00
</ tr >
< ? php } ?>
</ table >
< ? php
}
2007-09-20 01:32:42 +02:00
function create_key_table ( $list )
{
global $bc , $langs ;
$var = true ;
2007-09-19 21:42:07 +02:00
?>
2007-09-20 01:32:42 +02:00
< table class = " noborder " >
< tr class = " liste_titre " >
2007-09-19 21:42:07 +02:00
< th > Name </ th >
< th > Created </ th >
2007-09-20 01:32:42 +02:00
< th >< ? php print $langs -> trans ( " Size " ); ?> </th>
2007-09-19 21:42:07 +02:00
< th > ttl </ th >
</ tr >
< ? php
foreach ( $list as $key ) {
?>
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
< td >< ? php print dolibarr_trunc ( $key [ 'name' ], 80 , 'left' ); ?> </td>
< td align = " center " nowrap = " nowrap " >< ? php dolibarr_print_date ( $key [ 'created' ], 'dayhour' ); ?> </td>
< td align = " right " nowrap = " nowrap " >< ? php print number_format ( $key [ 'size' ] / 1024 , 3 ); ?> KB</td>
< td align = " right " nowrap = " nowrap " >< ? php
2007-09-19 21:42:07 +02:00
if ( $key [ 'ttl' ] == - 1 ) {
2007-09-20 01:32:42 +02:00
print 'expired' ;
2007-09-19 21:42:07 +02:00
} elseif ( $key [ 'ttl' ] == 0 ) {
2007-09-20 01:32:42 +02:00
print 'none' ;
2007-09-19 21:42:07 +02:00
} else {
2007-09-20 01:32:42 +02:00
print dolibarr_print_date ( $key [ 'ttl' ], 'dayhour' );
2007-09-19 21:42:07 +02:00
}
?> </td>
</ tr >
< ? php
}
?>
</ table >
< ? php
}
$html = new Form ( $db );
print_fiche_titre ( 'Dolibarr eAccelerator ' . $info [ 'version' ] . ' control panel' , '' , 'setup' );
2007-09-20 01:32:42 +02:00
$var = true ;
2007-09-19 21:42:07 +02:00
?>
< br >
2007-09-20 01:32:42 +02:00
< table class = " noborder " >
2007-09-19 21:42:07 +02:00
< tr class = " liste_titre " >< td colspan = " 2 " > Information </ td ></ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Caching enabled </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print $info [ 'cache' ] ? 'yes' : 'no' ?> </td>
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Optimizer enabled </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print $info [ 'optimizer' ] ? 'yes' : 'no' ?> </td>
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Memory usage </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print number_format ( 100 * $info [ 'memoryAllocated' ] / $info [ 'memorySize' ], 2 ); ?> %
( < ? php print number_format ( $info [ 'memoryAllocated' ] / ( 1024 * 1024 ), 2 ); ?> MB /
< ? php print number_format ( $info [ 'memorySize' ] / ( 1024 * 1024 ), 2 ); ?> MB)</td>
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Free memory in reserved cache </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print number_format ( $info [ 'memoryAvailable' ] / ( 1024 * 1024 ), 2 ); ?> MB</td>
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Cached scripts </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print $info [ 'cachedScripts' ]; ?> </td>
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Removed scripts </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print $info [ 'removedScripts' ]; ?> </td>
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Cached keys </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< ? php print $info [ 'cachedKeys' ]; ?> </td>
2007-09-19 21:42:07 +02:00
</ tr >
</ table >
2007-09-20 01:32:42 +02:00
< ? php
$var = true ;
2007-09-19 21:42:07 +02:00
2007-09-20 01:32:42 +02:00
?>
2007-09-19 21:42:07 +02:00
< br >
< form name = " ea_control " method = " post " >
2007-09-20 01:32:42 +02:00
< table class = " noborder " >
2007-09-19 21:42:07 +02:00
< tr class = " liste_titre " >< td colspan = " 2 " > Actions </ td ></ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Caching </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< input type = " submit " class = " butAction " name = " caching " value = " <?php print $info['cache'] ?'disable':'enable'; ?> " /></ td >
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Optimizer </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< input type = " submit " class = " butAction " name = " optimizer " value = " <?php print $info['optimizer'] ?'disable':'enable'; ?> " /></ td >
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Clear cache </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< input type = " submit " class = " butAction " name = " clear " value = " clear " title = " remove all unused scripts and data from shared memory and disk cache " /></ td >
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Clean cache </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< input type = " submit " class = " butAction " name = " clean " value = " clean " title = " remove all expired scripts and data from shared memory and disk cache " /></ td >
2007-09-19 21:42:07 +02:00
</ tr >
2007-09-20 01:32:42 +02:00
< tr < ? php $var = ! $var ; print $bc [ $var ]; ?> >
2007-09-19 21:42:07 +02:00
< td > Purge cache </ td >
2007-09-20 01:32:42 +02:00
< td align = " right " >< input type = " submit " class = " butAction " name = " purge " value = " purge " title = " remove all 'removed' scripts from shared memory " /></ td >
2007-09-19 21:42:07 +02:00
</ tr >
</ table >
</ form >
<!-- }}} -->
< br >< br >
2007-09-20 01:32:42 +02:00
< b > Cached scripts </ b >< br >
2007-09-19 21:42:07 +02:00
< table >
< ? php
$res = eaccelerator_cached_scripts (); // If success return an array
if ( is_array ( $res )) create_script_table ( $res );
else print " Check in your <b>php.ini</b> that <b>eaccelerator.allowed_admin_path</b> parameter is " . _FILE ;
?>
< br >< br >
2007-09-20 01:32:42 +02:00
< b > Removed scripts </ b >< br >
2007-09-19 21:42:07 +02:00
< table >
< ? php
$res = eaccelerator_removed_scripts ();
if ( is_array ( $res )) create_script_table ( $res );
else print " Check in your <b>php.ini</b> that <b>eaccelerator.allowed_admin_path</b> parameter is " . _FILE ;
if ( function_exists ( 'eaccelerator_get' )) {
?>
< br >< br >
2007-09-20 01:32:42 +02:00
< b > Cached keys </ b >< br >
2007-09-19 21:42:07 +02:00
< table >
< ? php
$res = eaccelerator_list_keys ();
create_key_table ( $res );
}
?>
< br />< br />
< hr />
< table >
< tr >< td class = " center " >
< strong > Eaccelerator is created by the eAccelerator team , < a href = " http://eaccelerator.net " > http :// eaccelerator . net </ a ></ strong >< br />< br />
</ td ></ tr >
</ table >
< ? php
llxfooter ( '$Date$ - $Revision$' );
?>