Results 1 to 4 of 4

Thread: Hit counters

  1. #1

    Hit counters

    How can I make my own hit counters to put up on my websites?

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    681
    you just need to write a script for the hit counter (you can search google for a tutorial) and if you want to be tricky you can have it only count unique users using a cookie and so on. i am not sure off the top of my head if you can do this on a free webhost because the script has to reference a file (usually a .js file... it's been a while since i wrote a hit counter) so that has to be stored server side. it's easiest to right a hit counter if you have your own server to put the server side file really... but if you aren't running your own you have to see if your host allows the file you need to call in the script

    [EDIT]your best bet would be to just use a free one off of like bravenet or one of those... you can find one on google...[/EDIT]

    (i believe you can write a script that does it with out calling another file but as i remember it is messy and a huge pain in the ass as well as allows for some security issues... but don't quote me cause we only talked about writing one like that in theory and i don't think it ever got put into practice do to the sloppiness of it)
    Learn like you are going to live forever, live like you are going to die tomorrow.

    Propoganda

  3. #3
    Senior Member
    Join Date
    Aug 2003
    Posts
    300
    You can pull free code down from a bunch of sites. The best site to find the code sites is Digital Deviation you can thank GreekGoddess for the site. Go to the java area and find a good counter you want.




    Adiz

  4. #4
    AO French Antique News Whore
    Join Date
    Aug 2001
    Posts
    2,126
    If you have PHP able on your site, try this (Text Base Counter)

    PHP Code:
    <?php

    /*
        Create an empty text file called Counter.dat and
        upload to the same directory as the page you want to
        count hits for. (CDMOD is to Read-Write for Everyone)

    */

    // Open the file for reading
    $fp fopen("Counter.dat""r");

    // Get the existing count
    $count fread($fp1024);

    // Close the file
    fclose($fp);

    // Add 1 to the existing count
    $count $count 1;

    // Display the number of hits
    // If you don't want to display it, comment out this line
    echo "<p>Hits Sinces 2004 (Or Whatever) : <b>" $count "</b></p>";

    // Reopen the file and erase the contents
    $fp fopen("Counter.dat""w");

    // Write the new count to the file
    fwrite($fp$count);

    // Close the file
    fclose($fp);

    ?&
    gt
    -Simon \"SDK\"

Posting Permissions

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