2020-08-02 14:15:06 +02:00
|
|
|
<?php
|
|
|
|
require "mdp.php";
|
|
|
|
if (isset($_GET['pw']) AND $_GET['pw'] == $mdp) {
|
|
|
|
|
|
|
|
require "bibli/parsedown/Parsedown.php";
|
|
|
|
require "bibli/parsedown/ParsedownExtra.php";
|
|
|
|
$nomsPages = array_diff(scandir("pages"), array('..', '.'));
|
|
|
|
foreach ($nomsPages as $nomPage) {
|
|
|
|
$nomPage = basename($nomPage, ".md");
|
|
|
|
|
|
|
|
// pages/exemple.md > temp/exemple.temp
|
|
|
|
// Exécute le HTML/PHP avec header et footer vers du HTML statique
|
|
|
|
ob_start();
|
|
|
|
require "pages/" . $nomPage . ".md";
|
|
|
|
file_put_contents("temp/" . $nomPage . ".temp", ob_get_contents());
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
// temp/exemple.temp > temp2/exemple.temp2
|
|
|
|
// Compile le Markdown/PHP vers du HTML/PHP
|
|
|
|
$contenuPage = ParsedownExtra::instance()
|
|
|
|
->setUrlsLinked(false)
|
|
|
|
->setMarkupEscaped(false)
|
|
|
|
->setBreaksEnabled(true)
|
|
|
|
->text(file_get_contents("temp/" .$nomPage . ".temp"));
|
|
|
|
file_put_contents("temp2/" . $nomPage . ".temp2", $contenuPage);
|
|
|
|
|
|
|
|
// temp2/exemple.temp2 > exemple.html
|
|
|
|
// Exécute et cache le PHP en HTML
|
|
|
|
$adresse = $nomPage;
|
|
|
|
ob_start();
|
|
|
|
require "inc/pages.php";
|
|
|
|
require "inc/debut.php";
|
|
|
|
if ($page['type'] == "article") {
|
|
|
|
echo "<h1>" . $page['h1'] . "</h1>";
|
|
|
|
echo "<article>";
|
|
|
|
} else if ($page['type'] == "centré") {
|
|
|
|
echo "<div class='centre'>";
|
|
|
|
}
|
|
|
|
require "temp2/" . $nomPage . ".temp2";
|
|
|
|
if ($page['type'] == "article") {
|
|
|
|
echo "</article>";
|
|
|
|
} else if ($page['type'] == "centré") {
|
|
|
|
echo "</div>";
|
|
|
|
}
|
|
|
|
require "inc/footer.php";
|
|
|
|
file_put_contents($nomPage . ".html", ob_get_contents());
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// exemple.html > exemple.html.gz
|
|
|
|
// Compresse les fichiers textes statiques HTML & CSS à la racine
|
2021-01-31 23:40:00 +01:00
|
|
|
exec('/usr/bin/static-compress -c zopfli "*.html" "*.css" "css/*.css"');
|
2020-08-02 14:15:06 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
echo "Non authentifié·e";
|
|
|
|
}
|