

<?php include_once "common/func_form.php"; include_once "common/connect.php"; { formReg("Aby sie zarejestrowac musisz wypelnic ponizszy formularz<br>"); } else { $register_login = $_POST['login']; $register_passwd = $_POST['haslo']; if (!is_numeric($register_login) and (!empty($register_login)) && (!empty($register_passwd) and $register_passwd !== NULL )) { { $register_passwd = sha1($register_passwd); $sql_select = mysql_query ("SELECT * FROM users_session WHERE user_login = '$register_login' and user_password = '$register_passwd'") or die ("nie znaleziono takiego usera"); { INSERT INTO users_session (user_login, user_password) VALUES ('$register_login', '$register_passwd') "); } else { formReg("Taki uzytkownik juz istnieje!<br>"); } } else { { } { formReg("login jest za krotki"); } formReg("haslo i login sa za krotkie"); } } { formReg("NIE MOZNA WPISYWAC LICZB<br>"); } //else { { formReg("FORMULARZ NIE MOZE BYC PUSTY<br>"); } else { formReg("MUSZA BYC WYPELNIONE OBA POLA<br>"); } } } ?>
<?php class security { if ($_SESSION['login'] == TRUE) { if ($_SESSION['ip'] === $_SERVER['REMOTE_ADDR']) { return TRUE; }else{ error::save('Błąd! Próba przejęcia sesji!', ERR_CRITICAL); return FALSE; } }else{ return FALSE; } } if (self::isLogin() == TRUE) { return $info = array('id' => $_SESSION['id'], 'name' => $_SESSION['name'], 'access' => $_SESSION['access']); }else{ error::save('Nie jesteś zalogowany!', ERR_NORMAL); return FALSE; } } if (self::isLogin() != TRUE) { $user = self::nohack($user); $pass = sha1($pass); if ($sql[0]['password'] == $pass) { $_SESSION['login'] = TRUE; $_SESSION['id'] = $sql[0]['id']; $_SESSION['name'] = $sql[0]['name']; $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; return TRUE; }else{ return FALSE; } }else{ return TRUE; } } if (self::isLogin() == TRUE) { return TRUE; }else{ error::save('Nie jesteś zalogowany!', ERR_NORMAL); return FALSE; } } //$string = htmlspecialchars($string); return $string; } } ?>
<?php class auth { private $user; private $password; private function filter($input) { ... filtrowanie danych... } public function login() { $this->user = $this->filter($_POST['user']); $this->password = $this->filter($_POST['password']); ... sprawdzanie czy taki jest ... logowanie ... } public function logout() { ...wylogowywanie... } ?>