If you use the httpd Web server, a database and a server-side programming language like PHP, you can easily track the downloads by making requests for downloading a deb file redirect to a script that counts the number of downloads and then sends the requested deb file.
First, create a database to hold the number of downloads. The rows that you will need are: id (integer), debfile (text) and downloads (integer).
Next, you'll create a script in a server-side language that will set the following headers:
* Content-Type: application/octet-stream
* Content-Length: (the size of the deb in bytes)
* Content-Disposition: inline; attachment=(filename of the deb)
Then it will read the “file” GET parameter, increment the counter for the file in the database, creating a new row if one doesn't already exist and sends the file to the user's device. Don't forget to turn off error reporting in your programming language or you might get corrupt files. And be absolutely sure that the name of the file does not contain a back or forward slash, just in case someone's trying to see a system file on your server. I can help you write this script if your server supports PHP and MySQL or SQLite.
Now, create a file called .htaccess (with the period at the start of the name) and enter this in:
And save that in your Website root. If you already have a htaccess file, paste that code at the bottom of it.
RewriteRule ^/cydia/downloads/(.*)$ /cydia/dltracker.php?file=$1 [L,QSA]
Change /cydia/downloads to the folder that your deb files are in and /cydia/dltracker.php to the location of the download tracking script. This will simply forward all requests to download a deb file to the script.
Now try downloading a package from your repo in Cydia. Check your database to see if a row was created for the download. If it worked, you can proceed to making a list of top downloads. With MySQL, you can use a command similar to this one:
And then you need to print out a HTML table of the results given by the database.
SELECT * FROM cydia_downloads SORT BY downloads ASC LIMIT 20