.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > Shrapnel Community > Shrapnel General

Reply
 
Thread Tools Display Modes
  #1  
Old August 16th, 2008, 08:18 PM
Richard's Avatar

Richard Richard is offline
Brigadier General
 
Join Date: Dec 1999
Location: Lancaster, OH 43130
Posts: 1,997
Thanks: 5
Thanked 9 Times in 8 Posts
Richard is on a distinguished road
Default Re: Automated redirect for old post/thread links

Quote:
Originally Posted by Fyron View Post
Out of curiosity, why where the old ID values not simply preserved, and inserted into the vbulletin database? That would have made supporting the old link namespace a simple mod_rewrite rule.
The vb import process tries to do things in a very clean way and because of that assigns a new post id/thread id starting at zero. It does preserve a concept of an import ID. I had written something to update all of the postID/threadID's to the old numbers but the one sticking point was threaded mode. Due to the way the parent/child post setup in vb works there was no easy way via sql to update the posts without breaking the parent posts used for threaded mode.

So instead I took some code from the vb import author and extended it a little.
Reply With Quote
  #2  
Old August 16th, 2008, 08:44 PM
Ballbarian's Avatar

Ballbarian Ballbarian is offline
Colonel
 
Join Date: May 2005
Location: Kansas, USA
Posts: 1,538
Thanks: 289
Thanked 194 Times in 94 Posts
Ballbarian will become famous soon enough
Default Re: Automated redirect for old post/thread links

I am not sure if this is what you are looking for, but I pulled these links from one of my threads:

THREADS - appear to be working
http://www.shrapnelcommunity.com/thr...b=5&o=&fpart=1
http://www.shrapnelcommunity.com/thr...&Number=528292

FILES - not found
http://www.shrapnelcommunity.com/thr...?Number=580660
http://www.shrapnelcommunity.com/thr...?Number=585712
http://www.shrapnelcommunity.com/thr...?Number=591882
http://www.shrapnelcommunity.com/thr...?Number=592318
http://www.shrapnelcommunity.com/thr...?Number=614035
http://www.shrapnelcommunity.com/thr...?Number=629537
http://www.shrapnelcommunity.com/thr...?Number=632163
__________________
RanDom v2 - Map gen & Semirandomizer.
Province Editor - Custom province creation made easier.
God Editor - Custom pretender creation made easier.
Map Forge - Map editor
Reply With Quote
  #3  
Old August 16th, 2008, 08:49 PM
Ballbarian's Avatar

Ballbarian Ballbarian is offline
Colonel
 
Join Date: May 2005
Location: Kansas, USA
Posts: 1,538
Thanks: 289
Thanked 194 Times in 94 Posts
Ballbarian will become famous soon enough
Default Re: Automated redirect for old post/thread links

This old image link is not working either:
http://www.shrapnelcommunity.com/thr...73-AomOrc3.JPG

Edit:
And here is an old link that used to go to the dom3 forums that gives me a permissions error instead of the page not found:
http://www.shrapnelcommunity.com/thr...at=&Board=dom3
__________________
RanDom v2 - Map gen & Semirandomizer.
Province Editor - Custom province creation made easier.
God Editor - Custom pretender creation made easier.
Map Forge - Map editor

Last edited by Ballbarian; August 16th, 2008 at 08:53 PM..
Reply With Quote
  #4  
Old August 17th, 2008, 05:34 PM
Richard's Avatar

Richard Richard is offline
Brigadier General
 
Join Date: Dec 1999
Location: Lancaster, OH 43130
Posts: 1,997
Thanks: 5
Thanked 9 Times in 8 Posts
Richard is on a distinguished road
Default Re: Automated redirect for old post/thread links

Quote:
Originally Posted by Ballbarian View Post
This old image link is not working either:
http://www.shrapnelcommunity.com/thr...73-AomOrc3.JPG

Edit:
And here is an old link that used to go to the dom3 forums that gives me a permissions error instead of the page not found:
http://www.shrapnelcommunity.com/thr...at=&Board=dom3
Okay all old uploads should redirect now so #1 should work. For #2 what I did is anything with postlist.php goes to a generic page on the new forum. Since we have no way to determine what the old crappy (editorial comment on UBB software ) word based forum names to the new forum numbers we can't do a better automated solution...
__________________
Change is inevitable, how you handle change is controllable - J. Strong
Reply With Quote
The Following User Says Thank You to Richard For This Useful Post:
  #5  
Old August 17th, 2008, 05:21 PM
Richard's Avatar

Richard Richard is offline
Brigadier General
 
Join Date: Dec 1999
Location: Lancaster, OH 43130
Posts: 1,997
Thanks: 5
Thanked 9 Times in 8 Posts
Richard is on a distinguished road
Default Re: Automated redirect for old post/thread links

Okay all of these should work now. Let me know...
__________________
Change is inevitable, how you handle change is controllable - J. Strong
Reply With Quote
The Following User Says Thank You to Richard For This Useful Post:
  #6  
Old August 17th, 2008, 05:55 PM
Ballbarian's Avatar

Ballbarian Ballbarian is offline
Colonel
 
Join Date: May 2005
Location: Kansas, USA
Posts: 1,538
Thanks: 289
Thanked 194 Times in 94 Posts
Ballbarian will become famous soon enough
Default Re: Automated redirect for old post/thread links

Quote:
Originally Posted by Richard View Post
Okay all of these should work now. Let me know...
Great!

All appear to be working now with one exception:
http://www.shrapnelcommunity.com/thr...&Number=528292

That old thread link was working with some of your changes (earlier), but now goes to the 404 page.
__________________
RanDom v2 - Map gen & Semirandomizer.
Province Editor - Custom province creation made easier.
God Editor - Custom pretender creation made easier.
Map Forge - Map editor
Reply With Quote
  #7  
Old August 17th, 2008, 06:26 PM
Richard's Avatar

Richard Richard is offline
Brigadier General
 
Join Date: Dec 1999
Location: Lancaster, OH 43130
Posts: 1,997
Thanks: 5
Thanked 9 Times in 8 Posts
Richard is on a distinguished road
Default Re: Automated redirect for old post/thread links

Quote:
Originally Posted by Ballbarian View Post
Great!

All appear to be working now with one exception:
http://www.shrapnelcommunity.com/thr...&Number=528292

That old thread link was working with some of your changes (earlier), but now goes to the 404 page.
Okay this one may be able to be fixed but I am not sure. The problem is most incoming links have an & after the post number and the redirect is looking for that. These types of url's don't have an & at the end so it's confused . Let me think on that one...
__________________
Change is inevitable, how you handle change is controllable - J. Strong
Reply With Quote
  #8  
Old August 18th, 2008, 10:26 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default Re: Automated redirect for old post/thread links

Richard, thanks for looking into this. I'd recommend that you create substitutes for the old showflat.php, shownested.php etc. scripts instead of abusing 404 error pages for this.

I'll drop some PHP code here which I have been using for some projects myself. First, a replacement for PHP's parse_url function:
PHP Code:
// returns an array with the following elements defined in it:
//   scheme://username:password@host:port/path?query#fragment
// this function is more robust than parse_url

function parseUrl($url) {
  
$r  '!(?:(?<scheme>\w+)://)?(?:(?<username>\w+)\:(?<password>\w+)@)?(?<host>[^/:]+)?';
  
$r .= '(?:\:(?<port>\d*))?(?<path>[^#?]+)?(?:\?(?<query>[^#]+))?(?:#(?<fragment>.+$))?!i';
  
preg_match($r$url$out);
#  for ($i = 0; $i < 9; ++$i)
#    unset($out[$i]);
  
return $out;

then one which does the reverse:
PHP Code:
// inverse function to parseUrl

function glueUrl($parsed)
{
  if (!
is_array($parsed)) return false;
  
$uri strlen($parsed['scheme']) ? $parsed['scheme'].':'.((strtolower($parsed['scheme']) == 'mailto') ? '' '//') : '';
  
$uri .= strlen($parsed['user']) ? $parsed['user'].(strlen($parsed['pass']) ? ':'.$parsed['pass'] : '').'@' '';
  
$uri .= strlen($parsed['host']) ? $parsed['host'] : '';
  
$uri .= strlen($parsed['port']) ? ':'.$parsed['port'] : '';
  if (
strlen($parsed['path'])) {
    
$uri .= ($parsed['path'][0] == '/') ? $parsed['path'] : ('/'.$parsed['path']);
  }
  
$uri .= strlen($parsed['query']) ? '?'.$parsed['query'] : '';
  
$uri .= strlen($parsed['fragment']) ? '#'.$parsed['fragment'] : '';
  return 
$uri;

and finally something which uses both to merge a given URL with a query string, which shows how they can be used:
PHP Code:
// merges given URL with the specified query string

function MergeQueryStrings($url$query) {
  
$parsed parseUrl($url);
  
parse_str($query$addq);
  
parse_str($parsed['query'], $oldq);
  
$newq array_merge($oldq$addq);
  
$parsed['query'] = http_build_query($newq);
  return 
glueUrl($parsed);

Maybe it's some help. What you really should make use of is the parse_str function.
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:58 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.