CodeIgniter Forums
BUG - Base_url not being set properly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: BUG - Base_url not being set properly (/showthread.php?tid=57086)



BUG - Base_url not being set properly - El Forum - 02-13-2013

[eluser]maltzurra[/eluser]
First things first. I'm on vacation away from my computer so I can't use Github. Sorry for that. This should be fixed straight in Github.

The bug happens when base_url is not set. This is the code from Config.php library (now in Common.php as is_https() function).

Code:
function is_https() {
     return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off');
}

The function is poorly written: whitelist > blacklist FTW! If $_SERVER['HTTPS'] value is "0" or "NULL", it will be set as HTTPS. And it happens depending on the hosting. That's obviously not correct.

Instead, it should be:

Code:
function is_https() {
     return (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) === 'on');
}

This way, you can assure HTTPS is ON.

PS: Sorry again for not using Github myself. Would be great if someone could do it himself.

Thanks for your time,
Regards,
Maltz.