<?php
	header('Content-Type: text/html; charset=utf-8');

	include('../../../inc/start.php');
	include('../../../inc/protect.php');

	if(!isset($_POST['token']) || $_SESSION['token'] != clean($_POST['token'], null))
		exit(json_encode(array('status' => 'error', 'text' => 'Неверный токен')));

	$tpl = new Template;
	$tpl->dir = '../tpl/ajax/elements/';

	$date = date('Y-m-d H:i:s');

	$admins = $pdo->query('SELECT `admins`.`id`, `admins`.`name`, `admins`.`cause`, `admins`.`pirce`, `admins`.`link`, `admins`.`active`, `servers`.`name` AS `server_name` FROM `admins` LEFT JOIN servers ON `servers`.`id`=`admins`.`server` WHERE `admins`.`user_id`="'.$_SESSION['id'].'" ORDER BY `admins`.`server`');
			  $admins->setFetchMode(PDO::FETCH_OBJ);

	$tpl->result['content'] = '';

	while($admin = $admins->fetch())
	{
		$tpl->load_template('profile_store.tpl');
			$tpl->set('{id}', $admin->id);
			$tpl->set('{server}', $admin->server_name);
			$tpl->set('{active}', $admin->active);
			$tpl->set('{cause}', $admin->cause);
			$tpl->set('{price}', $admin->pirce);
			$tpl->set('{link}', $admin->link);
			$tpl->set('{name}', $admin->name);
		$tpl->compile('content');
	}

	if($tpl->result['content'] == '')
	{
		$tpl->load_template('content_none.tpl');
			$tpl->set('{text}', 'Привилегий нет');
		$tpl->compile('content');
	}

	$tpl->show($tpl->result['content']);
?>