PDA

View Full Version : Mass Editing of posts question


wraggster
01-06-2014, 03:07 PM
I found a thread over at Vbulletin.com (http://www.vbulletin.com/forum/forum/vbulletin-4/vbulletin-4-questions-problems-and-troubleshooting/412135-query-to-mass-edit-spam-posts) which seems to be something that im looking for basically i want to change all the links in posts on my forum to a new url, replacement variable manager does work mostly but because i grab feeds from our news forums the news forums dont take the replaced variables with it. so on the thread linked above, theres this snippet of code which was used to make a plugin

if($thread['postuserid'] == '1') {
$find = array(
'________'
);

$replace = array(
''
);

$this->post['message'] = str_replace($find, $replace, $this->post['message']);
}

could this code be changed so that i can replace on any thread and instead of replacing _____, could i use it to replace www.oldurl.com with www.newurl.com ?

Is this doable?

--------------- Added 1389025772 at 1389025772 ---------------

so would this work

if($thread['postuserid'] == '1') {
$find = array(
'www.oldurl.com'
);

$replace = array(
'www.newurl.com'
);

$this->post['message'] = str_replace($find, $replace, $this->post['message']);
}

Still unsure how to make it effect all threads

kh99
01-06-2014, 04:42 PM
It sounds to me like you might want to use SQL to permanently change the post text in the database rather than to use a plugin to change it only when it's displayed.

Maybe something like:
UPDATE post SET pagetext = REPLACE(pagetext, 'www.oldurl.com', 'www.newurl.com') WHERE pagetext LIKE '%www.oldurl.com%'


But doing things like this is a little dangerous. You'd want to back up your database first, or maybe even get someone else to do it if you don't feel comfotable with it.