Es nem tudom ki irta a forum-scriptet, de gondolkozzon el rajta, hogy jo-e az, amit csinalt!
Telenyomhatnam az oldalt javascripttel!!!! Legalabb a < betuket ne nekem kelljen atirkalni!!!
Didn't anyone ever tell you web-page hit counters were useless? They don't count number of hits, they're a waste of time, and they serve only to stroke the writer's vanity. It's better to pick a random number; they're more realistic.
Anyway, this is what you can do if you can't help yourself.
use Fcntl qw(:DEFAULT :flock);
sysopen(FH, "numfile", O_RDWR|O_CREAT) or die "can't open numfile: $!";
flock(FH, LOCK_EX) or die "can't flock numfile: $!";
$num = <FH> || 0;
seek(FH, 0, 0) or die "can't rewind numfile: $!";
truncate(FH, 0) or die "can't truncate numfile: $!";
(print FH $num+1, "\n") or die "can't write numfile: $!";
close FH or die "can't close numfile: $!";
Didn't anyone ever tell you web-page hit counters were useless? They don't count number of hits, they're a waste of time, and they
serve only to stroke the writer's vanity. Better to pick a random number. It's more realistic.
Anyway, this is what you can do if you can't help yourself.
use Fcntl ':flock';
sysopen(FH, "numfile", O_RDWR|O_CREAT) or die "can't open numfile: $!";
flock(FH, LOCK_EX) or die "can't flock numfile: $!";
$num = || 0;
seek(FH, 0, 0) or die "can't rewind numfile: $!";
truncate(FH, 0) or die "can't truncate numfile: $!";
(print FH $num+1, "\n") or die "can't write numfile: $!";
# Perl as of 5.004 automatically flushes before unlocking
flock(FH, LOCK_UN) or die "can't flock numfile: $!";
close FH or die "can't close numfile: $!";
Én? Minek? Nem nekem kell. Én csak felhívtam a figyelmet erre a nem elhanyagolható apróságra ;-)
(ettől függetlenül az ötlet nem rossz... Én is furcsán néztem, amikor egyik éjjel létrehoztam a tar-on az oldalt és még sehol senkinek nem szóltam róla, mégis 20 fölött volt másnapra a látogatók száma :-) )
Ez a megnyitom, kiolvasom, növelem, visszaírom sokszor vezet lenullázáshoz, és elég lassú is.
Én 1 bájtot szoktam a számláló-fájl végére érni, és stat-tal megnézem a méretét.
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
open (READ, "<count.dat") or die ("Error opening file");
$szaml=<READ>
close (READ) or die ("Error closing file");
$szaml++;
print "Ön az oldal $szaml\. látogatója\.";
open (IR,">szam.dat") or die ("Error opening file");
print IR $szaml;
close(IR) or die ("Error closing file");
Hello kedves Linuxosok! Aki tud kérem segítsen! Számláló kéne a weboldalamra, mert szerintem a tár.hu átver! Nem létezik, hogy a 3 napja feltett oldamamat már 600 an látták volna, csak 2 helyen hirdettem meg. Én lennék ekkora király, hogy ilyen oldalt csinálok?:)))) Na ezt azért nem hiszem.
Szoval, kérlek irjátok le honnan lehet számlálót szerezni és hogy kell felrakni a lapra. Köszi.