mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-22 10:52:09 +00:00
finalisation de ma part :)
This commit is contained in:
parent
9df001d565
commit
cc8ee929f8
@ -507,7 +507,7 @@ input {
|
|||||||
.article .title {
|
.article .title {
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #3a3a3a;
|
color: #3a3a3a;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article .text {
|
.article .text {
|
||||||
@ -519,7 +519,7 @@ input {
|
|||||||
height: 180px;
|
height: 180px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article .text img {
|
.article .text img, .container-search img {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -672,10 +672,7 @@ label{
|
|||||||
-o-transition: 200ms;
|
-o-transition: 200ms;
|
||||||
transition: 200ms;
|
transition: 200ms;
|
||||||
box-shadow: 1px 1px 30px 1px lightgrey;
|
box-shadow: 1px 1px 30px 1px lightgrey;
|
||||||
}
|
color:#000;
|
||||||
.next:hover{
|
|
||||||
color: #007bff;
|
|
||||||
box-shadow: 1px 1px 30px 1px rgba(0,163,249,0.3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filtre {
|
.filtre {
|
||||||
@ -886,7 +883,7 @@ label{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
form.login > input {
|
form.login > input, form.login > a {
|
||||||
/* text-align: center; */
|
/* text-align: center; */
|
||||||
display: block;
|
display: block;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
@ -903,9 +900,8 @@ form.login >input[type="submit"], form.login > a {
|
|||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
form.login > a {
|
form.login a {
|
||||||
left: -28%;
|
width: 106px;
|
||||||
margin-top: 65px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.css" rel="stylesheet" />
|
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.css" rel="stylesheet" />
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.js"></script>
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote.js"></script>
|
||||||
|
<script src="https://unpkg.com/popper.js/dist/umd/popper.min.js"></script>
|
||||||
|
@ -44,10 +44,10 @@
|
|||||||
<div class="bloc-filter">
|
<div class="bloc-filter">
|
||||||
<h3>Plus d'articles</h3>
|
<h3>Plus d'articles</h3>
|
||||||
<p class="title-small">Catégories</p>
|
<p class="title-small">Catégories</p>
|
||||||
<div class="filtre dev-color">dev</div>
|
<a data-category="3" class="filtre dev-color">dev</a>
|
||||||
<div class="filtre digi-color">digi</div>
|
<a data-category="4" class="filtre digi-color">digi</a>
|
||||||
<div class="filtre ops-color">ops</div>
|
<a data-category="2" class="filtre ops-color">ops</a>
|
||||||
<div class="filtre devops-color">devops</div>
|
<a data-category="1" class="filtre devops-color">devops</a>
|
||||||
<p class="title-small">Tags</p>
|
<p class="title-small">Tags</p>
|
||||||
<tag type="tags" />
|
<tag type="tags" />
|
||||||
</div>
|
</div>
|
||||||
@ -58,6 +58,11 @@
|
|||||||
<a href="./edit" class="contenue-recent next">Editer l'article</a>
|
<a href="./edit" class="contenue-recent next">Editer l'article</a>
|
||||||
</if>
|
</if>
|
||||||
</tag>
|
</tag>
|
||||||
|
<tag type="isLoggedIn" reol="ROLE_ADMIN">
|
||||||
|
<if true>
|
||||||
|
<a style="float: left" href="./delete" class="contenue-recent next">Supprimmer l'article</a>
|
||||||
|
</if>
|
||||||
|
</tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 id="titre-between">Dans le même thème</h3>
|
<h3 id="titre-between">Dans le même thème</h3>
|
||||||
|
@ -17,16 +17,15 @@
|
|||||||
<div class="cover-text">
|
<div class="cover-text">
|
||||||
<h2 id="titre-home">Créer un utilisateur</h2>
|
<h2 id="titre-home">Créer un utilisateur</h2>
|
||||||
<div class="p-home">
|
<div class="p-home">
|
||||||
<form name="login" id="name" method="POST" class="login" action="./edit">
|
<form name="login" id="name" method="POST" class="login" action="./">
|
||||||
<input name="username" id="username" type="text" placeholder="Nom d'utilisateur" />
|
<tag type="userEditor" element="username" />
|
||||||
<input name="password" id="password" type="password" placeholder="Mot de passe" />
|
<input name="password" id="password" type="password" placeholder="Mot de passe" />
|
||||||
<select name="ROLE_ADMIN">
|
<input name="job" id="job" type="text" placeholder="apprenant" />
|
||||||
<tag type="userEditor" el="role" />
|
<select name="role">
|
||||||
<option value="ROLE_USER">Utilisateur</option>
|
<tag type="userEditor" element="role" />
|
||||||
<option value="ROLE_EDITOR">Editeur</option>
|
|
||||||
<option value="ROLE_ADMIN">Administrateur</option>
|
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" class="bloc-button" value="Créer"/>
|
<input type="submit" class="bloc-button" value="Créer"/>
|
||||||
|
<a style="border: none" class="bloc-button" href="../delete/">Supprimmer</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -107,19 +107,6 @@ var submit = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
http.send(data);
|
http.send(data);
|
||||||
// var url = './';
|
|
||||||
// var params = "title="+ title.value +"&category=" + category.value + "&content=" + major.innerHTML + "&tags=" + tglst;
|
|
||||||
// http.open('POST', url, true);
|
|
||||||
|
|
||||||
// //Send the proper header information along with the request
|
|
||||||
// http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
||||||
|
|
||||||
// console.log(major.innerHTML);
|
|
||||||
|
|
||||||
|
|
||||||
// http.send(params);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(document.querySelector(".addTag") != null) {
|
if(document.querySelector(".addTag") != null) {
|
||||||
@ -131,13 +118,13 @@ document.querySelector("#search + button").addEventListener("click", function()
|
|||||||
window.location = window.location.pathname + "?term=" + document.querySelector("#search").value;
|
window.location = window.location.pathname + "?term=" + document.querySelector("#search").value;
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll(".int-search .filtre").forEach(function(el) {
|
document.querySelectorAll(".filtre").forEach(function(el) {
|
||||||
el.addEventListener("click", function() {
|
el.addEventListener("click", function() {
|
||||||
var tagW = new URL(window.location).searchParams.get("tag");
|
var tagW = new URL(window.location).searchParams.get("tag");
|
||||||
var tag = (tagW != null ? "&tag=" + tagW : "");
|
var tag = (tagW != null ? "&tag=" + tagW : "");
|
||||||
var termW = new URL(window.location).searchParams.get("term");
|
var termW = new URL(window.location).searchParams.get("term");
|
||||||
var term = (termW != null ? "&term=" + termW : "");
|
var term = (termW != null ? "&term=" + termW : "");
|
||||||
window.location = window.location.pathname + "?category=" + this.getAttribute("data-category") + tag + term;
|
window.location = "/search/?category=" + this.getAttribute("data-category") + tag + term;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ class Controller {
|
|||||||
// 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" && $_SESSION["author"]->getRole() != "ROLE_ADMIN"))) 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/");
|
||||||
} 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")) header("Location: /login/?redirect=".$_SERVER["REQUEST_URI"]);
|
if(!isset($_SESSION["author"]) || (isset($_SESSION["author"]) && $_SESSION["author"]->getRole() != "ROLE_ADMIN")) header("Location: /login/");
|
||||||
} elseif($arr[0] === "title" && isset($cl) && $cl == $class) {
|
} elseif($arr[0] === "title" && isset($cl) && $cl == $class) {
|
||||||
array_shift($arr);
|
array_shift($arr);
|
||||||
$_GET['page_title'] = join(" ", $arr);
|
$_GET['page_title'] = join(" ", $arr);
|
||||||
|
@ -19,7 +19,6 @@ class LoginController extends Controller {
|
|||||||
$user = Author::getByUsername($_POST["username"]);
|
$user = Author::getByUsername($_POST["username"]);
|
||||||
if($user->checkPassword($_POST["password"])) {
|
if($user->checkPassword($_POST["password"])) {
|
||||||
$_SESSION["author"] = $user;
|
$_SESSION["author"] = $user;
|
||||||
if(isset($_GET["redirect"])) header("Location: " . $_GET["redirect"]);
|
|
||||||
header("Location: /");
|
header("Location: /");
|
||||||
}
|
}
|
||||||
else var_dump("login incorreect");
|
else var_dump("login incorreect");
|
||||||
|
@ -81,6 +81,15 @@ class PostController extends Controller {
|
|||||||
return file_get_contents(DIR."/html/post.html");
|
return file_get_contents(DIR."/html/post.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @route /^\/post\/[0-9]+\/delete\/$/
|
||||||
|
* @title Article
|
||||||
|
*/
|
||||||
|
public function delete() {
|
||||||
|
Post::remove(Post::get($_GET["post"]));
|
||||||
|
header("Location: /");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route /^\/post\/[0-9]+\/upload\/$/
|
* @route /^\/post\/[0-9]+\/upload\/$/
|
||||||
*/
|
*/
|
||||||
|
@ -36,13 +36,35 @@ class UserController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route /\/users\/edit\/[0-9]+\/$/
|
* @route /\/users\/[0-9]+\/edit\/$/
|
||||||
* @admin
|
* @admin
|
||||||
* @title Modifier un utilisateur
|
* @title Modifier un utilisateur
|
||||||
*/
|
*/
|
||||||
public function editUser() {
|
public function editUser() {
|
||||||
$_GET['edit_user'] = explode("/", $_GET["page"])[3];
|
var_dump($_POST);
|
||||||
return \file_get_contents(DIR."/html/user_edit.html");
|
$_GET['edit_user'] = explode("/", $_GET["page"])[2];
|
||||||
|
|
||||||
|
if(isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["job"]) && isset($_POST["role"])) {
|
||||||
|
$user = Author::get($_GET["edit_user"]);
|
||||||
|
$user->setUsername($_POST["username"]);
|
||||||
|
if($_POST["password"] != '') $user->setPassword($_POST["password"]);
|
||||||
|
$user->setRole($_POST["role"]);
|
||||||
|
var_dump($user);
|
||||||
|
Author::update($user);
|
||||||
|
// header("Location: /users/");
|
||||||
|
}
|
||||||
|
return file_get_contents(DIR."/html/user_edit.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @route /\/users\/[0-9]+\/delete\/$/
|
||||||
|
* @admin
|
||||||
|
* @title Modifier un utilisateur
|
||||||
|
*/
|
||||||
|
public function deleteUser() {
|
||||||
|
$_GET['edit_user'] = explode("/", $_GET["page"])[2];
|
||||||
|
Author::remove(Author::get($_GET["edit_user"]));
|
||||||
|
header("Location: /users/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,80 +6,41 @@ use App\DB\Category;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use App\DB\Tag;
|
use App\DB\Tag;
|
||||||
use App\DB\Post;
|
use App\DB\Post;
|
||||||
|
use App\DB\Author;
|
||||||
|
|
||||||
|
|
||||||
class UserEditor extends \App\Tags\Tag {
|
class UserEditor extends \App\Tags\Tag {
|
||||||
public function render() {
|
public function render() {
|
||||||
if($_GET["post"] == "new") $_GET["post"] = null;
|
$user = Author::get($_GET["edit_user"]);
|
||||||
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();
|
$el = $this->getElement();
|
||||||
//recuperation du document (necessaire a la création de balises
|
//recuperation du document (necessaire a la création de balises
|
||||||
$doc = $this->getDoc();
|
$doc = $this->getDoc();
|
||||||
|
|
||||||
$type = $pok->getAttribute("element");
|
$type = $el->getAttribute("element");
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'role':
|
case 'role':
|
||||||
foreach (array("Utilisateur" => "ROLE_USER", "Editeur" =>"ROLE_EDITOR", "Admin" => "ROLE_ADMIN") as $key => $value) {
|
foreach (array("Utilisateur" => "ROLE_USER", "Editeur" =>"ROLE_EDITOR", "Admin" => "ROLE_ADMIN") as $key => $value) {
|
||||||
$opt = $doc->createElement("option");
|
$opt = $doc->createElement("option");
|
||||||
$opt->setAttribute("value", $value);
|
$opt->setAttribute("value", $value);
|
||||||
|
if($user->getRole() == $value) $opt->setAttribute("selected", "selected");
|
||||||
$opt->appendChild($doc->createTextNode($key));
|
$opt->appendChild($doc->createTextNode($key));
|
||||||
$el->parentNode->appendChild();
|
$el->parentNode->appendChild($opt);
|
||||||
}
|
|
||||||
$option = $doc->createElement("option");
|
|
||||||
$text = $doc->createTextNode("Categorie");
|
|
||||||
$option->setAttribute("value", "1");
|
|
||||||
$option->setAttribute("disabled", "true");
|
|
||||||
if(!isset($post)) $option->setAttribute("selected", "selected");
|
|
||||||
$option->appendChild($text);
|
|
||||||
$pok->parentNode->insertBefore($option, $pok);
|
|
||||||
foreach (Category::list() as $cat) {
|
|
||||||
$option = $doc->createElement("option");
|
|
||||||
$text = $doc->createTextNode($cat->getName());
|
|
||||||
$option->appendChild($text);
|
|
||||||
$option->setAttribute("value", $cat->getId());
|
|
||||||
if(isset($post) && $post->getCategory()->getId() == $cat->getId()) $option->setAttribute("selected", "selected");
|
|
||||||
$pok->parentNode->insertBefore($option, $pok);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'datetime':
|
case 'username':
|
||||||
if(isset($post)) $txt = $post->getDateTime();
|
|
||||||
else $txt = (new DateTime())->format('d/m/Y H:i:s');
|
|
||||||
$pok->parentNode->insertBefore($doc->createTextNode($txt), $pok);
|
|
||||||
break;
|
|
||||||
case 'content':
|
|
||||||
$tarea = $doc->createElement("textarea");
|
|
||||||
if(isset($post)) $tarea->appendChild($doc->createTextNode($post->getContent()));
|
|
||||||
$tarea->setAttribute("style", "width: 100%; min-height: 200px");
|
|
||||||
$pok->parentNode->insertBefore($tarea, $pok);
|
|
||||||
break;
|
|
||||||
case 'title':
|
|
||||||
$input = $doc->createElement("input");
|
$input = $doc->createElement("input");
|
||||||
$input->setAttribute("style", "width: 100%");
|
$input->setAttribute("value", $user->getUsername());
|
||||||
$input->setAttribute("placeholder", "titre");
|
$input->setAttribute("name", "username");
|
||||||
if(isset($post)) $input->setAttribute("value", $post->getTitle());
|
$el->parentNode->insertBefore($input, $el);
|
||||||
$pok->parentNode->insertBefore($input, $pok);
|
break;
|
||||||
|
case 'job':
|
||||||
|
$input = $doc->createElement("input");
|
||||||
|
$input->setAttribute("value", $user->getJob());
|
||||||
|
$input->setAttribute("name", "job");
|
||||||
|
$el->parentNode->insertBefore($input, $el);
|
||||||
break;
|
break;
|
||||||
case 'tags':
|
|
||||||
foreach (Tag::list() as $el) {
|
|
||||||
$tg = $doc->createElement("input");
|
|
||||||
$tg->setAttribute("id", $el->getId());
|
|
||||||
$tg->setAttribute("type", "checkbox");
|
|
||||||
$tg->setAttribute("data-text", $el->getName());
|
|
||||||
if(isset($post)) {
|
|
||||||
if(in_array($el, $post->getTags())) $tg->setAttribute("checked", "checked");
|
|
||||||
}
|
|
||||||
$txt = $doc->createElement("label");
|
|
||||||
$txt->appendChild($doc->createTextNode($el->getName()));
|
|
||||||
$txt->setAttribute("for", $el->getId());
|
|
||||||
$pok->parentNode->insertBefore($tg, $pok);
|
|
||||||
$pok->parentNode->insertBefore($txt, $pok);
|
|
||||||
}
|
|
||||||
$btn = $doc->createElement("button");
|
|
||||||
$btn->appendChild($doc->createTextNode("Add Tag"));
|
|
||||||
$btn->setAttribute("class", "addTag");
|
|
||||||
$pok->parentNode->insertBefore($btn, $pok);
|
|
||||||
default:
|
default:
|
||||||
# code...
|
# code...
|
||||||
break;
|
break;
|
||||||
|
@ -12,6 +12,7 @@ class Users extends Tag {
|
|||||||
$parent = $el->parentNode;
|
$parent = $el->parentNode;
|
||||||
foreach (Author::list(true, 1000) as $user) {
|
foreach (Author::list(true, 1000) as $user) {
|
||||||
$pok = $el->childNodes->item(0)->cloneNode(true);
|
$pok = $el->childNodes->item(0)->cloneNode(true);
|
||||||
|
$pok->setAttribute("onclick", "window.location = window.location + '" . $user->getId() . "/edit/'");
|
||||||
|
|
||||||
$parent->insertBefore($pok, $el);
|
$parent->insertBefore($pok, $el);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class Author {
|
|||||||
|
|
||||||
private $password;
|
private $password;
|
||||||
|
|
||||||
private $job;
|
private $job = "Aprenant";
|
||||||
|
|
||||||
private $role = "ROLE_USER";
|
private $role = "ROLE_USER";
|
||||||
|
|
||||||
@ -134,15 +134,16 @@ class Author {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function remove(Author $author) {
|
public static function remove(Author $author) {
|
||||||
Functions::connect()->prepare("DELETE FROM author WHERE id=:id")->execute(array(":id" => $author->getId()));
|
Functions::connect()->prepare("DELETE FROM users WHERE id=:id")->execute(array(":id" => $author->getId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update(Author $author) {
|
public static function update(Author $author) {
|
||||||
Functions::connect()->prepare("UPDATE author SET name=':name', password=':password', job=':job' WHERE id=:id")->execute(array(
|
Functions::connect()->prepare("UPDATE users SET username=:username, password=:password, job=:job, role=:role WHERE id=:id")->execute(array(
|
||||||
":username" => $author->getUsername(),
|
":username" => $author->getUsername(),
|
||||||
":password" => $author->getPassword(),
|
":password" => $author->getPassword(),
|
||||||
":job" => $author->getJob(),
|
":job" => $author->getJob(),
|
||||||
|
":role" => $author->getRole(),
|
||||||
":id" => $author->getId()
|
":id" => $author->getId()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,16 @@ class Post {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function remove(Post $post) {
|
public static function remove(Post $post) {
|
||||||
Functions::connect()->prepare("DELETE FROM posts WHERE id=:id")->execute(array(":id" => $post->getId()));
|
|
||||||
|
$id = $post->getId();
|
||||||
|
|
||||||
|
$prepared = Functions::connect()->prepare("DELETE FROM post_tag WHERE post_id=:id");
|
||||||
|
$prepared->bindValue(":id", $id, PDO::PARAM_INT);
|
||||||
|
$prepared->execute();
|
||||||
|
|
||||||
|
$prepared = Functions::connect()->prepare("DELETE FROM posts WHERE id=:id");
|
||||||
|
$prepared->bindValue(":id", $id, PDO::PARAM_INT);
|
||||||
|
$prepared->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user