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
|
||||
.DS_Store
|
||||
**/.idea
|
||||
yarn.lock
|
||||
|
@ -9,6 +9,6 @@
|
||||
<script src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
pouet
|
||||
ACTIVE APACHE CONNARD
|
||||
</body>
|
||||
</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))
|
||||
<FilesMatch ".*\.(php|html)$">
|
||||
Order Allow,Deny
|
||||
Deny from all
|
||||
# Order Allow,Deny
|
||||
# Deny from all
|
||||
|
||||
# Require all denied
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
|
||||
# on donne l'autorisation d'acceder au fichier handler.php (sinon le site ne sera pas foncitonnel)
|
||||
<FilesMatch "handler.php">
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
# Order Allow,Deny
|
||||
# Allow from all
|
||||
|
||||
# Require all granted
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
|
||||
# on donne acces au fichiers webmanifest et svg
|
||||
<FilesMatch ".*\.(webmanifest|svg)$">
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
# Order Allow,Deny
|
||||
# Allow from all
|
||||
|
||||
# Require all granted
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
|
||||
# si le serveur apache a le module mod_deflate.c
|
||||
|
@ -4,4 +4,11 @@
|
||||
<body>
|
||||
<p>404</p>
|
||||
</body>
|
||||
<header>
|
||||
<tag type="includes" file="header" />
|
||||
</header>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
</footer>
|
||||
|
||||
</html>
|
@ -4,3 +4,4 @@
|
||||
<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" 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="cover-black">
|
||||
<div class="bloc_principal_titre">
|
||||
<h1>L'actualité de nos campus...</h1>
|
||||
<h1>L'actualité de nos campus...</h1>
|
||||
</div>
|
||||
<div class="test2">
|
||||
<h2 id="titre-home">Ceci est un magnifique titre</h2>
|
||||
@ -56,10 +56,8 @@
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
<!-- <tag type="includes" file="footer" /> -->
|
||||
</footer>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
|
||||
crossorigin="anonymous"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1 +1,11 @@
|
||||
// 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() {
|
||||
$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é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"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,6 +194,10 @@ class Loop extends Tag {
|
||||
|
||||
$parent = $el->parentNode;
|
||||
//var_dump($parent);
|
||||
|
||||
|
||||
$limit = $limit > sizeof($posts) ? sizeof($posts) : $limit;
|
||||
|
||||
for ($i=0; $i < $limit; $i++) {
|
||||
//var_dump($i);
|
||||
$pok = $el->childNodes->item(0)->cloneNode(true);
|
||||
@ -220,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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,7 +263,7 @@ function loadTags($ctnt) {
|
||||
$dom->removeChild($item);
|
||||
$dom->encoding = 'UTF-8';
|
||||
|
||||
$list = $dom->getElementsByTagName("tag");
|
||||
|
||||
|
||||
$head = $dom->getElementsByTagName("head");
|
||||
$t = $dom->createDocumentFragment();
|
||||
@ -270,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>
|
||||
';
|
||||
|
Loading…
x
Reference in New Issue
Block a user