|
|
|
|
![]() ![]() |
Jul 30 2007, 05:38 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 413 Joined: 4-October 06 From: Psychedelic Realms Member No.: 31,079 |
This is really simple script. Well at least this part is, but it could be extendable. Only problem is that it's not really for massive websites with hundread of visitors a day, but rather for small ones. But it is a good script to figure out how to make a visitor counter script.
Anyway here's the snippet. CODE <?php function getVisits($variable) { $visits = array(); if ($handle = opendir('stats/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { array_push($visits, $file); } } closedir($handle); } $key = array_search($variable, $visits); if ($key !== FALSE) { echo "Posjeta do sada: ".count($visits); } elseif ($key === FALSE){ $file = fopen("stats/".$variable, 'a'); fwrite($file, $variable); fclose($file); getVisits($variable); } } ?> Just call it with getVisits($_SERVER['REMOTE_ADDR'])., and be sure to have that stats directory in same root as file in which script is executed. Comments or improvments are welcome. |
|
|
|
Jul 30 2007, 07:27 AM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 221 Joined: 6-June 07 Member No.: 44,288 |
Good work! Looks pretty good to me. I might use this but maybe use MySql instead of flat files. I just like SQL
|
|
|
|
Jul 30 2007, 07:43 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 413 Joined: 4-October 06 From: Psychedelic Realms Member No.: 31,079 |
Ok, fast reply works again
Yeah, mySQL is great, this is like i stated for small sites with less than 10(0) visitors a day |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 8th September 2008 - 01:49 AM |