
- /html/upload-file.php - /html/editpage.php - /html/admin.php - /html/journal-interne.php - /html/login.php - /html/compte.php - /html/upload.php - /config/global.ini - /include/variables.php - /include/functions.php
100 lines
3.2 KiB
PHP
100 lines
3.2 KiB
PHP
<?php
|
|
require "../include/variables.php";
|
|
require "../include/functions.php";
|
|
|
|
$repertoire = "/var/www/e59/";
|
|
|
|
if(isset($_SESSION['role']) == false || $_SESSION['role'] < 3) {
|
|
header("Location: login.php");
|
|
http_response_code(404);
|
|
die();
|
|
}
|
|
|
|
if(isset($_POST['page-content'])) {
|
|
$filename = rand(100000, 999999);
|
|
while(file_exists($repertoire . "content/journal/" . $filename . ".md")) {
|
|
$filename = rand(100000, 999999);
|
|
}
|
|
file_put_contents($repertoire . "content/journal/" . $filename . ".md", nl2br($_POST['page-content']));
|
|
|
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
|
$upload = $bdd->prepare("INSERT INTO articles (ID, titre, date, auteur, classification) VALUES (:filename, :titre, :date, :auteur, :classification)");
|
|
$upload->bindParam(':filename', $filename);
|
|
$upload->bindParam(':titre', htmlspecialchars($_POST['titre']));
|
|
$upload->bindParam(':auteur', $_SESSION['display_name']);
|
|
$upload->bindParam(':classification', $_POST['classification']);
|
|
if($upload->execute()) {
|
|
$status = "Article Publié";
|
|
} else {
|
|
$status = "Erreur SQL";
|
|
}
|
|
header("Location: editpage.php?article=" . $filename);
|
|
exit();
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="./src/css/style.css">
|
|
<link rel="icon" href="src/img/favicon.ico">
|
|
<title><?=$title?></title>
|
|
<style>
|
|
textarea {
|
|
width: 100%;
|
|
min-height: 50em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="pancontent">
|
|
<div class="athena-container">
|
|
<a href="/">
|
|
<img src="./src/img/athena-mono.png" class="athena">
|
|
</a>
|
|
</div>
|
|
<div class="content">
|
|
<div>
|
|
<div class="main-title">
|
|
<div class="title"><?=$header_title?></div>
|
|
<div class="subtitle"><?=$header_subtitle?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<nav>
|
|
<div class="pancontent">
|
|
<?php nav($nav);?>
|
|
</div>
|
|
</nav>
|
|
<main>
|
|
<div class="content">
|
|
<div>
|
|
<form action="?article=<?=$filename?>" method="post">
|
|
<div>
|
|
<div><div><h1>Publier un article</h1></div>
|
|
<div><input type="text" name="titre" placeholder="Titre"></div>
|
|
<div><textarea name="page-content"></textarea></div>
|
|
<div>
|
|
<select name="classification" id="cars">
|
|
<?php foreach($classifications as $id => $nom) { echo '<option value="' . $id .'">' . $nom . '</option>'; }?>
|
|
</select>
|
|
</div>
|
|
<div><input type="submit" value="Publier"></div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div class="content">
|
|
<div>
|
|
<div><?=$copyright?></div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|