OK... but please please PLEASE backup your database before running this. I'm a builder, so my PHP skills are rudimentary at best. The script did run fine on my 2.2.6 vB.
Here's the code... just put it anywhere on your server and run it.
BACKUP YOUR DATABASE FIRST. This hasn't been tested anywhere other than on my solitary box. Your database is YOUR responsibility.
PHP Code:
<?
connectToDB();
$result=mysql_query("SELECT * FROM post WHERE pagetext LIKE '%[quote=%'");
while ($myrow=mysql_fetch_array($result)) {
$temp="";
echo "<b>Found [quote= in post id ".$myrow["postid"]."</b><br>\n";
$post_string=$myrow["pagetext"];
$post_string=str_replace("[/quote]","[/B][/QUOTE]",$post_string);
while(substr_count($post_string,"[quote=\"")) {
$position=strpos($post_string,"[quote=\"");
$temp[]=substr($post_string,0,$position+6);
$temp[]="][i]Originally posted by ";
$post_string=substr($post_string,$position+8,strlen($post_string));
$temp[]=substr($post_string,0,strpos($post_string,"\""))." [/i]".chr(13).chr(10)."[B]";
$post_string=substr($post_string,strpos($post_string,"\"")+2,strlen($post_string)-(strpos($post_string,"\"")+2));
}
$temp[]=$post_string;
$new_post_string=implode("",$temp);
$new_post_string=addslashes($new_post_string);
$update_query="UPDATE post SET pagetext='$new_post_string' WHERE postid=".$myrow["postid"];
$update_result=mysql_query($update_query);
if(!$update_result)
die("Couldn't update: ".mysql_error())."<br><br>";
echo "Post updated successfully... <p>";
}
echo "SCRIPT COMPLETED";
function connectToDB()
{
$link=mysql_connect("dbserver","username","password");
if(!$link)
die("Couldn't connect to MySQL");
mysql_select_db("dbname",$link)
or die ("Couldn't open forum: ".mysql_error());
}
?>
Obviously change the database information in the connectToDB function, including the dbname in the mysql_select_db statement.
Hope it works OK.
Cheers
Z