Archive

Tag Archives: php

Recently I decided, to redesign the site’s downloads system. Originally I was using the excellent PHP Click Counter from PHPJunkyard to count downloads. However the script was far from perfect and presented problems each time I released a new download. For the revamp I decided I wanted to use MySQL databases to store the data. Unfortunately I could not find a script which would do exactly what I required. So I made my own.

Three hours later the PHP and MySQL Link/Download Tracker was born.

What it does: The script will count link clicks and store its results in a database.

Setup:

  1. Create a new database using you web hosts control panel
  2. Select your new database in Phpmyadmin
  3. Go to the query tab and paste the following in the box:
    CREATE TABLE `Data` (
    `id` VARCHAR( 50 ) NOT NULL ,
    `count` INT( 10 ) NOT NULL default '0' ,
    PRIMARY KEY ( `id` )
    ) ENGINE = MYISAM ;
  4. Open up config.php and change the database values to match your settings
  5. Open up get.php and change the id’s and url’s in the links array to reflect the id’s you want to use. See below for an example:
    $links = array(
    "mydownload1" => "http://some.site/mydownload1.zip",
    "mydownload2" => "http://some.site/mydownload2.zip"
    );

    So if your download was called mytest, you would change mydownload1 to mytest and set the url to the download url of the file. You can add as many id’s as you wish.

  6. Upload get.php, show.php and config.php to your server
  7. Done

Usage:

The script is called like this: /get.php?id=mydownload1

So instead of linking to /mydownload1.zip, link to /get.php?id=mydownload1

To show your download stats simply call show.php rather than get.php

Download
Source

Update: See here.