Page 1 of 1

coding a WEB COUNTER , please help :)

Posted: Sat Oct 08, 2005 10:18 am
by CMG
Hi guys,
Could you please help someone who does not know Java, PHP, HTML etc. , yet knows his way around in MS FrontPage in makeing a hit/web counter for his website?

The counter could show in text

TOTAL HITS .......... <number of hits today>
TODAY HITS ......... <total number of hits>

Sincerely Yours,
CMG :D

Posted: Sat Oct 08, 2005 10:33 am
by Charles256
google web counter or page counter i believe and you can find some plug and play counters:-D

Posted: Sat Oct 08, 2005 10:42 am
by CMG
I've tries, yet mostly they come up as already-made counters ( images ) :?
Couldn't find any simple counter that would display text, of total hits and today hits.

CMG.

Posted: Sat Oct 08, 2005 11:20 am
by CMG
edit

Posted: Sat Oct 08, 2005 11:58 am
by CMG
ok, I've found another one!
http://www.akamarketing.com/simple-hit- ... -perl.html

It uses Perl ( whatever it is ), basicly it come to creating a counter.cgi file in a cgi-bin subdirectory with this code

Code: Select all

#!/usr/bin/perl

# the path for the log file
$logpath = "count.dat";

# digits for the counter
$pad = 5;

# opens the log file for reading, will be created if none exists.
open (LOG, "$logpath");
@file = <LOG>; # an array of the file contents
close(LOG);

$count = $file[0]; # the count value is the first line in the file, i.e. $file[0]
$count++; # increments the counter value

open (LOG, ">$logpath"); # opens the log file for writing
flock(LOG, 2); # file lock set
print LOG "$count\n"; # prints out the new counter value to the file
flock(LOG, 8); # file lock unset
close(LOG);

# sets the leading zeros padding for the counter
$pad = "%.$pad"."d";
$count = sprintf($pad, $count);

# prints out the counter
print "Content-type: text/html\n\n";
print "$count";
And an simple SHTML file with this

Code: Select all

<html>
<head>
<title>Basic Hit Counter Example</title>

<style type="text/css">
p {font-family:"Century Gothic", "Sans Serif"; font-size:12pt; color:black;}
</style>
</head>

<body>
<br>
<br>
<br>
<p>You are person number
<!--#include virtual="/cgi-bin/counter.cgi" -->
to view this demo!</p>
</body>
</html>
Their demo works
http://www.design-ireland.net/design/co ... demo.shtml

Yet when I do the same, it only outputs a line
"You are person number to view this demo!"
without any numbers... what do you think might be causing it?

Thanx! :D

Posted: Sat Oct 08, 2005 12:08 pm
by neophyte
I don't know perl but did you:

Code: Select all

# the path for the log file
$logpath = "count.dat";
Set the path and configure the thing correctly?

Posted: Sat Oct 08, 2005 12:19 pm
by d3ad1ysp0rk
The fact that you don't even know what Perl is means I doubt you have it installed.

Posted: Sat Oct 08, 2005 12:47 pm
by CMG
>> Set the path and configure the thing correctly?

I copied it from the tutorial, it seems to look ok.

$logpath = "count.dat"; i.e. the "count.dat" file is in the same cgi-bin directory as the counter.cgi file.

>> The fact that you don't even know what Perl is means I doubt you have it installed.

Did I have to install it? :? Where? I've tried puting it on a server and it also won't work from there...

Posted: Sat Oct 08, 2005 2:05 pm
by pilau
Where did you put the HTML file?
As you can see it includes the perl file from the cg-bin folder when it says this line:

Code: Select all

<!--#include virtual="/cgi-bin/counter.cgi" -->

Posted: Sat Oct 08, 2005 2:11 pm
by CMG
pilau wrote:Where did you put the HTML file?
As you can see it includes the perl file from the cg-bin folder when it says this line:

Code: Select all

<!--#include virtual="/cgi-bin/counter.cgi" -->
I have put the HTML file in the web directory, that has a cgi-bin subdirectory with the cgi file in it.

Posted: Sat Oct 08, 2005 2:33 pm
by pilau
It can be that for some reason your server don't have an access to cgi-bin.. 9don't ask me how I came up with that).

You could try putting the counter.cgi file in the same directory is the html file and remove the "/cgi-bin/" from that line.

Or try to remove that preceeding slah before the "cgi-bin" in that line, i.e. make it: "cgi-bin/counter.cgi" instaed of "/cgi-bin/counter.cgi".

That's all I can think of.

Posted: Sat Oct 08, 2005 3:00 pm
by CMG
Same, still nothing :?
Well, guess would have to look for some other script.

C.

Posted: Sat Oct 08, 2005 3:19 pm
by Charles256
i think you could have learned PHP in this time:-D

Posted: Sat Oct 08, 2005 4:18 pm
by feyd
the following posts may help with information and junk

viewtopic.php?t=38546
viewtopic.php?t=32554