Просмотр файла uncos/comments.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. {
  15. $id=$_GET['id'];
  16. }
  17. $news = mysql_fetch_array(mysql_query("SELECT * FROM `uncos` WHERE `id`='$id'"));
  18. $news_rows = mysql_query("SELECT * FROM `uncos` WHERE `id` = '$id'");
  19. $shcmsengine['title'] = 'Комментарии: '.$news['title'].'';
  20. include_once'../template/head.php';
  21.  
  22. $news_list = mysql_fetch_array(mysql_query("SELECT * FROM `uncos` WHERE `id` = '$id'"));
  23.  
  24. echo '<div class="maintitle mainrazd">'.$news_list['title'].' <span class="mainforum">'.$timedate->times($news_list['time']).'</span></div>';
  25. echo '<div class="maintext">'.processing($news_list['text']).'</div>';
  26. if($news['komm'] == 2)
  27. {
  28. errors('Запрещено добавление комментарий к данной новости.');
  29. include_once'../template/foot.php';
  30. exit();
  31. }
  32. if($_POST['submit'])
  33. {
  34. $submit = $_POST['submit'];
  35. }
  36. if(isset($submit))
  37. {
  38. if($_POST['text'])
  39. {
  40. $text = $_POST['text'];
  41. }
  42.  
  43. if(empty($text))
  44. {
  45. echo '<div class="errors">Введите текст комментарии</div>';
  46. header("Refresh: 1; url=?id=$id");
  47. include_once'../template/foot.php';
  48. exit;
  49. }
  50.  
  51.  
  52. $comm = mysql_query("INSERT INTO `uncos_comment` (`user_id`,`id_uncos`,`time`,`text`) VALUES ('$user_id','$id','".time()."','".my_esc($text)."')");
  53. if($comm == true)
  54. {
  55. echo '<div class="actshcms">Комментария успешно добавлена</div>';
  56. header("Refresh: 1; url=?id=$id");
  57. include_once'../template/foot.php';
  58. exit;
  59. }
  60. else
  61. {
  62. echo '<div class="actshcms">Возникла ошибка при добавлении комментарии</div>';
  63. header("Refresh: 1; url=?id=$id");
  64. include_once'../template/foot.php';
  65. exit;
  66. }
  67.  
  68. }
  69. else
  70. {
  71. if($user_id) {
  72. echo '<div class="maintext">';
  73. $form = new form("?id=$id");
  74. $form->textarea('<strong>Текст комментария:</strong>','text','',true);
  75. $form->submit('Отправить','submit');
  76. $form->submit('Обновить','refresh');
  77. $form ->form_link(DIR_SHCMS.'smile.php','Смайлы');
  78. $form->finish();
  79. echo '</div>';
  80. }
  81. }
  82. $allfield = mysql_result(mysql_query("SELECT COUNT(*) FROM `uncos_comment` WHERE `id_uncos`='$id'"),0);
  83. $newlist = new Navigation($allfield,10,true);
  84. $where_comm = mysql_query("SELECT * FROM `uncos_comment` WHERE `id_uncos`='$id' ORDER BY `id` ". $newlist->limit()."");
  85. if(mysql_num_rows($where_comm) > 0)
  86. {
  87. $num_post=0;
  88. while($whire_comm = mysql_fetch_array($where_comm))
  89. {
  90. $num_post++;
  91. $users = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$whire_comm[user_id]'"));
  92. echo '<div class="maintitle"> <font color="#0386C3">#'.$num_post.'</font>&nbsp;';
  93. users_profile($users['id']);
  94. list_users($users_id);
  95. echo '<span class="maintime">'.$timedate->times($whire_comm['time']).'</span></div>';
  96. echo '<div class="maintext">'.processing($whire_comm['text']).'';
  97. if($user4['team'] == 6){
  98. echo '<span style="float:right">
  99. <a href="delete.php?id='.$whire_comm['id'].'"><img src="../template/icon/delete.png"/></a></span>';
  100. }
  101. echo '</div>';
  102. }
  103. echo '<div class="pages">';
  104. echo $newlist->pagination('id='.$id.'');
  105. echo '</div>';
  106. }
  107. else
  108. {
  109. echo '<div class="maintext">';
  110. echo SHCMS_core::img_shcms('../template/icon/empty.png').'Комментарии не добавлены';
  111. echo '</div>';
  112. }
  113.  
  114. echo '<div class="link_str"><a href="/uncos/">Назад</div>';
  115. include_once'../template/foot.php';
  116. ?>