I'm writing a mambot for Joomla and I want it to execute when entering the {mos} tag with the parameter on or off in there.
Here is the code:
Code:
$action = $matches[1];
$port = $_SERVER['HTTPS'];
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if(empty($port) && $action == 'on')
header("location:https://$url");
else if(!empty($port) && $action == 'off')
header("location:http://$url)");
else
return true;
this is just the function that is actually performing the action. At this point I have already successfully retrieved the action from the mostag.
If you have the OFF parameter set and the page is accessed with HTTP, nothing happens (the page loads normally).
If you have the OFF parameter set and the page is accessed with HTTPS, it redirects to the same page but with only HTTP.
If you have the ON parameter set and the page is accessed with HTTPS, nothing happens (the page loads normally).
If you have the ON parameter set and the page is accessed with HTTP, it attempts to redirect but then Firefox says "This page is redirecting in a way that will never stop".
I cannot figure out why it is working when it is set to OFF but not when it is set to ON. The purpose of this script is so the administrator can force the use of SSL or not.
Can anyone here tell me what I've done wrong?
|