Hi. I am currently writing a script to put on my site so people can browse other sites by using my site as a mirror therefore the contents of a webpage would be retrieved and echoed on my site. I am having some problems with placing my ad at the top of the page that is echoed when a user browses a site so that it doesn't interfere with the headers. I am having problems with where to place the link e.g. after the body tag, and how to find out what type of page it is i.e. html, xhtml, etc. so I know if I can use specific effects with my ads. Also, when a user clicks on a link on the mirrored page the link should be mysite.com/index.php?go=http://othersite.com/othersitepage.htm and not mysite.com/othersitepage.htm I have tried to use str_replace in the contents of the retrieved webpage but it doesn't seam to work. Here is the simple piece of code that I have started with without security etc: <? ////// $http is the page that the user wants to browse $handle = fopen($http, "r"); ///////////get contents of webpage $contents = fread($handle, 500000); fclose($handle); $replace = explode("mysite.com/", $contents); str_replace("mysite.com", "mysite.com/index.php?http=$http/$replace[1]", $contents); if(strstr($contents, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML")) { $ads = ads_html(); $contents2 = explode("</body>" , $contents); } if(strstr($contents, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML")) { $ads = ads_xhtml(); $contents2 = explode("</body>" , $contents); } echo $contents2[0] . $ads . $contents2[1]; ?> Please advise me if there is another better way to place my ad and check the type of page because this coding is just wrong and error-prone. Thanks Wikus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php