12-22-2007, 04:08 PM
|
#12 (permalink)
|
|
The Contributor
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
|
Quote:
Originally Posted by damien
thanks, but -- this download counter will be on a static site, not the actual wordpress theme. You see, users will go to the download page, download the theme, and I want it counted there.
|
ok, this is a simple solution, i hope it suits to your needs.
Its based on 4 files.
- hitsCount.txt ( CHMOD to 777 )
- count.php
- The Theme file ( something.zip )
- Your index.php file
count.php:
PHP Code:
<?php $szFile = 'hitsCount.txt'; $aData = @file($szFile); $aData = $aData[0]; if($pHandle = @fopen($szFile, 'w')) { $aData = intval($aData); $aData++; fwrite($pHandle, $aData); fclose($pHandle); } header('Location: something.zip'); ?>
hitsCount.txt:
Set to 1 to prevent an error
index.php (example):
You can use, readfile or include to fetch the stats: <?php readfile("hitsCount.txt"); ?>
HTML Code:
<p><a href="count.php" title="Download Theme">Download This Theme</a><br/>
<small>This theme has been downloaded <strong><?php readfile("hitsCount.txt"); ?></strong> Time(s).</small></p>
This would give something like:
Quote:
Download This Theme
This theme has been donwloaded 2 Time(s).
|
Last edited by Matt83 : 12-22-2007 at 04:41 PM.
|
|
|
|