<?php

(!defined('IN_PowerBB')) ? die() : '';

define('IN_ADMIN',true);
define('STOP_STYLE',true);

include('common.php');

define('CLASS_NAME','PowerBBLoginMOD');

class PowerBBLoginMOD
{
	function run()
	{
		global $PowerBB;

		if ($PowerBB->_GET['login'])
		{
			$this->_StartLogin();
		}
	}

	function _StartLogin()
	{
		global $PowerBB;

		if (empty($PowerBB->_POST['username'])
			or empty($PowerBB->_POST['password']))
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['Please_fill_in_all_the_information']);
		}

		$username = $PowerBB->functions->CleanVariable($PowerBB->_POST['username'],'trim');
		$password = $PowerBB->functions->CleanVariable(md5($PowerBB->_POST['password']),'trim');
        $username	= 	$PowerBB->functions->CleanVariable($username,'html');
        $username	= 	$PowerBB->functions->CleanVariable($username,'sql');
        $password	= 	$PowerBB->functions->CleanVariable($password,'html');
        $password	= 	$PowerBB->functions->CleanVariable($password,'sql');
		$IsMember = $PowerBB->member->LoginAdmin(array(	'username'	=>	$username,
															'password'	=>	$password));


		if ($IsMember)
		{
			$PowerBB->functions->redirect('admin.php',0);
		}
		else
		{
			$PowerBB->functions->error($PowerBB->_CONF['template']['lang']['INcorrect_information']);
		}
	}
}

?>
