日期:2015-05-18  浏览次数:8260 次

将下面的内容保存成2.php 上传上网站目录下,访问修改下就可以了
 
 
 <?php
 
/**
 
date:2013-05-12
 
function:批量替换数据库中的联系方式
 
**/
 
header("content-Type: text/html; charset=utf-8");
 
include_once("config.inc.php");
 
if(isset($_GET["act"]) && $_GET["act"] == "del" ){   //删除测试文件
 
$filename=basename($_SERVER['PHP_SELF']);
 
@unlink($filename);
 
exit('Error:File Not Found!');
 
}
 
 
 
if(isset($_POST["submit"])){
 
$host=$dbHost;
 
$user=$dbUser;   //数据库用户名
 
$passwd=$dbPass; //密码
 
$db=$dbName;  //数据库名称
 
 
 
$txt=$_POST["txt"]; //源字符串
 
$plustitle=$_POST["plustitle"]; //目标字符串
 
$plusname=$_POST["plusname"]; //目标字符串
 
$tables=$TablePre._base_plus;
 
$link= mysql_connect($host,$user,$passwd) or die('Could not connect: '.mysql_error() );
 
mysql_select_db( $db,$link ) or die ('can\'t use'. $db . mysql_error());
 
mysql_query ('SET NAMES utf8'); 
 
$sql1="UPDATE `$tables` SET text='$txt' where title='$plustitle' and pluslable='$plusname'";
 
        if(mysql_query($sql1))
 
       echo "<font color=red>替换成功!<br></font>";
 
     else
 
       echo "替换失败:".mysql_error()."<br>";
 
mysql_close($link);
 
}
 
?>
 
<form method="post" action="">
 
 <?
 
 echo "数据库地址:&nbsp".$dbHost ;
 
echo "<br/>数据库名:&nbsp".$dbName;
 
echo "<br/>数据库用户名:&nbsp".$dbUser;
 
echo "<br/>数据库密码:&nbsp".$dbPass;
 
echo "<br/>表前缀:&nbsp".$TablePre;
 
 ?>
 
 <br/>
 
插件标题:<input name="plustitle" value="联系我们" type="txt"><br/>
 
插件名:<input name="plusname" value="modText" type="txt"><br/>
 
替换内容:<textarea name="txt" cols="50" rows="10" warp="virtual"></textarea>&nbsp; <br/>
 
<input type="submit" name="submit" value="开始替换"><br/><br/>
 
<font color=red >操作不可逆,请先备份数据库后再使用</font><br/>
 
<a href='?act=del'>删除测试文件</a>
 
</form>