Код онлайн на странице.
<?
$timelim=20;
session_id("hfJKcbJssJ");
session_start();
$f=1;
if(!isset($_SESSION['kolvo']))
$_SESSION['kolvo']=0;
if($_SESSION['kolvo']>0)
{
for($i=0;$i<$_SESSION['kolvo'];$i++)
if($_SESSION['users']['ip'][$i]==$_SERVER['REMOTE_ADDR'])
{
$_SESSION['users']['date'][$i]=date('U');
$f=0;
break;
}
if($_SESSION['kolvo']>0)
for($i=0;$i<$_SESSION['kolvo'];$i++)
if(date('U')-$_SESSION['users']['date'][$i]>$timelim)
{ for($j=$i;$j<$_SESSION['kolvo']-1;$j++)
{
$_SESSION['users']['date'][$j]=$_SESSION['users']['date'][$j+1];
$_SESSION['users']['ip'][$j]=$_SESSION['users']['ip'][$j+1];
}
$_SESSION['kolvo']--;
}
}
if($f)
{
$_SESSION['users']['ip'][$_SESSION['kolvo']]=$_SERVER['REMOTE_ADDR'];
$_SESSION['users']['date'][$_SESSION['kolvo']]=date('U');
$_SESSION['kolvo']++;
}
echo "<b>Онлайн:</b> ".$_SESSION['kolvo'];
?>