Easily updating links in forums, wikis and sites

1 post • Page 1 of 1

Denyer
Yesterday's model

User avatar

Posts: 2146
Joined: Tue Oct 17, 2000 11:00 pm

Over Pompous Autobot Commander

More Top

Details will vary slightly depending on the structure of your web application, so here's a generic version using MySQL:

Code: Select all
UPDATE nameoftable SET nameoftextfield = replace(nameoftextfield ,'[url]http://transfans.net','[url]http://transfans.co.uk');
UPDATE nameoftable SET nameoftextfield = replace(nameoftextfield ,'[url=http://transfans.net','[url=http://transfans.co.uk');


In vBulletin, as an example, it's probably the "post" table and the "pagetext" field. Since vB caches the contents of posts for speed, you'd also want to run 'Rebuild Post Cache' under Admin CP > Maintenance > Update Counters, and other forum systems may have similar functionality.

It's also possible to change lots of files easily if you have a flat-file wiki (or other situations where lots of files stored together want updating) -- this is one way of doing so using PHP:

Code: Select all
<?
$files=glob("*.txt");
foreach ($files as $file) {
$data=file_get_contents($file); echo "Opening ".$file;
$edit=str_replace("transfans.net","transfans.co.uk",$data);
if ($data!=$edit) { file_put_contents($file,$edit); echo " ... changes made<br>"; }
echo " ... done<br>";
}
?>


Any questions, ask away. I'm not a guru at scripting either of the above technologies, but this isn't a complicated topic.
 

Return to Website Info and Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron