This commit is contained in:
2019-03-03 21:55:45 +01:00
parent 39701a4a65
commit e032ef9080
3 changed files with 5 additions and 5 deletions

View File

@ -33,16 +33,16 @@ class Controller {
/** @var String[] $arr */
$arr = preg_split("/ /", $annot);
if($arr[0] === "route") {
if(preg_match($arr[1], $route)) {
if(preg_match($arr[1], $route) && !isset($instance)) {
$cl = $class;
$instance = new $class();
$function = ($method->getName());
// return $instance->$function();
}
} elseif ($arr[0] === "editor" && isset($cl) && $cl == $class) {
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && $_SESSION["author"]->getRole() != "ROLE_EDITOR")) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && ($_SESSION["author"]->getRole() != "ROLE_EDITOR" && $_SESSION["author"]->getRole() != "ROLE_ADMIN"))) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
} elseif($arr[0] === "admin" && isset($cl) && $cl ==$class) {
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && ($_SESSION["author"]->getRole() != "ROLE_ADMIN" || $_SESSION["author"]->getRole() != "ROLE_EDITOR"))) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && $_SESSION["author"]->getRole() != "ROLE_ADMIN")) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
}
}
if(isset($instance)) {