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 <br>
#_Author : Nig3h<br>
<br>--------------------------------------------------------
<br>
<form action="" method="POST" name="Submit"> 
<b>Host: </b>   <input type="text" name="host" value="127.0.0.1:3306"><br>
<b> User: </b>   <input type="text" name="user" value="root"><br>
<b> Password: </b>   <input type="text" name="pass" value="root"><br>
<b>Database Check: </b>   <input type="text" name="database" value="phpwms">
<b> Tables is: </b>   <input type="text" name="table" value="pw_admin"><br>
<b>New_Data Filename:</b>   <input type="text" name="back_file" value="data.txt">
<br>
<br>  
<a href = "http://xiaosan.cnblogs.com">Http://hExIe>>WWW.0rG</a><br><br>
<input type="submit" name="submit" value="0utPut">   <br>  
</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">[+]&nbsp'.$Str.'</font><br>';
    else
		echo '<font color="red" face="verdana" size="2px">[#] '.$Str.'</font><br>'; 
 }

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>
posted @ 2011-06-03 07:44 學習 阅读(75952) 评论(3) 编辑 收藏

 回复 引用 查看   
#1楼 2011-06-03 08:36 Jackin      
大哥! 那什么是不脱裤啊!
 回复 引用 查看   
#2楼 2011-06-03 11:57 LitIce      
谢谢分享~作为初学者~需要很多很多的代码例子来看。
提个建议,贴代码用后面一种好么?这种格式复制下来换行符全部没有掉了

 回复 引用 查看   
#3楼[楼主] 2011-06-28 00:22 cn_hyrz      
引用LitIce:
谢谢分享~作为初学者~需要很多很多的代码例子来看。
提个建议,贴代码用后面一种好么?这种格式复制下来换行符全部没有掉了


oh~确实这样,刚开始没明白你的意思。后面自己从上面把代码拷下来才发现的,我会试着用另外一种形式。