Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$cutoff = 1; //online cut of time
$exists = 0;
$users = 0;
$user = "";
$fp = fopen ("online.txt","r+"); //if the file exists open it
while (!feof($fp))
{
$user[] = chop(fgets($fp,65536));
}
fseek($fp,0,SEEK_SET);
foreach ($user as $line)
{
list($oldip,$oldtime) = explode('|',$line);
if ($oldip == $ip) {$oldtime = $time;$exists = 1;} //check to see if the user is already in the text file
if ($time < $oldtime + ($cutoff * 60)) //see if the last time the user visited is past the cut off time
{
fputs($fp,"$oldip|$oldtime\n"); //write the old data to the text file
$users = $users + 1; // add one to the user count
}
}
if ($exists == 0) //if the user isn't in the text file already:
{
fputs($fp,"$ip|$time\n"); //write the new data to the text file
$users = $users + 1; //add one to the user count
}
fclose ($fp); //close the text file
print "$users"; //display the number of users online
?>