From c4177f1f104671980e3d29f1bb29162ad58e9174 Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 18 Feb 2019 15:05:33 +0100 Subject: [PATCH] modifs!!!! --- .gitignore | 3 +- index.html | 4 +- project/.htaccess | 20 ++++----- project/assets/html/404.html | 9 +++- project/assets/html/includes/footer.html | 52 ++++++++++++------------ project/assets/html/includes/head.html | 3 +- project/assets/html/includes/header.html | 2 +- project/assets/html/index.html | 8 ++-- project/assets/js/script.js | 12 +++++- project/assets/php/functions.php | 8 +--- project/assets/php/pages.php | 12 +++++- project/assets/php/router.php | 12 +++++- project/assets/php/tagHandler.php | 52 ++++++++++++++++-------- project/assets/php/test.php | 45 ++++++++++++++++---- 14 files changed, 158 insertions(+), 84 deletions(-) diff --git a/.gitignore b/.gitignore index 922e271..9bb4808 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ package-lock.json build/ ops/terraform/secrets.tf .DS_Store -**/.idea \ No newline at end of file +**/.idea +yarn.lock diff --git a/index.html b/index.html index fe17661..597ad2f 100755 --- a/index.html +++ b/index.html @@ -9,6 +9,6 @@ - pouet + ACTIVE APACHE CONNARD - \ No newline at end of file + diff --git a/project/.htaccess b/project/.htaccess index 4b137e4..315c119 100755 --- a/project/.htaccess +++ b/project/.htaccess @@ -36,26 +36,26 @@ Options All -Indexes # lorsque qu'une url va correspondre a un fichier finissant par .php ou .html on interdit l'acces (retourne une erreur 403 (ensuite geré par notre ligne plus haut)) - Order Allow,Deny - Deny from all + # Order Allow,Deny + # Deny from all - # Require all denied + Require all denied # on donne l'autorisation d'acceder au fichier handler.php (sinon le site ne sera pas foncitonnel) - Order Allow,Deny - Allow from all + # Order Allow,Deny + # Allow from all - # Require all granted + Require all granted # on donne acces au fichiers webmanifest et svg - Order Allow,Deny - Allow from all + # Order Allow,Deny + # Allow from all - # Require all granted + Require all granted # si le serveur apache a le module mod_deflate.c @@ -82,4 +82,4 @@ Options All -Indexes ExpiresByType image/icon "access plus 12 month" ExpiresByType application/x-ico "access plus 12 month" ExpiresByType application/ico "access plus 12 month" - \ No newline at end of file + diff --git a/project/assets/html/404.html b/project/assets/html/404.html index 45c6692..c8ab412 100755 --- a/project/assets/html/404.html +++ b/project/assets/html/404.html @@ -4,4 +4,11 @@

404

- \ No newline at end of file +
+ +
+ + + diff --git a/project/assets/html/includes/footer.html b/project/assets/html/includes/footer.html index 2e9414e..ebbb39b 100755 --- a/project/assets/html/includes/footer.html +++ b/project/assets/html/includes/footer.html @@ -1,25 +1,27 @@ - +
+
+
+
+
+
    +
  • + +
  • +
  • + +
  • +
+

Suivez-nous sur les réseaux

+
+
+
    +
  • Politique et confidentialité
  • +
  • Mentions légales
  • +
  • Contact
  • +
  • Connexion
  • +
+
+
+
+
+
diff --git a/project/assets/html/includes/head.html b/project/assets/html/includes/head.html index 5d05c22..31e5d95 100755 --- a/project/assets/html/includes/head.html +++ b/project/assets/html/includes/head.html @@ -3,4 +3,5 @@ Page Title - \ No newline at end of file + + diff --git a/project/assets/html/includes/header.html b/project/assets/html/includes/header.html index ad32286..27c516d 100755 --- a/project/assets/html/includes/header.html +++ b/project/assets/html/includes/header.html @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/project/assets/html/index.html b/project/assets/html/index.html index 669fed3..642da4d 100755 --- a/project/assets/html/index.html +++ b/project/assets/html/index.html @@ -12,7 +12,7 @@
-

L'actualité de nos campus...

+

L'actualité de nos campus...

Ceci est un magnifique titre

@@ -56,10 +56,8 @@
- +
- - \ No newline at end of file + diff --git a/project/assets/js/script.js b/project/assets/js/script.js index 9adcf04..d5ec9af 100755 --- a/project/assets/js/script.js +++ b/project/assets/js/script.js @@ -1 +1,11 @@ -// Fichier des scripts (logiquement que pour les requets AJAX et pour certaines animations) (plusieurs fichiers sont possible bien sur) \ No newline at end of file +// Fichier des scripts (logiquement que pour les requets AJAX et pour certaines animations) (plusieurs fichiers sont possible bien sur) + +var processForm = () => { + var request = new XMLHttpRequest(); + var form = new FormData(); + form.append("photo", document.querySelector("#file").files[0]); + request.open("POST", "/test/", true); + request.send(form); +} + +document.querySelector("button").addEventListener("click", processForm); \ No newline at end of file diff --git a/project/assets/php/functions.php b/project/assets/php/functions.php index 3a0c409..64b494f 100755 --- a/project/assets/php/functions.php +++ b/project/assets/php/functions.php @@ -13,8 +13,8 @@ function endsWith($haystack, $needle) { function connect() { $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/pages.php b/project/assets/php/pages.php index 6e6d0f5..11d7d0d 100755 --- a/project/assets/php/pages.php +++ b/project/assets/php/pages.php @@ -1,9 +1,11 @@ addRoute("/^\/post\/$/", $post); // route "/post/*" +$router->addRoute("/^\/post\/" + $postCharacters + "+\/*$/", $post); // route "/post/*" //page de recherche $search = function () { @@ -24,3 +26,9 @@ $search = function () { }; $router->addRoute("/^\/search\/$/", $search); // route "/search/*" + +$post = function() { + var_dump("tst"); +}; + +$router->addRoute("/^\/post\/" + $postCharacters + "+\/edit\/*$/", $post); diff --git a/project/assets/php/router.php b/project/assets/php/router.php index cc916a6..2de66d2 100755 --- a/project/assets/php/router.php +++ b/project/assets/php/router.php @@ -8,12 +8,14 @@ */ class Router { //variable static pour stocker le router - private static $router; + private static $router = null; //definit le router public function __construct() { //TODO faire que si un router existe déjà retourner le routeur existant - Router::$router = $this; + if(Router::$router != null) { + return Router::$router; + } else Router::$router = $this; } //fonction static pour recuperer un router déjà crée @@ -42,4 +44,10 @@ class Router { return file_get_contents("../html/404.html"); }; } + + public function redirecter($source, $redirectPage) { + $this->addRoute($source, function() { + header("Location: " . $redirectPage); + }); + } } diff --git a/project/assets/php/tagHandler.php b/project/assets/php/tagHandler.php index f8f8b6b..9c78727 100755 --- a/project/assets/php/tagHandler.php +++ b/project/assets/php/tagHandler.php @@ -144,16 +144,12 @@ class Author extends Tag { class Includes extends Tag { public function render() { $el = $this->getDOM(); - $doc = $this->getDoc(); $attr = $el->getAttribute("file"); - $t = $doc->createDocumentFragment(); - // var_dump($attr); - // var_dump(file_get_contents("../html/includes/".$attr.".html")); + $p = file_get_contents("../html/includes/".$attr.".html"); // var_dump($p); appendHTML($el->parentNode, $p); - $el->setAttribute("style", $el->getAttribute("style")); } } @@ -224,12 +220,13 @@ class Loop extends Tag { // var_dump($nodes); if(sizeof($nodes) >= 1) $nodes[0]->setAttribute("class", str_replace("column-categorie", $posts[$i]["categorie"], $nodes[0]->getAttribute("class"))); - } + $loop = $pok->getElementsByTagName("loop"); + + while ($loop->count() >= 1) { + $loop->item(0)->parentNode->removeChild($loop->item(0)); + } - $loop = $parent->getElementsByTagName("loop"); - while ($loop->length >= 1 && !$this->isDebugging()) { - $loop[0]->parentNode->removeChild($loop[0]); } } } @@ -266,7 +263,7 @@ function loadTags($ctnt) { $dom->removeChild($item); $dom->encoding = 'UTF-8'; - $list = $dom->getElementsByTagName("tag"); + $head = $dom->getElementsByTagName("head"); $t = $dom->createDocumentFragment(); @@ -274,18 +271,37 @@ function loadTags($ctnt) { $t->appendXML($p); $head->item(0)->appendChild($t); - //charge et supprimme les tags - while($list->length >= 1) { - $lst = $list->item(0); - $tgs = ucfirst($lst->getAttribute("type")); - $tg = new $tgs($dom, $lst, false); + $test = array(); - $tg->render(); +$list = $dom->getElementsByTagName("tag"); - $list[0]->parentNode->removeChild($list[0]); +//charge et supprimme les tags +while($lst = $list->item(0)) { - $list = $dom->getElementsByTagName("tag"); + $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(); return $res; diff --git a/project/assets/php/test.php b/project/assets/php/test.php index aa524a6..0620020 100755 --- a/project/assets/php/test.php +++ b/project/assets/php/test.php @@ -1,11 +1,38 @@ query("SELECT title, categorie, dt as date, short as content -FROM posts -ORDER BY date DESC -LIMIT 6"); -while($row = $query->fetch()) { - echo $row["title"]; +if(isset($_GET["image"]) && !empty($_GET["image"])) $_POST["image"] = $_GET["image"]; + +$id = 1; //post id + +$uploadFolder = "../../uploads/posts/$id/"; + +if(!file_exists($uploadFolder)) { + mkdir($uploadFolder, 0660, true); } -// var_dump(connect()); \ No newline at end of file + +if(isset($_FILES["photo"]) && !empty($_FILES["photo"])) { + var_dump($_FILES["photo"]); + move_uploaded_file($_FILES["photo"]["tmp_name"], $uploadFolder.$_FILES["photo"]["name"]); + // require_once "functions.php"; + // file_put_contents($uploadFolder."/pouet.jpg", base64_decode($_POST["image"])); + // base64_to_jpeg($_POST["image"], $uploadFolder."/pouet.jpg"); + // file_put_content($uploadFolder."/pouet.jpg", base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $_POST["image"]))); +} + + + + +echo ''; + +echo ' + +';