271 lines
14 KiB
PHP
Executable File
271 lines
14 KiB
PHP
Executable File
<?php
|
|
require("../../include/variables.php");
|
|
require("../../include/init.php");
|
|
require("../../include/main-functions.php");
|
|
require("../../include/objects.php");
|
|
require("../../include/inputs.php");
|
|
require("../../include/panels.php");
|
|
|
|
$pdo = sqlConnect($sqlDatabaseHost, $sqlDatabaseName, $sqlDatabaseUser, $sqlDatabasePass);
|
|
|
|
if (isset($_GET['article']) && filter_var($_GET['article'], FILTER_VALIDATE_INT) && file_exists($rootFilePath . 'content/articles/' . $_GET['article'] . '.md')) {
|
|
|
|
$sqlRequest = "SELECT articles.ID, articles.title, articles.creation_date, articles.last_update, articles.miniature, articles.resume, articles.author, users.username, users.display_name, roles.badge_svg, users.profile_picture FROM articles INNER JOIN users ON articles.author = users.ID LEFT JOIN roles ON users.role = roles.ID WHERE articles.ID = :articleID AND (articles.classification <= :userAccreditation OR articles.author = :userID)";
|
|
$request = $pdo->prepare($sqlRequest);
|
|
$request->bindParam(":articleID", $_GET['article']);
|
|
$request->bindParam(":userAccreditation", $_SESSION['userAccreditation']);
|
|
$request->bindParam(":userID", $_SESSION['userID']);
|
|
$request->execute();
|
|
$result = $request->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if($result) {
|
|
$pubDateTime = strtotime($result[0]['creation_date']);
|
|
$pubDate = date('d/m/Y H:i', $pubDateTime);
|
|
$updateDateTime = strtotime($result[0]['last_update']);
|
|
if($updateDateTime != $pubDateTime) {
|
|
$updateDate = date('d/m/Y H:i', $updateDateTime);
|
|
} else {
|
|
$updateDate = 0;
|
|
}
|
|
$articleID = $result[0]['ID'];
|
|
$articleTitle = $result[0]['title'];
|
|
$articleResume = $result[0]['resume'];
|
|
$articleDescription = str_replace("<br />", "", $articleResume);
|
|
$miniatureURL = $result[0]['miniature'];
|
|
$authorUsername = $result[0]['username'];
|
|
$authorDisplayName = $result[0]['display_name'];
|
|
$authorBadge = $result[0]['badge_svg'];
|
|
$authorPPURL = $result[0]['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $result[0]['profile_picture'];
|
|
$authorID = $result[0]['author'];
|
|
}
|
|
|
|
} else {
|
|
$search = isset($_GET['search']) ? "%" . htmlspecialchars($_GET['search']) . "%" : "%%";
|
|
$sqlRequest = "SELECT articles.ID, articles.title, articles.creation_date, articles.miniature, articles.resume, users.username, users.display_name, roles.badge_svg FROM articles INNER JOIN users ON articles.author = users.ID LEFT JOIN roles ON users.role = roles.ID WHERE (articles.title LIKE :search OR articles.ID LIKE :search OR users.username LIKE :search OR users.display_name LIKE :search) AND (articles.classification <= :userAccreditation OR articles.author = :userID) ORDER BY articles.creation_date DESC";
|
|
$request = $pdo->prepare($sqlRequest);
|
|
$request->bindParam(":search", $search);
|
|
$request->bindParam(":userAccreditation", $_SESSION['userAccreditation']);
|
|
$request->bindParam(":userID", $_SESSION['userID']);
|
|
$request->execute();
|
|
$articlesResult = $request->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
|
|
<head>
|
|
<?php
|
|
if (isset($articleID)) {
|
|
echo ('<meta name="description" content="' . $articleDescription . '">');
|
|
echo ('<meta name="author" content="' . $authorDisplayName . '">');
|
|
|
|
echo ('<meta property="og:locale" content="fr_FR">');
|
|
echo ('<meta property="og:site_name" content="E59">');
|
|
echo ('<meta property="og:type" content="article">');
|
|
echo ('<meta property="og:title" content="' . $articleTitle . '">');
|
|
echo ('<meta property="og:description" content="' . $articleDescription . '">');
|
|
echo ('<meta property="og:url" content="' . $rootPageURL . 'news?article=' . $articleID . '">');
|
|
echo ('<meta property="og:image" content="' . $rootPageURL . $miniatureURL . '">');
|
|
echo ('<meta property="og:image:width" content="500">');
|
|
echo ('<meta property="og:image:height" content="300">');
|
|
echo ('<meta property="og:image:type" content="image/png">');
|
|
echo ('<meta property="og:article:published_time" content="' . $pubDateTime . '">');
|
|
echo ('<meta property="og:article:modified_time" content="' . $updateDateTime . '">');
|
|
|
|
echo ('<meta property="twitter:card" content="summary_large_image">');
|
|
echo ('<meta property="twitter:site" content="@e59_club">');
|
|
echo ('<meta property="twitter:title" content="' . $articleTitle . '">');
|
|
echo ('<meta property="twitter:description" content="' . $articleDescription . '">');
|
|
echo ('<meta property="twitter:url" content="' . $rootPageURL . 'news?article=' . $articleID . '">');
|
|
echo ('<meta property="twitter:image" content="' . $rootPageURL . $miniatureURL . '">');
|
|
echo ('<meta property="ownpage:title" content="' . $articleTitle . '">');
|
|
echo ('<meta property="ownpage:description" content="' . $articleDescription . '">');
|
|
echo ('<meta property="ownpage:published_date" content="' . $pubDateTime . '">');
|
|
echo ('<meta property="ownpage:image" content="' . $rootPageURL . $miniatureURL . '">');
|
|
echo ('<meta property="ownpage:offer_url" content="' . $rootPageURL . 'news?article=' . $articleID . '">');
|
|
echo ('<meta name="robots" content="max-snippet:-1,max-image-preview:large,noarchive">');
|
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
|
header("Expires: Sat, 1 Jan 2000 00:00:00 GMT"); // Date passée
|
|
fillHead($rootPageURL, $articleTitle, $darkTheme, $lightTheme);
|
|
} else {
|
|
fillHead($rootPageURL, "Actualités - " . $pageName, $darkTheme, $lightTheme);
|
|
}
|
|
?>
|
|
<style>
|
|
.article .article-title {
|
|
font-family: cfont, Arial, sans-serif;
|
|
font-size: 2em;
|
|
margin: 1em 0 0.5em 0;
|
|
}
|
|
|
|
.article .article-date {
|
|
font-size: 0.8em;
|
|
margin: 1em 0;
|
|
}
|
|
|
|
.article .article-illustration {
|
|
max-height: 20em;
|
|
overflow: hidden;
|
|
border-radius: 10px;
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.article .article-illustration img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.article .article-content {
|
|
font-family: cfont, Arial, sans-serif;
|
|
margin-top: 3em;
|
|
}
|
|
|
|
.article .article-content p {
|
|
font-family: Calibri, Arial, sans-serif;
|
|
}
|
|
|
|
.article .article-content img {
|
|
max-width: 100%;
|
|
max-height: 30em;
|
|
}
|
|
|
|
.article .article-content h1 {
|
|
font-size: 2em;
|
|
margin-top: 1em;
|
|
}
|
|
|
|
.article .article-content h2 {
|
|
font-weight: normal;
|
|
}
|
|
|
|
#edit-icon {
|
|
fill: var(--text);
|
|
height: 0.8em;
|
|
margin-left: 0.5em;
|
|
}
|
|
.user-widget {
|
|
margin-top: 5em;
|
|
}
|
|
.googleadbox {
|
|
margin: 0 auto;
|
|
width: 60%;
|
|
margin-top: 30em;
|
|
}
|
|
.adsbygoogle {
|
|
display:inline-block;
|
|
margin: 0 auto;
|
|
width:100%;
|
|
height:90px;
|
|
}
|
|
@media(max-width: 750px) {
|
|
.article .article-content h1 {
|
|
margin-top: 0;
|
|
}
|
|
.adsbygoogle {
|
|
height:50px
|
|
}
|
|
.googleadbox {
|
|
width: 100%;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="body">
|
|
<header>
|
|
<div class="panel-content">
|
|
<?php fillHeader($rootPageURL, $headerTitle, $headerSubtitle, $social);?>
|
|
</div>
|
|
</header>
|
|
|
|
<nav>
|
|
<div class="panel-content">
|
|
<?php fillNav($rootPageURL);?>
|
|
</div>
|
|
</nav>
|
|
|
|
<main>
|
|
<div class="content">
|
|
<?php
|
|
if(isset($articleID)) {
|
|
echo ('<div class="article">');
|
|
echo ('<div class="article-info">');
|
|
|
|
userWidget($authorPPURL, $authorDisplayName, $authorUsername, $authorBadge, $rootPageURL);
|
|
|
|
echo ('<div class="article-title">' . $articleTitle);
|
|
if ($_SESSION['userID'] == $authorID || $_SESSION['userRole'] == 50) {
|
|
echo ('<a href="/editor?article=' . $articleID . '" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px" id="edit-icon"><path d="M 43.125 2 C 41.878906 2 40.636719 2.488281 39.6875 3.4375 L 38.875 4.25 L 45.75 11.125 C 45.746094 11.128906 46.5625 10.3125 46.5625 10.3125 C 48.464844 8.410156 48.460938 5.335938 46.5625 3.4375 C 45.609375 2.488281 44.371094 2 43.125 2 Z M 37.34375 6.03125 C 37.117188 6.0625 36.90625 6.175781 36.75 6.34375 L 4.3125 38.8125 C 4.183594 38.929688 4.085938 39.082031 4.03125 39.25 L 2.03125 46.75 C 1.941406 47.09375 2.042969 47.457031 2.292969 47.707031 C 2.542969 47.957031 2.90625 48.058594 3.25 47.96875 L 10.75 45.96875 C 10.917969 45.914063 11.070313 45.816406 11.1875 45.6875 L 43.65625 13.25 C 44.054688 12.863281 44.058594 12.226563 43.671875 11.828125 C 43.285156 11.429688 42.648438 11.425781 42.25 11.8125 L 9.96875 44.09375 L 5.90625 40.03125 L 38.1875 7.75 C 38.488281 7.460938 38.578125 7.011719 38.410156 6.628906 C 38.242188 6.246094 37.855469 6.007813 37.4375 6.03125 C 37.40625 6.03125 37.375 6.03125 37.34375 6.03125 Z"/></svg></a>');
|
|
}
|
|
echo ('</div>');
|
|
echo ('<div class="article-date">' . $pubDate);
|
|
if ($updateDate != 0) {
|
|
echo (' (Mis à jour le ' . $updateDate . ')');
|
|
}
|
|
echo ('</div>');
|
|
|
|
echo ('<div class="article-illustration">');
|
|
echo ('<img src="' . $miniatureURL . '"/>');
|
|
echo ('</div>');
|
|
|
|
echo ('<div class="article-content">');
|
|
$pageContent = markdownContent($rootFilePath . 'content/articles/' . $articleID . '.md', $rootFilePath);
|
|
|
|
echo($pageContent);
|
|
echo ('</div>');
|
|
|
|
echo ('</div>');
|
|
echo ('</div>');
|
|
} else {
|
|
echo ('<h1>Actualités</h1>');
|
|
|
|
echo ('<form action="" method="get">');
|
|
$shapePath = '<path d="M10.25 3.75c-3.59 0-6.5 2.91-6.5 6.5s2.91 6.5 6.5 6.5c1.795 0 3.419-.726 4.596-1.904 1.178-1.177 1.904-2.801 1.904-4.596 0-3.59-2.91-6.5-6.5-6.5zm-8.5 6.5c0-4.694 3.806-8.5 8.5-8.5s8.5 3.806 8.5 8.5c0 1.986-.682 3.815-1.824 5.262l4.781 4.781-1.414 1.414-4.781-4.781c-1.447 1.142-3.276 1.824-5.262 1.824-4.694 0-8.5-3.806-8.5-8.5z"></path>';
|
|
textInput("text", $shapePath, "search", "Chercher", "");
|
|
echo ('</form>');
|
|
|
|
if(empty($_GET['search']) == false) {
|
|
$sqlRequest = "SELECT users.username, users.display_name, roles.badge_svg, users.profile_picture FROM users JOIN roles ON users.role = roles.ID WHERE username LIKE :search OR display_name LIKE :search";
|
|
$request = $pdo->prepare($sqlRequest);
|
|
$request->bindParam(":search", $search);
|
|
$request->execute();
|
|
$userResult = $request->fetchAll(PDO::FETCH_ASSOC);
|
|
if($userResult) {
|
|
echo ('<div class="users-list">');
|
|
foreach ($userResult as $user) {
|
|
$userPPURL = $user['profile_picture'] == NULL ? "https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png" : $user['profile_picture'];
|
|
userWidget($userPPURL, $user['display_name'], $user['username'], $user['badge_svg'], $rootPageURL);
|
|
}
|
|
echo ('</div>');
|
|
}
|
|
}
|
|
|
|
if ($articlesResult) {
|
|
echo('<div class="articles-list">');
|
|
listArticles($articlesResult, $rootPageURL);
|
|
echo('</div>');
|
|
} else {
|
|
echo ('Aucun article trouvé');
|
|
}
|
|
}
|
|
?>
|
|
<div class="googleadbox">
|
|
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5492094351136590" crossorigin="anonymous"></script>
|
|
<ins class="adsbygoogle" data-ad-client="ca-pub-5492094351136590" data-ad-slot="6694793177"></ins>
|
|
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div class="panel-content">
|
|
<?php fillFooter($footerText);?>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|