blob: c06149e581fe161bbe83d8103fac1775b1006ed4 [file] [log] [blame]
Andreu0d72bd62019-09-17 23:31:14 +02001<?php
Andreu2457e402019-09-22 00:52:41 +02002 require '../credentials.php';
Andreuabbcb7e2019-09-21 18:22:14 +02003 require 'utils.php';
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +01004 require_once("security.php");
Andreu20af6c22019-09-24 18:33:50 +02005
6 $credentials = new Credentials();
Adrià Vilanova Martínez60524332022-11-20 02:33:56 +01007 $usersdb = $credentials->usersdb();
Andreu20af6c22019-09-24 18:33:50 +02008
Adrià Vilanova Martínezd3394e12022-11-19 15:45:58 +01009 date_default_timezone_set("Europe/Madrid");
Andreu03d030d2019-09-25 21:52:01 +020010
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010011 if (!isset($_POST["user"])) {
12 header("Location: /?wronguser=1");
13 exit();
Andreu09b8b052019-09-21 21:47:20 +020014 }
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010015
16 $user = $_POST["user"];
17 $password = $_POST["password"] ?? "";
18
19 $ok = Security::signIn($user, $password);
20
Andreu20cbd1d2019-09-22 00:00:57 +020021 // Redirect if wrong
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010022 if (!$ok) {
23 header("Location: /?wrongpassword=1");
24 exit();
Andreu20cbd1d2019-09-22 00:00:57 +020025 }
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010026
Andreu20cbd1d2019-09-22 00:00:57 +020027 // Success, proceed to main page
Adrià Vilanova Martínez13cf0cd2022-11-20 01:02:20 +010028 header("Location: /main.php");