Jump to content



  • Please log in to reply
5 replies to this topic

#1 stephanes

  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 April 2013 - 09:19 PM



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 - 09:21 PM.

#2 DavidAM

  • Moderators
  • Advanced Member
  • 1,980 posts
  • LocationSpring, TX USA

Posted 14 April 2013 - 10: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

  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 April 2013 - 11: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 - 11:24 PM.

#4 requinix

  • Administrators
  • Lazy Administrator
  • 9,374 posts
  • LocationWA

Posted 14 April 2013 - 11:47 PM

Then you best start learning to read manual pages.

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

The Reimann Zeta Function Trolley Problem | "Summer is when I, the great ice fairy, can show my true power!"

#5 stephanes

  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 April 2013 - 11: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

  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 15 April 2013 - 01:14 AM

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