download counter - where to get it?

Discussion in 'Programming' started by Lorelei, Apr 13, 2007.

  1. #1
    i have seen mane websites have a download counter, for example near a template or a picture, "this file was downloaded xx times".... how and where can i get this counter?

    thanks!
     
    Lorelei, Apr 13, 2007 IP
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    well you can just update the database each time someone click on the link and then give the download file .

    onclick :

    - update database table .
    - give the download .
     
    commandos, Apr 13, 2007 IP
  3. Lorelei

    Lorelei Notable Member

    Messages:
    1,789
    Likes Received:
    166
    Best Answers:
    0
    Trophy Points:
    205
    #3
    well, this is abit complicated, i'd prefer something that works like a stat counter every time a click is made. simple to implement and accurate.
     
    Lorelei, Apr 13, 2007 IP
  4. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #4
    found this code :

    <?
    
     header ("Content-type: image/jpeg");
     $im = @imagecreate (200, 70)                            
                or die ("Cannot Initialize new GD image stream");           
             
     $background_color = imagecolorallocate ($im, 255, 255, 255);
     $text_color = imagecolorallocate ($im, 0, 0, 0);
     $file = "./count.txt"; 
    
     if(file_exists($file)) $count = trim(file_get_contents($file));
     else $count = 0;
    
     $count++;
     `echo $count > ./count.txt`;
     imagestring ($im, 5, 0, 0,  $count, $text_color);
     imagejpeg($im);
    ?>
    
    Code (markup):
    or this

    http://www.phpjunkyard.com/php-graphical-hit-counter.php

    Note : i dident try any of them .
     
    commandos, Apr 13, 2007 IP
  5. parab

    parab Banned

    Messages:
    502
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #5
    whcih is thes ite you want to put the counter?
     
    parab, Apr 13, 2007 IP
  6. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Lorelei: I'm confused... how do you think that a stat counter works, exactly? If you're talking about logging, then you need to write code that logs to a file then reads it back and parses it. It's not like there's something magical about it. It would pretty much be just as much work... actually, the DB option would be quicker to implement as well as run!
     
    TwistMyArm, Apr 13, 2007 IP
  7. RRWH

    RRWH Active Member

    Messages:
    821
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    70
    #7
    Well yes, it IS a bit complicated - In order to show this, you have to Record Downloads somewhere, and then you need to Display a count of all previous downloads.

    Using a database or text file to Record the previous downloads is as simple as it gets. If you accurately Record the data, then retreiving it and presenting the information will be accurate.
     
    RRWH, Apr 13, 2007 IP
  8. UneekTT

    UneekTT Peon

    Messages:
    196
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    First thing you might want to do is open a new browser window.
    Then type in google.com in the address bar
    After that type in "free hit counter" either with or without the quotes

    Now, you are on your own, choose wisely :)
     
    UneekTT, Apr 13, 2007 IP