MyBB Community Forums

Full Version: redirection to bad url: a bug ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Thank you Dylan, I'm happy if my report was useful.

But do you think the HTTP_PROTO change in the code will be implemented in future updates ?

Bye,
Diab
(2011-01-28, 04:50 PM)Dylan M. Wrote: [ -> ]
(2011-01-28, 03:23 PM)Diabolik Wrote: [ -> ]
(2011-01-28, 10:00 AM)Disturbed Wrote: [ -> ]In global.php below the require init.php :
if($_SERVER['HTTPS'] == on){
$settings['bburl'] = "https://domain.com";
}
else 
{
$settings['bburl'] = "http://domain.com";
}

Ummhhh... I'm not convinced about it, because in inc/settings.php, the parameter $settings['bburl'] is correctly configured to "https://my.web.site" via AdminCP/Configuration/General settings.

(2011-01-28, 11:22 AM)frostschutz Wrote: [ -> ]
        $url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

Hi frostschutz,
this resolved the issue, thanks !

I think this is a sort of "conceptual" bug, because cabling the protocol http:// in the php code cancels the flexibility given by using the setting $settings['bburl'], configurable via AdminCP.

Bye,
Diabolik

This is a bug actually. The code should be detecting which protocol to use, and using it dynamically.
All instances of hardcoded http:// protocol should be replaced by HTTP_PROTO (which we would need to set in init.php), so using the above example:
$url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
Would become:
$url = htmlspecialchars_uni(HTTP_PROTO.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

And in init.php we have:
// Fix for people who for some specify a trailing slash on the board URL
if(substr($settings['bburl'], -1) == "/")
{
	$settings['bburl'] = my_substr($settings['bburl'], 0, -1);
}
And we would change that to:
// Fix for people who for some specify a trailing slash on the board URL
if(substr($settings['bburl'], -1) == "/")
{
	$settings['bburl'] = my_substr($settings['bburl'], 0, -1);
}

if(substr($settings['bburl'], 0, 5) == "https")
{
	define("HTTP_PROTO", "https");
}
else
{
	define("HTTP_PROTO", "http");
}

There is a bug here as you are lacking "://" also this does not fix many of the static http:// calls. Whats wrong with using relative paths instead of absolutes everywhere?
Pages: 1 2