Файл: minichat_by_KoT/minichat_by_KoT/umnik1.php
Строк: 102
<?php
##########################################
# ~ Разработка отдельных модулей ~~~~~~~ #
# ~ и написание скриптов на php (c)KoT ~ #
# ~ ICQ: 7675072 ~~~~~~~~~~~~~~~~~~~~~~~ #
# ~ Site: 4atlove.ru ~~~~~~~~~~~~~~~~~~~ #
# ~ E-mail: notefree@bk.ru ~~~~~~~~~~~~~ #
##########################################
$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();
$st = $st + 240;
mysql_query("UPDATE `vopros` SET `time` = '$st' WHERE `ids` = '1'");
$a = mysql_fetch_array(mysql_query("SELECT count(*) as num FROM `question`"));
$num = $a['num'];
$rnd = mt_rand(1, $num);
$re = mysql_fetch_array(mysql_query("SELECT * FROM `question` WHERE `number`='$rnd'"));
$answ = $re['answer'];
$tran = $re['tran'];
$nom = 0;
$vr = $st;
$i = strlen2($tran);
$wop = mt_rand(1,9);
$wop = str_replace(1, '<b>Вопрос:</b>', $wop);
$wop = str_replace(2, '<b>А вот и вопрос:</b>', $wop);
$wop = str_replace(3, '<b>Ответите ли вы на это:</b>', $wop);
$wop = str_replace(4, '<b>А теперь ответьте на это:</b>', $wop);
$wop = str_replace(5, '<b>Вопросик:</b>', $wop);
$wop = str_replace(6, '<b>Вопросище:</b>', $wop);
$wop = str_replace(7, '<b>Отвечаем на:</b>', $wop);
$wop = str_replace(8, '<b>Итак:</b>', $wop);
$wop = str_replace(9, '<b>ВНИМАНИЕ! Вопрос:</b>', $wop);
$vp = $wop.' '.$re['vopros'].' ('.$i.' букв)';
mysql_query("UPDATE `vopros` SET `number` = '$nom', `question` = '$vp', `answer` = '$answ', `tran` = '$tran' WHERE `ids`='1'");
$today = date("H:i:s");
mysql_query("INSERT INTO `message` (`user`,`user_id`,`time`,`msg`,`rm`,`color`,`font`) VALUES ('$umnig','1','".$today."','$vp','$rm','6','0')");
} else {
$victint = 30;
$st = time();
$st = $st + $victint;
mysql_query("UPDATE `vopros` SET `time` = '$st' WHERE `ids` = '1'");
$a = mysql_fetch_array(mysql_query("SELECT count(*) as num FROM `question`"));
$num = $a['num'];
$rnd = mt_rand(1, $a['num']);
$re = mysql_fetch_array(mysql_query("SELECT * FROM `question` WHERE `number`='$rnd'"));
$answ = $re['answer'];
$tran = $re['tran'];
$nom = 5;
$vr = $st;
$b1 = mysql_fetch_array(mysql_query("SELECT `answer` FROM `vopros` WHERE `ids`='1'"));
$otvet = $b1['answer'];
$vp = 'Ответ на вопрос был: <b>'.$otvet.'</b>!';
$today = date("H:i:s");
mysql_query("INSERT INTO `message` (`user`,`user_id`,`time`,`msg`,`rm`,`color`,`font`) VALUES ('$umnig','1','".$today."','$vp','$rm','6','0')");
mysql_query("UPDATE `vopros` SET `number` = '$nom', `answer` = '$answ', `tran` = '$tran' WHERE `ids`='1'");
$ehvi = file('badumn.txt');
$mda = $ehvi[rand(0, count($ehvi) - 1)];
$mda = str_replace("n", '', $mda);
$mda = str_replace("r", '', $mda);
$vp = $mda . ' Следующий вопрос через 30 секунд.';
$today = date("H:i:s");
$rnd = mt_rand(0, 99999999);
$today = date("H:i:s");
mysql_query("INSERT INTO `message` (`user`,`user_id`,`time`,`msg`,`rm`,`color`,`font`) VALUES ('$umnig','1','".$today."','$vp','$rm','6','0')");
}
}
elseif ((($vr - time()) < 180) && ($nom == 0)) {
$nom = 1;
mysql_query("UPDATE `vopros` SET `number` = '$nom' WHERE `ids`='1'");
#$answ2 = $answ;
#$answ2 = mb_substr($answ2, 0, 2, 'UTF8');
#$answ2 = preg_replace('#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,0}'.'((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,500}).*#s','$1',$answ2);
$v = utf_to_win($answ);
$i = strlen($v)/3;
if ($i < 2) $i = 2;
$v = substr($v,0,$i);
$v = win_to_utf($v);
$vp = '<b>Подсказка:</b> '.$v.'...';
$today = date("H:i:s");
mysql_query("INSERT INTO `message` (`user`,`user_id`,`time`,`msg`,`rm`,`color`,`font`) VALUES ('$umnig','1','".$today."','$vp','$rm','6','0')");
} elseif ((($vr - time()) < 90) && ($nom < 2)) {
$nom = 2;
mysql_query("UPDATE `vopros` SET `number` = '$nom' WHERE `ids`='1'");
#$answ2 = $answ;
#$answ2 = mb_substr($answ2, 0, 4, 'UTF8');
#$answ2 = preg_replace('#^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,0}'.'((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,500}).*#s','$1',$answ2);
$v = utf_to_win($answ);
$v = mb_substr($v,0,1,'UTF8');
$v = win_to_utf($v);
$vp = '<b>Подсказка:</b> '.$v.'...';
$today = date("H:i:s");
mysql_query("INSERT INTO `message` (`user`,`user_id`,`time`,`msg`,`rm`,`color`,`font`) VALUES ('$umnig','1','".$today."','$vp','$rm','6','0')");
}
?>