aboutsummaryrefslogtreecommitdiff
path: root/class
diff options
context:
space:
mode:
Diffstat (limited to 'class')
-rw-r--r--class/class.w.aff.php297
-rw-r--r--class/class.w.app.php202
-rw-r--r--class/class.w.art.php2
-rw-r--r--class/class.w.config.php158
-rw-r--r--class/class.w.record.php116
5 files changed, 712 insertions, 63 deletions
diff --git a/class/class.w.aff.php b/class/class.w.aff.php
index 888736a..86a9aa3 100644
--- a/class/class.w.aff.php
+++ b/class/class.w.aff.php
@@ -8,13 +8,54 @@ class Aff
private static $edit = 2;
- // ____________________________________________________ F U N ______________________________________________
+ // ________________________________________________ C O N S T R U C T ______________________________________________
+
- public function __construct($session)
+ public function __construct($session = 0)
{
$this->setsession($session);
}
+
+
+ // ____________________________________________________ C O N F I G ______________________________________________
+
+
+ public function configform()
+ {
+ ?>
+ <p>Config file does not exist yet, or maybe you deleted it ? Anyway, it is time to set it :</p>
+ <form action="" method="post">
+ <input type="hidden" name="config" value="create">
+ Database settings</br>
+ <input type="text" name="host" id="" placeholder="host"></br>
+ <input type="text" name="dbname" id="" placeholder="dbname"></br>
+ <input type="text" name="user" id="" placeholder="user"></br>
+ <input type="text" name="password" id="" placeholder="password"></br>
+ Domain name settings</br>
+ <input type="text" name="domain" id="" placeholder="domain"></br>
+ W_cms settings</br>
+ <input type="text" name="admin" id="" placeholder="W admin password" required></br>
+ <input type="hidden" name="editor" id="" value="editor">
+ <input type="hidden" name="invite" id="" value="invite">
+ <input type="hidden" name="read" id="" value="read">
+ <input type="hidden" name="cssread" id="" value="">
+ (You can change everything later, set at least your admin password, and don't forget it !)</br>
+ <input type="submit" value="create config file">
+ </form>
+ <?php
+
+ }
+
+
+
+
+
+
+
+ // ____________________________________________________ F U N ______________________________________________
+
+
public function lecture(Art $art, App $app)
{
echo '<div class="lecture">';
@@ -25,10 +66,9 @@ class Aff
echo "<span class=\"alert\"><h4>cet article n'est pas publié</h4></span>";
}
- if ($this->session() >= $art->secure()) {
+ if ($app->session() >= $art->secure()) {
?>
<style type="text/css">
- <?= $art->csstemplate($app) ?>
body{
background: <?= $art->couleurbkg() ?>;
}
@@ -39,10 +79,11 @@ class Aff
a {
color: <?= $art->couleurlien() ?>;
}
-
+
section a[target="_blank"] {
color: <?= $art->couleurlienblank() ?>;
}
+ <?= $art->csstemplate($app) ?>
</style>
<section>
<header>
@@ -57,9 +98,9 @@ class Aff
echo '</div>';
}
- public function edit(Art $art, $list)
+ public function edit(Art $art, App $app, $list)
{
- if ($this->session() >= self::$edit) {
+ if ($app->session() >= self::$edit) {
?>
<div class="edit">
@@ -160,10 +201,10 @@ public function copy(Art $art, $list)
</div>
<?php
- }
+}
- public function head($title, $tool)
- {
+public function head($title, $tool)
+{
?>
<head>
<meta charset="utf8" />
@@ -176,10 +217,10 @@ public function copy(Art $art, $list)
</head>
<?php
- }
+}
- public function arthead(Art $art, $pre = '')
- {
+public function arthead(Art $art, $cssread = '', $edit = 0)
+{
?>
<head>
<meta charset="utf8" />
@@ -188,19 +229,20 @@ public function copy(Art $art, $list)
<link rel="shortcut icon" href="../media/logo.png" type="image/x-icon">
<link href="/css/stylebase.css" rel="stylesheet" />
<link href="/css/stylew.css" rel="stylesheet" />
- <title><?= $pre ?> <?= $art->titre() ?></title>
+ <?= $edit == 0 ? '<link href="/css/lecture/' . $cssread . '" rel="stylesheet" />' : '' ?>
+ <title><?= $edit == 1 ? '✏' : '' ?> <?= $art->titre() ?></title>
<script src="../rsc/js/app.js"></script>
</head>
<?php
- }
+}
- public function search()
- {
- ?>
+public function search()
+{
+ ?>
<form action="./" method="get">
<input type="text" name="id" id="id" placeholder="identifiant article" required>
<input type="submit" value="accéder">
@@ -293,13 +335,13 @@ public function copy(Art $art, $list)
echo ' </div> ';
}
- public function home2table($getlist)
+ public function home2table(App $app, $getlist)
{
echo '<div class="home">';
echo '<section>';
echo '<h1>W</h1>';
$this->search();
- if ($this->session() >= 2) {
+ if ($app->session() >= $app::EDITOR) {
echo '<h1>Home</h1>';
echo '<table>';
echo '<tr><th><a href="./?tri=titre">titre</a></th><th>résumé</th><th>lien from</th><th>lien to</th><th><a href="./?tri=datemodif&desc=DESC">dernière modif</a></th><th><a href="./?tri=datecreation&desc=DESC">date de création</a></th><th>edit</th></tr>';
@@ -331,11 +373,11 @@ public function copy(Art $art, $list)
echo ' </div> ';
}
- public function aside($list)
+ public function aside(App $app)
{
- if ($this->session() >= 2) {
+ if ($app->session() >= $app::EDITOR) {
echo '<aside><ul>';
- foreach ($list as $item) {
+ foreach ($app->lister() as $item) {
echo '<li><a href="?id=' . $item['id'] . '&edit=1">' . $item['titre'] . '</a> - <code>[' . $item['titre'] . '](?id=' . $item['id'] . ')</code>';
@@ -347,14 +389,14 @@ public function copy(Art $art, $list)
public function nav($app)
{
echo '<nav>';
- echo $this->session();
+ //echo $this->session();
echo '</br>';
echo '<a class="button" href="?">home</a>';
- if ($this->session() == 0) {
- if(isset($_GET['id'])) {
- echo '<form action="./?id='. $_GET['id'].'" method="post">';
+ if ($app->session() == $app::FREE) {
+ if (isset($_GET['id'])) {
+ echo '<form action="./?id=' . $_GET['id'] . '" method="post">';
} else {
echo '<form action="." method="post">';
}
@@ -366,9 +408,9 @@ public function copy(Art $art, $list)
<?php
}
- if ($this->session() > 0) {
- if(isset($_GET['id'])) {
- echo '<form action="./?id='. $_GET['id'].'" method="post">';
+ if ($app->session() > $app::FREE) {
+ if (isset($_GET['id'])) {
+ echo '<form action="./?id=' . $_GET['id'] . '" method="post">';
} else {
echo '<form action="." method="post">';
}
@@ -379,14 +421,14 @@ public function copy(Art $art, $list)
<?php
}
- if ($this->session() == 2 && isset($_GET['id']) && $app->exist($_GET['id'])) {
+ if ($app->session() == $app::ADMIN && isset($_GET['id']) && $app->exist($_GET['id'])) {
if (isset($_GET['edit']) && $_GET['edit'] == 1) {
echo '<a class="button" href="?id=' . $_GET['id'] . '" target="_blank">display</a>';
} else {
echo '<a class="button" href="?id=' . $_GET['id'] . '&edit=1" >edit</a>';
}
}
- if ($this->session() == 2 && !isset($_GET['id'])) {
+ if ($app->session() == $app::ADMIN && !isset($_GET['id'])) {
echo '<a class="button" href="?aff=media" >Media</a>';
echo '<a class="button" href="?aff=record" >Record</a>';
echo '<a class="button" href="?aff=admin" >Admin</a>';
@@ -400,18 +442,6 @@ public function copy(Art $art, $list)
// ____________________________________________________ M E D ________________________________________________
- public function media()
- {
- echo '<body>';
- echo '<section>';
-
- $this->addmedia();
- $this->medialist();
-
- echo '</section>';
- echo '</body>';
-
- }
public function addmedia()
{
@@ -419,7 +449,7 @@ public function copy(Art $art, $list)
?>
<details close>
- <summary>Add Media</summary>
+ <summary>Add Media</summary>
<form action="./" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="addmedia">
<input type="file" accept="*" name="media" required>
@@ -498,12 +528,185 @@ public function copy(Art $art, $list)
}
+ //______________________________________________________ R E C _________________________________________________
+
+
+ public function recordlist(App $app, $dir = "../ACRRecordings/")
+ {
+ echo '<details open>';
+ echo '<summary>Media List</summary>';
+
+ echo '<article class="gest">';
+
+ echo '<form action="" method="post">';
+
+ echo '<ul>';
+
+ foreach ($app->getlisterrecord($dir) as $item) {
+ echo '<li>';
+
+ ?>
+ <input type="checkbox" id="<?= $item->id() ?>" name="<?= $item->id() ?>" value="1">
+ <label for="<?= $item->id() ?>"><?= $item->id() ?></label>
+ <input type="hidden" name="id" value="<?= $item->id() ?>">
+
+ <?php
+
+ $filepathurl = $dir . urlencode($item->id()) . '.' . $item->extension();
+
+ echo '<br/>';
+ var_dump($item->size());
+ var_dump(intval($item->size()));
+ echo 'filesize = ' . readablesize(intval($item->size()));
+ echo '<br/>';
+ echo 'extension = ' . $item->extension();
+ echo '<br/>';
+
+ ?>
+
+ <audio controls>
+ <source src="<?= $filepathurl ?>" type="audio/mpeg">
+ </audio>
+
+
+
+ <?php
+
+
+
+
+ echo '</li>';
+ }
+
+ echo '</ul>';
+
+ ?>
+ <select name="action" id="">
+ <option value="">compress /2</option>
+ <option value="">downscale /2</option>
+ <option value="">upscale *2</option>
+ </select>
+ <input type="submit" value="edit">
+ <input type="submit" value="delete">
+ </form>
+ </div>
+
+
+ <?php
+
+
+ echo '</article>';
+ echo '</details>';
+
+
+ }
+
+
+ //______________________________________________________ A D M _________________________________________________
+
+
+
+ public function admincss(Config $config, array $list)
+ {
+ echo '<article>';
+ echo '<h2>Default CSS for articles</h2>';
+
+ echo '<form action="?aff=admin" method="post" >';
+ echo '<input type="hidden" name="action" value="changecss">';
+ echo '<select name="lecturecss" required>';
+ foreach ($list as $item) {
+ if ($item == $config->cssread()) {
+ echo '<option value="' . $item . '" " selected >' . $item . '</option>';
+ } else {
+ echo '<option value="' . $item . '">' . $item . '</option>';
+ }
+ }
+ echo '</select>';
+ echo '<input type="submit" value="choose">';
+ echo '</form>';
+
+
+ $cssfile = '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $config->cssread();
+ if (is_file($cssfile)) {
+ $cssread = file_get_contents($cssfile);
+ echo '<details>';
+ echo '<summary>Edit current CSS</summary>';
+ echo '<form>';
+ echo '<textarea>' . $cssread . '</textarea>';
+ echo '<input type="submit" value="edit">';
+ echo '</form>';
+ echo '</details>';
+ }
+
+ ?>
+ <details close>
+ <summary>Add CSS file</summary>
+ <form action="./" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="action" value="addcss">
+ <input type="file" accept=".css" name="css" required>
+ <input type="text" name="id" id="" placeholder="filename" required>
+ <input type="submit" value="submit">
+ </form>
+ </details>
+
+ <?php
+
+ }
+
+ public function admindb($config)
+ {
+ ?>
+
+ </article>
+ <article>
+
+
+ <h2>Database</h2>
+
+ <p>Status : ok</p>
+
+ <details>
+ <summary>Database credentials</summary>
+
+ <form action="./" method="post">
+ <input type="hidden" name="action" value="editconfig">
+ <input title="host" type="text" name="host" id="host" value="<?= $config->host() ?>" placeholder="host">
+ <input title="dbname" type="text" name="dbname" id="dbname" value="<?= $config->dbname() ?>" placeholder="dbname">
+ <input title="user" type="text" name="user" id="user" value="<?= $config->user() ?>" placeholder="user">
+ <input title="password" type="text" name="password" id="user" value="<?= $config->password() ?>" placeholder="password">
+ <input type="submit" name="edit" id="">
+ </form>
+
+ </details>
+
+ <details>
+ <summary>Actions</summary>
+
+ <p>Create new table on your database</p>
+
+ <form action="">
+ <input type="submit" value="reset">
+ <input type="submit" value="download">
+ </form>
+
+ </details>
+
+
+
+ </article>
+
+ <?php
+
+ }
+
+
+
- //______________________________________________________ S E T _________________________________________________
+//______________________________________________________ S E T _________________________________________________
public function setsession($session)
{
- if ($session <= 2 and $session >= 0) {
+ if ($session <= 100 and $session >= 0) {
$session = intval($session);
$this->session = $session;
}
diff --git a/class/class.w.app.php b/class/class.w.app.php
index d668c2b..1ee8005 100644
--- a/class/class.w.app.php
+++ b/class/class.w.app.php
@@ -2,21 +2,72 @@
class App
{
private $bdd;
- private $admin;
- private $secure;
+ private $session;
- public function __construct($config)
+
+ const CONFIG_FILE = '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config.json';
+ const CSS_READ_DIR = '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR;
+
+
+ const ADMIN = 10;
+ const EDITOR = 3;
+ const INVITE = 2;
+ const READ = 1;
+ const FREE = 0;
+
+
+// _____________________________________ C O N S T R U C T _________________________________
+
+
+
+ public function __construct()
+ {
+ $this->setsession($this::FREE);
+ }
+
+ public function setbdd(Config $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']);
+ $this->bdd = new PDO('mysql:host=' . $config->host() . ';dbname=' . $config->dbname() . ';charset=utf8', $config->user(), $config->password());
} catch (Exeption $e) {
die('Erreur : ' . $e->getMessage());
}
}
+
+// _________________________________________ C O N F I G ____________________________________
+
+ public function readconfig()
+ {
+ if (file_exists(self::CONFIG_FILE)) {
+ $current = file_get_contents(self::CONFIG_FILE);
+ $donnees = json_decode($current, true);
+ return new Config($donnees);
+ } else {
+ return 0;
+ }
+
+ }
+
+ public function createconfig(array $donnees)
+ {
+ return new Config($donnees);
+ }
+
+
+ public function savejson(string $json)
+ {
+ file_put_contents(self::CONFIG_FILE, $json);
+ }
+
+
+
+
+
+
+// ___________________________________________ A R T ____________________________________
+
public function add(Art $art)
{
@@ -141,10 +192,9 @@ class App
// __________________________________________ M E D ________________________________________________________
- public function addmedia(array $file, $maxsize, $id)
+ public function addmedia(array $file, $maxsize = 2 ** 24, $id)
{
$message = 'runing';
- $maxsize = 2 ** 40;
$id = strtolower(strip_tags($id));
$id = str_replace(' ', '_', $id);
if (isset($file) and $file['media']['error'] == 0 and $file['media']['size'] < $maxsize) {
@@ -152,14 +202,14 @@ class App
$extension_upload = $infosfichier['extension'];
$extensions_autorisees = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac');
if (in_array($extension_upload, $extensions_autorisees)) {
- if (!file_exists('../media/' . $id . '.' . $extension_upload)) {
+ if (!file_exists('..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload)) {
$extension_upload = strtolower($extension_upload);
- $uploadok = move_uploaded_file($file['media']['tmp_name'], '../media/' . $id . '.' . $extension_upload);
+ $uploadok = move_uploaded_file($file['media']['tmp_name'], '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload);
if ($uploadok) {
$message = 'uploadok';
} else {
- $message = 'uploadokerror';
+ $message = 'uploaderror';
}
} else {
$message = 'filealreadyexist';
@@ -231,13 +281,116 @@ class App
}
+
+
+ //_________________________________________________________ R E C ________________________________________________________
+
+
+ public function getlisterrecord($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
+ );
+
+ $list[] = new Record($donnees);
+
+ }
+ }
+ }
+
+ return $list;
+
+
+
+ }
+
+
+
+ //_________________________________________________________ A D M ________________________________________________________
+
+ public function changecss($lecturecss)
+ {
+ if (file_exists(self::CONFIG_FILE)) {
+ $current = file_get_contents(self::CONFIG_FILE);
+ $current = str_replace($this->lecturecss(), $lecturecss, $current);
+ file_put_contents(self::CONFIG_FILE, $current);
+ return 'ccss_change_ok';
+ } else {
+ return 'ccss_change_error';
+ }
+ }
+
+ public function addcss(array $file, $maxsize = 2 ** 24, $id)
+ {
+ $message = 'runing';
+ $id = strtolower(strip_tags($id));
+ $id = str_replace(' ', '_', $id);
+ if (isset($file) and $file['css']['error'] == 0 and $file['css']['size'] < $maxsize) {
+ $infosfichier = pathinfo($file['css']['name']);
+ $extension_upload = $infosfichier['extension'];
+ $extensions_autorisees = array('css');
+ if (in_array($extension_upload, $extensions_autorisees)) {
+ if (!file_exists('..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload)) {
+
+ $extension_upload = strtolower($extension_upload);
+ $uploadok = move_uploaded_file($file['css']['tmp_name'], '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload);
+ if ($uploadok) {
+ $message = 'uploadok';
+ } else {
+ $message = 'uploaderror';
+ }
+ } else {
+ $message = 'filealreadyexist';
+
+ }
+ }
+ } else {
+ $message = 'filetoobig';
+
+ }
+
+ return $message;
+ }
+
+ public function csslist()
+ {
+ if ($handle = opendir(self::CSS_READ_DIR)) {
+ $list = [];
+ while (false !== ($entry = readdir($handle))) {
+ if ($entry != "." && $entry != ".." && pathinfo($entry)['extension'] == 'css') {
+
+ $list[] = $entry;
+
+ }
+ }
+ return $list;
+ }
+ }
+
+
+
+
//_________________________________________________________ S E S ________________________________________________________
- public function login($pass)
+ public function login($pass, $config)
{
- if (strip_tags($pass) == $this->admin) {
- return $level = 2;
- } elseif (strip_tags($pass) == $this->secure) {
+ if (strip_tags($pass) == $config->admin()) {
+ return $level = 10;
+ } elseif (strip_tags($pass) == $config->read()) {
return $level = 1;
}
}
@@ -247,5 +400,24 @@ class App
return $level = 0;
}
+ // ________________________________________________________ S E T ___________________________________________________
+
+
+ public function setsession($session)
+ {
+ $this->session = $session;
+ }
+
+
+
+
+ //_________________________________________________________ G E T ________________________________________________________
+
+ public function session()
+ {
+ return $this->session;
+ }
+
+
}
?> \ No newline at end of file
diff --git a/class/class.w.art.php b/class/class.w.art.php
index 2b67611..02c06de 100644
--- a/class/class.w.art.php
+++ b/class/class.w.art.php
@@ -174,7 +174,7 @@ a:hover {}');
}
$html = str_replace('href="http', ' class="external" target="_blank" href="http', $html);
- $html = str_replace('src="/', 'src="../media/', $html);
+ $html = str_replace('<img src="/', '<img src="../media/', $html);
$html = str_replace('<iframe', '<div class="iframe"><div class="container"><iframe class="video" ', $html);
$html = str_replace('</iframe>', '</iframe></div></div>', $html);
return $html;
diff --git a/class/class.w.config.php b/class/class.w.config.php
new file mode 100644
index 0000000..8a54530
--- /dev/null
+++ b/class/class.w.config.php
@@ -0,0 +1,158 @@
+<?php
+
+
+
+class Config
+{
+ private $host;
+ private $dbname;
+ private $user;
+ private $password;
+ private $domain;
+ private $admin;
+ private $editor;
+ private $invite;
+ private $read;
+ private $cssread;
+
+
+// _______________________________________ 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);
+ }
+ }
+ }
+
+ public function tojson()
+ {
+ $arr = get_object_vars($this);
+ $json = json_encode($arr, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
+ return $json;
+ }
+
+// ________________________________________ G E T _______________________________________
+
+ public function host()
+ {
+ return $this->host;
+ }
+
+ public function dbname()
+ {
+ return $this->dbname;
+ }
+
+ public function user()
+ {
+ return $this->user;
+ }
+
+ public function password()
+ {
+ return $this->password;
+ }
+
+ public function domain()
+ {
+ return $this->domain;
+ }
+
+ public function admin()
+ {
+ return $this->admin;
+ }
+
+ public function editor()
+ {
+ return $this->editor;
+ }
+
+ public function invite()
+ {
+ return $this->invite;
+ }
+
+ public function read()
+ {
+ return $this->read;
+ }
+
+ public function cssread()
+ {
+ return $this->cssread;
+ }
+
+// __________________________________________ S E T ______________________________________
+
+ public function sethost($host)
+ {
+ $this->host = strip_tags($host);
+ }
+
+ public function setdbname($dbname)
+ {
+ $this->dbname = strip_tags($dbname);
+ }
+
+ public function setuser($user)
+ {
+ $this->user = strip_tags($user);
+ }
+
+ public function setpassword($password)
+ {
+ $this->password = strip_tags($password);
+ }
+
+ public function setdomain($domain)
+ {
+ $this->domain = strip_tags($domain);
+ }
+
+ public function setadmin($admin)
+ {
+ $this->admin = strip_tags($admin);
+ }
+
+ public function seteditor($editor)
+ {
+ $this->editor = strip_tags($editor);
+ }
+
+ public function setinvite($invite)
+ {
+ $this->invite = strip_tags($invite);
+ }
+
+ public function setread($read)
+ {
+ $this->read = strip_tags($read);
+ }
+
+ public function setcssread($cssread)
+ {
+ $this->cssread = strip_tags($cssread);
+ }
+
+}
+
+
+
+
+
+
+
+
+
+?> \ No newline at end of file
diff --git a/class/class.w.record.php b/class/class.w.record.php
new file mode 100644
index 0000000..e488383
--- /dev/null
+++ b/class/class.w.record.php
@@ -0,0 +1,116 @@
+<?php
+
+class Record
+{
+ private $id;
+ private $path;
+ private $extension;
+ private $size;
+ private $datetime;
+ private $number;
+
+
+
+// _____________________________________________________ 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 size()
+ {
+ return $this->size;
+ }
+
+ public function datetime()
+ {
+ return $this->datetime;
+ }
+
+ public function number()
+ {
+ return $this->number;
+ }
+
+// ___________________________________________________ S E T __________________________________________________
+
+ public function setid($id)
+ {
+ if (strlen($id) < 100 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 setdatetime($datetime)
+ {
+ if (is_int($datetime)) {
+ $this->datetime = strip_tags(strtolower($datetime));
+ }
+ }
+
+ public function setnumber($number)
+ {
+ if (is_int($number)) {
+ $this->number = strip_tags(strtolower($number));
+ }
+ }
+
+
+
+
+
+}
+
+?> \ No newline at end of file