Exemple #1
0
 if (isset($post['loginForm'])) {
     $superUser = '******';
     $superPass = '******';
     // array(3) { ["idMatricula"]=> string(9) "gerasysti" ["senhaServidor"]=> string(8) "gsti2010" ["NIVEL"]=> int(1) }
     $post['idMatricula'] = trim(strip_tags($post['idMatricula']));
     $post['senhaServidor'] = trim(strip_tags($post['senhaServidor']));
     unset($post['loginForm']);
     if (md5($post['idMatricula']) == $superUser and md5($post['senhaServidor']) == $superPass) {
         $post['NIVEL'] = 1;
         $post['NOME'] = 'ADMINISTRADOR';
         $_SESSION['user'] = $post;
         header('Location: index.php');
     } else {
         $senhaServidor = $post['senhaServidor'];
         $idMatricula = intval($post['idMatricula']);
         $arrUser = $user->read($cliente, $idMatricula);
         $acesso = $arrUser ? true : false;
         $acesso = $arrUser['ID_SERVIDOR'] == $idMatricula ? true : false;
         $acesso = password_verify($senhaServidor, trim($arrUser['SENHA']));
         if ($acesso) {
             $_SESSION['user'] = $arrUser;
             $_SESSION['user']['NIVEL'] = 3;
             header('Location: index.php');
         } else {
             // unset($_SESSION['orgao']);
             // session_destroy();
             $_SESSION['logout'] = true;
             header('Location: ../index.php');
         }
     }
 }