FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Converters » Changing old forum URLs in all messages
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Changing old forum URLs in all messages [message #22528 is a reply to message #22523] Sun, 06 February 2005 12:03 Go to previous messageGo to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma:
Senior Member
Administrator
Core Developer
Final code as requested:

<?php
// Seach all messages for a string and replace with another

$seachfor    = "Frank";
$replacewith = "FRANK";

set_time_limit(-1);
ini_set('memory_limit', '128M');

include("./GLOBALS.php");
include("./FUDdata/scripts/fudapi.inc.php");

fud_use('smiley.inc');
fud_use('rev_fmt.inc');
fud_use('replace.inc');
fud_use('post_proc.inc');

$c = q("SELECT * FROM ${DBHOST_TBL_PREFIX}msg");
while ($r = db_rowobj($c)) {
  echo "ID=[" . $r->id . "], FORUM=[" . $r->thread_id . "], POSTER=[" . $r->poster_id . "], SUBJECT=[" . $r->subject . "]<br/>\n";

  $fp = fopen($GLOBALS['MSG_STORE_DIR'].'msg_'.$r->file_id, 'rb');
  fseek($fp, $r->foff);
  $body = fread($fp, $r->length);

  $body = post_to_smiley($body);
  $body = html_to_tags($body);
  $body = apply_reverse_replace($body);

  if (($p = strpos($body, $seachfor)) !== false) {
    echo "OLD BODY=[" . $body . "]<hr>\n";
    $body = str_replace($seachfor, $replacewith, $body);
    echo "NEW BODY=[" . $body . "]<hr>\n";
    fud_update_message($r->subject, $body, 0, $r->poster_id, $r->id);
  }
}
?>


Best regards.

Frank
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Preparing for final conversion: reset the DB
Next Topic: Subscribe users to topics/ forums
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 19:19:27 GMT 2024

Total time taken to generate the page: 0.04008 seconds