Просмотр файла include/newtt.php

Размер файла: 14.37Kb
  1. <?
  2. if(!$authorize AND $AuthorAnonim)
  3. {
  4. $f = intval($_GET['f']);
  5. @$back = mysql_fetch_assoc(mysql_query("SELECT name, id FROM `forums` WHERE id=".$f));
  6. $ip = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR'] ;
  7. $ip = htmlspecialchars(addslashes($ip));
  8. $user = htmlspecialchars(sql($_SERVER['HTTP_USER_AGENT']));
  9. if(!mysql_result(mysql_query("SELECT COUNT(*) FROM forums WHERE id=".$f), 0))
  10. {
  11. if($version == "wml")
  12. {
  13. header('Content-type: text/vnd.wap.wml; charset=utf-8');
  14. header("Cache-Control: no-cache");
  15. echo(doctype("Ошибка").$tag.'
  16. Ошибка! Подфорума не существует! <br />
  17. <a href="./?p=0&amp;v=wml">Форумы</a>
  18. '.$tagC.'</p></card></wml>');
  19. } elseif($version == "xhtml")
  20. {
  21. header("Content-type: text/html; charset=utf-8");
  22. header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
  23. header("Cache-Control: no-cache, must-relative");
  24. echo('<html>
  25. <head>
  26. <title>Ошибка</title>
  27. </head>
  28. <body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
  29. <table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
  30. <tr><td align="center" bgcolor="'.$style['title'].'">
  31. <font color="#FFFFFF"><b>Ошибка</b></font>
  32. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Ошибка! Подфорума не существует! '.$tagC.' </td></tr>
  33. <tr bgcolor="'.$style['bottom'].'"><td>'.$tag.'
  34. <a href="./?p=0&amp;v=xhtml">Форумы</a>
  35. '.$tagC.'</td></tr></table>
  36. </body></html>');
  37. }
  38. } elseif(ban($user, $ip))
  39. {
  40. if($version == "wml")
  41. {
  42. header('Content-type: text/vnd.wap.wml; charset=utf-8');
  43. header("Cache-Control: no-cache");
  44. echo(doctype("Ошибка").$tag.'
  45. Ошибка! Вы заблокированы модератором '.$modername.'. <br />
  46. Причина: '.$banmess.'! <br />
  47. -
  48. <a href="'.$_SERVER['HTTP_REFERER'].'">Назад</a><br />
  49. <a href="./?p=0&amp;v=wml">Форумы</a>
  50. '.$tagC.'</p></card></wml>');
  51. } elseif($version == "xhtml")
  52. {
  53. header("Content-type: text/html; charset=utf-8");
  54. header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
  55. header("Cache-Control: no-cache, must-relative");
  56. echo('<html>
  57. <head>
  58. <title>Ошибка</title>
  59. </head>
  60. <body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
  61. <table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
  62. <tr align="center" bgcolor="'.$style['title'].'"><td colspan="2">
  63. <font color="#FFFFFF"><b>Ошибка</b></font>
  64. <tr bgcolor="'.$style['text'].'"><td colspan="2">'.$tag.'Вы заблокированы модератором '.$modername.'</td></tr>
  65. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Причина:'.$tagC.'</td><td>'.$tag.$banmess.$tagC.'</td></tr>
  66. <tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
  67. <a href="./?p=0&amp;v=xhtml">Форумы</a>
  68. '.$tagC.'</td></tr></table>
  69. </body></html>');
  70. }
  71. } else
  72. {
  73. if(empty($_POST['nt']))
  74. {
  75. $r = "";
  76. for($i=0; $i<strlen($username); $i++)
  77. {
  78. $r .= "_";
  79. }
  80. if($version == "wml")
  81. {
  82. header("Content-type: text/vnd.wap.wml; charset=utf-8");
  83. header("Cache-Control: no-cache");
  84. echo(doctype("Новая тема").$tag.'
  85. <b>Добавить тему в "'.$back['name'].'"</b><br /> <br />
  86. Имя: <input type="text" name="author" maxlength="10" /><br />
  87. Тема: '.$tagC.'<br />
  88. <input type="text" name="topic'.$ref.'" /><br />
  89. '.$tag.'Сообщение:'.$tagC.' <br />
  90. <input type="text" name="mess'.$ref.'" maxlength="600" /><br />');
  91. echo($tag.'Транслит: '.$tagC.'<br />
  92. <select name="transl'.$ref.'">
  93. <option value="0">Нет</option>
  94. <option value="1">Да</option>
  95. </select><br />
  96. <img src="./img.php?rnd='.$ref.'" alt="" /><br />
  97. <a href="./?p=31&amp;v=wml&amp;f='.$f.'&amp;rnd='.$ref.'">[Обновить код]</a><br />
  98. Введите число на картинке сверху: <input type="text" name="code" value="" maxlength="5" size="5" /><br />');
  99. echo('<anchor>[Добавить]
  100. <go href="./?p=31&amp;v=wml&amp;f='.$f.'&amp;rnd='.$ref.'" method="post">
  101. <postfield name="mess" value="$(mess'.$ref.')" />
  102. <postfield name="topic" value="$(topic'.$ref.')" />
  103. <postfield name="transl" value="$(transl'.$ref.')" />
  104. <postfield name="code" value="$(code'.$ref.')" />
  105. <postfield name="nt" value="1" />
  106. </go></anchor><br />
  107. '.$tag.'-
  108. <a href="./?p=14&amp;v=wml&amp;f=4">Смайлы</a><br />
  109. <a href="./?p=2&amp;v=wml&amp;f='.$f.'">Назад в «'.$back['name'].'»</a><br />
  110. '.$tagC.'</p></card></wml>');
  111. } elseif($version == "xhtml")
  112. {
  113. header("Content-type: text/html; charset=utf-8");
  114. header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
  115. header("Cache-Control: no-cache, must-relative");
  116. echo('<html>
  117. <head>
  118. <title>Новая тема</title>
  119. </head>
  120. <body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
  121. <form action="./?p=31&amp;v=xhtml&amp;f='.$f.'&amp;rnd='.$ref.'" method="post">
  122. <table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
  123. <tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
  124. <font color="#FFFFFF"><b>Новая тема</b></font>
  125. </td></tr>
  126. <tr bgcolor="'.$style['bottom'].'"><td colspan="2"><b>'.$tag.'Добавить тему в "'.$back['name'].'"'.$tagC.'</b></td></tr>
  127. <tr bgcolor="#deebf1"><td colspan="2"></td></tr>
  128. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td><input type="text" name="author" maxlength="10" /></td></tr>
  129. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Тема:'.$tagC.'</td><td><input type="text" name="topic"></td></tr>
  130. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Сообщение:'.$tagC.'</td><td><textarea name="mess" cols="30" rows="5"></textarea></td></tr>');
  131. echo('<tr bgcolor="'.$style['text'].'"><td nowrap>'.$tag.'Транслит:'.$tagC.'</td>
  132. <td><select name="transl">
  133. <option value="0">Нет</option>
  134. <option value="1">Да</option>
  135. </select></td></tr>
  136. <tr bgcolor="'.$style['text'].'"><td></td><td><img src="./img.php?rnd='.$ref.'" alt="" /><br />
  137. <a href="./?p=31&amp;v=xhtml&amp;f='.$f.'&amp;rnd='.$ref.'">[Обновить код]</a></td></tr>
  138. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Введите число на картинке сверху:'.$tagC.'</td><td><input type="text" name="code" value="" maxlength="5" size="5" /><br /></td></tr>
  139. <tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
  140. <input type="hidden" name="nt" value="1">
  141. <input type="submit" value="Добавить" /></td></tr>
  142. <tr bgcolor="'.$style['bottom'].'"><td colspan="2"> '.$tag.'
  143. <a href="./?p=14&amp;v=xhtml&amp;f=4">Смайлы</a><br />
  144. <a href="./?p=2&amp;v=xhtml&amp;f='.$back['id'].'">Назад в «'.$back['name'].'»</a><br />
  145. '.$tagC.'</td></tr></table>
  146. </form>
  147. </body></html>');
  148. }
  149. } else
  150. {
  151. $error = "";
  152. $topic = $_POST['topic'];
  153. $transl = sql(trim(htmlspecialchars(chop($_POST['transl']))));
  154. $username = sql(trim(htmlspecialchars(chop($_POST['author']))));
  155. $code = file_get_contents("./codes/".$_GET['rnd'].".txt");
  156. $_POST['code'] = htmlspecialchars($_POST['code']);
  157. if($transl == "1")
  158. {
  159. $topic = translate($topic);
  160. $message = translate($message);
  161. }
  162. $topic = cutString($topic, 256);
  163. $topic = sql(trim(htmlspecialchars(chop($topic))));
  164. $topic = preg_replace("|[\r\n]+|", "\r\n", $topic);
  165. $topic = preg_replace("|[\n]+|", "\n", $topic);
  166. $message = $_POST['mess'];
  167. $message = preg_replace("|[\r\n]+|", " \r\n", $message);
  168. $message = preg_replace("|[\n]+|", "\n", $message);
  169. $message = sql(htmlspecialchars(trim(chop(cutString($message, 1024)))));
  170. $message = preg_replace_callback("|&lt;(\d{1,20})&gt;|", "smile", $message);
  171. $sesss = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."'");
  172. $sesRR = mysql_fetch_array($sesss);
  173. $upd = $sesRR['upd'];
  174. $rz = time() - $upd;
  175. if(!preg_match("|^[<>@\[\] -\.\_0-9a-zA-Zа-яА-Я]+$|u", $username) or strlen($username) > 20)
  176. {
  177. $error .= "Ошибка!!! Поле \"Имя\" пустое или содержит плохие символы <br />";
  178. }
  179. if(empty($topic))
  180. {
  181. $error .= "Ошибка!!! Поле \"Тема\" не заполнено <br />";
  182. } if(!preg_match("|^[-a-z0-9а-яё_!?№#;:%^&*()+=~\|\\\/ @.,\[\]\{\}\"'<>]*$|iu", $topic))
  183. {
  184. $error .= "Ошибка!!! Тема содержит плохие символы <br />";
  185. } if(empty($message))
  186. {
  187. $error .= "Ошибка!!! Поле \"Сообщение\" не заполнено <br />";
  188. } if(!preg_match("|^[-a-z0-9а-яё_!?№#;:%^&*()+=~\|\\\/ @.,\[\]\{\}\"'<>\s]*$|iu", $message))
  189. {
  190. $error .= "Ошибка!!! Сообщение содержит плохие символы <br />";
  191. } if(empty($_POST['code']) or $_POST['code'] != $code)
  192. {
  193. $error .= "Ошибка!!! Неверно введен код из 5ти цифр с картинки<br />";
  194. }
  195. if(strpos($message, "http://") !== false)
  196. {
  197. $message = preg_replace("|(http://[^\s]+)|i", "<a href=\"go/?\\1\">\\1</a>", $message);
  198. }
  199. else if(strpos($message, "HTTP://") !== false)
  200. {
  201. $message = preg_replace("|(HTTP://[^\s]+)|i", "<a href=\"go/?\\1\">\\1</a>", $message);
  202. }
  203. if(mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE username='".$username."'"), 0) > 0)
  204. {
  205. $error .= "Ошибка!!! Для использования этого имени необходима авторизация <br />";
  206. }
  207. if ($rz <= 3600) {
  208. $error .= "Не стоит создавать столько тем! <br />";
  209. }
  210. if(!empty($error))
  211. {
  212. unlink('./codes/'.$_GET['rnd'].'.txt');
  213. $r = "";
  214. for($i=0; $i<strlen($username); $i++)
  215. {
  216. $r .= "_";
  217. }
  218. if($version == "wml")
  219. {
  220. header("Content-type: text/vnd.wap.wml; charset=utf-8");
  221. header("Cache-Control: no-cache");
  222. echo(doctype("Новая тема").$tag.$error.'
  223. <b>Добавить тему в "'.$back['name'].'"</b><br /> <br />
  224. Имя: <input type="text" name="author" maxlength="10" /><br />
  225. Тема:'.$tagC.' <br />
  226. <input type="text" name="topic'.$ref.'" /><br />
  227. '.$tag.'Сообщение:'.$tagC.' <br />
  228. <input type="text" name="mess'.$ref.'" maxlength="600" /><br />');
  229. echo($tag.'Транслит: '.$tagC.'<br />
  230. <select name="transl'.$ref.'">
  231. <option value="0">Нет</option>
  232. <option value="1">Да</option>
  233. </select><br />
  234. <img src="./img.php?rnd='.$ref.'" alt="" />
  235. <br />
  236. <a href="./?p=31&amp;v=wml&amp;f='.$f.'&amp;rnd='.$ref.'">[Обновить код]</a><br />
  237. Введите число на картинке сверху: <input type="text" name="code" value="" maxlength="5" size="5" /><br />');
  238. echo('
  239. <anchor>[Добавить]
  240. <go href="./?p=31&amp;v=wml&amp;f='.$f.'&amp;rnd='.$ref.'" method="post">
  241. <postfield name="mess" value="$(mess'.$ref.')" />
  242. <postfield name="transl" value="$(transl'.$ref.')" />
  243. <postfield name="topic" value="$(topic'.$ref.')" />
  244. <postfield name="code" value="$(code'.$ref.')" />
  245. <postfield name="nt" value="1" />
  246. </go></anchor><br />
  247. '.$tag.'-
  248. <a href="./?p=14&amp;v=wml&amp;f=4">Смайлы</a><br />
  249. <a href="./?p=2&amp;v=wml&amp;f='.$f.'">Назад в '.$back['name'].'</a><br />
  250. '.$tagC.'</p></card></wml>');
  251. } elseif($version == "xhtml")
  252. {
  253. header("Content-type: text/html; charset=utf-8");
  254. header("Last-Modified:".gmdate("D, d M Y H:i:s")." GMT");
  255. header("Cache-Control: no-cache, must-relative");
  256. echo('<html>
  257. <head>
  258. <title>Новая тема</title>
  259. </head>
  260. <body bgcolor="'.$style['background'].'" link="'.$style['link'].'" vlink="'.$style['link'].'" text="#000000">
  261. <form action="./?p=31&amp;v=xhtml&amp;f='.$f.'&amp;rnd='.$ref.'" method="post">
  262. <table align="center" border="0" cellspacing="1" cellpadding="5" width="350">
  263. <tr><td align="center" bgcolor="'.$style['title'].'" colspan="2">
  264. <font color="#FFFFFF"><b>Новая тема</b></font>
  265. </td></tr>
  266. <tr bgcolor="'.$style['bottom'].'"><td colspan="2"><b>'.$tag.'Добавить тему в "'.$back['name'].'"'.$tagC.'</b></td></tr>
  267. <tr bgcolor="#deebf1"><td colspan="2">'.$tag.'<b>'.$error.'</b>'.$tagC.'</td></tr>
  268. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Имя:'.$tagC.'</td><td><input type="text" name="author" maxlength="10" /></td></tr>
  269. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Тема:'.$tagC.'</td><td><input type="text" name="topic"></td></tr>
  270. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Сообщение:'.$tagC.'</td><td><textarea name="mess" cols="30" rows="5"></textarea></td></tr>');
  271. echo('<tr bgcolor="'.$style['text'].'"><td nowrap>'.$tag.'Транслит:'.$tagC.'</td>
  272. <td><select name="transl">
  273. <option value="0">Нет</option>
  274. <option value="1">Да</option>
  275. </select></td></tr>');
  276. echo('
  277. <tr bgcolor="'.$style['text'].'"><td></td><td><img src="./img.php?rnd='.$ref.'" alt="" /><br />
  278. <a href="./?p=31&amp;v=xhtml&amp;f='.$f.'&amp;rnd='.$ref.'">[Обновить код]</a></td></tr>
  279. <tr bgcolor="'.$style['text'].'"><td>'.$tag.'Введите число на картинке сверху:'.$tagC.'</td><td><input type="text" name="code" value="" maxlength="5" size="5" /><br /></td></tr>
  280. <tr bgcolor="'.$style['text'].'"><td align="center" colspan="2">
  281. <input type="hidden" name="nt" value="1">
  282. <input type="submit" value="Добавить" /></td></tr>
  283. <tr bgcolor="'.$style['bottom'].'"><td colspan="2">'.$tag.'
  284. <a href="./?p=14&amp;v=xhtml&amp;f=4">Смайлы</a><br />
  285. <a href="./?p=2&amp;v=xhtml&amp;f='.$back['id'].'">Назад в '.$back['name'].'</a><br />
  286. '.$tagC.'
  287. </td></tr>
  288. </table>
  289. </form>
  290. </body></html>');
  291. }
  292. } else
  293. {
  294. unlink('./codes/'.$_GET['rnd'].'.txt');
  295. if(mysql_result(
  296. mysql_query("SELECT COUNT(*)
  297. FROM `themes`
  298. WHERE `tname` = '".$topic."'
  299. AND `name` = '".$username."'"), 0))
  300. {
  301. header("Location: ".$forumdir."p=2&v=".$version."&f=".$f);
  302. exit();
  303. }
  304. {
  305. $SQL = "INSERT INTO `themes` VALUES(0, '".$topic."', '".$username."', 'off', ".$f.", ".time().", 1, 0, '')";
  306. }
  307. mysql_query($SQL);
  308. mysql_query("INSERT INTO `posts` VALUES (0, '".$username."', '".$message."', ".crc32($message).", '".mysql_insert_id()."', '".time()."', '".$user."', '".$ip."')");
  309. header("Location: ".$forumdir."p=2&v=".$version."&f=".$f);
  310. }
  311. }
  312. }
  313. }
  314. ?>