From aad58a057640120027650ab3847212ba1178538e Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 18 Mar 2018 20:20:03 +0100 Subject: version 01 --- class/class.aff.php | 195 ++++++++++++++++++++++++++++++ class/class.app.php | 51 +++++--- class/class.art.php | 340 +++++++++++++++++++++------------------------------- 3 files changed, 365 insertions(+), 221 deletions(-) create mode 100644 class/class.aff.php (limited to 'class') 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 @@ +setsession($session); + } + + public function lecture(Art $art) + { + if($art->secure() == 1) { + echo '

cet article est privé

'; + } + if($art->secure() == 2) { + echo "

cet article n'est pas publié

"; + } + + if ($this->session() >= $art->secure()) { + ?> + +
+

titre() ?>

+

soustitre() ?>

+

html('html') ?>

+
+ session() >= self::$edit) { + + ?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + <?= $title ?> + + '; + foreach ($list as $item) { + echo '
  • ' . $item['titre'] . ' - ' . $item['intro']; + if ($this->session() >= 2) { + echo ' - modifier
  • '; + } else { + echo ''; + } + } + echo ' '; + } + + public function aside($list) + { + if ($this->session() >= 2) { + echo ' '; + } + } + + public function nav($app) + { + ?> + + = 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 ' '; + $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 @@ 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) { - - ?> -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - = $this->secure()) { - - ?> - -
    -

    titre() ?>

    -

    soustitre() ?>

    -

    intro() ?>

    -

    html() ?>

    -
    - 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)); + } } -} } -- cgit v1.2.3