View Single Post
Old 12-22-2007, 04:08 PM   #12 (permalink)
Matt83
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

Quote:
Originally Posted by damien View Post
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.
  1. hitsCount.txt ( CHMOD to 777 )
  2. count.php
  3. The Theme file ( something.zip )
  4. 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

Code:
1
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).
Attached Files
File Type: zip count-download.zip (754 Bytes, 6 views)
__________________
http://www.mattvarone.com

Last edited by Matt83 : 12-22-2007 at 04:41 PM.
Matt83 is offline  
Reply With Quote
The Following User Says Thank You to Matt83 For This Useful Post:
damien (12-22-2007)