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