Advertisement
Guest User

Untitled

a guest
Jul 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.53 KB | None | 0 0
  1. <?php
  2. $error=false;
  3.     ob_start();
  4.     // Errors reporting, used if needed
  5.     error_reporting(E_ALL);
  6.     ini_set('display_errors', 'on');
  7.  
  8.     // General configuration like base, used if needed
  9.     include_once ('include/config.inc.php');
  10.  
  11.     // Mail functions
  12.     include_once ('include/mail.functions.php');
  13.  
  14.     // Start session if needed
  15.     session_start();
  16.  
  17.     // DBConn
  18.     include_once ('class/DB/DBConn.includeall.php');
  19.     $db = new DBConn(NULL);
  20.  
  21.     // Includere clasa login
  22.     require_once ('class/class_login.php');
  23.  
  24.     // Set up current language
  25.     $lang = "ro";
  26.     $_SESSION[PRE.'lang'] = $lang;
  27.  
  28.     $access = 0;
  29.  
  30.     // Check if the cookie for "remember me" exists
  31.     if(isset($cookie_name))
  32.     {
  33.         if(isset($_COOKIE[$cookie_name]))
  34.         {
  35.             parse_str($_COOKIE[$cookie_name]);
  36.  
  37.             $login = new Login($db);
  38.             if ($login->_checkLogin($usr, $hash) == true)
  39.             {
  40.                 $access = 1;
  41.             }
  42.  
  43.         }
  44.     }
  45.  
  46.  
  47.     $msg_email_recover = "";
  48.  
  49.  
  50.     $conn = pg_connect("host=dev.incorom.local port=5432 dbname=login_robinson user=robinson password=123");
  51.     $rezervare= isset($_POST['pass_login']);
  52.     $result = pg_query($conn, "SELECT checkin_status FROM tcheckin WHERE nr_rezervare = '$rezervare'");
  53.     if (!$result) {
  54.         echo "An error occurred.\n";
  55.         exit;
  56.     }
  57.     $checkin_status = pg_fetch_row($result);
  58.  
  59.     // Daca s-a submis formul de login si avem codul de checkin, aici este problema
  60.     if(isset($_POST['pass_login']) && trim($_POST['pass_login']) != '')
  61.     {
  62.  
  63.         $login = new Login($db);
  64.         if ($login->_checkLogin(trim($_POST['pass_login']), $_POST['pass_login']) && $checkin_status[0] == 0)
  65.         {
  66.  
  67.             $access = 1;
  68.             //Set cookie for "remember me"
  69.             if(isset($_POST["remember_me"]) && $_POST["remember_me"] == 1)
  70.             {
  71.                 $password_hash = $_POST['pass_login']; // will result in a 32 characters hash
  72.                 $nume_utilizator = $_SESSION[PRE . 'username'];
  73.  
  74.                 $set_cook = setcookie ($cookie_name, 'usr='.$nume_utilizator.'&hash='.$password_hash, time() + $cookie_time);
  75.  
  76.             }
  77.         }
  78.     }
  79.         // Daca s-a reusit logarea
  80.         if(0 < $access)
  81.         {
  82.             // Redirectam in functie de rol, dupa ce adaugam si locatiile corespunzatoare in sesiune
  83.             $rol = $_SESSION[PRE . "rol"];
  84.  
  85.             // ROL 1 AFL
  86.             if(isset($_POST['login']) && $checkin_status[0] != 1)
  87.             {
  88.                 header('Location:' . $BASE);
  89.                 exit();
  90.             }
  91.  
  92.         }
  93.  
  94.     if (isset($_POST['login'])) {
  95.         //update action
  96.     if(isset($_POST['pass_login']) == 0 && $checkin_status[0] != 1){
  97.         echo "login success";
  98.     }
  99.     else{
  100.           $error = true;
  101.     }
  102. }
  103.  
  104. if (isset($_POST['register'])) {
  105.     header("location:register.php");
  106. }
  107.  
  108.  
  109. ?>
  110.  
  111. <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  112.  
  113.     <head>
  114.         <!-- <base href="http://dev.incorom.local/ticketing/www/login.php" /> -->
  115.         <title>Login</title>
  116.         <?php
  117.             include('include/links.php');
  118.             include('include/scripts.php');
  119.         ?>
  120.     </head>
  121.  
  122.     <body style="display: block !important;" ng-cloak="" ng-class="{ 'layout-fixed' : app.layout.isFixed, 'layout-boxed' : app.layout.isBoxed, 'layout-dock' : app.layout.isDocked, 'layout-material': app.layout.isMaterial, 'aside-offscreen' : app.sidebar.isOffscreen, 'aside-mini' : app.sidebar.isMini, 'aside-right' : app.sidebar.isRight, 'footer-hidden': app.footer.hidden, 'in-app': !$state.includes('page')}">
  123.  
  124.         <div class="animated fadeOutZoom">
  125.             <div class="container container-sm animated fadeInDown">
  126.                 <div class="center-block mt-xl">
  127.                     <img src="images/logo_iconlab.png" alt="Image" class="center-block img-rounded">
  128.                     <div class="panel">
  129.                         <div class="panel-body">
  130.                             <p class="pv text-bold">Date de logare</p>
  131.                             <form class="mb-lg" method="post" action="login.php" id="form">
  132.  
  133.                             <div class="row">
  134.                                 <div class="col-md-12">
  135.                                     <div class="form-group has-feedback">
  136.                                         <input id="exampleInputPassword1" type="text" placeholder="Numar rezervare" class="form-control" name="pass_login" /><span class="fa fa-lock form-control-feedback text-muted"></span>
  137.                                     </div>
  138.                                 </div>
  139.                                 <div class="col-md-12">
  140.                                     <button type="submit" class="btn btn-block btn-info btnblue mb" name="login" value="login">Login</button>
  141.                                     <button type="submit" class="btn btn-block btn-info btnblue mb login" name="register" value="register">Inregistrare</button>
  142.                                 </div>
  143.  
  144.                             </form>
  145.                             <?php if($error){ ?>
  146.      <script> alert ("S-a produs o eroare la validarea formularului. Probabil utilizator nu exista in baza de date sau checkin-ul a fost efectuat deja.")</script>
  147. <?php } ?>
  148.                         </div>
  149.                     </div>
  150.                 </div>
  151.             </div>
  152.         </div>
  153.     </body>
  154.  
  155. </html>
  156. <?php
  157. ob_end_flush();
  158. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement