Changeset 1053
- Timestamp:
- 07/27/2012 09:17:42 AM (10 months ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 removed
- 9 modified
- 14 moved
-
devel/run (modified) (1 diff)
-
htdocs/cacher/cacher-en.lang.php (moved) (moved from trunk/htdocs/cacher/common-en.lang.php)
-
htdocs/cacher/cacher-zh-simplified.lang.php (moved) (moved from trunk/htdocs/cacher/common-zh-simplified-utf-8.lang.php)
-
htdocs/cacher/cacher-zh-traditional.lang.php (moved) (moved from trunk/htdocs/cacher/common-zh-traditional-utf-8.lang.php)
-
htdocs/cacher/cacher.css (moved) (moved from trunk/htdocs/cacher/xcache.css) (2 diffs)
-
htdocs/cacher/cacher.php (moved) (moved from trunk/htdocs/cacher/xcache.php) (4 diffs)
-
htdocs/cacher/cacher.tpl.php (moved) (moved from trunk/htdocs/cacher/xcache.tpl.php) (4 diffs)
-
htdocs/cacher/config.default.php (modified) (2 diffs)
-
htdocs/cacher/config.example.php (modified) (2 diffs)
-
htdocs/cacher/edit.php (modified) (1 diff)
-
htdocs/cacher/edit.tpl.php (modified) (2 diffs)
-
htdocs/cacher/help-zh-simplified.lang.php (moved) (moved from trunk/htdocs/cacher/help-zh-simplified-utf-8.lang.php)
-
htdocs/cacher/help-zh-traditional.lang.php (moved) (moved from trunk/htdocs/cacher/help-zh-traditional-utf-8.lang.php)
-
htdocs/cacher/index.php (modified) (1 diff)
-
htdocs/common (added)
-
htdocs/common/common-en.lang.php (added)
-
htdocs/common/common.php (moved) (moved from trunk/htdocs/cacher/common.php) (7 diffs)
-
htdocs/common/footer.tpl.php (moved) (moved from trunk/htdocs/cacher/footer.tpl.php) (1 diff)
-
htdocs/common/header.tpl.php (moved) (moved from trunk/htdocs/cacher/header.tpl.php) (1 diff)
-
htdocs/config.default.php (added)
-
htdocs/config.example.php (added)
-
htdocs/coverager/common-zh-simplified-gb2312.lang.php (deleted)
-
htdocs/coverager/common.php (added)
-
htdocs/coverager/config.example.php (moved) (moved from trunk/htdocs/coverager/config.php.example) (1 diff)
-
htdocs/coverager/coverager-en.lang.php (moved) (moved from trunk/htdocs/coverager/common-en.lang.php)
-
htdocs/coverager/coverager-zh-simplified.lang.php (moved) (moved from trunk/htdocs/coverager/common-zh-simplified-utf-8.lang.php) (1 diff)
-
htdocs/coverager/coverager.css (modified) (2 diffs)
-
htdocs/coverager/coverager.php (modified) (11 diffs)
-
htdocs/coverager/coverager.tpl.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/devel/run
r1048 r1053 198 198 ;; 199 199 dc) 200 exec ./php-cli -c devel.ini ./ mod_disassembler/bin/phpdc.phpr "${args[@]}" | tee decompiled.php200 exec ./php-cli -c devel.ini ./bin/phpdc.phpr "${args[@]}" | tee decompiled.php 201 201 ;; 202 202 dop) 203 exec ./php-cli -c devel.ini ./ mod_disassembler/bin/phpdop.phpr "${args[@]}"203 exec ./php-cli -c devel.ini ./bin/phpdop.phpr "${args[@]}" 204 204 ;; 205 205 retest) -
trunk/htdocs/cacher/cacher.css
r1041 r1053 1 input, table { font-family: sans-serif; }2 input { font-size: 12px; }3 table { border-collapse: collapse; font-size: 11px; margin: 0; }4 table caption, h2, h3 { font-size: 16px; font-weight: bold; text-align: left; padding-top: 20px; margin-bottom: 2px; }5 h3 { font-size: 14px; padding-top: 2px; margin-bottom: 0px; }6 1 td, th { white-space: pre; } 7 table.cycles { border: 1px solid black; margin-top: 5px; margin-bottom: 5px; }8 table.cycles .col1 { background-color: #f5f5f5; }9 table.cycles .col2 { background-color: #e0e0e0; }10 table.cycles th, table.cycles td { border: 1px solid black; font-family: monospace; }11 table.cycles th { background-color: #9999cc; color: black; font-weight: bold; height: 20px; line-height: 20px; font-family: serif; }12 th a { color: black; font-weight: bold; display: block; width: 100%; height: 100%; }13 th { font-size: 12px; }14 2 .phpinfo table { border: 1px solid black; margin-bottom: 1px; } 15 3 .phpinfo table th, .phpinfo table td { border: 1px solid black; } … … 39 27 .hitsgraph div div.barv.active { border-color: yellow; } 40 28 41 .switcher, h1 { text-align: center; display: block; }42 .switcher a { color: blue; padding: 1px 8px 1px 8px; border: 1px solid white; border-bottom-color: black; text-decoration: none; }43 .switcher a:hover.active44 , .switcher a:active.active45 , .switcher a.active { color: black; background: #99C; border-color: #99C; border-left-color: black; border-right-color: black; }46 .switcher a:hover { background: #f0f0f0; }47 .switcher a:active { background: #e0e0e0; }48 29 #help { display: block; float: right; } 49 .footnote { text-align: right; font-size: 12px; }50 30 dl { overflow: hidden; } 51 31 dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; } -
trunk/htdocs/cacher/cacher.php
r1041 r1053 2 2 3 3 include("./common.php"); 4 5 class Cycle6 {7 var $values;8 var $i;9 var $count;10 11 function Cycle($v)12 {13 $this->values = func_get_args();14 $this->i = -1;15 $this->count = count($this->values);16 }17 18 function next()19 {20 $this->i = ($this->i + 1) % $this->count;21 return $this->values[$this->i];22 }23 24 function cur()25 {26 return $this->values[$this->i];27 }28 29 function reset()30 {31 $this->i = -1;32 }33 }34 35 function number_formats($a, $keys)36 {37 foreach ($keys as $k) {38 $a[$k] = number_format($a[$k]);39 }40 return $a;41 }42 43 function size($size)44 {45 $size = (int) $size;46 if ($size < 1024)47 return number_format($size, 2) . ' b';48 49 if ($size < 1048576)50 return number_format($size / 1024, 2) . ' K';51 52 return number_format($size / 1048576, 2) . ' M';53 }54 55 function age($time)56 {57 if (!$time) return '';58 $delta = REQUEST_TIME - $time;59 60 if ($delta < 0) {61 $delta = -$delta;62 }63 64 static $seconds = array(1, 60, 3600, 86400, 604800, 2678400, 31536000);65 static $name = array('s', 'm', 'h', 'd', 'w', 'M', 'Y');66 67 for ($i = 6; $i >= 0; $i --) {68 if ($delta >= $seconds[$i]) {69 $ret = (int) ($delta / $seconds[$i]);70 return $ret . ' ' . $name[$i];71 }72 }73 74 return '0 s';75 }76 4 77 5 function freeblock_to_graph($freeblocks, $size) … … 183 111 } 184 112 185 function switcher($name, $options) 186 { 187 $n = isset($_GET[$name]) ? $_GET[$name] : null; 188 $html = array(); 189 foreach ($options as $k => $v) { 190 $html[] = sprintf('<a href="?%s=%s"%s>%s</a>', $name, $k, $k == $n ? ' class="active"' : '', $v); 191 } 192 return implode('', $html); 193 } 194 195 function th($name, $attrs = null) 196 { 197 $translated = __($name); 198 if ($translated == $name) { 199 $translated = "$name|$name"; 200 } 201 list($text, $title) = explode('|', $translated, 2); 202 return sprintf('%s<th%s id="%s" title="%s"><a href="javascript:" onclick="resort(this); return false">%s</a></th>%s' 203 , "\t" 204 , $attrs ? " $attrs" : "" 205 , $name, htmlspecialchars(trim($title)), trim($text) 206 , "\n"); 207 } 208 209 $php_version = phpversion(); 210 $xcache_version = XCACHE_VERSION; 211 $xcache_modules = XCACHE_MODULES; 212 113 $module = "cacher"; 213 114 if (!extension_loaded('XCache')) { 214 include(" header.tpl.php");115 include("../common/header.tpl.php"); 215 116 echo '<h1>XCache is not loaded</h1>'; 216 117 ob_start(); … … 235 136 } 236 137 echo "(See above)"; 237 include(" footer.tpl.php");138 include("../common/footer.tpl.php"); 238 139 exit; 239 140 } … … 401 302 $type_php = XC_TYPE_PHP; 402 303 $type_var = XC_TYPE_VAR; 403 $ types = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));404 405 include(" xcache.tpl.php");304 $listTypes = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data')); 305 306 include("cacher.tpl.php"); 406 307 407 308 ?> -
trunk/htdocs/cacher/cacher.tpl.php
r1041 r1053 1 <?php include("header.tpl.php"); ?> 1 <?php include("../common/header.tpl.php"); ?> 2 <div class="switcher"><?php echo switcher("type", $listTypes); ?></div> 2 3 <div id="help"> 3 4 <a href="help.php"><?php echo _("Help") ?> »</a> 4 5 </div> 5 <div class="switcher"><?php echo switcher("type", $types); ?></div>6 6 <?php 7 7 $a = new Cycle('class="col1"', 'class="col2"'); … … 215 215 $hits = number_format($entry['hits']); 216 216 $size = size($entry['size']); 217 $class_cnt = number_format($entry['class_cnt']);218 $function_cnt = number_format($entry['function_cnt']);219 if ($isphp) {220 $phprefcount = number_format($entry['phprefcount']);221 $file_size = size($entry['file_size']);217 if ($isphp) { 218 $class_cnt = number_format($entry['class_cnt']); 219 $function_cnt = number_format($entry['function_cnt']); 220 $phprefcount = number_format($entry['phprefcount']); 221 $file_size = size($entry['file_size']); 222 222 } 223 223 … … 231 231 } 232 232 233 if (!$isphp) { 233 if ($isphp) { 234 $namelink = $name; 234 235 echo <<<ENTRY 235 <td><input type="checkbox" name="remove[]" value="{$name}"/></td> 236 <td>{$entry['cache_name']} {$i}</td> 237 ENTRY; 238 } 239 else { 240 echo <<<ENTRY 241 <td><label><input type="checkbox" name="remove[]" value="{$name}"/>{$entry['cache_name']} {$i}</label></td> 236 242 ENTRY; 237 243 $uname = urlencode($entry['name']); 238 244 $namelink = "<a href=\"edit.php?name=$uname\">$name</a>"; 239 245 } 240 else {241 $namelink = $name;242 }243 246 244 247 echo <<<ENTRY 245 <td>{$entry['cache_name']} {$i}</td>246 248 <td>{$namelink}</td> 247 249 <td align="right" int="{$entry['hits']}">{$entry['hits']}</td> … … 299 301 } 300 302 ?> 301 <?php include(" footer.tpl.php"); ?>303 <?php include("../common/footer.tpl.php"); ?> -
trunk/htdocs/cacher/config.default.php
r920 r1053 1 1 <?php 2 2 3 // this is default config4 // DO NOT rename/delete/modify this file 5 // see config.example.php3 // [default config] 4 // DO NOT rename/delete/modify this file which will be overwritten when upgrade 5 // See config.example.php instead 6 6 7 // detected by browser8 // $config['lang'] = 'en-us';9 10 $config['charset'] = "UTF-8";11 12 // translators only13 $config['show_todo_strings'] = false;14 7 15 8 // width of graph for free or usage blocks … … 21 14 $config['enable_eval'] = false; 22 15 23 // this ob filter is applied for the cache list, not the whole page24 $config['path_nicer'] = 'ob_filter_path_nicer_default';25 26 ?> -
trunk/htdocs/cacher/config.example.php
r920 r1053 1 1 <?php 2 2 3 // this is example config 4 // DO NOT rename/delete/modify this file 5 // if you want to customize config, copy this file and name it as config.php 6 // upgrading your config.php when config.example.php were upgraded 7 8 // leave this setting unset to auto detect using browser request header 9 // $config['lang'] = 'en-us'; 10 11 $config['charset'] = "UTF-8"; 12 13 // enable this for translators only 14 $config['show_todo_strings'] = false; 3 // DO NOT rename/delete/modify example file which will be overwritten when upgrade 4 // How To Custom Config: 5 // 1. copy config.example.php config.php; edit config.php 6 // 2. upgrading your config.php when config.example.php were upgraded 7 // XCache will load 8 // 1. ../config.default.php 9 // 2. ./config.default.php 10 // 3. ../config.php 11 // 4. ./config.php 15 12 16 13 // width of graph for free or usage blocks … … 22 19 $config['enable_eval'] = false; 23 20 24 // this ob filter is applied for the cache list, not the whole page25 function custom_ob_filter_path_nicer($list_html)26 {27 $list_html = ob_filter_path_nicer_default($list_html); // this function is from common.php28 return $list_html;29 }30 $config['path_nicer'] = 'custom_ob_filter_path_nicer';31 32 // XCache builtin http auth is enforce for security reason33 // if http auth is disabled, any vhost user that can upload *.php, will see all variable data cached in XCache34 35 // but if you have your own login/permission system, you can use the following example36 // {{{ login example37 // this is an example only, it's won't work for you without your implemention.38 /*39 function check_admin_and_by_pass_xcache_http_auth()40 {41 require("/path/to/user-login-and-permission-lib.php");42 session_start();43 44 if (user_logined()) {45 user_load_permissions();46 if (user_is_admin()) {47 // user is trusted after permission checks above.48 // tell XCache about it (the only secure way to by pass XCache http auth)49 $_SERVER["PHP_AUTH_USER"] = "moo";50 $_SERVER["PHP_AUTH_PW"] = "your-xcache-password-before-md5";51 }52 else {53 die("Permission denied");54 }55 }56 else {57 if (!ask_the_user_to_login()) {58 exit;59 }60 }61 62 return true;63 }64 65 check_admin_and_by_pass_xcache_http_auth();66 */67 // }}}68 69 /* by pass XCache http auth70 $_SERVER["PHP_AUTH_USER"] = "moo";71 $_SERVER["PHP_AUTH_PW"] = "your-xcache-password-before-md5";72 */73 74 ?> -
trunk/htdocs/cacher/edit.php
r934 r1053 37 37 } 38 38 39 $php_version = phpversion(); 40 $xcache_version = XCACHE_VERSION; 41 $xcache_modules = XCACHE_MODULES; 39 $module = "cacher"; 42 40 43 41 include("edit.tpl.php"); -
trunk/htdocs/cacher/edit.tpl.php
r1038 r1053 1 <?php include(" header.tpl.php"); ?>1 <?php include("../common/header.tpl.php"); ?> 2 2 <?php 3 3 $h_name = htmlspecialchars($name); … … 16 16 </fieldset> 17 17 </form> 18 <?php include(" footer.tpl.php"); ?>18 <?php include("../common/footer.tpl.php"); ?> -
trunk/htdocs/cacher/index.php
r605 r1053 1 1 <?php 2 2 3 include(" xcache.php");3 include("cacher.php"); -
trunk/htdocs/common/common.php
r1038 r1053 1 1 <?php 2 2 3 class Cycle 4 { 5 var $values; 6 var $i; 7 var $count; 8 9 function Cycle($v) 10 { 11 $this->values = func_get_args(); 12 $this->i = -1; 13 $this->count = count($this->values); 14 } 15 16 function next() 17 { 18 $this->i = ($this->i + 1) % $this->count; 19 return $this->values[$this->i]; 20 } 21 22 function cur() 23 { 24 return $this->values[$this->i]; 25 } 26 27 function reset() 28 { 29 $this->i = -1; 30 } 31 } 32 33 function switcher($name, $options) 34 { 35 $n = isset($_GET[$name]) ? $_GET[$name] : null; 36 $html = array(); 37 foreach ($options as $k => $v) { 38 $html[] = sprintf('<a href="?%s=%s"%s>%s</a>', $name, $k, $k == $n ? ' class="active"' : '', $v); 39 } 40 return implode('', $html); 41 } 42 43 function moduleswitcher() 44 { 45 global $module, $modules; 46 $html = array(); 47 foreach ($modules as $k => $v) { 48 $html[] = sprintf('<a href="../%s/"%s>%s</a>', $k, $k == $module ? ' class="active"' : '', $v); 49 } 50 return implode('', $html); 51 } 52 53 function th($name, $attrs = null) 54 { 55 $translated = __($name); 56 if ($translated == $name) { 57 $translated = "$name|$name"; 58 } 59 list($text, $title) = explode('|', $translated, 2); 60 return sprintf('%s<th%s id="%s" title="%s"><a href="javascript:" onclick="resort(this); return false">%s</a></th>%s' 61 , "\t" 62 , $attrs ? " $attrs" : "" 63 , $name, htmlspecialchars(trim($title)), trim($text) 64 , "\n"); 65 } 66 3 67 function xcache_validateFileName($name) 4 68 { … … 6 70 } 7 71 8 function get_language_file_ex($name, $l , $s)9 { 10 static $l map = array(72 function get_language_file_ex($name, $lang) 73 { 74 static $langMap = array( 11 75 'zh' => 'zh-simplified', 12 76 'zh-hk' => 'zh-traditional', 13 77 'zh-tw' => 'zh-traditional', 14 78 ); 15 static $smap = array( 16 'gbk' => 'gb2312', 17 'gb18030' => 'gb2312', 18 ); 19 20 if (isset($lmap[$l])) { 21 $l = $lmap[$l]; 22 } 23 $file = "$name-$l-$s.lang.php"; 79 80 if (isset($langMap[$lang])) { 81 $lang = $langMap[$lang]; 82 } 83 $file = "$name-$lang.lang.php"; 24 84 if (xcache_validateFileName($file) && file_exists($file)) { 25 85 return $file; 26 86 } 27 if (isset($smap[$s])) {28 $s = $smap[$s];29 $file = "$name-$l-$s.lang.php";30 if (xcache_validateFileName($file) && file_exists($file)) {31 return $file;32 }33 }34 $file = "$name-$l.lang.php";35 if (xcache_validateFileName($file) && file_exists($file)) {36 return $file;37 }38 87 return null; 39 88 } … … 42 91 { 43 92 global $config; 44 $s = strtolower($config['charset']);45 93 if (!empty($config['lang'])) { 46 $l = strtolower($config['lang']);47 $file = get_language_file_ex($name, $l , $s);94 $lang = strtolower($config['lang']); 95 $file = get_language_file_ex($name, $lang); 48 96 if (!isset($file)) { 49 $l = strtok($l, ':-');50 $file = get_language_file_ex($name, $l , $s);97 $lang = strtok($lang, ':-'); 98 $file = get_language_file_ex($name, $lang); 51 99 } 52 100 } 53 101 else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 54 foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $l ) {55 $l = strtok($l, ':;');56 $file = get_language_file_ex($name, $l , $s);102 foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $lang) { 103 $lang = strtok($lang, ':;'); 104 $file = get_language_file_ex($name, $lang); 57 105 if (isset($file)) { 58 $config['lang'] = $l ;106 $config['lang'] = $lang; 59 107 break; 60 108 } 61 if (strpos($l, '-') !== false) { 62 $ll = strtok($l, ':-'); 63 $file = get_language_file_ex($name, $ll, $s); 109 if (strpos($lang, '-') !== false) { 110 $file = get_language_file_ex($name, strtok($lang, ':-')); 64 111 if (isset($file)) { 65 $config['lang'] = $l ;112 $config['lang'] = $lang; 66 113 break; 67 114 } … … 91 138 { 92 139 return $str; 140 } 141 142 function number_formats($a, $keys) 143 { 144 foreach ($keys as $k) { 145 $a[$k] = number_format($a[$k]); 146 } 147 return $a; 148 } 149 150 function size($size) 151 { 152 $size = (int) $size; 153 if ($size < 1024) 154 return number_format($size, 2) . ' b'; 155 156 if ($size < 1048576) 157 return number_format($size / 1024, 2) . ' K'; 158 159 return number_format($size / 1048576, 2) . ' M'; 160 } 161 162 function age($time) 163 { 164 if (!$time) return ''; 165 $delta = REQUEST_TIME - $time; 166 167 if ($delta < 0) { 168 $delta = -$delta; 169 } 170 171 static $seconds = array(1, 60, 3600, 86400, 604800, 2678400, 31536000); 172 static $name = array('s', 'm', 'h', 'd', 'w', 'M', 'Y'); 173 174 for ($i = 6; $i >= 0; $i --) { 175 if ($delta >= $seconds[$i]) { 176 $ret = (int) ($delta / $seconds[$i]); 177 return $ret . ' ' . $name[$i]; 178 } 179 } 180 181 return '0 s'; 93 182 } 94 183 … … 121 210 return $list_html; 122 211 } 123 124 212 125 213 error_reporting(E_ALL); … … 137 225 138 226 $config = array(); 139 include("./config.default.php"); 227 if (file_exists("./config.default.php")) { 228 include("./config.default.php"); 229 } 230 include("../config.default.php"); 231 if (file_exists("../config.php")) { 232 include("../config.php"); 233 } 140 234 if (file_exists("./config.php")) { 141 235 include("./config.php"); … … 143 237 144 238 include(get_language_file("common")); 145 if (empty($config['lang'])) { 146 $config['lang'] = 'en-us'; 147 } 148 239 240 $modules = array(); 241 if (file_exists("../cacher/index.php")) { 242 $modules["cacher"] = _("Cacher"); 243 } 244 if (file_exists("../coverager/index.php")) { 245 $modules["coverager"] = _("Coverager"); 246 } 149 247 header("Cache-Control: no-cache, must-revalidate"); 150 248 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); -
trunk/htdocs/common/footer.tpl.php
r934 r1053 1 1 <div class="footnote"> 2 <?php echo <<<EOS 3 PHP {$php_version} Powered By: XCache {$xcache_version}, {$xcache_modules} 4 EOS; 2 PHP <?php 3 echo phpversion(); 4 ?> Powered By: XCache <?php 5 echo defined('XCACHE_VERSION') ? XCACHE_VERSION : ''; 6 ?>, <?php 7 echo defined('XCACHE_MODULES') ? XCACHE_MODULES : ''; 5 8 ?> 9 6 10 </div> 7 11 -
trunk/htdocs/common/header.tpl.php
r1038 r1053 2 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 3 <head> 4 <?php 5 echo <<<HEAD 6 <meta http-equiv="Content-Type" content="text/html; charset=$config[charset]" /> 7 <meta http-equiv="Content-Language" content="$config[lang]" /> 8 <script type="text/javascript" src="tablesort.js" charset="$config[charset]"></script> 9 HEAD; 10 ?> 4 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['config']['charset']; ?>" /> 5 <meta http-equiv="Content-Language" content="<?php echo $GLOBALS['config']['charset']; ?>" /> 6 <script type="text/javascript" src="tablesort.js"></script> 11 7 12 <link rel="stylesheet" type="text/css" href="xcache.css" /> 13 <title><?php echo sprintf(_("XCache %s Administration"), $xcache_version); ?></title> 8 <link rel="stylesheet" type="text/css" href="../common/common.css" /> 9 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['module']; ?>.css" /> 10 <title><?php echo $title = sprintf("XCache %s", $xcache_version = defined('XCACHE_VERSION') ? XCACHE_VERSION : '') . " - " . ucfirst($GLOBALS['module']); ?></title> 14 11 </head> 15 12 16 13 <body> 17 <h1><?php echo sprintf(_("XCache %s Administration"), $xcache_version); ?></h1> 14 <h1><?php echo $title; ?></h1> 15 <div class="switcher"><?php echo moduleswitcher(); ?></div> -
trunk/htdocs/coverager/config.example.php
r605 r1053 1 1 <?php 2 2 3 // this is an example only 4 // write your own config and name it as config.php 3 // DO NOT rename/delete/modify example file which will be overwritten when upgrade 4 // How To Custom Config: 5 // 1. copy config.example.php config.php; edit config.php 6 // 2. upgrading your config.php when config.example.php were upgraded 7 // XCache will load 8 // 1. ../config.default.php 9 // 2. ./config.default.php 10 // 3. ../config.php 11 // 4. ./config.php 5 12 6 // detected by browser 7 // $lang = 'en-us'; 13 // $config['include_paths = array("/www/my-php-project/"); 14 // $config['exclude_paths = array("/www/my-php-project/tmp/"); 15 $config['syntax_higlight'] = true; 16 $config['use_cache'] = false; 17 //// $config['datadir'] is default to ini_get("xcache.coveragedump_directory") 18 // $config['datadir'] = ''; 8 19 9 $charset = "UTF-8";10 11 // developers only12 $show_todo_strings = false;13 14 // $include_paths = array("/www/my-php-project/");15 // $exclude_paths = array("/www/my-php-project/tmp/");16 $syntaxhiglight = true;17 $usecache = false;18 //// $datadir is default to ini_get("xcache.coveragedump_directory")19 // $datadir = '';20 21 function ob_filter_path_nicer($o)22 {23 $sep = DIRECTORY_SEPARATOR;24 $o = str_replace($_SERVER['DOCUMENT_ROOT'], "{DOCROOT}" . (substr($d, -1) == $sep ? $sep : ""), $o);25 $xcachedir = realpath(dirname(__FILE__) . "$sep..$sep");26 $o = str_replace($xcachedir . $sep, "{XCache}$sep", $o);27 if ($sep == '/') {28 $o = str_replace("/home/", "{H}/", $o);29 }30 return $o;31 }32 33 // implement your auth here if needed34 // {{{ home made login example35 // this is an example only, it's won't work for you without your implemention.36 function check_admin_auth()37 {38 require("/path/to/user-login-and-permission-lib.php");39 session_start();40 41 if (!user_logined()) {42 if (!ask_the_user_to_login()) {43 exit;44 }45 }46 47 user_load_permissions();48 if (!user_is_admin()) {49 die("Permission denied");50 }51 52 return true;53 }54 55 // uncomment:56 // check_admin_auth()57 // }}}58 59 ?> -
trunk/htdocs/coverager/coverager-zh-simplified.lang.php
r393 r1053 1 1 <?php 2 2 3 $strings = array(3 $strings += array( 4 4 'root' 5 5 => '开始', -
trunk/htdocs/coverager/coverager.css
r605 r1053 1 h1 { text-align: center; display: block; }2 input, table { font-family: sans-serif; font-size: 11px; }3 th { font-size: 12px; }4 table { border-collapse: collapse; }5 1 table.center { margin-left: auto; margin-right: auto; } 6 2 table\-center { text-align: center; } 7 table.cycles { border: 1px solid black; margin-top: 5px; margin-bottom: 5px; }8 table.cycles .col1 { background-color: #f5f5f5; }9 table.cycles .col2 { background-color: #e0e0e0; }10 table.cycles th, table.cycles td { border: 1px solid black; font-family: monospace; }11 table.cycles th { background-color: #9999cc; color: black; font-weight: bold; height: 20px; line-height: 20px; font-family: serif; }12 th a { color: black; font-weight: bold; display: block; width: 100%; height: 100%; }13 3 14 4 .coverFile { … … 68 58 } 69 59 70 .footnote { text-align: right; font-size: 12px; }71 60 .error { color: red; } -
trunk/htdocs/coverager/coverager.php
r531 r1053 2 2 3 3 include("./common.php"); 4 5 class Cycle6 {7 var $values;8 var $i;9 var $count;10 11 function Cycle($v)12 {13 $this->values = func_get_args();14 $this->i = -1;15 $this->count = count($this->values);16 }17 18 function next()19 {20 $this->i = ($this->i + 1) % $this->count;21 return $this->values[$this->i];22 }23 24 function cur()25 {26 return $this->values[$this->i];27 }28 29 function reset()30 {31 $this->i = -1;32 }33 }34 4 35 5 class XcacheCoverageViewer 36 6 { 37 var $syntax higlight = true;38 var $use cache = false;7 var $syntax_higlight = true; 8 var $use_cache = false; 39 9 var $include_paths = array(); 40 10 var $exclude_paths = array(); … … 50 20 $this->datadir = ini_get('xcache.coveragedump_directory'); 51 21 52 // copy config53 foreach (array('charset', 'include_paths', 'exclude_paths', 'syntax higlight', 'usecache', 'datadir', 'lang') as $k) {54 if (isset($ GLOBALS[$k])) {55 $this->{$k} = $ GLOBALS[$k];22 global $config; 23 foreach (array('charset', 'include_paths', 'exclude_paths', 'syntax_higlight', 'use_cache', 'datadir', 'lang') as $k) { 24 if (isset($config[$k])) { 25 $this->{$k} = $config[$k]; 56 26 } 57 27 } … … 79 49 $prefix_len = strlen($path) + 1; 80 50 $dirinfo = $this->loadDir($this->outpath); 81 if (!$this->use cache) {51 if (!$this->use_cache) { 82 52 ksort($dirinfo['subdirs']); 83 53 ksort($dirinfo['files']); … … 104 74 } 105 75 } 106 if ($this->syntax higlight) {76 if ($this->syntax_higlight) { 107 77 $source = implode('', $lines); 108 78 ob_start(); … … 130 100 else if (!$this->datadir) { 131 101 $action = 'error'; 132 $error = 'require ` ini:xcache.coveragedump_directory` or `config:$datadir`to be set';102 $error = 'require `xcache.coveragedump_directory` in ini or `$datadir` in config to be set'; 133 103 } 134 104 else { … … 137 107 } 138 108 139 $xcache_version = defined('XCACHE_VERSION') ? XCACHE_VERSION : '';109 global $config; 140 110 include("coverager.tpl.php"); 141 111 } … … 143 113 function loadDir($outdir, $addtodo = null) 144 114 { 145 if ($this->use cache) {115 if ($this->use_cache) { 146 116 $cachefile = $outdir . "/.pcovcache"; 147 117 if (file_exists($cachefile)) { … … 210 180 } 211 181 212 if ($this->use cache) {182 if ($this->use_cache) { 213 183 ksort($subdirs); 214 184 ksort($files); … … 223 193 ); 224 194 225 if ($this->use cache) {195 if ($this->use_cache) { 226 196 $fp = fopen($cachefile, "wb"); 227 197 fwrite($fp, serialize($info)); … … 233 203 function loadFile($file) 234 204 { 235 if ($this->use cache) {205 if ($this->use_cache) { 236 206 $cachefile = $file . "cache"; 237 207 if (file_exists($cachefile)) { … … 243 213 unset($info['cov']); 244 214 245 if ($this->use cache) {215 if ($this->use_cache) { 246 216 $fp = fopen($cachefile, "wb"); 247 217 fwrite($fp, serialize($info)); -
trunk/htdocs/coverager/coverager.tpl.php
r530 r1053 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <?php 5 echo <<<HEAD 6 <meta http-equiv="Content-Type" content="text/html; charset=$this->charset" /> 7 <meta http-equiv="Content-Language" content="{$this->lang}" /> 8 <script type="text/javascript" src="tablesort.js" charset="$this->charset"></script> 9 HEAD; 10 ?> 11 12 <link rel="stylesheet" type="text/css" href="coverager.css" /> 13 <title><?php echo _T("XCache PHP Code Coverage Viewer"); ?></title> 14 </head> 15 <body> 16 <h1><?php echo _T("XCache PHP Code Coverage Viewer"); ?></h1> 1 <?php include "../common/header.tpl.php"; ?> 17 2 18 3 <?php … … 50 35 global $cycle; 51 36 $cycle = new Cycle('class="col1"', 'class="col2"'); 52 $l_dir = _ T("Directory");53 $l_per = _ T("Percent");54 $l_hit = _ T("Hits");55 $l_lns = _ T("Lines");56 $l_tds = _ T("TODO");37 $l_dir = _("Directory"); 38 $l_per = _("Percent"); 39 $l_hit = _("Hits"); 40 $l_lns = _("Lines"); 41 $l_tds = _("TODO"); 57 42 return <<<EOS 58 43 <div class="table-center"> … … 114 99 global $cycle; 115 100 $cycle = new Cycle('class="col1"', 'class="col2"'); 116 $l_fil = _ T("File");117 $l_per = _ T("Percent");118 $l_hit = _ T("Hits");119 $l_lns = _ T("Lines");101 $l_fil = _("File"); 102 $l_per = _("Percent"); 103 $l_hit = _("Hits"); 104 $l_lns = _("Lines"); 120 105 return <<<EOS 121 106 <div class="center-table"> … … 168 153 } 169 154 170 $l_root = _ T("root");155 $l_root = _("root"); 171 156 if ($action == 'dir') { 172 157 if (function_exists('ob_filter_path_nicer')) { … … 246 231 ?> 247 232 248 <div class="footnote"> 249 Powered By: XCache <?php echo $xcache_version; ?> coverager <?php echo _T("module"); ?> 250 </div> 251 252 </body> 253 </html> 233 <?php include "../common/footer.tpl.php"; ?> 234

