limiting any given ip to only 2 files at a time could be weird for certain domains. some colleges, for instance, might have hundreds or thousands of users all behind a single IP address.
if that doesn't bother you, you might be able to do it with a php script like this:
step 1:
put the files OUTSIDE your html directory so that they are not accessible to a browser but are accessible to your php script. otherwise, a user might just figure out where they are located and download them directly, bypassing your script.
step 2:
set up a database to store download-related information like this
download_table
id <- integer primary key
user_ip <- varchar field of length 15
step 3:
set up your php script to fetch the files and echo them to the user. something like this
<?
// downloader script
// this is where your files are located...it should outside your public_html directory lest users bypass your download script
define('FILE_DIRECTORY', '/home/path/to/files');
$filename = FILE_DIRECTORY . '/file.avi';
$fp = fopen($filename, 'rb');
or die('could not open file');
$user_ip = $_SERVER['REMOTE_ADDR'];
$sql = "SELECT COUNT(*) FROM download_table WHERE user_ip='$user_ip'";
$result = mysql_query($sql)
or die('query failed:' . mysql_error());
$row = mysql_fetch_assoc($result)
or die('query returned nothing.');
if ($row >= 2) {
die("Sorry, but any given IP address may only download two files at a time");
}
$sql = "INSERT INTO download_table SET user_ip=" . $user_ip;
$result = mysql_query($sql)
or die('query to insert failed:' . mysql_error());
$record_id = mysql_insert_id();
// you'll need to figure out what the correct mime type is here
// i don't know much about mimetypes and headers
header('Content-type: video/x-msvideo');
header("Content-Length: " . filesize($filename));
fpassthru($fp);
$sql = "DELETE FROM download_table WHERE id=" . $record_id;
mysql_query($sql)
or die('delete query failed');
echo 'download complete';
?>
I have no idea if this will do what you want. You'd have to test it with some large files.