复制代码代码如下:
Mysql Database on Tables to Txt...
#_E-mail:go_root#Hotmail.com
#_Author:HYrz
--------------------------------------------------------
ini_set('display_errors', 1);
set_time_limit(0);
//error_reporting(E_ALL);
function ShowMessage($Str)
{
$FILENAME = $_SERVER["PHP_SELF"];
Die('');
Die('');
}
function _Printf($Str, $type = '')
{
if (empty($type))
echo '[+] '.$Str.'
';
else
echo '[#] '.$Str.'
';
}
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('[#] connect Error ! ');
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("Msg : OutPut_Succ!");}else
_Printf("Err : output fail !"); //endPri
?>