Просмотр файла download/comment.php

Размер файла: 4.29Kb
  1. <?
  2. /*
  3. =============================================
  4. Движок: SHCMS Engine
  5. =============================================
  6. Название файла: Обменник - Комментарии
  7. =============================================
  8. Official website: http://shcms.ru
  9. =============================================
  10. */
  11. define('SHCMS', true);
  12. include_once'../system/inc/basic_settings.php';
  13. if($_GET['id']) {
  14. $id = $_GET['id'];
  15. }
  16. $file2 = mysql_fetch_array(mysql_query("SELECT * FROM `download_file` WHERE `id`='$id'"));
  17. $shcmsengine['title'] = 'Комментарии к файлу '.$file2['names'].'';
  18. $user_s = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='$user_id'"));
  19. include_once'../template/head.php';
  20.  
  21.  
  22. if(!$id)
  23. {
  24. errors('Файл не существует');
  25. header("Refresh: 1; url=/download/");
  26. include_once'../template/foot.php';
  27. exit();
  28. }
  29. if($_POST['submit'])
  30. {
  31. $submit = $_POST['submit'];
  32. }
  33.  
  34. if(isset($submit)) {
  35. if($_POST['text']) {
  36. $text = $_POST['text'];
  37. }
  38. if(empty($text)) {
  39. echo '<div class="errors">Вы не ввели текст сообщения</div>';
  40. header("Refresh: 1; url=?id=$id");
  41. include_once'../template/foot.php';
  42. exit();
  43. }
  44.  
  45. $text_ok = mysql_query("INSERT INTO `down_comment` (`id_file`,`user_id`,`text`,`time`) VALUES ('$id','$user_id','".my_esc($text)."','".time()."')");
  46. if($text_ok == true) {
  47. echo '<div class="actshcms">Ваш комментарий успешно добавлен</div>';
  48. header("Refresh: 1; url=?id=$id");
  49. include_once'../template/foot.php';
  50. exit();
  51. }
  52. else {
  53. echo '<div class="errors">Ваш комментарий не добавлен</div>';
  54. header("Refresh: 1; url=?id=$id");
  55. include_once'../template/foot.php';
  56. exit();
  57. }
  58. }
  59. if(isset($_GET['delete'])) {
  60. if($user4['team'] == 6) {
  61. if($_GET['id_del']) {
  62. $id_del = $_GET['id_del'];
  63. }
  64.  
  65. $del_ok = mysql_query("DELETE FROM `down_comment` WHERE `id`='$id_del'");
  66. if($del_ok == true) {
  67. echo '<div class="actshcms">Комментарий успешно удален</div>';
  68. header("Refresh: 1; url=?id=$id");
  69. include_once'../template/foot.php';
  70. exit();
  71. }
  72. else {
  73. echo '<div class="errors">Комментарий не удален</div>';
  74. header("Refresh: 1; url=?id=$id");
  75. include_once'../template/foot.php';
  76. exit();
  77. }
  78. }
  79. }
  80. if(isset($user_id)) {
  81. echo '<div class="maintext">';
  82. $form = new form('?id='.$id.'');
  83. $form->textarea('<strong>Текст комментария:</strong>','text','',true);
  84. $form->submit('Написать','submit');
  85. $form->submit('Обновить','refresh');
  86. $form->finish();
  87. echo '</div>';
  88. }
  89. echo '<div class="maintext">';
  90. $komm1 = mysql_query("SELECT * FROM `down_comment` WHERE `id_file` = '$id' ORDER BY `id` DESC");
  91. $komm = mysql_fetch_array($komm1);
  92. if($komm == null)
  93. {
  94. echo SHCMS_core::img_shcms('../template/icon/empty.png').'Комментрии отсутствуют';
  95. }
  96. else
  97. {
  98. do
  99. {
  100. echo '<div class="posts">';
  101. users_profile($komm['user_id']);
  102. echo '<span class="maintime">'.$timedate->times($komm['time']).' </span><br/>';
  103. echo processing($komm['text']);
  104. echo '<span style="float:right;">';
  105. if($user4['team'] == 6)
  106. {
  107. echo '<a href="comment.php?id_del='.$komm['id'].'&delete&id='.$id.'">Удалить</a></span>';
  108. }
  109. echo '</div>';
  110. }
  111. while($komm = mysql_fetch_array($komm1));
  112. }
  113. echo '</div>';
  114.  
  115.  
  116. SHCMS_core::link_shcms('Вернуться назад','files.php?id='.$id.'');
  117.  
  118. include_once'../template/foot.php';
  119. ?>