![]() |
PHP to convert phpBB links to vB links?
I am working on converting my phpBB forum to vB. I am using the official Impex importer, but one feature it lacks is converting internal phpBB forum links within posts to point to the correct imported vB thread.
I have searched and posted on the official forum, but it's one of those often features that always seems to be "coming soon". Anyway, I'm open to any suggestions as an effective method to covert the links with a PHP script. I'm also hoping I might hear from someone who has already done this and might be willing to share. There must be a few people out there who have successfully converted phpBB links to vb. phpBB links are in the following format: http://www.domain.com/forum/viewtopic.php?t=10820 http://www.domain.com/forum/viewtopic.php?p=72155#72155 the vBulletin equivalents: http://www.domain.com/forum/showthread.php?t=13511 http://www.domain.com/forum/showthre...8246#post48246 phpBB table: phpbb_posts phpBB fields: post_id, topic_id phpBB table: phpbb_posts_text phpBB fields: post_id, post_text vBulletin table: vb3_post vBulletin fields: postid, threadid, pagetext, importthreadid, importpostid So, I guess I need to: search each vb3_post : pagetext for occurances of http://www.domain.com/forum/viewtopic.php?p=n#n then return the new $replace=vb3_post : postid where importpostid=n then write the replacement over the old link http://www.domain.com/forum/showthread.php?p=$replace#post$replace and also search each vb3_post : pagetext for occurances of http://www.domain.com/forum/viewtopic.php?t=n then return the new $replace=vb3_post : threadid where importthreadid=n then write the replacement over the old link http://www.domain.com/forum/showthread.php?t=$replace then after all links are replaced, overwrite the vb3_post : pagetext entry in the database Any pointers? I appreciate any help you can offer. |
This can be done, but it is not as easy as it seems.
|
I'd suggest leaving the db alone and writing a new viewtopic.php file with these contents, turning it into a simple redirecting file.
PHP Code:
|
That will not work since the thread/postid's have changed.
|
On second thought, you could use the ol id, to query the ompirt_id column, then redirect to the new id.
|
Thanks for the suggestions. I have seen the alternate viewtopic.php idea mentioned on the official forums and given the "invalidates your support" official response. Of course, doing a search and replace on the posts probably invalidates support too.
I have had some luck throwing together a script to rewrite my old image gallery links in posts, so I'll try a few tests with something like this and see if I can get anywhere with it. |
Quote:
|
Quote:
|
Maybe something like (using michael's code, no coffee yet, so this is not bugfree, but you'll get the idea:
PHP Code:
|
Thanks again guys. :D Here's the code that is working on my test server:
Code:
<?php Thanks to you guys, I can keep my old links working. This should tide me over until I (or Jelsoft) come up with a solid script to replace the old links in the database. |
Jelsoft will never make it i think, because there are too many (not only phpBB) variations.
PS You should remove connecting to the database, and start with a require_once of global.php. That will setup your connection in a secure way. Also change the database functions to vB onces. |
Well, I've got a rough, ROUGH version of a script to rewrite topic links in the database (no post links yet). This is cobbled together from my image link re-writing script which was equally shabby. Obviously, I don't really know what I am doing, but I pick up what I can from Google and work things out with lots of trial and error.
Anyway, this is basically working on my test server database. It searches for any post with a link pointing to an old forum topic, then counts the number of links within a post. Then it splits the post into segments for each link and fills an array with replacement links, then puts in a placeholder for already replaced links. After processing all the segments, it fills in all the placeholders with replacements and writes the updated post to the database. Code:
<?php Code:
POSTID:8761, NUMBER OF LINKS:3 I apologize for the state of the code. :o |
Tips in my previous post are still valid.
|
I don't know how much further I'll go with these. They're still very sloppy, but the output is "good enough" for my needs (and considering my lack of skills). Anyway, I'm posting these in the hope that maybe this will inspire someone to write a proper conversion script someday. ;)
I have made a second script copied from the first that fixes the the "p=" post links. The main difference is an additional check for '#' in the link. Running on a local test server, I have used these to update my full database (several thousand links updated within a few hundred thousand posts). imported post link converter (viewtopic.php?=p): PHP Code:
PHP Code:
|
Replace:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
All times are GMT. The time now is 06:52 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|