[SOLVED] Mixed content issue on stylesheet

wiz
Admin
Posts: 496
Joined: Sat Oct 30, 2010 12:23 am

Re: Mixed content issue on stylesheet

Post by wiz »

We're actually using HTTP_X_FORWARDED_PROTO in the Apache htaccess configuration for WonderCMS (also called "better security mode", which works on Apache only), it's the FRONT END HTTPS that was a total new thing to me.

Can you please give this a spin?
Included HTTP_X_FORWARDED_PROTO check and added multiple strtolower checks, as some servers may return "On" instead of "on", HTTPS instead of https, etc.

New modified fix (based on your fix):

Code: Select all

return 'http' . ((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS'] == 'on')) || (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS'] == 'on')) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']) . ((dirname($_SERVER['SCRIPT_NAME']) == '/') ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $location;
For comparison, your fix:

Code: Select all

return 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && $_SERVER['HTTP_FRONT_END_HTTPS'] == 'on') ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']) . ((dirname($_SERVER['SCRIPT_NAME']) == '/') ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $location;
And the last comparison, the original (currently in use in 2.5.1):

Code: Select all

return 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ((($_SERVER['SERVER_PORT'] == '80') || ($_SERVER['SERVER_PORT'] == '443')) ? '' : ':' . $_SERVER['SERVER_PORT']) . ((dirname($_SERVER['SCRIPT_NAME']) == '/') ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $location;
Since the above looks like something that will be included in the next version of WonderCMS, would you mind sharing your first name / last name + website link, so it can be included in the special contributors page (https://wondercms.com/special-contributors) and the release notes (https://wondercms.com/whatsnew)?
snathan99
Posts: 7
Joined: Thu May 10, 2018 2:22 pm

Re: Mixed content issue on stylesheet

Post by snathan99 »

Tested the update and works great!

My information
First Name: Senthil
Last Name: Nathan
Website: https://realclearagent.net

Thanks so much for including in the update. Now I can update without having to edit it again.
wiz
Admin
Posts: 496
Joined: Sat Oct 30, 2010 12:23 am

Re: Mixed content issue on stylesheet

Post by wiz »

The fix will be included in the update that's coming in the next couple of weeks. Even if you've modified your index.php, it will be overwritten with this fix once you update.

As a thank you, you've been added to the contributors page: https://wondercms.com/special-contributors
Once the update is live, you'll be also mentioned in the release notes: https://wondercms.com/whatsnew

Once again, thank you for the awesome discussion and for testing this out - marking thread solved.
wiz
Admin
Posts: 496
Joined: Sat Oct 30, 2010 12:23 am

Re: [SOLVED] Mixed content issue on stylesheet

Post by wiz »

Hey snathan99, just letting you know that this fix has been deployed in the latest 2.5.2 version.

You've been also added to the release notes page: https://wondercms.com/whatsnew.
Post Reply