Andreu | 0d72bd6 | 2019-09-17 23:31:14 +0200 | [diff] [blame] | 1 | <?php |
Andreu | 2457e40 | 2019-09-22 00:52:41 +0200 | [diff] [blame] | 2 | require '../credentials.php'; |
Andreu | abbcb7e | 2019-09-21 18:22:14 +0200 | [diff] [blame] | 3 | require 'utils.php'; |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 4 | require_once("security.php"); |
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 5 | |
6 | $credentials = new Credentials(); | ||||
7 | $usersdb = $credentials->usersdb; | ||||
Andreu | 20af6c2 | 2019-09-24 18:33:50 +0200 | [diff] [blame] | 8 | |
Adrià Vilanova Martínez | d3394e1 | 2022-11-19 15:45:58 +0100 | [diff] [blame] | 9 | date_default_timezone_set("Europe/Madrid"); |
Andreu | 03d030d | 2019-09-25 21:52:01 +0200 | [diff] [blame] | 10 | |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 11 | if (!isset($_POST["user"])) { |
12 | header("Location: /?wronguser=1"); | ||||
13 | exit(); | ||||
Andreu | 09b8b05 | 2019-09-21 21:47:20 +0200 | [diff] [blame] | 14 | } |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 15 | |
16 | $user = $_POST["user"]; | ||||
17 | $password = $_POST["password"] ?? ""; | ||||
18 | |||||
19 | $ok = Security::signIn($user, $password); | ||||
20 | |||||
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 21 | // Redirect if wrong |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 22 | if (!$ok) { |
23 | header("Location: /?wrongpassword=1"); | ||||
24 | exit(); | ||||
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 25 | } |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 26 | |
Andreu | 20cbd1d | 2019-09-22 00:00:57 +0200 | [diff] [blame] | 27 | // Success, proceed to main page |
Adrià Vilanova Martínez | 13cf0cd | 2022-11-20 01:02:20 +0100 | [diff] [blame] | 28 | header("Location: /main.php"); |