Thread: phpBB2 Importer
View Single Post
  #91  
Old 07-27-2002, 12:11 AM
ZenithRS ZenithRS is offline
 
Join Date: Jul 2002
Location: Canberra, Australia
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01091 seconds
  • Memory Usage 1,772KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete