$v) {
if ($config['percent_graph_type'] != 'free') {
$v = 1 - $v;
}
$v = (int) ($v * $c);
$r = $g = $c - $v;
$b = $c;
$html[] = '
]*>!';
if (preg_match($regex, $info)) {
$moduleInfo[] = preg_replace($regex, "\\0$caption", $info, 1);
}
else {
$moduleInfo[] = "$caption
";
$moduleInfo[] = $info;
}
}
return implode('', $moduleInfo);
}
// }}}
function getCacheInfos() // {{{
{
static $cacheInfos;
if (isset($cacheInfos)) {
return $cacheInfos;
}
$phpCacheCount = xcache_count(XC_TYPE_PHP);
$varCacheCount = xcache_count(XC_TYPE_VAR);
$cacheInfos = array();
$total = array();
global $maxHitsByHour;
$maxHitsByHour = array(0, 0);
for ($i = 0; $i < $phpCacheCount; $i ++) {
$data = xcache_info(XC_TYPE_PHP, $i);
if ($_GET['do'] === 'listphp') {
$data += xcache_list(XC_TYPE_PHP, $i);
}
$data['type'] = XC_TYPE_PHP;
$data['cache_name'] = "php#$i";
$data['cacheid'] = $i;
$cacheInfos[] = $data;
$maxHitsByHour[XC_TYPE_PHP] = max($maxHitsByHour[XC_TYPE_PHP], max($data['hits_by_hour']));
if ($phpCacheCount >= 2) {
calc_total($total, $data);
}
}
if ($phpCacheCount >= 2) {
$total['type'] = XC_TYPE_PHP;
$total['cache_name'] = _('Total');
$total['cacheid'] = -1;
$total['gc'] = null;
$total['istotal'] = true;
unset($total['compiling']);
$cacheInfos[] = $total;
}
$total = array();
for ($i = 0; $i < $varCacheCount; $i ++) {
$data = xcache_info(XC_TYPE_VAR, $i);
if ($_GET['do'] === 'listvar') {
$data += xcache_list(XC_TYPE_VAR, $i);
}
$data['type'] = XC_TYPE_VAR;
$data['cache_name'] = "var#$i";
$data['cacheid'] = $i;
$cacheInfos[] = $data;
$maxHitsByHour[XC_TYPE_VAR] = max($maxHitsByHour[XC_TYPE_VAR], max($data['hits_by_hour']));
if ($varCacheCount >= 2) {
calc_total($total, $data);
}
}
if ($varCacheCount >= 2) {
$total['type'] = XC_TYPE_VAR;
$total['cache_name'] = _('Total');
$total['cacheid'] = -1;
$total['gc'] = null;
$total['istotal'] = true;
$cacheInfos[] = $total;
}
return $cacheInfos;
}
// }}}
function getEntryList() // {{{
{
static $entryList;
if (isset($entryList)) {
return $entryList;
}
$entryList = array('cache_list' => array(), 'deleted_list' => array());
if ($_GET['do'] == 'listphp') {
$entryList['type_name'] = 'php';
$entryList['type'] = XC_TYPE_PHP;
}
else {
$entryList['type_name'] = 'var';
$entryList['type'] = XC_TYPE_VAR;
}
foreach (getCacheInfos() as $i => $c) {
if (!empty($c['istotal'])) {
continue;
}
if ($c['type'] == $entryList['type'] && isset($c['cache_list'])) {
foreach ($c['cache_list'] as $e) {
$e['cache_name'] = $c['cache_name'];
$entryList['cache_list'][] = $e;
}
foreach ($c['deleted_list'] as $e) {
$e['cache_name'] = $c['cache_name'];
$entryList['deleted_list'][] = $e;
}
}
}
return $entryList;
}
// }}}
$module = "cacher";
xcache_count(XC_TYPE_PHP); // trigger auth
if (!extension_loaded('XCache')) {
include "../common/header.tpl.php";
echo 'XCache is not loaded
';
ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_clean();
if (preg_match_all("![^<]*| ]*>[^<]*(?:Configuration|ini|Server API)[^<]* | [^<]*]*>[^<]* | [^<]*
!s", $info, $m)) {
echo '';
echo 'PHP Info';
echo '
';
echo implode('', $m[0]);
echo '
';
echo '
';
}
if (preg_match('!(.*?\\.ini)!', $info, $m)) {
echo "Please check $m[1]";
}
else if (preg_match('!Configuration File \\(php.ini\\) Path * | ([^<]+)!', $info, $m)) {
echo "Please put a php.ini in $m[1] and load XCache extension";
}
else {
echo "You don't even have a php.ini yet?";
}
echo "(See above)";
include "../common/footer.tpl.php";
exit;
}
$doTypes = array(
'' => _('Summary'),
'listphp' => _('List PHP'),
'listvar' => _('List Var Data'),
'help' => _('Help'),
);
function processPOST() // {{{
{
if (isset($_POST['remove']) && is_array($_POST['remove'])) {
foreach ($_POST['remove'] as $name) {
if (is_string($name)) {
xcache_unset($name);
}
}
}
$type = isset($_POST['type']) ? $_POST['type'] : null;
if ($type != XC_TYPE_PHP && $type != XC_TYPE_VAR) {
$type = null;
}
if (isset($type)) {
$cacheid = (int) (isset($_POST['cacheid']) ? $_POST['cacheid'] : 0);
if (isset($_POST['clearcache'])) {
xcache_clear_cache($type, $cacheid);
}
if (isset($_POST['enable'])) {
xcache_enable_cache($type, $cacheid);
}
if (isset($_POST['disable'])) {
xcache_enable_cache($type, $cacheid, false);
}
}
if (isset($_POST['coredump'])) {
xcache_coredump();
}
}
// }}}
processPOST();
if (!isset($_GET['do'])) {
$_GET['do'] = '';
}
switch ($_GET['do']) {
case 'listphp':
case 'listvar':
include "./listentries.tpl.php";
break;
case 'help':
include "./help.tpl.php";
break;
default:
include "./summary.tpl.php";
break;
}
?>
|