This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
dogstats/web/pages/err/controller.php
Chris fea847afd2
All checks were successful
Build and push / Pulling repo on server (push) Successful in 3s
auto login when chosen so
2023-10-29 15:58:16 +01:00

46 lines
1.1 KiB
PHP

<?php
class Err extends Page {
function notfound($params=false)
{
$this->set("page",$params[0]);
$this->set('template', "notfound.html");
}
function notallowed()
{
//check if user has a cookie and if so, logg them in and refresh the page
if(isset($_COOKIE['token']))
{
$u = new User();
$allusers = $u->getAll(false);
foreach($allusers as $user)
{
if($user['token'] && $user['token'] == $_COOKIE['token'])
{
$u->id = $user['id'];
break;
}
}
if($u->id)
{
$u->load($u->id);
$u->login();
$url = '/'.implode('/',$GLOBALS['url']);
//var_dump($url);
$this->redirect($url);
}
else
{
setcookie('token', '', time() - 3600, "/");
}
}
$this->set("loggedin",(isset($_SESSION['user']) && $_SESSION['user'] !== false));
$this->set('template', "notallowed.html");
}
}