|
Posted by windandwaves on 12/04/06 07:05
Can someone rewrite the function below. I am sure this can be done so
much easier! Note that the dd_... are constants.
function secureswitch($normalurl, $normalswitchpage, $secureurl,
$secureswitchpage, $_GET) {
$currentfile = file_currentfilename("?");
$redirectfile = $currentfile.'?';
foreach($_GET as $key=>$value) {
$redirectfile .= "&$key=$value";
}
$currentserver = 'http://'.$_SERVER['HTTP_HOST']."/";
$isnormalswitchpage = strpos($currentfile, $normalswitchpage);
$issecureswitchpage = strpos($currentfile, $secureswitchpage);
if($isnormalswitchpage !== false && $currentserver != $normalurl) {
//switch to normal
$goto = $normalurl.$redirectfile;
header("location: $goto");
}
else {
$testurl = str_replace("https", "http", $secureurl);
if($issecureswitchpage !== false && $currentserver != $testurl) {
//switch to secure
$goto = $secureurl.dd_secure_extension.$redirectfile;
header("location: $goto");
}
}
}
function file_currentfilename($cutoff = "?") {
$file = explode($cutoff, basename($_SERVER['PHP_SELF']));
return $file[0];
}
[Back to original message]
|