Re: Problems with mirror site script
| From: | Dan | Date: | Thu, 28 Jun 2007 23:24:20 +0000 |
| Subject: | Re: Problems with mirror site script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257927@lists.php.net to get a copy of this message | ||
If you're looking to build an web based proxy that supports ads, there's already tons of scripts out there that do it securely, and render very nicely. Most even supporting ad management.
CGIProxy http://www.jmarshall.com/tools/cgiproxy/
PHProxy http://whitefyre.com/poxy/
Zelune http://www.zelune.net/
Are some of the extremly popular ones. No need to reinvent the wheel.
- Dan
""Wikus Möller"" <wikus.m@gmail.com> wrote in message news:723b2ee70706261719k2de4f038t7094fa36a2c372f7@mail.gmail.com...
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 htmlPUBLIC \"-//W3C//DTD HTML")){ $ads = ads_html(); $contents2 = explode("</body>" , $contents); } if(strstr($contents, "<!DOCTYPE htmlPUBLIC \"-//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