<?php
/**
* <p>
* Script to safely serve a file for download.
* And, most important, block downloads for bots to save bandwidth on our server
* </p>
*
* <p>
* No harvesting allowed!
* </p>
*
* <p>
* Usage:
* </p>
*
* <ul>
* <li>Upload this script to your webserver, for example in /var/www/yoursite.com/download/</li>
* <li>Fill in the config section</li>
* <li>Add links to your web pages, like <a href="http://www.yoursite.com/download/?file=test.mp3">Download</a></li>
* <li>Use a good tool like <a href="http://www.mrunix.net/webalizer/">webalizer</a> to analyze the traffic</a></li>
* <li>Some time, keep a close look on low level to your web server logs. Check all succeeded downloads, to
* be sure there are no more bots downloading your prohibited files.</li>
* <li>If you have <a href="http://redis.io/"><redis</a> (in Ubuntu repository as redis-server) installed on
* your server, then this script can also keep track of the number of downloads, so users which are
* harvesting but not identified as bots will be blocked too.
* See <a href="http://github.com/nrk/predis/">predis</a> for PHP client</li>
* </ul>
*
* <p>
* This script written using the (free and OpenSource) ShishKabab PHP IDE,
* <a href="http://www.shishkabab.net/skphpide.html">shishkabab.net</a>
* <p>
*
* @author Nico den Boer <[email protected]>, <www.nicodenboer.com>, <www.denboer-ims.nl>
* @version 1.0.1
* @package AntiHarvestDownload
*/
/**
* Class with protoctor
*/
require(dirname(__FILE__) . '/class.protector.inc.php');
$p = new protector();
// Path where the files to download actually are
$p->setPath('/tmp/test/');
// If you like, set user agents known as bots.
// See constructor of class about the format of the array
// $p->setAgents(array(
// ));
// If you like, set hosts known as bots
// See constructor of class about the format of the array
// $p->setHosts(array(
// ));
// If you like, you can use redis for memcaching to detect harvesting:
// $p->setPredis(
// '/tmp/libs/predis/Predis.php',
// 5 * 60, // all visits of more than 5 minutes back will be ignored
// 5 // if >5 visits during the timeframe above (5 minutes), then we have found a bot
// );
// In this case, pay special attention to line 240 in the class file!
$p->process();
?>
|