e59-website/html-old/upload.php
Jan BELLON fe47cb9f3b Update 72 files
- /html/about.php
- /html/admin.php
- /html/compte.php
- /html/editpage.php
- /html/login.php
- /html/logout.php
- /html/news.php
- /html/register.php
- /html/src/banner/index.php
- /html/src/img/empty.jpg
- /html/src/img/favicon.ico
- /html/src/miniature/index.php
- /html/src/pp/index.php
- /html/upload.php
- /html/user.php
- /html/users.php
- /content/journal/0.md
- /content/journal/198183.md
- /content/about.md
- /content/admin.md
- /content/index.md
- /html-old/editpage.php
- /html-old/src/banner/index.php
- /html-old/src/css/index.php
- /html-old/src/css/style.css
- /html-old/src/fonts/index.php
- /html-old/src/fonts/bahnschrift.ttf
- /html-old/src/img/empty.jpg
- /html-old/src/img/favicon.ico
- /html-old/src/img/index.php
- /html-old/src/img/athena-mono.png
- /html-old/src/miniature/index.php
- /html-old/src/pp/index.php
- /html-old/src/index.php
- /html-old/about.php
- /html-old/robots.txt
- /html-old/admin.php
- /html-old/compte.php
- /html-old/login.php
- /html-old/logout.php
- /html-old/index.php
- /html-old/news.php
- /html-old/register.php
- /html-old/upload.php
- /html-old/users.php
- /html-old/user.php
- /html/about/index.php
- /html/account/index.php
- /html/admin/index.php
- /html/assets/banners/index.php
- /html/assets/miniatures/index.php
- /html/assets/pp/index.php
- /html/assets/index.php
- /html/editor/index.php
- /html/login/index.php
- /html/login/logout.php
- /html/login/register.php
- /html/news/index.php
- /html/settings/index.php
- /html/settings/deleteaccount.php
- /html/src/css/style.css
- /html/src/img/athena-mono.png
- /html/index.php
- /html/robots.txt
- /content/articles/0.md
- /content/articles/198183.md
- /content/pages/about.md
- /content/pages/admin.md
- /content/pages/index.md
- /include/variables.php
- /include/functions.php
- /config/global.ini
2024-03-14 19:55:10 +00:00

118 lines
3.9 KiB
PHP

<?php
require "../include/variables.php";
require "../include/functions.php";
if($_SESSION['role'] < 1) {
header("Location: login.php");
http_response_code(404);
die();
}
$filename = rand(100000, 999999);
while(file_exists($wwwroot . "/content/journal/" . $filename . ".md")) {
$filename = rand(100000, 999999);
}
if(isset($_POST['article-content'])) {
file_put_contents($wwwroot . "/content/journal/" . $filename . ".md", nl2br($_POST['article-content']));
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$upload = $bdd->prepare("INSERT INTO articles (ID, titre, auteur, resume, classification) VALUES (:filename, :titre, :auteur, :resume, :classification)");
$upload->bindParam(':filename', $filename);
$upload->bindParam(':titre', htmlspecialchars($_POST['article-titre']));
$upload->bindParam(':auteur', $_SESSION['userid']);
$upload->bindParam(':resume', htmlspecialchars($_POST['article-resume']));
$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 name="robots" content="noindex">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./src/css/style.css">
<style>
@media (prefers-color-scheme: dark) {
.body {
<?=$theme_dark?>
}
}
@media (prefers-color-scheme: light) {
.body {
<?=$theme_light?>
}
}
</style>
<link rel="icon" href="./src/img/favicon.ico">
<title><?=$title?></title>
<style>
textarea {
width: 100%;
min-height: 50em;
}
</style>
</head>
<body class="body">
<header>
<div class="pancontent">
<div class="athena-container">
<a href="<?=$root?>">
<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>
<div class="status"><?=$status?></div>
<form action="?article=<?=$filename?>" method="post">
<div>
<div><div><h1>Publier un article</h1></div>
<div><input type="text" name="article-titre" placeholder="Titre"></div>
<div><textarea name="article-resume" placeholder="Résumé de l'article (200 cacactères) ..." class="article-resume-input" maxlength="200"></textarea></div>
<div><textarea name="article-content" placeholder="Contenu de l'article (MarkDown) ..."></textarea></div>
<div>
<label for="classification">Classification : </label>
<select name="classification" required>
<?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>