ok

Mini Shell

Direktori : /home/institutonamaste/www/admin/class/
Upload File :
Current File : /home/institutonamaste/www/admin/class/class-acesso.php

<?php
class ClassAcesso
{
	private $tb = 'administrador';
	private $lp = 'index.php';
	private $lh = 'blog.php';
	
	public $db_user = 'usuario';
	public $db_pass = 'senha';
	
	public function Acessar()
	{
		if($_POST['usuario'] && $_POST['senha'] && $_POST['login'])
			$this->AcessoSistem($_POST['usuario'], $_POST['senha']);
		else 
			$this->Form();
	}

	private function Form()
	{
		echo'
		<form method="post">
			<input name="usuario" type="text" placeholder="Usuário" required/>
			<br /><br />
			
			<input name="senha" type="password" placeholder="Senha" required/>
			<br /><br />
			
			<input name="login" type="submit" value=" Entrar "/>
		</form>';		
	}

	private function AcessoSistem($user, $pass)
	{
		$user = md5(DBEscape($this->ValidUser(str_replace("'","",$user))));
		$pass = md5(DBEscape($this->ValidPass(str_replace("'","",$pass))));

		$where = "WHERE ".$this->db_user." = '$user' AND ".$this->db_pass." = '$pass'";
		if(mysqli_num_rows(DBRead($this->tb, $where)) == 1)
		{
			$_SESSION['AdM_Web_Log'] = TRUE;
			$this->LinkReturn('', $this->lh);
		}
		else
		{
			$this->LinkReturn('Usuário ou senha inválido', $this->lp);
		}
	}

	private function LinkReturn($mensagem, $link)
	{
		echo (!empty($mensagem))? "<script type=\"text/javascript\">alert(\"".$mensagem."\");</script>" : '';
		echo "<META HTTP-EQUIV=REFRESH CONTENT='0; URL=".$link."'>";
		exit();
	}
	
	private function ValidUser($user)
	{
		if($user == "" or $user == NULL or empty($user))
			$this->LinkReturn('Informe o login!', 'index.php');
		
		if(!preg_match("/^[A-Za-z]+$/", $user))
			$this->LinkReturn('Usuário ou senha inválido', 'index.php');
		
		return $user;
	}
	
	private function ValidPass($pass)
	{
		if($pass == "" or $pass == NULL or empty($pass))
			$this->LinkReturn('Informe a senhas!', 'index.php');
		
		if(!preg_match("/^[A-Za-z0-9#]+$/", $pass))
			$this->LinkReturn('Usuário ou senha inválido', 'index.php');
		
		return $pass;
	}
}

function CheckLogin()
{
	if(!isset($_SESSION['AdM_Web_Log']) or $_SESSION['AdM_Web_Log'] != TRUE)
	{
		echo"
		<script type=\"text/javascript\">alert(\"Necessario fazer o login para acessar esta pagina!\");</script>
		<META HTTP-EQUIV=REFRESH CONTENT='0; URL=index.php'>";
		exit();
	}
}
?>

Zerion Mini Shell 1.0