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

Размер файла: 3.28Kb
  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. if($_GET['id']){
  16. $id = $_GET['id'];
  17. }
  18. $photo_comm = mysql_fetch_array(mysql_query("SELECT * FROM `photo_users` WHERE `id` = '$id'"));
  19. $shcmsengine['title'] = 'Комментарии к '.$photo_comm['name'].'';
  20. include_once'../template/head.php';
  21. $allfield = mysql_result(mysql_query("SELECT COUNT(*) FROM `photo_comm` WHERE `id_comm` = '$id'"),0);
  22. $newlist = new Navigation($allfield,10, true);
  23. if($user_id)
  24. {
  25. echo '<strong>Текст комментария:</strong><br/>';
  26. echo '<form action="?id='.$id.'" method="post" name="form">';
  27. echo '<textarea id="text" name="text"></textarea><br/>';
  28. echo '<input type="submit" name="submit" value="Написать"> ';
  29. echo '<input type="submit" name="refresh" value="Обновить">';
  30. echo '</form>';
  31. echo '<br/>';
  32. }
  33.  
  34. $where_comm = mysql_query("SELECT * FROM `photo_comm` WHERE `id_comm` = '$id' ORDER BY `id` DESC ". $newlist->limit()."");
  35. if(mysql_num_rows($where_comm) > 0)
  36. {
  37. while($whire_comm = mysql_fetch_array($where_comm))
  38. {
  39. $users = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$whire_comm[user_id]'"));
  40. echo '<div class="posts">';
  41. users_profile($users['id']);
  42. echo list_users($users['id']).'';
  43. echo '<br/>'.processing($whire_comm['text']).'<span style="float: right">'.$timedate->times($whire_comm['time']).'</span></div>';
  44. }
  45.  
  46. echo '<div class="pages">';
  47. echo $newlist->pagination('id='.$id.'');
  48. echo '</div>';
  49. }
  50. else
  51. {
  52. echo '<div class="posts">Комментарии не добавлены</div>';
  53. }
  54. if($_POST['submit'])
  55. {
  56. $submit = $_POST['submit'];
  57. }
  58. if(isset($submit))
  59. {
  60. if($_POST['text'])
  61. {
  62. $text = $_POST['text'];
  63. }
  64.  
  65. if(empty($text))
  66. {
  67. echo '<div class="errors">Введите текст комментарии</div>';
  68. header("Refresh: 1; url=?id=$id");
  69. include_once'../template/foot.php';
  70. exit;
  71. }
  72.  
  73.  
  74. $comm = mysql_query("INSERT INTO `photo_comm` (`user_id`,`id_comm`,`time`,`text`) VALUES ('$user_id','$id','".time()."','$text')");
  75. if($comm == true)
  76. {
  77. echo '<div class="actshcms">Комментария успешно добавлена</div>';
  78. header("Refresh: 1; url=?id=$id");
  79. include_once'../template/foot.php';
  80. exit;
  81. }
  82. else {
  83. errors('Возникла ошибка при добавлении комментарии');
  84. header("Refresh: 1; url=?id=$id");
  85. include_once'../template/foot.php';
  86. exit;
  87. }
  88.  
  89. }
  90.  
  91.  
  92. include_once'../template/foot.php';
  93. ?>