mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-06-07 16:09:53 +00:00
Merge branch 'master' of gitlab.com:aviortheking/blog_imie
This commit is contained in:
commit
4065deb683
@ -26,7 +26,7 @@ RewriteCond %{REQUEST_FILENAME} !-f
|
|||||||
# (ex : blog.delta-wings.net/flag?p=5 va devenir de notre coté -> blog.delta-wings.net/assets/php/handler.php?page=flag&p=5)
|
# (ex : blog.delta-wings.net/flag?p=5 va devenir de notre coté -> blog.delta-wings.net/assets/php/handler.php?page=flag&p=5)
|
||||||
RewriteRule ^(.*)$ /assets/php/handler.php?page=$1 [L,QSA]
|
RewriteRule ^(.*)$ /assets/php/handler.php?page=$1 [L,QSA]
|
||||||
|
|
||||||
# indique unr redirection lorque on obtient une page d'erreur 403 (interdiction d'accès (permet de "cacher" les fichiers critiques))
|
# indique une redirection lorque on obtient une page d'erreur 403 (interdiction d'accès (permet de "cacher" les fichiers critiques))
|
||||||
# on redirige vars note handler pour qu'il afficher la page 404
|
# on redirige vars note handler pour qu'il afficher la page 404
|
||||||
ErrorDocument 403 /assets/php/handler.php?page=404
|
ErrorDocument 403 /assets/php/handler.php?page=404
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ function endsWith($haystack, $needle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
$host = "localhost";
|
$host = "127.0.0.1";
|
||||||
$db = "blog";
|
$db = "blog";
|
||||||
$user = "root";
|
$user = "blog";
|
||||||
$pass = "root";
|
$pass = "blog";
|
||||||
$charset="utf8mb4";
|
$charset="utf8mb4";
|
||||||
|
|
||||||
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
||||||
@ -25,7 +25,3 @@ function connect() {
|
|||||||
}
|
}
|
||||||
return $pdo;
|
return $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBDD() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "functions.php";
|
require_once "functions.php";
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
ini_set('display_errors', 'On');
|
ini_set('display_errors', 'On');
|
||||||
|
|
||||||
//renvoie vers le fichier css si il est demandé
|
//renvoie vers le fichier css si il est demandé
|
||||||
|
@ -28,7 +28,54 @@ $search = function () {
|
|||||||
$router->addRoute("/^\/search\/$/", $search); // route "/search/*"
|
$router->addRoute("/^\/search\/$/", $search); // route "/search/*"
|
||||||
|
|
||||||
$post = function() {
|
$post = function() {
|
||||||
var_dump("tst");
|
$_POST = array_merge($_POST, $_GET); //debug uniquement
|
||||||
|
var_dump($_POST);
|
||||||
|
/*
|
||||||
|
$_POST should contain
|
||||||
|
post :
|
||||||
|
id
|
||||||
|
title
|
||||||
|
content
|
||||||
|
category
|
||||||
|
author
|
||||||
|
|
||||||
|
UPDATE posts
|
||||||
|
SET
|
||||||
|
title = title,
|
||||||
|
url = strtolower(preg_replace(["/\ /", '/[\'\/~`\!@#\$%\^&\*\(\)\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/'], ["_", ""], title));
|
||||||
|
content = content,
|
||||||
|
short = substr(content, 0, 253) . "...";
|
||||||
|
category = categoryId
|
||||||
|
author = authorId
|
||||||
|
WHERE id = id
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once "functions.php";
|
||||||
|
|
||||||
|
|
||||||
|
$request = "UPDATE posts SET `title`=:title, `url`=:url, `content`=:content, `short`=:short, `category`=:category, `author`=:author, WHERE `id`=:id";
|
||||||
|
|
||||||
|
$title = $_POST["title"];
|
||||||
|
$url = strtolower(preg_replace(["/\ /", '/[\'\/~`\!@#\$%\^&\*\(\)\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/'], ["_", ""], $title));
|
||||||
|
$content = $_POST["content"];
|
||||||
|
$short = substr($content, 0, 253) . "...";
|
||||||
|
$category = intval($_POST["category"]);
|
||||||
|
$author = intval($_POST["author"]);
|
||||||
|
|
||||||
|
$id = intval($_POST["id"]);
|
||||||
|
|
||||||
|
|
||||||
|
$pdo = connect();
|
||||||
|
$prepared = $pdo->prepare($request);
|
||||||
|
$prepared->bindParam(":title", $title);
|
||||||
|
$prepared->bindParam(":url", $url);
|
||||||
|
$prepared->bindParam(":content", $content);
|
||||||
|
$prepared->bindParam(":short", $short);
|
||||||
|
$prepared->bindParam(":category", $category, PDO::PARAM_INT);
|
||||||
|
$prepared->bindParam(":author", $author, PDO::PARAM_INT);
|
||||||
|
$prepared->bindParam(":id", $id, PDO::PARAM_INT);
|
||||||
|
|
||||||
|
$prepared->execute();
|
||||||
};
|
};
|
||||||
|
|
||||||
$router->addRoute("/^\/post\/" . $postCharacters . "+\/edit\/*$/", $post);
|
$router->addRoute("/^\/post\/" . $postCharacters . "+\/edit\/*$/", $post);
|
||||||
|
@ -266,17 +266,19 @@ function loadTags($ctnt) {
|
|||||||
|
|
||||||
|
|
||||||
$head = $dom->getElementsByTagName("head");
|
$head = $dom->getElementsByTagName("head");
|
||||||
|
if($head->count() >= 1) {
|
||||||
$t = $dom->createDocumentFragment();
|
$t = $dom->createDocumentFragment();
|
||||||
$p = file_get_contents("../html/includes/head.html");
|
$p = file_get_contents("../html/includes/head.html");
|
||||||
$t->appendXML($p);
|
$t->appendXML($p);
|
||||||
$head->item(0)->appendChild($t);
|
$head->item(0)->appendChild($t);
|
||||||
|
}
|
||||||
|
|
||||||
$test = array();
|
$test = array();
|
||||||
|
|
||||||
$list = $dom->getElementsByTagName("tag");
|
$list = $dom->getElementsByTagName("tag");
|
||||||
|
|
||||||
//charge et supprimme les tags
|
//charge et supprimme les tags
|
||||||
while($lst = $list->item(0)) {
|
while($lst = $list->item(0)) {
|
||||||
|
|
||||||
$tgs = ucfirst($lst->getAttribute("type"));
|
$tgs = ucfirst($lst->getAttribute("type"));
|
||||||
array_push($test, $tgs);
|
array_push($test, $tgs);
|
||||||
@ -300,7 +302,7 @@ while($lst = $list->item(0)) {
|
|||||||
// echo (htmlspecialchars($dom->saveHTML()));
|
// echo (htmlspecialchars($dom->saveHTML()));
|
||||||
|
|
||||||
$list = $dom->getElementsByTagName("tag");
|
$list = $dom->getElementsByTagName("tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = $dom->saveHTML();
|
$res = $dom->saveHTML();
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
|
|
||||||
require_once "assets/php/functions.php";
|
|
||||||
|
|
||||||
$host = "localhost";
|
|
||||||
$db = "blog";
|
|
||||||
$user = "blog";
|
|
||||||
$pass = "blog";
|
|
||||||
$charset="utf8mb4";
|
|
||||||
|
|
||||||
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
|
||||||
$pdo = new PDO($dsn, $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
|
||||||
echo "pokemon";
|
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user