 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
12-21-2007, 08:57 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 6
Thanks: 1
|
No idea where to start.
I have no idea where to start a little script of php that counts the number of times my wordpress theme has been downloaded.
Any ideas?
Thanks,
Damien
|
|
|
|
12-21-2007, 09:23 PM
|
#2 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 14
Thanks: 0
|
Are you wanting the php script to record each time it is downloaded AND report how many times that is? Or are you wanting the script to use your webhosts logs to report how many times it has been downloaded?
|
|
|
|
12-21-2007, 09:30 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Proably the first..
|
|
|
|
12-21-2007, 09:32 PM
|
#4 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 14
Thanks: 0
|
Quote:
Originally Posted by Tanax
Proably the first..
|
That's what I'm guessing, but dont want to start giving out suggestions until I know for sure which direction he is headed in. 
|
|
|
|
12-21-2007, 09:35 PM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by gilzow
That's what I'm guessing, but dont want to start giving out suggestions until I know for sure which direction he is headed in. 
|
Heh, I hear ya
Based on that he said that he wanted to COUNT, and not FETCH; guessing that he wants to store each time someone downloads, is a pretty good guess  
|
|
|
|
12-21-2007, 09:38 PM
|
#6 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 14
Thanks: 0
|
Quote:
Originally Posted by Tanax
Heh, I hear ya
Based on that he said that he wanted to COUNT, and not FETCH; guessing that he wants to store each time someone downloads, is a pretty good guess  
|
good point. though, if he just wants a raw count, he doesnt need php to do that. He could simply use his weblogs and some web log parsing tools to get the number.
|
|
|
|
12-21-2007, 09:47 PM
|
#7 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by gilzow
good point. though, if he just wants a raw count, he doesnt need php to do that. He could simply use his weblogs and some web log parsing tools to get the number.
|
Yeap, you'll just have to wait for him to reply until you can help him with his script 
|
|
|
|
12-22-2007, 03:29 AM
|
#8 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
The best way is to mimic the download process, and load in the file using the header function in PHP. I wrote a little script for someone else on TalkPHP like this not so long ago, but I was unable to find it with a quick search a moment ago. But that way you can then put all the PHP into the download process, so you know when the user is presented with the download prompt, that you can increment the download count, too.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
12-22-2007, 05:23 AM
|
#9 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 6
Thanks: 1
|
I need it for a wordpress theme. So I can post on the site
"x,xxx downloads and counting"
you know?
|
|
|
|
12-22-2007, 01:37 PM
|
#10 (permalink)
|
|
The Contributor
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
|
Quote:
Originally Posted by damien
I need it for a wordpress theme. So I can post on the site
"x,xxx downloads and counting"
you know?
|
Wordpress Download Monitor Plugin v1.6
From their site:
Quote:
this plugin is to keep your website downloads organised, and provide means to monitor the amount of downloads a file has (...)
To show download links, use the following tags:
Link/hits - [download#id] Output example: <a href="download.php?id=1" title="Version 1 downloaded 10 times">Download title (10)</a>
Hits only - [download#id#hits] Output example: 10
|
|
|
|
|
12-22-2007, 03:59 PM
|
#11 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 6
Thanks: 1
|
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.
|
|
|
|
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.
|
|
|
|
|
The Following User Says Thank You to Matt83 For This Useful Post:
|
|
12-22-2007, 05:07 PM
|
#13 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 6
Thanks: 1
|
Matt83, you are a godsend. Thank you so much.
|
|
|
|
12-23-2007, 01:55 AM
|
#14 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Posts: 6
Thanks: 1
|
What about the "location part" of the count.php
I just have the zip in the pub_html folder of my site
so is it okay?
|
|
|
|
12-23-2007, 03:30 PM
|
#15 (permalink)
|
|
The Contributor
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
|
Quote:
Originally Posted by damien
What about the "location part" of the count.php
I just have the zip in the pub_html folder of my site
so is it okay?
|
Yes, though i would recommend you that you use the full path to the file, like:
PHP Code:
header('Location: http://www.yourdomain.com/something.zip');
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|