| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | include "../common/common.php"; |
|---|
| 4 | |
|---|
| 5 | $module = "diagnosis"; |
|---|
| 6 | |
|---|
| 7 | $notes = array(); |
|---|
| 8 | function note($type, $reason, $suggestion = "ok") // {{{ |
|---|
| 9 | { |
|---|
| 10 | global $notes; |
|---|
| 11 | $notes[] = array( |
|---|
| 12 | 'type' => $type |
|---|
| 13 | , 'reason' => $reason |
|---|
| 14 | , 'suggestion' => $suggestion |
|---|
| 15 | ); |
|---|
| 16 | } |
|---|
| 17 | // }}} |
|---|
| 18 | function getCacheInfos() // {{{ |
|---|
| 19 | { |
|---|
| 20 | $phpCacheCount = xcache_count(XC_TYPE_PHP); |
|---|
| 21 | $varCacheCount = xcache_count(XC_TYPE_VAR); |
|---|
| 22 | |
|---|
| 23 | $cacheInfos = array(); |
|---|
| 24 | for ($i = 0; $i < $phpCacheCount; $i ++) { |
|---|
| 25 | $cacheInfo = xcache_info(XC_TYPE_PHP, $i); |
|---|
| 26 | $cacheInfo['type'] = XC_TYPE_PHP; |
|---|
| 27 | $cacheInfos[] = $cacheInfo; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | for ($i = 0; $i < $varCacheCount; $i ++) { |
|---|
| 31 | $cacheInfo = xcache_info(XC_TYPE_VAR, $i); |
|---|
| 32 | $cacheInfo['type'] = XC_TYPE_VAR; |
|---|
| 33 | $cacheInfos[] = $cacheInfo; |
|---|
| 34 | } |
|---|
| 35 | return $cacheInfos; |
|---|
| 36 | } |
|---|
| 37 | // }}} |
|---|
| 38 | |
|---|
| 39 | if (!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 | } |
|---|
| 64 | else { |
|---|
| 65 | note("info", _T('XCache loaded')); |
|---|
| 66 | |
|---|
| 67 | $cacheInfos = getCacheInfos(); |
|---|
| 68 | |
|---|
| 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) { |
|---|
| 88 | note( |
|---|
| 89 | "warning" |
|---|
| 90 | , _T("Out of memory happened when trying to write to cache") |
|---|
| 91 | , "Increase xcache.size and/or xcache.var_size" |
|---|
| 92 | ); |
|---|
| 93 | } |
|---|
| 94 | else { |
|---|
| 95 | note("info", _T('XCache Memory Size')); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | $errors = false; |
|---|
| 99 | foreach ($cacheInfos as $cacheInfo) { |
|---|
| 100 | if ($cacheInfo['errors']) { |
|---|
| 101 | $errors = true; |
|---|
| 102 | break; |
|---|
| 103 | } |
|---|
| 104 | } |
|---|
| 105 | if ($errors) { |
|---|
| 106 | note( |
|---|
| 107 | "warning" |
|---|
| 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") |
|---|
| 110 | ); |
|---|
| 111 | } |
|---|
| 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 | */ |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | /* |
|---|
| 138 | |
|---|
| 139 | if (($coredumpFiles = globCoreDumpFiles()) { |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | if (module not for server) { |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | $phpVersion = php_version(); |
|---|
| 146 | foreach ($knownUnstablePhpVersion as $unstablePhpVersion => $reason) { |
|---|
| 147 | if (substr($phpVersion, 0, strlen($unstablePhpVersion)) == $unstablePhpVersion) { |
|---|
| 148 | // .. |
|---|
| 149 | } |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | if (Zend Optimizer is loaded, zend optimize level > 0) { |
|---|
| 153 | warn("disabled"); |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | */ |
|---|
| 157 | |
|---|
| 158 | include "./diagnosis.tpl.php"; |
|---|
| 159 | |
|---|