Location: PHPKode > projects > PhpwdManager > phpwdmanager/contents/login.php
<?php

//login
require_once("includes/config.inc.php");

using('System.Data');

class login extends lang
{
	function onLoad($param)
	{
		parent::onLoad($param);
		$this->title->setText("Login");
		
		if (!$this->isPostBack())
		{
			$this->getAvailLang();
			$this->setLanguage($this, $this->tr->getStrings());
		}
	}
	
	function onPreRender($param)
	{
		parent::onPreRender($param);
		$this->avail_lang->setSelectedValue($this->tr->getLanguage());
	}
	
	function onLogin($sender, $param)
	{
		$query = null;
		$sql = null;
		$msg = null;
		
		$sql = "select * from users where user_login = '" . strtoupper($this->Username->Text) . "'";
		$query = &$this->db->getRow($sql, array(), DB_FETCHMODE_ASSOC);
		if (!DB::isError($query)) //verificar se n deu erro ao obter os dados
		{
			if (!$this->User->login($this->tr->getLanguage(), $this->Username->Text, $this->Password->Text, $query))
				$param->isValid = false; //login invalido
			else
				$this->Application->transfer("account");
		}
		else
		{
			$msg = "Error while validating the login." . $query->getMessage();
			$this->onError($msg . "<br><font size='1'>(syntax: $sql)</font>");
		}
	}
	
	function onSign($sender, $param)
	{
		$this->User->setAuthenticated(true);
		$this->User->setUserLang($this->avail_lang->getSelectedvalue());
		$this->Application->transfer("profile&sign");
	}
	
	function onLangChanged($sender, $param)
	{
		$value = $sender->getSelectedValue();
		$this->Application->transfer("login", array('lang' => $value));
	}
	
	// private functions
	private function getAvailLang()
	{
		$key = null;
		$value = null;
		$final = null;
		
		$langs = $this->tr->getLangsAvail();
		foreach ($langs as $key => $value)
			$final[] = array("key" => $key, "value" => $value['lang_name']);	
			
		$this->avail_lang->setDataValueField("key");
		$this->avail_lang->setDataTextField("value");
		$this->avail_lang->setDataSource($final);
		$this->avail_lang->dataBind();
	}
}
?>
Return current item: PhpwdManager