Free uploading of multi-user files without databases to the voting system (2) _ PHP Tutorial

Source: Internet
Author: User
Free uploading of multi-user files without databases to the voting system (2 ). This is the download.php of the system. The owner is responsible for downloading and recording. the file format is illustrated in. html? The input num in php indicates the file number to be downloaded. the ip address of the column to be downloaded by col does not time out. this is the download of the system. php is mainly responsible for downloading and recording data. the file format is described in the annotations.



// Input num as the file number to be downloaded, col = column to be downloaded
// Ip address no-timeout download count plus one

// File format
// 0 No. <1 Author <2 file location <3 voting count <4 Introduction <5 file size <6 file downloads
// Ip file format address: Project: Time


$ Uploadto = "../uploadfile/". $ col. "/"; // subdirectory to which the file is uploaded
$ Cgiroot = "http://eccct.51.net/cgi-bin/"; // add the current directory to the host

$ Pathtemp = explode ("/", $ HTTP_ENV_VARS ["PATH_INFO"]);
$ Pathtemp [sizeof ($ pathtemp)-1] = "";
$ Cgiroot = "http: //". $ HTTP_HOST.implode ("/", $ pathtemp); // add the current directory to the host

$ Ipfile = $ uploadto. $ col. ". ipd"; // download the ip address file
$ Overtime = 4; // timeout Hour

$ Goback ="



The system will return in 3 seconds .... Script setTimeout ('location. href = "view. php? Col = ". $ col." "', 3000) script";
$ Recfile = $ uploadto. $ col. ". lst ";


// Retrieve the ip file
$ Fp = @ fopen ($ ipfile, "r") or die ("Sorry, this vote is invalid". $ goback );
$ Ipinfo = fread ($ fp, filesize ($ ipfile ));
Fclose ($ fp );
Unlink ($ ipfile );
$ Times = getdate ();
$ Abstime = $ times ["yday"]. sprintf ("% 02d", $ times ["hours"]);
// Absolute time




// Remove the expired ip address
$ 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]. "| ");
}
}
// Echo $ ipinfo;
If (strstr ($ ipinfo, $ REMOTE_ADDR. ":". $ num ))
{
$ Fp = @ fopen ($ ipfile, "w") or die ("error". $ goback );
Fwrite ($ fp, $ ipinfo );
Fclose ($ fp );
$ Firstdown = 0; // The first download
}
Else {
$ Firstdown = 1; // not the first download

$ Ipinfo = $ ipinfo. $ REMOTE_ADDR. ":". $ num. ":". $ abstime. "| ";

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

// Ip end 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 invalid". $ 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) {// The Project to be downloaded
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 02". $ goback );
}



For ($ I = 0; $ I If (trim ($ info [$ I])! = "") Fputs ($ fp, trim ($ info [$ I]. "> "));
}
Fclose ($ fp );


Echo" ";
Echo" ";
Echo"";
Echo"

";
Echo"


";
Echo"

Your browser will automatically download in three seconds

";
Echo"


";
Echo"

Or click here to download

";
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



?>

Forbidden. html? Php // input num as the file number to be downloaded, col = column to be downloaded // ip does not time out...

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.