Просмотр файла fnc/chat_on.php

Размер файла: 1.21Kb
<?
session_start();
if(isset($_SESSION['chat_name'])){if(trim($_SESSION['chat_name'])!=""){$chat_log=trim(htmlspecialchars($_SESSION['chat_name']));}}
	if(isset($chat_log))
	{
		$chat_fail=file("../data/chat_aut.dat");
		$chat_c=count($chat_fail);
		for($chat_i=0; $chat_i<$chat_c; $chat_i++)
		{
			$chat_ex=explode("::", $chat_fail[$chat_i]);
			if($chat_log == $chat_ex[0])
			{
				unset($chat_fail[$chat_i]); 
			}
		}
		
		$chat_fp=fopen("../data/chat_aut.dat","w"); 
		fputs($chat_fp,implode("",$chat_fail)); 
		fclose($chat_fp);
		$chat_time = time();
		$chat_file = fopen("../data/chat_aut.dat", "a+");
		$chat_str = "$chat_log::$chat_time\r\n";
		flock($chat_file, LOCK_EX);
		fwrite($chat_file, $chat_str);
		flock($chat_file, LOCK_UN);
		fclose($chat_file);
	}



		$chat_fi=file("../data/chat_aut.dat");
		$chat_c=count($chat_fi);
		for($chat_i=0; $chat_i<$chat_c; $chat_i++)
		{
			$chat_ex=explode("::", $chat_fi[$chat_i]);
			if((time()-$chat_ex[1]) < 20)
			{
				echo'<a href="javascript:chat_DoSmilie(\''.$chat_ex[0].',  \')"><b>'.$chat_ex[0].'</b></a>
				<a href="javascript:chat_DoSmilie(\'[priv]'.$chat_ex[0].'[priv]  \')"><font color=red> [П]</font></a><br/>';
			}
		}

?>