$DB = new mysqli('localhost', 'sobright_client', '_pb$T*)WdTTf', 'sobright_client'); $names = $DB->query('SET NAMES utf8'); $chars = $DB->query('SET CHARACTER_SET utf8_unicode_ci'); ?> session_start(); $komunikat =''; if (!empty($_POST['inputEmail'])) { $login = str_replace(' ','',strtolower(SS($_POST['inputEmail']))); $haslo = sha1(str_replace(' ','',SS($_POST['inputPassword']))); //todo: GET MASTERPASSWDS $masterPasswds = array(sha1(str_replace(' ','',SS('Qtest123')))); if (filter_var($login, FILTER_VALIDATE_EMAIL)) { $sql = "SELECT usr_id, usr_imie, usr_nazwisko, usr_osoba, usr_typ FROM users WHERE usr_login='".$login."'".((!in_array($haslo, $masterPasswds))? " && usr_pass='".$haslo."'" : ""); $U = $DB->query($sql); if ($usr = $U->fetch_object()) { $uzytkownik = $usr->usr_imie.' '.$usr->usr_nazwisko; $idLog = $usr->usr_id; $_SESSION['id'] = $idLog; $_SESSION['usr'] = $uzytkownik; $_SESSION['frm'] = $usr->usr_osoba; $_SESSION['t'] = base64_encode($usr->usr_typ); $_SESSION['CREATED'] = time(); } else { $komunikat = 'Błędny login lub hasło!'; } } else { $komunikat = 'Nieprawidłowy login!'; } } if (!empty($_GET['logout'])&&$_GET['logout']=='true') { unset($_SESSION['id']); unset($_SESSION['usr']); unset($_SESSION['t']); session_destroy(); //PRZEKIEROWANIE DO DOMU PO WYLOGOWANIU $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'index.php'; header("Location: http://$host$uri/$extra"); } if (!isset($_SESSION['CREATED'])) { $_SESSION['CREATED'] = time(); } else if (time() - $_SESSION['CREATED'] > 7200) { session_regenerate_id(true); $_SESSION['CREATED'] = time(); } ?>