View file pages/apanel/users.php

File size: 2.66Kb
<?

$PageConfig = [	
	'title' =>  'Пользователи',
];
PageConfig($PageConfig);

$sqlsort = "`id` DESC";
$sqlwhere = '`id` > 0';
$type = (isset($_GET['t']) ? $_GET['t'] : 'users');

if ($type == 'users') {
	$sqlsort = '`id` ASC';
}
if ($type == 'admins') {
	$sqlwhere = "`id_level` > '0'";
	$sqlsort = '`id` ASC';
}
if ($type == 'new') {
	$sqlwhere = "`date_create` > '". (time() - 86400) ."' or `id` > 0 ";
}

$count_max = 9;
$count = $sql->rowCount("SELECT * FROM `users` where {$sqlwhere}");
$page_num = (!empty($_GET['page']) ? (int) $_GET['page'] : 1); 
$page = page('?page=',  $page_num , $count , $count_max);
$page['count'] = $count;
$page['page_num'] = $page_num;
$page['count_max'] = $count_max;

$uslist = [];
$query = $sql->fetchAll("SELECT * FROM `users` where {$sqlwhere} ORDER BY {$sqlsort} LIMIT {$page['start']} , {$page['num']};");
foreach ($query AS $p) {
	if (FileSystem::TextStrlen($p['status']) > 79) {
		$p['status'] = FileSystem::TextCut($p['status'] , 80);
	}
	$p['news_count'] = $sql->rowCount("SELECT * FROM `news` WHERE `id_user` = '{$p['id']}' AND `act` = '1'");
	$uslist[] = $p;
}

$z = 2;
foreach($uslist AS $p) {
	$z = ($z % 2 ? 1 : 2);
	$position = '';
	if ($p['id_level'] == 1) {
		$position = 'Модератор';
	}
	if ($p['id_level'] == 2) {
		$position = 'Администратор';
	}	
	if ($p['id_level'] == 3) {
		$position = 'Системный администратор';
	}
	if ($p['id_level'] > 0) { 
		$position = '  <i style="color:#6697f1" class="fa fa-eercast " aria-hidden="true"></i> <b style="color:#6697f1">'.$position .'</b><br/>';
	}
	?>
		<div class="post_<?=$z?>">
			<a href="/@<?=$p['link']?>">
				<?=user::avatar($p['id'], 0)?>
				<b><?=user::nick($p['id'], 5)?></b>
			</a> <br/>
			<?=$position?>
			
			<span style="color:#b5bece"><?=$p['status']?></span style>
			<br/><br/>
			<i class="fa fa-bars fa-lg" aria-hidden="true"></i>  Опубликовано новостей  : <b><?=$p['news_count']?></b><br/>
			
			<i class="fa fa-clock-o fa-lg" aria-hidden="true"></i> Дата регистрации : <b><?=times::out($p['date_create'])?></b><br/>
			<i class="fa fa-clock-o fa-lg" aria-hidden="true"></i> Последнее посищ. : <b><?=times::out($p['date_last'])?></b><br/>
			<? if ($user['id_level'] > $p['id_level'] AND $user['id'] != $p['id']) : ?>
				<a href="/apanel/user_edit/<?=$p['link']?>/">
					<i class="fa fa-pencil" aria-hidden="true"></i> Редактировать
				</a>
			<? endif ?>
		</div>
	<?	
	$z++;
}

if ($page['count'] > $page['count_max']) {
	echo '<div class="page-nav-fon">'. $page['display'] .'</div>';
}