<?php
require('./load.php');

$table = $DB->table('admin');
$admin_auth = $_COOKIE['admin_auth'];
list($admin_id, $admin_pass, $login_count) = $admin_auth ? explode('@', authcode($admin_auth, 'DECODE')) : array('', '', '');
$admin_id = intval($admin_id);
$admin_pass = addslashes($admin_pass);
if (!$admin_id || !$admin_pass) {
	$admin_id = 0;	
	msgbox('您还未登录或无权限！', './login.php');
}

$myself = array();
$admin = $DB->fetch_one("SELECT admin_name, admin_pass, login_time, login_ip, login_count FROM $table WHERE admin_id='$admin_id'");
if ($admin['admin_pass'] == $admin_pass && $admin['login_count'] == $login_count) {
	$myself = array(
		'user_name' => $admin['admin_name'],
		'login_time' => date('Y-m-d H:i:s', $admin['login_time']),
		'login_ip' => $admin['login_ip'],
		'login_count' => $admin['login_count'],
	);
} else {
	$admin_id = 0;
	$admin_pass = '';
	setcookie('admin_auth', '');
	msgbox('您还未登录或无权限！', './login.php');
}

$smarty->assign('myself', $myself);
?>