Hello everyone, i have this script that i am trying to implement to work on my website and the script is suppose to track what games are being played at the moment but the only problem is that when i call the script to display the entries it would show duplicates and i want the script to actually explore the string and take only the $gamename and look for duplicates, not the entire string.
What the script does: Records the gameID, gamename, gamethumb url, IP and time all separated by |. Example: 1744|The Simpliest Snowboarding|The Simpliest Snowboarding|77.88.42.26|1264717552
Look for the IP and if already exists update the record with the new info. If the IP does not exist already write a new line with the information. If the record is older then 60min erase it.
Its just a simple script that i will use to show what people are currently playing on the website.
$dataFile = "visitors2.txt";
$numbergames = 30;
//Please do not edit bellow this line
error_reporting(E_ERROR | E_PARSE);
$users = array();
//getting
$fp = fopen($dataFile, "r");
flock($fp, LOCK_SH);
while(!feof($fp)) {
$users[] = fgets($fp, 4096);
}
flock($fp, LOCK_UN);
fclose($fp);
$i = 0;
echo '<ul>';
foreach(array_unique($users) as $key => $data) {
list($game2id , $gamename , $gamethumb , , ) = explode("|", $data);
//echo $game2id . $gamename;
if($gamename != "" && $i <= $numbergames) {
$newpageurl = str_replace(" ", "-", strip_tags(trim(str_replace($rplce, "", $gamename)))) ;
$url = $game2id .'-'. $newpageurl .'.html';
echo '<li><a href="'.$url.'"><img src="./arcade/img/'.$gamethumb.'.png" width="35" height="35" border="0" /></a>'.$gamename.'</li>';
}
$i++;
}
Please, help and thanks everyone in advance.