Page 1 of 1

if 'on' = https

Posted: Mon Apr 05, 2004 10:44 am
by ol4pr0
Some time ago i seen something like the following

Code: Select all

if ('on' = 'HTTPS') {
   do something
   }
   else
   {
    do something else
}
however i tried this but it will always do the } else { part

Anybody knows how to do this.

it need to check if the connection used is true the SSL - https

if not do something else

Posted: Mon Apr 05, 2004 11:01 am
by lostboy
I would suspect that 'on' is the result of some kind of URL grabbing function that splits the incoming URL to see if it equals 'HTTPS'

Posted: Mon Apr 05, 2004 11:02 am
by vigge89
the got you got now tries to set 'on' to 'https', which can't be done i reckon :P

Posted: Mon Apr 05, 2004 11:04 am
by magicrobotmonkey
==

Posted: Mon Apr 05, 2004 11:09 am
by JayBird
does this help?

Code: Select all

<?

$url_components = parse_url($_SERVER["SCRIPT_URI"]);

if ($url_components['scheme'] == "https") {
   // do something 
} else { 
    // do something else 
} 

?>
Mark

Posted: Mon Apr 05, 2004 11:16 am
by JayBird
maybe the information stored in $_SERVER['SERVER_PROTOCOL'] may also be useful.

Mark

Posted: Mon Apr 05, 2004 11:54 am
by ol4pr0
Found something else that might do the trick however i am gonna try both.. and see what it will get me

Thanks

Code: Select all

<?
$port = $_SERVER['REMOTE_PORT'];
IF ($port == 443) {
 do something
}
else
{ 
do something else 
}
?>

Posted: Tue Apr 06, 2004 4:13 pm
by ol4pr0
tried both cases.. the $port and the scheme

However both of them return the else statement as it did with ' on' == ' https'

Any other suggestions ?!

Posted: Tue Apr 06, 2004 4:20 pm
by markl999
Tried this ?

Code: Select all

if($_SERVER['SERVER_PORT'] == 443){
     //ssl
} else {
    //not ssl
}

Posted: Tue Apr 06, 2004 4:23 pm
by ol4pr0

Code: Select all

$port = $_SERVER['REMOTE_PORT'];
Anything with that line simply wont work or in any form of that because port changes constantly ;-)

Posted: Tue Apr 06, 2004 4:26 pm
by markl999
SERVER_PORT not REMOTE_PORT

Posted: Tue Apr 06, 2004 4:27 pm
by ol4pr0
I could almost kiss ya Bleeep....


Thanks that logic didnt come up my mind....


Image