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
This commit is contained in:
parent
36e183925a
commit
b06e5345b3
@ -2,7 +2,14 @@
|
|||||||
title = "Club Réseaux"
|
title = "Club Réseaux"
|
||||||
header-title = "E59"
|
header-title = "E59"
|
||||||
header-subtitle = "Club Réseaux"
|
header-subtitle = "Club Réseaux"
|
||||||
copyright = "© 2024 - E59"
|
copyright = "© 2024 - E59"
|
||||||
|
|
||||||
|
[sql]
|
||||||
|
dbname = ""
|
||||||
|
dbuser = ""
|
||||||
|
dbpass = ""
|
||||||
|
dbhost = ""
|
||||||
|
|
||||||
[nav]
|
[nav]
|
||||||
Journal = "journal.php"
|
Journal = "journal.php"
|
||||||
|
|
||||||
|
60
html/admin.php
Normal file
60
html/admin.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
require "../include/variables.php";
|
||||||
|
require "../include/functions.php";
|
||||||
|
|
||||||
|
if(isset($_SESSION['userid']) == false) {
|
||||||
|
http_response_code(404);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!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>
|
||||||
|
<div><a href="upload.php">Publier un article</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<div class="content">
|
||||||
|
<div>
|
||||||
|
<div><?=$copyright?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../include/variables.php";
|
require "../include/variables.php";
|
||||||
require "../include/functions.php";
|
require "../include/functions.php";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../include/variables.php";
|
require "../include/variables.php";
|
||||||
require "../include/functions.php";
|
require "../include/functions.php";
|
||||||
|
|
||||||
if (isset($_GET['article']) == false || filter_var($_GET['article'], FILTER_VALIDATE_INT) == false) {
|
if (isset($_GET['article']) == false || filter_var($_GET['article'], FILTER_VALIDATE_INT) == false) {
|
||||||
$article = "0";
|
$article = "0";
|
||||||
} else {
|
} else {
|
||||||
@ -51,7 +52,16 @@ if (isset($_GET['article']) == false || filter_var($_GET['article'], FILTER_VALI
|
|||||||
$parsedown = new Parsedown();
|
$parsedown = new Parsedown();
|
||||||
echo $parsedown->text($markdownContent);
|
echo $parsedown->text($markdownContent);
|
||||||
} else {
|
} else {
|
||||||
echo "<h1>L'article demandé n'existe pas</h1>";
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||||
|
$req = $bdd->prepare("SELECT (ID, titre, date, auteur) FROM articles ORDER BY date DESC");
|
||||||
|
$bdd->execute();
|
||||||
|
$resultat = $req->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($resultat) {
|
||||||
|
foreach($resultat as $row) {
|
||||||
|
echo "<div class='article'><div><a href='#?article=" . $row['ID'] . "'>" . $row['Titre'] . "</a></div><div>" . $row['auteur'] . "</div><div>" . $row['date'] . "</div></div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
82
html/login.php
Normal file
82
html/login.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
require "../include/variables.php";
|
||||||
|
require "../include/functions.php";
|
||||||
|
|
||||||
|
if(isset($_SESSION['userid'])) {
|
||||||
|
header("Location: index.php");
|
||||||
|
die("Vous êtes déjà connecté");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['username']) && isset($_POST['password'])) {
|
||||||
|
if(empty($_POST['username']) == false && empty($_POST['password']) === false) {
|
||||||
|
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
|
||||||
|
|
||||||
|
$req = $bdd->prepare("SELECT (ID, username, email, display_name) FROM admins WHERE (username = :username OR email = :username) AND password = :password");
|
||||||
|
$bdd->bindParam(':username', htmlspecialchars($_POST['username']));
|
||||||
|
$bdd->bindParam(':password', md5($_POST['password']));
|
||||||
|
$bdd->execute();
|
||||||
|
|
||||||
|
$resultat = $req->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if ($resultat) {
|
||||||
|
$_SESSION['username'] = $resultat[0]['username'];
|
||||||
|
$_SESSION['email'] = $resultat[0]['email'];
|
||||||
|
$_SESSION['display_name'] = $resultat[0]['display_name'];
|
||||||
|
$_SESSION['userid'] = $resultat[0]['ID'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!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><form action="#" method="post">
|
||||||
|
<div>
|
||||||
|
<div><input type="text" name="username" placeholder="Nom d'utilisateur" required></div>
|
||||||
|
<div><input type="text" name="password" placeholder="Mot de Passe" required></div>
|
||||||
|
<div><input type="sumbit"></div>
|
||||||
|
</div>
|
||||||
|
</div></form>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<div class="content">
|
||||||
|
<div>
|
||||||
|
<div><?=$copyright?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
87
html/upload.php
Normal file
87
html/upload.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?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>
|
@ -1,7 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
function nav($nav) {
|
function nav($nav) {
|
||||||
foreach($nav as $name => $url) {
|
foreach($nav as $name => $url) {
|
||||||
echo "<div class='navitem'><a href='$url'>$name</a></div>";
|
echo "<div class='navitem'><a href='$url'>$name</a></div>";
|
||||||
}
|
}
|
||||||
|
if(isset($_SESSION['userid'])) {
|
||||||
|
echo "<div class='navitem'><a href='admin.php'>Admin</a></div>";
|
||||||
|
}
|
||||||
|
echo "<div class='navitem'><a href='logout.php'>Déconnexion</a></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function connect($dbhost, $dbname, $dbuser, $dbpass) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$bdd = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname . ';charset=UTF8',$dbuser,$dbpass);
|
||||||
|
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
die('Erreur : '.$e->getMessage());
|
||||||
|
}
|
||||||
|
return $bdd;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
$global_config = parse_ini_file('../config/global.ini', true);
|
$config = parse_ini_file('../config/global.ini', true);
|
||||||
|
|
||||||
|
$dbuser = $config['sql']['dbuser'];
|
||||||
|
$dbpass = $config['sql']['dbpass'];
|
||||||
|
$dbname = $config['sql']['dbname'];
|
||||||
|
$dbhost = $config['sql']['dbhost'];
|
||||||
|
|
||||||
|
$title = $config['main']['title'];
|
||||||
|
$header_title = $config['main']['header-title'];
|
||||||
|
$header_subtitle = $config['main']['header-subtitle'];
|
||||||
|
$copyright = $config['main']['copyright'];
|
||||||
|
$nav = $config['nav'];
|
||||||
|
$navadmin = $nav
|
||||||
|
|
||||||
$title = $global_config['main']['title'];
|
|
||||||
$header_title = $global_config['main']['header-title'];
|
|
||||||
$header_subtitle = $global_config['main']['header-subtitle'];
|
|
||||||
$copyright = $global_config['main']['copyright'];
|
|
||||||
$nav = $global_config['nav'];
|
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user