Gazelle/sections/tools/data/opcode_stats.php

145 lines
4.1 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
//TODO: Accelerator cache keys, removed scripts (stats here and a class to manage them (we'd probably never use it, but I like completeness))
//INFO: http://bart.eaccelerator.net/doc/phpdoc/
//INFO: http://bakery.cakephp.org/articles/view/eaccelerator-cache-engine - pertains to potential todo for eAccelerator cache class
if(!check_perms('site_debug')) { error(403); }
if (!extension_loaded('eAccelerator')) {
error('eAccelerator Extension not loaded.');
}
if (isset($_POST['submit'])) {
if($_POST['cache'] == 1) {
authorize();
eaccelerator_caching(true);
} else {
eaccelerator_caching(false);
}
if (function_exists('eaccelerator_optimizer')) {
if($_POST['optimize'] == 1) {
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
authorize();
eaccelerator_optimizer(true);
} else {
eaccelerator_optimizer(false);
}
}
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
if (isset($_POST['clear'])) {
authorize();
eaccelerator_clear();
}
if (isset($_POST['clean'])) {
authorize();
eaccelerator_clean();
}
if (isset($_POST['purge'])) {
authorize();
eaccelerator_purge();
}
}
$Opcode = eaccelerator_info();
$CachedScripts = eaccelerator_cached_scripts();
//$RemovedScripts = eaccelerator_removed_scripts();
2012-10-11 08:00:15 +00:00
View::show_header("Opcode Stats");
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
<div>
2012-09-15 08:00:25 +00:00
<form class="manage_form" name="opcode_stats" action="" method="post">
2011-03-28 14:21:28 +00:00
<div>
<input type="hidden" name="action" value="opcode_stats" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
</div>
2012-09-01 08:00:24 +00:00
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
2011-03-28 14:21:28 +00:00
<tr>
<td><strong>Enable:</strong></td>
<td>
<input type="checkbox" name="cache" value="1" id="cache"<?=($Opcode['cache'])?' checked="checked"':''?> />
<label for="cache">Cache</label>
<? if (function_exists('eaccelerator_optimizer')) { ?>
<input type="checkbox" name="optimize" value="1" id="optimize"<?=($Opcode['optimizer'])?' checked="checked"':''?> />
<label for="optimize">Optimize</label>
<? } ?>
</td>
</tr>
<tr>
<td><strong>Controls:</strong></td>
<td>
<input type="checkbox" name="clear" value="clear" id="clear" />
<label for="clear">Clear</label>
<input type="checkbox" name="clean" value="clean" id="clean" />
<label for="clean">Clean</label>
<input type="checkbox" name="purge" value="purge" id="purge" />
<label for="purge">Purge</label>
</td>
</tr>
<tr>
<td colspan="2" class="center">
<input type="submit" name="submit" value="Update" />
</td>
</tr>
2013-02-22 08:00:24 +00:00
</table>
2011-03-28 14:21:28 +00:00
</form>
</div>
<br /><br />
<table>
2012-09-01 08:00:24 +00:00
<tr class="colhead">
<td colspan="6">Status</td>
2011-03-28 14:21:28 +00:00
</tr>
<tr>
<td>Total Storage:</td>
2012-10-11 08:00:15 +00:00
<td><?=Format::get_size($Opcode['memorySize'])?></td>
2011-03-28 14:21:28 +00:00
<td>Used Storage:</td>
2012-10-11 08:00:15 +00:00
<td><?=Format::get_size($Opcode['memoryAllocated'])?> (<?=number_format(($Opcode['memoryAllocated']/$Opcode['memorySize'])*100, 3);?>%)</td>
2011-03-28 14:21:28 +00:00
<td>Free Storage:</td>
2012-10-11 08:00:15 +00:00
<td><?=Format::get_size($Opcode['memoryAvailable'])?> (<?=number_format(($Opcode['memoryAvailable']/$Opcode['memorySize'])*100, 3);?>%)</td>
2011-03-28 14:21:28 +00:00
</tr>
<tr>
<td>Cached Scripts:</td>
<td><?=number_format($Opcode['cachedScripts'])?></td>
<td>Removed Scripts:</td>
<td><?=number_format($Opcode['removedScripts'])?></td>
<td>Cached Keys:</td>
<? if (function_exists('eaccelerator_get')) { ?>
<td><?=number_format($Opcode['cachedKeys'])?></td>
<? } else { ?>
<td>N/A</td>
<? } ?>
</tr>
</table>
<br /><br />
<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
<tr class="colhead">
<td>File Path</td>
<td>Age</td>
<td>Size</td>
<td>Hits</td>
</tr>
<?
if(count($CachedScripts) == 0) { // Uh-oh, try again.
echo '<tr><td colspan="5">No scripts cached.</td></tr>';
}
$Row = 'a'; // For the pretty colours
foreach ($CachedScripts as $Script) {
list($FilePath, $Modified, $Size, $Reloads, $Uses, $Hits) = array_values($Script);
$Row = ($Row == 'a') ? 'b' : 'a';
?>
<tr class="row<?=$Row?>">
<td><?=$FilePath?></td>
<td><?=time_diff($Modified)?></td>
2012-10-11 08:00:15 +00:00
<td><?=Format::get_size($Size)?></td>
2011-03-28 14:21:28 +00:00
<td><?=number_format($Hits)?></td>
</tr>
<?
}
?>
</table>
</div>
2012-10-11 08:00:15 +00:00
<? View::show_footer(); ?>