This is the download.php of this system, which is mainly responsible for downloading and counting. The file format is explained in the comments.
//Input num is the file number to be downloaded, col= Column to be downloaded
//Add one to the number of IP downloads without timeout
//File format
//0Number<1 Author<2File location<3Vote count<4Introduction<5File size< 6 Number of file downloads
//ip file format Address: project: time
$uploadto="../uploadfile/".$col."/";//Subdirectory uploaded to
$cgiroot="http:// eccct.51.net/cgi-bin/"; //Host plus current directory
$pathtemp=explode("/",$HTTP_ENV_VARS["PATH_INFO"]);
$pathtemp[sizeof($pathtemp)-1]= "";
$cgiroot="http://".$HTTP_HOST.implode("/",$pathtemp);//Host plus current directory
$ipfile=$uploadto.$col.".ipd";// IP file for download
$overtime=4;//Timeout in hours
$goback="
The system will return after 3 seconds.. ..<script>setTimeout('location.href="view.php?col=".$col.""',3000)</script>";
$recfile=$uploadto. $col.".lst";
//Get the ip file
$fp=@fopen($ipfile,"r") or die("Sorry, the vote is illegal".$goback);
$ipinfo=fread($ fp,filesize($ipfile));
fclose($fp);
unlink($ipfile);
$times=getdate();
$abstime=$times["yday"].sprintf("%02d", $times["hours"]);
//Absolute time
//Remove the timeout ip
$ip_times=explode("|",$ipinfo);
$temp="";
$ipinfo="";
for($i=0;$i
$ip=explode(":",$ip_times[$i]);
if($ip[1]==" "||$ip[0]==""||$ip[2]=="") continue;
eval ('$temp='.$abstime.'-'.$ip[2].'; ');
strstr($ipinfo,$REMOTE_ADDR.":".$num))
{
$fp=@fopen($ipfile,"w") or die("An error occurred".$goback);
fwrite($fp, $ipinfo);
fclose($fp);
$firstdown=0;//First download
}
else{
$firstdown=1;//Not the first download
$ipinfo=$ipinfo.$REMOTE_ADDR .":".$num.":".$abstime."|";
$fp=@fopen($ipfile,"w") or die("An error occurred".$goback);
fwrite($fp ,$ipinfo);
fclose($fp);
}
//End of ip judgment
for($i=0;$i<100 && !file_exists($recfile);$i++);
if($i= =99) die("System error 00".$goback);
$fp=@fopen($recfile,"r") or die("Sorry, illegal".$goback);
$info=explode("> ;",fread($fp,filesize($recfile)));
fclose($fp);
copy($recfile,$recfile.".bak");
unlink($recfile);
for($i =0;$i $items=explode("<",$info[$i]);
if(!trim($items[0])) continue;
if(trim($items[0])==$num){//Items to be downloaded
if($firstdown)
$items[6]++;
$filepath=$uploadto.$items[2] ;
$info[$i]=implode("<",$items); $ fp=fopen($recfile,"w")){
copy($votefile.".bak",$votefile);
die("Error 02".$goback);
}
for($i=0; $i if(trim($info[$i])!="") fputs($fp,trim($info[$i].">")) ;
}
fclose($fp);
echo "";
echo "< ;body class=tb >";
echo "";
echo "
";
echo "
Your browser will Automatically download
";
echo "
";
echo "
";
echo "
";
echo "
";
//echo $ HTTP_ENV_VARS["PATH_INFO"];
//echo "<script>window.location.href='".$filepath."';window.close();</script>";
echo " body>";
//header("Content-type: application/.rar");
//header("Content-Disposition: attachment; filename=".$filepath);
//Header("Location: " .$filepath);
//header("Content-Description: PHP3 Generated Data
?>
The above has introduced the free multi-user file upload voting system 2 without a database, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.