<?php
/*
 * Copyright(C). D-cube,Inc. All Rights Reserved.
 */

/*
 * @file		Authorize.class.php
 * @brief		ユーザ認証クラス
 * @date		2007.01.17
 */

require_once(CLASS_DIR."/adodb/AccountManager.class.php");

class Authorize
{
	function login($username="",$password="")
	{
		if($this->canLogin($username,md5($password)))
		{
			$_SESSION["auth_username"] = $username;
			$_SESSION["auth_password"] = md5($password);
			return true;
		}
		return false;
	}
	
	function canLogin($username="",$password="")
	{
		$dao = new AccountManager;
		return $dao->findAccount($username,$password);
	}
	
	function isLogin()
	{
		if($this->canLogin($_SESSION["auth_username"],$_SESSION["auth_password"]))
			return true;
		else
			return false;
	}
	
	function logout()
	{
		session_destroy();
	}
}
