Файл: chat/umnik1.php
Строк: 109
<?php
$b = mysql_fetch_array(mysql_query("SELECT * FROM `vopros` WHERE `ids` = '1'"));
$nom = $b['number'];
$vr = $b['time'];
$answ = $b['answer'];
if (time() >= $vr)
{
if ($nom == 5)
{
$st = time() + 240;
mysql_query("UPDATE `vopros` SET `time` = '$st' WHERE `ids` = '1' LIMIT 1");
$a = mysql_result(mysql_query("SELECT COUNT(*) FROM `question`"), 0);
$rnd = mt_rand(1, $a);
$re = mysql_fetch_array(mysql_query("SELECT * FROM `question` WHERE `number` = '$rnd' LIMIT 1"));
$answ = $re['answer'];
$tran = $re['tran'];
$nom = 0;
$vr = $st;
$i = mb_strlen($tran, 'UTF8');
$vp = $re['vopros'] . ' (' . $i . ' букв)';
mysql_query("UPDATE `vopros` SET `number` = '$nom', `question` = '$vp', `answer` = '$answ', `tran` = '$tran' WHERE `ids` = '1' LIMIT 1");
$ids = mt_rand(100000, 999999);
mysql_query("INSERT INTO `message` SET
`id` = '$ids',
`user` = 'Умник',
`who` = '0',
`time` = '" . time() . "',
`msg` = '$vp',
`room` = '$rm'");
} else {
$st = time() + 20;
mysql_query("UPDATE `vopros` SET `time` = '$st' WHERE `ids` = '1' LIMIT 1");
$a = mysql_result(mysql_query("SELECT COUNT(*) FROM `question`"), 0);
$rnd = mt_rand(1, $a);
$re = mysql_fetch_array(mysql_query("SELECT * FROM `question` WHERE `number` = '$rnd' LIMIT 1"));
$answ = $re['answer'];
$tran = $re['tran'];
$nom = 5;
$b1 = mysql_fetch_array(mysql_query("SELECT `answer` FROM `vopros` WHERE `ids` = '1' LIMIT 1"));
$otvet = $b1['answer'];
$vp = 'Ответ на вопрос был: <b>' . $otvet . '</b>! Следующий вопрос через 20 секунд.';
$ids = mt_rand(100000, 999999);
mysql_query("INSERT INTO `message` SET
`id` = '$ids',
`user` = 'Умник',
`who` = '0',
`time` = '" . time() . "',
`msg` = '$vp',
`room` = '$rm'");
mysql_query("UPDATE `vopros` SET `number` = '$nom', `answer` = '$answ', `tran` = '$tran' WHERE `ids` = '1' LIMIT 1");
}
} elseif ((($vr - time()) < 150) and ($nom == 0)) {
$nom = 1;
mysql_query("UPDATE `vopros` SET `number` = '$nom' WHERE `ids` = '1' LIMIT 1");
$len = mb_strlen($answ, 'UTF8');
if ($len >= 11) {
$sub_1 = mb_substr($answ, 0, 5, 'UTF8');
$sub_2 = mb_substr($answ, -5, 5, 'UTF8');
$answ = str_replace($sub_1, '*****', $answ);
$answ = str_replace($sub_2, '*****', $answ);
} elseif ($len >= 9 && $len < 11) {
$sub_1 = mb_substr($answ, 0, 4, 'UTF8');
$sub_2 = mb_substr($answ, -4, 4, 'UTF8');
$answ = str_replace($sub_1, '****', $answ);
$answ = str_replace($sub_2, '****', $answ);
} else {
$sub_1 = mb_substr($answ, 0, 3, 'UTF8');
$sub_2 = mb_substr($answ, -3, 3, 'UTF8');
$answ = str_replace($sub_1, '***', $answ);
$answ = str_replace($sub_2, '***', $answ);
}
$vp = '<b>Подсказка:</b> ' . $answ;
$ids = mt_rand(100000, 9999999);
mysql_query("INSERT INTO `message` SET
`id` = '$ids',
`user` = 'Умник',
`who` = '0',
`time` = '" . time() . "',
`msg` = '$vp',
`room` = '$rm'");
} elseif ((($vr - time()) < 75) and ($nom < 2)) {
$nom = 2;
mysql_query("UPDATE `vopros` SET `number` = '$nom' WHERE `ids` = '1' LIMIT 1");
$len = mb_strlen($answ, 'UTF8');
if ($len >= 11) {
$sub_1 = mb_substr($answ, 0, 4, 'UTF8');
$sub_2 = mb_substr($answ, -4, 4, 'UTF8');
$answ = str_replace($sub_1, '****', $answ);
$answ = str_replace($sub_2, '****', $answ);
} elseif ($len >= 9 && $len < 11) {
$sub_1 = mb_substr($answ, 0, 3, 'UTF8');
$sub_2 = mb_substr($answ, -3, 3, 'UTF8');
$answ = str_replace($sub_1, '***', $answ);
$answ = str_replace($sub_2, '***', $answ);
} else {
$sub_1 = mb_substr($answ, 0, 2, 'UTF8');
$sub_2 = mb_substr($answ, -2, 2, 'UTF8');
$answ = str_replace($sub_1, '**', $answ);
$answ = str_replace($sub_2, '**', $answ);
}
$vp = '<b>Подсказка:</b> ' . $answ;
$ids = mt_rand(100000, 9999999);
mysql_query("INSERT INTO `message` SET
`id` = '$ids',
`user` = 'Умник',
`who` = '0',
`time` = '" . time() . "',
`msg` = '$vp',
`room` = '$rm'");
}
?>