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

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