* @checkedout $Name: $ * @date $Date: 2006/08/15 18:16:05 $ * @copyright http://www.vbulletin.com/license.html * */ /* Ensure you have this table for logging CREATE TABLE `404_actions` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `time` INT UNSIGNED NOT NULL , `incomming` VARCHAR( 250 ) NOT NULL , `outgoing` VARCHAR( 250 ) NOT NULL , `action` TINYINT UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY ( `id` ) ) TYPE = MYISAM ; */ // System #Currently supported : 'phpBB2' 'ubb.threads' $old_system = 'phpBB2'; // Domain // Example :: http://www.example.com/phpBB/ //$old_folder = 'phpBB'; $old_folder = 'foros'; $standard_404 = 'http://www.todopsp.com/foros/'; // The usual 404 that this script replaces // Example :: http://www.example.com/vBulletin/ $new_domain = 'www.todopsp.com'; $new_folder = 'foros'; $ext_type = 'php'; // File extension type that vBulletin is using, i.e. index.php // Database // This is the vBulletin database, needed for import id look up and logging $server = '91.142.209.154'; $user = 'todopsp_demo'; $password = 'control'; $database = 'todopsp_puente'; $tableprefix = 'vbgreat_'; // System $refresh_speed = 0; // Speed of the redirect, 0 advised. $do_logs = true; // Always best to log to see that its working and if there are any "Unknown link type, talk to Jerry" links $do_404 = false; // true = a 404 (Not Found) redirect. false is a 301 search engine friendly redirect (Moved Permanently) ############################################################################################################################# # Don't touch below ############################################################################################################################# $old_id = 0; $action_code = 0; $action = null; $sql = null; // Get the file names and types switch ($old_system) { case 'phpBB2' : $old_forum_script = 'viewforum.php?f='; $old_thread_script = 'viewtopic.php?t='; $old_post_script = "viewtopic.php?p="; $old_user_script = 'profile.php?mode=viewprofile&u='; // Append userid break; case 'ubb.threads' : $old_forum_script = 'postlist.php?'; // postlist.php?Cat=&Board=beadtechniques -- have to try to do it on title $old_thread_script = 'showflat.php?'; // Cat=&Board=beadtechniques&Number=74690&page=0&view=collapsed&sb=5&o=&fpart=1Greg Go for Number=XX $old_post_script = 'showthreaded.php?'; // ubbthreads/showthreaded.php?Cat=&Board=othertopics&Number=79355&page=0&view=collapsed&sb=5&o=&fpart=1 -- going to thread link, not post, meh $old_user_script = 'showprofile.php'; // ubbthreads/showprofile.php?Cat=&User=SaraSally&Board=isgbannounce&what=ubbthreads&page=0&view=collapsed&sb=5&o -- username break; default : // No valid system entered die('No valid system entered'); } // It's for the old forum if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/") === 0) { switch ($old_system) { case 'phpBB2' : // It's a forum link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_forum_script}") === 0) { $action = 'forum'; $sql = "SELECT forumid FROM {$tableprefix}forum WHERE importforumid = " . substr($_SERVER['REDIRECT_QUERY_STRING'], 2, abs(strpos($_SERVER['REDIRECT_QUERY_STRING'], '&',2)-2)); } // It's a thread link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_thread_script}") === 0) { $action = 'thread'; if( preg_match("/&/", $_SERVER['REDIRECT_QUERY_STRING']) ) { $sql = "SELECT threadid FROM {$tableprefix}thread WHERE importthreadid = " . substr(substr($_SERVER['REDIRECT_QUERY_STRING'], 2), 0, strpos(substr($_SERVER['REDIRECT_QUERY_STRING'], 2), '&')); } else { $sql = "SELECT threadid FROM {$tableprefix}thread WHERE importthreadid = " . substr($_SERVER['REDIRECT_QUERY_STRING'], 2); } } if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/about") === 0) { if(preg_match('#(.*)about(.*).html#Uis', $_SERVER['REQUEST_URI'], $matches)) { if (is_numeric($matches[2])) { $action = 'thread'; $sql = "SELECT threadid FROM {$tableprefix}thread WHERE importthreadid=" . $matches[2]; } } } // It's a post link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_post_script}") === 0) { $action = 'post'; if( preg_match("/&/", $_SERVER['REDIRECT_QUERY_STRING']) ) { $sql = "SELECT postid FROM {$tableprefix}post WHERE importpostid = " . substr(substr($_SERVER['REDIRECT_QUERY_STRING'], 2), 0, strpos(substr($_SERVER['REDIRECT_QUERY_STRING'], 2), '&')); } else { $sql = "SELECT postid FROM {$tableprefix}post WHERE importpostid = " . substr($_SERVER['REDIRECT_QUERY_STRING'], 2); } } // It's a user link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_user_script}") === 0) { $action = 'user'; // Cuts 12 out of this : profile.php?mode=viewprofile&u=12&sid=f646e2a0948e0244ba82cef12c3b93d8 $sql = "SELECT userid FROM {$tableprefix}user WHERE importuserid = " . substr(substr($_SERVER['REDIRECT_QUERY_STRING'], 19), 0, strpos(substr($_SERVER['REDIRECT_QUERY_STRING'], 19), '&')); } break; case 'ubb.threads' : // It's a forum link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_forum_script}") === 0) { $action = 'forum'; $sql = "SELECT forumid FROM {$tableprefix}forum WHERE importforumid LIKE " . substr($_SERVER['REDIRECT_QUERY_STRING'], strpos($_SERVER['REDIRECT_QUERY_STRING'], 'Board=')+6); } // It's a thread link (Will get direct post links some times too) if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_thread_script}") === 0) { $action = 'thread'; $begin = strpos ($url, 'Number='); $middle = strpos ($url, '&', $begin); $sql = "SELECT threadid FROM {$tableprefix}thread WHERE importthreadid = " . substr($url, $begin+7, ($middle-$begin)-7); // +7 & -7 To remove the off set of Number= } // It's a post link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_post_script}") === 0) { if(preg_match('#(.*)Number=(.*)&(.*)#Uis', $text, $matches)) { if (is_int($matches[2])) { $action = 'post'; $sql = "SELECT postid FROM {$tableprefix}post WHERE importpostid = " . $matches[2]; } } } // It's a user link if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}/{$old_user_script}") === 0) { if(preg_match('#(.*)User=(.*)&(.*)#Uis', $text, $matches)) { if (is_string($matches[2])) { $action = 'post'; $sql = "SELECT userid FROM {$tableprefix}user WHERE importpostid = " . $matches[2]; } } } break; default : // No valid system entered die('No valid system entered'); } if (!$action) { $action = 'log'; } } if (!$action) { ?>