Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Counters?
#1
How do you put a hit counter on your web page? :???:
Reply
#2
You can do it in several ways. For example, you can use PHP if your server allows you that.

If you don't know how to do, there is plenty of free counter services in the net.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
Well thanks that solves my problem

my server doesnt allow PHP it only allows perl any way perl could do it? :???:

(I don't want to use other peoples stuff thats all :oops: )
Reply
#4
While you are at it, search "extreme tracking" and get one of their cool trackers. It's not a visible hit counter but na_th_an already told you how to get one of those.

Nath: what's the php code for a hit counter?
Reply
#5
This one is done by aetherfox with later modifications by me. Originally, it used GIFs to show numbers but I needed text. Also, I added an IP recording facility:

Code:
<?php

$counter_File = "counter.txt";

# begin layout

  $fa = @fopen($counter_File, "r") or die("Could not open the file for reading!");
  $size = filesize($counter_File);
  $read = fread($fa, $size);
  fclose($fa);

  $fa = @fopen($counter_File, "w") or die("Could not open the file for writing!");
  $read++;
  fwrite($fa, $read);
  fclose($fa);
  
# begin code (img, txt)

  $fa = @fopen($counter_File, "r") or die("Could not open the file for reading!");
  $size = filesize($counter_File);
  $read = fread($fa, $size);
  fclose($fa);
  
      $l = 6-strlen($read)-1;    
      for($i=0;$i<=$l;$i++)
      {
          echo "0";
      }

      $l = strlen($read)-1;
      for($i=0;$i<=$l;$i++)
      {
          echo $read[$i];
      }

    // GREAT WOPR2K Addition
    
    $fpa=fopen("usersdata.dat","a");
    $ua=get_browser();
    $browser = $_SERVER["HTTP_USER_AGENT"];
    fputs($fpa,"[".date("D, d F Y, h:i:s a")."] User:".GetHostByName($REMOTE_ADDR)." w. ".$browser."·");
    fclose($fpa);

  }

?>

To use the counter just save it as "counter.inc" and do a <?php include("counter.inc"); ?> where you want to show it. You need two blank files in your browser prior to running this for the first time, called "counter.txt" and "usersdata.dat".

You can retrieve users data with this code:

Code:
<HTML>
<HEAD>
<TITLE>User list</TITLE>
<META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ ME">
</HEAD>

<BODY>

<h1>User list:</h1>

<?php

$fpr=fopen("usersdata.dat","r");
$counter=0;

while(!feof($fpr))
{
    // First we look for the name
    $printline="";
    do {
        $ch=fgetc($fpr);
        if($ch != "·")
            $printline=$printline.$ch;
    }while ($ch!="·" && !feof($fpr));
    
    if($printline!="")
    {
        echo $printline."<br>";
        $counter=$counter+1;
    }
}


fclose($fpr);

echo "<p><b>Loads from activation: ".$counter."</b></p>";

?>

</BODY>
</HTML>

save it as "counterstats.php", for example.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#6
Thanks, I'm learning php now so that is handy for practice. I once saw a php counter that was only 5 lines long, but I don't think it showed the counter on the site anywhere.
Reply
#7
counters are very easy and populous. look at cgi-resources.com for plenty of perl ones.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)