function _adsense_page_match in Google AdSense integration 5.3
Same name and namespace in other branches
- 5 adsense.module \_adsense_page_match()
- 5.2 adsense.module \_adsense_page_match()
- 6 adsense.module \_adsense_page_match()
- 7 adsense.module \_adsense_page_match()
Determine if AdSense has permission to be used on the current page.
Return value
TRUE if can render, FALSE if not allowed.
5 calls to _adsense_page_match()
- adsense_cse_block in cse/
adsense_cse.module - Implementation of hook_block().
- adsense_display in ./
adsense.module - Generates the Google AdSense Ad
- adsense_managed_block in managed/
adsense_managed.module - Implementation of hook_block().
- adsense_oldcode_block in old/
oldcode/ adsense_oldcode.module - Implementation of hook_block().
- adsense_search_block in old/
search/ adsense_search.module - Implementation of hook_block().
File
- ./
adsense.module, line 535 - Displays Google AdSense ads on Drupal pages
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 (isset($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
return FALSE;
}
$pages = variable_get('adsense_access_pages', ADSENSE_ACCESS_PAGES_DEFAULT);
$visibility = variable_get('adsense_visibility', ADSENSE_VISIBILITY_DEFAULT);
if ($pages) {
if ($visibility == 2) {
return drupal_eval($pages);
}
$path = drupal_get_path_alias($_GET['q']);
$page_match = _adsense_match_path($path, $pages);
if ($path != $_GET['q']) {
$page_match = $page_match || _adsense_match_path($_GET['q'], $pages);
}
return !($visibility xor $page_match);
}
else {
return !$visibility;
}
}