I've just made this download counter, to make it work, all you have to do is make a blank counter.txt and CHMOD it to 777. This ups the number in counter.txt and then redirects you to the file you wanted to download.
Next make a file called redir.php and put the following in it:PHP Code:<?php
$filename = "counter.txt"; /* Set variable "$filename" as counter.txt */
$handle = fopen($filename, "r+"); /* Sets the $handle variable to open the "$filename" variable */
$nexturl = "http://www.technoteens.net/Habbox%20Baby.mp3"; /* Sets the URL to go to after counting */
$line = fgets($handle, 20); /* Gets the first line from the file */
$line += 1; /* Increases the line by one */
rewind($handle); /* Goes back to the start of the file */
fwrite($handle, $line); /* Performs the increads */
fclose($handle); /* Closes the file on the server */
header("location: $nexturl"); /* Redirects to the $nexturl file */
?>
Then you can easily make a page that displays the current stats, make a file called display.php, and put in the following contents:PHP Code:<?php $countingfile = "Habbox Baby.mp3"; ?>
If you put all that together into a directory, it will all work well! To view a demo of this in action click here. If you want you can make a full center out of this and you can make it display stats for all of your downloads.HTML Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Hit Counter</title> <style type="text/css"> <!-- body,td,th { color: #FFFFFF; } body { background-color: #00ccff; } .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; } --> </style></head> <body> <?php include 'redir.php'; ?> <p> </p> <p> </p> <p align="center" class="style1">Hits on <?php echo $countingfile ?><br /> <br /> <center><span class="style1"><?php // set file to read $file = 'counter.txt'; // open file $fh = fopen($file, 'r') or die('Could not load counter.'); // read file contents $data = fread($fh, filesize($file)) or die('Could not fetch counter contents.'); // close file fclose($fh); // print file contents echo $data; ?></span></center> </p> </body> </html>
[b]To customize this all you have to do is change the following variables:
$nexturl - Change this to the URL of your download
$countingurl - Make this the name of the file you are counting the hits to






Reply With Quote



