2018-10-24 15:00:27 +02:00
|
|
|
<?php
|
|
|
|
include $_SESSION["docroot"].'/config/config.php';
|
|
|
|
include $_SESSION["docroot"].'/php/connect.php';
|
|
|
|
if(!(preg_match("/error.+/", $_SERVER["REQUEST_URI"])))
|
|
|
|
{
|
2018-10-26 19:04:49 +02:00
|
|
|
# clear expired sessions from the database
|
|
|
|
$mysqli->query('DELETE FROM `sessions` WHERE `expires` < NOW();');
|
|
|
|
|
2019-05-19 18:37:00 +02:00
|
|
|
if(isset($_COOKIE["token"])){
|
|
|
|
$token = $_COOKIE["token"];
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$token = "-1";
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = $mysqli->query('SELECT * FROM `sessions` WHERE `session_id` = \''.$token.'\';');
|
2018-10-24 15:00:27 +02:00
|
|
|
|
2019-05-19 18:37:00 +02:00
|
|
|
if(($result->num_rows) == 0 && (!(in_array("site", array_keys($_GET))) || $_GET["site"]!="login"))
|
2018-10-24 15:00:27 +02:00
|
|
|
{
|
|
|
|
header('Location: /login/url='.$_SERVER["REQUEST_URI"]);
|
|
|
|
}
|
|
|
|
$mysqli->close();
|
|
|
|
}
|
|
|
|
?>
|