<?
session_start();
include "conf.php";
$data = mysql_connect($base_name, $base_user, $base_pass);
mysql_select_db($db_name,$data);
if (ereg("[<>\\/-]",$login)){print "?!"; exit();}
$phrase=htmlspecialchars($phrase);
$date=htmlspecialchars($date);
$name=htmlspecialchars($name);
$msg=htmlspecialchars($msg);
$class=htmlspecialchars($class);
$sql = "SELECT * FROM users WHERE login='$login'";
$result = mysql_query($sql);
$db = mysql_fetch_array($result);

$room = $db["room"];
$color= $db["color"];
$city = $db["city_game"];

$SEEK = mysql_query("SELECT * FROM chat WHERE id!=0");
$num = mysql_num_rows($SEEK);

if($num>150){
$D = mysql_query("DELETE FROM chat");
print "log cleaned.";
}

global $h, $words;
$name=$login;
if ($h and $db["shut"]==0 and $db["chat_s"]!=2) {
        $chas = date("H");
        $minute = date("i");
        $mes = date("m");
        $dat = date("d");
        $year = date("Y");

        $dname=date("d.m.Y.H", mktime($chas-$GSM));

        $h = htmlspecialchars($h);
        $h = str_replace("\n","",$h);
        $h = "<font color=$color>$h</font>";
        $time = time();

        $d=date("H:i", mktime($chas-$GSM, $minute));
        $S = mysql_query("INSERT INTO chat(date,name,room,msg,class,date_stamp,city) VALUES('$d','$name','$room','$h','us','$time','$city')");
        if($S){print "message added...";}else{echo mysql_error();}

        $to    = "to [FloodeR]";
        $pos = strpos($h, $to);
        if($pos !== false){
        include "shut.php";
         
        }



        ?>
        <script language="JavaScript">
                parent.talk.talker.phrase.value='';
                parent.talk.talker.phrase.focus();
                top.ref.location.reload();
        </script>
        <?
}
?>
