<?
// Download Manager 1.0 (c)2000 Blake McDonald (webmaster@dark-library.com)
$download_log = "log.txt";
$webmaster_email = "Email@address.com";
$url_to_admin = "
http://www.full_url_to.com/admin.php3";// enter "auto" or "manual".
// auto makes it automaticly email you of broken links, manual tells the downloader to email you.
$if_broken = "auto";
#####
// sees if file exists
$exists = @fopen($url,"r");
if($exists){
$log_lines = file($download_log);
$total_lines = count($log_lines);
$dl_time = time();
for($i=0; $total_lines > $i; $i++){
$split = explode("||",$log_lines[$i]);
if($url == $split[1]){
$fp = fopen($download_log, "r");
flock($fp,1);
$x = fread($fp, filesize($download_log));
flock($fp,3);
fclose($fp);
$add = $split[0]+1;
$fp = fopen($download_log, "w");
$x = str_replace("$split[0]||$split[1]||$split[2]||$split[3]||","$add||$split[1]||$split[2]||$dl_time||", $x);
flock($fp,2);
$fw = fwrite($fp, $x);
flock($fp,3);
fclose($fp);
$write = 1;
}
}
if($write != 1){
$fp = fopen($download_log, "a");
flock($fp,2);
$fw = fwrite($fp, "1||$url||$dl_time||$dl_time||\n");
flock($fp,3);
fclose($fp);
}
header("location: $url");
} else
// file doesn't exist error
{
if($if_broken == "auto"){
mail("$webmaster_email", "Broken Link!", "This link was found to be broken:
$url
$HTTP_REFERER
-
$url_to_admin", "From: <$webmaster_email>");
echo "ERROR! This links destination can't be found! The webmaster has been notified of this and it will be fixed shortly.<br>";
} else {
echo "ERROR! This links destination can't be found! Please contact the webmaster about this.<br>";
echo "<a href=\"mailto:$webmaster_email\">$webmaster_email</a>";
}
}
?>