mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-06-22 22:39:19 +00:00
modifs!!!!
This commit is contained in:
@ -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() {
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
include_once "router.php";
|
||||
|
||||
//recupération du router
|
||||
//recup<EFBFBD>ration du router
|
||||
$router = Router::getRouter();
|
||||
|
||||
$postCharacters = "[a-z0-9-]";
|
||||
|
||||
//page d'accueil
|
||||
$home = function () {
|
||||
return file_get_contents("../html/index.html");
|
||||
@ -16,7 +18,7 @@ $post = function () {
|
||||
return file_get_contents("../html/post.html");
|
||||
};
|
||||
|
||||
$router->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);
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1,11 +1,38 @@
|
||||
<?php
|
||||
include_once "functions.php";
|
||||
$pdo = connect();
|
||||
$query = $pdo->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());
|
||||
|
||||
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 '<input id="file" type="file" multiple/><button>Send !</button>';
|
||||
|
||||
echo '
|
||||
<script defer>
|
||||
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);
|
||||
</script>
|
||||
';
|
||||
|
Reference in New Issue
Block a user