I'm helping someone create a type of free hosting php script, he's finished it, but to place an ad, he's using this code:-
$adcode = file_get_contents("includes/ads.inc");
$open2 = fopen("$savedir/$filename",'r+');
fwrite($open2, $filecontents);
fwrite($open2, "<!--ADS-START--><div align=\"center\">$adcode</div><!--ADS-END-->");
fclose($open2);
to append the contents of ads.inc to the end of the /html tag, which is not of any use, what I'm trying to do is to use a javascript .js file that reads the contents of ads.inc and when the page is opened it displays it at the top of the page.
Using this code replacement, it would place the html code underneath the /html tag, then when a user edits that page using TinyMCE, TinyMCE deletes anything that's after the /html tag, thus the inserted html code doesn't get shown, then when the user saves the file, the code below would add the html code again to the bottom of the page, thus when the page is opened, the ad gets shown at the top.
$adcode = "<script language=\"javascript\" src=\"/includes/ads.js\"></script>";
$open2 = fopen("$savedir/$filename",'r+');
fwrite($open2, $filecontents);
fwrite($open2, "<!--ADS-START--><div align=\"center\">$adcode</div><!--ADS-END-->");
fclose($open2);
Is it possible to create such a js file to position an ad at the top of a page without actually inserting it into the page?
This is the contents of ads.inc:-
<br /><div align="center"><script type="text/javascript"><!--
google_ad_client = "pub-8204591385655028";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>