<?php

/**
 * Copyright (C) 2009 Wskm Inc.All rights reserved.  
 * [Gart] www.wskmphp.com 
 * $Id: auth.php 53 2010-09-30 04:49:27Z ws99 $ 
 */

!defined('IN_ART') && exit('Access Denied');

class adminapp_auth extends admin_auth
{
	function doLogin()
	{
		$session=$this->readSession();
		if ($session !== false){
			adminMessage('logged','index.php');
		}

		if (checkToken()) {
			$password=requestPost('password');
			if (strlen($password)<6) {
				adminMessage('password_length','index.php');
			}

			$objectlog=usingAdminModel('log');
			$objectlog->deleteExpiredAdminLoginLog();

			if($this->login($password))
			{
				$this->islogin=true;
			}

			$password='***'.substr($password,3);

			$objectlog->insertAdminLoginLog(array(
			'uid'=>$this->getUid(),
			'uname'=>$this->getUname(),
			'adminid'=>$this->getAdminid(),
			'groupid'=>$this->getGroupid(),
			'ip'=>USER_IP,
			'logintime'=>WSKM_TIME,
			'password'=>$password,
			'type'=>$this->islogin?1:0
			));

			if ($this->islogin) {
				$ref=wskm_cookie::getValue('referernav');
				gotoUrl($ref?'index.php?'.wskm_cookie::getValue('referernav'):'index.php');
			}else{
				adminMessage('password_error','index.php');
			}
		}
		else
		{
			adminMessage('unknow_error');
		}
	}

	function doLogout()
	{
		$this->logout();
		adminMessage('logout_successed',ART_URL);
	}

}

?>