Commit d38afd22 authored by Corentin Bettiol's avatar Corentin Bettiol 💻

add basic admin view

parent 2ae140cc
...@@ -25,10 +25,10 @@ CSS ...@@ -25,10 +25,10 @@ CSS
font-family: ubuntumono; font-family: ubuntumono;
background-color: #f0f0f0; background-color: #f0f0f0;
padding: 2px; padding: 2px;
border-bottom: 5px solid #cccccc; border-bottom: 5px solid #ccc;
} }
article p, #pageTitle, article h3, article ul{ article p, #pageTitle, article h3, article ul, article form{
max-width: 1500px; max-width: 1500px;
margin: 30px auto; margin: 30px auto;
} }
...@@ -63,7 +63,6 @@ h2{ ...@@ -63,7 +63,6 @@ h2{
font-size: 1.5em; font-size: 1.5em;
} }
h3 a{ h3 a{
text-decoration: none; text-decoration: none;
text-shadow: 0 0 1px #69f; text-shadow: 0 0 1px #69f;
...@@ -106,12 +105,9 @@ article{ ...@@ -106,12 +105,9 @@ article{
background-color: #f0f0f0; background-color: #f0f0f0;
} }
section{
}
#listMenu .selected{ #listMenu .selected{
padding-bottom: 2px; padding-bottom: 2px;
border-bottom: 5px solid #cccccc; border-bottom: 5px solid #ccc;
} }
article .postInfos{ article .postInfos{
...@@ -129,7 +125,7 @@ article .postInfos{ ...@@ -129,7 +125,7 @@ article .postInfos{
hr{ hr{
width: 66%; width: 66%;
border: 1px solid #CFCFCF; border: 1px solid #ccc;
} }
a{ a{
...@@ -141,6 +137,42 @@ a:hover{ ...@@ -141,6 +137,42 @@ a:hover{
transition: color 0.3s; transition: color 0.3s;
} }
input{
width: 50%;
display: block;
box-sizing: border-box;
margin: 15px auto;
padding: 10px;
font-size: 1em;
}
input[type="text"], input[type="password"]{
background-color: white;
border: none;
padding-left: 13px;
border-bottom: 3px solid #ccc;
border-left: 0px solid #ccc;
transition: border-left 0.05s, padding-left 0.05s;
}
input[type="text"]:hover, input[type="password"]:hover, input[type="text"]:focus, input[type="password"]:focus{
border-left: 3px solid #ccc;
padding-left: 10px;
transition: border-left 0.05s, padding-left 0.05s;
}
input[type="submit"]{
background-color: #ccc;
border: none;
transition: background-color 0.3s;
}
input[type="submit"]:hover{
background-color: #ddd;
transition: background-color 0.3s;
}
/* /*
==== ====
......
<?php <?php
session_start();
require_once("site/controller/mainController.php"); require_once("site/controller/mainController.php");
require_once("site/layout/layout.php"); require_once("site/layout/layout.php");
......
<?php <?php
ini_set('display_errors','on');
error_reporting(E_ALL|E_STRICT);
require_once("site/model/config.php"); require_once("site/model/config.php");
require_once("site/model/Base.php"); require_once("site/model/Base.php");
...@@ -31,6 +29,12 @@ function getPageName(){ ...@@ -31,6 +29,12 @@ function getPageName(){
case 'article': case 'article':
return [$_GET['title'], $_GET['title']]; return [$_GET['title'], $_GET['title']];
break; break;
case 'patate':
return ["Administration", "administration"];
break;
case 'eplucher':
return ["prout hihi", "eplucher"];
break;
default: default:
return ["Blog", "blog"]; return ["Blog", "blog"];
break; break;
...@@ -44,6 +48,7 @@ function getPageName(){ ...@@ -44,6 +48,7 @@ function getPageName(){
function writeMenu($pageName){ function writeMenu($pageName){
?> ?>
<ul id="listMenu"> <ul id="listMenu">
<?php if($pageName == "Administration"){ ?><li><h2><a href="/eplucher" class="selected">🔧</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="/" 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="/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"){ ?>class="selected"<?php } ?>>Projets</a></h2></li> <li><h2><a href="/projects" title="Projets" <?php if($pageName == "Projets"){ ?>class="selected"<?php } ?>>Projets</a></h2></li>
...@@ -51,8 +56,6 @@ function writeMenu($pageName){ ...@@ -51,8 +56,6 @@ function writeMenu($pageName){
</ul> </ul>
<?php } <?php }
function writeBlogPage($pageName){ function writeBlogPage($pageName){
if($pageName[1] == "blog"){ if($pageName[1] == "blog"){
...@@ -67,7 +70,7 @@ function writeBlogPage($pageName){ ...@@ -67,7 +70,7 @@ function writeBlogPage($pageName){
header("Location:/404"); header("Location:/404");
} }
else{ else{
$blogposts = $blog->getBlog(); $blogposts = $blog->getBlog(0);
require("site/view/public/blogView.php"); require("site/view/public/blogView.php");
} }
} }
...@@ -82,6 +85,35 @@ function writeProjectsPage($pageName){ ...@@ -82,6 +85,35 @@ function writeProjectsPage($pageName){
require("site/view/public/projectsView.php"); require("site/view/public/projectsView.php");
} }
function loginAdminPage($pageName){
if(password_verify($_POST['pass'], pass) && $_POST['user'] == user){
$_SESSION['user'] = $_POST['user'];
$_SESSION['pass'] = $_POST['pass'];
header("Location:/patate");
}
else
echo "nan";
}
function writeAdminPage($pageName){
if(verifyAdminConnect())
require("site/view/private/admin.php");
else{
require("site/view/private/loginFormView.php");
}
}
function verifyAdminConnect(){
return isset($_SESSION['user']) && $_SESSION['user'] == user && isset($_SESSION['pass']) && password_verify($_SESSION['pass'], pass);
}
function decoAdminPage(){
$_SESSION = array();
header("Location:/");
}
$pageName = getPageName(); $pageName = getPageName();
\ No newline at end of file
...@@ -55,6 +55,17 @@ ...@@ -55,6 +55,17 @@
case '404': case '404':
require("site/view/public/404.php"); require("site/view/public/404.php");
break; break;
case 'administration':
if(isset($_POST['user']) && isset($_POST['pass'])){
loginAdminPage($pageName);
}
else{
writeAdminPage($pageName);
}
break;
case 'eplucher':
decoAdminPage();
break;
default: default:
# code... # code...
...@@ -65,7 +76,7 @@ ...@@ -65,7 +76,7 @@
<footer id="footer"> <footer id="footer">
<p> <p>
Site créé par Corentin Bettiol - <a href="/changelog" title="changelog">Changelog</a> - <a href="/rss" title="rss">RSS</a> - v5 Site en vanilla html5/css3/php7, fait avec ♥ - <a href="/changelog" title="changelog">Changelog</a> - <a href="/rss" title="rss">RSS</a> - v5
</p> </p>
</footer> </footer>
......
<?php <?php
class BlogManager extends Base class BlogManager extends Base
{ {
public function getBlog() public function getBlog($page)
{ {
$start = $page*5;
$stop = $start + 5;
$db = $this->dbConnect(); $db = $this->dbConnect();
$req = $db->query('SELECT * FROM l3m_blog ORDER BY id DESC LIMIT 0, 5'); $req = $db->prepare('SELECT * FROM l3m_blog ORDER BY id DESC LIMIT '. $start .', '. $stop .'');
$posts = $req->fetch();
return $req; return $posts;
} }
public function getBlogPost($link) public function getBlogPost($link)
......
<?php <?php
// config file // config file
// rename this file config.php
// database config // database config
...@@ -8,3 +9,9 @@ ...@@ -8,3 +9,9 @@
define('dbName', ''); define('dbName', '');
define('dbUser', ''); define('dbUser', '');
define('dbPass', ''); define('dbPass', '');
// login config
define('user', '');
define('pass', '');
\ No newline at end of file
<article>
<h3>🔧 Administration</h3>
<p>Todo : toutes les fonctionnalités hyper chiadées & ultra stylées.</p>
<nav>
<ul>
<li><a href="/patatedouce/b">Nouveau post du blog</a></li>
<li><a href="/patatedouce/lb">Lister les articles</a></li>
<li><a href="/patatedouce/p">Nouveau projet</a></li>
<li><a href="/patatedouce/lp">Lister les projets</a></li>
</ul>
</nav>
</article>
\ No newline at end of file
<article>
<h3>Connexion à la partie administration du site</h3>
<p>Attention au ban ip à partir de deux erreurs !</p>
<form action="/patate" method="post" accept-charset="utf-8">
<input type="text" name="user" placeholder="Pseudonyme" />
<input type="password" name="pass" placeholder="Mot de passe" />
<input type="submit" value="Connexion" />
</form>
</article>
...@@ -10,6 +10,6 @@ ...@@ -10,6 +10,6 @@
<div id="videoFond"> <div id="videoFond">
<video autoplay loop> <video autoplay loop>
<source type="video/mp4" src="/img/CloudsLoop.mp4" media="(orientation: landscape)"> <source type="video/mp4" src="/img/CloudsLoop.mp4" media="(orientation: landscape)" />
</video> </video>
</div> </div>
\ No newline at end of file
<article> <article>
<h3>12/01/19</h3> <h3>13/01/19</h3>
<ul>
<li>Ajout du formulaire au panneau d'administration</li>
<li>Stockage du hash du mdp dans le fichier config.php, utilisation de verify_hash() pour la connexion</li>
<li>Affichage d'une vue sommaire pour le panneau d'administration</li>
</ul>
</article>
<article>
<h3><a href="https://git.bitmycode.com/sodimel/l3m-website/commit/2ae140cc39ec43e1a9da520e988fc42d172d29c8" title="commit 2ae140cc">12/01/19</a></h3>
<ul> <ul>
<li>Modifications mineures css</li> <li>Modifications mineures css</li>
......
RewriteEngine On RewriteEngine On
RewriteRule /(about|changelog|blog|rss|projects|contact|login) /index.php?action=$1 RewriteRule /(about|changelog|blog|rss|projects|contact|patate|eplucher)$ /index.php?action=$1
RewriteRule /article/([a-zA-Z0-9\-]*)$ /index.php?action=blog&title=$1 RewriteRule /article/([a-zA-Z0-9\-]*)$ /index.php?action=blog&title=$1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment