Professional Web Applications Themes

How to calculate how many downloads? - PHP Development

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...

  1. #1

    Default 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




    Ben Guest

  2. #2

    Default Re: How to calculate how many downloads?

    "Ben Xia" <com> kirjoitti
    viestissä:05_Re.10522$bellglobal.com... 


    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 com


    Kimmo Guest

  3. #3

    Default Re: How to calculate how many downloads?



    Hi, how would you solve succesful downloads counter?

    PH


    PH Guest

  4. #4

    Default Re: How to calculate how many downloads?

    Kimmo Laine wrote:
     

    Is this doented somewhere?

    --
    Jock
    John Guest

  5. #5

    Default Re: How to calculate how many downloads?

    "John Dunlop" <usenet+dunlop.name> kirjoitti
    viestissä:Jv%Re.8527$ntli.net... 
    >
    > Is this doented somewhere?
    >[/ref]


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

    --
    SETI Home - Donate your cpu's idle time to science.
    Further reading at <http://setiweb.ssl.berkeley.edu/>
    Kimmo Laine <com>


    Kimmo Guest

  6. #6

    Default Re: How to calculate how many downloads?

    Kimmo Laine wrote:

    [re application/force-download]
     

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

    --
    Jock
    John Guest

  7. #7

    Default Re: How to calculate how many downloads?

    Using a piped log is probably the best solution. See the Apache
    doentation for more info. Using PHP to serve downloads is not
    terribly efficient.

    Chung Guest

  8. #8

    Default Re: How to calculate how many downloads?

    John Dunlop (usenet+dunlop.name) wrote:
    : Kimmo Laine wrote:

    : [re application/force-download]

    : > It's widely used, but I'm not sure if it is doented 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 doented, if it
    isn't registered then there can't be any "official" doentation, 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.
    Malcolm Guest

  9. #9

    Default Re: How to calculate how many downloads?

    F'ups directed away from a.p.sql.

    Malcolm Dew-Jones wrote:

    [re application/force-download]
     

    There could be application-specific doentation, which is what I
    was after.
     

    It's not. It isn't registered and doesn't follow RFC2046's form of
    private types.
     

    or even older ones!
     

    Right, application/octet-stream, in the case of application subtypes.
     

    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
    John Guest

  10. #10

    Default Re: How to calculate how many downloads?

    PH wrote: 
    >
    >
    > Hi, how would you solve succesful downloads counter?
    >
    > PH
    >
    >[/ref]

    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
    Manchild Guest

Similar Threads

  1. Calculate CDF
    By friend.05@gmail.com in forum PERL Modules
    Replies: 3
    Last Post: April 8th, 08:04 PM
  2. Calculate values
    By Cindy587 in forum Macromedia ColdFusion
    Replies: 7
    Last Post: March 8th, 01:00 AM
  3. Calculate Age from DOB
    By hil400 in forum FileMaker
    Replies: 1
    Last Post: October 16th, 08:37 PM
  4. Calculate next available IP
    By Jim in forum PERL Modules
    Replies: 8
    Last Post: July 18th, 12:30 PM
  5. calculate the time
    By Frank Dulk in forum Microsoft SQL / MS SQL Server
    Replies: 4
    Last Post: July 14th, 01:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139