Ignore:
Timestamp:
2012-07-30T17:01:09+02:00 (2 years ago)
Author:
moo
Message:

diagnosis: impl some advises

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.