adeydas8 Posted March 31, 2006 Share Posted March 31, 2006 Hi!I am trying to write an Anti Leeching script in PHP and have the following code:[code]<?php$referer=$_SERVER['HTTP_REFERER']; //Finds the referer and stores it into $referer//Edit from here//The following array contains the URL's from where the download can be accessed.//Usually you should put the name of your site here along with any subdomains from where //you want to allow files to be downloaded//The format is://$sites[0]="http://example.com";//$sites[1]="http://subdomain.example.com";//$sites[2]="http://friendssite.com";//and so on and so forth...$sites[0]="http://example.com";$sites[1]="http://www.example.com";$sites[2]="http://subdomain.example.com";$sites[3]="http://www.subdomain.example.com";$sites[4]="http://localhost";$last=4; //Change 4 to the last number in your array, i.e, the number in [] of $sites. // In the default file it is $sites[4]="http://localhost"; and our number is 4$length=16; //Enter the length of the shortest URL. In the default file it is http://localhost and the //length of it is 16, so I have entered 16. Please remember to count the whole thing including //http:// and www. or ftp://$folder="downloads/".$go; //Enter the name of the secret folder where you store your downloads$anti_leech_page="anti_leech.php"; //Enter the file name of the page which you want to show if somebody //is caught leeching$wrong_access="access.php"; //Enter the file name of the page which you want to show if the anti leeching //script is accessed directly//Please don't edit beyond this point unless you know what you are doing//Truncating the referer$res=substr($referer,0,$length);echo($res);//Truncating the string of the URL'sfor ($i=0; $i<=$last; $i++){ $site[$i]=substr($sites[$i],0,$length);}/*for ($k=0; $k<=$last; $k++){ echo($site[$k]); echo("<br />");}*///Checking whether HTTP_REFERER is NULLif ($go==""){ $dummy=$wrong_access; } //If HTTP_REFERER is not NULL this happens for ($p=0; $p<=$last; $p++) { if ($site[$p]==$res) { $k=1; break; } else { $dummy=$anti_leech_page; } }if ($k=1){ $wer=$folder;}else{ $wer=$dummy;}echo($folder);echo("<br />");echo($wer);echo("<br />");echo($dummy);echo("<br />");?><!-- This is the HTML code of Abhishek's Anti Leeching Script --><html><head><title>Abhishek's Anti Leeching Script</title><!-- <meta http-equiv="refresh" content="1;url=<?php echo($wer); ?>"> --></head><body>Your download will begin in 1 seconds. If it dosen't start, please click <a href="<?php echo($wer); ?>" />here</a>.<br /><br />Referer is: <?php echo($referer); ?><br /></body></html>[/code]The output of this comes out as follows:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined variable: go in C:\Program Files\Apache Group\Apache2\htdocs\abhishek\leech\go.php on line 28[a href=\"http://localhost\" target=\"_blank\"]http://localhost[/a]Notice: Undefined variable: go in C:\Program Files\Apache Group\Apache2\htdocs\abhishek\leech\go.php on line 61downloads/downloads/anti_leech.phpYour download will begin in 1 seconds. If it dosen't start, please click here.Referer is: [a href=\"http://localhost/abhishek/leech/main.php\" target=\"_blank\"]http://localhost/abhishek/leech/main.php[/a][/quote]First of all, the value of $go is not recognised. Second, though [a href=\"http://localhost\" target=\"_blank\"]http://localhost[/a] exists in the array, still $dummy is given the value of $anti_leech_page.Can you please help me out with this code.Thank you.Abhishek. Link to comment https://forums.phpfreaks.com/topic/6258-problems-with-anti-leeching-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.