This commit is contained in:
Florian Bouillon 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 */ /** @var String[] $arr */
$arr = preg_split("/ /", $annot); $arr = preg_split("/ /", $annot);
if($arr[0] === "route") { if($arr[0] === "route") {
if(preg_match($arr[1], $route)) { if(preg_match($arr[1], $route) && !isset($instance)) {
$cl = $class; $cl = $class;
$instance = new $class(); $instance = new $class();
$function = ($method->getName()); $function = ($method->getName());
// return $instance->$function(); // return $instance->$function();
} }
} elseif ($arr[0] === "editor" && isset($cl) && $cl == $class) { } 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) { } 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)) { if(isset($instance)) {

View File

@ -45,7 +45,7 @@ class AddEditController extends Controller {
*/ */
public function postAdd() { public function postAdd() {
// var_dump($_SESSION["author"]); var_dump($_GET);
// die; // die;
if(isset($_GET["title"]) && isset($_GET["category"]) && isset($_GET["content"]) && isset($_GET["tags"])) { if(isset($_GET["title"]) && isset($_GET["category"]) && isset($_GET["content"]) && isset($_GET["tags"])) {

View File

@ -11,7 +11,7 @@ use App\DB\Post;
class Editor extends \App\Tags\Tag { class Editor extends \App\Tags\Tag {
public function render() { public function render() {
if($_GET["post"] == "new") $_GET["post"] = null; if($_GET["post"] == "new") $_GET["post"] = null;
else $post = Post::get($_GET["post"]); elseif(isset($_GET["post"])) $post = Post::get($_GET["post"]);
//recuperation de la balise de base (<tag type="bold">pouet</tag>) //recuperation de la balise de base (<tag type="bold">pouet</tag>)
$pok = $this->getElement(); $pok = $this->getElement();
//recuperation du document (necessaire a la création de balises //recuperation du document (necessaire a la création de balises