|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hit Counter
Hi,
How do I go about putting a hit counter up on a website? Thanks |
|
#2
|
|||
|
|||
|
Do you want to write your own or get a free one from somewhere else? If you just want a free one google has a bunch of suggestions: http://www.google.com/search?&q=free%20hit%20counter
|
|
#3
|
||||
|
||||
|
writing one: Perl
Make a file count.cgi in your cgi-bin:
Code:
#!/usr/bin/perl
our $count;
open (INFILE,"./count.txt");
while(<INFILE>){
$count = $_;
}
close INFILE;
print "<table><tr><td>$count visitors so far!</td></tr></table>\n";
$count++;
open(OUTFILE,">./count.txt");
print OUTFILE "$count";
close OUTFILE;
Then, wherever you want the html code to go, do: Code:
<!--#exec cgi="http://mysite.com/cgi-bin/count.cgi"--> EDIT: closing my filehandle! Last edited by linuxChique : September 30th, 2003 at 03:42 PM. |
|
#4
|
||||
|
||||
|
You should lock your files as well, because this will get borked under concurrent accesses. It will lose or corrupt data.
|
|
#5
|
||||
|
||||
|
|
![]() |
| Viewing: Dev Shed Forums > Web Design > Web Design Help > Hit Counter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|