Файл: social12/chat/anagram1.php
Строк: 57
<?php
$b = mysql_fetch_array(mysql_query("SELECT * FROM `vopros` WHERE `ids` = '2'"));
$nom = $b['number'];
$vr = $b['time'];
$answ = $b['answer'];
if (time() >= $vr) {
if ($nom == 5) {
$st = time();
$st = $st + 240;
mysql_query("UPDATE `vopros` SET `time` = '$st' WHERE `ids` = '2' LIMIT 1");
$a = mysql_result(mysql_query("SELECT COUNT(*) FROM `bota`"), 0);
$rnd = mt_rand(1, $a);
$re = mysql_fetch_array(mysql_query("SELECT * FROM `bota` WHERE `number` = '$rnd' LIMIT 1"));
$answ = $re['answer'];
$tran = $re['tran'];
$nom = 0;
$vr = $st;
$arr = preg_split("//u", $re['answer'], -1, PREG_SPLIT_NO_EMPTY);
shuffle($arr);
$vprs = join('', $arr);
$vp = 'Угадайте слово: <b>' . $vprs . '</b>';
mysql_query("UPDATE `vopros` SET `number` = '$nom', `question` = '$vp', `answer` = '$answ', `tran` = '$tran' WHERE `ids` = '2' 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();
$st = $st + 20;
mysql_query("UPDATE `vopros` SET `time` = '$st' WHERE `ids` = '2' LIMIT 1");
$a = mysql_result(mysql_query("SELECT COUNT(*) AS num FROM `bota`"), 0);
$rnd = mt_rand(1, $a);
$re = mysql_fetch_array(mysql_query("SELECT * FROM `bota` WHERE `number` = '$rnd' LIMIT 1"));
$answ = $re['answer'];
$tran = $re['tran'];
$nom = 5;
$vr = $st;
$b1 = mysql_fetch_array(mysql_query("SELECT `answer` FROM `vopros` WHERE `ids` = '2' 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` = '2' LIMIT 1");
$vp = 'Время истекло! Следующая анаграмма через 20 секунд.';
$ids = mt_rand(100000, 999999);
mysql_query("INSERT INTO SET `message`
`id` = '$ids',
`user` = 'Анаграмма',
`who` = '0',
`time` = '" . time() . "',
`msg` = '$vp',
`room` = '$rm'");
}
} elseif ((($vr - time()) < 150) && ($nom == 0)) {
$nom = 1;
mysql_query("UPDATE `vopros` SET `number` = '$nom' WHERE `ids` = '2' LIMIT 1");
$first_l = mb_substr($answ, 0, 1, 'UTF8');
$vp = '<b>Первая буква:</b> ' . $first_l . '...';
$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) && ($nom < 2)) {
$nom = 2;
mysql_query("UPDATE `vopros` SET `number` = '$nom' WHERE `ids` = '2' LIMIT 1");
$last_l = mb_substr($answ, -1, 1, 'UTF8');
$vp = '<b>Последняя буква:</b> ' . $last_l . '...';
$ids = mt_rand(100000, 9999999);
mysql_query("INSERT INTO `message` SET
`id` = '$ids',
`user` = 'Анаграмма',
`who` = '0',
`time` = '" . time() . "',
`msg` = '$vp',
`room` = '$rm'");
}
?>