TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack (1) Thread Tools Search this Thread Display Modes
Old 12-21-2007, 08:57 PM   1 links from elsewhere to this Post. Click to view. #1 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 6
Thanks: 1
damien is on a distinguished road
Default 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
damien is offline  
Reply With Quote
Old 12-21-2007, 09:23 PM   #2 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 14
Thanks: 0
gilzow is on a distinguished road
Default

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?
gilzow is offline  
Reply With Quote
Old 12-21-2007, 09:30 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Proably the first..
Tanax is offline  
Reply With Quote
Old 12-21-2007, 09:32 PM   #4 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 14
Thanks: 0
gilzow is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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.
gilzow is offline  
Reply With Quote
Old 12-21-2007, 09:35 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by gilzow View Post
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
Tanax is offline  
Reply With Quote
Old 12-21-2007, 09:38 PM   #6 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 14
Thanks: 0
gilzow is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
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.
gilzow is offline  
Reply With Quote
Old 12-21-2007, 09:47 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by gilzow View Post
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
Tanax is offline  
Reply With Quote
Old 12-22-2007, 03:29 AM   #8 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-22-2007, 05:23 AM   #9 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 6
Thanks: 1
damien is on a distinguished road
Default

I need it for a wordpress theme. So I can post on the site
"x,xxx downloads and counting"

you know?
damien is offline  
Reply With Quote
Old 12-22-2007, 01:37 PM   #10 (permalink)
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
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
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote
Old 12-22-2007, 03:59 PM   #11 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 6
Thanks: 1
damien is on a distinguished road
Default

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.
damien is offline  
Reply With Quote
Old 12-22-2007, 04:08 PM   #12 (permalink)
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)
Old 12-22-2007, 05:07 PM   #13 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 6
Thanks: 1
damien is on a distinguished road
Default

Matt83, you are a godsend. Thank you so much.
damien is offline  
Reply With Quote
Old 12-23-2007, 01:55 AM   #14 (permalink)
The Wanderer
 
Join Date: Dec 2007
Posts: 6
Thanks: 1
damien is on a distinguished road
Default

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?
damien is offline  
Reply With Quote
Old 12-23-2007, 03:30 PM   #15 (permalink)
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
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'); 
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.talkphp.com/absolute-beginners/1790-no-idea-where-start.html
Posted By For Type Date
TalkPHP - Powered by vBulletin This thread Refback 12-22-2007 04:18 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:38 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design