session_start("dorotheus"); if($_SESSION['id_dorotheus'] != "" ) { echo " "; exit; } include("config.php"); if($_REQUEST['acao']==logar){ $txtemail = $_POST['txtemail']; $txtsenha = $_POST['txtsenha']; $logvalido = nao; $busca=mysql_query("SELECT * FROM $tblusuarios WHERE email='$txtemail' AND senha='$txtsenha' AND desativado != '1' "); $n=mysql_num_rows($busca); if($n > 0){ unset($_SESSION['email_dorotheus']); unset($_SESSION['id_dorotheus']); unset($_SESSION['nome_dorotheus']); unset($_SESSION['nivel_dorotheus']); unset($_SESSION['tipo_dorotheus']); unset($_SESSION['subtipo_dorotheus']); unset($_SESSION['permi_dorotheus_1']); unset($_SESSION['permi_dorotheus_2']); unset($_SESSION['permi_dorotheus_3']); unset($_SESSION['permi_dorotheus_4']); unset($_SESSION['permi_dorotheus_5']); //unset($_SESSION['permi_dorotheus_6']); $linha = mysql_fetch_array($busca); $email_dorotheus = $linha["email"]; $id_dorotheus = $linha["idusuario"]; $nome_dorotheus = $linha["nome"]; $nivel_dorotheus = $linha["nivel"]; $tipo_dorotheus = $linha["tipo"]; $subtipo_dorotheus = $linha["subtipo"]; $senha = $linha["senha"]; //confere se os dados do banco batem com os digitados, para evitar sql injecton if( ($email_dorotheus==$txtemail AND $senha==$txtsenha) || ($id_dorotheus==$txtemail AND $senha==$txtsenha) ){ $_SESSION['email_dorotheus']=$email_dorotheus; $_SESSION['id_dorotheus']=$id_dorotheus; $_SESSION['nome_dorotheus']=$nome_dorotheus; $_SESSION['nivel_dorotheus']=$nivel_dorotheus; $_SESSION['tipo_dorotheus']=$tipo_dorotheus; $_SESSION['subtipo_dorotheus']=$subtipo_dorotheus; $logvalido = sim; $sqlchec=mysql_query("SELECT permissao FROM permissoes WHERE idusuario='$id_dorotheus' "); while( $rchec = mysql_fetch_array( $sqlchec) ){ $permissao = $rchec['permissao']; $_SESSION['permi_dorotheus_'.$permissao] = 's'; } } } if($logvalido==sim){ //log $logacesso = "Acesso ao sistema"; $agora = date("Y") . "-" . date("m") . "-" . date("d") . " " . date("H") . ":" . date("i") . ":" . date("s") ; @mysql_query("INSERT INTO $acessos (idusuario, datahora, log) VALUES ('$id_dorotheus','$agora','$logacesso')"); echo " "; } else{ echo " "; } exit; } ?>