473,779 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

download counter?

Hi,

I'm trying to create a download counter for individual files on a web
site and I'm not sure how to do this. Right now I'm using Webalizer
to just read the log files and see how many times the files I'm
interested in were downloaded. The problem is Webalizer breaks it up
by month and I want a running total. I'd also like to see the counts
without having to log in to Webalizer in the first place. Not that
logging in or adding the results is too difficult, but it would be
nice if I could just put a little number on the web site so when I go
to the site I can imediately see the download counts.

The first thing I thought of was accessing the log files via PHP and
reading the data out of there. However because the log files get
broken up, zipped, and a new one started after they reach a certain
size I'm afraid this will be too complicated and may put too much
extra strain on the server if this is done too often.

Also, what's the best way to read log files with PHP anyway?

Any ideas?

Thanks.

->Later.....Spic e

Feb 7 '07 #1
12 2915
I think you can make simple php application for count the download,
like:
when people click http://host/download.php?file=xyz.zip, the
download.php will increase the counter and the people will forwarded
into file xyz.zip

these are not the code but the algorithm:
1. create mysql table
create table counter (filename varchar(100), counter int);
insert into counter values ('xyz.zip', 0);
2. create download.php file:
//increase the counter table
update counter set counter = counter + 1 where filename like
'$_GET[file]'
//forward to file
header ("location: xyz.zip");

----
http://www.mastervb.net/phpbooks -- recommended php books
http://ascii.mastervb.net -- ascii art generator

On Feb 8, 3:02 am, "devospice" <s...@suddendea th.orgwrote:
Hi,

I'm trying to create a download counter for individual files on a web
site and I'm not sure how to do this. Right now I'm using Webalizer
to just read the log files and see how many times the files I'm
interested in were downloaded. The problem is Webalizer breaks it up
by month and I want a running total. I'd also like to see the counts
without having to log in to Webalizer in the first place. Not that
logging in or adding the results is too difficult, but it would be
nice if I could just put a little number on the web site so when I go
to the site I can imediately see the download counts.

The first thing I thought of was accessing the log files via PHP and
reading the data out of there. However because the log files get
broken up, zipped, and a new one started after they reach a certain
size I'm afraid this will be too complicated and may put too much
extra strain on the server if this is done too often.

Also, what's the best way to read log files with PHP anyway?

Any ideas?

Thanks.

->Later.....Spic e

Feb 8 '07 #2
"lorento" <la**********@y ahoo.compíse v diskusním príspevku
news:11******** *************@j 27g2000cwj.goog legroups.com...
>I think you can make simple php application for count the download,
like:
when people click http://host/download.php?file=xyz.zip, the
download.php will increase the counter and the people will forwarded
into file xyz.zip

these are not the code but the algorithm:
1. create mysql table
create table counter (filename varchar(100), counter int);
insert into counter values ('xyz.zip', 0);
2. create download.php file:
//increase the counter table
update counter set counter = counter + 1 where filename like
'$_GET[file]'
//forward to file
header ("location: xyz.zip");
Better then redirecting is to read file in php script, send to browser and
write to sql table after a file is complete send.

1. open file
2. read file and send to browser until EOF
3. increase counter in DB

This avoid a situation when user cancel download.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Feb 8 '07 #3
On Feb 7, 11:03 pm, "lorento" <laurente1...@y ahoo.comwrote:
I think you can make simple php application for count the download,
like:
when people clickhttp://host/download.php?fi le=xyz.zip, the
download.php will increase the counter and the people will forwarded
into file xyz.zip
That's what I'm doing for some other files on the site. I'm just
storing the count in a MySQL table.

I can't do that with these files though, because they're MP3s from a
podcast. I can do that with the direct links on the web page, but
people who download the files via iTunes will bypass that link. And
changing the RSS feed to point to the PHP page instead of the MP3 page
breaks iTunes.

- Tom

Feb 9 '07 #4
Better then redirecting is to read file in php script, send to browser and
write to sql table after a file is complete send.

1. open file
2. read file and send to browser until EOF
3. increase counter in DB
Just in case you don't see my other reply, the problem with this is
it's a podcast. And pointing the RSS feed to a PHP document instead
of directly at the MP3 breaks iTunes.

- Tom

Feb 9 '07 #5
Rik
On Fri, 09 Feb 2007 16:33:48 +0100, devospice <sp***@suddende ath.org
wrote:
On Feb 7, 11:03 pm, "lorento" <laurente1...@y ahoo.comwrote:
>I think you can make simple php application for count the download,
like:
when people clickhttp://host/download.php?fi le=xyz.zip, the
download.php will increase the counter and the people will forwarded
into file xyz.zip

That's what I'm doing for some other files on the site. I'm just
storing the count in a MySQL table.

I can't do that with these files though, because they're MP3s from a
podcast. I can do that with the direct links on the web page, but
people who download the files via iTunes will bypass that link. And
changing the RSS feed to point to the PHP page instead of the MP3 page
breaks iTunes.
Why does it break things? It shouldn't.

Then again, maybe an easier solution is just to parse the access log of
the server. Or maybe a javascript counter, allthough somewhat unreliable..
--
Rik Wasmus
Feb 9 '07 #6
devospice wrote:
>Better then redirecting is to read file in php script, send to browser and
write to sql table after a file is complete send.

1. open file
2. read file and send to browser until EOF
3. increase counter in DB

Just in case you don't see my other reply, the problem with this is
it's a podcast. And pointing the RSS feed to a PHP document instead
of directly at the MP3 breaks iTunes.

- Tom
Tom,

It shouldn't if you send the correct header information. The fact it's
coming from PHP should be completely transparent.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 9 '07 #7
It shouldn't if you send the correct header information. The fact it's
coming from PHP should be completely transparent.
It is. The PHP feed works fine. (http://www.thefump.com/cast.php)
But pointing the link tag to a PHP file instead of an audio file
generates a "this feed is not valid" error in iTunes.

->Later.....Spic e

Feb 13 '07 #8
Why does it break things? It shouldn't.

The link tag has to point to an MP3 or AAC file in order for iTunes to
recognize it and allow the download. Otherwise it assumes you
accidentally tried to subscribe to a non-audio based RSS feed, like a
news service or something. The PHP feed works fine. But the link has
to be to an audio file.

->Later.....Spic e

Feb 13 '07 #9
devospice wrote:
>It shouldn't if you send the correct header information. The fact it's
coming from PHP should be completely transparent.

It is. The PHP feed works fine. (http://www.thefump.com/cast.php)
But pointing the link tag to a PHP file instead of an audio file
generates a "this feed is not valid" error in iTunes.

->Later.....Spic e
As I said - if the header is correct, it should be OK.

I looked at your link, but I didn't see any php files being pointed to -
just the mp3 files themselves.

I still suspect you're not sending the correct info in the header,
especially the content header. But you haven't shown us any code or
your php buffering.

Browsers are pretty loose about things. iTunes might be more stringent.

Of course, it's possible they could be looking at the file extension
instead of the content header. But that's defeating the purpose of the
header - and pretty stupid, IMHO. But it's still possible.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 14 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2425
by: Jim Willsher | last post by:
Hi all, PHP 4.2.2 on RedHat9 I have some files on my website for people to download, and I want to generate the file location "on the fly", so the URL is held in a database. I have a simple PHP script, pasted below. IE users are fine, but Mozilla users actually see the file contents on screen, as garbage, instead of being presented with the "save as" dialog.
4
2983
by: Bernhard | last post by:
I am not sure if php can achieve this, but i guess that my problem shoulb be solved with an server side language. Is there any way i can tell if a visitor of my website has finished a download? For example the visitor clicks on a file download link, and when his download is finished then i want to happen something (for example some download counter or something like that.)
3
20548
by: Michael | last post by:
I am trying to allow a user to view a PDF in a new window. I currently have this working using the following: <a href="./pdf.do?parameter=01121980" target="top"><b>pdf</b></a> The problem with the above solution is the back/forward buttons and all the other browser options. Because of this, I am trying to get the following solution to work: <a href="#" onclick="popUp('./pdf.do?parameter=01121980')"><b>pdf</b></a>
8
5261
by: William Starr Moake | last post by:
I'm trying to script a download counter that will display the total number on the download page without server-side scripting. Below is my very incomplete beginning. It returns no errors, but does nothing: <script language="JavaScript"> function addClicks() { total = "form1.value"; form1.value = (eval(total.value) + (1));
0
1797
by: Marius III | last post by:
Hi there, I am building a File download counter in PHP5. It's working fine but the problem is that its not working with any Download Managers for ex: Free Download Manager / DAP etc. The download manager downloads the actual PHP script file. How can I correct this? Here is my code:
5
1588
by: Mickey | last post by:
Hi all, Is there a way to find out when a user has completed a download? I ask this because I have a current system where users download files, however due to serious bandwidth issues I need to limit the amount of downloads at one time. Ideally, I want to be able to allow a maximum of 5 members to access the download page at one time (with one download per person at one
7
3440
by: mistral | last post by:
I use htaccess to protect directory and granting access to download file only for the authorized users. Just want implement simple PHP file download counter for single file. I need track the number of downloads of this file on my website, IP address and date. Since I have no access to Apache log files, I need some other way, use script that will write a log file. Is there some handy way? M.
3
1845
by: malaysiauser | last post by:
Dear all, Last year I install a download control script in Linux server. its working. This year i'd changed my hosting server to other company. i'd tried install the script. It was installed properly but doesn't work. More about the script; This script will log date, time, ip address, by day, by month, by year and analysis of downloads. It has 4 log files for one module (year, date...) Now the problem is if i create new module, it...
1
47487
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.