Просмотр файла ilichat/ansbuy.php

Размер файла: 6.27Kb
  1. <?php
  2. //POWERED by ILI
  3. // ICQ : 197042
  4. //site: ili.wab.ru
  5. // ilichat v4.0
  6. error_reporting(0);
  7. require_once"./includes/functions/gzip.php";
  8. include('start.php');
  9. include("config.php");
  10. include("./includes/".$ver."/banned");
  11.  
  12. $rid = intval($_GET['rid']);
  13.  
  14. list($msec, $sec) = explode(chr(32), microtime());
  15. $headtime = $sec + $msec;
  16. $nocache = rand(1000, 9999);
  17.  
  18. switch($ver)
  19. {
  20. case 'wml':
  21. ///////////////////////////////////////////////////////
  22. //WML VERSION
  23. ///////////////////////////////////////////////////////
  24.  
  25. header("Content-type: text/vnd.wap.wml; charset=utf-8");
  26. header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  27. header("Cache-Control: no-cache, must-revalidate");
  28.  
  29. //AUTH
  30. $id = intval($_SESSION['id']);
  31. $password = mysql_escape_string($_SESSION['password']);
  32. $q = mysql_query("SELECT `posts` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
  33. if(mysql_num_rows($q) == 0)
  34. {
  35. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  36. echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
  37. echo "<card title=\"ERROR\" ontimer=\"index.php?ver=wml\"><timer value=\"15\"/><p align=\"left\">\n";
  38. echo "<small>Ошибка авторизации!<br/>\n";
  39. list($msec, $sec) = explode(chr(32), microtime());
  40. echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
  41. echo "</small>";
  42. require_once "includes/functions/gzip_foot.php";
  43. echo "</p></card></wml>";
  44. ob_end_flush();
  45. exit();
  46. }
  47.  
  48. //POSTS CHECK
  49. $posts = mysql_result($q, 0);
  50. if($posts < 50)
  51. {
  52. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  53. echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
  54. echo "<card title=\"Buy an answer\" ontimer=\"room.php?".SID."&amp;ver=wml&amp;rid=$rid&amp;nocache=$nocache\"><timer value=\"15\"/><p align=\"left\">\n";
  55. echo "Чтобы получить ответ, Вам необходимо набрать минимум 50 постов в чате.<br/>\n";
  56. list($msec, $sec) = explode(chr(32), microtime());
  57. echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
  58. require_once "includes/functions/gzip_foot.php";
  59. echo "</p></card></wml>";
  60. ob_end_flush();
  61. exit();
  62. }
  63. //END POSTS CHECK
  64.  
  65.  
  66. if(!isset($_POST['action'])){
  67. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  68. echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
  69. echo "<card title=\"Buy an answer\"><p align=\"left\">\n";
  70. echo "Нажав на ссылку внизу вы можете получить ответ на текущий вопрос<br/>\n";
  71. echo "<anchor>Получить<go href=\"ansbuy.php?".SID."&amp;ver=wml&amp;rid=$rid&amp;nocache=$nocache\" method=\"post\">\n";
  72. echo "<postfield name=\"action\" value=\"1\"/>\n";
  73. echo "</go></anchor><br/>\n";
  74. print '<br/><a href="room.php?'.SID.'&amp;ver=wml&amp;rid='.$rid.'&amp;nocache='.$nocache.'">Викторина</a><br/>';
  75. list($msec, $sec) = explode(chr(32), microtime());
  76. echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
  77. require_once "includes/functions/gzip_foot.php";
  78. echo "</p></card></wml>";
  79. ob_end_flush();
  80. }
  81. else{
  82. //ANSWER
  83. if($rid == 1){
  84. $fd = fopen("bots/answer.dat", "r");
  85. $answer = fgets($fd);
  86. fclose($fd);
  87. }
  88. else{
  89. $fd = fopen("bots/second_bot/answer.dat", "r");
  90. $answer = fgets($fd);
  91. fclose($fd);
  92. }
  93. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  94. echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.3//EN\" \"http://www.wapforum.org/DTD/wml13.dtd\"><wml>\n";
  95. echo "<card title=\"Buy an answer\"><p align=\"left\">\n";
  96. echo $answer;
  97. mysql_query("UPDATE `chat_users` SET `posts` = ".$posts." - '50' WHERE `id` = '".$id."';");
  98. print '<br/><a href="room.php?'.SID.'&amp;ver=wml&amp;rid='.$rid.'&amp;nocache='.$nocache.'">Викторина</a><br/>';
  99. list($msec, $sec) = explode(chr(32), microtime());
  100. echo "<br/>[".round(($sec+$msec)-$headtime,5)."] sec<br/>\n";
  101. require_once "includes/functions/gzip_foot.php";
  102. echo "</p></card></wml>";
  103. ob_end_flush();
  104. }
  105. break;
  106.  
  107. case 'html':
  108. ///////////////////////////////////////////////////////
  109. //HTML VERSION
  110. ///////////////////////////////////////////////////////
  111.  
  112. $my_title = "Menu";
  113. if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = 1;
  114. include_once "themes/".intval($_COOKIE['theme'])."/index.php";
  115.  
  116. //AUTH
  117. $id = intval($_SESSION['id']);
  118. $password = mysql_escape_string($_SESSION['password']);
  119. $q = mysql_query("SELECT `posts` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';");
  120. if(mysql_num_rows($q) == 0)
  121. {
  122. echo "Ошибка авторизации!<br/>\n";
  123. include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
  124. exit();
  125. }
  126. //END AUTH
  127.  
  128. //POSTS CHECK
  129. $posts = mysql_result($q, 0);
  130. if($posts < 50)
  131. {
  132. echo "Чтобы получить ответ, Вам необходимо набрать минимум 50 постов в чате.<br/>\n";
  133. print '<br/><a href="room.php?'.SID.'&amp;ver=html&amp;rid='.$rid.'&amp;nocache='.$nocache.'">Викторина</a><br/>';
  134. include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
  135. exit();
  136. }
  137. //END POSTS CHECK
  138.  
  139.  
  140. if(!isset($_POST['action'])){
  141. echo "Нажав на кнопку внизу вы можете получить ответ на текущий вопрос<br/>\n";
  142. echo "<div class=\"form\">\n";
  143. echo "<form action=\"ansbuy.php?".SID."&amp;ver=html&amp;rid=$rid&amp;nocache=$nocache\" method=\"post\">\n";
  144. echo "<input type=\"hidden\" name=\"action\" value=\"1\" />\n";
  145. echo "<input type=\"submit\" value=\"Получить\" /></form></div>\n";
  146. print '<a href="room.php?'.SID.'&amp;ver=html&amp;rid='.$rid.'&amp;nocache='.$nocache.'">Викторина</a><br/>';
  147. include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
  148. }
  149. else{
  150. //ANSWER
  151. if($rid == 1){
  152. $fd = fopen("bots/answer.dat", "r");
  153. $answer = fgets($fd);
  154. fclose($fd);
  155. }
  156. else{
  157. $fd = fopen("bots/second_bot/answer.dat", "r");
  158. $answer = fgets($fd);
  159. fclose($fd);
  160. }
  161.  
  162. echo $answer;
  163. mysql_query("UPDATE `chat_users` SET `posts` = ".$posts." - '50' WHERE `id` = '".$id."';");
  164. print '<br/><a href="room.php?'.SID.'&amp;ver=html&amp;rid='.$rid.'&amp;nocache='.$nocache.'">Викторина</a><br/>';
  165. include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
  166. }
  167. break;
  168. }
  169. ?>