okay i run a small site, where i offer downloads to visitors.
i have a rule in place, 2 downloads per visitor, well, some visitors choose to ignore this rule, and download up to a 100 files at a time, and it really impacts my server.
i use a standard php script that downloads the actually files, you can find it on php.net in fopen and fread function list, i have seen this thousands of other places, so i assume it is the status quo. it has been slightly modified for some of my security settings.
well here is the part of the code that controls the removal of the number of downloads from the database when a user downloads a file successfully or cancel it out:
if($numdown == 2)
{
echo "you have 2 downloads started already, please wait till they are done to continue.";
exit;
}
else
{
ignore_user_abort(TRUE);
while(TRUE)
{
$fp = fopen($file, 'rb');
//seek to start of missing part
fseek($fp, $seek_start);
//start buffered download
while(!feof($fp))
{
print(fread($fp, 1024*8));
flush();
ob_flush();
}
echo ".";
flush;
if (connection_status()!=0)
{
}
else
{
include 'repository/config.php';
$set = mysql_query("update members_downloads set downloads=downloads-1 where membername='$username");
fclose($fp);
exit;
}
}
}
the problem i am currently having, some of my users are on dial up, and they time out sometimes, and the script takes forever, like 2 hours, to remove something that has timed out, is there any way to make this process faster or easier?
thanks in advanced,
transhour