View file element_town_journal.php

File size: 2.49Kb
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
	
	
	if (!$id) {
	$title = 'Город не найден';
	$error1 = '<span class="small">Выбранный Вами город не существует, либо был удален</span>';
	require_once 'element_error_page.php';
	exit;
	}
	
	if ($id != $user['lost_town'] AND $user['lost_privilege'] != 3) {
	$title = 'Доступ закрыт';
	$error1 = '<span class="small">Администрация ограничила доступ к этой странице</span>';
	require_once 'element_error_page.php';
	exit;
	}
	
	$cache_town = cache_town($id);
	
	if (!$cache_town) {
	$title = 'Город не найден';
	$error1 = '<span class="small">Выбранный Вами город не существует, либо был удален</span>';
	require_once 'element_error_page.php';
	exit;
	}
	
	function count_journal($town) {
		return mysql_result(mysql_query("SELECT COUNT(lost_town) FROM `element_town_journal` WHERE `lost_town` = '$town'"), 0);
	}
	
		$title = 'Журнал "'.$cache_town['lost_name'].'"';
		require_once './element_include/element_head.php';
		require_once './element_include/element_header_user_true.php';
		require_once './element_function/element_function_town.php';
		echo '<div class="nfl p5 mt5 mb5 mlra">';
		
		$count_journal = count_journal($id);
		if ($count_journal > 0) {
		require_once './element_function/element_function_pagination.php';
		$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
		$pagination = pagination(10, $page, $count_journal);
		
		$query = mysql_query("SELECT * FROM `element_town_journal` WHERE `lost_town` = '$id' ORDER BY `lost_time` DESC LIMIT $pagination[start], $pagination[num]");
		$i = 1;
		echo '<div class="ml5 mr5">';
		while($myrrow = mysql_fetch_array($query)) {
		$odd = (($i % 2) ? ' odd' : '');		
		echo '<div class="bl p5 block small'.$odd.'">';
		echo '<div class="mb5">'.peplace_text_journal($myrrow['lost_value'], $online).'</div><span class="small mt5 ccc">'.rdate("d M H:i", $myrrow['lost_time']).'</span></div>';
		$i++;
		}
		echo pagination_echo($pagination['page'],$pagination['total'],'/town/journal?id='.$id.'&page=');
		echo '</div>';
		} else echo '<div class="small yellow1 cntr">В журнале записей не найдено</div>';
		
		
		echo '</div>';
		require_once './element_include/element_foot_user_true.php';
?>