Файл: vsime.com/chat/inc/umnik.php
Строк: 122
<?
$umnik_last = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat` WHERE `id_room` = '$room[id]' AND `umnik_st` <> '0' AND `type` = 'post' ORDER BY id DESC"));
if ($umnik_last!=NULL && $umnik_last['umnik_st']!=4 && $umnik_last['umnik_st']!=0)
{
$umnik_vopros = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat_vopros` WHERE `id` = '$umnik_last[vopros]' LIMIT 1"));
$umnik_post = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat` WHERE `id_room` = '$room[id]' AND `message` like '%$umnik_vopros[otvet]%' AND `umnik_st` = '0' AND `time` >= '".($time-$umnik_last['time'])."' AND `type` = 'post' ORDER BY `id` ASC LIMIT 1"));
if($umnik_post!=NULL){
$ank=mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `user` WHERE `id` = '$umnik_post[id_user]' LIMIT 1"));
$add_balls=0;
if ($umnik_last['umnik_st']==1){$add_balls=25;$pods='не используя подсказок';}
if ($umnik_last['umnik_st']==2){$add_balls=10;$pods='используя одну подсказку';}
if ($umnik_last['umnik_st']==3){$add_balls=5;$pods='используя обе посказки';}
$msg="Молодец, [b]$ank[nick][/b].nТы первым дал верный ответ: [b]$umnik_vopros[otvet][/b] $pods.n[b]$ank[nick][/b] получает $add_balls баллов.nСледующий вопрос через ".sklon_text($config['umnik_new'], array('секунду', 'секунды', 'секунд')).".";
mysqli_query($dbi, "INSERT INTO `chat` (`umnik_st`, `time`, `message`, `id_room`, `vopros`, `type`) values('4', '".($time+1)."', '$msg', '$room[id]', '$umnik_vopros[id]', 'post')");
mysqli_query($dbi, "UPDATE `user` SET `balls` = '".($ank['balls']+$add_balls)."' WHERE `id` = '$ank[id]' LIMIT 1");
}
}
$umnik_last1 = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat` WHERE `id_room` = '$room[id]' AND `umnik_st` = '1' AND `type` = 'post' ORDER BY id DESC"));
if ($umnik_last1!=NULL && $umnik_last['umnik_st']!=4 && $umnik_last1['time']<time()-$config['umnik_time'])
{
$umnik_vopros = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat_vopros` WHERE `id` = '$umnik_last1[vopros]' LIMIT 1"));
$msg="На вопрос никто не ответил.nПравильный ответ: $umnik_vopros[otvet].nСледующий вопрос через ".sklon_text($config['umnik_new'], array('секунду', 'секунды', 'секунд')).".";
mysqli_query($dbi, "INSERT INTO `chat` (`umnik_st`, `time`, `message`, `id_room`, `vopros`, `type`) values('4', '".($time+1)."', '$msg', '$room[id]', '$umnik_vopros[id]', 'post')");
}
$umnik_last = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat` WHERE `id_room` = '$room[id]' AND `umnik_st` <> '0' AND `type` = 'post' ORDER BY id DESC"));
if ($umnik_last==NULL || $umnik_last['umnik_st']==4 && $umnik_last['time']<time()-$config['umnik_new'])
{
// задается вопрос
$k_vopr=mysqli_num_rows(mysqli_query($dbi, "SELECT * FROM `chat_vopros`"));
$umnik_vopros = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat_vopros` LIMIT ".rand(0,$k_vopr).", 1"));
$msg="[b]Вопрос:[/b] "$umnik_vopros[vopros]"n[b]Ответ:[/b] слово из ".(strlen($umnik_vopros['otvet'])/2)." букв";
mysqli_query($dbi, "INSERT INTO `chat` (`umnik_st`, `time`, `message`, `id_room`, `vopros`, `type`) values('1', '".($time+1)."', '$msg', '$room[id]', '$umnik_vopros[id]', 'post')");
}
if ($umnik_last!=NULL && $umnik_last['umnik_st']==1 && $umnik_last['time']<time()-$config['umnik_help'])
{
$umnik_vopros = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat_vopros` WHERE `id` = '$umnik_last[vopros]' LIMIT 1"));
if (function_exists('iconv_substr'))
$help=iconv_substr($umnik_vopros['otvet'], 0, 1, 'utf-8');
else
$help=substr($umnik_vopros['otvet'], 0, 2);
for ($i=0;$i<(strlen($umnik_vopros['otvet'])/2)-1 ;$i++ ) {
$help.='*';
}
$msg="[b]Вопрос:[/b] "$umnik_vopros[vopros]"n[b]Первая подсказка:[/b] $help (".sklon_text((strlen($umnik_vopros['otvet'])/2), array('буквы', 'буквы', 'букв')).")";
mysqli_query($dbi, "INSERT INTO `chat` (`umnik_st`, `time`, `message`, `id_room`, `vopros`, `type`) values('2', '".($time+1)."', '$msg', '$room[id]', '$umnik_vopros[id]', 'post')");
}
if ($umnik_last!=NULL && $umnik_last['umnik_st']==2 && $umnik_last['time']<time()-$config['umnik_help'])
{
$umnik_vopros = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `chat_vopros` WHERE `id` = '$umnik_last[vopros]' LIMIT 1"));
if (function_exists('iconv_substr'))
$help=iconv_substr($umnik_vopros['otvet'], 0, 2, 'utf-8');
else
$help=substr($umnik_vopros['otvet'], 0, 4);
for ($i=0;$i<(strlen($umnik_vopros['otvet'])/2)-2 ;$i++ ) {
$help.='*';
}
$msg="[b]Вопрос:[/b] "$umnik_vopros[vopros]"n[b]Вторая подсказка:[/b] $help (".sklon_text((strlen($umnik_vopros['otvet'])/2), array('буквы', 'буквы', 'букв')).")";
mysqli_query($dbi, "INSERT INTO `chat` (`umnik_st`, `time`, `message`, `id_room`, `vopros`, `type`) values('3', '".($time+1)."', '$msg', '$room[id]', '$umnik_vopros[id]', 'post')");
}
?>