Post Reply 
looking for a PHP download script
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1294
Offline
Post: #17
RE: looking for a PHP download script
Better:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
	switch($_GET["file"]) {
		case "DF001.zip":
		case "DF002.zip":
			$hitsfile = substr($_GET["file"], 0, -4) . '.txt';
			if($fp = @fopen($hitsfile, 'r+')) {
				flock($fp, LOCK_EX); // prevent two simultaneous downloads corrupting the file
				$hits = intval(fgets($fp)) +1;
				rewind($fp);
			} else {
				// file doesn't exist, create it
				$hits = 1;
				($fp = @fopen($hitsfile, 'w')) or die('Can\'t write file');
				flock($fp, LOCK_EX);
			}
			fputs($fp, strval($hits));
			flock($fp, LOCK_UN);
			fclose($fp);
			
			include 'get.php';
			
			break;
		default:
			header('HTTP/1.1 404 Not Found');
			
	}

?>

14/12/2010 08:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
looking for a PHP download script - lembas - 14/12/2010, 12:52 PM
RE: looking for a PHP download script - ZiNgA BuRgA - 14/12/2010 08:31 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: