Free upload voting system with multiple user files without database (2)

Source: Internet
Author: User
Tags continue explode file size fread header trim
This is the system's download.php, mainly responsible for downloading and counting, where the file format is described in the comments.


<?php
Incoming num is the file number to download, col= the columns to download
IP does not timeout download times plus a

File format
0 Number <1 author <2 file location <3 Polling Count <4 introduction <5 file size <6 file download times
IP file Format address: item: Time


$uploadto = ". /uploadfile/". $col." /";//uploaded to subdirectories
$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 ";//Download IP file
$overtime =4;//Timeout Hour

$goback = "<br><br><br><br><center> system will return ....</center><script> in 3 seconds settimeout (' location.href= "view.php?col=". $col. "" ", 3000) </script>;
$recfile = $uploadto. $col. " LST ";


Remove IP file
$fp = @fopen ($ipfile, "R") or Die ("Sorry this vote is not legal". $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 <sizeof ($ip _times); $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]. "|");
}
}
Echo $ipinfo;
if (Strstr ($ipinfo, $REMOTE _addr.: ". $num))
{
$fp = @fopen ($ipfile, "w") or Die ("error occurred". $goback);
Fwrite ($fp, $ipinfo);
Fclose ($FP);
$firstdown =0;//First time download
}
else{
$firstdown =1;//is not the first time to download

$ipinfo = $ipinfo. $REMOTE _addr ":". $num. ":" $abstime. "|";

$fp = @fopen ($ipfile, "w") or Die ("error occurred". $goback);
Fwrite ($fp, $ipinfo);
Fclose ($FP);
}

IP Judgment End







for ($i =0; $i <100 &&!file_exists ($recfile); $i + +);
if ($i ==99) die ("System error". $goback);


$fp = @fopen ($recfile, "R") or Die ("Sorry not valid". $goback);
$info =explode (">", Fread ($fp, FileSize ($recfile));
Fclose ($FP);
Copy ($recfile, $recfile. " Bak ");
Unlink ($recfile);







for ($i =0; $i <sizeof ($info); $i + +) {

$items =explode ("<", $info [$i]);
if (!trim ($items [0])) continue;
if (Trim ($items [0]) = = $num) {//items to download
if ($firstdown)
$items [6]++;
$filepath = $uploadto. $items [2];
$info [$i]=implode ("<", $items);
Break
}


}

$writetofile =implode (">", $info);

if (! $fp =fopen ($recfile, "w")) {
Copy ($votefile. ". Bak ", $votefile);
Die ("error". $goback);
}



for ($i =0; $i <sizeof ($info); $i + +) {
if (Trim ($info [$i])!= "") fputs ($fp, Trim ($info [$i]. " > "));
}
Fclose ($FP);


echo "echo "<link rel= ' stylesheet ' href= '. /css/eccct.css ' >echo "<body class=tb >";
echo "<div >";
echo "<br><br><br>";
echo "<div class= ' values ' > your browser will automatically download </div> in three seconds";
echo "<br><br><br>";
echo "<div class= ' values ' > or click <a href= '". $filepath. "' > here </a> download </div> ";
echo "<br><br><br>";
echo "</div>";

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



?>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.