<?
if(!isset($ses_user_id)||!isset($ses_user_psd)){errorview("对不起，你没有登陆！！");exit;}
$user_login_id=$ses_user_id;
$user_login_psd=$ses_user_psd;
###########
$onlinefile=read_file("count/oncount.php");
$onlinefile=explode("\n",$onlinefile);
$onlineusercount=count($onlinefile);
for ($j=0;$j<$onlineusercount;$j++)
    {
    $onlineuserdetail=explode("\t",$onlinefile[$j]);
    if($onlineuserdetail[0]==$user_login_id){$ynonlinedel=1;break;}else $ynonlinedel=0;
    }
if($ynonlinedel==1)
   {
   $hastitles = file("count/oncount.php");
   $ccc=count($hastitles);
   $fp = fopen("count/oncount.php","w");
   for ($i=0;$i<$ccc;$i++)
        {
        list($con_id,$con_etime)=explode("\t",$hastitles[$i]);
        if($con_id!=$user_login_id)fputs($fp,$hastitles[$i]);
        }
   fclose($fp);
   }
########写入用户
/*
$lines = file("class/$myclass/online");
while (list($tmpkey,$line) = each($lines))
   {
   $line=ereg_replace("\n","",$line);
   if($line!=$user_login_id)$writeyn="0";else $writeyn="1";
   list($classonlineuser,$classentertime)=split("\t",$line);
   }*/
$classcountfile=read_file("count/oncount.php");
$classcountfile=explode("\n",$classcountfile);
$listcount=count($classcountfile);
for ($j=0;$j<$listcount;$j++)
    {
    $classcountdetail=explode("\t",$classcountfile);
    if($classcountdetail[0]==$user_login_id){$writeyn="0";break;}else $writeyn="1";
    }
for ($j=0;$j<$listcount;$j++)
    {
    $classcountdetail=explode("\t",$classcountfile);
    if($stemp-$classcountdetail[1]>1000){$writeyn2="1";break;}else $writeyn2="0";
    }
if($writeyn=="1")
{
$newdat=$user_login_id."\t".$stemp."\n";
$fp=fopen("count/oncount.php","a+");
fwrite($fp,$newdat);
fclose($fp);
}
########删除超出时间范围内的用户
$onlinetimefile=read_file("count/oncount.php");
$onlinetimefile=explode("\n",$onlinetimefile);
$onlineusercount=count($onlinetimefile);
for ($j=0;$j<$onlineusercount;$j++)
    {
    $onlineuserdetail=explode("\t",$onlinetimefile[$j]);
    if($stemp-$onlineuserdetail[1]>1000)
       {
       $hastitles = file("count/oncount.php");
       $ccc=count($hastitles);
       $fp = fopen("count/oncount.php","w");
       for ($i=0;$i<$ccc;$i++)
            {
            list($con_id1,$con_etime1)=explode("\t",$hastitles[$i]);
            if($con_id1!=$onlineuserdetail[0])fputs($fp,$hastitles[$i]);
            }
   fclose($fp);
       }
    }

?>
