Zend - The PHP Company




Counters

Add Code


download counter v1.0  

Type: application
Added by: _The_Crow_
Entered: 06/07/2000
Last modified: 08/12/1999
Rating: *** (3 votes)
Views: 14387
A download counter for your files, check for more info the example.php. Don't use mySQL, this is appropriated for small sites. Tested under Apache 1.3.12 / PHP 4.0.1 / Linux 2.2.16 and Win98.


<?
/*                               __                         
//   .-----.-----.-. .-.-----.--|  |-----.-----.-----.-----.
//   |__ --|  -  | |_| |     |  _  |  .__|  - _|  -  |     |
//   |_____|_____|_____|__|__|_____|__|  |_____|_| |_|_|||_|
//   . ..: s o u n d r e a m   o r g a n i z a t i o n :.. .
//                      . ..Coding Division.. .
//
//  PHP Script..: Download Counter
//  Made By.....: |The-Crow| - thecrow@impulsive.org
//  Site........: http://soundream.planet-d.net
*/

//--------------------------------------------------------//
//              PLEASE DEFINE THE VARIABLES               //
//--------------------------------------------------------//

  
$extension ".zip";         //leave this blank if you have various extensions.
  
$counterdir "counters/";     //change this if you want other directory for the counter files.

  
$textfont "Verdana,Arial";  //text font for the error msg

//--------------------------------------------------------//
//             DO NOT EDIT ANYTHING FROM HERE             //
//--------------------------------------------------------//

  
if (file_exists("$get$extension"))
       {
        
header("location: $get$extension"); // download the file [download.php?get=name_of_file]
    
$file fopen("$counterdir/$get$extension.txt","r+");  // download counter
    
$count fread($filefilesize("$counterdir/$get$extension.txt"));
    
fclose($file);
    
$count += 1;
    
$file fopen("$counterdir/$get$extension.txt","w+");
    
fputs($file$count);
    
fclose($file);
       }
  else     echo 
"<font face=$textfont size=2>";
    echo 
"<center><br><br>That file [<b>$get$extension</b>] is not available for download.<br>";
    echo 
"Please contact the server administrator <a href='mailto:$SERVER_ADMIN'>$SERVER_ADMIN</a>.";

?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories