il n'y a pas eu de leak de mot de passe ici ;)
0
CHANGELOG.md
Normal file → Executable file
47
bdd_proj.sql
Normal file → Executable file
@ -11,6 +11,8 @@ CREATE TABLE posts (
|
||||
title VARCHAR(32),
|
||||
url VARCHAR(32),
|
||||
content TEXT,
|
||||
short varchar(256),
|
||||
dt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
categorie INT,
|
||||
author INT
|
||||
);
|
||||
@ -33,11 +35,10 @@ CREATE TABLE tag (
|
||||
|
||||
CREATE TABLE categories (
|
||||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
url VARCHAR(32),
|
||||
name VARCHAR(32)
|
||||
);
|
||||
|
||||
CREATE TABLE user (
|
||||
CREATE TABLE users (
|
||||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(128),
|
||||
linkedin VARCHAR(560)
|
||||
@ -45,13 +46,47 @@ CREATE TABLE user (
|
||||
|
||||
|
||||
ALTER TABLE post_tag
|
||||
ADD FOREIGN KEY (post_id) REFERENCES posts(post_id);
|
||||
ADD FOREIGN KEY (post_id) REFERENCES posts(id);
|
||||
|
||||
ALTER TABLE post_tag
|
||||
ADD FOREIGN KEY (categorie) REFERENCES tag(categorie);
|
||||
ADD FOREIGN KEY (categorie) REFERENCES tag(id);
|
||||
|
||||
ALTER TABLE posts
|
||||
ADD FOREIGN KEY (categorie) REFERENCES categories(id)
|
||||
ADD FOREIGN KEY (categorie) REFERENCES categories(id);
|
||||
|
||||
ALTER TABLE posts
|
||||
ADD FOREIGN KEY (author) REFERENCES users(id)
|
||||
ADD FOREIGN KEY (author) REFERENCES users(id);
|
||||
|
||||
|
||||
-- posts
|
||||
INSERT INTO posts (title, url, content, short, categorie, author)
|
||||
VALUES ('pokemon', 'pokemon', 'cacacacacacacacacacacacaca\r\ncacacacacacacacacacacacaca\r\ncacacacacacacacacacacacaca', 'caca', 1, 2),
|
||||
('Pokemon Go', 'pokemon-go', 'I PLAY POKEMON GO EVERYDAY', 'I PLAY POKEMON GO', 2, 1);
|
||||
|
||||
-- users
|
||||
INSERT INTO users (username, linkedin) VALUES ('Florian Bouillon', NULL), ('Adrien huchet', 'adrienhuchet');
|
||||
|
||||
-- categories
|
||||
INSERT INTO categories (name) VALUES ('devops'), ('ops'), ('dev'), ('digi');
|
||||
|
||||
-- requete 1 :
|
||||
-- recuperer 10 posts avec la categorie associé la date du post et les 256 premiers mots du contenu
|
||||
|
||||
SELECT title, short, categorie, url FROM posts
|
||||
LIMIT 10;
|
||||
|
||||
-- requete 2 :
|
||||
-- recuperer 1 post son titre, Categories, dates, contenu, nom_auteur, photo_auteur, lien linkedin
|
||||
|
||||
SELECT post.title as title, post.categorie as categorie, post.date as date, post.content as content, user.username as author, user.linkedin as linkedin
|
||||
FROM post
|
||||
INNER JOIN users BY post.author=user.id
|
||||
LIMIT 1;
|
||||
|
||||
-- requette 3 : comme la 1 sauf uniquement les 6 posts les plus récents
|
||||
-- requete lancée lors sur la page d'accueil
|
||||
SELECT title, categories.name as categorie, dt as date, short as content
|
||||
FROM posts
|
||||
INNER JOIN categories ON categories.id=posts.categorie
|
||||
ORDER BY date DESC
|
||||
LIMIT 6;
|
||||
|
14
index.html
Executable file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Page Title</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="main.css">
|
||||
<script src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
pouet
|
||||
</body>
|
||||
</html>
|
18
project/.htaccess
Normal file → Executable file
@ -36,20 +36,26 @@ Options All -Indexes
|
||||
|
||||
# lorsque qu'une url va correspondre a un fichier finissant par .php ou .html on interdit l'acces (retourne une erreur 403 (ensuite geré par notre ligne plus haut))
|
||||
<FilesMatch ".*\.(php|html)$">
|
||||
Order Allow,Deny
|
||||
Deny from all
|
||||
# Order Allow,Deny
|
||||
# Deny from all
|
||||
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
|
||||
# on donne l'autorisation d'acceder au fichier handler.php (sinon le site ne sera pas foncitonnel)
|
||||
<FilesMatch "handler.php">
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
# Order Allow,Deny
|
||||
# Allow from all
|
||||
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
|
||||
# on donne acces au fichiers webmanifest et svg
|
||||
<FilesMatch ".*\.(webmanifest|svg)$">
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
# Order Allow,Deny
|
||||
# Allow from all
|
||||
|
||||
Require all granted
|
||||
</FilesMatch>
|
||||
|
||||
# si le serveur apache a le module mod_deflate.c
|
||||
|
40
project/assets/css/style.css
Normal file → Executable file
@ -63,14 +63,9 @@ h2{
|
||||
font-weight: 600;
|
||||
font-size: 17px;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
.test{
|
||||
height: 300vh;
|
||||
=======
|
||||
|
||||
.contenue{
|
||||
height: 285vh;
|
||||
>>>>>>> 5029010f15d22427dc323fafc747a1a08afbeb77
|
||||
}
|
||||
.articleHome{
|
||||
margin: auto;
|
||||
@ -193,7 +188,7 @@ h2{
|
||||
.bloc-plus{
|
||||
margin-top: 40px;
|
||||
float: right;
|
||||
background-color: #190034;;
|
||||
background-color: #190034;
|
||||
padding: 10px 15px;
|
||||
color: white;
|
||||
}
|
||||
@ -327,21 +322,44 @@ input {outline: none}
|
||||
}
|
||||
|
||||
.fullFooter{
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
width: 100%;
|
||||
height: 220px;
|
||||
background-color: grey;
|
||||
background-color: #190034;
|
||||
font-weight: bold;
|
||||
}
|
||||
.iconFooter{
|
||||
.upFooter{
|
||||
height: 160px;
|
||||
background-color: lightgray;
|
||||
background-color: #42027e;
|
||||
text-align: center;
|
||||
}
|
||||
.lowFooter{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.lowFooterItem{
|
||||
font-size:16px;
|
||||
color: white;
|
||||
padding-top:22px;
|
||||
display: inline-block;
|
||||
margin-right:15px;
|
||||
}
|
||||
.iconOnFooter{
|
||||
padding-top:125px;
|
||||
padding-top:60px;
|
||||
display: inline-block;
|
||||
color: black;
|
||||
|
||||
}
|
||||
|
||||
.pad{
|
||||
padding:0;
|
||||
}
|
||||
|
||||
.phraseFooter{
|
||||
font-size: 18px;
|
||||
padding-top:10px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#twi{
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
|
0
project/assets/font/blod.otf
Normal file → Executable file
0
project/assets/font/roman.otf
Normal file → Executable file
0
project/assets/html/404.html
Normal file → Executable file
17
project/assets/html/includes/footer.html
Normal file → Executable file
@ -1,15 +1,24 @@
|
||||
<footer>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="col-12 pad">
|
||||
<div class="fullFooter">
|
||||
<div class="iconFooter">
|
||||
<div class="upFooter">
|
||||
<ul>
|
||||
<li class="iconOnFooter"><a><tag type="svg" file="twitter" style="color: white; width: 18px; height: 18px"/></a></li>
|
||||
<li class="iconOnFooter"><a><tag type="svg" file="facebook" style="color: white; width: 18px; height: 18px"/></a></li>
|
||||
<li class="iconOnFooter"><a><tag type="svg" file="twitter" style="color: white; width: 18px; height: 18px"/></a></li>
|
||||
</ul>
|
||||
<p class="phraseFooter">Suivez-nous sur les réxseaux</p>
|
||||
</div>
|
||||
<div class="lowFooter">
|
||||
<ul>
|
||||
<li class="lowFooterItem">Politique et confidentialité</li>
|
||||
<li class="lowFooterItem">Mentions légales</li>
|
||||
<li class="lowFooterItem">Contact</li>
|
||||
<li class="lowFooterItem">Connexion</li>
|
||||
</ul>
|
||||
</div>
|
||||
</dwhite
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
14
project/assets/html/includes/head.html
Normal file → Executable file
@ -1,8 +1,6 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Page Title</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css"/>
|
||||
</head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Page Title</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css"/>
|
4
project/assets/html/includes/header.html
Normal file → Executable file
@ -6,8 +6,8 @@
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<ul>
|
||||
<li class="item_nav_imie" ><a>Connexion</a></li>
|
||||
<li class="item_nav_imie" ><a>Accès Net-Yparéo</a></li>
|
||||
<li class="item_nav_imie" ><a>IMIE Numérique</a></li>
|
||||
<li class="item_nav_imie" ><a>Accès Net-Yparéo</a></li>
|
||||
<li class="item_nav_imie" ><a>IMIE Numérique</a></li>
|
||||
<li class="item_nav_imie" ><a><tag type="svg" file="twitter" style="color: white; width: 18px; height: 18px"/></a></li>
|
||||
<li class="item_nav_imie" ><a><tag type="svg" file="facebook" style="color: white; width: 18px; height: 18px"/></a></li>
|
||||
</ul>
|
||||
|
198
project/assets/html/index.html
Normal file → Executable file
@ -1,145 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<tag type="includes" file="header" />
|
||||
</header>
|
||||
<main class="contenue container">
|
||||
<div class="bloc_principal">
|
||||
<div class="cover-black">
|
||||
<div class="bloc_principal_titre">
|
||||
<h1>L'actualité de nos campus...</h1>
|
||||
</div>
|
||||
<div class="articleHome">
|
||||
<h2 id="titre-home">Ceci est un magnifique titre</h2>
|
||||
<p class="p-home">
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
|
||||
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
||||
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
|
||||
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
|
||||
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<div class="bloc-plus">
|
||||
En savoir plus
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 id="titre-between">Articles récents</h3>
|
||||
<div class="row articles">
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article dev">
|
||||
<h4 class="title">Mettre en place un serveur web sous linux</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
DEV
|
||||
</span>
|
||||
<span class="date">
|
||||
26-06-2018
|
||||
</span>
|
||||
</div>
|
||||
<p class="text">
|
||||
Dum apud Persas, ut supra narravimus, perfidia regis motus agitat insperatos,
|
||||
et in eois tractibus bella rediviva consurgunt, anno sexto decimo et eo diutius
|
||||
post Nepotiani exitium, saeviens per urbem aeternam urebat cuncta Bellona, ex primordiis
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article digi">
|
||||
<h4 class="title">Mettre en place un serveur web sous linux</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
DIGI
|
||||
</span>
|
||||
<span class="date">
|
||||
26-06-2018
|
||||
</span>
|
||||
</div>
|
||||
<p class="text">Dum apud Persas, ut supra narravimus, perfidia regis motus agitat insperatos,
|
||||
et in eois tractibus bella rediviva consurgunt, anno sexto decimo et eo diutius
|
||||
post Nepotiani exitium, saeviens per urbem aeternam urebat cuncta Bellona, ex primordiis
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article ops">
|
||||
<h4 class="title">Mettre en place un serveur web sous linux</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
OPS
|
||||
</span>
|
||||
<span class="date">
|
||||
26-06-2018
|
||||
</span>
|
||||
</div>
|
||||
<p class="text">Dum apud Persas, ut supra narravimus, perfidia regis motus agitat insperatos,
|
||||
et in eois tractibus bella rediviva consurgunt, anno sexto decimo et eo diutius
|
||||
post Nepotiani exitium, saeviens per urbem aeternam urebat cuncta Bellona, ex primordiis
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article ops">
|
||||
<h4 class="title">Mettre en place un serveur web sous linux</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
OPS
|
||||
</span>
|
||||
<span class="date">
|
||||
26-06-2018
|
||||
</span>
|
||||
</div>
|
||||
<p class="text">Dum apud Persas, ut supra narravimus, perfidia regis motus agitat insperatos,
|
||||
et in eois tractibus bella rediviva consurgunt, anno sexto decimo et eo diutius
|
||||
post Nepotiani exitium, saeviens per urbem aeternam urebat cuncta Bellona, ex primordiis
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article devops">
|
||||
<h4 class="title">Mettre en place un serveur web sous linux</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
DEVOPS
|
||||
</span>
|
||||
<span class="date">
|
||||
26-06-2018
|
||||
</span>
|
||||
</div>
|
||||
<p class="text">Dum apud Persas, ut supra narravimus, perfidia regis motus agitat insperatos,
|
||||
et in eois tractibus bella rediviva consurgunt, anno sexto decimo et eo diutius
|
||||
post Nepotiani exitium, saeviens per urbem aeternam urebat cuncta Bellona, ex primordiis
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<html lang="fr">
|
||||
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article ops">
|
||||
<h4 class="title">Mettre en place un serveur web sous linux</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
OPS
|
||||
</span>
|
||||
<span class="date">
|
||||
26-06-2018
|
||||
</span>
|
||||
</div>
|
||||
<p class="text">Dum apud Persas, ut supra narravimus, perfidia regis motus agitat insperatos,
|
||||
et in eois tractibus bella rediviva consurgunt, anno sexto decimo et eo diutius
|
||||
post Nepotiani exitium, saeviens per urbem aeternam urebat cuncta Bellona, ex primordiis
|
||||
</p>
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<tag type="includes" file="header" />
|
||||
</header>
|
||||
<main class="test container">
|
||||
<div class="bloc_principal">
|
||||
<div class="cover-black">
|
||||
<div class="bloc_principal_titre">
|
||||
<h1>L'actualité de nos campus...</h1>
|
||||
</div>
|
||||
<div class="test2">
|
||||
<h2 id="titre-home">Ceci est un magnifique titre</h2>
|
||||
<p class="p-home">
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
|
||||
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
|
||||
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
|
||||
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
|
||||
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
<div class="bloc-plus">
|
||||
En savoir plus
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
</footer>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</div>
|
||||
</div>
|
||||
<h3 id="titre-between">Articles récents</h3>
|
||||
<div class="row articles">
|
||||
<tag type="loop" for="posts" limit="6">
|
||||
<div class="col-12 col-md-6 col-lg-4">
|
||||
<div class="article column-categorie">
|
||||
<h4 class="title">
|
||||
<loop column="title" />
|
||||
</h4>
|
||||
<div class="etiquettes">
|
||||
<span class="cat">
|
||||
<loop column="categorie" />
|
||||
</span>
|
||||
<span class="date">
|
||||
<loop column="date" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="text">
|
||||
<loop column="content" />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</tag>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<tag type="includes" file="footer" />
|
||||
</footer>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
|
||||
crossorigin="anonymous"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
0
project/assets/html/post.html
Normal file → Executable file
0
project/assets/html/search.html
Normal file → Executable file
0
project/assets/img/facebook.svg
Normal file → Executable file
Before Width: | Height: | Size: 376 B After Width: | Height: | Size: 376 B |
0
project/assets/img/img-home.jpg
Normal file → Executable file
Before Width: | Height: | Size: 931 KiB After Width: | Height: | Size: 931 KiB |
2
project/assets/img/logo-imie-blog.svg
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 738.1 233.6" style="enable-background:new 0 0 738.1 233.6;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFFFFF;}
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
2
project/assets/img/mignify.svg
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFFFFF;}
|
||||
|
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 634 B |
0
project/assets/img/search-solid.svg
Normal file → Executable file
Before Width: | Height: | Size: 559 B After Width: | Height: | Size: 559 B |
0
project/assets/img/twitter.svg
Normal file → Executable file
Before Width: | Height: | Size: 1007 B After Width: | Height: | Size: 1007 B |
0
project/assets/js/script.js
Normal file → Executable file
20
project/assets/php/functions.php
Normal file → Executable file
@ -9,3 +9,23 @@ function endsWith($haystack, $needle) {
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
$host = "127.0.0.1";
|
||||
$db = "blog";
|
||||
$user = "username";
|
||||
$pass = "motdepasse";
|
||||
$charset="utf8mb4";
|
||||
|
||||
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
||||
try {
|
||||
$pdo = new PDO($dsn, $user, $pass);
|
||||
} catch (\PDOException $e) {
|
||||
throw new \PDOException($e->getMessage(), (int)$e->getCode());
|
||||
}
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
function getBDD() {
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
require_once "functions.php";
|
||||
ini_set('display_errors', 'On');
|
||||
|
||||
//renvoie vers le fichier css si il est demand<EFBFBD>
|
||||
//renvoie vers le fichier css si il est demandé
|
||||
if(endsWith($_GET["page"], ".css")) {
|
||||
echo file_get_contents("../css/style.css");
|
||||
die;
|
||||
}
|
||||
|
||||
//renvoie vers le fichier js si demand<EFBFBD>
|
||||
//renvoie vers le fichier js si demandé
|
||||
if(endsWith($_GET["page"], ".js")) {
|
||||
echo file_get_contents("../js/script.js");
|
||||
die;
|
||||
@ -22,10 +22,10 @@ if($_GET["page"] != "" && !endsWith($_GET["page"], "/") && sizeof($_GET) <= 1) {
|
||||
die;
|
||||
}
|
||||
|
||||
//enleve les / du d<EFBFBD>but & fin
|
||||
//enleve les / du début & fin
|
||||
$_GET['page'] = trim($_GET['page'], '/');
|
||||
|
||||
// si taille sup<EFBFBD>rieur <20> 1 $_getpost = element
|
||||
// si taille supérieur à 1 $_getpost = element
|
||||
if(sizeof(explode("/", $_GET["page"])) > 1) {
|
||||
$_GET["post"] = explode("/", $_GET["page"])[1];
|
||||
}
|
||||
@ -42,13 +42,14 @@ if(strlen($_GET['page']) > 1) {
|
||||
|
||||
//page de test pour des functions
|
||||
// A ENLEVER LORS DES COMMITS DE FIN
|
||||
if($_GET["page"] == "test") {
|
||||
// var_dump($_GET);
|
||||
if($_GET["page"] == "/test/") {
|
||||
include_once "test.php";
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* D<EFBFBD>marrage du routage du contenu
|
||||
* Démarrage du routage du contenu
|
||||
*/
|
||||
|
||||
include_once "router.php";
|
||||
@ -60,7 +61,4 @@ include_once "pages.php";
|
||||
include_once "tagHandler.php";
|
||||
$pokemon = loadTags($router->search($_GET["page"])(), false);
|
||||
|
||||
//TODO trouver pourquoi il y a un pb avec l'UTF-8
|
||||
//(actuellement forcer des compiler en "Windows 1252")
|
||||
$pokemon = htmlspecialchars_decode($pokemon, ENT_HTML5);
|
||||
echo $pokemon;
|
||||
|
2
project/assets/php/pages.php
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
include_once "router.php";
|
||||
|
||||
//recupération du router
|
||||
//recupération du router
|
||||
$router = Router::getRouter();
|
||||
|
||||
//page d'accueil
|
||||
|
4
project/assets/php/router.php
Normal file → Executable file
@ -12,11 +12,11 @@ class Router {
|
||||
|
||||
//definit le router
|
||||
public function __construct() {
|
||||
//TODO faire que si un router existe dajà retourner le routeur existant
|
||||
//TODO faire que si un router existe déjà retourner le routeur existant
|
||||
Router::$router = $this;
|
||||
}
|
||||
|
||||
//fonction static pour recuperer un router déjà créé
|
||||
//fonction static pour recuperer un router déjà crée
|
||||
public static function getRouter() {
|
||||
return Router::$router;
|
||||
}
|
||||
|
77
project/assets/php/tagHandler.php
Normal file → Executable file
@ -35,7 +35,7 @@ class Bold extends Tag {
|
||||
public function render() {
|
||||
//recuperation de la balise de base (<tag type="bold">pouet</tag>)
|
||||
$pok = $this->getDOM();
|
||||
//recuperation du document (necessaire a la création de balises
|
||||
//recuperation du document (necessaire a la cr<EFBFBD>ation de balises
|
||||
$doc = $this->getDoc();
|
||||
//creation de la balise "span"
|
||||
$res = $doc->createElement("span");
|
||||
@ -150,6 +150,7 @@ class Includes extends Tag {
|
||||
// var_dump($attr);
|
||||
// var_dump(file_get_contents("../html/includes/".$attr.".html"));
|
||||
$p = file_get_contents("../html/includes/".$attr.".html");
|
||||
|
||||
// var_dump($p);
|
||||
appendHTML($el->parentNode, $p);
|
||||
$el->setAttribute("style", $el->getAttribute("style"));
|
||||
@ -171,7 +172,10 @@ class Svg extends Tag {
|
||||
}
|
||||
|
||||
/**
|
||||
* input <tag type="loop" for="(table)" limit="(nombre-max généré)" />
|
||||
* input
|
||||
* <tag type="loop" for="(table)" limit="(nombre-max g<>n<EFBFBD>r<EFBFBD>)">
|
||||
* <loop column="element"/>
|
||||
* </tag>
|
||||
* return something
|
||||
*/
|
||||
class Loop extends Tag {
|
||||
@ -182,59 +186,40 @@ class Loop extends Tag {
|
||||
|
||||
$limit = (int) $el->getAttribute("limit");
|
||||
|
||||
//testing purpose variable
|
||||
$posts = array(
|
||||
array(
|
||||
'title'=> "a",
|
||||
'url'=> "e",
|
||||
'content'=> "<p>i</p>",
|
||||
'date'=> "2018-09-20"
|
||||
),
|
||||
array(
|
||||
'title'=> "b",
|
||||
'url'=> "f",
|
||||
'content'=> "<p>j</p>",
|
||||
'date'=> "2018-09-21"
|
||||
),
|
||||
array(
|
||||
'title'=> "c",
|
||||
'url'=> "g",
|
||||
'content'=> "<p>k</p>",
|
||||
'date'=> "2018-09-22"
|
||||
),
|
||||
array(
|
||||
'title'=> "d",
|
||||
'url'=> "h",
|
||||
'content'=> "<p>l</p>",
|
||||
'date'=> "2018-09-23"
|
||||
),
|
||||
array(
|
||||
'title'=> "z",
|
||||
'url'=> "z",
|
||||
'content'=> "<p>z</p>",
|
||||
'date'=> "2018-10-23"
|
||||
),
|
||||
);
|
||||
require_once 'functions.php';
|
||||
|
||||
//if($limit == 0) $limit = count($posts);
|
||||
$pdo = connect();
|
||||
$query = $pdo->query("SELECT title, categories.name as categorie, dt as date, short as content
|
||||
FROM posts
|
||||
INNER JOIN categories ON categories.id=posts.categorie
|
||||
ORDER BY date DESC
|
||||
LIMIT 6;");
|
||||
$posts = $query->fetchAll();
|
||||
|
||||
$parent = $el->parentNode;
|
||||
//var_dump($parent);
|
||||
for ($i=0; $i < $limit; $i++) {
|
||||
//var_dump($i);
|
||||
$pok = $el->childNodes->item(1)->cloneNode(true);
|
||||
$pok = $el->childNodes->item(0)->cloneNode(true);
|
||||
|
||||
$parent->insertBefore($pok, $el);
|
||||
|
||||
$elements = $pok->getElementsByTagName("loop");
|
||||
|
||||
foreach ($elements as $ele) {
|
||||
if($ele->getAttribute("column") == "content") {
|
||||
appendHTML($ele, $posts[$i][$ele->getAttribute("column")]);
|
||||
appendHTML($ele->parentNode, $posts[$i]["content"]);
|
||||
} else {
|
||||
$txt = $doc->createTextNode($posts[$i][$ele->getAttribute("column")]);
|
||||
$ele->parentNode->insertBefore($txt, $ele);
|
||||
}
|
||||
}
|
||||
|
||||
$finder = new DomXPath($doc);
|
||||
$nodes = $finder->query("//*[contains(@class, 'column-cat')]");
|
||||
// var_dump($nodes);
|
||||
if(sizeof($nodes) >= 1) $nodes[0]->setAttribute("class", str_replace("column-categorie", $posts[$i]["categorie"], $nodes[0]->getAttribute("class")));
|
||||
|
||||
}
|
||||
|
||||
$loop = $parent->getElementsByTagName("loop");
|
||||
@ -251,7 +236,13 @@ function appendHTML(DOMNode $parent, $source) {
|
||||
$html = "<html><body>";
|
||||
$html .= $source;
|
||||
$html .= "</body></html>";
|
||||
$tmpDoc->loadHTML($html);
|
||||
$tmpDoc->loadHTML('<?xml encoding="UTF-8">'.$html);
|
||||
|
||||
foreach ($tmpDoc->childNodes as $item)
|
||||
if ($item->nodeType == XML_PI_NODE)
|
||||
$tmpDoc->removeChild($item);
|
||||
$tmpDoc->encoding = 'UTF-8';
|
||||
|
||||
foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) {
|
||||
$importedNode = $parent->ownerDocument->importNode($node, true);
|
||||
$parent->appendChild($importedNode);
|
||||
@ -262,9 +253,15 @@ function appendHTML(DOMNode $parent, $source) {
|
||||
function loadTags($ctnt) {
|
||||
$dom = new DOMDocument();
|
||||
libxml_use_internal_errors(true);
|
||||
$dom->loadHTML($ctnt);
|
||||
$dom->loadHTML('<?xml encoding="UTF-8">'.$ctnt);
|
||||
libxml_clear_errors();
|
||||
|
||||
// fix UTF-8 problem
|
||||
foreach ($dom->childNodes as $item)
|
||||
if ($item->nodeType == XML_PI_NODE)
|
||||
$dom->removeChild($item);
|
||||
$dom->encoding = 'UTF-8';
|
||||
|
||||
$list = $dom->getElementsByTagName("tag");
|
||||
|
||||
$head = $dom->getElementsByTagName("head");
|
||||
|
@ -1,57 +1,11 @@
|
||||
<?php
|
||||
var_dump($_POST);
|
||||
$target_dir = dirname(__FILE__, 3) . "/uploads/".date("Y")."/".date("m")."/";
|
||||
|
||||
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
||||
$uploadOk = 1;
|
||||
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
|
||||
// Check if image file is a actual image or fake image
|
||||
if(isset($_POST["upload"])) {
|
||||
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
|
||||
if($check !== false) {
|
||||
echo "File is an image - " . $check["mime"] . ".";
|
||||
$uploadOk = 1;
|
||||
} else {
|
||||
echo "File is not an image.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
include_once "functions.php";
|
||||
$pdo = connect();
|
||||
$query = $pdo->query("SELECT title, categorie, dt as date, short as content
|
||||
FROM posts
|
||||
ORDER BY date DESC
|
||||
LIMIT 6");
|
||||
while($row = $query->fetch()) {
|
||||
echo $row["title"];
|
||||
}
|
||||
// Check if file already exists
|
||||
if (file_exists($target_file)) {
|
||||
echo "Sorry, file already exists.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
// Check file size
|
||||
if ($_FILES["fileToUpload"]["size"] > 500000) {
|
||||
echo "Sorry, your file is too large.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
// Allow certain file formats
|
||||
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
|
||||
&& $imageFileType != "gif" ) {
|
||||
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
|
||||
$uploadOk = 0;
|
||||
}
|
||||
// Check if $uploadOk is set to 0 by an error
|
||||
if ($uploadOk == 0) {
|
||||
echo "Sorry, your file was not uploaded.";
|
||||
// if everything is ok, try to upload file
|
||||
} else {
|
||||
if(!is_dir($target_dir)) {
|
||||
mkdir($target_dir, 0777, true);
|
||||
}
|
||||
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
|
||||
echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
|
||||
} else {
|
||||
echo "Sorry, there was an error uploading your file.";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<form action="/test/" method="post" enctype="multipart/form-data">
|
||||
Select image to upload:
|
||||
<input type="file" name="fileToUpload" id="fileToUpload">
|
||||
<input type="submit" value="i-play-pokemon-go-everyday" name="upload">
|
||||
</form>
|
||||
|
||||
// var_dump(connect());
|