Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-09-2008, 04:46 PM
Karri's Avatar
Karri Karri is offline
 
Join Date: Feb 2002
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $vbulletin->options['bburl'] questions

I am kind of a novice at writing plugins so bare with me.

I wrote a plugin to change the value of $vbulletin->options['bburl'] to match the url the user was using to visit my site. Basically I made a plugin on the hook global_setup_complete with the code
PHP Code:
$vbulletin->options['bburl'] = $_SERVER['HTTP_HOST']; 
This works great some places except for it not including the http:// but other places it makes a mess. For example in the lost password screen where it says
Quote:
You have entered an invalid username or password. Please press the back button, enter the correct details and try again. Don't forget that the password is case sensitive. Forgotten your password? Click here!
The url of the here is http://mysiteurl/mysiteurl/login.php?do=lostpw It seems to duplicate the url in some places and not others. Any one have any idea why it does this and how I can fix it?

Thanks!!!
Reply With Quote
  #2  
Old 07-09-2008, 05:16 PM
sockwater's Avatar
sockwater sockwater is offline
 
Join Date: Apr 2008
Posts: 187
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Add the full URL:
PHP Code:
$vbulletin->options['bburl'] = 'http://' $_SERVER['HTTP_HOST'] . '/path/to/forums'// no trailing slash 
Reply With Quote
  #3  
Old 07-09-2008, 05:37 PM
calorie calorie is offline
 
Join Date: May 2003
Posts: 2,804
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And try the init_startup or global_start hook instead.
Reply With Quote
  #4  
Old 07-09-2008, 05:43 PM
Karri's Avatar
Karri Karri is offline
 
Join Date: Feb 2002
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You guys rock!!!!

My forum is in the root dir so I changed it to

PHP Code:
$vbulletin->options['bburl'] = 'http://' $_SERVER['HTTP_HOST'] ; // no trailing slash 
and changed the hook location and that seemed to fix it.

Thanks for the assistance!!!!
Reply With Quote
  #5  
Old 07-10-2008, 05:15 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There may be a possibility of XSS there. HTTP_HOST can be spoofed by the browser using the "Host" header. Since 'bburl' is used in the display of the pages, it will print right out into the source code.
Reply With Quote
  #6  
Old 07-10-2008, 02:08 PM
Karri's Avatar
Karri Karri is offline
 
Join Date: Feb 2002
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hmm. Do you have any suggestions on how to get the url the user is visiting from to show up where the bburl value instead of the one that is hard coded into the admincp?

Maybe a series of if then statements in the plugin? If the http_host =url1 then bburl=preset url 1?
Reply With Quote
  #7  
Old 07-10-2008, 02:17 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
switch ($_SERVER['HTTP_HOST'])
{
    case 
'somedomain.com':
        
$vbulletin->options['bburl'] = 'http://somedomain.com';
        break;
    case 
'mywebsite.com':
        
$vbulletin->options['bburl'] = 'http://mywebsite.com';
        break;
    default:
        
$vbulletin->options['bburl'] = 'http://website.com';
        break;

Reply With Quote
  #8  
Old 07-10-2008, 02:30 PM
Karri's Avatar
Karri Karri is offline
 
Join Date: Feb 2002
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No luck. When I try to save the plugin with that code it says "In order to accept POST request originating from this domain, the admin must add this domain to the whitelist."
Reply With Quote
  #9  
Old 07-10-2008, 02:34 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's not an error with the plugin, that's an error from vBulletin itself. The error speaks for itself.
Reply With Quote
  #10  
Old 07-10-2008, 02:40 PM
Karri's Avatar
Karri Karri is offline
 
Join Date: Feb 2002
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are right, right after I posted that I restarted my browsers and everything is working again. I must have had some bad code in there or something from other attempts at re-writing the plugin my self.

Thanks for the help!!! I think that will accomplish exactly what I was looking for and much cleaner than any code I was attempting to create.
Reply With Quote
Reply


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 Off

Forum Jump


All times are GMT. The time now is 02:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04180 seconds
  • Memory Usage 2,259KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete