vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Fix a redirect URL (https://vborg.vbsupport.ru/showthread.php?t=104368)

Immortal 01-03-2006 09:00 PM

Fix a redirect URL
 
Hello everyone,

I've used preg_match_all to replace all of my URLs to be more SEO friendly. However, I tried to use preg_match_all (global_complete hook) for redirects such as showthread.php?p=id#postid and search.php?searchid=id however it does not want to cooperate since they are "redirects" and not URLs...I've tried using the following code.

PHP Code:

$found preg_match_all('#showthread\.php\?p=([0-9]+)\#post([0-9]+)#i'$output$matches);

if(
$found)
{
    
// Build an array of ID's
    
$ids = array();

    for(
$i 0$i $found$i++)
    {
        if(
is_numeric($matches[1][$i]))
            
$ids[] = $matches[1][$i];
    }
    
$ids implode(','$ids);

    
// Go through each
    
$res $vbulletin->db->query_read("SELECT threadid, postid FROM " TABLE_PREFIX "post WHERE postid IN($ids)");

    while(
$t $vbulletin->db->fetch_array($res))
    {
       
        
$tid $t['threadid'];
        
$pid $t['postid'];
                
$threadinfo $vbulletin->db->query_first("SELECT title, forumid FROM thread WHERE threadid='$tid'");
        
$title urlize($threadinfo['title']);
        
$fid $threadinfo['forumid'];
        
$f fetch_foruminfo($fid); 
        
$fname urlize($f['title']);



        
$output str_replace("showthread.php?p=$pid#post$pid""$fname/p-$title-$pid.html#$pid"$output);
    }




But preg_match_all found nothing. Is there a special way I have to do this or in a different hook then global_complete? I really don't want to modify any files if I can stay away from that. Any help would be greatly appreciated :)

Immortal 01-07-2006 12:21 AM

Just giving this a kind bump up (sorry!). I've also tried to replace the code in case newpost in showthread.php but it's still redirecting. It honestly doesn't matter how it can be done as long as its correct at this point :nervous:

Immortal 01-10-2006 07:58 PM

Okay, I thought I had it, but apprently not. I stuck this code in global_start:

PHP Code:

if(THIS_SCRIPT == 'showthread') {
if(!isset(
$_GET['is_vrewrite'])){

//Let's see if we're doing a thread, or a post.
$threadid $_GET['t'];

if(!empty(
$threadid)) { 
$thread $vbulletin->db->query_first("SELECT title, forumid FROM  " TABLE_PREFIX "thread WHERE threadid='$threadid'");

$title $thread['title'];
$fid $thread['forumid'];
  
$f $vbulletin->forumcache[$fid];
  
$fid $f['forumid'];
  
$ftitle $f['title'];
exec_header_redirect("$ftitle/$title-$threadid.html");

 }

else
{ die(
'we are on a post'); }

 } 


But its redirecting as the forums over and over, but how can that be if its not in a while? :S

yayvb 01-30-2006 11:56 PM

Surprising that no one has any ideas, maybe it's just an impossibility. ;)


All times are GMT. The time now is 08:22 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01527 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete