Old hyperlinks won't work

Discussion about the project in general, organization, website, or any other details that aren't directly about the game.
Post Reply
Message
Author
User avatar
utilae
Cosmic Dragon
Posts: 2175
Joined: Fri Jun 27, 2003 12:37 am
Location: Auckland, New Zealand

Old hyperlinks won't work

#1 Post by utilae »

Heaps of people have hyperlinks in their posts. It seems since they link to the old forum they don't work.

Tyreth
FreeOrion Lead Emeritus
Posts: 885
Joined: Thu Jun 26, 2003 6:23 am
Location: Australia

#2 Post by Tyreth »


Daveybaby
Small Juggernaut
Posts: 724
Joined: Mon Sep 01, 2003 11:07 am
Location: Hastings, UK

#3 Post by Daveybaby »

Hmmm.... if you did a backup of the forum database, would it be possible to do a global search & replace of artcluster.com/bb. with freeorion.org/forum/ and then re-upload???

Or is the data not in a text searchable format?

I assume that the topic/post IDs would remain valid...
The COW Project : You have a spy in your midst.

Tyreth
FreeOrion Lead Emeritus
Posts: 885
Joined: Thu Jun 26, 2003 6:23 am
Location: Australia

#4 Post by Tyreth »

It might be possible to issue an SQL 'UPDATE' command in the mysql console, I'll look into that.

Moriarty
Dyson Forest
Posts: 205
Joined: Thu Aug 14, 2003 4:50 pm
Location: United Kingdom of Great Britain and Northern Ireland

#5 Post by Moriarty »

Hmmm, i don't think it can be done with MySQL, as i don't believe MySQL allows u to use Update in conjunction with REGEXP.

The following PHP script will however do the job for you.

Code: Select all

<?php

//connect to DB.
$database_link = mysql_connect("localhost", "ENTER USERNAME", "ENTER PASS");
mysql_select_db("phpBB", $database_link);


$num_changed = 0;

$db_func_query = mysql_query("select post_text, post_id from phpbb_posts_text") or die(mysql_error());

//db("select post_text, post_id from phpbb_posts_text");
while($results = mysql_fetch_array($db_func_query)){
	if(preg_match("/artclusta\.com\/bb/i", $results['text']) != 0){
		mysql_query("update phpbb_posts_text set post_text = '".preg_replace("/artclusta\.com\/bb/i", "freeorion.org/forum", $results['post_text'])."' where post_id = '$results[post_id]'", $database_link);
		$num_changed++;
	}
}

echo $num_changed." links updated";
?>

U can run that as a stand alone script. Might take a few seconds with 11000 posts to go through though. :)

Note: you will need to change the login details for your database, and you will also need to change the
mysql_select_db("phpBB", $database_link);

phpBB part of the above, to whatever the database name is.

Should all work after that.
Should. :)

Any problems, just let me know. 8)

Post Reply