Zend - The PHP Company




HTTP

Add Code


Anti-leech  

Type: code fragment
Added by: Odey_dot_com
Entered: 01/08/2000
Last modified: 08/12/1999
Rating: **** (10 votes)
Views: 10225
Want to prevent people from linking to certain pages on your site? This tiny script will alow you to admit users to specified pages from other pages on your site, while preventing people from viewing your pages via outside links. Very reliable script, and extremely easy to set up...


<?

               
/* Anti-leech bandwidth protecter by Corey Milner, http://www.odey.com. 
               Turn the refererring URL into a variable */
$from getenv("HTTP_REFERER");

               
/* Check to see if the URL in the variable is a valid referrer. Add the page URL which you would like                               people to arrive from here. */
if ($from != "http://www.yoursite.com/validpage.htm")

               
/* If the URL is valid, page loads now */

               /* If URL is invalid the following error message and proper link appears, enter your custom error                             message and a hyperlink to the valid URL you entered above here*/
{print(" Sorry you have tried to link to a page which does not accept visitors directly. <br>
<a href=http://www.yoursite.com/validpage.htm>CLICK HERE</a> to enter"
);

               
/* Prevent the rest of the page from loading */
exit;}

?>


Usage Example




Rate This Script





Search



This Category All Categories