473,395 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to calculate how many downloads?

Hello all:

I want to know how many successful downloads from website, is there some PHP
script can do this?

Let's say I have file "abc.zip" people can download, The system is
Apache+linux+php+mysql, how I can know exact how many successfully downloads
and the download time.

I know it can be done by weblog statistic, but I want to know is there some
way in php can do it so I can save in database and view real time result.

any help will be appreciate.

Ben


Sep 2 '05 #1
9 1400
"Ben Xia" <be*@jetcom.com> kirjoitti
viestissä:05********************@news20.bellglobal .com...
Hello all:

I want to know how many successful downloads from website, is there some
PHP script can do this?

Let's say I have file "abc.zip" people can download, The system is
Apache+linux+php+mysql, how I can know exact how many successfully
downloads and the download time.

I know it can be done by weblog statistic, but I want to know is there
some way in php can do it so I can save in database and view real time
result.

any help will be appreciate.

Make a file called download.php:
<?php
if(file_exists($file=$_REQUEST['file'])) {
header("Content-type: application/force-download");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=$file");
readfile($file);
file_put_contents('counter.log', file_get_contents('counter.log')+1);
} else {
header("HTTP/1.0 404 Not Found");
}
?>

And make a downloadlink <a href="download.php?file=abc.zip">download</a>

Although this counts only attempted downloads, not succesful ones.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine et****************@5P4Mgmail.com
Sep 2 '05 #2
PH
>
Although this counts only attempted downloads, not succesful ones.


Hi, how would you solve succesful downloads counter?

PH
Sep 2 '05 #3
Kimmo Laine wrote:
application/force-download


Is this documented somewhere?

--
Jock
Sep 2 '05 #4
"John Dunlop" <us*********@john.dunlop.name> kirjoitti
viestissä:Jv****************@newsfe1-gui.ntli.net...
Kimmo Laine wrote:
application/force-download


Is this documented somewhere?

That I don't know. It's widely used, but I'm not sure if it is documented
anywhere.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <et****************@5P4Mgmail.com>
Sep 2 '05 #5
Kimmo Laine wrote:

[re application/force-download]
It's widely used, but I'm not sure if it is documented anywhere.


I did do a Google, but it only confirmed that it's widely used.

--
Jock
Sep 2 '05 #6
Using a piped log is probably the best solution. See the Apache
documentation for more info. Using PHP to serve downloads is not
terribly efficient.

Sep 2 '05 #7
John Dunlop (us*********@john.dunlop.name) wrote:
: Kimmo Laine wrote:

: [re application/force-download]

: > It's widely used, but I'm not sure if it is documented anywhere.

: I did do a Google, but it only confirmed that it's widely used.

google: "list of mime types"
should turn up the official list of registered mime types.

Since it isn't an X- sub-type then it should either be on that list, or
else it should not be used. If it isn't on the list then by rights that
should be something like X-force-download. As for being documented, if it
isn't registered then there can't be any "official" documentation, simply
common usage and individual opinions.

I suspect it isn't on the list, but on the other hand a browser could
easily (in theory) be unaware of recent mime-types and is supposed to fall
back to some other default if it doesn't know the sub-type anyway, so if
it works then surely little or no harm can come of using it.
--

This programmer available for rent.
Sep 2 '05 #8
F'ups directed away from a.p.sql.

Malcolm Dew-Jones wrote:

[re application/force-download]
As for being documented, if it isn't registered then there can't be any
"official" documentation, simply common usage and individual opinions.
There could be application-specific documentation, which is what I
was after.
I suspect it isn't on the list, [IANA's list of registered types]
It's not. It isn't registered and doesn't follow RFC2046's form of
private types.
but on the other hand a browser could easily (in theory) be unaware of
recent mime-types
or even older ones!
and is supposed to fall back to some other default if it doesn't know
the sub-type anyway,
Right, application/octet-stream, in the case of application subtypes.
so if it works then surely little or no harm can come of using it.


application/force-download, lacking a 'rigorous and public
definition', violates a 'must' condition of MIME, and depending on
your interpretation of RFC2616, it might or might not violate HTTP/1.1.

--
Jock
Sep 2 '05 #9
PH wrote:
Although this counts only attempted downloads, not succesful ones.

Hi, how would you solve succesful downloads counter?

PH


Nothing to stop you slipping a SQL statement in at the end of the page.
So long as it outputs nothing to the 'page' itself it should do the job

J
Sep 3 '05 #10

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

Similar topics

4
by: Dag Sunde | last post by:
Just wondering if anyone have looked into this? How to split up ones JavaScript library? A lot of very specific (and small) .js files, or a few larger files. I'm thinking about load-time...
1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
96
by: david ullua | last post by:
I am reading "Joel on Software" these days, and am in stuck with the question of "how to calculate bitsize of a byte" which is listed as one of the basic interview questions in Joel's book. Anyone...
5
by: js | last post by:
Can anyone help with the following Transact SQL question? Thanks. I need a store procedure to return the the result recordset which will be execute from a web page. The database has tables, A...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
6
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
3
ChaseCox
by: ChaseCox | last post by:
Hi all, I have a problem that I have been looking at for a couple days now and I can not quite get it to work. I would like to calculate the cumulative percent failure of a certain product in...
9
by: howzit | last post by:
I have a set date in my MySQL database that records when a Sales Lead is established and I echo that date as $row_rsLead; I need to be able to calculate how many days that lead has existed....
3
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.