<?php
if(!defined('APP_PATH')||!defined('I_PATH')){exit('Access Denied');}

class login extends controllerBase
{	
	function __construct(){
		parent::__construct();
	}
	function index(){
		$this->d=$GLOBALS['LD_I']['ext'];
		$this->display("login.html");
	}
	function go(){
		if($this->sysParams("adminuser",1) && $this->sysParams("adminpass",1)){
			
			if(func_get_iglobal(array('vercode'))==1){
				if(md5(strtolower($this->sysParams("vercode",1)))!=$_SESSION['i_verify'])message_a("验证码错误");
			}
	
			
			$conditions = array('auser' => $this->sysParams("adminuser",1),'apass' => md5(md5($this->sysParams("adminpass",1)).$this->sysParams("adminuser",1)));
			$r = syDB('admin_user')->find($conditions);
		
			if(!$r){
				message_a("用户名或密码错误");
			}else{
				$_SESSION['auser'] = array(
					'auser' => $r['auser'],
					'auid' => $r['auid'],
					'level' => $r['level'],
					'gid' => $r['gid'],
					'pclasstype' => $r['pclasstype'],
				);	
				
				/*
				if($GLOBALS['iConfig']['ext']['qq_sync']==1)
				{
					$_SESSION['referre']=$GLOBALS['iConfig']['ext']['http_path'].'/admin.php';
    				$_SESSION['referre_type']=1;
					message('请先登陆需要同步的QQ号码', $GLOBALS['iConfig']['ext']["http_path"]."/qq/");
					exit;
				}
				*/
				$this->jump("admin.php");
			}
		}else{
			message_a("请输入用户名和密码");
		}
	}
	function out(){
		$_SESSION['auser'] = array();
		if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', time()-42000, '/');}
		session_destroy();
		$this->jump("admin.php?c=login");
	}
}	