Closed (fixed)
Project:
Google AdSense integration
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
15 May 2009 at 17:52 UTC
Updated:
2 Jun 2009 at 21:30 UTC
The following code:
function _adsense_page_match() {
// Do not show ads on secure pages.
// This is for two reasons:
// Google would most probably not have indexed secure pages
// and it also prevents warnings about mixed-content
// Thanks to Brad Konia http://drupal.org/node/29585
// Should be restricted when running on Apache only
if (function_exists('apache_get_version') && isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) {
return FALSE;
}
Should be
function _adsense_page_match() {
// Do not show ads on secure pages.
// This is for two reasons:
// Google would most probably not have indexed secure pages
// and it also prevents warnings about mixed-content
// Thanks to Brad Konia http://drupal.org/node/29585
// Should be restricted when running on Apache only
if (function_exists('apache_get_version') || isset($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] == 'on')) {
return FALSE;
}
This works on my apache server
Comments
Comment #1
jcnventuraThe way you posted your code seems to reduce the function to:
on Apache servers. I run my site in Apache only, and I can tell you that I don't want _adsense_page_match() to return FALSE on all pages.
So, either something important is missing from your patch above, or you're trying to do something strange..
Actually the code as it is now seems perfectly fine to me.
João
Comment #2
jamesweston commentedOk i missed out the rest of the function the
All that is changed is this if statement
So the the module doesn't show ads on HTTPS pages i don't not if this break computability with IIS
Comment #3
jcnventuraReally, look at your code.. You have something like:
if (something that is always true in Apache || whatever || whatever) {
return FALSE;
}
On apache servers, that function always returns false.. It's as simple as that.. So on apache servers, you've basically disabled the module. And I mean really disabled, no ads on https pages, but also no ads on http pages, no ads at all. Well done, but there are easier ways to disable it without changing the code.
João
Comment #4
jamesweston commentedi understand what you are saying about the if statement but its results work on my site i can see ads on http://meamod.com but not on https://meamod.com/user so its working
Comment #5
jcnventuraCan you help then?
Please insert the following lines into just before the if:
Do a refresh and tell me what it prints out for you. Then delete the code.
Comment #6
jcnventuraRun it both on an http page and on a https page, please!
Comment #7
jamesweston commentedOk this is the output
HTTP Page
bool(false) bool(false) NULL bool(false) bool(false) NULL
HTTPS Page
bool(false) bool(true) string(2) "on"
I am running Apache/2.-.-- (Unix)
Comment #8
jcnventuraHaha!
Found the guilty party.. Apparently, in some strange cases, it's possible to be running Apache, but apache_get_version() is not defined (according to the documentation it's only available with the filter API in Apache 2).
So, your code works because it's still false in the http case, and it's true in https.. For the rest of us who have the filter API, it fails horribly.. I'll try to come up with a better solution.
João
Comment #9
jcnventuraI think that checking for
stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== FALSEwill do the trick. I can't test it right now..Comment #10
jamesweston commentedOk so this seems to be working for me
Comment #11
jcnventuraRemove the function_exists section completely.. The stripos replaces that as the 'Apache detection' condition.
João
Comment #12
jamesweston commentedAll done and works I just left it in because there was a bug what SERVER_SOFTWARE would return but it is really not applicable in this situation
Comment #13
jcnventuraThe fix highlighted above was commited to CVS. It should be in the latest dev in a few hours.
João