Просмотр файла publs_v1_0/index.php

Размер файла: 7.97Kb
<?php
if (defined('BASEDIR')) {
	exit (header('Location: /index.php'));
}

$headmod = 'pub';
$textl = 'Публикации';
$config['newtitle'] = 'Публикации';

require_once ('../includes/start.php');
require_once ('../includes/functions.php');
require_once ('../includes/header.php');
include_once ('../themes/header.php');

require_once ("./inc/conf.php");

//$kol_file = $kmess;
$mod = isset($_GET['mod']) ? abs(intval($_GET['mod'])) : 0;
$start = isset($_GET['start']) ?  abs(intval($_GET['start'])) : 0; 

#	Ограничиваем доступ к Библиотеке
/*
if (!$set['mod_lib'] && $rights < 7) {
	$error = 'Публикации закрыты!';
} else if ($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;
}

include_once ("panel.dat");
?>
<table class="table table-hover table-sm text-center mt-n4 mb-n3">
  <tbody>
    <tr>
      <td><img src="img/bar.png" alt=""/> <a href="pop.php?">Топ</a></td>
      <td><img src="img/new.png" alt=""/> <a href="new.php?">New</a></td>
      <th><a href="serch.php?">Поиск</a></th>
    </tr>
  </tbody>
</table>
<?

if (empty($id)) {
	echo '<ol class="breadcrumb position-sticky">';
	echo '<li><a href="/index.php?"> <i class="fa fa-home fa-lg text-muted"></i> </a></li>';
	echo '<li class="active"><strong>Публикации</strong></li>';
	echo '</ol> ';
} else {
	#################################################################
	##		 	     	 Получаем структуру каталогов              ##
	#################################################################
	$tree = array();
	$dirid = $id;
	while ($dirid != '0' && $dirid != "") {
		$req = DB::run() -> query("SELECT `name`,`fid` FROM `pub_arts` WHERE `type` = 'dir' and `id` = '".$dirid."' LIMIT 1;");
		$res = $req -> fetch();
		$tree[] = '<a href="index.php?id='.$dirid.'">'.$res['name'].'</a>';
		$dirid = $res['fid'];
	}
	krsort($tree);
	$cdir = array_pop($tree);
	echo '<ol class="breadcrumb">';
	echo '<li><a href="/index.php?"> <i class="fa fa-home fa-lg text-muted"></i> </a></li>';
	echo '<li><a href="index.php">Публикации</a></li> ';
	foreach ($tree as $value) {
		echo '<li>'.$value.'</li>';
	}
	echo '<li class="active"><strong>'.strip_tags($cdir).'</strong></li></ol>';
}

$tot_dir = DB::run() -> querySingle("SELECT COUNT(*) from `pub_arts` WHERE `type` = 'dir' AND `fid` = '".$id."';");
$tot_file = DB::run() -> querySingle("SELECT COUNT(*) from `pub_arts` WHERE `type` = 'file' AND `fid` = '".$id."' AND `moder` = '1';");

$total = $tot_dir + $tot_file;
if ($total > 0) {
	$sql = DB::run() -> query("SELECT * FROM `pub_arts` WHERE `fid` = '".$id."' AND `moder` != '0' ORDER BY `type` ASC, `ord` ASC, `id` desc LIMIT ".$start.",".$kol_file.";");
	$i = 0;
	while ($mas = $sql -> fetch()) {
		if ($tot_dir > 0 && $mas['type'] == 'dir') {
			$count = 0;
			$count = DB::run() -> querySingle("SELECT COUNT(*) from `pub_arts` WHERE `type` = 'file' AND `path` LIKE '".$mas['path']."%' and `moder` != '0';");
		//	if ($count >0) {
				echo ''.($i % 2) ? '<div class="list1">' : '<div class="list2">';	++$i;
				echo '&raquo;<img src="./img/'.($mas['type2'] == "YES" ? 'folder_user' : 'folder').'.png" alt="" />
				<a href="index.php?id='.$mas['id'].'"><strong>'.htmlentities($mas['name'],ENT_QUOTES,'utf-8').'</strong></a> ';

				$countnew = 0;
				$dir = DB::run() -> querySingle("SELECT COUNT(*) from `pub_arts` WHERE `type` = 'dir' and `fid` = '".$mas['id']."';");
				$countnew = DB::run() -> querySingle("select COUNT(*) from `pub_arts` where `type` = 'file' and `path` LIKE '".$mas['path']."%' and `time` > '".(SITETIME -($new_fil * 24 * 3600) )."' and `moder` != '0';");
				echo '('.$dir.' / '.intval($count);
				if ($countnew !== "0") { 
					echo '<span class="red">+'.intval($countnew).'</span>)';
				} else {
					echo ')';
				}

				if(!empty($mas['opis'])) {
					echo '<div class="sub">'.htmlentities($mas['opis'],ENT_QUOTES,'utf-8').'</div>';
				}
				echo '</div>';
		//	}
			
		}

		if ($tot_file > 0 && $mas['type'] == "file" && $mas['moder'] != "0") {
			echo ($i % 2) ? '<div class="list1" id="'.$mas['id'].'">' : '<div class="list2" id="'.$mas['id'].'">';	++$i;
			echo '<div class = "b">' .
			'<img src="./img/page_white_text.png" alt="" />' .
			'<a href="read.php?id='.$mas['id'].'"><label>'.htmlentities($mas['name'],ENT_QUOTES,'utf-8').'</label></a>' .
			'</div>';
			$c = DB::run() -> querySingle("select COUNT(*) from `pub_file` where `fid` = '".$mas['id']."';");
			if ($c > 0) {
				$sql1 = DB::run() -> query("SELECT * FROM `pub_file` WHERE `fid` = '".$mas['id']."'");
				echo '<br />';
				echo '<small>Прикрепленные файлы: <br />';
				//while ($res = mysql_fetch_array($sql1)) {
				while ($res = $sql1 -> fetch()) {
					echo '<a href="file.php?act=look&amp;id='.$res['id'].'">
					'.htmlentities($res['name']).'</a>, ';
				}
				echo '</small>';
			}

			if (empty($mas['view']) == 1) {
				if ($mod != ''.$mas['id'].'') {
					//echo '<div class="ml-5">'.r_bb_code(r_utf_substr($mas['text'], 0, 1000)).'';
					if (iconv_strlen($mas['text']) > 1000) {
						echo '<div class="ml-5">'.bb_code(utf_substr($mas['text'], 0, 1000)).'...';
						echo ' ...<br /><a class="" href="?id='.$mas['fid'].'&amp;start='.$start.'&amp;mod='.$mas['id'].'#'.$mas['id'].'"><label>Полностью &raquo;</label></a>';
					} else {
						echo '<div class="ml-5">'.bb_code($mas['text']).'...';
						//echo '</div>';
					}
				} else {
					echo '<div class="ml-5">'.bb_code($mas['text']).'';
				}
			} else if (!empty($mas['opis'])) {
				echo '<div class="ml-5"><small>'.htmlentities($mas['opis'],ENT_QUOTES,'utf-8').'</small></div>';
			} else {
				echo '<br />';
			}

			$re1 = explode(":",$mas['rating']);
			if ($re1[0] > 0) {
				$tit = round($re1[1] / 2 / $re1[0],1);
			} else { 
				$tit = round($re1[0] );
			}
			echo '</div><p class="border-top mb-n3"><br /><small><strong>Прочтений: </strong>'.$mas['count'].' / ';
			echo '<strong>Оценка:</strong> '.$tit.'/<b>'.(int)$re1[0].'</b> / ';
			echo '<strong>Добавил: </strong>'.profile($mas['avtor']).' / ';
			echo '<a href="komm.php?id='.$mas['id'].'">Комментарии</a>['.count_komm($mas['id']).'] ';
			echo '</small></p>';
			echo '</div>';
		}
    }

} else {
	show_error('<strong>Упс! А в данной категори пока ничего нету :)!</strong>');
}

#	Постраничная навигация
if ($total > $kol_file) {
	page_strnavigation('index.php?id='.$id.'&amp;', $kol_file, $start, $total);
	//echo '<p>'.pagination('index.php?id='.$id.'&amp;', $start, $total, $kol_file).'';
}

echo '<div class="breadcrumb">';
if ($tot_dir > 0) {
	echo 'Папок: '. $tot_dir;
}

echo '&nbsp;&nbsp;&nbsp;';
if ($tot_file > 0) {
	echo 'Файлов: '.$tot_file;
}
echo '</div>';



echo '<div class="gmenu"><small><ul><li><a href="set.php?">Настройки показа</a></li>';
//echo '<li><a href="serch.php?">Поиск</a></li>';
echo '<li><a href="stat.php?">Статистика публикаций</a></li>';
echo '<li><a href="zak.php?">Стол заказов</a></li></ul></small>';
echo '</div>';
echo '<hr/>';

if (!empty($_GET['id'])) {
	$sq = DB::run() -> queryfetch("select `type2` from `pub_arts` where `id` = '".$id."' LIMIT 1;");
	if ($sq['type2'] == "YES" && is_user()) {
		echo '<div class="func"><ul>';
		echo '<li><a href="file.php?act=upload&amp;id='.$id.'">Выгрузить статью</a></li>'; 
		echo '<li><a href="file.php?act=newstat&amp;id='.$id.'">Написать статью</a></li>';
		echo '</ul></div>';
	}
}

include_once ('../themes/footer.php');
?>