August 7, 201214 yr I have a pices of informatyion / javascript for the cookie control code on my site which i DO NOT want to display if the page is a secure/SSL/https page. can anyone help me with the a php if statment please
August 7, 201214 yr Author thinking maybe something like <?php if ($request_type == 'NONSSL') { //code goes here for non-ssl } else { //if its ssl, show me this stuff } ?>
August 7, 201214 yr Author or even <?php // If page is SSL then use Secure Code if($_SERVER['HTTPS']=='on'){ //Put your secure code here } else { // Else use Non-Secure Code // Put your non-secure code here. } // End if ?>
August 7, 201214 yr if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') { // CODE HERE FOR NON SSL } else { // CODE HERE FOR SSL }
August 7, 201214 yr Author all thats seems to happen is i get a blank site, im using this in the footer of my site to include a civicuk cookie control script <?php if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') { // CODE HERE FOR NON SSL <script src="https://ssl.geoplugin.net/javascript.gp" type="text/javascript"></script> <script src="cookieControl-5.1.min.js" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ cookieControl({ introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>', fullText:'<p>This site uses some unobtrusive cookies.</p>', position:'left', // left or right shape:'triangle', // triangle or diamond theme:'dark', // light or dark startOpen:true, autoHide:6000, subdomains:true, protectedCookies: [], //list the cookies you do not want deleted ['analytics', 'twitter'] consentModel:'implicit', onAccept:function(){ccAddAnalytics()}, onReady:function(){}, onCookiesAllowed:function(){ccAddAnalytics()}, onCookiesNotAllowed:function(){}, countries:'United Kingdom,Netherlands' // Or supply a list ['United Kingdom', 'Greece'] }); function ccAddAnalytics() { jQuery.getScript("https://www.google-analytics.com/ga.js", function() { var GATracker = _gat._createTracker(''); GATracker._trackPageview(); }); } //]]> </script> } else { // CODE HERE FOR SSL } ?>
August 12, 201214 yr all thats seems to happen is i get a blank site, im using this in the footer of my site to include a civicuk cookie control script <?php if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') { // CODE HERE FOR NON SSL <script src="https://ssl.geoplugin.net/javascript.gp" type="text/javascript"></script> <script src="cookieControl-5.1.min.js" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ cookieControl({ introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>', fullText:'<p>This site uses some unobtrusive cookies.</p>', position:'left', // left or right shape:'triangle', // triangle or diamond theme:'dark', // light or dark startOpen:true, autoHide:6000, subdomains:true, protectedCookies: [], //list the cookies you do not want deleted ['analytics', 'twitter'] consentModel:'implicit', onAccept:function(){ccAddAnalytics()}, onReady:function(){}, onCookiesAllowed:function(){ccAddAnalytics()}, onCookiesNotAllowed:function(){}, countries:'United Kingdom,Netherlands' // Or supply a list ['United Kingdom', 'Greece'] }); function ccAddAnalytics() { jQuery.getScript("https://www.google-analytics.com/ga.js", function() { var GATracker = _gat._createTracker(''); GATracker._trackPageview(); }); } //]]> </script> } else { // CODE HERE FOR SSL } ?> Maybe cause you're not actually echoing anything? Rather than using 'echo' I like to do something like this. <?php if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') { ?> // CODE HERE FOR NON SSL <script src="https://ssl.geoplugin.net/javascript.gp" type="text/javascript"></script> <script src="cookieControl-5.1.min.js" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ cookieControl({ introText:'<p>This site uses some unobtrusive cookies to store information on your computer.</p>', fullText:'<p>This site uses some unobtrusive cookies.</p>', position:'left', // left or right shape:'triangle', // triangle or diamond theme:'dark', // light or dark startOpen:true, autoHide:6000, subdomains:true, protectedCookies: [], //list the cookies you do not want deleted ['analytics', 'twitter'] consentModel:'implicit', onAccept:function(){ccAddAnalytics()}, onReady:function(){}, onCookiesAllowed:function(){ccAddAnalytics()}, onCookiesNotAllowed:function(){}, countries:'United Kingdom,Netherlands' // Or supply a list ['United Kingdom', 'Greece'] }); function ccAddAnalytics() { jQuery.getScript("https://www.google-analytics.com/ga.js", function() { var GATracker = _gat._createTracker(''); GATracker._trackPageview(); }); } //]]> </script> <?php } else { // CODE HERE FOR SSL } ?>
Create an account or sign in to comment