if 'on' = https

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

if 'on' = https

Post 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
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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'
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

the got you got now tries to set 'on' to 'https', which can't be done i reckon :P
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

==
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

maybe the information stored in $_SERVER['SERVER_PROTOCOL'] may also be useful.

Mark
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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 
}
?>
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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 ?!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Tried this ?

Code: Select all

if($_SERVER['SERVER_PORT'] == 443){
     //ssl
} else {
    //not ssl
}
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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 ;-)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

SERVER_PORT not REMOTE_PORT
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I could almost kiss ya Bleeep....


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


Image
Post Reply