View file modules/chat/send_3.php

File size: 4.88Kb
  1. <?php
  2. ########################################
  3. ## WAP-ENGINE ##
  4. ########################################
  5. ## ##
  6. ## Автор : CHUMA (Токарев Владимир) ##
  7. ## e-mail : crazychuma@gmail.com ##
  8. ## WAP : http://wap-engine.ru ##
  9. ## ##
  10. ########################################
  11. ## ВЫ НЕ ИМЕЕТЕ ПРАВО ##
  12. ## ИЗМЕНЯТЬ КОД СКРИПТА ##
  13. ## ДЛЯ ДАЛЬНЕЙШЕГО РАСПРОСТРАНЕНИЯ! ##
  14. ########################################
  15. include ('../../config.php');
  16. include ('../../templates/run.php');
  17. include ('../../templates/func.php');
  18. ####################
  19. $banlist = file('../../data/ban.txt');
  20. $base = '../../data/chat/3.txt';
  21.  
  22. $gb_flood = '../../data/flood_chat.txt';
  23. $gb_flood_list = file($gb_flood);
  24. $flood_time = time();
  25.  
  26. if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw)
  27. {
  28. $name_guest = $login;
  29. }
  30. else
  31. {
  32. $name_guest = 'Гость';
  33. }
  34.  
  35. $msg = filter($_POST['msg']);
  36. $msg = str_replace('|', '', $msg);
  37. $popravka = $sdvigclock*3600;
  38. $time = date('H:i:s', time() + $popravka);
  39. $date = date('d.m.Y', time() + $popravka);
  40. $ip = filter($_SERVER['REMOTE_ADDR']);
  41. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  42. $brauzer = strtok($user_agent,' ');
  43. $brauzer = filter($brauzer);
  44. $brauzer = str_replace('|', '', $brauzer);
  45. $ban = $brauzer.'||'.$ip;
  46.  
  47. foreach ($banlist as $key => $string)
  48. {
  49. if($ban == trim(array_shift($banlist)))
  50. {
  51. $errb = 1;
  52. }
  53. }
  54.  
  55. $date_now = date ('YmdHis', time() + $popravka);
  56. if($bantime > $date_now)
  57. {
  58. $errb = 2;
  59. }
  60.  
  61. $for = filter($_POST['for']);
  62. $for = str_replace('|', '', $for);
  63. $nicks = file('../../data/nicks.php');
  64. $count_nicks = count($nicks);
  65. $count_nicks = $count_nicks - 2;
  66. for($i=2; $i <= $count_nicks; $i++)
  67. {
  68. if($for == trim($nicks[$i]))
  69. {
  70. $user_est = 1;
  71. break;
  72. }
  73. }
  74.  
  75. # Проверка на флуд
  76. $flood = 0;
  77. foreach ($gb_flood_list as $key => $string)
  78. {
  79. $flood_arr = explode('|', $string);
  80. if(trim($flood_arr[0]) == $ip && trim($flood_arr[1]) + $antiflood_chat >= $flood_time)
  81. {
  82. $flood = 1;
  83. break;
  84. }
  85. }
  86. # Проверка на флуд
  87.  
  88. if(!empty($for) && strlen($for) > 20)
  89. {
  90. header("Location: add_3.php?err=1");
  91. }
  92. elseif(!empty($for) && empty($user_est))
  93. {
  94. header("Location: add_3.php?err=2");
  95. }
  96. elseif(empty($msg))
  97. {
  98. header("Location: add_3.php?err=3");
  99. }
  100. elseif(strlen($msg) > 500)
  101. {
  102. header("Location: add_3.php?err=4");
  103. }
  104. elseif($name_guest=="Гость" && empty($_POST['imgrand']))
  105. {
  106. header("Location: add_3.php?err=5");
  107. }
  108. elseif($name_guest=="Гость" && !empty($_POST['imgrand']) && $_POST['imgrand'] != $_SESSION['rand'])
  109. {
  110. header("Location: add_3.php?err=6");
  111. }
  112. elseif($name_guest=="Гость" && $errb == 1)
  113. {
  114. header("Location: add_3.php?err=7");
  115. }
  116. elseif($errb == 2)
  117. {
  118. header("Location: add_3.php?err=8");
  119. }
  120. elseif($name_guest=="Гость" && $dostup_chat == "0")
  121. {
  122. header("Location: add_3.php?err=9");
  123. }
  124. elseif($flood == 1)
  125. {
  126. header("Location: index_3.php?err=flood");
  127. }
  128. else
  129. {
  130. if ($_POST[msgtrans]==1)
  131. {
  132. $msg = tr_to_win($msg);
  133. }
  134. $msg = smiles($msg);
  135. $msg = antimat($msg);
  136. $msg = bbcodes($msg);
  137. $msg = stripslashes($msg);
  138. $msg = str_replace("\r\n", '<br />', $msg);
  139. $back = @file_get_contents($base);
  140.  
  141. if(!empty($nick_name))
  142. {
  143. $name_guest = $name_guest.'::'.$nick_name.'::'.$nick_color;
  144. }
  145.  
  146. $for_user_f = @file('../../data/users/'.$for.'.php');
  147. $for_nick_name = trim($for_user_f[37]);
  148. if(!empty($for_nick_name))
  149. {
  150. $for_nick_name_arr = explode('::', $for_nick_name);
  151. $for_nick_name_user = $for_nick_name_arr[0];
  152. $for_nick_name_color = $for_nick_name_arr[1];
  153. $for = $for.'::'.$for_nick_name_user.'::'.$for_nick_name_color;
  154. }
  155.  
  156. write_to_file($base, "$name_guest|$for|$brauzer|$ip|$time|$date|$msg"."\r\n"."$back");
  157.  
  158. if(isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw)
  159. {
  160. $mes_chat = $mes_chat + 1;
  161. $rating = $rating + 1;
  162. if($rating == 10 && $status == '5')
  163. {
  164. $status = '4';
  165. }
  166.  
  167. $str_to_user_file = str_user_data(); # Строка данных пользователя находится в файле templates/func.php
  168.  
  169. write_to_file('../../data/users/'.$login.'.php', "<?php\r\n/*\r\n$str_to_user_file\r\n*/\r\n?>");
  170. }
  171.  
  172. # Запись в базу антифлуда
  173. $flood_list_new = $ip.'|'.$flood_time."\r\n";
  174. foreach ($gb_flood_list as $key => $string)
  175. {
  176. $flood_arr = explode('|', $string);
  177.  
  178. if(trim($flood_arr[0]) != $ip && trim($flood_arr[1]) + $antiflood_chat >= $flood_time)
  179. {
  180. $flood_list_new .= trim($flood_arr[0]).'|'.trim($flood_arr[1])."\r\n";
  181. }
  182. }
  183.  
  184. write_to_file($gb_flood, $flood_list_new);
  185. # Запись в базу антифлуда
  186.  
  187. header ('Location: index_3.php?'.session_name().'='.session_id().'');
  188. }
  189. ####################
  190. ?>