Changeset 1053


Ignore:
Timestamp:
2012-07-27T09:17:42+02:00 (21 months ago)
Author:
moo
Message:

refactor: move htdocs, bin, lib for easier installation

Location:
trunk
Files:
5 added
1 deleted
9 edited
14 moved

Legend:

Unmodified
Added
Removed
  • trunk/devel/run

    r1048 r1053  
    198198    ;; 
    199199dc) 
    200     exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdc.phpr "${args[@]}" | tee decompiled.php 
     200    exec ./php-cli -c devel.ini ./bin/phpdc.phpr "${args[@]}" | tee decompiled.php 
    201201    ;; 
    202202dop) 
    203     exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdop.phpr "${args[@]}" 
     203    exec ./php-cli -c devel.ini ./bin/phpdop.phpr "${args[@]}" 
    204204    ;; 
    205205retest) 
  • trunk/htdocs/cacher/cacher.css

    r1052 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; } 
    61td, 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; } 
    142.phpinfo table { border: 1px solid black; margin-bottom: 1px; } 
    153.phpinfo table th, .phpinfo table td { border: 1px solid black; } 
     
    3927.hitsgraph div div.barv.active { border-color: yellow; } 
    4028 
    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.active 
    44 , .switcher a:active.active 
    45 , .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; } 
    4829#help { display: block; float: right; } 
    49 .footnote { text-align: right; font-size: 12px; } 
    5030dl { overflow: hidden; } 
    5131dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; } 
  • trunk/htdocs/cacher/cacher.php

    r1052 r1053  
    22 
    33include("./common.php"); 
    4  
    5 class Cycle 
    6 { 
    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 } 
    764 
    775function freeblock_to_graph($freeblocks, $size) 
     
    183111} 
    184112 
    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"; 
    213114if (!extension_loaded('XCache')) { 
    214     include("header.tpl.php"); 
     115    include("../common/header.tpl.php"); 
    215116    echo '<h1>XCache is not loaded</h1>'; 
    216117    ob_start(); 
     
    235136    } 
    236137    echo "(See above)"; 
    237     include("footer.tpl.php"); 
     138    include("../common/footer.tpl.php"); 
    238139    exit; 
    239140} 
     
    401302$type_php = XC_TYPE_PHP; 
    402303$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 
     306include("cacher.tpl.php"); 
    406307 
    407308?> 
  • trunk/htdocs/cacher/cacher.tpl.php

    r1052 r1053  
    1 <?php include("header.tpl.php"); ?> 
     1<?php include("../common/header.tpl.php"); ?> 
     2<div class="switcher"><?php echo switcher("type", $listTypes); ?></div> 
    23<div id="help"> 
    34    <a href="help.php"><?php echo _("Help") ?> &raquo;</a> 
    45</div> 
    5 <div class="switcher"><?php echo switcher("type", $types); ?></div> 
    66<?php 
    77$a = new Cycle('class="col1"', 'class="col2"'); 
     
    215215            $hits     = number_format($entry['hits']); 
    216216            $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']); 
    222222            } 
    223223 
     
    231231            } 
    232232 
    233             if (!$isphp) { 
     233            if ($isphp) { 
     234                $namelink = $name; 
    234235                echo <<<ENTRY 
    235                     <td><input type="checkbox" name="remove[]" value="{$name}"/></td> 
     236                <td>{$entry['cache_name']} {$i}</td> 
     237ENTRY; 
     238            } 
     239            else { 
     240                echo <<<ENTRY 
     241                    <td><label><input type="checkbox" name="remove[]" value="{$name}"/>{$entry['cache_name']} {$i}</label></td> 
    236242ENTRY; 
    237243                $uname = urlencode($entry['name']); 
    238244                $namelink = "<a href=\"edit.php?name=$uname\">$name</a>"; 
    239245            } 
    240             else { 
    241                 $namelink = $name; 
    242             } 
    243246 
    244247            echo <<<ENTRY 
    245             <td>{$entry['cache_name']} {$i}</td> 
    246248            <td>{$namelink}</td> 
    247249            <td align="right" int="{$entry['hits']}">{$entry['hits']}</td> 
     
    299301} 
    300302?> 
    301 <?php include("footer.tpl.php"); ?> 
     303<?php include("../common/footer.tpl.php"); ?> 
  • trunk/htdocs/cacher/config.default.php

    r920 r1053  
    11<?php 
    22 
    3 // this is default config 
    4 // DO NOT rename/delete/modify this file 
    5 // see config.example.php 
     3// [default config] 
     4// DO NOT rename/delete/modify this file which will be overwritten when upgrade 
     5// See config.example.php instead 
    66 
    7 // detected by browser 
    8 // $config['lang'] = 'en-us'; 
    9  
    10 $config['charset'] = "UTF-8"; 
    11  
    12 // translators only 
    13 $config['show_todo_strings'] = false; 
    147 
    158// width of graph for free or usage blocks 
     
    2114$config['enable_eval'] = false; 
    2215 
    23 // this ob filter is applied for the cache list, not the whole page 
    24 $config['path_nicer'] = 'ob_filter_path_nicer_default'; 
    25  
    26 ?> 
  • trunk/htdocs/cacher/config.example.php

    r920 r1053  
    11<?php 
    22 
    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 
    1512 
    1613// width of graph for free or usage blocks 
     
    2219$config['enable_eval'] = false; 
    2320 
    24 // this ob filter is applied for the cache list, not the whole page 
    25 function custom_ob_filter_path_nicer($list_html) 
    26 { 
    27     $list_html = ob_filter_path_nicer_default($list_html); // this function is from common.php 
    28     return $list_html; 
    29 } 
    30 $config['path_nicer'] = 'custom_ob_filter_path_nicer'; 
    31  
    32 // XCache builtin http auth is enforce for security reason 
    33 // if http auth is disabled, any vhost user that can upload *.php, will see all variable data cached in XCache 
    34  
    35 // but if you have your own login/permission system, you can use the following example 
    36 // {{{ login example 
    37 // 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 auth 
    70 $_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  
    3737} 
    3838 
    39 $php_version = phpversion(); 
    40 $xcache_version = XCACHE_VERSION; 
    41 $xcache_modules = XCACHE_MODULES; 
     39$module = "cacher"; 
    4240 
    4341include("edit.tpl.php"); 
  • trunk/htdocs/cacher/edit.tpl.php

    r1038 r1053  
    1 <?php include("header.tpl.php"); ?> 
     1<?php include("../common/header.tpl.php"); ?> 
    22<?php 
    33$h_name = htmlspecialchars($name); 
     
    1616    </fieldset> 
    1717</form> 
    18 <?php include("footer.tpl.php"); ?> 
     18<?php include("../common/footer.tpl.php"); ?> 
  • trunk/htdocs/cacher/index.php

    r605 r1053  
    11<?php 
    22 
    3 include("xcache.php"); 
     3include("cacher.php"); 
  • trunk/htdocs/common/common.php

    r1052 r1053  
    11<?php 
    22 
     3class 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 
     33function 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 
     43function 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 
     53function 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 
    367function xcache_validateFileName($name) 
    468{ 
     
    670} 
    771 
    8 function get_language_file_ex($name, $l, $s) 
    9 { 
    10     static $lmap = array( 
     72function get_language_file_ex($name, $lang) 
     73{ 
     74    static $langMap = array( 
    1175            'zh'    => 'zh-simplified', 
    1276            'zh-hk' => 'zh-traditional', 
    1377            'zh-tw' => 'zh-traditional', 
    1478            ); 
    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"; 
    2484    if (xcache_validateFileName($file) && file_exists($file)) { 
    2585        return $file; 
    2686    } 
    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     } 
    3887    return null; 
    3988} 
     
    4291{ 
    4392    global $config; 
    44     $s = strtolower($config['charset']); 
    4593    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); 
    4896        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); 
    5199        } 
    52100    } 
    53101    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); 
    57105            if (isset($file)) { 
    58                 $config['lang'] = $l; 
     106                $config['lang'] = $lang; 
    59107                break; 
    60108            } 
    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, ':-')); 
    64111                if (isset($file)) { 
    65                     $config['lang'] = $l; 
     112                    $config['lang'] = $lang; 
    66113                    break; 
    67114                } 
     
    91138{ 
    92139    return $str; 
     140} 
     141 
     142function number_formats($a, $keys) 
     143{ 
     144    foreach ($keys as $k) { 
     145        $a[$k] = number_format($a[$k]); 
     146    } 
     147    return $a; 
     148} 
     149 
     150function 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 
     162function 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'; 
    93182} 
    94183 
     
    121210    return $list_html; 
    122211} 
    123  
    124212 
    125213error_reporting(E_ALL); 
     
    137225 
    138226$config = array(); 
    139 include("./config.default.php"); 
     227if (file_exists("./config.default.php")) { 
     228    include("./config.default.php"); 
     229} 
     230include("../config.default.php"); 
     231if (file_exists("../config.php")) { 
     232    include("../config.php"); 
     233} 
    140234if (file_exists("./config.php")) { 
    141235    include("./config.php"); 
     
    143237 
    144238include(get_language_file("common")); 
    145 if (empty($config['lang'])) { 
    146     $config['lang'] = 'en-us'; 
    147 } 
    148  
     239 
     240$modules = array(); 
     241if (file_exists("../cacher/index.php")) { 
     242    $modules["cacher"] = _("Cacher"); 
     243} 
     244if (file_exists("../coverager/index.php")) { 
     245    $modules["coverager"] = _("Coverager"); 
     246} 
    149247header("Cache-Control: no-cache, must-revalidate"); 
    150248header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 
  • trunk/htdocs/common/footer.tpl.php

    r1052 r1053  
    11<div class="footnote"> 
    2 <?php echo <<<EOS 
    3 PHP {$php_version} Powered By: XCache {$xcache_version}, {$xcache_modules} 
    4 EOS; 
     2PHP <?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 : ''; 
    58?> 
     9 
    610</div> 
    711 
  • trunk/htdocs/common/header.tpl.php

    r1052 r1053  
    22<html xmlns="http://www.w3.org/1999/xhtml"> 
    33<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> 
    117 
    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> 
    1411</head> 
    1512 
    1613<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

    r1052 r1053  
    11<?php 
    22 
    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 
    512 
    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'] = ''; 
    819 
    9 $charset = "UTF-8"; 
    10  
    11 // developers only 
    12 $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 needed 
    34 // {{{ home made login example 
    35 // 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

    r1052 r1053  
    11<?php 
    22 
    3 $strings = array( 
     3$strings += array( 
    44        'root' 
    55        => '开始', 
  • 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; } 
    51table.center { margin-left: auto; margin-right: auto; } 
    62table\-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%; } 
    133 
    144.coverFile { 
     
    6858} 
    6959 
    70 .footnote { text-align: right; font-size: 12px; } 
    7160.error { color: red; } 
  • trunk/htdocs/coverager/coverager.php

    r531 r1053  
    22 
    33include("./common.php"); 
    4  
    5 class Cycle 
    6 { 
    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 } 
    344 
    355class XcacheCoverageViewer 
    366{ 
    37     var $syntaxhiglight = true; 
    38     var $usecache = false; 
     7    var $syntax_higlight = true; 
     8    var $use_cache = false; 
    399    var $include_paths = array(); 
    4010    var $exclude_paths = array(); 
     
    5020        $this->datadir = ini_get('xcache.coveragedump_directory'); 
    5121 
    52         // copy config 
    53         foreach (array('charset', 'include_paths', 'exclude_paths', 'syntaxhiglight', '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]; 
    5626            } 
    5727        } 
     
    7949            $prefix_len = strlen($path) + 1; 
    8050            $dirinfo = $this->loadDir($this->outpath); 
    81             if (!$this->usecache) { 
     51            if (!$this->use_cache) { 
    8252                ksort($dirinfo['subdirs']); 
    8353                ksort($dirinfo['files']); 
     
    10474                } 
    10575            } 
    106             if ($this->syntaxhiglight) { 
     76            if ($this->syntax_higlight) { 
    10777                $source = implode('', $lines); 
    10878                ob_start(); 
     
    130100        else if (!$this->datadir) { 
    131101            $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'; 
    133103        } 
    134104        else { 
     
    137107        } 
    138108 
    139         $xcache_version = defined('XCACHE_VERSION') ? XCACHE_VERSION : ''; 
     109        global $config; 
    140110        include("coverager.tpl.php"); 
    141111    } 
     
    143113    function loadDir($outdir, $addtodo = null) 
    144114    { 
    145         if ($this->usecache) { 
     115        if ($this->use_cache) { 
    146116            $cachefile = $outdir . "/.pcovcache"; 
    147117            if (file_exists($cachefile)) { 
     
    210180        } 
    211181 
    212         if ($this->usecache) { 
     182        if ($this->use_cache) { 
    213183            ksort($subdirs); 
    214184            ksort($files); 
     
    223193                ); 
    224194 
    225         if ($this->usecache) { 
     195        if ($this->use_cache) { 
    226196            $fp = fopen($cachefile, "wb"); 
    227197            fwrite($fp, serialize($info)); 
     
    233203    function loadFile($file) 
    234204    { 
    235         if ($this->usecache) { 
     205        if ($this->use_cache) { 
    236206            $cachefile = $file . "cache"; 
    237207            if (file_exists($cachefile)) { 
     
    243213        unset($info['cov']); 
    244214 
    245         if ($this->usecache) { 
     215        if ($this->use_cache) { 
    246216            $fp = fopen($cachefile, "wb"); 
    247217            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"; ?> 
    172 
    183<?php 
     
    5035    global $cycle; 
    5136    $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"); 
    5742    return <<<EOS 
    5843<div class="table-center"> 
     
    11499    global $cycle; 
    115100    $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"); 
    120105    return <<<EOS 
    121106<div class="center-table"> 
     
    168153} 
    169154 
    170 $l_root = _T("root"); 
     155$l_root = _("root"); 
    171156if ($action == 'dir') { 
    172157    if (function_exists('ob_filter_path_nicer')) { 
     
    246231?> 
    247232 
    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 
Note: See TracChangeset for help on using the changeset viewer.