News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Error when adding AdSense mobile code to wireless.template.php

Started by bluejay51, September 16, 2009, 10:58:32 PM

Previous topic - Next topic

bluejay51

Hi everyone

Ive been trying to add the AdSense mobile PHP code to the wireless.template.php file in the default theme (I'm currently using the the Dilbert theme with SMF v1.1.10) and I keep getting errors. I've tried inserting the code in various parts of this file and no matter where I add it, it screws the page up.

Any suggestions?. Am I doing this correctly?.
Community operated support group for people living with anxiety disorders.
http://www.anxietyzone.com

TheDisturbedOne

Can you attach your Wireless.template.php here?  In addition, please post your ad code here, but substitute your advertiser number with X's (If you don't know how to do it, PM me the ad code). 

And where would you like it to be added?

Arantor

Holder of controversial views, all of which my own.


Afro

i have the same problem too,

here is my wireless.template file and the adsense code


adsense code 

<?php

$GLOBALS
['google']['ad_type']='text';
$GLOBALS['google']['channel']='4483471667+7643994418+6033608322';
$GLOBALS['google']['client']='pub-XXXXXXXXXXXXXXXX';
$GLOBALS['google']['color_border']='FFFFFF';
$GLOBALS['google']['color_bg']='FFFFFF';
$GLOBALS['google']['color_link']='0000CC';
$GLOBALS['google']['color_text']='000000';
$GLOBALS['google']['color_url']='008000';
$GLOBALS['google']['format']='mobile_single';
$GLOBALS['google']['https']=read_global('HTTPS');
$GLOBALS['google']['ip']=read_global('REMOTE_ADDR');
$GLOBALS['google']['markup']='xhtml';
$GLOBALS['google']['oe']='utf8';
$GLOBALS['google']['output']='xhtml';
$GLOBALS['google']['ref']=read_global('HTTP_REFERER');
$GLOBALS['google']['url']=read_global('HTTP_HOST') . read_global('REQUEST_URI');
$GLOBALS['google']['useragent']=read_global('HTTP_USER_AGENT');
$google_dt = time();
google_set_screen_res();
google_set_muid();
google_set_via_and_accept();
function
read_global($var) {
 return isset(
$_SERVER[$var]) ? $_SERVER[$var]: '';
}

function
google_append_url(&$url, $param, $value) {
 
$url .= '&' . $param . '=' . urlencode($value);
}

function
google_append_globals(&$url, $param) {
 
google_append_url($url, $param, $GLOBALS['google'][$param]);
}

function
google_append_color(&$url, $param) {
 global
$google_dt;
 
$color_array = split(',', $GLOBALS['google'][$param]);
 
google_append_url($url, $param,
                   
$color_array[$google_dt % sizeof($color_array)]);
}

function
google_set_screen_res() {
 
$screen_res = read_global('HTTP_UA_PIXELS');
 if (
$screen_res == '') {
   
$screen_res = read_global('HTTP_X_UP_DEVCAP_SCREENPIXELS');
 }
 if (
$screen_res == '') {
   
$screen_res = read_global('HTTP_X_JPHONE_DISPLAY');
 }
 
$res_array = split('[x,*]', $screen_res);
 if (
sizeof($res_array) == 2) {
   
$GLOBALS['google']['u_w'] = $res_array[0];
   
$GLOBALS['google']['u_h'] = $res_array[1];
 }
}

function
google_set_muid() {
 
$muid = read_global('HTTP_X_DCMGUID');
 if (
$muid != '') {
   
$GLOBALS['google']['muid'] = $muid;
 }
 
$muid = read_global('HTTP_X_UP_SUBNO');
 if (
$muid != '') {
   
$GLOBALS['google']['muid'] = $muid;
 }
 
$muid = read_global('HTTP_X_JPHONE_UID');
 if (
$muid != '') {
   
$GLOBALS['google']['muid'] = $muid;
 }
 
$muid = read_global('HTTP_X_EM_UID');
 if (
$muid != '') {
   
$GLOBALS['google']['muid'] = $muid;
 }
}

function
google_set_via_and_accept() {
 
$ua = read_global('HTTP_USER_AGENT');
 if (
$ua == '') {
   
$GLOBALS['google']['via'] = read_global('HTTP_VIA');
   
$GLOBALS['google']['accept'] = read_global('HTTP_ACCEPT');
 }
}

function
google_get_ad_url() {
 
$google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?';
 
google_append_url($google_ad_url, 'dt',
                   
round(1000 * array_sum(explode(' ', microtime()))));
 foreach (
$GLOBALS['google'] as $param => $value) {
   if (
$param == 'client') {
     
google_append_url($google_ad_url, $param,
                       
'ca-mb-' . $GLOBALS['google'][$param]);
   } else if (
strpos($param, 'color_') === 0) {
     
google_append_color($google_ad_url, $param);
   } else if (
strpos($param, 'url') === 0) {
     
$google_scheme = ($GLOBALS['google']['https'] == 'on')
         ?
'https://' : 'http://';
     
google_append_url($google_ad_url, $param,
                       
$google_scheme . $GLOBALS['google'][$param]);
   } else {
     
google_append_globals($google_ad_url, $param);
   }
 }
 return
$google_ad_url;
}

$google_ad_handle = @fopen(google_get_ad_url(), 'r');
if (
$google_ad_handle) {
 while (!
feof($google_ad_handle)) {
   echo
fread($google_ad_handle, 8192);
 }
 
fclose($google_ad_handle);
}

?>





Afro


Filipina

hope this helps this is what mine looks like... but i know google has updated the code i just don't feel like changing mine since the clicks are so few. I show you one line above and below the code so you can see where it fit in for me. I did not do it someone else did.

<body>';
}
$GLOBALS['google']['ad_type']='text_image';
$GLOBALS['google']['channel']='0431491315';
$GLOBALS['google']['client']='pub-xxxxxxxxxxxxxxxx';
$GLOBALS['google']['format']='mobile_single';
$GLOBALS['google']['https']=isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : '';
$GLOBALS['google']['host']=$_SERVER['HTTP_HOST'];
$GLOBALS['google']['ip']=$_SERVER['REMOTE_ADDR'];
$GLOBALS['google']['markup']='xhtml';
$GLOBALS['google']['oe']='utf8';
$GLOBALS['google']['output']='xhtml';
$GLOBALS['google']['ref']=isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
  $screen_res = isset($_SERVER['HTTP_UA_PIXELS']) ? $_SERVER['HTTP_UA_PIXELS'] : '';
  $screen_res = isset($_SERVER['HTTP_X_UP_DEVCAP_SCREENPIXELS']) ? $_SERVER['HTTP_X_UP_DEVCAP_SCREENPIXELS'] : '';
  $dcmguid = isset($_SERVER['HTTP_X_DCMGUID']) ? $_SERVER['HTTP_X_DCMGUID'] : '';
$GLOBALS['google']['url']=$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$GLOBALS['google']['useragent']=$_SERVER['HTTP_USER_AGENT'];
$google_dt = time();
google_set_screen_res();
google_set_dcmguid();

function google_append_url(&$url, $param, $value) {
  $url .= '&' . $param . '=' . urlencode($value);
}

function google_append_globals(&$url, $param) {
  google_append_url($url, $param, $GLOBALS['google'][$param]);
}

function google_append_color(&$url, $param) {
  global $google_dt;
  $color_array = split(',', $GLOBALS['google'][$param]);
  google_append_url($url, $param,
                    $color_array[$google_dt % sizeof($color_array)]);
}

function google_set_screen_res() {
  $screen_res = isset($_SERVER['HTTP_UA_PIXELS']) ? $_SERVER['HTTP_UA_PIXELS'] : '';
  $delimiter = 'x';
  if ($screen_res == '') {
    $screen_res = isset($_SERVER['HTTP_X_UP_DEVCAP_SCREENPIXELS']) ? $_SERVER['HTTP_X_UP_DEVCAP_SCREENPIXELS'] : '';
    $delimiter = ',';
  }
  $res_array = explode($delimiter, $screen_res);
  if (sizeof($res_array) == 2) {
    $GLOBALS['google']['u_w'] = $res_array[0];
    $GLOBALS['google']['u_h'] = $res_array[1];
  }
}

function google_set_dcmguid() {
  $dcmguid = isset($_SERVER['HTTP_X_DCMGUID']) ? $_SERVER['HTTP_X_DCMGUID'] : '';
  if ($dcmguid != '') {
    $GLOBALS['google']['dcmguid'] = $dcmguid;
  }
}

function google_get_ad_url() {
  $google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?';
  $google_scheme = ($GLOBALS['google']['https'] == 'on')
      ? 'https://' : 'http://';
  foreach ($GLOBALS['google'] as $param => $value) {
    if ($param == 'client') {
      google_append_url($google_ad_url, $param,
                        'ca-mb-' . $GLOBALS['google'][$param]);
    } else if (strpos($param, 'color_') === 0) {
      google_append_color($google_ad_url, $param);
    } else if ((strpos($param, 'host') === 0)
               || (strpos($param, 'url') === 0)) {
      google_append_url($google_ad_url, $param,
                        $google_scheme . $GLOBALS['google'][$param]);
    } else {
      google_append_globals($google_ad_url, $param);
    }
  }
  google_append_url($google_ad_url, 'dt',
        round(1000 * array_sum(explode(' ', microtime()))));
  return $google_ad_url;
}

$google_ad_handle = @fopen(google_get_ad_url(), 'r');
if ($google_ad_handle) {
  while (!feof($google_ad_handle)) {
    echo fread($google_ad_handle, 8192);
  }
  fclose($google_ad_handle);
}
function template_imode_boardindex()





Aleksi "Lex" Kilpinen

Hi bluejay51, do you still need help with this or are we ready to mark this solved? :)
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: