Home > Backend Development > PHP Tutorial > Multi-user file free upload voting system without database (2)_PHP tutorial

Multi-user file free upload voting system without database (2)_PHP tutorial

WBOY
Release: 2016-07-21 16:02:53
Original
667 people have browsed it

This is the download.php of this system, which is mainly responsible for downloading and counting. The file format is explained in the comments.



// Pass in num as 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 <2 File location<3 Voting count<4 Introduction<5 File size<6 Number of file downloads
//ip file format Address: Project: Time


$uploadto= "../uploadfile/".$col."/";//The 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";//For downloading ip file
$overtime=4;//Timeout time hours

$goback="



The system will wait in 3 seconds Then return....
<script>setTimeout('location.href="view.php?col=".$col.""',3000)</script>";
$recfile=$uploadto.$col.".lst";


//Take out the ip file
$fp=@fopen($ipfile,"r") or die("Sorry about that 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].';');

if($temp<$overtime&&$temp>=0){

$ipinfo.=($ip_times[$ i]."|");
                                                                                                                                       ;
$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 it's not legal".$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);                                                      ">",$info);

if(!$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 "
";
echo "";
echo "
";
echo "


";
echo "
您的浏览器会在三秒钟后自动下载
";
echo "


";
echo "
或者点击此处下载
";
echo "


";
echo "
";

//echo $HTTP_ENV_VARS["PATH_INFO"];
//echo "<script>window.location.href='".$filepath."';window.close();</script>";

echo "";

//header("Content-type: application/.rar");

//header("Content-Disposition: attachment; filename=".$filepath);
//Header("Location: ".$filepath);
//header("Content-Description: PHP3 Generated Data



?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316394.htmlTechArticle这是本系统的download.php,主要负责下载和记数,其中文件格式均在注释中说明. html ?php //传入num为要下载的文件号,col=要下载的分栏 //ip不超时...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template