Changeset 1090 in svn


Ignore:
Timestamp:
2012-07-30T15:01:09Z (3 years ago)
Author:
Xuefer
Message:

diagnosis: impl some advises

Location:
trunk/htdocs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/cacher/index.php

    r1088 r1090  
    257257xcache_count(XC_TYPE_PHP); // trigger auth
    258258if (!extension_loaded('XCache')) {
    259     include "../common/header.tpl.php";
    260     echo '<h1>XCache is not loaded</h1>';
    261     ob_start();
    262     phpinfo(INFO_GENERAL);
    263     $info = ob_get_clean();
    264     if (preg_match_all("!<tr>[^<]*<td[^>]*>[^<]*(?:Configuration|ini|Server API)[^<]*</td>[^<]*<td[^>]*>[^<]*</td>[^<]*</tr>!s", $info, $m)) {
    265         echo '<div class="phpinfo">';
    266         echo 'PHP Info';
    267         echo '<table>';
    268         echo implode('', $m[0]);
    269         echo '</table>';
    270         echo '</div>';
    271     }
    272     if (preg_match('!<td class="v">(.*?\\.ini)!', $info, $m)) {
    273         echo "Please check $m[1]";
    274     }
    275     else if (preg_match('!Configuration File \\(php.ini\\) Path *</td><td class="v">([^<]+)!', $info, $m)) {
    276         echo "Please put a php.ini in $m[1] and load XCache extension";
    277     }
    278     else {
    279         echo "You don't even have a php.ini yet?";
    280     }
    281     echo "(See above)";
    282     include "../common/footer.tpl.php";
     259    header("Location: ../diagnosis");
    283260    exit;
    284261}
  • trunk/htdocs/common/common.php

    r1089 r1090  
    149149    }
    150150    if (!empty($GLOBALS['config']['show_todo_strings'])) {
    151         return '<span style="color:red">' . htmlspecialchars($str) . '</span>|';
     151        return '<span style="color:red">' . $str . '</span>|';
    152152    }
    153153    return $str;
  • trunk/htdocs/diagnosis/diagnosis.tpl.php

    r1089 r1090  
    11<?php include "../common/header.tpl.php"; ?>
     2<table cellspacing="0" cellpadding="4" class="cycles">
     3    <caption>
     4        <?php echo _T("Diagnosis Result"); ?>
     5    </caption>
     6    <tr>
     7        <th>
     8            <?php echo _T("Level"); ?>
     9        </th>
     10        <th>
     11            <?php echo _T("Reason"); ?>
     12        </th>
     13        <th>
     14            <?php echo _T("Suggestion"); ?>
     15        </th>
     16    </tr>
     17<?php foreach ($notes as $note) { ?>
     18    <tr>
     19        <td><?php echo ucfirst($note['type']); ?></td>
     20        <td><?php echo $note['reason']; ?></td>
     21        <td><?php echo $note['suggestion']; ?></td>
     22    </tr>
     23<?php } ?>
     24</table>
    225<?php include "../common/footer.tpl.php"; ?>
  • trunk/htdocs/diagnosis/index.php

    r1089 r1090  
    66
    77$notes = array();
    8 function note($type, $reason, $suggestion)
     8function note($type, $reason, $suggestion = "ok") // {{{
    99{
    1010    global $notes;
     
    1515            );
    1616}
    17 
     17// }}}
    1818function getCacheInfos() // {{{
    1919{
     
    3535    return $cacheInfos;
    3636}
     37// }}}
    3738
    38 $cacheInfos = getCacheInfos();
     39if (!extension_loaded('XCache')) {
     40    ob_start();
     41    phpinfo(INFO_GENERAL);
     42    $info = ob_get_clean();
     43    ob_start();
     44    if (preg_match_all("!<tr>[^<]*<td[^>]*>[^<]*(?:Configuration|ini|Server API)[^<]*</td>[^<]*<td[^>]*>[^<]*</td>[^<]*</tr>!s", $info, $m)) {
     45        echo '<div class="phpinfo">';
     46        echo 'PHP Info';
     47        echo '<table>';
     48        echo implode('', $m[0]);
     49        echo '</table>';
     50        echo '</div>';
     51    }
     52    if (preg_match('!<td class="v">(.*?\\.ini)!', $info, $m)) {
     53        echo "Please check $m[1]";
     54    }
     55    else if (preg_match('!Configuration File \\(php.ini\\) Path *</td><td class="v">([^<]+)!', $info, $m)) {
     56        echo "Please put a php.ini in $m[1] and load XCache extension";
     57    }
     58    else {
     59        echo "You don't even have a php.ini yet?";
     60    }
     61    echo "(See above)";
     62    note("error", _T('XCache is not loaded'), ob_get_clean());
     63}
     64else {
     65    note("info", _T('XCache loaded'));
    3966
    40 // if (!$ini['xcache.size'] || !$ini['xcache.cacher']) {
     67    $cacheInfos = getCacheInfos();
    4168
    42 foreach ($cacheInfos as $cacheInfo) {
    43     if ($cacheInfo['ooms']) {
     69    if (!ini_get("xcache.size") || !ini_get("xcache.cacher")) {
     70        note(
     71            "error"
     72            , _T("XCache is not enabled. Website is not accelerated by XCache")
     73            , _T("Set xcache.size to non-zero, set xcache.cacher = On")
     74            );
     75    }
     76    else {
     77        note("info", _T('XCache Enabled'));
     78    }
     79
     80    $ooms = false;
     81    foreach ($cacheInfos as $cacheInfo) {
     82        if ($cacheInfo['ooms']) {
     83            $ooms = true;
     84            break;
     85        }
     86    }
     87    if ($ooms) {
    4488        note(
    4589            "warning"
    46             , "Out of memory happened when trying to write to cache"
     90            , _T("Out of memory happened when trying to write to cache")
    4791            , "Increase xcache.size and/or xcache.var_size"
    4892            );
    49         break;
    5093    }
    51 }
     94    else {
     95        note("info", _T('XCache Memory Size'));
     96    }
    5297
    53 foreach ($cacheInfos as $cacheInfo) {
    54     if ($cacheInfo['errors']) {
     98    $errors = false;
     99    foreach ($cacheInfos as $cacheInfo) {
     100        if ($cacheInfo['errors']) {
     101            $errors = true;
     102            break;
     103        }
     104    }
     105    if ($errors) {
    55106        note(
    56107            "warning"
    57             , "Error happened when compiling your PHP code"
    58             , "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"
     108            , _T("Error happened when compiling at least one of your PHP code")
     109            , _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")
    59110            );
    60         break;
    61111    }
     112    else {
     113        note("info", _T('All PHP scripts seem fine'));
     114    }
     115
     116    /*
     117    if ($ini['xcache.count'] < cpucount() * 2) {
     118    }
     119
     120    if ($ini['xcache.size'] is small $ini['xcache.slots'] is big) {
     121    }
     122
     123    if ($ini['xcache.readonly_protection']) {
     124    }
     125
     126    if ($cache['compiling']) {
     127    }
     128
     129    if ($cache['compiling']) {
     130    }
     131
     132    if ($cache['disabled']) {
     133    }
     134    */
    62135}
    63136
    64137/*
    65 if ($ini['xcache.count'] < cpucount() * 2) {
    66 }
    67 
    68 if ($ini['xcache.size'] is small $ini['xcache.slots'] is big) {
    69 }
    70 
    71 if ($ini['xcache.readonly_protection']) {
    72 }
    73 
    74 if ($cache['compiling']) {
    75 }
    76 
    77 if ($cache['compiling']) {
    78 }
    79 
    80 if ($cache['disabled']) {
    81 }
    82138
    83139if (($coredumpFiles = globCoreDumpFiles()) {
Note: See TracChangeset for help on using the changeset viewer.