mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-23 19:32:15 +00:00
oui
This commit is contained in:
commit
036a05eca4
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ build/
|
|||||||
ops/terraform/secrets.tf
|
ops/terraform/secrets.tf
|
||||||
.DS_Store
|
.DS_Store
|
||||||
**/.idea
|
**/.idea
|
||||||
|
yarn.lock
|
||||||
|
@ -9,6 +9,6 @@
|
|||||||
<script src="main.js"></script>
|
<script src="main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
pouet
|
ACTIVE APACHE CONNARD
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -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))
|
# 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))
|
||||||
<FilesMatch ".*\.(php|html)$">
|
<FilesMatch ".*\.(php|html)$">
|
||||||
Order Allow,Deny
|
# Order Allow,Deny
|
||||||
Deny from all
|
# Deny from all
|
||||||
|
|
||||||
# Require all denied
|
Require all denied
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
# on donne l'autorisation d'acceder au fichier handler.php (sinon le site ne sera pas foncitonnel)
|
# on donne l'autorisation d'acceder au fichier handler.php (sinon le site ne sera pas foncitonnel)
|
||||||
<FilesMatch "handler.php">
|
<FilesMatch "handler.php">
|
||||||
Order Allow,Deny
|
# Order Allow,Deny
|
||||||
Allow from all
|
# Allow from all
|
||||||
|
|
||||||
# Require all granted
|
Require all granted
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
# on donne acces au fichiers webmanifest et svg
|
# on donne acces au fichiers webmanifest et svg
|
||||||
<FilesMatch ".*\.(webmanifest|svg)$">
|
<FilesMatch ".*\.(webmanifest|svg)$">
|
||||||
Order Allow,Deny
|
# Order Allow,Deny
|
||||||
Allow from all
|
# Allow from all
|
||||||
|
|
||||||
# Require all granted
|
Require all granted
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
# si le serveur apache a le module mod_deflate.c
|
# si le serveur apache a le module mod_deflate.c
|
||||||
|
@ -4,4 +4,11 @@
|
|||||||
<body>
|
<body>
|
||||||
<p>404</p>
|
<p>404</p>
|
||||||
</body>
|
</body>
|
||||||
|
<header>
|
||||||
|
<tag type="includes" file="header" />
|
||||||
|
</header>
|
||||||
|
<footer>
|
||||||
|
<tag type="includes" file="footer" />
|
||||||
|
</footer>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -4,3 +4,4 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" />
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" />
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css"/>
|
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css"/>
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<div class="bloc_principal">
|
<div class="bloc_principal">
|
||||||
<div class="cover-black">
|
<div class="cover-black">
|
||||||
<div class="bloc_principal_titre">
|
<div class="bloc_principal_titre">
|
||||||
<h1>L'actualité de nos campus...</h1>
|
<h1>L'actualité de nos campus...</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="test2">
|
<div class="test2">
|
||||||
<h2 id="titre-home">Ceci est un magnifique titre</h2>
|
<h2 id="titre-home">Ceci est un magnifique titre</h2>
|
||||||
@ -56,10 +56,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<tag type="includes" file="footer" />
|
<!-- <tag type="includes" file="footer" /> -->
|
||||||
</footer>
|
</footer>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1 +1,11 @@
|
|||||||
// Fichier des scripts (logiquement que pour les requets AJAX et pour certaines animations) (plusieurs fichiers sont possible bien sur)
|
// 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);
|
@ -13,8 +13,8 @@ function endsWith($haystack, $needle) {
|
|||||||
function connect() {
|
function connect() {
|
||||||
$host = "127.0.0.1";
|
$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,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "router.php";
|
include_once "router.php";
|
||||||
|
|
||||||
//recupération du router
|
//recupération du router
|
||||||
$router = Router::getRouter();
|
$router = Router::getRouter();
|
||||||
|
|
||||||
|
$postCharacters = "[a-z0-9-]";
|
||||||
|
|
||||||
//page d'accueil
|
//page d'accueil
|
||||||
$home = function () {
|
$home = function () {
|
||||||
return file_get_contents("../html/index.html");
|
return file_get_contents("../html/index.html");
|
||||||
@ -16,7 +18,7 @@ $post = function () {
|
|||||||
return file_get_contents("../html/post.html");
|
return file_get_contents("../html/post.html");
|
||||||
};
|
};
|
||||||
|
|
||||||
$router->addRoute("/^\/post\/$/", $post); // route "/post/*"
|
$router->addRoute("/^\/post\/" + $postCharacters + "+\/*$/", $post); // route "/post/*"
|
||||||
|
|
||||||
//page de recherche
|
//page de recherche
|
||||||
$search = function () {
|
$search = function () {
|
||||||
@ -24,3 +26,9 @@ $search = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$router->addRoute("/^\/search\/$/", $search); // route "/search/*"
|
$router->addRoute("/^\/search\/$/", $search); // route "/search/*"
|
||||||
|
|
||||||
|
$post = function() {
|
||||||
|
var_dump("tst");
|
||||||
|
};
|
||||||
|
|
||||||
|
$router->addRoute("/^\/post\/" + $postCharacters + "+\/edit\/*$/", $post);
|
||||||
|
@ -8,12 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
class Router {
|
class Router {
|
||||||
//variable static pour stocker le router
|
//variable static pour stocker le router
|
||||||
private static $router;
|
private static $router = null;
|
||||||
|
|
||||||
//definit le router
|
//definit le router
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
//TODO faire que si un router existe déjà retourner le routeur existant
|
//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
|
//fonction static pour recuperer un router déjà crée
|
||||||
@ -42,4 +44,10 @@ class Router {
|
|||||||
return file_get_contents("../html/404.html");
|
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 {
|
class Includes extends Tag {
|
||||||
public function render() {
|
public function render() {
|
||||||
$el = $this->getDOM();
|
$el = $this->getDOM();
|
||||||
$doc = $this->getDoc();
|
|
||||||
$attr = $el->getAttribute("file");
|
$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");
|
$p = file_get_contents("../html/includes/".$attr.".html");
|
||||||
|
|
||||||
// var_dump($p);
|
// var_dump($p);
|
||||||
appendHTML($el->parentNode, $p);
|
appendHTML($el->parentNode, $p);
|
||||||
$el->setAttribute("style", $el->getAttribute("style"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +194,10 @@ class Loop extends Tag {
|
|||||||
|
|
||||||
$parent = $el->parentNode;
|
$parent = $el->parentNode;
|
||||||
//var_dump($parent);
|
//var_dump($parent);
|
||||||
|
|
||||||
|
|
||||||
|
$limit = $limit > sizeof($posts) ? sizeof($posts) : $limit;
|
||||||
|
|
||||||
for ($i=0; $i < $limit; $i++) {
|
for ($i=0; $i < $limit; $i++) {
|
||||||
//var_dump($i);
|
//var_dump($i);
|
||||||
$pok = $el->childNodes->item(0)->cloneNode(true);
|
$pok = $el->childNodes->item(0)->cloneNode(true);
|
||||||
@ -220,12 +220,13 @@ class Loop extends Tag {
|
|||||||
// var_dump($nodes);
|
// var_dump($nodes);
|
||||||
if(sizeof($nodes) >= 1) $nodes[0]->setAttribute("class", str_replace("column-categorie", $posts[$i]["categorie"], $nodes[0]->getAttribute("class")));
|
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]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ function loadTags($ctnt) {
|
|||||||
$dom->removeChild($item);
|
$dom->removeChild($item);
|
||||||
$dom->encoding = 'UTF-8';
|
$dom->encoding = 'UTF-8';
|
||||||
|
|
||||||
$list = $dom->getElementsByTagName("tag");
|
|
||||||
|
|
||||||
$head = $dom->getElementsByTagName("head");
|
$head = $dom->getElementsByTagName("head");
|
||||||
$t = $dom->createDocumentFragment();
|
$t = $dom->createDocumentFragment();
|
||||||
@ -270,18 +271,37 @@ function loadTags($ctnt) {
|
|||||||
$t->appendXML($p);
|
$t->appendXML($p);
|
||||||
$head->item(0)->appendChild($t);
|
$head->item(0)->appendChild($t);
|
||||||
|
|
||||||
//charge et supprimme les tags
|
$test = array();
|
||||||
while($list->length >= 1) {
|
|
||||||
$lst = $list->item(0);
|
|
||||||
$tgs = ucfirst($lst->getAttribute("type"));
|
|
||||||
$tg = new $tgs($dom, $lst, false);
|
|
||||||
|
|
||||||
$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();
|
$res = $dom->saveHTML();
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -1,11 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "functions.php";
|
if(isset($_GET["image"]) && !empty($_GET["image"])) $_POST["image"] = $_GET["image"];
|
||||||
$pdo = connect();
|
|
||||||
$query = $pdo->query("SELECT title, categorie, dt as date, short as content
|
$id = 1; //post id
|
||||||
FROM posts
|
|
||||||
ORDER BY date DESC
|
$uploadFolder = "../../uploads/posts/$id/";
|
||||||
LIMIT 6");
|
|
||||||
while($row = $query->fetch()) {
|
if(!file_exists($uploadFolder)) {
|
||||||
echo $row["title"];
|
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>
|
||||||
|
';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user