Jump to content


Photo

SSL vs NON-SSL


  • Please log in to reply
5 replies to this topic

#1 stephanes

stephanes

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 14 April 2013 - 04:19 PM

Hi,

 

I have a live chat widget. To have the widget to work in SSL pages, I had to change in all .php this: if(!strstr($hostdomain,"http")){ $hostdomain="http://".$hostdomain; } to if(!strstr($hostdomain,"https")){ $hostdomain="https://".$hostdomain; }.

 

The problem is when I change the http to https in the code above, now the widget don't appear in non-ssl pages.

 

So my question is how can I modify the code below to have it to work with both http and https ?


Edited by stephanes, 14 April 2013 - 04:21 PM.


#2 DavidAM

DavidAM

    Advanced Member

  • Gurus
  • 1,974 posts
  • LocationSpring, TX USA

Posted 14 April 2013 - 05:11 PM

Have a look at the $_SERVER super-global array. There are a couple of entries there that can tell you if the user requested through HTTP or HTTPS. Then build your domain variable appropriately.
-- I haven't lost my mind, it's backed up on tape ... somewhere!

#3 stephanes

stephanes

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 14 April 2013 - 06:23 PM

Thank you for your answer but to be honest I don't understand. Just giving me a link to the php manual is no help in my case.


Edited by stephanes, 14 April 2013 - 06:24 PM.


#4 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,128 posts
  • LocationWA

Posted 14 April 2013 - 06:47 PM

Then you best start learning to read manual pages.

'HTTPS'
Set to a non-empty value if the script was queried through the HTTPS protocol.



#5 stephanes

stephanes

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 14 April 2013 - 06:53 PM

Probably I'm just a the wrong place. I was just asking for help. I don't understand the purpose to register here if the only help I can get is to tell me to read the php manual. 



#6 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 14 April 2013 - 08:14 PM

We expect people to do some work and ask decent questions.
Even without that you were given the relevant information already.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com