diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-03-18 20:20:03 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-03-18 20:20:03 +0100 |
commit | aad58a057640120027650ab3847212ba1178538e (patch) | |
tree | 4df845231c53b88e35e4e3f2225eb70cfde3c21b | |
parent | 2060e198b1f9ac41deee93848417121fb1c066f5 (diff) | |
download | wcms-aad58a057640120027650ab3847212ba1178538e.tar.gz wcms-aad58a057640120027650ab3847212ba1178538e.zip |
version 01
-rw-r--r-- | class/class.aff.php | 195 | ||||
-rw-r--r-- | class/class.app.php | 51 | ||||
-rw-r--r-- | class/class.art.php | 340 | ||||
-rw-r--r-- | fn/fn.php | 1 | ||||
-rw-r--r-- | public/css/style.css | 72 | ||||
-rw-r--r-- | public/index.php | 50 | ||||
-rw-r--r-- | public/w/art.php | 0 | ||||
-rw-r--r-- | public/w/art_create.php | 0 | ||||
-rw-r--r-- | public/w/art_delete.php | 0 | ||||
-rw-r--r-- | public/w/art_display.php | 0 | ||||
-rw-r--r-- | public/w/art_edit.php | 0 | ||||
-rw-r--r-- | public/w/index.php | 131 |
12 files changed, 496 insertions, 344 deletions
diff --git a/class/class.aff.php b/class/class.aff.php new file mode 100644 index 0000000..2558c24 --- /dev/null +++ b/class/class.aff.php @@ -0,0 +1,195 @@ +<?php + +class Aff +{ + + private $session; + + private static $edit = 2; + + + // ____________________________________________________ F U N ______________________________________________ + + public function __construct($session) + { + $this->setsession($session); + } + + public function lecture(Art $art) + { + if($art->secure() == 1) { + echo '<span class="alert"><h4>cet article est privé</h4></span>'; + } + if($art->secure() == 2) { + echo "<span class=\"alert\"><h4>cet article n'est pas publié</h4></span>"; + } + + if ($this->session() >= $art->secure()) { + ?> + <style type="text/css"> + article { + background: <?= $art->couleurbkg() ?>; + color: <?= $art->couleurtext() ?>; + } + + a { + color: <?= $art->couleurlien() ?>; + } + <?= $art->css() ?> + </style> + <article> + <h1><?= $art->titre() ?></h1> + <h2><?= $art->soustitre() ?></h2> + <p><?= $art->html('html') ?></p> + </article> + <?php + + } + } + + public function edit(Art $art) + { + if ($this->session() >= self::$edit) { + + ?> + <article> + <form class="edit" action="?id=<?= $art->id() ?>" method="post"> + <input type="submit" value="modifier"> + <label for="titre">Titre :</label> + <input type="text" name="titre" id="titre" value="<?= $art->titre(); ?>"> + <label for="soustitre">Sous-titre :</label> + <input type="text" name="soustitre" id="soustitre" value="<?= $art->soustitre(); ?>"> + <label for="intro">Introduction :</label> + <input type="text" name="intro" id="intro" value="<?= $art->intro(); ?>"> + <label for="tag">Tag(s) :</label> + <input type="text" name="tag" id="tag" value="<?= $art->tag(); ?>"> + <label for="css">Styles CSS :</label> + <textarea name="css" id="css"><?= $art->css(); ?></textarea> + <label for="secure">Niveau de sécuritée :</label> + <select name="secure" id="secure"> + <option value="0" <?= $art->secure() == 0 ? 'selected' : '' ?>>0</option> + <option value="1" <?= $art->secure() == 1 ? 'selected' : '' ?>>1</option> + <option value="2" <?= $art->secure() == 2 ? 'selected' : '' ?>>2</option> + </select> + <label for="couleurtext">Couleur du texte :</label> + <input type="color" name="couleurtext" value="<?= $art->couleurtext() ?>" id="couleurtext"> + <label for="couleurbkg">Couleur de l'arrière plan :</label> + <input type="color" name="couleurbkg" value="<?= $art->couleurbkg() ?>" id="couleurbkg"> + <label for="couleurlien">Couleur des liens :</label> + <input type="color" name="couleurlien" value="<?= $art->couleurlien() ?>" id="couleurlien"> + <label for="html">Contenu :</label> + <textarea name="html" id="html" ><?= $art->html('md'); ?></textarea> + <input type="hidden" name="datecreation" value="<?= $art->datecreation('string'); ?>"> + <input type="hidden" name="id" value="<?= $art->id() ?>"> + <input type="hidden" name="action" value="update"> + <input type="submit" value="modifier"> + </form> + </article> + + <?php + + } + + } + + public function head($title) { + ?> + <head> + <meta charset="utf8" /> + <link href="/css/style.css" rel="stylesheet" /> + <title><?= $title ?></title> + </head> + <?php + } + + public function home($list) + { + echo '<ul>'; + foreach ($list as $item) { + echo '<li><a href="?id=' . $item['id'] . '">' . $item['titre'] . '</a> - ' . $item['intro']; + if ($this->session() >= 2) { + echo ' - <a href="?id=' . $item['id'] . '&edit=1">modifier</a></li>'; + } else { + echo '</li>'; + } + } + echo ' </ul> '; + } + + public function aside($list) + { + if ($this->session() >= 2) { + echo '<aside><ul>'; + foreach ($list as $item) { + echo '<li><a href="?id=' . $item['id'] . '&edit=1">' . $item['titre'] . '</a> - <code>[' . $item['titre'] . '](?id=' . $item['id'].')</code>'; + + + } + echo ' </ul></aside> '; + } + } + + public function nav($app) + { + ?> + <nav> + <?= $this->session() ?> + <a href="?" >home</a> + <?php + if ($this->session() >= 1) { + if(isset($_GET['id'])){ + ?> + <form action="?id=<?= $_GET['id'] ?>" method="post"> + <input type="hidden" name="action" value="logout"> + <input type="submit" value="disconnect"> + </form> + <?php + } + if(isset($_GET['id']) AND $app->exist($_GET['id']) AND $this->session() == 2) + { + ?> + <a href="?id=<?= $_GET['id'] ?>&display=1" target="_blank">display</a> + <a href="?id=<?= $_GET['id'] ?>&edit=1" >edit</a> + <?php + } + } + else + { + if(isset($_GET['id'])){ + ?> + <form action="?id=<?= $_GET['id'] ?>" method="post"> + <input type="hidden" name="action" value="login"> + <input type="password" name="pass" id="pass" placeholder="password"> + <input type="submit" value="connect"> + </form> + <?php + } + } + ?> + </nav> + <?php + } + + //______________________________________________________ S E T _________________________________________________ + + public function setsession($session) + { + if ($session <= 2 and $session >= 0) { + $session = intval($session); + $this->session = $session; + } + } + + //______________________________________________________ G E T _________________________________________________ + + public function session() + { + return $this->session; + } + + +} + + + +?>
\ No newline at end of file diff --git a/class/class.app.php b/class/class.app.php index ad62c25..ab67fdc 100644 --- a/class/class.app.php +++ b/class/class.app.php @@ -2,20 +2,19 @@ class App { private $bdd; + private $admin; + private $secure; public function __construct($config) { + $this->admin = $config['admin']; + $this->secure = $config['secure']; + try { $this->bdd = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'] . ';charset=utf8', $config['user'], $config['password']); } catch (Exeption $e) { die('Erreur : ' . $e->getMessage()); } - - // try { - // $this->bdd = new PDO('mysql:host=localhost;dbname=wcms;charset=utf8', 'root', ''); - // } catch (Exeption $e) { - // die('Erreur : ' . $e->getMessage()); - // } } public function add(Art $art) @@ -37,7 +36,7 @@ class App $q->bindValue(':datecreation', $now->format('Y-m-d H:i:s')); $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s')); $q->bindValue(':css', $art->css()); - $q->bindValue(':html', $art->html()); + $q->bindValue(':html', $art->html('md')); $q->bindValue(':secure', $art->secure()); $q->bindValue(':couleurtext', $art->couleurtext()); $q->bindValue(':couleurbkg', $art->couleurbkg()); @@ -77,19 +76,13 @@ class App return $list; } - public function menu($session) + public function list() { $req = $this->bdd->query('SELECT * FROM art ORDER BY id'); - echo '<ul>'; - while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) { - echo '<li><a href="?id=' . $donnees['id'] . '&display=1">' . $donnees['titre'] . '</a> - ' . $donnees['intro']; - if ($session >= 2) { - echo ' - <a href="?id=' . $donnees['id'] . '&edit=1">modifier</a></li>'; - } else { - echo '</li>'; - } - } - echo ' </ul> '; + $donnees = $req->fetchAll(PDO::FETCH_ASSOC); + return $donnees; + + $req->closeCursor(); } @@ -121,7 +114,7 @@ class App $q->bindValue(':datecreation', $art->datecreation('string')); $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s')); $q->bindValue(':css', $art->css()); - $q->bindValue(':html', $art->html()); + $q->bindValue(':html', $art->html('md')); $q->bindValue(':secure', $art->secure()); $q->bindValue(':couleurtext', $art->couleurtext()); $q->bindValue(':couleurbkg', $art->couleurbkg()); @@ -130,5 +123,25 @@ class App $q->execute(); } + //_________________________________________________________ S E S ________________________________________________________ + + public function login($pass) + { + if(strip_tags($pass) == $this->admin) + { + var_dump($this->admin); + $_SESSION['level'] = 2; + } + elseif(strip_tags($pass) == $this->secure) + { + $_SESSION['level'] = 1; + } + } + + public function logout() + { + $_SESSION['level'] = 0; + } + } ?>
\ No newline at end of file diff --git a/class/class.art.php b/class/class.art.php index bf2aeef..54fa28d 100644 --- a/class/class.art.php +++ b/class/class.art.php @@ -1,5 +1,7 @@ <?php +use Michelf\Markdown; + class Art { private $id; @@ -20,7 +22,6 @@ class Art private static $lenhtml = 65535; private static $securemax = 2; private static $lencouleur = 7; - private static $edit = 2; // _____________________________________________________ F U N ____________________________________________________ @@ -50,7 +51,7 @@ class Art $this->setintro('resumé'); $this->settag('sans tag,'); $this->setdatecreation($now); - $this->setcss('display: inline;'); + $this->setcss(''); $this->sethtml('contenu'); $this->setsecure(2); $this->setcouleurtext('#000000'); @@ -58,253 +59,188 @@ class Art $this->setcouleurlien('#000000'); } - public function edit($session) - { - if ($session >= self::$edit) { - - ?> - <article> - <form class="edit" action="?id=<?= $this->id() ?>" method="post"> - <label for="titre">Titre :</label> - <input type="text" name="titre" id="titre" value="<?= $this->titre(); ?>"> - <label for="soustitre">Sous-titre :</label> - <input type="text" name="soustitre" id="soustitre" value="<?= $this->soustitre(); ?>"> - <label for="intro">Introduction :</label> - <input type="text" name="intro" id="intro" value="<?= $this->intro(); ?>"> - <label for="tag">Tag(s) :</label> - <input type="text" name="tag" id="tag" value="<?= $this->tag(); ?>"> - <label for="css">Styles CSS :</label> - <input type="text" name="css" id="css" value="<?= $this->css(); ?>"> - <label for="secure">Niveau de sécuritée :</label> - <select name="secure" id="secure"> - <option value="0" <?= $this->secure() == 0 ? 'selected' : '' ?>>0</option> - <option value="1" <?= $this->secure() == 1 ? 'selected' : '' ?>>1</option> - <option value="2" <?= $this->secure() == 2 ? 'selected' : '' ?>>2</option> - </select> - <label for="couleurtext">Couleur du texte :</label> - <input type="color" name="couleurtext" value="<?= $this->couleurtext() ?>" id="couleurtext"> - <label for="couleurbkg">Couleur de l'arrière plan :</label> - <input type="color" name="couleurbkg" value="<?= $this->couleurbkg() ?>" id="couleurbkg"> - <label for="couleurlien">Couleur des liens :</label> - <input type="color" name="couleurlien" value="<?= $this->couleurlien() ?>" id="couleurlien"> - <label for="html">Contenu :</label> - <textarea name="html" id="html" ><?= $this->html(); ?></textarea> - <input type="hidden" name="datecreation" value="<?= $this->datecreation('string'); ?>"> - <input type="hidden" name="id" value="<?= $this->id() ?>"> - <input type="hidden" name="action" value="update"> - <input type="submit" value="modifier"> - </form> - </article> - - <?php - -} - -} - -public function display($session) -{ - if ($session >= $this->secure()) { - - ?> - <style> - article { - background: <?= $this->couleurbkg() ?>; - color: <?= $this->couleurtext() ?>; - } - - a { - color: <?= $this->couleurlien() ?>; - } - <?= $this->css() ?> - </style> - <article> - <h1><?= $this->titre() ?></h1> - <h2><?= $this->soustitre() ?></h2> - <h3><?= $this->intro() ?></h3> - <p><?= $this->html() ?></p> - </article> - <?php - -} - -} - // _____________________________________________________ G E T ____________________________________________________ -public function id() -{ - return $this->id; -} + public function id() + { + return $this->id; + } -public function titre() -{ - return $this->titre; -} + public function titre() + { + return $this->titre; + } -public function soustitre() -{ - return $this->soustitre; -} + public function soustitre() + { + return $this->soustitre; + } -public function intro() -{ - return $this->intro; -} + public function intro() + { + return $this->intro; + } -public function tag() -{ - return $this->tag; -} + public function tag() + { + return $this->tag; + } -public function datecreation($option) { - if ($option == 'string') { - return $this->datecreation->format('Y-m-d H:i:s'); - } elseif($option == 'date') { - return $this->datecreation; + public function datecreation($option) + { + if ($option == 'string') { + return $this->datecreation->format('Y-m-d H:i:s'); + } elseif ($option == 'date') { + return $this->datecreation; + } } -} -public function datemodif($option) { - if ($option == 'string') { - return $this->datemodif->format('Y-m-d H:i:s'); - } elseif($option == 'date') { - return $this->datemodif; + public function datemodif($option) + { + if ($option == 'string') { + return $this->datemodif->format('Y-m-d H:i:s'); + } elseif ($option == 'date') { + return $this->datemodif; + } } -} -public function css() -{ - return $this->css; -} + public function css() + { + return $this->css; + } -public function html() -{ - return $this->html; -} + public function html($option) + { + if ($option == 'md') { + return $this->html; + } elseif ($option == 'html') { + return Markdown::defaultTransform($this->html); + } + // return $this->html; + } -public function secure() -{ - return $this->secure; -} + public function secure() + { + return $this->secure; + } -public function couleurtext() -{ - return $this->couleurtext; -} + public function couleurtext() + { + return $this->couleurtext; + } -public function couleurbkg() -{ - return $this->couleurbkg; -} + public function couleurbkg() + { + return $this->couleurbkg; + } -public function couleurlien() -{ - return $this->couleurlien; -} + public function couleurlien() + { + return $this->couleurlien; + } // _____________________________________________________ S E T ____________________________________________________ -public function setid($id) -{ - if (strlen($id) < self::$len and is_string($id)) { - $this->id = strip_tags(strtolower(str_replace(" ", "", $id))); + public function setid($id) + { + if (strlen($id) < self::$len and is_string($id)) { + $this->id = strip_tags(strtolower(str_replace(" ", "", $id))); + } } -} -public function settitre($titre) -{ - if (strlen($titre) < self::$len and is_string($titre)) { - $this->titre = strip_tags(trim($titre)); + public function settitre($titre) + { + if (strlen($titre) < self::$len and is_string($titre)) { + $this->titre = strip_tags(trim($titre)); + } } -} -public function setsoustitre($soustitre) -{ - if (strlen($soustitre) < self::$len and is_string($soustitre)) { - $this->soustitre = strip_tags(trim($soustitre)); + public function setsoustitre($soustitre) + { + if (strlen($soustitre) < self::$len and is_string($soustitre)) { + $this->soustitre = strip_tags(trim($soustitre)); + } } -} -public function setintro($intro) -{ - if (strlen($intro) < self::$len and is_string($intro)) { - $this->intro = strip_tags(trim($intro)); + public function setintro($intro) + { + if (strlen($intro) < self::$len and is_string($intro)) { + $this->intro = strip_tags(trim($intro)); + } } -} -public function settag($tag) -{ - if (strlen($tag) < self::$len and is_string($tag)) { - $this->tag = strip_tags(trim(strtolower($tag))); + public function settag($tag) + { + if (strlen($tag) < self::$len and is_string($tag)) { + $this->tag = strip_tags(trim(strtolower($tag))); + } } -} -public function setdatecreation($datecreation) -{ - if ($datecreation instanceof DateTimeImmutable) { - $this->datecreation = $datecreation; - } else { - $this->datecreation = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datecreation, new DateTimeZone('Europe/Paris')); + public function setdatecreation($datecreation) + { + if ($datecreation instanceof DateTimeImmutable) { + $this->datecreation = $datecreation; + } else { + $this->datecreation = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datecreation, new DateTimeZone('Europe/Paris')); + } } -} -public function setdatemodif($datemodif) -{ - if ($datemodif instanceof DateTimeImmutable) { - $this->datemodif = $datemodif; - } else { - $this->datemodif = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datemodif, new DateTimeZone('Europe/Paris')); + public function setdatemodif($datemodif) + { + if ($datemodif instanceof DateTimeImmutable) { + $this->datemodif = $datemodif; + } else { + $this->datemodif = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datemodif, new DateTimeZone('Europe/Paris')); + } } -} -public function setcss($css) -{ - if (strlen($css) < self::$len and is_string($css)) { - $this->css = strip_tags(trim(strtolower($css))); + public function setcss($css) + { + if (strlen($css) < self::$len and is_string($css)) { + $this->css = strip_tags(trim(strtolower($css))); + } } -} -public function sethtml($html) -{ - if (strlen($html) < self::$lenhtml and is_string($html)) { - $this->html = $html; + public function sethtml($html) + { + if (strlen($html) < self::$lenhtml and is_string($html)) { + $this->html = $html; + } } -} -public function setsecure($secure) -{ - if ($secure >= 0 and $secure <= self::$securemax) { - $this->secure = intval($secure); + public function setsecure($secure) + { + if ($secure >= 0 and $secure <= self::$securemax) { + $this->secure = intval($secure); + } } -} -public function setcouleurtext($couleurtext) -{ - $couleurtext = strval($couleurtext); - if (strlen($couleurtext) <= self::$lencouleur) { - $this->couleurtext = strip_tags(trim($couleurtext)); + public function setcouleurtext($couleurtext) + { + $couleurtext = strval($couleurtext); + if (strlen($couleurtext) <= self::$lencouleur) { + $this->couleurtext = strip_tags(trim($couleurtext)); + } } -} -public function setcouleurbkg($couleurbkg) -{ - $couleurbkg = strval($couleurbkg); - if (strlen($couleurbkg) <= self::$lencouleur) { - $this->couleurbkg = strip_tags(trim($couleurbkg)); + public function setcouleurbkg($couleurbkg) + { + $couleurbkg = strval($couleurbkg); + if (strlen($couleurbkg) <= self::$lencouleur) { + $this->couleurbkg = strip_tags(trim($couleurbkg)); + } } -} -public function setcouleurlien($couleurlien) -{ - $couleurlien = strval($couleurlien); - if (strlen($couleurlien) <= self::$lencouleur) { - $this->couleurlien = strip_tags(trim($couleurlien)); + public function setcouleurlien($couleurlien) + { + $couleurlien = strval($couleurlien); + if (strlen($couleurlien) <= self::$lencouleur) { + $this->couleurlien = strip_tags(trim($couleurlien)); + } } -} } @@ -30,5 +30,6 @@ function head($title) { </head> <?php } + ?> diff --git a/public/css/style.css b/public/css/style.css index ca04f38..245258c 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1,6 +1,25 @@ -body {background-color: #dcdcdceb;} +body { + background-color: #dcdcdceb; -input, textarea, select { +} + +h1 { + font-size: 3em; +} + +h2 { + font-style: italic; +} + +h3 { + opacity: 0.7; +} + +p{ + font-size: 1.1em; +} + +article input, textarea, select { width: 90%; padding-left: 15px; padding-right: 15px; @@ -10,6 +29,51 @@ input, textarea, select { height: 30px; border-style: unset; } -textarea { - height: 1000px; +#html{ + height: 400px; +} + +#css{ + height: 100px; +} + +input[type="submit"] { + background-color: #bfbfbf; +} + +aside { + position: fixed; + bottom: 0px; + right: -300px; + padding: 7px; + z-index: 5; + background: coral; + opacity: 0.3; + width: 350px; +} + +aside:hover { + opacity: 0.9; + right: 0px; +} + +nav { + position: fixed; + top: 0px; + right: -50px; + padding: 7px; + z-index: 10; + background: #5085ff; + opacity: 0.3; + width:100px; +} + +nav:hover { + opacity: 0.9; + right: 0px; +} + +.alert h4 { + background-color: red; + margin: 0px; }
\ No newline at end of file diff --git a/public/index.php b/public/index.php index 9b8a61b..2409769 100644 --- a/public/index.php +++ b/public/index.php @@ -1,51 +1,3 @@ <html> <a href="/w/">w</a> -</html> - -<?php - -try -{ - $bdd = new PDO('mysql:host=localhost;dbname=wcms;charset=utf8', 'root', ''); -} -catch(Exception $e) -{ - die('Erreur : '.$e->getMessage()); -} - -// $reponse = $bdd->query('SELECT nom, age FROM art2 WHERE nom = \'eddie\''); - -// while ($donnees = $reponse->fetch()) -// { -// echo $donnees['nom'] . ' a ' . $donnees['age'] . ' ANS<br />'; -// } - -// $reponse->closeCursor(); - -// $req = $bdd->prepare('SELECT nom, age FROM art2 WHERE age = 23 '); -// $req->execute(array($_GET['possesseur'], $_GET['prix_max'])); - -// echo '<ul>'; -// while ($donnees = $req->fetch()) -// { -// echo '<li>' . $donnees['nom'] . ' (' . $donnees['prix'] . ' EUR)</li>'; -// } -// echo '</ul>'; - -// $req->closeCursor(); - -$req = $bdd->prepare('SELECT * FROM art WHERE id = :id '); -$req->execute(array('id' => 'articlet')); - -echo '<ul>'; -while ($donnees = $req->fetch()) -{ - echo '<li>' . $donnees['titre'] . ' (' . $donnees['id'] . ' ANS)</li>'; -} -echo '</ul>'; - -$req->closeCursor(); - - - -?>
\ No newline at end of file +</html>
\ No newline at end of file diff --git a/public/w/art.php b/public/w/art.php deleted file mode 100644 index e69de29..0000000 --- a/public/w/art.php +++ /dev/null diff --git a/public/w/art_create.php b/public/w/art_create.php deleted file mode 100644 index e69de29..0000000 --- a/public/w/art_create.php +++ /dev/null diff --git a/public/w/art_delete.php b/public/w/art_delete.php deleted file mode 100644 index e69de29..0000000 --- a/public/w/art_delete.php +++ /dev/null diff --git a/public/w/art_display.php b/public/w/art_display.php deleted file mode 100644 index e69de29..0000000 --- a/public/w/art_display.php +++ /dev/null diff --git a/public/w/art_edit.php b/public/w/art_edit.php deleted file mode 100644 index e69de29..0000000 --- a/public/w/art_edit.php +++ /dev/null diff --git a/public/w/index.php b/public/w/index.php index 41137d0..6148dee 100644 --- a/public/w/index.php +++ b/public/w/index.php @@ -1,95 +1,86 @@ <?php -//inw + +// _____________________________________________________ R E Q U I R E ________________________________________________________________ + + +$_SESSION['level'] = 0; + +$config = require('../../config.php'); +require('../../vendor/autoload.php'); +use Michelf\Markdown; require('../../fn/fn.php'); require('../../class/class.art.php'); require('../../class/class.app.php'); -$config = include('../../config.php'); -$app = new App($config); - +require('../../class/class.aff.php'); session(); +$app = new App($config); +$aff = new Aff($_SESSION['level']); -// fin de in +// _____________________________________________________ A C T I O N __________________________________________________________________ -head('article'); +if (isset($_POST['action'])) { + switch ($_POST['action']) { + + case 'update': + if ($app->exist($_GET['id'])) { + $art = new Art($_POST); + $app->update($art); + header('Location: ?id=' . $art->id() . '&edit=1'); + } + break; + + case 'login' : + $app->login($_POST['pass']); + header('Location: ?id=' . $_GET['id']); + break; + + case 'logout' : + $app->logout(); + header('Location: ?id=' . $_GET['id']); + break; + } + +} -// $art = new Art([ -// 'id' => 'prout', -// 'titre' => 'Prout', -// 'soustitre' => 'mega prout !', -// 'intro' => 'bienvenue dans le mega prout', -// 'datemodif' => new DateTimeImmutable(null, timezone_open("Europe/Paris")) -// ]); -// $arraytest = ([ -// 'id' => 'articlet2', -// 'titre' => 'titre', -// 'soustitre' => 'soustitre', -// 'intro' => 'intro', -// 'tag' => 'sans tag,', -// 'datecreation' => '2018-03-17 18:31:34', -// 'datemodif' => '2018-03-17 18:31:34', -// 'css' => 'display: inline:', -// 'html' => 'coucou les loulous', -// 'secure' => 0, -// 'couleurtext' => '#000000', -// 'couleurbkg' => '#ffffff', -// 'couleurlien' => '#2a3599' -// ]); -// $art = new Art($arreytest); +// _______________________________________________________ H E A D _____________________________________________________________ +$titre = 'home'; +if (isset($_GET['id'])) { + $titre = $_GET['id']; + if ($app->exist($_GET['id'])) { + $art = $app->get($_GET['id']); + $titre = $art->titre(); + } +} +$aff->head($titre); -// echo '<pre>'; -// print_r($art); -// print_r($app); -// echo '</pre>'; -// $app->add($art); -// echo '<p>art count :' . $app->count() . '</p>'; -// echo '<p>article exist :' . $app->exist('articlet') . '</p>'; -// var_dump($app->exist('articlet')); +// ______________________________________________________ B O D Y _______________________________________________________________ -$session = 2; +echo '<body>'; +$aff->nav($app); if (isset($_GET['id'])) { - - if ($session == 2) { - ?> - <nav> - <a href="?" >home</a> - <a href="?id=<?= $_GET['id'] ?>&display=1" target="_blank">display</a> - <a href="?id=<?= $_GET['id'] ?>&edit=1" >edit</a> - </nav> - <?php -} + if ($app->exist($_GET['id'])) { + + $art = $app->get($_GET['id']); -if ($app->exist($_GET['id'])) { - - if (isset($_POST['action']) and $_POST['action'] == 'update') { - $art = new Art($_POST); - var_dump($art); - $app->update($art); - header('Location: ?id=' . $art->id() . '&edit=1'); - - } - - $art = $app->get($_GET['id']); - - - - if (isset($_GET['display']) and $_GET['display'] == 1) { - $art->display($session); - } if (isset($_GET['edit']) and $_GET['edit'] == 1) { - $art->edit($session); + $aff->edit($art); + $aff->aside($app->list()); + } else { + $aff->lecture($art); + } } else { if (isset($_POST['action'])) { @@ -101,20 +92,20 @@ if ($app->exist($_GET['id'])) { header('Location: ?id=' . $_GET['id'] . '&edit=1'); } } else { - echo '<h4>Cet article n\'éxiste pas encore</h4>'; + echo '<span class="alert"><h4>Cet article n\'existe pas encore</h4></span>'; - if ($session >= 2) { + if ($_SESSION['level'] >= 2) { echo '<form action="?id=' . $_GET['id'] . '&edit=1" method="post"><input type="hidden" name="action" value="new"><input type="submit" value="créer"></form>'; } - echo '<a href="?info=erreur">retour maison</a>'; } } } else { echo "<h4>Bienvenue sur ce site.</h4>"; - $app->menu($session); + $aff->home($app->list()); } +echo '</body>'; |