1
0
Fork 0

diagnosis: impl some advises

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1090 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 2012-07-30 15:01:09 +00:00
parent f9b4ab0c41
commit b0291af8d9
4 changed files with 112 additions and 56 deletions

View File

@ -256,30 +256,7 @@ function getEntryList() // {{{
$module = "cacher";
xcache_count(XC_TYPE_PHP); // trigger auth
if (!extension_loaded('XCache')) {
include "../common/header.tpl.php";
echo '<h1>XCache is not loaded</h1>';
ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_clean();
if (preg_match_all("!<tr>[^<]*<td[^>]*>[^<]*(?:Configuration|ini|Server API)[^<]*</td>[^<]*<td[^>]*>[^<]*</td>[^<]*</tr>!s", $info, $m)) {
echo '<div class="phpinfo">';
echo 'PHP Info';
echo '<table>';
echo implode('', $m[0]);
echo '</table>';
echo '</div>';
}
if (preg_match('!<td class="v">(.*?\\.ini)!', $info, $m)) {
echo "Please check $m[1]";
}
else if (preg_match('!Configuration File \\(php.ini\\) Path *</td><td class="v">([^<]+)!', $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";
header("Location: ../diagnosis");
exit;
}

View File

@ -148,7 +148,7 @@ function _T($str)
return $GLOBALS['strings'][$str];
}
if (!empty($GLOBALS['config']['show_todo_strings'])) {
return '<span style="color:red">' . htmlspecialchars($str) . '</span>|';
return '<span style="color:red">' . $str . '</span>|';
}
return $str;
}

View File

@ -1,2 +1,25 @@
<?php include "../common/header.tpl.php"; ?>
<table cellspacing="0" cellpadding="4" class="cycles">
<caption>
<?php echo _T("Diagnosis Result"); ?>
</caption>
<tr>
<th>
<?php echo _T("Level"); ?>
</th>
<th>
<?php echo _T("Reason"); ?>
</th>
<th>
<?php echo _T("Suggestion"); ?>
</th>
</tr>
<?php foreach ($notes as $note) { ?>
<tr>
<td><?php echo ucfirst($note['type']); ?></td>
<td><?php echo $note['reason']; ?></td>
<td><?php echo $note['suggestion']; ?></td>
</tr>
<?php } ?>
</table>
<?php include "../common/footer.tpl.php"; ?>

View File

@ -5,7 +5,7 @@ include "../common/common.php";
$module = "diagnosis";
$notes = array();
function note($type, $reason, $suggestion)
function note($type, $reason, $suggestion = "ok") // {{{
{
global $notes;
$notes[] = array(
@ -14,7 +14,7 @@ function note($type, $reason, $suggestion)
, 'suggestion' => $suggestion
);
}
// }}}
function getCacheInfos() // {{{
{
$phpCacheCount = xcache_count(XC_TYPE_PHP);
@ -34,51 +34,107 @@ function getCacheInfos() // {{{
}
return $cacheInfos;
}
// }}}
$cacheInfos = getCacheInfos();
if (!extension_loaded('XCache')) {
ob_start();
phpinfo(INFO_GENERAL);
$info = ob_get_clean();
ob_start();
if (preg_match_all("!<tr>[^<]*<td[^>]*>[^<]*(?:Configuration|ini|Server API)[^<]*</td>[^<]*<td[^>]*>[^<]*</td>[^<]*</tr>!s", $info, $m)) {
echo '<div class="phpinfo">';
echo 'PHP Info';
echo '<table>';
echo implode('', $m[0]);
echo '</table>';
echo '</div>';
}
if (preg_match('!<td class="v">(.*?\\.ini)!', $info, $m)) {
echo "Please check $m[1]";
}
else if (preg_match('!Configuration File \\(php.ini\\) Path *</td><td class="v">([^<]+)!', $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)";
note("error", _T('XCache is not loaded'), ob_get_clean());
}
else {
note("info", _T('XCache loaded'));
// if (!$ini['xcache.size'] || !$ini['xcache.cacher']) {
$cacheInfos = getCacheInfos();
foreach ($cacheInfos as $cacheInfo) {
if ($cacheInfo['ooms']) {
if (!ini_get("xcache.size") || !ini_get("xcache.cacher")) {
note(
"error"
, _T("XCache is not enabled. Website is not accelerated by XCache")
, _T("Set xcache.size to non-zero, set xcache.cacher = On")
);
}
else {
note("info", _T('XCache Enabled'));
}
$ooms = false;
foreach ($cacheInfos as $cacheInfo) {
if ($cacheInfo['ooms']) {
$ooms = true;
break;
}
}
if ($ooms) {
note(
"warning"
, "Out of memory happened when trying to write to cache"
, _T("Out of memory happened when trying to write to cache")
, "Increase xcache.size and/or xcache.var_size"
);
break;
}
}
else {
note("info", _T('XCache Memory Size'));
}
foreach ($cacheInfos as $cacheInfo) {
if ($cacheInfo['errors']) {
$errors = false;
foreach ($cacheInfos as $cacheInfo) {
if ($cacheInfo['errors']) {
$errors = true;
break;
}
}
if ($errors) {
note(
"warning"
, "Error happened when compiling your PHP code"
, "This usually means there is syntax error in your PHP code. Enable PHP error_log to see what parser error is it, fix your code"
, _T("Error happened when compiling at least one of your PHP code")
, _T("This usually means there is syntax error in your PHP code. Enable PHP error_log to see what parser error is it, fix your code")
);
break;
}
else {
note("info", _T('All PHP scripts seem fine'));
}
/*
if ($ini['xcache.count'] < cpucount() * 2) {
}
if ($ini['xcache.size'] is small $ini['xcache.slots'] is big) {
}
if ($ini['xcache.readonly_protection']) {
}
if ($cache['compiling']) {
}
if ($cache['compiling']) {
}
if ($cache['disabled']) {
}
*/
}
/*
if ($ini['xcache.count'] < cpucount() * 2) {
}
if ($ini['xcache.size'] is small $ini['xcache.slots'] is big) {
}
if ($ini['xcache.readonly_protection']) {
}
if ($cache['compiling']) {
}
if ($cache['compiling']) {
}
if ($cache['disabled']) {
}
if (($coredumpFiles = globCoreDumpFiles()) {
}