From a511593da994da9ba3fc47adcdb32fe63ac73b5e Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Mon, 21 May 2018 16:48:06 +0200 Subject: transfert --- class/class.aff.php | 105 ++++++++++++++++++++++++++++++----------------- class/class.app.php | 71 +++++++++++++++++++++++++++++--- class/class.art.php | 10 +++++ class/class.media.php | 110 +++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 251 insertions(+), 45 deletions(-) (limited to 'class') diff --git a/class/class.aff.php b/class/class.aff.php index a62274e..3ae4662 100644 --- a/class/class.aff.php +++ b/class/class.aff.php @@ -17,7 +17,7 @@ class Aff public function lecture(Art $art, App $app) { - echo ''; + echo '
'; if ($art->secure() == 1) { echo '

cet article est privé

'; } @@ -28,6 +28,7 @@ class Aff if ($this->session() >= $art->secure()) { ?>
+

titre() ?>

soustitre() ?>
+
html($app) ?>
'; + echo '
'; } public function edit(Art $art, $list) @@ -60,7 +62,7 @@ class Aff if ($this->session() >= self::$edit) { ?> - +
@@ -85,11 +87,17 @@ class Aff
- + '; - echo '
'; - echo ''; - echo ''; - echo ''; ?> - +
+ + + + '; + ?> + + + + + + + + + + +
'; - echo ''; - echo ''; + } public function head($title, $tool) @@ -149,7 +167,8 @@ public function head($title, $tool) ?> - + + <?= $title ?> @@ -174,7 +193,7 @@ public function head($title, $tool) public function tag($getlist, $tag) { - echo ''; + echo '
'; echo ' '; - echo ' '; + echo '
'; } public function lien($getlist, $lien) { - echo ''; + echo '
'; echo ' '; - echo ' '; + echo '
'; } public function home($getlist) @@ -236,7 +255,7 @@ public function head($title, $tool) public function home2($getlist) { - echo ''; + echo '
'; if ($this->session() >= 2) { echo ' '; } - echo ' '; + echo '
'; } public function home2table($getlist) { - echo ''; + echo '
'; echo '
'; echo '

W

'; $this->search(); if ($this->session() >= 2) { echo '

Home

'; echo ''; - echo ''; + echo ''; foreach ($getlist as $item) { - $count = 0; + $liento = 0; + $lienfrom = 0; foreach ($getlist as $lien) { if (in_array($item->id(), $lien->lien('array'))) { - $count++; + $liento++; } } + foreach ($item->lien('array') as $count) { + $lienfrom++; + } echo ''; echo ''; echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''; } echo '
titrerésumélienedit
titrerésumélien fromlien todernière modifdate de créationedit
' . $item->titre() . '' . $item->intro() . '' . $count . '' . $lienfrom . '' . $liento . '' . $item->datemodif('hrdi') . '' . $item->datecreation('hrdi') . 'modifier
'; } echo '
'; - echo ' '; + echo '
'; } public function aside($list) @@ -314,7 +340,7 @@ public function head($title, $tool) if (isset($_GET['id'])) { if ($this->session() == 0) { ?> -
+ @@ -324,7 +350,7 @@ public function head($title, $tool) } if ($this->session() >= 1) { ?> - +
@@ -372,13 +398,16 @@ public function head($title, $tool) if ($this->session() >= 2) { ?> +
+ Add Media

Ajouter un media

-
+ +
bdd->query($select); while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) { $list[] = new Art($donnees); @@ -114,8 +114,6 @@ class App $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); $art->updatelien(); - var_dump($now); - $q = $this->bdd->prepare('UPDATE art SET titre = :titre, soustitre = :soustitre, intro = :intro, tag = :tag, datecreation = :datecreation, datemodif = :datemodif, css = :css, html = :html, secure = :secure, couleurtext = :couleurtext, couleurbkg = :couleurbkg, couleurlien = :couleurlien, couleurlienblank = :couleurlienblank, lien = :lien, template = :template WHERE id = :id'); $q->bindValue(':id', $art->id()); @@ -138,6 +136,11 @@ class App $q->execute(); } + + + +// __________________________________________ M E D ________________________________________________________ + public function addmedia(array $file, $maxsize, $id) { $maxsize = 2 ** 40; @@ -149,6 +152,7 @@ class App if (in_array($extension_upload, $extensions_autorisees)) { if (!file_exists('../media/' . $id . '.' . $extension_upload)) { + $extension_upload = strtolower($extension_upload); $uploadok = move_uploaded_file($file['media']['tmp_name'], '../media/' . $id . '.' . $extension_upload); if ($uploadok) { header('Location: ./?message=uploadok'); @@ -166,6 +170,63 @@ class App } } + + public function getmedia($entry) + { + $fileinfo = pathinfo($entry); + + $filepath = $fileinfo['dirname'] . '.' . $fileinfo['extension']; + + list($width, $height, $type, $attr) = getimagesize($filepath); + + echo 'filepath : ' . $filepath; + + $donnes = array( + 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']), + 'path' => $fileinfo['dirname'], + 'extension' => $fileinfo['extension'] + ); + + + + return new Art($donnees); + + } + + public function getlistermedia($dir) + { + if ($handle = opendir($dir)) { + $list = []; + while (false !== ($entry = readdir($handle))) { + if ($entry != "." && $entry != "..") { + $fileinfo = pathinfo($entry); + + $filepath = $dir . $fileinfo['filename'] . '.' . $fileinfo['extension']; + + list($width, $height, $type, $attr) = getimagesize($filepath); + $filesize = filesize($filepath); + + $donnees = array( + 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']), + 'path' => $fileinfo['dirname'], + 'extension' => $fileinfo['extension'], + 'size' => $filesize, + 'width' => $width, + 'height' => $height + ); + + $list[] = new Media($donnees); + + } + } + return $list; + } + + return $list; + + } + + //_________________________________________________________ S E S ________________________________________________________ public function login($pass) diff --git a/class/class.art.php b/class/class.art.php index 2b03a7d..2b67611 100644 --- a/class/class.art.php +++ b/class/class.art.php @@ -20,6 +20,7 @@ class Art private $couleurlien; private $couleurlienblank; private $lien; + private $template; const LEN = 255; const LENHTML = 20000; @@ -64,6 +65,7 @@ a:hover {}'); $this->setcouleurlien('#000000'); $this->setcouleurlienblank('#000000'); $this->setlien(''); + $this->settemplate(''); } public function updatelien() @@ -110,6 +112,9 @@ a:hover {}'); return $this->datecreation->format('Y-m-d H:i:s'); } elseif ($option == 'date') { return $this->datecreation; + } elseif ($option == 'hrdi') { + $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); + return hrdi($this->datecreation->diff($now)); } } @@ -120,6 +125,9 @@ a:hover {}'); return $this->datemodif->format('Y-m-d H:i:s'); } elseif ($option == 'date') { return $this->datemodif; + } elseif ($option == 'hrdi') { + $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); + return hrdi($this->datemodif->diff($now)); } } @@ -167,6 +175,8 @@ a:hover {}'); $html = str_replace('href="http', ' class="external" target="_blank" href="http', $html); $html = str_replace('src="/', 'src="../media/', $html); + $html = str_replace('
', $html); return $html; diff --git a/class/class.media.php b/class/class.media.php index e144776..e5056c9 100644 --- a/class/class.media.php +++ b/class/class.media.php @@ -3,14 +3,120 @@ class Media { private $id; + private $path; private $extension; private $type; private $size; - private $height; private $width; + private $height; -} +// _____________________________________________________ F U N ____________________________________________________ + + public function __construct(array $donnees) + { + $this->hydrate($donnees); + } + + public function hydrate(array $donnees) + { + foreach ($donnees as $key => $value) { + $method = 'set' . $key; + + if (method_exists($this, $method)) { + $this->$method($value); + } + } + } + + + +// _________________________________________________ G E T ____________________________________________________ + + public function id() + { + return $this->id; + } + + public function path() + { + return $this->path; + } + + public function extension() + { + return $this->extension; + } + + public function type() + { + return $this->type; + } + + public function size() + { + return $this->size; + } + + public function width() + { + return $this->width; + } + + public function height() + { + return $this->height; + } + +// ___________________________________________________ S E T __________________________________________________ + + public function setid($id) + { + if (strlen($id) < 40 and is_string($id)) { + $this->id = strip_tags(strtolower($id)); + } + } + + public function setpath($path) + { + if (strlen($path) < 40 and is_string($path)) { + $this->path = strip_tags(strtolower($path)); + } + } + + public function setextension($extension) + { + if (strlen($extension) < 7 and is_string($extension)) { + $this->extension = strip_tags(strtolower($extension)); + } + } + + public function setsize($size) + { + if (40 and is_int($size)) { + $this->size = strip_tags(strtolower($size)); + } + } + + public function setwidth($width) + { + if (is_int($width)) { + $this->width = strip_tags(strtolower($width)); + } + } + + public function setheight($height) + { + if (is_int($height)) { + $this->height = strip_tags(strtolower($height)); + } + } + + + + + +} ?> \ No newline at end of file -- cgit v1.2.3