Просмотр файла komm.php

Размер файла: 4.23Kb
  1. <?php
  2. define('_IN_JOHNCMS', 1);
  3.  
  4. $headmod = 'lib';
  5. $textl = 'Библиотека';
  6. require_once ("../incfiles/core.php");
  7. require_once ("./inc/conf.php");
  8. // Ограничиваем доступ к Библиотеке
  9. if (!$set['mod_lib'] && $rights < 7)
  10. $error = 'Библиотека закрыта';
  11. elseif ($set['mod_lib'] == 1 && !$user_id)
  12. $error = 'Доступ в Библиотеку открыт только <a href="../in.php">авторизованным</a> посетителям';
  13. if ($error) {
  14. require_once ("../incfiles/head.php");
  15. echo '<div class="rmenu"><p>' . $error . '</p></div>';
  16. require_once ("../incfiles/end.php");
  17. exit;
  18. }
  19. require_once ("../incfiles/head.php");
  20. if($rights == 5 || $rights >= 6)
  21. {
  22. echo '<div class="gmenu"><a href="admin.php"><strong>Управление библиотекой</strong></a></div>';
  23. $co = mysql_result(mysql_query("select COUNT(*) from `library` where `moder` = '0' and `type` = 'file'"),0);
  24. if($co > 0)
  25. {
  26. echo '<div class="menu"><strong>'.$co.'</strong> статей ожидают модерации перейти к ним <a href="mod.php">&gt;&gt;&gt;</a></div>';
  27. }
  28. }
  29. if(!empty($id))
  30. {
  31. if(empty($_POST['submit']))
  32. {
  33. echo '<form method="POST" action="komm.php?id='.$id.'">';
  34. echo 'Ваш комментари:<br/><textarea name="msg"></textarea><br/>';
  35. echo '<input value="Добавить" type="submit" name="submit"/></form>';
  36. }else{
  37. if(!empty($_POST['msg']))
  38. {
  39. $msg = mysql_real_escape_string(trim($_POST['msg']));
  40. if(mysql_query("insert into `lib_kom` set
  41. `id` = '',
  42. `fid` = '".$id."',
  43. `user` = '".$user_id."',
  44. `text` = '".$msg."',
  45. `ip` = '".$ipp."',
  46. `soft` = '".$agn."',
  47. `time` = '".$realtime."';"))
  48. {
  49. header("location: komm.php?id=$id&yes");
  50. }else{
  51. header("Location: komm.php?id=$id&no");
  52. }
  53. }
  54. }
  55. $total = mysql_result(mysql_query("select COUNT(*) from `lib_kom` where `fid` = '".$id."'"),0);
  56. if($total > 0)
  57. {
  58. $sql = mysql_query("select * from `lib_kom` where `fid` = '".$id."' order by `id` DESC LIMIT ".$start.",".$kol_file."");
  59. while($mas = mysql_fetch_array($sql))
  60. {
  61. $i = 1;
  62. echo ($i % 2) ? '<div class="list1">' : '<div class="list2">';
  63. echo '<div class="menu">';
  64. $us = mysql_fetch_array(mysql_query("select * from `users` where `id` = '".$mas['user']."' LIMIT 1"));
  65. if($mas['user'] === $user_id)
  66. {
  67. echo '<a href="../str/anketa.php?id='.$mas['user'].'">'.$us['name'].'</a>';
  68. }else{
  69. echo '<strong>'.$us['name'].'</strong>';
  70. }
  71. switch ($us['rights'])
  72. {
  73. case 7:
  74. echo ' Adm ';
  75. break;
  76. case 6:
  77. echo ' Smd ';
  78. break;
  79. case 5:
  80. echo ' Mod ';
  81. break;
  82. case 1:
  83. echo ' Kil ';
  84. break;
  85. }
  86. $ontime = $us['lastdate'] + 300;
  87. if($realtime > $ontime)
  88. {
  89. echo '<font color="#FF0000"> [Off]</font>';
  90. }else{
  91. echo '<font color="#00AA00"> [ON]</font>';
  92. }
  93. echo '('.date("d.m.Y / H:i",$mas['time']).')';
  94. echo '</div>';
  95. $text = htmlentities($mas['text'],ENT_QUOTES,'utf-8');
  96. $text = tags($text);
  97. echo $text.'<br/>';
  98. if($rights == 5 || $rights >= 6)
  99. {
  100. echo '(<i>'.$mas['ip'] .' - '.$mas['soft'].'</i>)<br/><a href="komm.php?act=del&amp;fid='.$id.'&amp;id='.$mas['id'].'">(Удалить)</a>';
  101. }
  102. echo '</div>';
  103. }
  104. if ($total > $kol_file) {
  105. echo '<p>' . pagenav('komm.php?id=' . $id . '&amp;', $start, $total, $kol_file) . '</p>';
  106. }
  107. }
  108. if($act == 'del')
  109. {
  110. $fid = abs(intval($_GET['fid']));
  111. mysql_query("DELETE FROM `lib_kom` WHERE `id` = '".$id."' and `fid` = '".$fid."' LIMIT 1");
  112. header("Location: komm.php?id=$fid");
  113. }
  114. }
  115. echo '<br/><a href="index.php?">В библиотеку</a><br/>';
  116. require_once ('../incfiles/end.php');
  117. ?>