How to calculate how many downloads?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Xia

    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+ph p+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




  • Kimmo Laine

    #2
    Re: How to calculate how many downloads?

    "Ben Xia" <ben@jetcom.com > kirjoitti
    viestissä:05_Re .10522$884.8674 53@news20.bellg lobal.com...[color=blue]
    > 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+ph p+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.
    >[/color]


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

    And make a downloadlink <a href="download. php?file=abc.zi p">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.ber keley.edu/>
    Kimmo Laine eternal.erectio nN0@5P4Mgmail.c om


    Comment

    • PH

      #3
      Re: How to calculate how many downloads?

      >[color=blue]
      > Although this counts only attempted downloads, not succesful ones.
      >[/color]

      Hi, how would you solve succesful downloads counter?

      PH


      Comment

      • John Dunlop

        #4
        Re: How to calculate how many downloads?

        Kimmo Laine wrote:
        [color=blue]
        > application/force-download[/color]

        Is this documented somewhere?

        --
        Jock

        Comment

        • Kimmo Laine

          #5
          Re: How to calculate how many downloads?

          "John Dunlop" <usenet+2004@jo hn.dunlop.name> kirjoitti
          viestissä:Jv%Re .8527$t4.3724@n ewsfe1-gui.ntli.net...[color=blue]
          > Kimmo Laine wrote:
          >[color=green]
          >> application/force-download[/color]
          >
          > Is this documented somewhere?
          >[/color]


          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.ber keley.edu/>
          Kimmo Laine <eternal.erecti onN0@5P4Mgmail. com>


          Comment

          • John Dunlop

            #6
            Re: How to calculate how many downloads?

            Kimmo Laine wrote:

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

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

            --
            Jock

            Comment

            • Chung Leong

              #7
              Re: How to calculate how many downloads?

              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.

              Comment

              • Malcolm Dew-Jones

                #8
                Re: How to calculate how many downloads?

                John Dunlop (usenet+2004@jo hn.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.

                Comment

                • John Dunlop

                  #9
                  Re: How to calculate how many downloads?

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

                  Malcolm Dew-Jones wrote:

                  [re application/force-download]
                  [color=blue]
                  > As for being documented, if it isn't registered then there can't be any
                  > "official" documentation, simply common usage and individual opinions.[/color]

                  There could be application-specific documentation, which is what I
                  was after.
                  [color=blue]
                  > I suspect it isn't on the list, [IANA's list of registered types][/color]

                  It's not. It isn't registered and doesn't follow RFC2046's form of
                  private types.
                  [color=blue]
                  > but on the other hand a browser could easily (in theory) be unaware of
                  > recent mime-types[/color]

                  or even older ones!
                  [color=blue]
                  > and is supposed to fall back to some other default if it doesn't know
                  > the sub-type anyway,[/color]

                  Right, application/octet-stream, in the case of application subtypes.
                  [color=blue]
                  > so if it works then surely little or no harm can come of using it.[/color]

                  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

                  Comment

                  • Manchild

                    #10
                    Re: How to calculate how many downloads?

                    PH wrote:[color=blue][color=green]
                    >>Although this counts only attempted downloads, not succesful ones.
                    >>[/color]
                    >
                    >
                    > Hi, how would you solve succesful downloads counter?
                    >
                    > PH
                    >
                    >[/color]

                    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

                    Comment

                    Working...