Re: webpage counters

From: Date: Thu, 06 Sep 2001 04:57:08 +0000
Subject: Re: webpage counters
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-12208@lists.php.net to get a copy of this message
mysql will always have overhead. plus, IMO, mysql is overkill for just simple page counters. if i were you, keeping the text files outside the WEB DOC path would be better. they would have to crack into the machine itself... not just the web server... Eduardo Vela wrote: > > Hi: > > I have two types of counters in my web site and I would like > to know which one is better. > > a) the first one using a field in mysql table and updating it each time > a visitor hits the page. > > b) the second one using a plaint text file using code like this: > > <? > $counter_file = "counterfile.txt"; > $linecounter = file($counter_file); > $linecounter[0]++; > $cf = fopen($counter_file, "w"); > fputs($cf, "$linecounter[0]"); > fclose($cf); > echo "$linecounter[0]"; > ?> > in this case i had to change the permission of the file to: > chmod 666 counterfile.txt > > My questions are: > 1. Which is more efficient in terms of time, i.e. accessing a database or > accessing a text file? > 2. is the second counter secure? is there a possibility that the file > counterfile.txt (with those > permissions) can be used as a insecure door to my web server? > -- Leo G. Divinagracia III ldivinag@csuhayward.edu

« previous php.db (#12208) next »