Location: PHPKode > projects > Monyet > controllers/authentication.php
<?php
Class Authentication extends ControllerBase {

	public function __construct(){
		parent::__construct();
	}

	public function login(){
		//reading session
		$this->session->set('last','authentication/login');	
	   $this->xml->addText(SITENAME.' -login','title',0);
		$this->xml->addForm('javascript:sndReq(\'authentication/login\')','panel',0);
		$this->xml->addTextField('Username',null,'username','text');
		$this->xml->addTextField('Password',null,'pass','password');
		$this->xml->addSubmitBtn('submitForm(\''.$this->getName().'/process\')','Login');
		$this->xml->flush();
	}

	public function logout(){
		$this->session->remove('last');	
		$this->session->remove('user');	
		$this->session->remove('group');	
	   $this->xml->addText(SITENAME.' -logout','title',0);
	   $this->xml->addText('Logging out','note',0);
		$this->xml->addRedir('index/initiate');
		$this->xml->flush();
	}

	public function process(){
		$user = new User();
		$username = '';
		$pass = '';	
		if(isset($_POST['username'])){
			$username = $_POST['username'];
			$pass = $_POST['pass'];
			if($user->validate($username,$pass)){
				$this->xml->addRedir('admin/index');
				$this->xml->addText('logging in as '.$username,'note',0);
				$this->session->set('user',$username);
				$this->session->set('group',$user->getGroupID($username));
			}
			else{
				$result='ERROR: Invalid username or password';
				$this->xml->addRedir($this->getName().'/login');
				$this->xml->addText('redirecting','note',0);
				$this->xml->addText($result,'rightcontent',0);
			}
		}
		$this->xml->flush();
	}

	public function index(){}
	public function __destruct(){}
}
?>
Return current item: Monyet