
11-16-2009, 02:55 PM
|
|
|
Join Date: Nov 2001
Posts: 312
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
Originally Posted by testbot
you have to create it.
here. below is my setup. you should only have to change the styleid to your mobile styleid (this will make it so the plugin only runs when it's mobile - less is better) and your google options. i marked the parts you should change.
Create Plugin
Product: vBulletin
Hook Location: global_start
Title: Mobile AdSense Top
Execution Order: 5
Plugin PHP Code:
Code:
/*** Change to your mobile style id ***/
if ($styleid==20){
/*** End Change to your mobile style id ***/
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_get_ad_url() {
$google_ad_url = 'http://pagead2.googlesyndication.com/pagead/ads?';
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);
}
}
google_append_url($google_ad_url, 'dt',
round(1000 * array_sum(explode(' ', microtime()))));
return $google_ad_url;
}
/**** YOUR SETTINGS ***/
$GLOBALS['google']['ad_type']='text_image';
$GLOBALS['google']['channel']='xxxx';
$GLOBALS['google']['client']='pub-xxxx';
$GLOBALS['google']['color_border']='336699';
$GLOBALS['google']['color_bg']='FFFFFF';
$GLOBALS['google']['color_link']='0000FF';
$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']='chtml';
$GLOBALS['google']['oe']='utf8';
$GLOBALS['google']['output']='chtml';
/*** END YOUR SETTINGS ***/
$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_ad_handle = @fopen(google_get_ad_url(), 'r');
if ($google_ad_handle) {
while (!feof($google_ad_handle)) {
$mobile_ad_top .= fread($google_ad_handle, 8192);
}
fclose($google_ad_handle);
}
}
Styles & Templates> Style Manager>Ad Location Templates>ad_navbar_below & ad_footer_start
Code:
<div>
<!-- Mobile Ad -->
$mobile_ad_top
<!-- /Mobile Ad -->
</div>
|
I added this plugin and modified templates in my mobile style exactly as described but see no mobile ads. How doe the $mobile_ad_top get connected with the plugin? That might be the part I am missing.
|