4images Forum & Community

General / Allgemeines => Programming => Topic started by: Sunny C. on August 01, 2010, 07:21:44 PM

Title: Imagecode in Adsense- Script dont work
Post by: Sunny C. on August 01, 2010, 07:21:44 PM
Hello this is my code in details.php:

// Image Adsense Start
$image_adsense = $config['image_adsense'];
$image_adsense_time = $config['image_adsense_time'];
   if($config['image_adsense_onoff'] == 1)  {
$image_adsense_show .= "<div align=\"center\">\n";
$image_adsense_show .= "<script type=\"text/javascript\">\n";
$image_adsense_show .= "<!--\n";
$image_adsense_show .= "function fc() {\n";
$image_adsense_show .= "if(c>0){\n";
$image_adsense_show .= "document.getElementById(\"dl\").innerHTML = '".$lang['adsense_sek']."<br />".$lang['adsense_loader']."';\n";
$image_adsense_show .= "c=c-1;\n";      
$image_adsense_show .= "setTimeout(\"fc()\", 1000);\n";
$image_adsense_show .= "} else {\n";
$image_adsense_show .= "var tt = '";
$image_adsense_show .= get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
$image_adsense_show .= "';\n";
$image_adsense_show .= "document.getElementById(\"dl\").innerHTML = tt;\n";
$image_adsense_show .= "}\n";
$image_adsense_show .= "}\n";
$image_adsense_show .= "var c=".$image_adsense_time.";\n";        
$image_adsense_show .= "if (window.location.hash == \"#dlt\")\n";
$image_adsense_show .= "c = 0;\n";
$image_adsense_show .= "window.onload = fc;\n";
$image_adsense_show .= "//-->\n";
$image_adsense_show .= "</script>\n";
$image_adsense_show .= "<div id=\"dl\">.</div>";
   } else {
  $image_adsense_show = get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
   }
$site_template->register_vars(array(
  "image_adsense" => $image_adsense_show,
  "image_adsense_time" => $image_adsense_time,
  ));
// Image Adsense Ende

If the advertisement is switched off, the original code is given
   } else {
  $image_adsense_show = get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
   }

If the advertisement is switched on, the Javascript with the image code should be given, but functioned not.
$image_adsense_show .= "<div align=\"center\">\n";
$image_adsense_show .= "<script type=\"text/javascript\">\n";
$image_adsense_show .= "<!--\n";
$image_adsense_show .= "function fc() {\n";
$image_adsense_show .= "if(c>0){\n";
$image_adsense_show .= "document.getElementById(\"dl\").innerHTML = '".$lang['adsense_sek']."<br />".$lang['adsense_loader']."';\n";
$image_adsense_show .= "c=c-1;\n";      
$image_adsense_show .= "setTimeout(\"fc()\", 1000);\n";
$image_adsense_show .= "} else {\n";
$image_adsense_show .= "var tt = '";
$image_adsense_show .= get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
$image_adsense_show .= "';\n";
$image_adsense_show .= "document.getElementById(\"dl\").innerHTML = tt;\n";
$image_adsense_show .= "}\n";
$image_adsense_show .= "}\n";
$image_adsense_show .= "var c=".$image_adsense_time.";\n";        
$image_adsense_show .= "if (window.location.hash == \"#dlt\")\n";
$image_adsense_show .= "c = 0;\n";
$image_adsense_show .= "window.onload = fc;\n";
$image_adsense_show .= "//-->\n";
$image_adsense_show .= "</script>\n";
$image_adsense_show .= "<div id=\"dl\">.</div>";
This line simply does not function
$image_adsense_show .= get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);
But in the source text everything is right
Code: [Select]
<script type="text/javascript">
<!--
function fc() {
if(c>0){
document.getElementById("dl").innerHTML = 'Noch ' + c + ' Sekunden<br /><img src="./templates/default/images/loader.gif" width="16" height="16" />';
c=c-1;
setTimeout("fc()", 1000);
} else {
var tt = '<img src="./data/media/1/1-7be2c989ee4267f4.jpg" border="1" alt="test" width="200" height="266" />
';
document.getElementById("dl").innerHTML = tt;
}
}
var c=2;
if (window.location.hash == "#dlt")
c = 0;
window.onload = fc;
//-->
</script>

Edit://
This work:
$image_adsense_show .= "var tt = '";
$image_adsense_show .= "<img src=\"".MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file']."\" border=\"1\" alt=\"".$image_row['image_name']."\"".$width_height." />";
$image_adsense_show .= "';\n";
But is this conform

and
".$width_height."
dont work
Title: Re: Imagecode in Adsense- Script dont work
Post by: webmasterforum on November 21, 2010, 07:00:52 PM
I think you should better directly include adsense at seperate html file.
Title: Re: Imagecode in Adsense- Script dont work
Post by: x23piracy on November 21, 2010, 07:12:54 PM
Hi,

you should read that or similar in google, it's forbidden by
the rules to display adsense only for seconds and placing the
adsense code on a single html file...

http://www.quickonlinetips.com/archives/2005/05/15-common-mistakes-by-google-adsense-publishers/ (http://www.quickonlinetips.com/archives/2005/05/15-common-mistakes-by-google-adsense-publishers/)

auf Deutsch: Benny pass auf, ein adsense account der einmal weg ist, ist es für immer!
Ich mach das auch nicht anders, aber die Adsense Bots besuchen dich und finden das
für google heraus ;) das geht schneller als man denkt...


Gruß Jens
Title: Re: Imagecode in Adsense- Script dont work
Post by: Sunny C. on November 21, 2010, 08:03:01 PM
Ach den Mist nutze ich so oderso nicht mehr. Kaum Vergütung und genrell einfach nur Mist es gibt extrem viele bessere Anbieter!
Title: Re: Imagecode in Adsense- Script dont work
Post by: x23piracy on November 21, 2010, 08:33:13 PM
Ach den Mist nutze ich so oderso nicht mehr. Kaum Vergütung und genrell einfach nur Mist es gibt extrem viele bessere Anbieter!

Hi,

die wären?
Erzähl mal von deinen Erfahrungen bitte.


Gruß Jens
Title: Re: Imagecode in Adsense- Script dont work
Post by: V@no on November 21, 2010, 09:17:07 PM
You probably are getting javascript error, because JS doesn't allow multiline text.

replace
Code: [Select]
$image_adsense_show .= get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view);

with:
Code: [Select]
$image_adsense_show .= str_replace("\n", " ", str_replace("'", "\'", get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view)));