diff --git a/project/.htaccess b/project/.htaccess
index 9ff28c4..40121fe 100755
--- a/project/.htaccess
+++ b/project/.htaccess
@@ -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)
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
ErrorDocument 403 /assets/php/handler.php?page=404
@@ -70,25 +70,25 @@ Options All -Indexes
# si le serveur apache a le module mod_deflate.c
# on va indiquer que le serveur prend en charge a compression GZIP (compression pour les photos (gif, jpeg, png))
- SetOutputFilter DEFLATE
- SetEnvIfNoCase Request_URI \
- \.(?:gif|jpe?g|png)$ no-gzip dont-vary
+ SetOutputFilter DEFLATE
+ SetEnvIfNoCase Request_URI \
+ \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# si le module mod_expires.c existe
# on donne un temps de mise en cache navigateur au fichiers si dessous
- ExpiresActive on
- ExpiresByType image/jpg "access 2 month"
- ExpiresByType image/gif "access 2 month"
- ExpiresByType image/jpeg "access 2 month"
- ExpiresByType image/png "access 2 month"
- ExpiresByType text/css "access 2 month"
- ExpiresByType application/x-javascript "access plus 2 month"
- ExpiresByType text/javascript "access plus 2 month"
- ExpiresByType application/javascript "access plus 2 month"
- ExpiresByType image/x-icon "access plus 12 month"
- ExpiresByType image/icon "access plus 12 month"
- ExpiresByType application/x-ico "access plus 12 month"
- ExpiresByType application/ico "access plus 12 month"
+ ExpiresActive on
+ ExpiresByType image/jpg "access 2 month"
+ ExpiresByType image/gif "access 2 month"
+ ExpiresByType image/jpeg "access 2 month"
+ ExpiresByType image/png "access 2 month"
+ ExpiresByType text/css "access 2 month"
+ ExpiresByType application/x-javascript "access plus 2 month"
+ ExpiresByType text/javascript "access plus 2 month"
+ ExpiresByType application/javascript "access plus 2 month"
+ ExpiresByType image/x-icon "access plus 12 month"
+ ExpiresByType image/icon "access plus 12 month"
+ ExpiresByType application/x-ico "access plus 12 month"
+ ExpiresByType application/ico "access plus 12 month"
diff --git a/project/assets/php/functions.php b/project/assets/php/functions.php
index 010e838..64b494f 100755
--- a/project/assets/php/functions.php
+++ b/project/assets/php/functions.php
@@ -11,10 +11,10 @@ function endsWith($haystack, $needle) {
}
function connect() {
- $host = "localhost";
+ $host = "127.0.0.1";
$db = "blog";
- $user = "root";
- $pass = "root";
+ $user = "blog";
+ $pass = "blog";
$charset="utf8mb4";
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
@@ -25,7 +25,3 @@ function connect() {
}
return $pdo;
}
-
-function getBDD() {
-
-}
diff --git a/project/assets/php/handler.php b/project/assets/php/handler.php
index 19f4c1c..8c74307 100755
--- a/project/assets/php/handler.php
+++ b/project/assets/php/handler.php
@@ -1,5 +1,7 @@
addRoute("/^\/search\/$/", $search); // route "/search/*"
$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);
diff --git a/project/assets/php/tagHandler.php b/project/assets/php/tagHandler.php
index b5a0ad0..adcd024 100755
--- a/project/assets/php/tagHandler.php
+++ b/project/assets/php/tagHandler.php
@@ -266,41 +266,43 @@ function loadTags($ctnt) {
$head = $dom->getElementsByTagName("head");
- $t = $dom->createDocumentFragment();
- $p = file_get_contents("../html/includes/head.html");
- $t->appendXML($p);
- $head->item(0)->appendChild($t);
+ if($head->count() >= 1) {
+ $t = $dom->createDocumentFragment();
+ $p = file_get_contents("../html/includes/head.html");
+ $t->appendXML($p);
+ $head->item(0)->appendChild($t);
+ }
$test = array();
-$list = $dom->getElementsByTagName("tag");
-
-//charge et supprimme les tags
-while($lst = $list->item(0)) {
-
- $tgs = ucfirst($lst->getAttribute("type"));
- array_push($test, $tgs);
- $tg = new $tgs($dom, $lst, false);
-
- $tg->render();
- // var_dump("--------- 1 ---------");
- // for ($i=0; $i < $list->count(); $i++) {
- // var_dump($list->item($i)->getAttribute("type"));
- // }
- // echo (htmlspecialchars($dom->saveHTML()));
-
- // var_dump($list[0]->parentNode->nodeName);
-
- $lst->parentNode->removeChild($lst);
-
- // var_dump("--------- 2 ---------");
- // for ($i=0; $i < $list->count(); $i++) {
- // var_dump($list->item($i)->getAttribute("type"));
- // }
- // echo (htmlspecialchars($dom->saveHTML()));
-
$list = $dom->getElementsByTagName("tag");
-}
+
+ //charge et supprimme les tags
+ while($lst = $list->item(0)) {
+
+ $tgs = ucfirst($lst->getAttribute("type"));
+ array_push($test, $tgs);
+ $tg = new $tgs($dom, $lst, false);
+
+ $tg->render();
+ // var_dump("--------- 1 ---------");
+ // for ($i=0; $i < $list->count(); $i++) {
+ // var_dump($list->item($i)->getAttribute("type"));
+ // }
+ // echo (htmlspecialchars($dom->saveHTML()));
+
+ // var_dump($list[0]->parentNode->nodeName);
+
+ $lst->parentNode->removeChild($lst);
+
+ // var_dump("--------- 2 ---------");
+ // for ($i=0; $i < $list->count(); $i++) {
+ // var_dump($list->item($i)->getAttribute("type"));
+ // }
+ // echo (htmlspecialchars($dom->saveHTML()));
+
+ $list = $dom->getElementsByTagName("tag");
+ }
$res = $dom->saveHTML();
diff --git a/project/index.php b/project/index.php
deleted file mode 100644
index 0fe42d0..0000000
--- a/project/index.php
+++ /dev/null
@@ -1,16 +0,0 @@
- PDO::ERRMODE_EXCEPTION));
-echo "pokemon";
-?>
\ No newline at end of file