Commit 3e33e9c7 authored by Corentin Bettiol's avatar Corentin Bettiol 💻

remove hr, add adminController, remove comments concept, add admin link in all pages if connected

parent ebe5a9ea
......@@ -66,18 +66,17 @@ h2{
h3 a{
text-decoration: none;
text-shadow: 0 0 1px #69f;
transition: padding-left 0.3s, text-shadow 0.3s, color 0.3s;
transition: color 0.3s;
}
h3 a:hover{
padding-left: 5px;
text-shadow: -5px 0 4px #BBf;
transition: padding-left 0.3s, text-shadow 0.3s, color 0.3s;
color: #47476b;
text-shadow: 0 0 1px #69f;
transition: color 0.3s;
}
#listMenu{
padding: 0;
width: auto;
display: flex;
margin: 15px 0;
flex-direction: row;
......@@ -103,6 +102,7 @@ article{
margin: 20px 0;
padding: 5px 15px;
background-color: #f0f0f0;
border-bottom: 3px solid #ccc;
}
#listMenu .selected{
......@@ -123,11 +123,6 @@ article .postInfos{
background-color: #f0f0f0;
}
hr{
width: 66%;
border: 1px solid #ccc;
}
a{
transition: color 0.3s;
}
......@@ -156,10 +151,13 @@ input, textarea{
margin: 0 0 0 20px;
}
#inputContent{
height: 10em;
}
input:hover, input:focus, textarea:hover, textarea:focus{
padding-left: 10px;
border-left: 3px solid #ccc;
transition: border-left 0.05s, padding-left 0.05s;
transition: border-left 0.05s;
}
......@@ -175,25 +173,6 @@ input[type="submit"]:hover{
transition: background-color 0.3s;
}
input[type="checkbox"]{
width: 30px;
height: 30px;
margin: 15px;
cursor: pointer;
appearance: none;
border-width: 0;
display: inline-block;
box-sizing: border-box;
background-color: #eaa;
-webkit-appearance: none;
transition: background-color 0.3s;
}
input[type="checkbox"]:checked{
background-color: #aea;
transition: background-color 0.3s;
}
label{
display: inline-block;
width: 250px;
......@@ -201,7 +180,7 @@ label{
background-color: #d9d9d9;
}
label.large{
label .large{
width: 300px;
}
......@@ -213,6 +192,7 @@ form .small{
display: flex;
align-items: flex-start;
justify-content: center;
flex-wrap: wrap;
}
#listAdmin{
......@@ -304,6 +284,28 @@ Media Queries
}
}
@media all and (max-width: 700px){
input, textarea, label{
width: 100%;
}
label{
margin-right: 20px;
}
#menu{
width: 100%;
}
#listMenu{
flex-direction: column;
justify-content: center;
}
#listMenu li, #listMenu h2, #listMenu a{
display: block;
width: 90%;
margin: 2px auto;
text-align: center;
}
}
@media all and (max-width: 500px){
#page{
font-size: 1em;
......@@ -312,30 +314,19 @@ Media Queries
width: 45px;
height: 45px;
}
#title{
margin-bottom: 15px;
}
#listMenu{
width: 50%;
width: 80%;
margin: auto;
flex-wrap: wrap;
justify-content: center;
}
#listMenu li, #listMenu h2, #listMenu a{
width: 100%;
}
#listMenu li{
margin: 5px auto;
text-align: center;
margin: 3px auto;
}
#listMenu a{
margin: 0;
padding: 3px 0;
display: inline-block;
}
#listMenu .selected{
border: none;
background-color: #cccccc;
background-color: #ccc;
}
}
......
......@@ -6,6 +6,9 @@ session_start();
// le gros gros controlleur (peut-être le casser en plusieurs morceaux plus tard)
require_once('site/controller/mainController.php');
// le moins gros controlleur (oui c'est un morceau)
require_once('site/controller/adminController.php');
// afficher le contenu (qui va switcher sur le contenu dynamique à afficher)
require_once('site/layout/layout.php');
......
......@@ -10,25 +10,9 @@ CREATE TABLE `l3m_blog` (
`time` datetime NOT NULL,
`title` varchar(255) NOT NULL,
`content` text NOT NULL,
`shortContent` varchar(255) NOT NULL DEFAULT 'Ce billet de blog ne dispose d''aucune description.',
`comments` tinyint(4) NOT NULL DEFAULT '1'
`shortContent` varchar(255) NOT NULL DEFAULT 'Ce billet de blog ne dispose d''aucune description.'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `l3m_blog` (`id`, `time`, `title`, `content`, `shortContent`, `comments`) VALUES
(1, '2019-01-10 00:00:00', 'Le premier article !', 'Contenu contenu contenu.', 'Le premier article du blog !', 1),
(2, '2019-01-14 12:08:00', 'Second article du blog !', 'L\'édition fonctionne.', 'WIP !', 1);
CREATE TABLE `l3m_comments` (
`id` int(11) NOT NULL,
`id_blog` int(11) NOT NULL,
`pseudo` varchar(255) NOT NULL,
`mail` varchar(255) NOT NULL,
`link` varchar(255) NOT NULL,
`content` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `l3m_projects` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
......@@ -37,28 +21,8 @@ CREATE TABLE `l3m_projects` (
`shortContent` varchar(255) NOT NULL DEFAULT 'Pas de description.'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `l3m_projects` (`id`, `name`, `link`, `content`, `shortContent`) VALUES
(1, 'l3m website', 'http://l3m.in', 'Ce site.', 'Pas de description.');
ALTER TABLE `l3m_blog`
ADD PRIMARY KEY (`id`);
ALTER TABLE `l3m_comments`
ADD PRIMARY KEY (`id`),
ADD KEY `id_blog` (`id_blog`);
ALTER TABLE `l3m_projects`
ADD PRIMARY KEY (`id`);
ALTER TABLE `l3m_blog`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
ALTER TABLE `l3m_comments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `l3m_projects`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
ALTER TABLE `l3m_comments`
ADD CONSTRAINT `l3m_comments_ibfk_1` FOREIGN KEY (`id_blog`) REFERENCES `l3m_blog` (`id`);
\ No newline at end of file
ADD PRIMARY KEY (`id`);
\ No newline at end of file
<?php
// classe pour l'administration du contenu du site
require_once('site/model/AdminManager.php');
// tente de connecter l'administrateur
function loginAdminPage($pageName){
if(password_verify($_POST['pass'], pass) && $_POST['user'] == user){
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
header('Location:/patate');
}
else
header('Location:/patate');
}
// afficher le panneau d'administration & gère l'administration du site
function writeAdminPage($pageName){
$admin = new AdminManager();
if($admin->verifyAdminConnect()){
if(isset($_GET['editb'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
if($blogpost = $admin->getBlogPost($title))
require('site/view/private/editblogView.php');
else
header('Location:/404');
}
else{
$admin->updateBlogPost();
header('Location:/patate');
}
}
else if(isset($_GET['editp'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$project = $admin->getProject($title);
require('site/view/private/editProjectView.php');
}
else{
$admin->updateProject();
header('Location:/patate');
}
}
else if(isset($_GET['submitb'])){
require('site/view/private/createBlogView.php');
}
else if(isset($_GET['submitp'])){
require('site/view/private/createProjectView.php');
}
else if(isset($_GET['sendb'])){
$admin->sendBlogPost();
header('Location:/');
}
else if(isset($_GET['sendp'])){
$admin->sendProject();
header('Location:/projects');
}
else if(isset($_GET['deleteb'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$admin->deleteBlogPost($title);
header('Location:/patate');
}
}
else if(isset($_GET['deletep'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$admin->deleteProject($title);
header('Location:/patate');
}
}
else{
$blogposts = $admin->getBlogPosts();
$projects = $admin->getProjects();
require('site/view/private/admin.php');
}
}
else
require('site/view/private/loginFormView.php');
}
// déconnexion de la partie administration
function decoAdminPage(){
$_SESSION = array();
header('Location:/');
}
\ No newline at end of file
......@@ -6,9 +6,6 @@ require_once('site/model/config.php');
// connexion à la base de données
require_once('site/model/Base.php');
// classe pour l'administration du contenu du site
require_once('site/model/AdminManager.php');
// classe pour la gesion des billets de blog
require_once('site/model/BlogManager.php');
......@@ -28,7 +25,7 @@ function getPageName(){
return ['À Propos', 'about'];
break;
case 'projects': // projets
return ['Projets', 'projects'];
return ['Projets', 'project'];
break;
case 'project': // projet
return ['Projet', 'project'];
......@@ -45,9 +42,6 @@ function getPageName(){
case '404': // page not found
return ['Erreur 404 - File not found', '404'];
break;
case 'article': // billet de blog
return [$_GET['title'], $_GET['title']];
break;
case 'patate': // administration
return ['Administration', 'administration'];
break;
......@@ -66,7 +60,13 @@ function getPageName(){
function writeMenu($pageName){
?>
<ul id='listMenu'>
<?php if($pageName == 'Administration'){ ?><li><h2><a href="/eplucher" class="selected">🔧</a></h2></li><?php } ?>
<?php
if($pageName == 'Administration'){ ?>
<li><h2><a href="/eplucher" class="selected">🔧</a></h2></li>
<?php }
else if(isset($_SESSION['user'])){ ?>
<li><h2><a href="/patate" >🔧</a></h2></li>
<?php } ?>
<li><h2><a href="/" title="Blog" <?php if($pageName == 'Blog'){ ?>class="selected"<?php } ?>>Blog</a></h2></li>
<li><h2><a href="/about" title="À propos" <?php if($pageName == 'À Propos'){ ?>class="selected"<?php } ?>>À propos</a></h2></li>
<li><h2><a href="/projects" title="Projets" <?php if($pageName == 'Projets' || $pageName == 'Projet'){ ?>class="selected"<?php } ?>>Projets</a></h2></li>
......@@ -99,116 +99,23 @@ function writeBlogPage($pageName){
}
// affiche la liste des projets
function writeProjectsPage($pageName){
$projects = new ProjectManager(NULL, NULL, NULL, NULL, NULL);
$projects = $projects->getProjects();
require('site/view/public/projectsView.php');
}
// affiche un projet en particulier
function writeProjectPage($pageName){
$project = new ProjectManager(NULL, NULL, NULL, NULL, NULL);
// si on affiche un projet en particulier
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$project = $project->get($title);
if($project != false){
$project['pageProject'] = true;
if($project != false)
require('site/view/public/projectView.php');
}
else{
else
header('Location:/404');
}
}
else
// si on affiche la liste des projets
else{
$projects = $project->getProjects();
require('site/view/public/projectsView.php');
}
// tente de connecter l'administrateur
function loginAdminPage($pageName){
if(password_verify($_POST['pass'], pass) && $_POST['user'] == user){
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
header('Location:/patate');
}
else
header('Location:/patate');
}
// afficher le panneau d'administration & gère l'administration du site
function writeAdminPage($pageName){
$admin = new AdminManager();
if($admin->verifyAdminConnect()){
if(isset($_GET['editb'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
if($blogpost = $admin->getBlogPost($title))
require('site/view/private/editblogView.php');
else
header('Location:/404');
}
else{
$admin->updateBlogPost();
header('Location:/patate');
}
}
else if(isset($_GET['editp'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$project = $admin->getProject($title);
require('site/view/private/editProjectView.php');
}
else{
$admin->updateProject();
header('Location:/patate');
}
}
else if(isset($_GET['submitb'])){
require('site/view/private/createBlogView.php');
}
else if(isset($_GET['submitp'])){
require('site/view/private/createProjectView.php');
}
else if(isset($_GET['sendb'])){
$admin->sendBlogPost();
header('Location:/');
}
else if(isset($_GET['sendp'])){
$admin->sendProject();
header('Location:/projects');
}
else if(isset($_GET['deleteb'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$admin->deleteBlogPost($title);
header('Location:/patate');
}
}
else if(isset($_GET['deletep'])){
if(isset($_GET['title'])){
$title = urldecode($_GET['title']);
$admin->deleteProject($title);
header('Location:/patate');
}
}
else{
$blogposts = $admin->getBlogPosts();
$projects = $admin->getProjects();
require('site/view/private/admin.php');
}
}
else
require('site/view/private/loginFormView.php');
}
// déconnexion de la partie administration
function decoAdminPage(){
$_SESSION = array();
header('Location:/');
}
// on récupère le nom de la page ici (avant d'inclure le layout)
......
......@@ -42,10 +42,7 @@
case 'about': // à propos
require('site/view/public/about.php'); // statique
break;
case 'projects': // projets
writeProjectsPage($pageName); // voir mainController
break;
case 'project': // projet en particulier
case 'project': // projet
writeProjectPage($pageName); // voir mainController
break;
case 'eplucher': // déconnexion du panneau d'administration
......@@ -77,8 +74,6 @@
break;
} ?>
<hr />
<footer id="footer">
<p>
Site en vanilla html5/css3/php7, fait avec ♥ - <a href="/changelog" title="changelog">Changelog</a> - <a href="/rss" title="rss">RSS</a> - v5
......
......@@ -5,18 +5,13 @@ class BlogManager extends Base
private $title;
private $content;
private $shortContent;
private $comments;
private $id;
function __construct($time, $title, $content, $shortContent, $comments, $id){
function __construct($time, $title, $content, $shortContent, $id){
$this->time = htmlspecialchars($time);
$this->title = htmlspecialchars($title);
$this->content = htmlspecialchars($content);
$this->shortContent = htmlspecialchars($shortContent);
if($comments == 'on')
$this->comments = 1;
else
$this->comments = 0;
$this->id = htmlspecialchars($id);
}
......@@ -56,13 +51,12 @@ class BlogManager extends Base
// todo vérifier qu'on poste pas un truc vide
public function update(){
$db = $this->dbConnect();
$req = $db->prepare('UPDATE l3m_blog SET time = :time, title = :title, content = :content, shortContent = :shortContent, comments = :comments WHERE id = :id');
$req = $db->prepare('UPDATE l3m_blog SET time = :time, title = :title, content = :content, shortContent = :shortContent, WHERE id = :id');
$req->execute([
'time' => $this->time,
'title' => $this->title,
'content' => $this->content,
'shortContent' => $this->shortContent,
'comments' => $this->comments,
'id' => $this->id
]);
}
......@@ -81,13 +75,12 @@ class BlogManager extends Base
$this->shortContent = 'Ce billet de blog ne dispose d\'aucune description.';
}
$db = $this->dbConnect();
$req = $db->prepare('INSERT INTO l3m_blog(time, title, content, shortcontent, comments) VALUES(:time, :title, :content, :shortContent, :comments)');
$req = $db->prepare('INSERT INTO l3m_blog(time, title, content, shortcontent) VALUES(:time, :title, :content, :shortContent)');
$req->execute([
'time' => $this->time,
'title' => $this->title,
'content' => $this->content,
'shortContent' => $this->shortContent,
'comments' => $this->comments
'shortContent' => $this->shortContent
]);
}
......
......@@ -12,30 +12,25 @@
<form action="/patate/blog/send" method="post" accept-charset="utf-8">
<article class="input">
<section class="input">
<label for="inputTitle">Titre</label>
<input type="text" name="title" placeholder="Titre" id="inputTitle" required />
</article>
</section>
<article class="input">
<section class="input">
<label for="inputDate">Date de publication</label>
<input type="datetime-local" name="time" placeholder="<?php echo $date->format("Y-m-d\TH:i:s"); ?>" class="small" id="inputDate" />
</article>
</section>
<article class="input">
<section class="input">
<label for="inputShortContent">Description</label>
<textarea name="shortContent" id="inputShortContent"></textarea>
</article>
</section>
<article class="input">
<section class="input">
<label for="inputContent">Contenu</label>
<textarea name="content" id="inputContent"></textarea>
</article>
<article class="input">
<label for="inputComments" class="large">Autoriser les commentaires</label>
<input type="checkbox" name="comments" id="inputComments" checked />
</article>
</section>
<input type="submit" value="Envoyer" />
......
......@@ -14,25 +14,25 @@
<input type="hidden" name="id" value="<?php echo $project['id']; ?>" />
<article class="input">
<section class="input">
<label for="inputTitle">Nom du projet</label>
<input type="text" name="name" placeholder="Nom du projet" id="inputName" />
</article>
</section>
<article class="input">
<section class="input">
<label for="inputLink">Lien vers le projet</label>
<input type="url" name="link" placeholder="Lien vers le projet" id="inputLink" />
</article>
</section>
<article class="input">
<section class="input">
<label for="inputShortContent">Résumé</label>
<textarea name="shortContent" id="inputShortContent"></textarea>
</article>
</section>
<article class="input">
<section class="input">
<label for="inputContent">Description</label>
<textarea name="content" id="inputContent"></textarea>
</article>
</section>
<input type="submit" value="Envoyer" />
......
......@@ -9,10 +9,7 @@
$post['datetime'] = new DateTime($post['time']);
$post['link'] = urlencode(str_replace(' ', '-', $post['title']));
if(!$hr)
$hr = true;
else
echo '<hr />';
$exist = true;
?>
<article>
<p class="listAdmin">
......@@ -22,7 +19,7 @@
</article>
<?php
}
if(!$hr){
if(!isset($exist)){
?>
<article>
<h4>Pas de post</h4>
......
......@@ -8,10 +8,7 @@
foreach ($projects as $project){
$project['internalLink'] = urlencode(str_replace(' ', '-', $project['name']));
if(!$hr)
$hr = true;
else
echo '<hr />';
$exist = true;
?>
<article>
<p class="listAdmin">
......@@ -21,7 +18,7 @@
</article>
<?php
}
if(!$hr){
if(!isset($exist)){
?>
<article>
<h4>Pas de projet</h4>
......
......@@ -4,13 +4,9 @@
<p>
Je suis Corentin Bettiol, étudiant en Master informatique à Grenoble.
</p>
</article>
<hr />
<article>
<h3>À propos du site</h3>
<p>
......@@ -24,25 +20,17 @@
</p>
</article>
<hr />
<article>
<h3>À propos du serveur</h3>
<p>
Le serveur est en fait un dell optiplex fx160, acheté a 50€ en 2017 sur ebay.<br />
<a href="http://l3m.in/p/up/files/1539952451.png">Voilà à quoi il ressemble</a> (todo = remplacer image par photo de l'ordi).
Le serveur est en fait un dell optiplex fx160 (acheté 50€ en 2017 sur ebay) sous debian, et actuellement posé à côté de ma box internet.
</p>
<p>
Certaines données pouvant vous concerner peuvent être y conservées dessus (pas plus d'un an). Elles ne seront jamais vendues ni transmises à des tiers.
<a href="http://l3m.in/p/up/files/1539952451.png">Voilà à quoi il ressemble</a> (todo = remplacer image par photo de l'ordi).
</p>
</article>
<hr />
<article>
<h3>À propos du logo</h3>
......
......@@ -8,7 +8,7 @@
<article>
<h3><a href="/article/<?php echo $blogpost['link']; ?>"><?php echo $blogpost['title']; ?></a></h3>
<p class="postInfos">
Le <time datetime="<?php echo $blogpost['time']; ?>"><?php echo date_format($blogpost['datetime'], 'd/m/Y à H:i'); ?></time>, pas de commentaire
Le <time datetime="<?php echo $blogpost['time']; ?>"><?php echo date_format($blogpost['datetime'], 'd/m/Y à H:i'); ?></time>.
</p>
<section>
<p>
......
......@@ -9,15 +9,11 @@
foreach ($blogposts as $blogpost){
$blogpost['link'] = urlencode(str_replace(' ', '-', $blogpost['title']));
$blogpost['datetime'] = new DateTime($blogpost['time']);
if(!$hr)
$hr = true;