diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | class/class.w.aff.php | 297 | ||||
-rw-r--r-- | class/class.w.app.php | 202 | ||||
-rw-r--r-- | class/class.w.art.php | 2 | ||||
-rw-r--r-- | class/class.w.config.php | 158 | ||||
-rw-r--r-- | class/class.w.record.php | 116 | ||||
-rw-r--r-- | config.sample.json | 0 | ||||
-rw-r--r-- | config.sample.php | 11 | ||||
-rw-r--r-- | fn/fn.php | 2 | ||||
-rw-r--r-- | public/css/stylebase.css | 3 | ||||
-rw-r--r-- | public/css/stylerecord.css | 66 | ||||
-rw-r--r-- | public/css/stylew.css | 15 | ||||
-rw-r--r-- | public/w/index.php | 166 |
13 files changed, 919 insertions, 122 deletions
@@ -1,5 +1,6 @@ vendor/* .vscode/* -config.php +config.json error_log public/media/* +public/ACRRecordings/* 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 diff --git a/config.sample.json b/config.sample.json new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/config.sample.json diff --git a/config.sample.php b/config.sample.php deleted file mode 100644 index 9238ddb..0000000 --- a/config.sample.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -return [ - 'host' => 'localhost', - 'dbname' => 'wiki', - 'user' => 'root', - 'password' => 'mdp', - 'domaine' => 'vincent.club1.fr' -] - -?>
\ No newline at end of file @@ -52,7 +52,7 @@ function search($haystack, $debut, $fin) } -function readablesize(int $bytes) +function readablesize($bytes) { $num = 5; diff --git a/public/css/stylebase.css b/public/css/stylebase.css index 92ea674..ff59114 100644 --- a/public/css/stylebase.css +++ b/public/css/stylebase.css @@ -46,10 +46,9 @@ form { section { padding: 3%; - line-height: 1.2em; } -.edit { +.edit body { overflow-y: scroll; } diff --git a/public/css/stylerecord.css b/public/css/stylerecord.css new file mode 100644 index 0000000..9e46c3f --- /dev/null +++ b/public/css/stylerecord.css @@ -0,0 +1,66 @@ +section { + padding: 0; +} + +.infobulle { + display: none; +} + +.little:hover .infobulle { + display: inline-block; + position: relative; + background-color: white; + z-index: 5; + top: 5px; + width: 300px; + font-family: monospace; + font-size: 0.9em; + line-height: 1.1em; +} + +span.infobulle img { + width: 100%; +} + +.grid { + display: flex; + flex-wrap: wrap; + padding: 4%; + margin-right: 120px; + list-style: none; + +} + +.little { + width: 100px; + height: 150px; + margin: 10px; + background-color: white; + +} + +.infobulle input[type="text"] { + font-family: monospace; + font-size: 0.9em; + margin: 3px; +} + +img.thumbnail { + max-width: 100%; + max-height: 100px; +} + +section.gest { + padding-bottom: 300px; +} + +input[type="file"] { + font-size: 1.3em; +} + +input[type="checkbox"] { + width: unset; + padding: unset; + margin: unset; + height: unset; +}
\ No newline at end of file diff --git a/public/css/stylew.css b/public/css/stylew.css index 3a414c7..f175036 100644 --- a/public/css/stylew.css +++ b/public/css/stylew.css @@ -2,6 +2,7 @@ body { background-color: #dcdcdceb; font-family: helvetica, arial, sans-serif; margin: 0px; + overflow: hidden; } @@ -52,11 +53,23 @@ form { section { text-align: justify; padding: 3%; - line-height: 1.2em; } .edit { overflow-y: scroll; + height: 100%; + +} + +.lecture { + overflow-wrap: break-word; + overflow-y: auto; + height: 100%; +} + +.home { + overflow-y: scroll; + height: 100%; } .edit section { diff --git a/public/w/index.php b/public/w/index.php index 9a40e9f..3f572b3 100644 --- a/public/w/index.php +++ b/public/w/index.php @@ -3,32 +3,120 @@ // _____________________________________________________ R E Q U I R E ________________________________________________________________ - - -$config = require('../../config.php'); require('../../vendor/autoload.php'); use Michelf\Markdown; use Michelf\MarkdownExtra; - require('../../fn/fn.php'); +require('../../class/class.w.config.php'); require('../../class/class.w.art.php'); require('../../class/class.w.app.php'); require('../../class/class.w.aff.php'); require('../../class/class.w.media.php'); +require('../../class/class.w.record.php'); + +// ________________________________________________________ I N S T A L _________________________________________________ + +$app = new App(); +$aff = new Aff(); + + +$config = $app->readconfig(); +if (!$config) { + $message = 'config_file_error'; + echo $message; + if (isset($_POST['config']) && $_POST['config'] == 'create') { + $config = $app->createconfig($_POST); + $app->savejson($config->tojson()); + header('Location: ./'); + + } else { + $aff->configform(); + } + exit; +} + + +// _________________________________________________________ S E S ___________________________________________________________ + session(); if (!isset($_SESSION['level'])) { - $level = 0; + $session = 0; } else { - $level = $_SESSION['level']; + $session = $_SESSION['level']; +} + +$app->setsession($session); + +//var_dump($config); +//var_dump($app); + + + +// _________________________________________________________ N A V _______________________________________________ + +if (isset($_GET['id'])) { + $app->setbdd($config); } -$app = new App($config); -$aff = new Aff($level); // _____________________________________________________ A C T I O N __________________________________________________________________ + +if (isset($_POST['action'])) { + switch ($_POST['action']) { + + case 'login': + $_SESSION['level'] = $app->login($_POST['pass'], $config); + if (isset($_GET['id'])) { + header('Location: ?id=' . $_GET['id']); + } else { + header('Location: ./'); + } + break; + + case 'logout': + $_SESSION['level'] = $app->logout(); + if (isset($_GET['id'])) { + header('Location: ?id=' . $_GET['id']); + } else { + header('Location: ./'); + } + break; + + case 'addmedia': + $message = $app->addmedia($_FILES, 2 ** 24, $_POST['id']); + header('Location: ./?aff=media&message=' . $message); + break; + + case 'addcss': + $message = $app->addcss($_FILES, 2 ** 24, $_POST['id']); + header('Location: ./?aff=admin&message=' . $message); + break; + + case 'changecss': + $config->setcssread($_POST['lecturecss']); + $app->savejson($config->tojson()); + header('Location: ./?aff=admin'); + break; + + case 'editconfig': + $config->hydrate($_POST); + $app->savejson($config->tojson()); + header('Location: ./?aff=admin'); + + break; + + + } +} + + +// _____________________________________________________ D A T A B A S E __________________________________________________________________ + if (isset($_POST['action'])) { + $app->setbdd($config); + switch ($_POST['action']) { case 'update': @@ -71,46 +159,22 @@ if (isset($_POST['action'])) { } break; - - case 'login': - $_SESSION['level'] = $app->login($_POST['pass']); - if (isset($_GET['id'])) { - header('Location: ?id=' . $_GET['id']); - } else { - header('Location: ./'); - } - break; - - case 'logout': - $_SESSION['level'] = $app->logout(); - if (isset($_GET['id'])) { - header('Location: ?id=' . $_GET['id']); - } else { - header('Location: ./'); - } - break; - - case 'addmedia': - $message = $app->addmedia($_FILES, 2 ** 10, $_POST['id']); - header('Location: ./?aff=media&message='.$message); - break; - } } - - // _______________________________________________________ H E A D _____________________________________________________________ if (isset($_GET['id'])) { + $app->setbdd($config); if ($app->exist($_GET['id'])) { $art = $app->get($_GET['id']); if (isset($_GET['edit']) && $_GET['edit'] == 1) { - $aff->arthead($art, '✏'); + $aff->arthead($art, $config->cssread(), 1); + } else { + $aff->arthead($art, $config->cssread(), 0); } - $aff->arthead($art, ''); } else { $aff->head($_GET['id'], 'w'); @@ -146,15 +210,17 @@ echo '<body>'; $aff->nav($app); if (isset($_GET['id'])) { + $app->setbdd($config); + if ($app->exist($_GET['id'])) { $art = $app->get($_GET['id']); - if (isset($_GET['edit']) and $_GET['edit'] == 1 and $aff->session() == 2) { - $aff->edit($art, $app->getlister(['id', 'titre'], 'id')); + if (isset($_GET['edit']) and $_GET['edit'] == 1 and $app->session() >= $app::EDITOR) { + $aff->edit($art, $app, $app->getlister(['id', 'titre'], 'id')); $aff->copy($art, $app->getlister(['id', 'titre'], 'id')); - $aff->aside($app->lister()); + $aff->aside($app); } else { $aff->lecture($art, $app); @@ -170,7 +236,7 @@ if (isset($_GET['id'])) { } else { echo '<span class="alert"><h4>Cet article n\'existe pas encore</h4></span>'; - if ($level >= 2) { + if ($aff->session() >= 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>'; } @@ -184,11 +250,17 @@ if (isset($_GET['id'])) { } elseif (isset($_GET['lien'])) { echo '<h4>' . $_GET['lien'] . '</h4>'; $aff->lien($app->getlister(['id', 'titre', 'intro', 'lien'], 'id'), $_GET['lien']); - -} elseif (isset($_GET['aff'])) { +} elseif (isset($_GET['aff']) && $app->session() == $app::ADMIN) { if ($_GET['aff'] == 'admin') { + echo '<section>'; echo '<h1>Admin</h1>'; + + $aff->admincss($config, $app->csslist()); + $aff->admindb($config); + + echo '</section>'; } elseif ($_GET['aff'] == 'media') { + echo '<h1>Media</h1>'; echo '<section>'; $aff->addmedia(); @@ -198,11 +270,19 @@ if (isset($_GET['id'])) { } elseif ($_GET['aff'] == 'record') { echo '<h1>Record</h1>'; + echo '<section>'; + + $aff->recordlist($app); + + echo '</section>'; + } else { header('Location: ./'); } } else { + $app->setbdd($config); + if (isset($_GET['tri'])) { $tri = strip_tags($_GET['tri']); } else { @@ -213,7 +293,7 @@ if (isset($_GET['id'])) { } else { $desc = 'ASC'; } - $aff->home2table($app->getlister(['id', 'titre', 'intro', 'lien', 'datecreation', 'datemodif'], $tri, $desc)); + $aff->home2table($app, $app->getlister(['id', 'titre', 'intro', 'lien', 'datecreation', 'datemodif'], $tri, $desc)); } |