Jump to content

Problems with Anti Leeching Script


adeydas8

Recommended Posts

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's
for ($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 NULL
if ($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 61
downloads/
downloads/
anti_leech.php
Your 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.