File size: 2.89Kb
<?php
$qu = @mysql_query("select * from `".$px.$vtable."` where login='Вопрос' and ci='$ci' order by id desc;");
$quser = @mysql_query("select `vposts` from `".$px.$utable."` where login='Вопрос' and ci='$ci'");
$vuser = @mysql_fetch_array($quser);
$vposts = $login['vposts'];
$posts = $vuser['posts'];
$vict = @mysql_fetch_array($qu);
$que = @mysql_query("select * from `".$px.$qtable."`;");
$num_ques = @mysql_num_rows($que);
$rand1 = $vict['vopros'];
if(empty($rand1)) $rand1 = rand(1,$num_ques);
$rand_q = @mysql_query("select * from `".$px.$qtable."` where id='$rand1';");
$ques = @mysql_fetch_array($rand_q);
$nv = $ques['vopros'];
$answer = strtolower($ques['otvet']);
$msg = strtolower($msg);
$answered = $vict['answered'];
$vopros = $vict['vopros'];
$time = $vict['time'];
$now = time();
if($vopros) {
if(($now < $time + 120)&&(empty($answered))) {
if(preg_match("/$answer/i","$msg")) {
@mysql_query("update `".$px.$utable."` set posts=".($posts+1)." where login='Вопрос' and ci='$ci'");
@mysql_query("update `".$px.$utable."` set vposts=".($vposts+1)." where login='".$login['login']."' and ci='$ci'");
@mysql_query("insert into `".$px.$vtable."` values (0,'Вопрос','Молодец, ".$login['login']."! Ответ верный! Правильных ответов: ".($vposts+1)."!','','','','','".time()."', '$ci');");
@mysql_query("update `".$px.$vtable."` set answered='1' where vopros='$rand1' and login='Вопрос' and ci='$ci'");
}
} else {
if(empty($answered)&&(!empty($vopros)))
@mysql_query("insert into `".$px.$vtable."` values (0,'Вопрос','Время истекло, следующий вопрос через минуту!','$pr_from','$pr_to','0','0','".time()."','$ci');");
@mysql_query("update `".$px.$utable."` set posts=".($posts+1)." where login='Вопрос' and ci='$ci'");
}
} else {
$len = strlen($answer)/2;
@mysql_query("insert into `".$px.$vtable."` values (0,'Вопрос','$nv ($len букв)','','','$rand1','0','".time()."', '$ci');");
@mysql_query("update `".$px.$utable."` set posts=".($posts+1)." where login='Вопрос' and ci='$ci'");
}
?>