Просмотр файла shouts/index.php

Размер файла: 6.73Kb
  1. <?
  2. /*
  3. =============================================
  4. Движок: SHCMS Engine
  5. =============================================
  6. Название файла: Мини-чат
  7. =============================================
  8. Official website: http://shcms.ru
  9. =============================================
  10. Данный код защищен авторскими правами
  11. =============================================
  12. */
  13. define('SHCMS', true);
  14. include_once'../system/inc/basic_settings.php';
  15. $shcmsengine['title'] = 'Мини-Чат';
  16. include_once'../template/head.php';
  17. if($user_id)
  18. {
  19. echo '<strong>Текст сообщения:</strong><br/>';
  20. if(isset($_GET['otv']))
  21. {
  22. if(isset($_GET['id']))
  23. {
  24. $mess_id = $_GET['id'];
  25. }
  26. $shoutsf = mysql_fetch_array(mysql_query("SELECT * FROM `shouts` WHERE `id` = '$mess_id'"));
  27. $guest_sh = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$shoutsf[user_id]'"));
  28. $mess_ots = '[b]'.$guest_sh['login'].'[/b],';
  29. }
  30. $form = new form ('?');
  31. $form -> textarea (false,'text',$mess_ots,true);
  32. $form->captcha('captcha_guest');
  33. $form -> submit ('Отправить','submit');
  34. $form -> submit ('Обновить','refresh');
  35. $form ->form_link(DIR_SHCMS.'smile.php','Смайлы');
  36. $form->finish();
  37. }
  38. if(isset($_POST['submit']))
  39. {
  40. $submit = $_POST['submit'];
  41. }
  42. if(isset($submit))
  43. {
  44. if(isset($_POST['login']))
  45. {
  46. $submit = $_POST['submit'];
  47. }
  48. if(isset($_POST['text']))
  49. {
  50. $text = $_POST['text'];
  51. }
  52. /*Отключения транслита
  53. if($_POST['tran'] == 1)
  54. {
  55. $text = $translits->translit_rus($text);
  56. }elseif($_POST['tran'] == 2)
  57. {
  58. $text = $translits->translit_eng($text);
  59. }*/
  60. if($settings_shcms['antilink'] == true) {
  61. $text = $system_function->antilink($text);
  62. }
  63. if($settings_shcms['antimat'] == true) {
  64. $text = $system_function->antimat($text);
  65. }
  66. if(empty($text))
  67. {
  68. echo '<div class="errors">Введите текст</div>';
  69. header('Refresh: 1; url=?' . $conservation . '&' );
  70. include_once'../template/foot.php';
  71. exit;
  72. }
  73.  
  74. if(strlen($text)< 0 or strlen($text) > 9200)
  75. {
  76. echo '<div class="errors">Ваш текст не должен превышать 9200символов</div>';
  77. header('Refresh: 1; url=?' . $conservation . '&' );
  78. include_once'../template/foot.php';
  79. exit;
  80. }
  81. if($settings_shcms['captcha_guest'] == 1)
  82. {
  83. $antibot = isset($_POST['kod']) ? trim($_POST['kod']) : '';
  84. if (empty($antibot) || strlen($antibot) < 3)
  85. {
  86. echo '<div class="errors">Код безопастности не введен!</div>';
  87. header('Refresh: 1; url=?' . $conservation . '&' );
  88. include_once'../template/foot.php';
  89. exit;
  90. }
  91. elseif ($antibot != $_SESSION['code'])
  92. {
  93. echo '<div class="errors">Код безопасности не соответствует отображённому</div>';
  94. header('Refresh: 1; url=?' . $conservation . '&' );
  95. include_once'../template/foot.php';
  96. exit;
  97. }
  98. unset($_SESSION['code']);
  99. }
  100.  
  101. $text = stripslashes($text);
  102. $text = htmlspecialchars($text);
  103.  
  104. $yel = mysql_query("INSERT INTO `shouts` (text,time,user_id) VALUES ('".my_esc($text)."','".time()."','$user_id')");
  105. $balls = $users_nav['ball'] +1;
  106. mysql_query("UPDATE `users` SET `ball`='$balls' WHERE `id`='$user_id'");
  107.  
  108. if($yel == true)
  109. {
  110. messag ('Сообщение успешно добавлено');
  111. header('Refresh: 1; url=?'.$conservation.'&' );
  112. include_once'../template/foot.php';
  113. exit;
  114. }
  115. else
  116. {
  117. echo '<div class="errors">Сообщение не добавлено</div>';
  118. header('Refresh: 1; url=?' . $conservation . '&' );
  119. include_once'../template/foot.php';
  120. exit;
  121. }
  122.  
  123. }
  124.  
  125. $allfield = mysql_result(mysql_query("SELECT COUNT(*) FROM `shouts`"),0);
  126. $newlist = new Navigation($allfield, 10, true);
  127.  
  128. $shouts = mysql_query("SELECT * FROM `shouts` ORDER BY `id` DESC ". $newlist->limit()." ");
  129. $shouts2 = mysql_fetch_array($shouts);
  130.  
  131. $count_user = mysql_result(mysql_query("SELECT COUNT(*) FROM `shouts` WHERE `user_id` = '$user_id'"),0);
  132. echo '<div class="maintext"><img src="/template/icon/pisem.gif"/> Всего сообщений в мини чате: <b>'.$allfield.'</b>, из них ваши <b>'.$count_user.'</b></div>';
  133. if($shouts2 == null)
  134. {
  135. echo '<div class="maintext">Сообщений в мини-чате нет</div>';
  136. }
  137. else
  138. {
  139. do
  140. {
  141. echo '<div class="maintitle">';
  142. users_profile($shouts2['user_id']);
  143. list_users($shouts2['user_id']);
  144. echo' <span class="maintime">'.$timedate->times($shouts2['time']).'</span>';
  145. echo '</div>';
  146. echo "<div class='maintext'>".processing($shouts2['text'])."";
  147.  
  148. if($users_user['team'] == 6)
  149. {
  150. echo '<div style="text-align:right"><a href="?otv&id='.$shouts2['id'].'"><img title="Ответить" src="../template/icon/replayal.png"/></a> &nbsp<a href="delete.php?id='.$shouts2['id'].'"><img title="Удалить" src="../template/icon/delete.png"/></a></div>';
  151. }
  152. else{
  153. if($user_id)
  154. {
  155. echo '<div style="text-align:right"><a href="?otv&id='.$shouts2['id'].'"><img title="Ответить" src="../template/icon/replayal.png"/></a></div>';
  156. }
  157. }
  158. echo '</div>';
  159. }
  160. while($shouts2 = mysql_fetch_array($shouts));
  161. echo '<div class="pages">';
  162. echo $newlist->pagination();
  163. echo '</div>';
  164. }
  165. if(isset($_POST['refresh']))
  166. {
  167. $refresh = $_POST['refresh'];
  168. }
  169. if(isset($refresh))
  170. {
  171. header('Refresh: 1; url=?'.$conservation.'&');
  172. }
  173. if($user4['team'] == 6)
  174. {
  175. echo '<div class="posts"><a href="remove_all.php">Очистка мини-чата</a></div>';
  176. }
  177. include_once'../template/foot.php';
  178. ?>