Размер файла: 4.23Kb
- <?php
- define('_IN_JOHNCMS', 1);
-
- $headmod = 'lib';
- $textl = 'Библиотека';
- require_once ("../incfiles/core.php");
- require_once ("./inc/conf.php");
- // Ограничиваем доступ к Библиотеке
- if (!$set['mod_lib'] && $rights < 7)
- $error = 'Библиотека закрыта';
- elseif ($set['mod_lib'] == 1 && !$user_id)
- $error = 'Доступ в Библиотеку открыт только <a href="../in.php">авторизованным</a> посетителям';
- if ($error) {
- require_once ("../incfiles/head.php");
- echo '<div class="rmenu"><p>' . $error . '</p></div>';
- require_once ("../incfiles/end.php");
- exit;
- }
- require_once ("../incfiles/head.php");
- if($rights == 5 || $rights >= 6)
- {
- echo '<div class="gmenu"><a href="admin.php"><strong>Управление библиотекой</strong></a></div>';
- $co = mysql_result(mysql_query("select COUNT(*) from `library` where `moder` = '0' and `type` = 'file'"),0);
- if($co > 0)
- {
- echo '<div class="menu"><strong>'.$co.'</strong> статей ожидают модерации перейти к ним <a href="mod.php">>>></a></div>';
- }
- }
- if(!empty($id))
- {
- if(empty($_POST['submit']))
- {
- echo '<form method="POST" action="komm.php?id='.$id.'">';
- echo 'Ваш комментари:<br/><textarea name="msg"></textarea><br/>';
- echo '<input value="Добавить" type="submit" name="submit"/></form>';
- }else{
- if(!empty($_POST['msg']))
- {
- $msg = mysql_real_escape_string(trim($_POST['msg']));
- if(mysql_query("insert into `lib_kom` set
- `id` = '',
- `fid` = '".$id."',
- `user` = '".$user_id."',
- `text` = '".$msg."',
- `ip` = '".$ipp."',
- `soft` = '".$agn."',
- `time` = '".$realtime."';"))
- {
- header("location: komm.php?id=$id&yes");
- }else{
- header("Location: komm.php?id=$id&no");
- }
- }
- }
- $total = mysql_result(mysql_query("select COUNT(*) from `lib_kom` where `fid` = '".$id."'"),0);
- if($total > 0)
- {
- $sql = mysql_query("select * from `lib_kom` where `fid` = '".$id."' order by `id` DESC LIMIT ".$start.",".$kol_file."");
- while($mas = mysql_fetch_array($sql))
- {
- $i = 1;
- echo ($i % 2) ? '<div class="list1">' : '<div class="list2">';
- echo '<div class="menu">';
- $us = mysql_fetch_array(mysql_query("select * from `users` where `id` = '".$mas['user']."' LIMIT 1"));
- if($mas['user'] === $user_id)
- {
- echo '<a href="../str/anketa.php?id='.$mas['user'].'">'.$us['name'].'</a>';
- }else{
- echo '<strong>'.$us['name'].'</strong>';
- }
- switch ($us['rights'])
- {
- case 7:
- echo ' Adm ';
- break;
- case 6:
- echo ' Smd ';
- break;
- case 5:
- echo ' Mod ';
- break;
- case 1:
- echo ' Kil ';
- break;
- }
- $ontime = $us['lastdate'] + 300;
- if($realtime > $ontime)
- {
- echo '<font color="#FF0000"> [Off]</font>';
- }else{
- echo '<font color="#00AA00"> [ON]</font>';
- }
- echo '('.date("d.m.Y / H:i",$mas['time']).')';
- echo '</div>';
- $text = htmlentities($mas['text'],ENT_QUOTES,'utf-8');
- $text = tags($text);
- echo $text.'<br/>';
- if($rights == 5 || $rights >= 6)
- {
- echo '(<i>'.$mas['ip'] .' - '.$mas['soft'].'</i>)<br/><a href="komm.php?act=del&fid='.$id.'&id='.$mas['id'].'">(Удалить)</a>';
- }
- echo '</div>';
- }
- if ($total > $kol_file) {
- echo '<p>' . pagenav('komm.php?id=' . $id . '&', $start, $total, $kol_file) . '</p>';
- }
-
- }
- if($act == 'del')
- {
- $fid = abs(intval($_GET['fid']));
- mysql_query("DELETE FROM `lib_kom` WHERE `id` = '".$id."' and `fid` = '".$fid."' LIMIT 1");
- header("Location: komm.php?id=$fid");
- }
- }
- echo '<br/><a href="index.php?">В библиотеку</a><br/>';
- require_once ('../incfiles/end.php');
- ?>