e59-website/html/upload.php
Jan BELLON b06e5345b3 Update 8 files
- /include/variables.php
- /include/functions.php
- /html/index.php
- /html/admin.php
- /html/upload.php
- /html/login.php
- /html/journal.php
- /config/global.ini
2024-03-07 01:09:05 +00:00

87 lines
2.8 KiB
PHP

<?php
require "../include/variables.php";
require "../include/functions.php";
if(isset($_SESSION['userid']) == false) {
http_response_code(404);
die();
}
if(isset($_POST['title']) && isset($_FILES['file'])) {
$filename = date("YmdHis");
$destination = "../content/journal/" . $filename;
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$insertcred = $bdd->prepare("INSERT INTO articles (ID, titre, date, auteur) VALUES (:filename, :titre, :date, :auteur)");
$bdd->bindParam(':filename', $filename);
$bdd->bindParam(':titre', htmlspecialchars($_POST['titre']));
$bdd->bindParam(':auteur', $_SESSION['display_name']);
if (isset($_POST['date']) && empty($_POST['date']) == false) {
$bdd->bindParam(':date', htmlspecialchars($_POST['date']));
} else {
$bdd->bindParam(':date', date());
}
$insertcred->execute();
move_uploaded_file($_FILES['file']['tmp_name'], $destination);
}
?>
<!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>
</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>
<div>
<h1>Publier un article</h1>
<form action="#" method="post">
<div>
<div><input type="text" name="title" placeholder="Titre de l'article" required></div>
<div><input type="date" name="date"></div>
<!--<div><input type="radio">Interne</input></div>-->
<div><input type="file" name="file" required></div>
<div><input type="submit"></div>
</div>
</form>
</div>
</div>
</div>
</main>
<footer>
<div class="content">
<div>
<div><?=$copyright?></div>
</div>
</div>
</footer>
</body>
</html>