<?php
require_once('class.stdModule.php');


class casd extends stdModule {

	function casd() {
		
		$this->stdModule('casd0100');
		
		// Available Templates
		$this->_settings->templates->login				= 'login.tpl';
		$this->_settings->templates->overview			= 'overview.tpl';
	}


	//*** LOGIN/LOGOUT FUNCTIONS ***//
	
	function checkLogin($username=null, $password=null) {
		
		if ($username && $password) {
		
			$sql = "SELECT usr_id, usr_username, usr_admin FROM tbl_sup_users WHERE usr_username = '".mysql_escape_string($username)."' AND usr_password = '".mysql_escape_string($password)."' AND usr_active = 1";
			$rs = $this->_db->query($sql);

			if (!$rs->EOF()) {
				$_SESSION['session_usr_id'] = $rs->Row('usr_id');
				$_SESSION['session_user'] = $rs->Row();
				return true;
			} else {
				$this->logout();
				return false;
			}
		} else {
			return is_numeric($_SESSION['session_usr_id']);
		}
	}

	function logout() {
		unset($_SESSION['session_usr_id']);
		unset($_SESSION['session_user']);
	}

	function printLogin() {
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->login);
	}

	function printOverview() {
		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->overview);
	}

}
?>