aboutsummaryrefslogtreecommitdiff
path: root/w/class
diff options
context:
space:
mode:
Diffstat (limited to 'w/class')
-rw-r--r--w/class/class.w.aff.php1161
-rw-r--r--w/class/class.w.app.php770
-rw-r--r--w/class/class.w.art.php501
-rw-r--r--w/class/class.w.art2.php585
-rw-r--r--w/class/class.w.config.php188
-rw-r--r--w/class/class.w.media.php173
-rw-r--r--w/class/class.w.opt.php272
-rw-r--r--w/class/class.w.quickcss.php291
-rw-r--r--w/class/class.w.record.php116
9 files changed, 4057 insertions, 0 deletions
diff --git a/w/class/class.w.aff.php b/w/class/class.w.aff.php
new file mode 100644
index 0000000..adb8b61
--- /dev/null
+++ b/w/class/class.w.aff.php
@@ -0,0 +1,1161 @@
+<?php
+
+class Aff
+{
+
+ private $session;
+
+ private static $edit = 2;
+
+
+ // ________________________________________________ C O N S T R U C T ______________________________________________
+
+
+ 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)
+ {
+ if ($art->secure() == 1) {
+ echo '<span class="alert">This article is private</span>';
+ }
+ if ($art->secure() == 2) {
+ echo "<span class=\"alert\">This article is not published yet</span>";
+ }
+
+ if ($app->session() >= $art->secure()) {
+ ?>
+ <style type="text/css">
+ body{
+ background: <?= $art->couleurbkg() ?>;
+ }
+ section {
+ color: <?= $art->couleurtext() ?>;
+ }
+
+ a {
+ color: <?= $art->couleurlien() ?>;
+ }
+
+ section a.external {
+ color: <?= $art->couleurlienblank() ?>;
+ }
+ <?= $art->csstemplate($app) ?>
+ </style>
+ <header>
+ <h1><?= $art->titre() ?></h1>
+ <h6><?= $art->soustitre() ?></h6>
+ </header>
+ <article><?= $art->html($app) ?></article>
+ <?php
+
+ }
+ }
+
+ public function edit(Art $art, App $app, $list, $fontsize, $imagelist)
+ {
+
+ if ($app->session() >= self::$edit) {
+
+ ?>
+
+ <form action="?id=<?= $art->id() ?>" method="post" id="artedit">
+
+ <?php
+ echo '<style>textarea{font-size: ' . $fontsize . '}</style>';
+ $tablist = ['html' => $art->md(), 'css' => $art->css(), 'aside' => 'NOT WORKING', 'footer' => 'NOT WORKING'];
+
+ $this->tabs($tablist, 'html');
+
+ ?>
+
+ <div id="submit">
+ <input type="submit" name="action" value="home" accesskey="w" onclick="document.getElementById('artedit').submit();" form="artedit">
+ <input type="submit" name="action" value="update" accesskey="x" onclick="document.getElementById('artedit').submit();" form="artedit">
+ <input type="submit" name="action" value="display" accesskey="c" onclick="document.getElementById('artedit').submit();" form="artedit">
+ <input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Delete this article', 'artedit')" form="artedit">
+ <a href="?id=<?= $art->id() ?>" target="_blank">👁</a>
+
+ <span id="headid"><?= $art->id() ?></span>
+
+ <label for="fontsize">Font-size</label>
+ <input type="number" name="fontsize" value="<?= $fontsize ?>" id="fontsize">
+ </div>
+ <div class="sidebar">
+ <details id="editinfo" open>
+ <summary>Infos</summary>
+ <fieldset>
+ <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('string'); ?>">
+ <label for="secure">Niveau de sécurité :</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="template">Template :</label>
+ <select name="template" id="template">
+ <?php
+ if ($art->template() == 'NULL') {
+ echo '<option value="" selected >No template</option>';
+ } else {
+ echo '<option value="" >No template</option>';
+ }
+ foreach ($list as $item) {
+
+ if ($item->id() == $art->template()) {
+ echo '<option value="' . $item->id() . '" selected >' . $item->titre() . '</option>';
+ } else {
+ echo '<option value="' . $item->id() . '">' . $item->titre() . '</option>';
+ }
+ }
+ ?>
+ </select>
+ </fieldset>
+ </details>
+ <details>
+ <summary>Advanced</summary>
+ <fieldset>
+ <h3>Template options</h3>
+ <p>NOT WORKING</p>
+ <ul>
+ <?php
+
+ $templatelist = ['header' => 0, 'section' => 0, 'nav' => 0, 'aside' => 0, 'footer' => 0, 'quickcss' => 1, 'css' => 1];
+
+ foreach ($templatelist as $template => $check) {
+ if ($check == 1) {
+ echo '<li><input type="checkbox" name="template' . $template . '" id="template' . $template . '" checked><label for="template' . $template . '">' . $template . '</label></li>';
+ } else {
+ echo '<li><input type="checkbox" name="template' . $template . '" id="template' . $template . '"><label for="template' . $template . '">' . $template . '</label></li>';
+ }
+ }
+ ?>
+ </ul>
+ </fieldset>
+ </details>
+ <details id="editcss" open>
+ <summary>Quick CSS</summary>
+ <fieldset>
+
+ <?php
+ $colorlist = ['text' => $art->couleurtext(), 'lien' => $art->couleurlien(), 'lienblank' => $art->couleurlienblank(), 'bkg' => $art->couleurbkg()];
+ foreach ($colorlist as $element => $color) {
+ echo '<label for="couleur' . $element . '">Couleur du ' . $element . ' :</label><input type="color" name="couleur' . $element . '" value="' . $color . '" id="couleur' . $element . '">';
+ }
+
+
+
+ ?>
+
+ <label for="bkgimage">NOT WORKING</label>
+ <select name="bkgimage" id="bkgimage">
+ <?php
+
+ $artbkgimage = "NULL";
+
+ if ($artbkgimage == 'NULL') {
+ echo '<option value="" selected >No background image</option>';
+ } else {
+ echo '<option value="" >No background image</option>';
+ }
+ foreach ($imagelist as $image) {
+ if ($image->id() == $artbkgimage) {
+ echo '<option value="' . $image->id() . '.' . $image->extension() . '" selected >' . $image->id() . '.' . $image->extension() . '</option>';
+ } else {
+ echo '<option value="' . $image->id() . '.' . $image->extension() . '">' . $image->id() . '.' . $image->extension() . '</option>';
+ }
+ }
+ ?>
+ </select>
+
+ </fieldset>
+ </details>
+ <details>
+ <summary>Help</summary>
+ <div id="help">
+ <h2>Help !</h2>
+ <p>To save your article, press the HOME, UPDATE, or DISPLAY buttons. You can use the keyboard shortcuts as well.</p>
+ <pre><span class="i">ALT + W</span> : home</pre>
+ <pre><span class="i">ALT + X</span> : update</pre>
+ <pre><span class="i">ALT + C</span> : display</pre>
+ <h3>Markdown</h3>
+ <p>The html section use <a href="https://daringfireball.net/projects/markdown/syntax" target="_blank">Markdown encoding</a>. Actualy, W is using Michel Fortin's <a href="https://michelf.ca/projects/php-markdown/extra/" target="_blank">Markdown Extra</a>.</p>
+ <h3>Links</h3>
+ <pre>[text](=<span class="i">article_id</span>)</pre>
+ <p>where article_id is the article's id you want to point to.</p>
+ <h3>Images</h3>
+ <pre>[altimage](/<span class="i">img_id.extension</span>)</pre>
+ <p>Where img_id is the id of your image and its extension.</p>
+ <h3>Shortcuts</h3>
+ <pre>%TITLE%</pre>
+ <p>Show the title of your article.</p>
+ <pre>%DESCRIPTION%</pre>
+ <p>Show the description (intro) of your article.</p>
+ <pre>%SUMMARY%</pre>
+ <p>Generate a <strong>summary</strong>, the list of all your head titles using #, ##, ###...</p>
+ <pre>%%<span class="i">tag_name</span>%%</pre>
+ <p>Generate a <strong>menu</strong>, a list of links to all articles under this tag.</p>
+ <p>vv</p>
+ <p>vv</p>
+ <p>vv</p>
+ <p></p>
+ </div>
+ </details>
+
+
+ </div>
+
+
+ <input type="hidden" name="datecreation" value="<?= $art->datecreation('string'); ?>">
+ <input type="hidden" name="id" value="<?= $art->id() ?>">
+
+ </form>
+
+
+ <?php
+
+}
+
+}
+
+
+public function tabs($tablist, $opentab)
+{
+ echo '<div class="tabs">';
+ foreach ($tablist as $key => $value) {
+ echo '<div class="tab">';
+ if ($key == $opentab) {
+ echo '<input name="checkbox-tabs-group" type="radio" id="tab' . $key . '" class="checkboxtab" checked>';
+ } else {
+ echo '<input name="checkbox-tabs-group" type="radio" id="tab' . $key . '" class="checkboxtab">';
+ }
+ echo '<label for="tab' . $key . '">' . $key . '</label>';
+ echo '<div class="content">';
+ echo '<textarea name="' . $key . '" id="' . $key . '" >' . $value . '</textarea>';
+ echo '</div>';
+ echo '</div>';
+ }
+
+ echo '</div>';
+}
+
+
+
+public function copy(Art $art, $list)
+{
+ ?>
+ <div id="copy">
+ <form action="?id=<?= $art->id() ?>&edit=1" method="post">
+ <fieldset>
+ <input type="hidden" name="action" value="copy">
+ <input type="hidden" name="id" value="<?= $art->id() ?>">
+ <select name="copy" required>
+ <?php
+ foreach ($list as $item) {
+ echo '<option value="' . $item->id() . '">' . $item->id() . '</option>';
+ }
+ echo '</select>';
+ ?>
+ <label for="checkcss">CSS</label>
+ <input type="checkbox" id="checkcss" name="css" value="true">
+ <label for="checkcolor">Color</label>
+ <input type="checkbox" id="checkcolor" name="color" value="true">
+ <label for="checkhtml">HTML</label>
+ <input type="checkbox" id="checkhtml" name="html" value="true">
+ <label for="checktemplate">template</label>
+ <input type="checkbox" id="checktemplate" name="template" value="true">
+ <input type="submit" value="copy" onclick="confirmSubmit(event, 'Erase values')">
+ </fieldset>
+ </form>
+ </div>
+ <?php
+
+}
+
+public function head($title, $tool, $color4)
+{
+ ?>
+ <head>
+ <meta charset="utf8" />
+ <meta name="viewport" content="width=device-width" />
+ <link rel="shortcut icon" href="./media/logo.png" type="image/x-icon">
+ <link href="./rsc/css/stylebase.css" rel="stylesheet" />
+ <link href="./rsc/css/style<?= $tool ?>.css" rel="stylesheet" />
+ <style>
+ :root {
+ --color4: <?= $color4 ?>;
+ }
+ </style>
+ <title><?= $title ?></title>
+ <script src="./rsc/js/app.js"></script>
+ </head>
+ <?php
+
+}
+
+public function arthead(Art $art, $globalcss, $edit = 0)
+{
+ ?>
+ <head>
+ <meta charset="utf8" />
+ <meta name="description" content="<?= $art->intro() ?>" />
+ <meta name="viewport" content="width=device-width" />
+ <link rel="shortcut icon" href="./media/logo.png" type="image/x-icon">
+ <link href="./rsc/css/stylebase.css" rel="stylesheet" />
+ <?= $edit == 0 ? '<link href="' . $globalcss . '" rel="stylesheet" />' : '<link href="./rsc/css/styleedit.css" rel="stylesheet" />' ?>
+ <title><?= $edit == 1 ? '✏' : '' ?> <?= $art->titre() ?></title>
+ <script src="./rsc/js/app.js"></script>
+ </head>
+ <?php
+
+}
+
+public function noarthead($id, $globalcss)
+{
+ ?>
+ <head>
+ <meta charset="utf8" />
+ <meta name="description" content="This article does not exist yet." />
+ <meta name="viewport" content="width=device-width" />
+ <link rel="shortcut icon" href="./media/logo.png" type="image/x-icon">
+ <link href="./rsc/css/stylebase.css" rel="stylesheet" />
+ <link href="<?= $globalcss ?>" rel="stylesheet" />
+ <title>❓ <?= $id ?></title>
+ <script src="./rsc/js/app.js"></script>
+ </head>
+ <?php
+
+}
+
+
+
+
+public function search()
+{
+ ?>
+ <div id="search">
+ <form action="./" method="get">
+ <input type="text" name="id" id="id" placeholder="identifiant article" required>
+ <input type="submit" value="accéder">
+ </form>
+ </div>
+ <?php
+
+}
+
+public function tag($getlist, $tag, $app)
+{
+ echo '<div class="tag">';
+ echo '<ul>';
+ foreach ($getlist as $item) {
+ if (in_array($tag, $item->tag('array'))) {
+ echo '<li><a href="?id=' . $item->id() . '">' . $item->titre() . '</a> - ' . $item->intro();
+ if ($app->session() >= $app::EDITOR) {
+ echo ' - <a href="?id=' . $item->id() . '&edit=1">modifier</a></li>';
+ } else {
+ echo '</li>';
+ }
+ }
+ }
+ echo ' </ul> ';
+ echo ' </div> ';
+}
+
+public function lien($getlist, $lien, App $app)
+{
+ echo '<div class="lien">';
+ echo '<ul>';
+ foreach ($getlist as $item) {
+ if (in_array($lien, $item->lien('array'))) {
+ echo '<li><a href="?id=' . $item->id() . '">' . $item->titre() . '</a> - ' . $item->intro();
+ if ($app->session() >= $app::EDITOR) {
+ echo ' - <a href="?id=' . $item->id() . '&edit=1">modifier</a> - <a href="?lien=' . $item->id() . '">liens</a></li>';
+ } else {
+ echo '</li>';
+ }
+ }
+ }
+ echo ' </ul> ';
+ echo ' </div> ';
+}
+
+
+
+public function dump($getlist)
+{
+ echo '<ul>';
+ foreach ($getlist as $item) {
+ echo '<li>';
+ var_dump($item);
+ echo '</li>';
+ }
+ echo ' </ul> ';
+}
+
+public function header()
+{
+ echo '<header>';
+ $this->search();
+ echo '</header>';
+}
+
+
+public function home2table(App $app, $getlist, $masslist)
+{
+ echo '<div id="main">';
+ echo '<h2>Articles</h2>';
+ echo '<form action="./" method="post">';
+
+ ?>
+ <div id="massedit">
+ <h3>Mass Edit</h3>
+ <select name="massedit" required>
+ <option value="public">set as public</option>
+ <option value="private">set as private</option>
+ <option value="not published">set as not published</option>
+ <option value="erasetag">erase all tags</option>
+ <option value="erasetemplate">erase template</option>
+ <option value="delete">delete</option>
+ </select>
+
+ <input type="submit" name="massaction" value="do" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <input type="text" name="targettag" placeholder="add tag">
+ <input type="submit" name="massaction" value="add tag" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <select name="masstemplate">
+ <?php
+ foreach ($masslist as $art) {
+ echo '<option value="' . $art->id() . '">' . $art->id() . '</option>';
+ }
+ ?>
+ </select>
+
+ <input type="submit" name="massaction" value="set template" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <input type="hidden" name="action" value="massedit">
+ </div>
+
+ <?php
+ if ($app->session() >= $app::EDITOR) {
+ echo '<table id="home2table">';
+ echo '<tr><th>x</th><th>title</th><th>tag</th><th>summary</th><th>↘ to</th><th>↗ from</th><th>last modification</th><th>date of creation</th><th>privacy</th><th>display</th></tr>';
+ foreach ($getlist as $item) {
+ echo '<tr>';
+ echo '<td><input type="checkbox" name="id[]" value=' . $item->id() . '></td>';
+ echo '<td><a href="?id=' . $item->id() . '&edit=1">' . $item->titre() . '</a></td>';
+ echo '<td>' . $item->tag('sort') . '</td>';
+ echo '<td>' . $item->intro() . '</td>';
+ echo '<td><a href="?lien=' . $item->id() . '">' . $item->liento('sort') . '</a></td>';
+ echo '<td>' . $item->lien('sort') . '</td>';
+ echo '<td>' . $item->datemodif('hrdi') . '</td>';
+ echo '<td>' . $item->datecreation('hrdi') . '</td>';
+ echo '<td>' . $item->secure('string') . '</td>';
+ echo '<td><a href="?id=' . $item->id() . '" target="_blank">👁</a></td>';
+ echo '</tr>';
+ }
+ echo ' </table> ';
+ echo ' </form> ';
+ echo '</div>';
+ }
+}
+
+public function option(App $app, Opt $opt)
+{
+ if ($app->session() >= $app::EDITOR) {
+ echo '<div id="options">';
+ echo '<h2>Options</h2>';
+ echo '<form action="./" method="get" >';
+ echo '<input type="submit" name="submit" value="filter">';
+ echo '⬅<input type="submit" name="submit" value="reset">';
+
+
+ $this->optionsort($opt);
+ $this->optionprivacy($opt);
+ $this->optiontag($opt);
+
+ if ($opt->invert() == 1) {
+ echo '<input type="checkbox" name="invert" value="1" id="invert" checked>';
+ } else {
+ echo '<input type="checkbox" name="invert" value="1" id="invert">';
+ }
+ echo '<label for="invert">invert</></br>';
+
+
+ echo '<input type="submit" name="submit" value="filter">';
+ echo '⬅<input type="submit" name="submit" value="reset">';
+
+ echo '</form></div>';
+
+ }
+
+}
+
+public function optiontag(Opt $opt)
+{
+
+ echo '<fieldset><legend>Tag</legend><ul>';
+
+
+ echo '<input type="radio" id="OR" name="tagcompare" value="OR" ' . ($opt->tagcompare() == "OR" ? "checked" : "") . ' ><label for="OR">OR</label>';
+ echo '<input type="radio" id="AND" name="tagcompare" value="AND" ' . ($opt->tagcompare() == "AND" ? "checked" : "") . '><label for="AND">AND</label>';
+
+ //echo '<input type="hidden" name="tagfilter[]" value="">';
+
+ $in = false;
+ $out = false;
+ $limit = 1;
+ foreach ($opt->taglist() as $tagfilter => $count) {
+
+ if ($count > $limit && $in == false) {
+ echo '<details open><summary>>' . $limit . '</summary>';
+ $in = true;
+ }
+ if ($count == $limit && $in == true && $out == false) {
+ echo '</details><details><summary>' . $limit . '</summary>';
+ $out = true;
+ }
+
+ if (in_array($tagfilter, $opt->tagfilter())) {
+
+ echo '<li><input type="checkbox" name="tagfilter[]" id="' . $tagfilter . '" value="' . $tagfilter . '" checked /><label for="' . $tagfilter . '">' . $tagfilter . ' (' . $count . ')</label></li>';
+ } else {
+ echo '<li><input type="checkbox" name="tagfilter[]" id="' . $tagfilter . '" value="' . $tagfilter . '" /><label for="' . $tagfilter . '">' . $tagfilter . ' (' . $count . ')</label></li>';
+ }
+ }
+ if ($in = true || $out = true) {
+ echo '</details>';
+ }
+ echo '</ul></fieldset>';
+
+}
+
+public function optionprivacy(Opt $opt)
+{
+ echo '<fieldset><legend>Privacity</legend><ul>';
+ echo '<li><input type="radio" id="4" name="secure" value="4" ' . ($opt->secure() == 4 ? "checked" : "") . ' /><label for="4">all</label></li>';
+ echo '<li><input type="radio" id="2" name="secure" value="2" ' . ($opt->secure() == 2 ? "checked" : "") . ' /><label for="2">not published</label></li>';
+ echo '<li><input type="radio" id="1" name="secure" value="1" ' . ($opt->secure() == 1 ? "checked" : "") . ' /><label for="1">private</label></li>';
+ echo '<li><input type="radio" id="0" name="secure" value="0" ' . ($opt->secure() == 0 ? "checked" : "") . ' /><label for="0">public</label></li>';
+ echo '</ul></fieldset>';
+}
+
+public function optionsort(Opt $opt)
+{
+ echo '<fieldset><legend>Sort</legend>';
+ echo '<select name="sortby" id="sortby">';
+ foreach ($opt->col('array') as $key => $col) {
+ echo '<option value="' . $col . '" ' . ($opt->sortby() == $col ? "selected" : "") . '>' . $col . '</option>';
+ }
+ echo '</select>';
+ echo '</br>';
+ echo '<input type="radio" id="asc" name="order" value="1" ' . ($opt->order() == '1' ? "checked" : "") . ' /><label for="asc">ascending</label>';
+ echo '</br>';
+ echo '<input type="radio" id="desc" name="order" value="-1" ' . ($opt->order() == '-1' ? "checked" : "") . ' /><label for="desc">descending</label>';
+
+ echo '</fieldset>';
+
+}
+
+public function mapheader()
+{
+ $selectcurve = isset($_GET['curve']) ? $_GET['curve'] : 'basis';
+ $selectorient = isset($_GET['orient']) ? $_GET['orient'] : 'TD';
+ $curves = ['linear', 'basis', 'natural', 'step', 'stepAfter', 'stepBefore', 'monotoneX', 'monotoneY'];
+ $orients = ['TD', 'LR', 'BT', 'RL'];
+ ?>
+ <h2>Map</h2>
+
+ <form action="./" method="get">
+ <label for="curve">Curve style</label>
+ <select name="curve" id="curve">
+ <?php
+ foreach ($curves as $curve) {
+ ?>
+ <option value="<?= $curve ?>" <?= $selectcurve == $curve ? 'selected' : '' ?>><?= $curve ?></option>
+ <?php
+
+ }
+ ?>
+ </select>
+ <label for="orient">Orientation</label>
+ <select name="orient" id="orient">
+ <?php
+ foreach ($orients as $orient) {
+ ?>
+ <option value="<?= $orient ?>" <?= $selectorient == $orient ? 'selected' : '' ?>><?= $orient ?></option>
+ <?php
+
+ }
+ ?>
+ </select>
+ <input type="submit" value="draw" name="map">
+ </form>
+ <?php
+
+}
+
+public function mermaid(string $map)
+{
+ $curve = isset($_GET['curve']) ? $_GET['curve'] : 'basis';
+ $orient = isset($_GET['orient']) ? $_GET['orient'] : 'TD';
+
+
+ ?>
+
+ <script src="./rsc/js/mermaid.min.js"></script>
+
+ <script>
+ mermaid.initialize({
+ startOnLoad:true,
+ themeCSS: ".node circle, .node rect , .node polygon { fill: var(--color1); stroke: var(--color4);} ",
+ flowchart: {
+ curve: '<?= $curve ?>'
+ }
+ });
+
+ </script>
+
+
+ <div class="mermaid">
+
+ graph <?= $orient ?>
+ <?= $map ?>
+ </div>
+
+
+ <?php
+
+}
+
+public function aside(App $app)
+{
+ if ($app->session() >= $app::EDITOR) {
+ echo '<div id="linklist">Links<div id="roll"><ul>';
+ foreach ($app->lister() as $item) {
+ echo '<li><a href="?id=' . $item['id'] . '&edit=1">' . $item['titre'] . '</a> - <input type="text" value="[' . $item['titre'] . '](?id=' . $item['id'] . ')">';
+
+
+ }
+ echo ' </ul></div></div> ';
+ }
+}
+
+public function nav($app)
+{
+ echo '<nav>';
+ echo $app->session();
+ echo '<div id="menu">';
+
+ echo '<a class="button" href="?">home</a>';
+
+ if ($app->session() == $app::FREE) {
+ if (isset($_GET['id'])) {
+ echo '<form action="./?id=' . $_GET['id'] . '" method="post">';
+ } else {
+ echo '<form action="." method="post">';
+ }
+ ?>
+ <input type="hidden" name="action" value="login">
+ <input type="password" name="pass" id="loginpass" placeholder="password">
+ <input type="submit" value="login">
+ </form>
+ <?php
+
+ }
+ if ($app->session() > $app::FREE) {
+ if (isset($_GET['id'])) {
+ echo '<form action="./?id=' . $_GET['id'] . '" method="post">';
+ } else {
+ echo '<form action="." method="post">';
+ }
+ ?>
+ <input type="hidden" name="action" value="logout">
+ <input type="submit" value="logout">
+ </form>
+ <?php
+
+ }
+ if ($app->session() >= $app::EDITOR && 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 ($app->session() >= $app::EDITOR) {
+ echo '<a class="button" href="?aff=media" >Media</a>';
+ echo '<a class="button" href="?aff=record" >Record</a>';
+ if ($app->session() >= $app::ADMIN) {
+ echo '<a class="button" href="?aff=admin" >Admin</a>';
+ }
+ }
+
+
+
+
+ ?>
+ </div>
+ </nav>
+ <?php
+
+ }
+
+ // ____________________________________________________ M E D ________________________________________________
+
+
+ public function addmedia($app)
+ {
+ if ($app->session() >= $app::EDITOR) {
+
+ ?>
+ <details close>
+ <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>
+ <input type="text" name="id" id="" placeholder="nom du fichier" required>
+ <input type="submit" value="envoi">
+ </form>
+ </details>
+ <?php
+
+ }
+ }
+
+ public function medialist(array $getlistermedia, $dir)
+ {
+ ?>
+ <details open>
+ <summary>Media List</summary>
+
+ <form action="" method="post">
+
+ <table id=mediatable>
+ <tr><th>x</th><th>Name</th><th>extension</th><th>width</th><th>height</th><th>size</th><th>code</th><th>thumbnail</th></tr>
+ <?php
+
+
+ foreach ($getlistermedia as $item) {
+ $filepath = $dir . $item->id() . '.' . $item->extension();
+ echo '<tr>';
+ echo '<td><input type="checkbox" name="id[]" value=' . $item->id() . ' id="' . $item->id() . '"></td>';
+ echo '<td><label for="' . $item->id() . '">' . $item->id() . '</label></td>';
+ echo '<td>' . $item->extension() . '</td>';
+ echo '<td>' . $item->width() . '</td>';
+ echo '<td>' . $item->height() . '</td>';
+ echo '<td>' . readablesize($item->size()) . '</td>';
+ if ($item->type() == 'image') {
+ echo '<td><input type="text" value="![' . $item->id() . '](/' . $item->id() . '.' . $item->extension() . ')"></td>';
+ echo '<td class="tooltip">👁<span class="infobulle"><a href="' . $filepath . '" target="_blank" ><img class="thumbnail" src="' . $filepath . '" alt="' . $item->id() . '"></a></span></td>';
+ } elseif ($item->type() == 'sound') {
+ echo '<td><input type="text" value="[' . $item->id() . '](' . $filepath . ')"></td>';
+ echo '<td><a href="' . $filepath . '" target="_blank" >♪</a></td>';
+ } else {
+ echo '<td><input type="text" value="[' . $item->id() . '](' . $filepath . ')"></td>';
+ echo '<td><a href="' . $filepath . '" target="_blank" >∞</a></td>';
+ }
+ echo '</tr>';
+ echo '';
+
+ }
+
+
+ ?>
+
+
+ </table>
+
+ <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>
+
+ </details>
+
+
+ <?php
+
+ }
+
+
+ //______________________________________________________ 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, $app)
+ {
+ ?>
+ <article>
+ <h2>CSS</h2>
+
+ <p>CSS file :</p>
+
+ <p><code> <?= $app::GLOBAL_CSS_DIR ?></code></p>
+
+ <?php
+ $cssfile = $app::GLOBAL_CSS_DIR;
+ if (is_file($cssfile)) {
+ $cssread = file_get_contents($cssfile);
+ echo '<details>';
+ echo '<summary>Edit current CSS</summary>';
+ echo '<form action="./" method="post">';
+ echo '<textarea name="editcss" id="cssarea">' . $cssread . '</textarea>';
+ echo '<input type="hidden" name="action" value="editcss">';
+ echo '<input type="submit" value="edit">';
+ echo '</form>';
+ echo '</details>';
+ }
+
+ ?>
+
+ </article>
+ <?php
+
+ }
+
+ public function admindb($config)
+ {
+ ?>
+
+ <article>
+
+
+ <h2>Database</h2>
+
+ <details>
+ <summary>Database credentials</summary>
+
+ <p>Fill this sections with the database settings you want to connect to</p>
+
+ <form action="./" method="post">
+ <input type="hidden" name="action" value="editconfig">
+ <label for="host">Host</label>
+ <input title="host" type="text" name="host" id="host" value="<?= $config->host() ?>">
+ <label for="dbname">DataBase name</label>
+ <input title="dbname" type="text" name="dbname" id="dbname" value="<?= $config->dbname() ?>">
+ <label for="user">User name</label>
+ <input title="user" type="text" name="user" id="user" value="<?= $config->user() ?>">
+ <label for="password">Password</label>
+ <input title="password" type="text" name="password" id="password" value="<?= $config->password() ?>">
+ <input type="submit" value="edit" id="">
+ </form>
+
+ </details>
+
+
+ </article>
+
+ <?php
+
+ }
+
+ public function adminpassword(Config $config)
+ {
+ ?>
+ <article>
+
+ <h2>Passwords</h2>
+
+ <details>
+ <summary>Admin</summary>
+
+ <p>Edit your own admin password. You can find it in the config.w.json file, in the root of your website folder.</p>
+
+ <form action="./" method="post">
+ <input type="hidden" name="action" value="editconfig">
+ <label for="admin">Administrator password (10)</label>
+ <input title="admin password" type="password" name="admin" id="admin" value="<?= $config->admin() ?>" >
+ <input type="submit" value="edit" id="">
+ </form>
+
+ </details>
+ <details>
+ <summary>Others</summary>
+
+ <p>Use this section to set all the others users passwords. They cant access this page, so they cant change it by themselves.</p>
+
+ <form action="./" method="post">
+ <input type="hidden" name="action" value="editconfig">
+ <label for="editor">Editor password (3)</label>
+ <input title="editor" type="text" name="editor" id="editor" value="<?= $config->editor() ?>">
+ <label for="invite">Invite password (2)</label>
+ <input title="invite" type="text" name="invite" id="invite" value="<?= $config->invite() ?>" >
+ <label for="read">Reader password (1)</label>
+ <input title="read" type="text" name="read" id="read" value="<?= $config->read() ?>">
+ <input type="submit" value="edit" id="">
+ </form>
+
+ </details>
+ </article>
+
+
+
+
+ <?php
+
+ }
+
+ public function admintable(Config $config, string $status, array $arttables)
+ {
+ ?>
+
+ <article>
+
+ <h2>Table</h2>
+
+
+
+ <p>Database status : <strong><?= $status ?></strong></p>
+
+
+ <p>Current Table : <strong><?= $config->arttable(); ?></strong></p>
+ <details>
+ <summary>Select Table</summary>
+ <p>The table is where all your articles are stored, select the one you want to use.</p>
+
+ <form action="./" method="post">
+ <select name="arttable" required>
+
+ <?php
+ foreach ($arttables as $arttable) {
+ if ($arttable == $config->arttable()) {
+ echo '<option value="' . $arttable . '" " selected >' . $arttable . '</option>';
+ } else {
+ echo '<option value="' . $arttable . '">' . $arttable . '</option>';
+ }
+ }
+ ?>
+ </select>
+ <input type="hidden" name="action" value="editconfig">
+ <input type="submit" value="choose">
+ </form>
+
+ </details>
+
+ <details>
+ <summary>Add table</summary>
+
+ <p>Create new table in your database. You need at least one to use W_cms</p>
+
+ <form action="./" method="post">
+ <input type="hidden" name="actiondb" value="addtable">
+ <input type="text" name="tablename" placeholder="table name" maxlength="30" required>
+ <input type="submit" value="create">
+ </form>
+
+ </details>
+
+ <details>
+ <summary>Duplicate Table</summary>
+ <p>If you want to save versions of your work.</p>
+
+ <form action="./" method="post">
+ <label for="arttable">Select the table you want to copy.</label>
+ <select name="arttable" id="arttable" required>
+
+ <?php
+ foreach ($arttables as $arttable) {
+ if ($arttable == $config->arttable()) {
+ echo '<option value="' . $arttable . '" " selected >' . $arttable . '</option>';
+ } else {
+ echo '<option value="' . $arttable . '">' . $arttable . '</option>';
+ }
+ }
+ ?>
+ </select>
+ <label for="tablename">Choose a name for the copy</label>
+ <input type="text" name="tablename" id="tablename" required>
+ <input type="hidden" name="actiondb" value="duplicatetable">
+ <input type="submit" value="Duplicate">
+ </form>
+
+ </details>
+
+ </article>
+
+ <?php
+
+ }
+
+ public function admindisplay($color4)
+ {
+ ?>
+ <article>
+ <h2>Display</h2>
+ <details>
+ <summary>Update favicon</summary>
+ <form action="./" method="post" enctype="multipart/form-data">
+ <input type="file" name="favicon" id="favicon">
+ <input type="submit" value="update">
+ </form>
+ </details>
+ <details>
+ <summary>Change desktop background color</summary>
+ <form action="./" method="post">
+ <label for="color4">Background color</label>
+ <input type="color" name="color4" id="color4" value="<?= $color4 ?>">
+ <input type="hidden" name="action" value="editconfig">
+ <input type="submit" value="color my life">
+ </form>
+ </details>
+ </article>
+ <?php
+
+ }
+
+
+
+
+
+//______________________________________________________ S E T _________________________________________________
+
+ public function setsession($session)
+ {
+ if ($session <= 100 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/w/class/class.w.app.php b/w/class/class.w.app.php
new file mode 100644
index 0000000..922740b
--- /dev/null
+++ b/w/class/class.w.app.php
@@ -0,0 +1,770 @@
+<?php
+class App
+{
+ private $bdd;
+ private $session;
+ private $arttable;
+
+
+ const CONFIG_FILE = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'w.config.json';
+ const GLOBAL_CSS_DIR = '.' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'global' . DIRECTORY_SEPARATOR . 'global.css';
+ const MEDIA_DIR = '.' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR;
+ const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf');
+ const MEDIA_TYPES = ['image', 'video', 'sound', 'other'];
+
+
+ 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)
+ {
+ $caught = true;
+
+ try {
+ $this->bdd = new PDO('mysql:host=' . $config->host() . ';dbname=' . $config->dbname() . ';charset=utf8', $config->user(), $config->password(), array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
+ //$this->bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ } catch (PDOException $e) {
+ $caught = false;
+ echo '<h1>Error 500, database offline</h1>';
+ if ($this->session() >= self::EDITOR) {
+ echo '<p>Error : ' . $e->getMessage() . '</p>';
+ if ($this->session() == self::ADMIN) {
+ echo '<p>Go to the <a href="?aff=admin">Admin Panel</a> to edit your database credentials</p>';
+ } else {
+ echo '<p>Logout and and come back with an <strong>admin password</strong> to edit the database connexions settings.</p>';
+ }
+ } else {
+ echo '<p><a href=".">Homepage for admin login</a> (connect on the top right side)</p>';
+ }
+ exit;
+ }
+
+ return $caught;
+
+ }
+
+ public function settable(Config $config)
+ {
+ if (!empty($config->arttable())) {
+ $this->arttable = $config->arttable();
+ } else {
+ echo '<h1>Table Error</h1>';
+
+ if ($this->session() >= self::EDITOR) {
+ if ($this->session() == self::ADMIN) {
+ echo '<p>Go to the <a href="?aff=admin">Admin Panel</a> to select or add an Article table</p>';
+ } else {
+ echo '<p>Logout and and come back with an <strong>admin password</strong> to edit table settings.</p>';
+ }
+ } else {
+ echo '<p><a href=".">Homepage for admin login</a> (connect on the top right side)</p>';
+ }
+ $caught = false;
+ exit;
+ }
+ }
+
+ public function bddinit(Config $config)
+ {
+ $test = $this->setbdd($config);
+ if ($test) {
+ $this->settable($config);
+ }
+ }
+
+
+// _________________________________________ 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)
+ {
+
+ if ($this->exist($art->id())) {
+ echo '<h4>cet id existe deja</h4>';
+ } else {
+
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $request = 'INSERT INTO ' . $this->arttable . '(id, titre, soustitre, intro, tag, datecreation, datemodif, css, html, secure, couleurtext, couleurbkg, couleurlien, couleurlienblank, lien, template) VALUES(:id, :titre, :soustitre, :intro, :tag, :datecreation, :datemodif, :css, :html, :secure, :couleurtext, :couleurbkg, :couleurlien, :couleurlienblank, :lien, :template)';
+
+ $q = $this->bdd->prepare($request);
+
+ $q->bindValue(':id', $art->id());
+ $q->bindValue(':titre', $art->titre());
+ $q->bindValue(':soustitre', $art->soustitre());
+ $q->bindValue(':intro', $art->intro());
+ $q->bindValue(':tag', $art->tag('string'));
+ $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->md());
+ $q->bindValue(':secure', $art->secure());
+ $q->bindValue(':couleurtext', $art->couleurtext());
+ $q->bindValue(':couleurbkg', $art->couleurbkg());
+ $q->bindValue(':couleurlien', $art->couleurlien());
+ $q->bindValue(':couleurlienblank', $art->couleurlienblank());
+ $q->bindValue(':lien', $art->lien('string'));
+ $q->bindValue(':template', $art->template());
+
+ $q->execute();
+ }
+ }
+
+ public function add2(Art2 $art)
+ {
+
+ if ($this->exist($art->id())) {
+ echo '<span class="alert">idalreadyexist</span>';
+ } else {
+
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $request = 'INSERT INTO ' . $this->arttable . '(id, title, description, tag, date, datecreation, datemodif, daterender, css, quickcss, javascript, html, header, section, nav, aside, footer, render, secure, invitepassword, interface, linkfrom, template, affcount, editcount)
+ VALUES(:id, :title, :description, :tag, :date, :datecreation, :datemodif, :daterender, :css, :quickcss, :javascript, :html, :header, :section, :nav, :aside, :footer, :render, :secure, :invitepassword, :interface, :linkfrom, :template, :affcount, :editcount)';
+
+ $q = $this->bdd->prepare($request);
+
+ $q->bindValue(':id', $art->id());
+ $q->bindValue(':title', $art->title());
+ $q->bindValue(':description', $art->description());
+ $q->bindValue(':tag', $art->tag('string'));
+ $q->bindValue(':date', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':datecreation', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':daterender', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':css', $art->css());
+ $q->bindValue(':quickcss', $art->quickcss('string'));
+ $q->bindValue(':javascript', $art->javascript());
+ $q->bindValue(':html', $art->html());
+ $q->bindValue(':header', $art->header());
+ $q->bindValue(':section', $art->section());
+ $q->bindValue(':nav', $art->nav());
+ $q->bindValue(':aside', $art->aside());
+ $q->bindValue(':footer', $art->footer());
+ $q->bindValue(':render', $art->render());
+ $q->bindValue(':secure', $art->secure());
+ $q->bindValue(':invitepassword', $art->invitepassword());
+ $q->bindValue(':interface', $art->interface());
+ $q->bindValue(':linkfrom', $art->linkfrom('string'));
+ $q->bindValue(':template', $art->template('string'));
+ $q->bindValue(':affcount', $art->affcount());
+ $q->bindValue(':editcount', $art->editcount());
+
+ $q->execute();
+ }
+ }
+
+ public function delete(Art $art)
+ {
+ $req = $this->bdd->prepare('DELETE FROM ' . $this->arttable . ' WHERE id = :id ');
+ $req->execute(array('id' => $art->id()));
+ $req->closeCursor();
+ }
+
+ public function get($id)
+ {
+ $req = $this->bdd->prepare('SELECT * FROM ' . $this->arttable . ' WHERE id = :id ');
+ $req->execute(array('id' => $id));
+ $donnees = $req->fetch(PDO::FETCH_ASSOC);
+
+ return new Art($donnees);
+
+ $req->closeCursor();
+
+ }
+
+
+
+ public function update(Art $art)
+ {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $q = $this->bdd->prepare('UPDATE ' . $this->arttable . ' 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());
+ $q->bindValue(':titre', $art->titre());
+ $q->bindValue(':soustitre', $art->soustitre());
+ $q->bindValue(':intro', $art->intro());
+ $q->bindValue(':tag', $art->tag('string'));
+ $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->md());
+ $q->bindValue(':secure', $art->secure());
+ $q->bindValue(':couleurtext', $art->couleurtext());
+ $q->bindValue(':couleurbkg', $art->couleurbkg());
+ $q->bindValue(':couleurlien', $art->couleurlien());
+ $q->bindValue(':couleurlienblank', $art->couleurlienblank());
+ $q->bindValue(':lien', $art->lien('string'));
+ $q->bindValue(':template', $art->template());
+
+ $q->execute();
+ }
+
+ public function update2(Art2 $art)
+ {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $request = 'UPDATE ' . $this->arttable . '(id, title, description, tag, date, datecreation, datemodif, daterender, css, quickcss, javascript, html, header, section, nav, aside, footer, render, secure, invitepassword, interface, linkfrom, template, affcount, editcount)
+ VALUES(:id, :title, :description, :tag, :date, :datecreation, :datemodif, :daterender, :css, :quickcss, :javascript, :html, :header, :section, :nav, :aside, :footer, :render, :secure, :invitepassword, :interface, :linkfrom, :template, :affcount, :editcount) WHERE id = :id';
+
+ $q = $this->bdd->prepare($request);
+
+ $q->bindValue(':id', $art->id());
+ $q->bindValue(':title', $art->title());
+ $q->bindValue(':description', $art->description());
+ $q->bindValue(':tag', $art->tag('string'));
+ $q->bindValue(':date', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':datecreation', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':daterender', $now->format('Y-m-d H:i:s'));
+ $q->bindValue(':css', $art->css());
+ $q->bindValue(':quickcss', $art->quickcss('string'));
+ $q->bindValue(':javascript', $art->javascript());
+ $q->bindValue(':html', $art->html());
+ $q->bindValue(':header', $art->header());
+ $q->bindValue(':section', $art->section());
+ $q->bindValue(':nav', $art->nav());
+ $q->bindValue(':aside', $art->aside());
+ $q->bindValue(':footer', $art->footer());
+ $q->bindValue(':render', $art->render());
+ $q->bindValue(':secure', $art->secure());
+ $q->bindValue(':invitepassword', $art->invitepassword());
+ $q->bindValue(':interface', $art->interface());
+ $q->bindValue(':linkfrom', $art->linkfrom('string'));
+ $q->bindValue(':template', $art->template('string'));
+ $q->bindValue(':affcount', $art->affcount());
+ $q->bindValue(':editcount', $art->editcount());
+
+ $q->execute();
+ }
+
+
+
+
+ //____________________________________________ L S T ______________________________
+
+
+
+ public function getlister(array $selection = ['id'], array $opt = [])
+ {
+ // give an array using SELECTION columns and sort and desc OPTIONS
+
+ $default = ['tri' => 'id', 'desc' => 'DESC'];
+ $opt = array_update($default, $opt);
+
+ $list = [];
+ $option = ['datecreation', 'titre', 'id', 'intro', 'datemodif', 'tag', 'secure'];
+ if (is_array($selection) && is_string($opt['tri']) && strlen($opt['tri']) < 16 && is_string($opt['desc']) && strlen($opt['desc']) < 5 && in_array($opt['tri'], $option)) {
+
+ $selection = implode(", ", $selection);
+
+ $select = 'SELECT ' . $selection . ' FROM ' . $this->arttable . ' ORDER BY ' . $opt['tri'] . ' ' . $opt['desc'];
+ $req = $this->bdd->query($select);
+ while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) {
+ $list[] = new Art($donnees);
+ }
+ return $list;
+ }
+ }
+
+
+
+
+
+
+ public function getlisteropt(Opt $opt)
+ {
+
+ $artlist = [];
+
+ $select = 'SELECT ' . $opt->col('string') . ' FROM ' . $this->arttable;
+ $req = $this->bdd->query($select);
+ while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) {
+ $artlist[] = new Art($donnees);
+ }
+ return $artlist;
+
+ }
+
+ public function listcalclien(&$artlist)
+ {
+ foreach ($artlist as $art) {
+ $art->calcliento($artlist);
+ }
+ }
+
+ public function artcompare($art1, $art2, $method = 'id', $order = 1)
+ {
+ $result = ($art1->$method('sort') <=> $art2->$method('sort'));
+ return $result * $order;
+
+ }
+
+ public function buildsorter($sortby, $order)
+ {
+ return function ($art1, $art2) use ($sortby, $order) {
+ $result = $this->artcompare($art1, $art2, $sortby, $order);
+ return $result;
+ };
+ }
+
+
+
+ public function artlistsort(&$artlist, $sortby, $order = 1)
+ {
+ return usort($artlist, $this->buildsorter($sortby, $order));
+ }
+
+
+
+
+
+
+ public function filtertagfilter(array $artlist, array $tagchecked, $tagcompare = 'OR')
+ {
+
+ $filteredlist = [];
+ foreach ($artlist as $art) {
+ if (empty($tagchecked)) {
+ $filteredlist[] = $art->id();
+ } else {
+ $inter = (array_intersect($art->tag('array'), $tagchecked));
+ if ($tagcompare == 'OR') {
+ if (!empty($inter)) {
+ $filteredlist[] = $art->id();
+ }
+ } elseif ($tagcompare == 'AND') {
+ if (!array_diff($tagchecked, $art->tag('array'))) {
+ $filteredlist[] = $art->id();
+ }
+ }
+ }
+ }
+ return $filteredlist;
+ }
+
+ public function filtersecure(array $artlist, $secure)
+ {
+ $filteredlist = [];
+ foreach ($artlist as $art) {
+ if ($art->secure() == intval($secure)) {
+ $filteredlist[] = $art->id();
+ } elseif (intval($secure) >= 4) {
+ $filteredlist[] = $art->id();
+ }
+ }
+ return $filteredlist;
+ }
+
+
+ public function lister()
+ {
+ $req = $this->bdd->query(' SELECT * FROM ' . $this->arttable . ' ORDER BY id ');
+ $donnees = $req->fetchAll(PDO::FETCH_ASSOC);
+ $req->closeCursor();
+ return $donnees;
+
+ }
+
+ public function tag(array $artlist, $tagchecked)
+ {
+ $artcheckedlist = [];
+ foreach ($artlist as $art) {
+ if (in_array($tagchecked, $art->tag('array'))) {
+ $artcheckedlist[] = $art;
+ }
+ }
+ return $artcheckedlist;
+ }
+
+ public function taglist(array $artlist, array $tagcheckedlist)
+ {
+ $taglist = [];
+ foreach ($tagcheckedlist as $tag) {
+ $taglist[$tag] = $this->tag($artlist, $tag);
+ }
+ return $taglist;
+ }
+
+ public function count()
+ {
+ return $this->bdd->query(' SELECT COUNT(*) FROM ' . $this->arttable . ' ')->fetchColumn();
+ }
+
+ public function exist($id)
+ {
+ $req = $this->bdd->prepare(' SELECT COUNT(*) FROM ' . $this->arttable . ' WHERE id = :id ');
+ $req->execute(array('id' => $id));
+ $donnees = $req->fetch(PDO::FETCH_ASSOC);
+
+ return (bool)$donnees['COUNT(*)'];
+ }
+
+
+ // __________________________________________ T A B L E ________________________________________________________
+
+
+ public function tableexist($dbname, $tablename)
+ {
+
+ $req = $this->bdd->prepare('SELECT COUNT(*)
+ FROM information_schema.tables
+ WHERE table_schema = :dbname AND
+ table_name like :tablename');
+ $req->execute(array(
+ 'dbname' => $dbname,
+ 'tablename' => $tablename
+ ));
+ $donnees = $req->fetch(PDO::FETCH_ASSOC);
+ $req->closeCursor();
+ $exist = intval($donnees['COUNT(*)']);
+ return $exist;
+
+
+
+
+ }
+
+ public function tablelist($dbname)
+ {
+ $request = 'SHOW TABLES IN ' . $dbname;
+ $req = $this->bdd->query($request);
+ $donnees = $req->fetchAll(PDO::FETCH_ASSOC);
+ $req->closeCursor();
+
+ $arttables = [];
+ foreach ($donnees as $table) {
+ $arttables[] = $table['Tables_in_' . $dbname];
+ }
+ return $arttables;
+
+
+ }
+
+
+ public function addtable($dbname, $tablename)
+ {
+
+ if (!$this->tableexist($dbname, $tablename)) {
+
+ $table = "CREATE TABLE `$tablename` (
+ `id` varchar(255) NOT NULL DEFAULT 'art',
+ `titre` varchar(255) NOT NULL DEFAULT 'titre',
+ `soustitre` varchar(255) NOT NULL DEFAULT 'soustitre',
+ `intro` varchar(255) NOT NULL DEFAULT 'intro',
+ `tag` varchar(255) NOT NULL DEFAULT 'sans tag,',
+ `datecreation` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `datemodif` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `css` text,
+ `html` text,
+ `secure` int(1) NOT NULL DEFAULT '0',
+ `couleurtext` varchar(7) NOT NULL DEFAULT '#000000',
+ `couleurbkg` varchar(7) NOT NULL DEFAULT '#ffffff',
+ `couleurlien` varchar(7) NOT NULL DEFAULT '#2a3599',
+ `couleurlienblank` varchar(7) NOT NULL DEFAULT '#2a8e99',
+ `lien` varchar(255) DEFAULT NULL,
+ `template` varchar(255) DEFAULT NULL
+ )";
+
+ $alter = "ALTER TABLE `$tablename`
+ ADD PRIMARY KEY (`id`)";
+
+ $req = $this->bdd->query($table);
+ $req = $this->bdd->query($alter);
+
+ return 'tablecreated';
+ } else {
+ return 'tablealreadyexist';
+ }
+ }
+
+
+
+ public function tableduplicate($dbname, $arttable, $tablename)
+ {
+ $arttable = strip_tags($arttable);
+ $tablename = str_clean($tablename);
+ if ($this->tableexist($dbname, $arttable) && !$this->tableexist($dbname, $tablename)) {
+ $duplicate = " CREATE TABLE `$tablename` LIKE `$arttable`;";
+ $alter = "ALTER TABLE `$tablename` ADD PRIMARY KEY (`id`);";
+ $insert = "INSERT `$tablename` SELECT * FROM `$arttable`;";
+
+
+ $req = $this->bdd->query($duplicate . $alter . $insert);
+
+ return 'tableduplicated';
+ } else {
+ return 'tablealreadyexist';
+ }
+ }
+
+
+
+
+// __________________________________________ M E D ________________________________________________________
+
+ public function addmedia(array $file, $maxsize = 2 ** 24, $id)
+ {
+ $message = 'runing';
+ $id = strtolower(strip_tags($id));
+ $id = str_replace(' ', '_', $id);
+ if (isset($file) and $file['media']['error'] == 0 and $file['media']['size'] < $maxsize) {
+ $infosfichier = pathinfo($file['media']['name']);
+ $extension_upload = $infosfichier['extension'];
+ $extensions_autorisees = $this::MEDIA_EXTENSIONS;
+ if (in_array($extension_upload, $extensions_autorisees)) {
+ if (!file_exists($this::MEDIA_DIR . $id . '.' . $extension_upload)) {
+
+ $extension_upload = strtolower($extension_upload);
+ $uploadok = move_uploaded_file($file['media']['tmp_name'], $this::MEDIA_DIR . $id . '.' . $extension_upload);
+ if ($uploadok) {
+ $message = 'uploadok';
+ } else {
+ $message = 'uploaderror';
+ }
+ } else {
+ $message = 'filealreadyexist';
+
+ }
+ }
+ } else {
+ $message = 'filetoobig';
+
+ }
+
+ return $message;
+ }
+
+
+ public function getmedia($entry, $dir)
+ {
+ $fileinfo = pathinfo($entry);
+
+ $filepath = $fileinfo['dirname'] . '.' . $fileinfo['extension'];
+
+ $donnees = array(
+ 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']),
+ 'path' => $dir,
+ 'extension' => $fileinfo['extension']
+ );
+
+
+
+ return new Media($donnees);
+
+ }
+
+ public function getlistermedia($dir, $type = "all")
+ {
+ if ($handle = opendir($dir)) {
+ $list = [];
+ while (false !== ($entry = readdir($handle))) {
+ if ($entry != "." && $entry != "..") {
+
+ $media = $this->getmedia($entry, $dir);
+
+
+ $media->analyse();
+
+ if (in_array($type, self::MEDIA_TYPES)) {
+ if ($media->type() == $type) {
+ $list[] = $media;
+ }
+ } else {
+ $list[] = $media;
+ }
+
+
+ }
+ }
+ return $list;
+ }
+
+ return $list;
+
+ }
+
+
+
+
+ //_________________________________________________________ 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 dirlist($dir, $extension)
+ {
+ if ($handle = opendir($dir)) {
+ $list = [];
+ while (false !== ($entry = readdir($handle))) {
+ if ($entry != "." && $entry != ".." && pathinfo($entry)['extension'] == $extension) {
+
+ $list[] = $entry;
+
+ }
+ }
+ return $list;
+ }
+ }
+
+ public function downloadtable()
+ {
+
+ }
+
+
+
+
+ // ________________________________________________________ M A P ________________________________________________________
+
+
+ public function map(array $getlister, $lb = PHP_EOL)
+ {
+
+ $map = "";
+ $link = "";
+ $style = "";
+ foreach ($getlister as $item) {
+ if($item->secure() == 2) {
+ $style = $style . $lb . $item->id() . '{' . $item->titre() . '}';
+ } elseif ($item->secure() == 1) {
+ $style = $style . $lb . $item->id() . '(' . $item->titre() . ')';
+
+ } else {
+ $style = $style . $lb . $item->id() . '((' . $item->titre() . '))';
+ }
+ foreach ($item->lien('array') as $lien) {
+ $map = $map . $lb . $item->id() . ' --> ' . $lien;
+ $link = $link . $lb . 'click ' . $lien . ' "./?id=' . $lien . '"';
+
+ }
+ $link = $link . $lb . 'click ' . $item->id() . ' "./?id=' . $item->id() . '"';
+ }
+ return $map . $link . $style;
+
+ }
+
+
+
+
+
+ //_________________________________________________________ S E S ________________________________________________________
+
+ public function login($pass, $config)
+ {
+ if (strip_tags($pass) == $config->admin()) {
+ return $level = self::ADMIN;
+ } elseif (strip_tags($pass) == $config->read()) {
+ return $level = self::READ;
+ } elseif (strip_tags($pass) == $config->editor()) {
+ return $level = self::EDITOR;
+ } elseif (strip_tags($pass) == $config->invite()) {
+ return $level = self::INVITE;
+ }
+ }
+
+ public function logout()
+ {
+ 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/w/class/class.w.art.php b/w/class/class.w.art.php
new file mode 100644
index 0000000..001b29d
--- /dev/null
+++ b/w/class/class.w.art.php
@@ -0,0 +1,501 @@
+<?php
+
+use Michelf\MarkdownExtra;
+
+
+class Art
+{
+ private $id;
+ private $titre;
+ private $soustitre;
+ private $intro;
+ private $tag;
+ private $datecreation;
+ private $datemodif;
+ private $css;
+ private $html;
+ private $secure;
+ private $couleurtext;
+ private $couleurbkg;
+ private $couleurlien;
+ private $couleurlienblank;
+ private $lien;
+ private $liento;
+ private $template;
+
+ const LEN = 255;
+ const LENHTML = 20000;
+ const SECUREMAX = 2;
+ const LENCOULEUR = 7;
+ const DEBUT = '(?id=';
+ const FIN = ')';
+
+
+
+
+// _____________________________________________________ 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 reset()
+ {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $this->settitre($this->id());
+ $this->setsoustitre('');
+ $this->setintro('');
+ $this->settag('');
+ $this->setdatecreation($now);
+ $this->setcss('');
+ $this->sethtml('');
+ $this->setsecure(2);
+ $this->setcouleurtext('#000000');
+ $this->setcouleurbkg('#FFFFFF');
+ $this->setcouleurlien('#000000');
+ $this->setcouleurlienblank('#000000');
+ $this->setlien('');
+ $this->settemplate('');
+ }
+
+ public function updatelien()
+ {
+ $this->lien = [];
+ $this->lien = array_unique(search($this->md(true), self::DEBUT, self::FIN));
+
+ }
+
+ public static function classvarlist()
+ {
+ $classvarlist = [];
+ foreach (get_class_vars(__class__) as $var => $default) {
+ $classvarlist[] = $var;
+ }
+ return ['artvarlist' => $classvarlist];
+ }
+
+
+
+
+ public function calcliento($getlist)
+ {
+ $liento = [];
+ foreach ($getlist as $lien) {
+ if (in_array($this->id(), $lien->lien('array'))) {
+ $liento[] = $lien->id();
+ }
+ }
+ $this->setliento($liento);
+ }
+
+
+ public function autotaglist()
+ {
+ $pattern = "/%%(\w*)%%/";
+ preg_match_all($pattern, $this->md(), $out);
+ return $out[1];
+
+ }
+
+ public function autotaglistupdate($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ $replace = '<ul>';
+ foreach ($artlist as $art) {
+ $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->intro() . '">' . $art->titre() . '</a></li>';
+ }
+ $replace .= '</ul>';
+ $this->html = str_replace('%%' . $tag . '%%', $replace, $this->html);
+ }
+ }
+
+ public function autotaglistcalc($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ foreach ($artlist as $art) {
+ if(!in_array($art->id(), $this->lien('array')) && $art->id() != $this->id()) {
+ $this->lien[] = $art->id();
+ }
+ }
+ }
+ }
+
+
+ // _____________________________________________________ G E T ____________________________________________________
+
+ public function id($type = 'string')
+ {
+ return $this->id;
+ }
+
+ public function titre($type = 'string')
+ {
+ return $this->titre;
+ }
+
+ public function soustitre($type = 'string')
+ {
+ return $this->soustitre;
+ }
+
+ public function intro($type = 'string')
+ {
+ return $this->intro;
+ }
+
+ public function tag($option)
+ {
+ if ($option == 'string') {
+ return implode(", ", $this->tag);
+ } elseif ($option == 'array') {
+ return $this->tag;
+ } elseif ($option == 'sort') {
+ return count($this->tag);
+ }
+ }
+
+ public function datecreation($option)
+ {
+ if ($option == 'string') {
+ return $this->datecreation->format('Y-m-d H:i:s');
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->datecreation;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->datecreation->diff($now));
+ }
+ }
+
+
+ public function datemodif($option)
+ {
+ if ($option == 'string') {
+ return $this->datemodif->format('Y-m-d H:i:s');
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->datemodif;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->datemodif->diff($now));
+ }
+ }
+
+ public function css($type = 'string')
+ {
+ return $this->css;
+ }
+
+ public function cssprint()
+ {
+ return $cssprint;
+ }
+
+ public function csstemplate(App $app)
+ {
+ $data = [];
+ $temp = '';
+ if (!empty($this->template())) {
+ if ($app->exist($this->template()) and !in_array($this->template(), $data)) {
+ $template = $app->get($this->template());
+ $temp = $temp . $template->css($app);
+ $data[] = $template->id();
+
+ }
+
+ }
+ $cssprint = str_replace('url(/', 'url('.$app::MEDIA_DIR , $temp . $this->css);
+ return $cssprint;
+ }
+
+ public function md($expand = false)
+ {
+ if ($expand == true) {
+ $md = str_replace('](=', '](?id=', $this->html);
+ } else {
+ $md = $this->html;
+ }
+ return $md;
+ }
+
+ public function html(App $app)
+ {
+
+ // %%%% TITLE & DESCIPTION
+ $html = str_replace('%TITLE%', $this->titre(), $this->html);
+ $html = str_replace('%DESCRIPTION%', $this->intro(), $html);
+
+ $parser = new MarkdownExtra;
+
+ // id in headers
+ $parser->header_id_func = function ($header) {
+ return preg_replace('/[^\w]/', '', strtolower($header));
+ };
+ $html = $parser->transform($html);
+
+ // replace = > ?id=
+ $html = str_replace('href="=', 'href="?id=', $html);
+
+
+ // infobulles tooltip
+ foreach ($this->lien('array') as $id) {
+ $title = "Cet article n'existe pas encore";
+ foreach ($app->getlister(['id', 'intro']) as $item) {
+ if ($item->id() == $id) {
+ $title = $item->intro();
+ }
+ }
+ $lien = 'href="?id=' . $id . '"';
+ $titlelien = ' title="' . $title . '" ' . $lien;
+ $html = str_replace($lien, $titlelien, $html);
+ }
+
+ if(!empty(strstr($html, '%SUMMARY%'))) {
+
+
+
+ $html = str_replace('%SUMMARY%', sumparser($html), $html);
+ }
+
+
+ $html = str_replace('href="./media/', ' class="file" target="_blank" href="./media/', $html);
+ $html = str_replace('href="http', ' class="external" target="_blank" href="http', $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;
+
+
+ }
+
+ public function secure($type = 'int')
+ {
+ if ($type == 'string') {
+ if ($this->secure == 0) $secure = 'public';
+ if ($this->secure == 1) $secure = 'private';
+ if ($this->secure == 2) $secure = 'not published';
+ return $secure;
+ } else {
+ return $this->secure;
+ }
+ }
+
+ public function couleurtext()
+ {
+ return $this->couleurtext;
+ }
+
+ public function couleurbkg()
+ {
+ return $this->couleurbkg;
+ }
+
+ public function couleurlien()
+ {
+ return $this->couleurlien;
+ }
+
+ public function couleurlienblank()
+ {
+ return $this->couleurlienblank;
+ }
+
+ public function lien($option)
+ {
+ if ($option == 'string') {
+ $lien = implode(", ", $this->lien);
+ } elseif ($option == 'array') {
+ $lien = $this->lien;
+ } elseif ($option == 'sort') {
+ return count($this->lien);
+ }
+ return $lien;
+
+ }
+
+ public function liento($option)
+ {
+ if ($option == 'string') {
+ $liento = implode(", ", $this->liento);
+ } elseif ($option == 'array') {
+ $liento = $this->liento;
+ } elseif ($option == 'sort') {
+ return count($this->liento);
+ }
+ return $liento;
+
+ }
+
+ public function template($type = 'string')
+ {
+ return $this->template;
+ }
+
+
+
+
+
+ // _____________________________________________________ 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 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 setintro($intro)
+ {
+ if (strlen($intro) < self::LEN and is_string($intro)) {
+ $this->intro = strip_tags(trim($intro));
+ }
+ }
+
+ public function settag($tag)
+ {
+ if (is_string($tag)) {
+
+ if (strlen($tag) < self::LEN and is_string($tag)) {
+ $tag = strip_tags(trim(strtolower($tag)));
+ $tag = str_replace('*', '', $tag);
+ $tag = str_replace(' ', '', $tag);
+
+ $taglist = explode(",", $tag);
+ $taglist = array_filter($taglist);
+ $this->tag = $taglist;
+ }
+ } elseif (is_array($tag)) {
+ $this->tag = $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 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::LENHTML 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 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 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 setcouleurlienblank($couleurlienblank)
+ {
+ $couleurlienblank = strval($couleurlienblank);
+ if (strlen($couleurlienblank) <= self::LENCOULEUR) {
+ $this->couleurlienblank = strip_tags(trim($couleurlienblank));
+ }
+ }
+
+ public function setlien($lien)
+ {
+ if (!empty($lien) && strlen($lien) < self::LEN && is_string($lien)) {
+ $lien = strip_tags(trim(strtolower($lien)));
+ $lienlist = explode(", ", $lien);
+ $this->lien = $lienlist;
+ } else {
+ $this->lien = [];
+ }
+ }
+
+ public function setliento($liento)
+ {
+ if (is_array($liento)) {
+ $this->liento = $liento;
+ }
+
+
+ }
+
+ public function settemplate($template)
+ {
+ $template = strip_tags($template);
+ if (strlen($template) == 0) {
+ $template = 'NULL';
+ }
+ $this->template = $template;
+ }
+
+
+}
+
+
+?> \ No newline at end of file
diff --git a/w/class/class.w.art2.php b/w/class/class.w.art2.php
new file mode 100644
index 0000000..feee0ca
--- /dev/null
+++ b/w/class/class.w.art2.php
@@ -0,0 +1,585 @@
+<?php
+
+use Michelf\MarkdownExtra;
+
+
+class Art
+{
+ private $id;
+ private $title;
+ private $description;
+ private $tag;
+ private $date;
+ private $datecreation;
+ private $datemodif;
+ private $daterender;
+ private $css;
+ private $quickcss;
+ private $javascript;
+ private $html;
+ private $header;
+ private $section;
+ private $nav;
+ private $aside;
+ private $footer;
+ private $render;
+ private $secure;
+ private $invitepassword;
+ private $interface;
+ private $linkfrom;
+ private $template;
+ private $affcount;
+ private $editcount;
+
+ private $linkto;
+
+ const LEN = 255;
+ const LENHTML = 20000;
+ const SECUREMAX = 2;
+ const LENCOULEUR = 7;
+ const DEBUT = '(?id=';
+ const FIN = ')';
+
+
+
+
+// _____________________________________________________ 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 reset()
+ {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+
+ $this->settitle($this->id());
+ $this->setdescription('');
+ $this->settag([]);
+ $this->setdate($now);
+ $this->setdatecreation($now);
+ $this->setdatecreation($now);
+ $this->setdatemodif($now);
+ $this->setdaterender($now);
+ $this->setcss('');
+ $this->setquickcss([]);
+ $this->setjavascript('');
+ $this->sethtml('');
+ $this->setheader('');
+ $this->setsection('');
+ $this->setnav('');
+ $this->setaside('');
+ $this->setfooter('');
+ $this->setsecure(2);
+ $this->setinterface('section');
+ $this->setlinkfrom([]);
+ $this->settemplate([]);
+ $this->setaffcount(0);
+ $this->seteditcount(0);
+ }
+
+ public function updatelien()
+ {
+ $this->linkfrom = [];
+ $this->linkfrom = array_unique(search($this->md(true), self::DEBUT, self::FIN));
+
+ }
+
+ public static function classvarlist()
+ {
+ $classvarlist = [];
+ foreach (get_class_vars(__class__) as $var => $default) {
+ $classvarlist[] = $var;
+ }
+ return ['artvarlist' => $classvarlist];
+ }
+
+
+
+
+ public function calcliento($getlist)
+ {
+ $liento = [];
+ foreach ($getlist as $lien) {
+ if (in_array($this->id(), $lien->lien('array'))) {
+ $liento[] = $lien->id();
+ }
+ }
+ $this->setliento($liento);
+ }
+
+
+ public function autotaglist()
+ {
+ $pattern = "/%%(\w*)%%/";
+ preg_match_all($pattern, $this->md(), $out);
+ return $out[1];
+
+ }
+
+ public function autotaglistupdate($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ $replace = '<ul>';
+ foreach ($artlist as $art) {
+ $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->intro() . '">' . $art->titre() . '</a></li>';
+ }
+ $replace .= '</ul>';
+ $this->html = str_replace('%%' . $tag . '%%', $replace, $this->html);
+ }
+ }
+
+ public function autotaglistcalc($taglist)
+ {
+ foreach ($taglist as $tag => $artlist) {
+ foreach ($artlist as $art) {
+ if (!in_array($art->id(), $this->lien('array')) && $art->id() != $this->id()) {
+ $this->lien[] = $art->id();
+ }
+ }
+ }
+ }
+
+
+ // _____________________________________________________ G E T ____________________________________________________
+
+ public function id($type = 'string')
+ {
+ return $this->id;
+ }
+
+ public function title($type = 'string')
+ {
+ return $this->title;
+ }
+
+ public function description($type = 'string')
+ {
+ return $this->description;
+ }
+
+ public function tag($option)
+ {
+ if ($option == 'string') {
+ return implode(", ", $this->tag);
+ } elseif ($option == 'array') {
+ return $this->tag;
+ } elseif ($option == 'sort') {
+ return count($this->tag);
+ }
+ }
+
+ public function date($option)
+ {
+ if ($option == 'string') {
+ return $this->date->format('Y-m-d H:i:s');
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->date;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->date->diff($now));
+ }
+ }
+
+ public function datecreation($option)
+ {
+ if ($option == 'string') {
+ return $this->datecreation->format('Y-m-d H:i:s');
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->datecreation;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->datecreation->diff($now));
+ }
+ }
+
+
+ public function datemodif($option)
+ {
+ if ($option == 'string') {
+ return $this->datemodif->format('Y-m-d H:i:s');
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->datemodif;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->datemodif->diff($now));
+ }
+ }
+
+ public function daterender($option)
+ {
+ if ($option == 'string') {
+ return $this->daterender->format('Y-m-d H:i:s');
+ } elseif ($option == 'date' || $option == 'sort') {
+ return $this->daterender;
+ } elseif ($option == 'hrdi') {
+ $now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
+ return hrdi($this->daterender->diff($now));
+ }
+ }
+
+ public function css($type = 'string')
+ {
+ return $this->css;
+ }
+
+ public function quickcss($option = 'json')
+ {
+ if ($option == 'json') {
+ return json_encode($this->quickcss);
+ } elseif ($option == 'array') {
+ return $this->quickcss;
+ } elseif ($option == 'string') {
+ $string = '';
+ foreach ($this->quickcss as $key => $css) {
+ $string .= PHP_EOL . $key . ' {';
+ foreach ($css as $param => $value) {
+ if(is_int($value)) {
+ $string .= PHP_EOL . ' ' . $param . ': ' . $value . 'px;';
+ } else {
+ $string .= PHP_EOL . ' ' . $param . ': ' . $value . ';';
+ }
+ }
+ $string .= PHP_EOL . '}' . PHP_EOL;
+ }
+ return $string;
+ }
+ }
+
+ public function cssprint()
+ {
+ return $cssprint;
+ }
+
+ public function csstemplate(App $app)
+ {
+ $data = [];
+ $temp = '';
+ if (!empty($this->template())) {
+ if ($app->exist($this->template()) and !in_array($this->template(), $data)) {
+ $template = $app->get($this->template());
+ $temp = $temp . $template->css($app);
+ $data[] = $template->id();
+
+ }
+
+ }
+ $cssprint = str_replace('url(/', 'url(' . $app::MEDIA_DIR, $temp . $this->css);
+ return $cssprint;
+ }
+
+ public function md($expand = false)
+ {
+ if ($expand == true) {
+ $md = str_replace('](=', '](?id=', $this->html);
+ } else {
+ $md = $this->html;
+ }
+ return $md;
+ }
+
+ public function html(App $app)
+ {
+
+ // %%%% TITLE & DESCIPTION
+ $html = str_replace('%TITLE%', $this->titre(), $this->html);
+ $html = str_replace('%DESCRIPTION%', $this->intro(), $html);
+
+ $parser = new MarkdownExtra;
+
+ // id in headers
+ $parser->header_id_func = function ($header) {
+ return preg_replace('/[^\w]/', '', strtolower($header));
+ };
+ $html = $parser->transform($html);
+
+ // replace = > ?id=
+ $html = str_replace('href="=', 'href="?id=', $html);
+
+
+ // infobulles tooltip
+ foreach ($this->lien('array') as $id) {
+ $title = "Cet article n'existe pas encore";
+ foreach ($app->getlister(['id', 'intro']) as $item) {
+ if ($item->id() == $id) {
+ $title = $item->intro();
+ }
+ }
+ $lien = 'href="?id=' . $id . '"';
+ $titlelien = ' title="' . $title . '" ' . $lien;
+ $html = str_replace($lien, $titlelien, $html);
+ }
+
+ if (!empty(strstr($html, '%SUMMARY%'))) {
+
+
+
+ $html = str_replace('%SUMMARY%', sumparser($html), $html);
+ }
+
+
+ $html = str_replace('href="./media/', ' class="file" target="_blank" href="./media/', $html);
+ $html = str_replace('href="http', ' class="external" target="_blank" href="http', $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;
+
+
+ }
+
+ public function secure($type = 'int')
+ {
+ if ($type == 'string') {
+ if ($this->secure == 0) $secure = 'public';
+ if ($this->secure == 1) $secure = 'private';
+ if ($this->secure == 2) $secure = 'not published';
+ return $secure;
+ } else {
+ return $this->secure;
+ }
+ }
+
+ public function couleurtext()
+ {
+ return $this->couleurtext;
+ }
+
+ public function couleurbkg()
+ {
+ return $this->couleurbkg;
+ }
+
+ public function couleurlien()
+ {
+ return $this->couleurlien;
+ }
+
+ public function couleurlienblank()
+ {
+ return $this->couleurlienblank;
+ }
+
+ public function lien($option)
+ {
+ if ($option == 'string') {
+ $lien = implode(", ", $this->lien);
+ } elseif ($option == 'array') {
+ $lien = $this->lien;
+ } elseif ($option == 'sort') {
+ return count($this->lien);
+ }
+ return $lien;
+
+ }
+
+ public function liento($option)
+ {
+ if ($option == 'string') {
+ $liento = implode(", ", $this->liento);
+ } elseif ($option == 'array') {
+ $liento = $this->liento;
+ } elseif ($option == 'sort') {
+ return count($this->liento);
+ }
+ return $liento;
+
+ }
+
+ public function template($type = 'string')
+ {
+ return $this->template;
+ }
+
+
+
+
+
+ // _____________________________________________________ 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 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 setintro($intro)
+ {
+ if (strlen($intro) < self::LEN and is_string($intro)) {
+ $this->intro = strip_tags(trim($intro));
+ }
+ }
+
+ public function settag($tag)
+ {
+ if (is_string($tag)) {
+
+ if (strlen($tag) < self::LEN and is_string($tag)) {
+ $tag = strip_tags(trim(strtolower($tag)));
+ $tag = str_replace('*', '', $tag);
+ $tag = str_replace(' ', '', $tag);
+
+ $taglist = explode(",", $tag);
+ $taglist = array_filter($taglist);
+ $this->tag = $taglist;
+ }
+ } elseif (is_array($tag)) {
+ $this->tag = $tag;
+ }
+ }
+
+ public function setdate($date)
+ {
+ if ($date instanceof DateTimeImmutable) {
+ $this->date = $date;
+ } else {
+ $this->date = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date, 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 setdaterender($daterender)
+ {
+ if ($daterender instanceof DateTimeImmutable) {
+ $this->daterender = $daterender;
+ } else {
+ $this->daterender = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $daterender, new DateTimeZone('Europe/Paris'));
+ }
+ }
+
+ public function setquickcss($quickcss)
+ {
+
+ }
+
+ public function setcss($css)
+ {
+ if (strlen($css) < self::LENHTML 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 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 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 setcouleurlienblank($couleurlienblank)
+ {
+ $couleurlienblank = strval($couleurlienblank);
+ if (strlen($couleurlienblank) <= self::LENCOULEUR) {
+ $this->couleurlienblank = strip_tags(trim($couleurlienblank));
+ }
+ }
+
+ public function setlien($lien)
+ {
+ if (!empty($lien) && strlen($lien) < self::LEN && is_string($lien)) {
+ $lien = strip_tags(trim(strtolower($lien)));
+ $lienlist = explode(", ", $lien);
+ $this->lien = $lienlist;
+ } else {
+ $this->lien = [];
+ }
+ }
+
+ public function setliento($liento)
+ {
+ if (is_array($liento)) {
+ $this->liento = $liento;
+ }
+
+
+ }
+
+ public function settemplate($template)
+ {
+ $template = strip_tags($template);
+ if (strlen($template) == 0) {
+ $template = 'NULL';
+ }
+ $this->template = $template;
+ }
+
+
+}
+
+
+?> \ No newline at end of file
diff --git a/w/class/class.w.config.php b/w/class/class.w.config.php
new file mode 100644
index 0000000..3b4cde0
--- /dev/null
+++ b/w/class/class.w.config.php
@@ -0,0 +1,188 @@
+<?php
+
+
+
+class Config
+{
+ private $host;
+ private $dbname;
+ private $user;
+ private $password;
+ private $arttable;
+ private $domain;
+ private $admin;
+ private $editor;
+ private $invite;
+ private $read;
+ private $color4;
+ private $fontsize = 6;
+
+
+// _______________________________________ 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 arttable()
+ {
+ return $this->arttable;
+ }
+
+ 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 color4()
+ {
+ return $this->color4;
+ }
+
+ public function fontsize()
+ {
+ return $this->fontsize;
+ }
+
+
+
+// __________________________________________ 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 setarttable($arttable)
+ {
+ $this->arttable = strip_tags($arttable);
+ }
+
+ 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 setcolor4($color4)
+ {
+ if(strlen($color4) <= 8) {
+ $this->color4 = $color4;
+ }
+ }
+
+ public function setfontsize($fontsize)
+ {
+ $fontsize = intval($fontsize);
+ if($fontsize > 1) {
+ $this->fontsize = $fontsize;
+ }
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
+?> \ No newline at end of file
diff --git a/w/class/class.w.media.php b/w/class/class.w.media.php
new file mode 100644
index 0000000..2d27be7
--- /dev/null
+++ b/w/class/class.w.media.php
@@ -0,0 +1,173 @@
+<?php
+
+class Media
+{
+ private $id;
+ private $path;
+ private $extension;
+ private $type;
+ private $size;
+ private $width;
+ private $height;
+ private $length;
+
+ const IMAGE = array('jpg', 'jpeg', 'gif', 'png');
+ const SOUND = array('mp3', 'flac');
+ const VIDEO = array('mp4', 'mov', 'avi');
+
+
+
+// _____________________________________________________ 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 analyse()
+ {
+ $this->settype();
+
+ $filepath = $this->path . $this->id . '.' . $this->extension;
+
+ $this->size = filesize($filepath);
+
+ if ($this->type == 'image') {
+ list($width, $height, $type, $attr) = getimagesize($filepath);
+ $this->width = $width;
+ $this->height = $height;
+ }
+
+
+ }
+
+
+
+// _________________________________________________ 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;
+ }
+
+ public function length()
+ {
+ return $this->length;
+ }
+
+// ___________________________________________________ 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 settype()
+ {
+ if (isset($this->extension)) {
+ if (in_array($this->extension, $this::IMAGE)) {
+ $this->type = "image";
+ } elseif (in_array($this->extension, $this::SOUND)) {
+ $this->type = "sound";
+ } elseif (in_array($this->extension, $this::VIDEO)) {
+ $this->type = "video";
+ } else {
+ $this->type = "other";
+ }
+ }
+ }
+
+ 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));
+ }
+ }
+
+ public function setlength($length)
+ {
+ if ($this->type == 'sound') {
+ $this->length = $length;
+ }
+ }
+
+
+
+
+
+
+}
+
+?> \ No newline at end of file
diff --git a/w/class/class.w.opt.php b/w/class/class.w.opt.php
new file mode 100644
index 0000000..7164cb7
--- /dev/null
+++ b/w/class/class.w.opt.php
@@ -0,0 +1,272 @@
+<?php
+class Opt
+{
+ private $sortby = 'id';
+ private $order = 1;
+ private $tagfilter = [];
+ private $tagcompare = 'OR';
+ private $secure = 4;
+ private $liento = ['min' => '0', 'max' => '0'];
+ private $lienfrom = ['min' => '0', 'max' => '0'];
+ private $col = ['id'];
+ private $taglist = [];
+ private $invert = 0;
+
+ private $artvarlist;
+
+ 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 resetall()
+ {
+ $varlist = get_class_vars(__class__);
+
+ foreach ($varlist as $var => $default) {
+ $method = 'set' . $var;
+ $this->$method($default);
+ }
+ }
+
+ public function reset($var)
+ {
+ $varlist = get_class_vars(__class__);
+ if(in_array($var, $varlist)) {
+ $this->$var = $varlist[$var];
+ }
+ }
+
+ public function submit()
+ {
+ if(isset($_GET['submit'])) {
+ if ($_GET['submit'] == 'reset') {
+ $_SESSION['opt'] = [];
+ } elseif ($_GET['submit'] == 'filter') {
+ $this->getall();
+ }
+ } else {
+ $this->sessionall();
+ }
+ }
+
+ public function getall()
+ {
+ $optlist = ['sortby', 'order', 'secure', 'tagcompare', 'tagfilter', 'invert'];
+
+ foreach ($optlist as $method) {
+ if (method_exists($this, $method)) {
+ if(isset($_GET[$method])) {
+ $setmethod = 'set'. $method;
+ $this->$setmethod($_GET[$method]);
+ } else {
+ $this->reset($method);
+ }
+ $_SESSION['opt'][$method] = $this->$method();
+ }
+ }
+ }
+
+ public function sessionall()
+ {
+ if(isset($_SESSION['opt'])) {
+ $this->hydrate($_SESSION['opt']);
+ }
+ }
+
+
+
+ // _______________________________________________ G E T _______________________________________________
+
+ public function sortby()
+ {
+ return $this->sortby;
+ }
+
+ public function order()
+ {
+ return $this->order;
+ }
+
+ public function secure()
+ {
+ return $this->secure;
+ }
+
+ public function tagfilter($type = 'array')
+ {
+ return $this->tagfilter;
+ }
+
+ public function tagcompare()
+ {
+ return $this->tagcompare;
+ }
+
+ public function liento($type = 'array')
+ {
+ return $this->liento;
+ }
+
+ public function lienfrom($type = 'array')
+ {
+ return $this->lienfrom;
+ }
+
+ public function col($type = 'array')
+ {
+ if ($type == 'string') {
+ return implode(', ', $this->col);
+ } else {
+ return ($this->col);
+ }
+ }
+
+ public function taglist()
+ {
+ return $this->taglist;
+ }
+
+ public function invert()
+ {
+ return $this->invert;
+ }
+
+ public function artvarlist()
+ {
+ return $this->artvarlist;
+ }
+
+
+ // __________________________________________________ S E T _____________________________________________
+
+ public function setsortby($sortby)
+ {
+ if (is_string($sortby) && in_array($sortby, $this->artvarlist())) {
+ $this->sortby = strtolower(strip_tags($sortby));
+ }
+ }
+
+ public function setorder($order)
+ {
+ $order = intval($order);
+ if (in_array($order, [-1, 0, 1])) {
+ $this->order = $order;
+ }
+ }
+
+ public function settagfilter($tagfilter)
+ {
+ if (!empty($tagfilter) && is_array($tagfilter)) {
+ $tagfilterverif = [];
+ foreach ($tagfilter as $tag) {
+ if(array_key_exists($tag, $this->taglist)) {
+ $tagfilterverif[] = $tag;
+ }
+ }
+ $this->tagfilter = $tagfilterverif;
+ }
+ }
+
+ public function settagcompare($tagcompare)
+ {
+ if (in_array($tagcompare, ['OR', 'AND'])) {
+ $this->tagcompare = $tagcompare;
+ }
+ }
+
+ public function setsecure($secure)
+ {
+ if ($secure >= 0 && $secure <= 5) {
+ $this->secure = intval($secure);
+ }
+ }
+
+ public function setliento($range)
+ {
+ $this->liento = $range;
+ }
+
+ public function setlienfrom($range)
+ {
+ $this->lienfrom = $range;
+ }
+
+ public function setlientomin($min)
+ {
+ $this->liento['min'] = intval($min);
+ }
+
+ public function setlientomax($max)
+ {
+ $this->liento['max'] = intval($max);
+ }
+
+ public function setlienfrommin($min)
+ {
+ $this->lienfrom['min'] = intval($min);
+ }
+
+ public function setlienfrommax($max)
+ {
+ $this->lienfrom['max'] = intval($max);
+ }
+
+ public function setcol($col)
+ {
+ if (is_array($col)) {
+ $this->col = array_intersect($this->artvarlist(), $col);
+ }
+ }
+
+
+ public function settaglist(array $artlist)
+ {
+ $taglist = [];
+ foreach ($artlist as $art) {
+ foreach ($art->tag('array') as $tag) {
+ if (!array_key_exists($tag, $taglist)) {
+ $taglist[$tag] = 1;
+ } else {
+ $taglist[$tag]++;
+ }
+ }
+ }
+ $taglistsorted = arsort($taglist);
+ $this->taglist = $taglist;
+ }
+
+ public function setinvert(int $invert)
+ {
+ if ($invert == 0 || $invert == 1) {
+ $this->invert = $invert;
+ } else {
+ $this->invert = 0;
+ }
+ }
+
+
+ public function setartvarlist(array $artvarlist)
+ {
+ $this->artvarlist = $artvarlist;
+ }
+
+
+}
+
+
+
+
+?> \ No newline at end of file
diff --git a/w/class/class.w.quickcss.php b/w/class/class.w.quickcss.php
new file mode 100644
index 0000000..dc7dbac
--- /dev/null
+++ b/w/class/class.w.quickcss.php
@@ -0,0 +1,291 @@
+<?php
+
+class Quickcss
+{
+
+
+ private $active = [];
+ private $values = [];
+ private $units = [];
+ private $new = [];
+ private $jsoncss = [];
+
+ private $quickcss = [];
+
+ const COLOR = ['color', 'background-color', 'border-color', 'text-decoration-color'];
+ const SIZE = ['width', 'height', 'margin', 'padding', 'border-radius', 'border-width', 'left', 'right', 'top', 'bottom'];
+ const UNIQUE = ['background-image', 'opacity', 'font-size'];
+
+ const OPTIONS = [
+ 'text-align' => ['left', 'right', 'center', 'justify'],
+ 'border-style' => ['solid', 'double', 'outset', 'ridge'],
+ 'font-family' => ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy'],
+ 'text-decoration-line' => ['none', 'underline', 'overline', 'line-through', 'underline overline'],
+ 'display' => ['none', ]
+ ];
+
+
+ private static function getselect()
+ {
+ return array_keys(self::OPTIONS);
+ }
+
+ private static function getparams()
+ {
+ $params = array_merge(self::COLOR, self::SIZE, self::getselect(), self::UNIQUE);
+ sort($params, SORT_STRING );
+ return $params;
+ }
+
+ public function __construct($data)
+ {
+ $this->hydrate($data); }
+
+ public function hydrate($data)
+ {
+ foreach ($data as $key => $value) {
+ $method = 'set' . $key;
+
+ if (method_exists($this, $method)) {
+ $this->$method($value);
+ }
+ }
+ }
+
+ public function calc()
+ {
+ $quickcss = $this->intersect($this->values,$this->active);
+ $quickcss = $this->merge($quickcss, $this->new);
+ $quickcss = $this->addunits($quickcss, $this->units);
+ $quickcss = $this->merge($this->jsoncss, $quickcss);
+
+ $this->quickcss = $quickcss;
+ }
+
+
+
+ // _________________________________________ P O S T __________________________________________________
+
+ public function setvalues($data)
+ {
+ if(is_array($data)) {
+ $this->values = $data;
+ }
+ }
+
+ public function setunits($data)
+ {
+ if(is_array($data)) {
+ $this->units = $data;
+ }
+ }
+
+ public function setactive($data)
+ {
+ if(is_array($data)) {
+ $this->active = $data;
+ }
+ }
+
+ public function setnew($data)
+ {
+ if (!empty($data['element']) && !empty($data['param']) && in_array($data['param'], self::getparams())) {
+ $new = array($data['element'] => array($data['param'] => ''));
+ $this->new = $new;
+ }
+ }
+
+
+ public function setjson($jsoncss)
+ {
+ if(!empty($jsoncss) && is_string($jsoncss)) {
+ $jsoncss = json_decode($jsoncss);
+ if(is_array($jsoncss)) {
+ $this->jsoncss = $jsoncss;
+ } else {
+ $this->jsoncss = [];
+ }
+ }
+ }
+
+
+ // _______________________________________ C A L C ___________________________________________________
+
+ public function intersect($values, $active)
+ {
+ $intersect = array_intersect_key($values, $active);
+
+ foreach ($intersect as $element => $css) {
+ $intersect[$element] = array_intersect_key($values[$element], $active[$element]);
+ }
+ return $intersect;
+ }
+
+ public function merge($quickcss, $new)
+ {
+ $quickcss = array_merge_recursive($quickcss, $new);
+ return $quickcss;
+ }
+
+ public function addunits($quickcss, $units)
+ {
+ foreach ($units as $element => $css) {
+ foreach ($css as $param => $unit) {
+ if (array_key_exists($element, $quickcss) && array_key_exists($param, $quickcss[$element])) {
+ $quickcss[$element][$param] = $quickcss[$element][$param] . $unit;
+ }
+ }
+ }
+ return $quickcss;
+ }
+
+
+
+ // __________________________________________ C O M _________________________________________
+
+ public function tocss()
+ {
+ $string = '';
+ foreach ($this->quickcss as $element => $css) {
+ $string .= PHP_EOL . $element . ' {';
+ foreach ($css as $param => $value) {
+ $string .= PHP_EOL . ' ' . $param . ': ' . $value . ';';
+ }
+ $string .= PHP_EOL . '}' . PHP_EOL;
+ }
+ return $string;
+ }
+
+ public function tojson()
+ {
+ return json_encode($this->quickcss);
+ }
+
+
+
+
+ // _____________________________________________ F O R M ____________________________________________
+
+ public function form($action)
+ {
+ echo '<form action="' . $action . '" method="post">';
+ echo '</br><input type="submit" value="submit">';
+ $this->inputs($this->quickcss);
+ echo '</br><input type="submit" value="submit">';
+ echo '</form>';
+
+ }
+
+ public function inputs($quickcss)
+ {
+ echo '<h1>Add element</h1>';
+
+ echo '<input type="text" name="new[element]" list="used">';
+ echo '<datalist id="used">';
+ foreach (array_keys($quickcss) as $element) {
+ echo '<option value ="'.$element.'">';
+ }
+ echo '</datalist>';
+
+ echo '<select name="new[param]">';
+ foreach (self::getparams() as $param) {
+ echo '<option value="' . $param . '">' . $param . '</option>';
+ }
+ echo '</select>';
+
+ foreach ($quickcss as $element => $css) {
+ echo '<h3>' . $element . '</h3>';
+ foreach ($css as $param => $value) {
+
+ echo '<div class="quicklabel">';
+ echo '<input type="checkbox" name="active[' . $element . '][' . $param . ']" id="active[' . $element . '][' . $param . ']" checked>';
+ echo '<label for="active[' . $element . '][' . $param . ']">' . $param . '</label>';
+ echo '</div>';
+
+ echo '<div class="quickinput">';
+
+ if (in_array($param, self::COLOR)) {
+ echo '<input type="color" name="values[' . $element . '][' . $param . ']" value="' . $quickcss[$element][$param] . '" id="values[' . $element . '][' . $param . ']">';
+ }
+
+ if (in_array($param, self::SIZE)) {
+ $this->sizeinput($element, $param, $value);
+ }
+
+ if (in_array($param, self::getselect())) {
+ $this->selectinput($element, $param, $value);
+ }
+
+ if (in_array($param, self::UNIQUE)) {
+ $method = str_replace('-', '', $param) . 'input';
+ if (method_exists($this, $method)) {
+ $this->$method($element, $param, $value);
+ }
+ }
+
+ echo '</div>';
+ }
+ }
+
+
+ }
+
+
+
+
+
+
+ // ____________________________________ I N P U T __________________________________
+
+ public function sizeinput($element, $param, $value)
+ {
+ echo '<input type="number" name="values[' . $element . '][' . $param . ']" value="' . intval($value) . '" id="values[' . $element . '][' . $param . ']">';
+
+ $unit = preg_replace('/\d/', '', $value);
+ ?>
+ <select name="units[<?= $element ?>][<?= $param ?>]" >
+ <option value="px" <?= $unit == 'px' ? 'selected' : '' ?>>px</option>
+ <option value="%" <?= $unit == '%' ? 'selected' : '' ?>>%</option>
+ </select>
+ <?php
+
+ }
+
+ public function fontsizeinput($element, $param, $value)
+ {
+ echo '<input type="number" name="values[' . $element . '][' . $param . ']" value="' . intval($value) . '" id="values[' . $element . '][' . $param . ']">';
+
+ $unit = preg_replace('/\d/', '', $value);
+ ?>
+ <select name="units[<?= $element ?>][<?= $param ?>]" >
+ <option value="px" <?= $unit == 'px' ? 'selected' : '' ?>>px</option>
+ <option value="em" <?= $unit == 'em' ? 'selected' : '' ?>>em</option>
+ </select>
+ <?php
+
+ }
+
+ public function opacityinput($element, $param, $value)
+ {
+ echo '<input type="number" name="values[' . $element . '][' . $param . ']" value="' . $value . '" id="values[' . $element . '][' . $param . ']" step="0.1" min="0" max="1">';
+ }
+
+ public function selectinput($element, $param, $value)
+ {
+ echo '<select name="values[' . $element . '][' . $param . ']">';
+ foreach (self::OPTIONS[$param] as $option) {
+ if($option == $value) {
+ echo '<option value="'.$option.'" selected>'.$option.'</option>';
+ } else {
+ echo '<option value="'.$option.'">'.$option.'</option>';
+ }
+ }
+ echo '</select>';
+ }
+
+
+}
+
+
+
+?> \ No newline at end of file
diff --git a/w/class/class.w.record.php b/w/class/class.w.record.php
new file mode 100644
index 0000000..e488383
--- /dev/null
+++ b/w/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