Размер файла: 6.27Kb
- <?php
- //POWERED by ILI
- // ICQ : 197042
- //site: ili.wab.ru
- // ilichat v4.0
- error_reporting(0);
- require_once"./includes/functions/gzip.php";
- include('start.php');
- include("config.php");
- include("./includes/".$ver."/banned");
-
- $rid = intval($_GET['rid']);
-
- list($msec, $sec) = explode(chr(32), microtime());
- $headtime = $sec + $msec;
- $nocache = rand(1000, 9999);
-
- switch($ver)
- {
- case 'wml':
- ///////////////////////////////////////////////////////
- //WML VERSION
- ///////////////////////////////////////////////////////
-
- header("Content-type: text/vnd.wap.wml; charset=utf-8");
- header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
- header("Cache-Control: no-cache, must-revalidate");
-
- //AUTH
- $id = intval($_SESSION['id']);
- $password = mysql_escape_string($_SESSION['password']);
- $q = mysql_query("SELECT `posts` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
- if(mysql_num_rows($q) == 0)
- {
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
- echo "<card title=\"ERROR\" ontimer=\"index.php?ver=wml\"><timer value=\"15\"/><p align=\"left\">\n";
- echo "<small>Ошибка авторизации!<br/>\n";
- list($msec, $sec) = explode(chr(32), microtime());
- echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
- echo "</small>";
- require_once "includes/functions/gzip_foot.php";
- echo "</p></card></wml>";
- ob_end_flush();
- exit();
- }
-
- //POSTS CHECK
- $posts = mysql_result($q, 0);
- if($posts < 50)
- {
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
- echo "<card title=\"Buy an answer\" ontimer=\"room.php?".SID."&ver=wml&rid=$rid&nocache=$nocache\"><timer value=\"15\"/><p align=\"left\">\n";
- echo "Чтобы получить ответ, Вам необходимо набрать минимум 50 постов в чате.<br/>\n";
- list($msec, $sec) = explode(chr(32), microtime());
- echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
- require_once "includes/functions/gzip_foot.php";
- echo "</p></card></wml>";
- ob_end_flush();
- exit();
- }
- //END POSTS CHECK
-
-
- if(!isset($_POST['action'])){
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
- echo "<card title=\"Buy an answer\"><p align=\"left\">\n";
- echo "Нажав на ссылку внизу вы можете получить ответ на текущий вопрос<br/>\n";
- echo "<anchor>Получить<go href=\"ansbuy.php?".SID."&ver=wml&rid=$rid&nocache=$nocache\" method=\"post\">\n";
- echo "<postfield name=\"action\" value=\"1\"/>\n";
- echo "</go></anchor><br/>\n";
- print '<br/><a href="room.php?'.SID.'&ver=wml&rid='.$rid.'&nocache='.$nocache.'">Викторина</a><br/>';
- list($msec, $sec) = explode(chr(32), microtime());
- echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
- require_once "includes/functions/gzip_foot.php";
- echo "</p></card></wml>";
- ob_end_flush();
- }
- else{
- //ANSWER
- if($rid == 1){
- $fd = fopen("bots/answer.dat", "r");
- $answer = fgets($fd);
- fclose($fd);
- }
- else{
- $fd = fopen("bots/second_bot/answer.dat", "r");
- $answer = fgets($fd);
- fclose($fd);
- }
- echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
- echo "<card title=\"Buy an answer\"><p align=\"left\">\n";
- echo $answer;
- mysql_query("UPDATE `chat_users` SET `posts` = ".$posts." - '50' WHERE `id` = '".$id."';");
- print '<br/><a href="room.php?'.SID.'&ver=wml&rid='.$rid.'&nocache='.$nocache.'">Викторина</a><br/>';
- list($msec, $sec) = explode(chr(32), microtime());
- echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
- require_once "includes/functions/gzip_foot.php";
- echo "</p></card></wml>";
- ob_end_flush();
- }
- break;
-
- case 'html':
- ///////////////////////////////////////////////////////
- //HTML VERSION
- ///////////////////////////////////////////////////////
-
- $my_title = "Menu";
- if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = 1;
- include_once "themes/".intval($_COOKIE['theme'])."/index.php";
-
- //AUTH
- $id = intval($_SESSION['id']);
- $password = mysql_escape_string($_SESSION['password']);
- $q = mysql_query("SELECT `posts` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
- if(mysql_num_rows($q) == 0)
- {
- echo "Ошибка авторизации!<br/>\n";
- include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
- exit();
- }
- //END AUTH
-
- //POSTS CHECK
- $posts = mysql_result($q, 0);
- if($posts < 50)
- {
- echo "Чтобы получить ответ, Вам необходимо набрать минимум 50 постов в чате.<br/>\n";
- print '<br/><a href="room.php?'.SID.'&ver=html&rid='.$rid.'&nocache='.$nocache.'">Викторина</a><br/>';
- include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
- exit();
- }
- //END POSTS CHECK
-
-
- if(!isset($_POST['action'])){
- echo "Нажав на кнопку внизу вы можете получить ответ на текущий вопрос<br/>\n";
- echo "<div class=\"form\">\n";
- echo "<form action=\"ansbuy.php?".SID."&ver=html&rid=$rid&nocache=$nocache\" method=\"post\">\n";
- echo "<input type=\"hidden\" name=\"action\" value=\"1\" />\n";
- echo "<input type=\"submit\" value=\"Получить\" /></form></div>\n";
- print '<a href="room.php?'.SID.'&ver=html&rid='.$rid.'&nocache='.$nocache.'">Викторина</a><br/>';
- include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
- }
- else{
- //ANSWER
- if($rid == 1){
- $fd = fopen("bots/answer.dat", "r");
- $answer = fgets($fd);
- fclose($fd);
- }
- else{
- $fd = fopen("bots/second_bot/answer.dat", "r");
- $answer = fgets($fd);
- fclose($fd);
- }
-
- echo $answer;
- mysql_query("UPDATE `chat_users` SET `posts` = ".$posts." - '50' WHERE `id` = '".$id."';");
- print '<br/><a href="room.php?'.SID.'&ver=html&rid='.$rid.'&nocache='.$nocache.'">Викторина</a><br/>';
- include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
- }
- break;
- }
- ?>