comment faire pour intégrer ce code adsense pour mobile dans mon fichier php sans causer d'erreurs ?
CODE
<?php
$GLOBALS['google']['ad_type']='text_image';
$GLOBALS['google']['channel']='';
$GLOBALS['google']['client']='pub-xxxxxxxxxxxxxxxx';
$GLOBALS['google']['format']='mobile_double';
$GLOBALS['google']['https']=$_SERVER['HTTPS'];
$GLOBALS['google']['host']=$_SERVER['HTTP_HOST'];
$GLOBALS['google']['ip']=$_SERVER['REMOTE_ADDR'];
$GLOBALS['google']['markup']='wml';
$GLOBALS['google']['oe']='latin1';
$GLOBALS['google']['output']='wml';
$GLOBALS['google']['ref']=$_SERVER['HTTP_REFERER'];
$GLOBALS['google']['url']=$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$GLOBALS['google']['useragent']=$_SERVER['HTTP_USER_AGENT'];
$google_dt = time();
google_set_screen_res();
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 = $_SERVER['HTTP_UA_PIXELS'];
$delimiter = 'x';
if ($screen_res == '') {
$screen_res = $_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_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 = _AT_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);
}
?>
$GLOBALS['google']['ad_type']='text_image';
$GLOBALS['google']['channel']='';
$GLOBALS['google']['client']='pub-xxxxxxxxxxxxxxxx';
$GLOBALS['google']['format']='mobile_double';
$GLOBALS['google']['https']=$_SERVER['HTTPS'];
$GLOBALS['google']['host']=$_SERVER['HTTP_HOST'];
$GLOBALS['google']['ip']=$_SERVER['REMOTE_ADDR'];
$GLOBALS['google']['markup']='wml';
$GLOBALS['google']['oe']='latin1';
$GLOBALS['google']['output']='wml';
$GLOBALS['google']['ref']=$_SERVER['HTTP_REFERER'];
$GLOBALS['google']['url']=$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$GLOBALS['google']['useragent']=$_SERVER['HTTP_USER_AGENT'];
$google_dt = time();
google_set_screen_res();
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 = $_SERVER['HTTP_UA_PIXELS'];
$delimiter = 'x';
if ($screen_res == '') {
$screen_res = $_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_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 = _AT_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);
}
?>
Fichier php
CODE
<?
session_start();
include_once("admin/inc.php");
$catname = " :: LA_WAP";
include_once("header_inc.php");
writeLinkedTitle("");
$catid_search = "";
$tplList=new TplLoad;
$val_string="";
$val_string2="";
if ($validation == 1) { $val_string = " AND ad_is_validated = 1"; } else { $val_string = ""; }
if ($validation == 1) { $val_string2 = " where ad_is_validated = 1"; } else { $val_string2 = ""; }
$sql_links = "select ad_id,ad_title,ad_description,ad_date from $ads_tbl $val_string2 order by ad_id desc limit 30";
$sql_result = q ($sql_links);
$num_links = mysql_num_rows($sql_result);
$file_pointer = fopen("wap/index.wml", "w");
fwrite($file_pointer,"<?xml version=\"1.0\"?>\n"
. "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n"
. "<wml>\t<card id=\"LatestAds\" title=\"Latest ads\">\n<p><table columns=\"1\">");
fclose($file_pointer);
for ($i=0; $i<$num_links; $i++)
{
$row = mysql_fetch_array($sql_result);
$ad_id = $row["ad_id"];
$sitetitle = $row["ad_title"];
$ad_description = $row["ad_description"];
$datestamp = $row["datestamp"];
$ad_date=formatDateShort($row["ad_date"]);
$fp=fopen("wap/index.wml", 'a');
fwrite($fp,"\n<tr><td><a href=\"detail.wml#wap_$ad_id\">$sitetitle</a> $ad_date1</td></tr>");
fclose($fp);
}
$fi=fopen("wap/index.wml", 'a');
fwrite($fi,"</table></p></card></wml>");
fclose($fi);
$num_links = mysql_num_rows($sql_result);
$sql_links = "select ad_id,ad_title,ad_description,user_name,user_email from $ads_tbl, $usr_tbl where ad_owner = user_id $val_string order by ad_id desc limit 10";
$sql_result = q ($sql_links);
$num_links = mysql_num_rows($sql_result);
for ($i=0; $i<$num_links; $i++)
{
$row = mysql_fetch_array($sql_result);
$ad_id = $row["ad_id"];
$sitetitle = $row["ad_title"];
$ad_description = strip_tags($row["ad_description"]);
$name = $row["user_name"];
$phone = $row["phone"];
$email = $row["user_email"];
$array[] = "<card id=\"wap_$ad_id\" title=\"$sitetitle\"><p>$sitetitle<br />$ad_description<br /><br />$name / $email</p></card>";
}
$arrelm0=""; $arrelm1=""; $arrelm2=""; $arrelm3=""; $arrelm4=""; $arrelm5=""; $arrelm6=""; $arrelm7=""; $arrelm8=""; $arrelm9=""; $arrelm10="";
$special = "";
// DETAILED PAGES
$start = "<?xml version=\"1.0\"?>\n<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n<wml>\t";
if (isset($array[0]))
$arrelm0 = $array[0];
if (isset($array[1]))
$arrelm1 = $array[1];
if (isset($array[2]))
$arrelm2 = $array[2];
if (isset($array[3]))
$arrelm3 = $array[3];
if (isset($array[4]))
$arrelm4 = $array[4];
if (isset($array[5]))
$arrelm5 = $array[5];
if (isset($array[6]))
$arrelm6 = $array[6];
if (isset($array[7]))
$arrelm7 = $array[7];
if (isset($array[8]))
$arrelm8 = $array[8];
if (isset($array[9]))
$arrelm9 = $array[9];
if (isset($array[10]))
$arrelm10 = $array[10];
$slutt= "</wml>";
$file_pointer = fopen("wap/detail.wml", "w");
fwrite($file_pointer,"$start $arrelm0 $arrelm1 $arrelm2 $arrelm3 $arrelm4 $arrelm5 $arrelm6 $arrelm7 $arrelm8 $arrelm9 $arrelm10 $slutt");
fclose($file_pointer);
$tplList->assign("wap_url","http://$url/wap/index.wml");
if (file_exists("images/rss.xml"))
$tplList->assign("LA_RSS_FEED", LA_RSS_FEED);
$tplList->display("latestwap.tpl");
include_once("footer_inc.php");
?>
session_start();
include_once("admin/inc.php");
$catname = " :: LA_WAP";
include_once("header_inc.php");
writeLinkedTitle("");
$catid_search = "";
$tplList=new TplLoad;
$val_string="";
$val_string2="";
if ($validation == 1) { $val_string = " AND ad_is_validated = 1"; } else { $val_string = ""; }
if ($validation == 1) { $val_string2 = " where ad_is_validated = 1"; } else { $val_string2 = ""; }
$sql_links = "select ad_id,ad_title,ad_description,ad_date from $ads_tbl $val_string2 order by ad_id desc limit 30";
$sql_result = q ($sql_links);
$num_links = mysql_num_rows($sql_result);
$file_pointer = fopen("wap/index.wml", "w");
fwrite($file_pointer,"<?xml version=\"1.0\"?>\n"
. "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n"
. "<wml>\t<card id=\"LatestAds\" title=\"Latest ads\">\n<p><table columns=\"1\">");
fclose($file_pointer);
for ($i=0; $i<$num_links; $i++)
{
$row = mysql_fetch_array($sql_result);
$ad_id = $row["ad_id"];
$sitetitle = $row["ad_title"];
$ad_description = $row["ad_description"];
$datestamp = $row["datestamp"];
$ad_date=formatDateShort($row["ad_date"]);
$fp=fopen("wap/index.wml", 'a');
fwrite($fp,"\n<tr><td><a href=\"detail.wml#wap_$ad_id\">$sitetitle</a> $ad_date1</td></tr>");
fclose($fp);
}
$fi=fopen("wap/index.wml", 'a');
fwrite($fi,"</table></p></card></wml>");
fclose($fi);
$num_links = mysql_num_rows($sql_result);
$sql_links = "select ad_id,ad_title,ad_description,user_name,user_email from $ads_tbl, $usr_tbl where ad_owner = user_id $val_string order by ad_id desc limit 10";
$sql_result = q ($sql_links);
$num_links = mysql_num_rows($sql_result);
for ($i=0; $i<$num_links; $i++)
{
$row = mysql_fetch_array($sql_result);
$ad_id = $row["ad_id"];
$sitetitle = $row["ad_title"];
$ad_description = strip_tags($row["ad_description"]);
$name = $row["user_name"];
$phone = $row["phone"];
$email = $row["user_email"];
$array[] = "<card id=\"wap_$ad_id\" title=\"$sitetitle\"><p>$sitetitle<br />$ad_description<br /><br />$name / $email</p></card>";
}
$arrelm0=""; $arrelm1=""; $arrelm2=""; $arrelm3=""; $arrelm4=""; $arrelm5=""; $arrelm6=""; $arrelm7=""; $arrelm8=""; $arrelm9=""; $arrelm10="";
$special = "";
// DETAILED PAGES
$start = "<?xml version=\"1.0\"?>\n<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n<wml>\t";
if (isset($array[0]))
$arrelm0 = $array[0];
if (isset($array[1]))
$arrelm1 = $array[1];
if (isset($array[2]))
$arrelm2 = $array[2];
if (isset($array[3]))
$arrelm3 = $array[3];
if (isset($array[4]))
$arrelm4 = $array[4];
if (isset($array[5]))
$arrelm5 = $array[5];
if (isset($array[6]))
$arrelm6 = $array[6];
if (isset($array[7]))
$arrelm7 = $array[7];
if (isset($array[8]))
$arrelm8 = $array[8];
if (isset($array[9]))
$arrelm9 = $array[9];
if (isset($array[10]))
$arrelm10 = $array[10];
$slutt= "</wml>";
$file_pointer = fopen("wap/detail.wml", "w");
fwrite($file_pointer,"$start $arrelm0 $arrelm1 $arrelm2 $arrelm3 $arrelm4 $arrelm5 $arrelm6 $arrelm7 $arrelm8 $arrelm9 $arrelm10 $slutt");
fclose($file_pointer);
$tplList->assign("wap_url","http://$url/wap/index.wml");
if (file_exists("images/rss.xml"))
$tplList->assign("LA_RSS_FEED", LA_RSS_FEED);
$tplList->display("latestwap.tpl");
include_once("footer_inc.php");
?>