diff options
-rw-r--r-- | class/class.w.aff.php | 65 | ||||
-rw-r--r-- | class/class.w.app.php | 62 | ||||
-rw-r--r-- | class/class.w.art.php | 12 | ||||
-rw-r--r-- | class/class.w.config.php | 3 | ||||
-rw-r--r-- | class/class.w.opt.php | 45 | ||||
-rw-r--r-- | fn/fn.php | 7 | ||||
-rw-r--r-- | public/css/styleadmin.css | 12 | ||||
-rw-r--r-- | public/css/stylebase.css | 20 | ||||
-rw-r--r-- | public/css/styleedit.css | 40 | ||||
-rw-r--r-- | public/css/stylehome.css | 38 | ||||
-rw-r--r-- | public/css/stylemedia.css | 14 | ||||
-rw-r--r-- | public/css/stylerecord.css | 13 | ||||
-rw-r--r-- | public/rsc/js/app.js | 2 | ||||
-rw-r--r-- | public/w/article.php | 28 | ||||
-rw-r--r-- | public/w/home.php | 57 | ||||
-rw-r--r-- | public/w/index.php | 188 | ||||
-rw-r--r-- | public/w/menu.php | 50 |
17 files changed, 460 insertions, 196 deletions
diff --git a/class/class.w.aff.php b/class/class.w.aff.php index 9f1177a..198f61e 100644 --- a/class/class.w.aff.php +++ b/class/class.w.aff.php @@ -162,7 +162,7 @@ class Aff </form> <div id="submit"> <input type="submit" name="action" value="update" accesskey="s" onclick="document.getElementById('artedit').submit();" form="artedit"> - <input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Suppression de cet article', 'artedit')" form="artedit"> + <input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Delete this article', 'artedit')" form="artedit"> </div> @@ -197,7 +197,7 @@ public function copy(Art $art, $list) <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, 'Ecraser ces valeurs')"> + <input type="submit" value="copy" onclick="confirmSubmit(event, 'Erase values')"> </fieldset> </form> </div> @@ -313,13 +313,27 @@ public function header() public function home2table(App $app, $getlist) { + echo '<form action="./" method="post">'; + ?> + <div id="massedit"> + <select name="massedit" required> + <option value="delete">delete</option> + <option value="0">set as public</option> + <option value="1">set as private</option> + <option value="2">set as not published</option> + </select> + <input type="submit" value="submit" 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>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>⚙ edit</th></tr>'; + 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>⚙ edit</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() . '">' . $item->titre() . '</a></td>'; echo '<td>' . $item->tag('sort') . '</td>'; echo '<td>' . $item->intro() . '</td>'; @@ -332,6 +346,7 @@ public function home2table(App $app, $getlist) echo '</tr>'; } echo ' </table> '; + echo ' </form> '; } } @@ -340,15 +355,19 @@ public function option(App $app, Opt $opt) if ($app->session() >= $app::EDITOR) { echo '<div id="options"><form action="./" method="get" >'; + echo '<input type="submit" name="submit" value="filter">'; + echo '⬅<input type="submit" name="submit" value="reset">'; + - $this->optiontag($opt); - $this->optionprivacy($opt); $this->optionsort($opt); + $this->optionprivacy($opt); + $this->optiontag($opt); - echo '<input type=submit value="show">'; + echo '<input type="submit" name="submit" value="filter">'; + echo '⬅<input type="submit" name="submit" value="reset">'; echo '</form></div>'; @@ -360,13 +379,34 @@ public function optiontag(Opt $opt) { echo '<fieldset><legend>Tag</legend><ul>'; - foreach ($opt->taglist() as $tagor => $count) { - if (in_array($tagor, $opt->tagor())) { - echo '<li><input type="checkbox" name="tagor[]" id="' . $tagor . '" value="' . $tagor . '" checked /><label for="' . $tagor . '">' . $tagor . ' (' . $count . ')</label></li>'; + + 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>'; + + $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="tagor[]" id="' . $tagor . '" value="' . $tagor . '" /><label for="' . $tagor . '">' . $tagor . ' (' . $count . ')</label></li>'; + 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>'; } @@ -389,7 +429,9 @@ public function optionsort(Opt $opt) 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>'; @@ -469,7 +511,7 @@ public function nav($app) echo '<a class="button" href="?id=' . $_GET['id'] . '&edit=1" >edit</a>'; } } - if ($app->session() >= $app::EDITOR && !isset($_GET['id'])) { + 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) { @@ -827,6 +869,7 @@ public function nav($app) + //______________________________________________________ S E T _________________________________________________ public function setsession($session) diff --git a/class/class.w.app.php b/class/class.w.app.php index efb8986..5e1ddb0 100644 --- a/class/class.w.app.php +++ b/class/class.w.app.php @@ -37,25 +37,52 @@ class App } catch (PDOException $e) { $caught = false; echo '<h1>Error 500, database offline</h1>'; - echo '<p><a href=".">Homepage for admin login</a> (connect on the top right side)</p>'; - if ($this->session() >= 3) { + if ($this->session() >= self::EDITOR) { echo '<p>Error : ' . $e->getMessage() . '</p>'; - if ($this->session() == 10) { + 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; } - if ($caught) { - $this->arttable = $config->arttable(); - } 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 ____________________________________ @@ -206,7 +233,6 @@ class App public function getlisteropt(Opt $opt) { - $artlist = []; $select = 'SELECT ' . $opt->col('string') . ' FROM ' . $this->arttable; @@ -252,15 +278,24 @@ class App - public function filtertagor(array $artlist, array $tagchecked) + public function filtertagfilter(array $artlist, array $tagchecked, $tagcompare = 'OR') { $filteredlist = []; foreach ($artlist as $art) { - if (!empty(array_intersect($art->tag('array'), $tagchecked))) { - $filteredlist[] = $art->id(); - } elseif (empty($tagchecked)) { + 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; @@ -311,9 +346,6 @@ class App public function tableexist($dbname, $tablename) { - var_dump($dbname); - var_dump($tablename); - $req = $this->bdd->prepare('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = :dbname AND @@ -341,7 +373,7 @@ class App $arttables = []; foreach ($donnees as $table) { - $arttables[] = $table['Tables_in_wcms']; + $arttables[] = $table['Tables_in_' . $dbname]; } return $arttables; diff --git a/class/class.w.art.php b/class/class.w.art.php index d757e0d..ffdb670 100644 --- a/class/class.w.art.php +++ b/class/class.w.art.php @@ -73,7 +73,7 @@ class Art public function updatelien() { - $this->lien = search($this->md(), self::DEBUT, self::FIN); + $this->lien = search($this->md(true), self::DEBUT, self::FIN); } public static function classvarlist() @@ -179,9 +179,14 @@ class Art return $temp . $this->css; } - public function md() + public function md($expand = false) { - return $this->html; + if($expand == true) { + $md = str_replace('](=', '](?id=', $this->html); + } else { + $md = $this->html; + } + return $md; } public function html(App $app) @@ -200,6 +205,7 @@ class Art $html = str_replace($lien, $titlelien, $html); } + $html = str_replace('href="=', 'href="?id=', $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); diff --git a/class/class.w.config.php b/class/class.w.config.php index 4a63f86..839bf77 100644 --- a/class/class.w.config.php +++ b/class/class.w.config.php @@ -99,6 +99,8 @@ class Config return $this->cssread; } + + // __________________________________________ S E T ______________________________________ public function sethost($host) @@ -156,6 +158,7 @@ class Config $this->cssread = strip_tags($cssread); } + } diff --git a/class/class.w.opt.php b/class/class.w.opt.php index 76b3905..fc71312 100644 --- a/class/class.w.opt.php +++ b/class/class.w.opt.php @@ -2,8 +2,9 @@ class Opt { private $sortby = 'id'; - private $order = '1'; - private $tagor = []; + private $order = 1; + private $tagfilter = []; + private $tagcompare = 'OR'; private $secure = 4; private $liento = ['min' => '0', 'max' => '0']; private $lienfrom = ['min' => '0', 'max' => '0']; @@ -65,9 +66,14 @@ class Opt return $this->secure; } - public function tagor($type = 'array') + public function tagfilter($type = 'array') { - return $this->tagor; + return $this->tagfilter; + } + + public function tagcompare() + { + return $this->tagcompare; } public function liento($type = 'array') @@ -117,16 +123,23 @@ class Opt } } - public function settagor($tagor) + public function settagfilter($tagfilter) { - if (is_array($tagor)) { - // $tagorlist = []; - // foreach ($tagor as $tag) { + if (is_array($tagfilter)) { + // $tagfilterlist = []; + // foreach ($tagfilter as $tag) { // if (array_key_exists($tag, $this->taglist())) { - // $tagorlist[] = $tag; + // $tagfilterlist[] = $tag; // } // } - $this->tagor = $tagor; + $this->tagfilter = $tagfilter; + } + } + + public function settagcompare($tagcompare) + { + if(in_array($tagcompare, ['OR', 'AND'])) { + $this->tagcompare = $tagcompare; } } @@ -137,18 +150,14 @@ class Opt } } - public function setliento($n0, $n1) + public function setliento($range) { - $stock = [intval($n1), intval($n2)]; - $sorted = asort($stock); - $this->liento = ['min' => $stock[0], 'max' => $stock[1]]; + $this->liento = $range; } - public function setlienfrom($n0, $n1) + public function setlienfrom($range) { - $stock = [intval($n1), intval($n2)]; - $sorted = asort($stock); - $this->lienfrom = ['min' => $stock[0], 'max' => $stock[1]]; + $this->lienfrom = $range; } public function setlientomin($min) @@ -9,9 +9,9 @@ function bddconnect($host, $bdname, $user, $password) return $bdd; } -function session() +function my_autoloader($class) { - session_start(); + require('../../class/class.w.' . strtolower($class) . '.php'); } function secure() @@ -134,5 +134,4 @@ function array_update($base, $new) -?> - +?>
\ No newline at end of file diff --git a/public/css/styleadmin.css b/public/css/styleadmin.css index e69de29..aacca33 100644 --- a/public/css/styleadmin.css +++ b/public/css/styleadmin.css @@ -0,0 +1,12 @@ + +@media (max-width: 600px) { + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } +}
\ No newline at end of file diff --git a/public/css/stylebase.css b/public/css/stylebase.css index 5621363..581994d 100644 --- a/public/css/stylebase.css +++ b/public/css/stylebase.css @@ -11,10 +11,6 @@ body { } -section { -} - - @@ -30,8 +26,6 @@ nav { right: 0; z-index: 10; background-color: var(--color1); - /* width: calc(10% - 20px); */ - width: 10%; border: ridge 1px grey; } @@ -56,3 +50,17 @@ nav #loginpass { } +@media (max-width: 600px) { + body { + font-size: 1.3em; + } + + input, textarea, select, button { + font-size: 0.8em; + } + + nav { + display: none; + } + +}
\ No newline at end of file diff --git a/public/css/styleedit.css b/public/css/styleedit.css index 0e5ed01..3a868c3 100644 --- a/public/css/styleedit.css +++ b/public/css/styleedit.css @@ -56,7 +56,8 @@ textarea#html { padding-bottom: 40px; font-family: serif; padding-left: 2%; - padding-right: calc(50% - 500px); + padding-right: calc(50% - 500px); + resize: none; } @@ -117,4 +118,41 @@ fieldset { summary, div#linklist, div#copy, div#submit { border: ridge 1px grey; +} + + +@media (max-width: 600px) { + details#editinfo, details#editcss, div#copy, div#linklist { + display: none; + } + + + nav { + position: absolute; + display: inline-flex; + } + + div#menu { + display: block; + } + + div#submit { + position: absolute; + display: block; + width: unset; + top: unset; + bottom: 0; + } + + nav form, nav a { + display: inline-flex; + margin: 1%; + } + + textarea#html { + padding-top: 60px; + } + + + }
\ No newline at end of file diff --git a/public/css/stylehome.css b/public/css/stylehome.css index b2e8c73..beaae93 100644 --- a/public/css/stylehome.css +++ b/public/css/stylehome.css @@ -54,3 +54,41 @@ div#options { +@media (max-width: 600px) { + + section.home { + position: relative; + display: block; + margin: unset; + } + + div#options { + position: relative; + width: unset; + } + + header { + position: relative; + border: none; + } + + table#home2table { + display: block; + position: relative; + width: 100%; + overflow-x: scroll; + font-size: 1em; + } + + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } + + +}
\ No newline at end of file diff --git a/public/css/stylemedia.css b/public/css/stylemedia.css index 9e46c3f..a2f9800 100644 --- a/public/css/stylemedia.css +++ b/public/css/stylemedia.css @@ -63,4 +63,18 @@ input[type="checkbox"] { padding: unset; margin: unset; height: unset; +} + + + +@media (max-width: 600px) { + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } }
\ No newline at end of file diff --git a/public/css/stylerecord.css b/public/css/stylerecord.css index 9e46c3f..409bcd4 100644 --- a/public/css/stylerecord.css +++ b/public/css/stylerecord.css @@ -63,4 +63,17 @@ input[type="checkbox"] { padding: unset; margin: unset; height: unset; +} + + +@media (max-width: 600px) { + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } }
\ No newline at end of file diff --git a/public/rsc/js/app.js b/public/rsc/js/app.js index b806baf..1f1df61 100644 --- a/public/rsc/js/app.js +++ b/public/rsc/js/app.js @@ -1,5 +1,5 @@ function confirmSubmit(event, element, idform) { - if (window.confirm('Confirmer ? ' + element) === false) { + if (window.confirm('Confirm ? ' + element) === false) { event.preventDefault(); } else { document.getElementById(idform).submit(); diff --git a/public/w/article.php b/public/w/article.php new file mode 100644 index 0000000..e5cfff7 --- /dev/null +++ b/public/w/article.php @@ -0,0 +1,28 @@ +<?php + +if ($app->exist($_GET['id'])) { + + $art = $app->get($_GET['id']); + + if (isset($_GET['edit']) and $_GET['edit'] == 1 and $app->session() >= $app::EDITOR) { + echo '<section class=edit>'; + $aff->edit($art, $app, $app->getlister(['id', 'titre'])); + $aff->copy($art, $app->getlister(['id', 'titre'])); + $aff->aside($app); + echo '</section>'; + } else { + echo '<section class="lecture">'; + $aff->lecture($art, $app); + echo '</section>'; + + } +} else { + echo '<span class="alert">This article does not exist yet</span>'; + + if ($app->session() >= $app::EDITOR) { + echo '<form action="?id=' . $_GET['id'] . '&edit=1" method="post"><input type="hidden" name="action" value="new"><input type="submit" value="Create"></form>'; + } + +} + +?>
\ No newline at end of file diff --git a/public/w/home.php b/public/w/home.php new file mode 100644 index 0000000..4966c62 --- /dev/null +++ b/public/w/home.php @@ -0,0 +1,57 @@ +<?php + + +$aff->header(); + +echo '<section class="home">'; + + +if ($app->session() >= $app::EDITOR) { + + $app->bddinit($config); + $opt = new Opt(Art::classvarlist()); + + if(!empty($_GET)) { + + $_SESSION['opt'] = $_GET; + $opt->hydrate($_GET); + + } + if(isset($_GET['submit']) && $_GET['submit'] == 'reset') { + $opt = new Opt(Art::classvarlist()); + } else { + $opt->hydrate($_SESSION['opt']); + + } + + $opt->setcol(['id', 'tag', 'lien', 'contenu', 'intro', 'titre', 'datemodif', 'datecreation', 'secure']); + $table = $app->getlisteropt($opt); + $app->listcalclien($table); + $opt->settaglist($table); + $opt->setcol(['id', 'tag', 'lien', 'contenu', 'intro', 'titre', 'datemodif', 'datecreation', 'secure', 'liento']); + + $aff->option($app, $opt); + + $filtertagfilter = $app->filtertagfilter($table, $opt->tagfilter(), $opt->tagcompare()); + $filtersecure = $app->filtersecure($table, $opt->secure()); + + $filter = array_intersect($filtertagfilter, $filtersecure); + $table2 = []; + foreach ($table as $art) { + if (in_array($art->id(), $filter)) { + $table2[] = $art; + } + } + + $app->artlistsort($table2, $opt->sortby(), $opt->order()); + + + + $aff->home2table($app, $table2); +} + + + +echo '</section>'; + +?>
\ No newline at end of file diff --git a/public/w/index.php b/public/w/index.php index 8b5069f..d9b9d5c 100644 --- a/public/w/index.php +++ b/public/w/index.php @@ -1,18 +1,17 @@ <?php - // _____________________________________________________ R E Q U I R E ________________________________________________________________ +session_start(); + require('../../vendor/autoload.php'); require('../../fn/fn.php'); -function my_autoloader($class) -{ - require('../../class/class.w.' . strtolower($class) . '.php'); -} spl_autoload_register('my_autoloader'); + + // ________________________________________________________ I N S T A L _________________________________________________ $app = new App(); @@ -37,7 +36,7 @@ if (!$config) { // _________________________________________________________ S E S ___________________________________________________________ -session(); + if (!isset($_SESSION['level'])) { $session = 0; } else { @@ -47,11 +46,6 @@ if (!isset($_SESSION['level'])) { $app->setsession($session); -// __________________________________________________________ I D _______________________________________________ - -if (isset($_GET['id'])) { - $app->setbdd($config); -} // _______________________________________________________ A C T I O N __________________________________________________________________ @@ -100,13 +94,23 @@ if (isset($_POST['action'])) { } + // _____________________________________________________ D A T A B A S E __________________________________________________________________ if (isset($_POST['action'])) { - $app->setbdd($config); + $app->bddinit($config); switch ($_POST['action']) { + case 'new': + if (isset($_GET['id'])) { + $art = new Art($_GET); + $art->reset(); + $app->add($art); + header('Location: ?id=' . $_GET['id'] . '&edit=1'); + } + break; + case 'update': if ($app->exist($_GET['id'])) { $art = new Art($_POST); @@ -147,6 +151,24 @@ if (isset($_POST['action'])) { } break; + case 'massedit': + if (isset($_POST['id'])) { + foreach ($_POST['id'] as $id) { + $art = new Art(['id' => $id]); + if ($_POST['massedit'] == 'delete' && $app->exist($id)) { + $app->delete($art); + } + if ($_POST['massedit'] >= 0 && $app->exist($id)) { + $art = $app->get($id); + $art->setsecure($_POST['massedit']); + $app->update($art); + } + header('Location: ./'); + } + + } + break; + } } @@ -165,10 +187,14 @@ if (isset($_POST['actiondb'])) { } } + + + + // _______________________________________________________ H E A D _____________________________________________________________ if (isset($_GET['id'])) { - $app->setbdd($config); + $app->bddinit($config); if ($app->exist($_GET['id'])) { $art = $app->get($_GET['id']); if (!isset($_GET['edit'])) { @@ -206,140 +232,28 @@ if (isset($_GET['message'])) { // ______________________________________________________ B O D Y _______________________________________________________________ -echo '<body>'; -$aff->nav($app); - -if (isset($_GET['id'])) { - $app->setbdd($config); - - - if ($app->exist($_GET['id'])) { - - $art = $app->get($_GET['id']); - - if (isset($_GET['edit']) and $_GET['edit'] == 1 and $app->session() >= $app::EDITOR) { - echo '<section class=edit>'; - $aff->edit($art, $app, $app->getlister(['id', 'titre'])); - $aff->copy($art, $app->getlister(['id', 'titre'])); - $aff->aside($app); - echo '</section>'; - } else { - echo '<section class="lecture">'; - $aff->lecture($art, $app); - echo '</section>'; - } - } else { - if (isset($_POST['action'])) { - if ($_POST['action'] == 'new') { - $art = new Art($_GET); - $art->reset(); - $app->add($art); - header('Location: ?id=' . $_GET['id'] . '&edit=1'); - } - } else { - echo '<span class="alert">This article does not exist yet</span>'; +$aff->nav($app); - if ($app->session() >= $app::EDITOR) { - echo '<form action="?id=' . $_GET['id'] . '&edit=1" method="post"><input type="hidden" name="action" value="new"><input type="submit" value="Create"></form>'; - } - } - } -} elseif (isset($_GET['tag'])) { - $app->setbdd($config); +if (array_key_exists('id', $_GET)) { + $app->bddinit($config); + include('article.php'); +} elseif (array_key_exists('tag', $_GET)) { + $app->bddinit($config); echo '<h4>' . $_GET['tag'] . '</h4>'; $aff->tag($app->getlister(['id', 'titre', 'intro', 'tag'], 'id'), $_GET['tag'], $app); - -} elseif (isset($_GET['lien'])) { - $app->setbdd($config); +} elseif (array_key_exists('lien', $_GET)) { + $app->bddinit($config); echo '<h4><a href="?id=' . $_GET['lien'] . '">' . $_GET['lien'] . '</a></h4>'; $aff->lien($app->getlister(['id', 'titre', 'intro', 'lien']), $_GET['lien'], $app); - -} elseif (isset($_GET['aff']) && $app->session() >= $app::EDITOR) { - if ($_GET['aff'] == 'admin' && $app->session() >= $app::ADMIN) { - echo '<section>'; - echo '<h1>Admin</h1>'; - - - - // $app->tableexist($config->dbname(), 'guigui'); - - $aff->admincss($config, $app); - $aff->adminpassword($config); - $aff->admindb($config); - if ($app->setbdd($config)) { - //var_dump($app->tablelist($config->dbname())); - echo '<p>database status : OK</p>'; - } - $aff->admintable($config, $app->tablelist($config->dbname())); - - echo '</section>'; - } elseif ($_GET['aff'] == 'media') { - echo '<h1>Media</h1>'; - echo '<section>'; - - $aff->addmedia($app); - $aff->medialist($app); - - echo '</section>'; - - } elseif ($_GET['aff'] == 'record') { - echo '<h1>Record</h1>'; - echo '<section>'; - - $aff->recordlist($app); - - echo '</section>'; - - } elseif ($_GET['aff'] == 'map') { - $app->setbdd($config); - $aff->map($app, $config->domain()); - } else { - header('Location: ./'); - } - +} elseif (array_key_exists('aff', $_GET)) { + include('menu.php'); } else { - - $aff->header(); - - echo '<section class="home">'; - - - $app->setbdd($config); - $opt = new Opt(Art::classvarlist()); - $opt->hydrate($_GET); - $opt->setcol(['id', 'tag', 'lien', 'contenu', 'intro', 'titre', 'datemodif', 'datecreation', 'secure']); - $table = $app->getlisteropt($opt); - $app->listcalclien($table); - $opt->settaglist($table); - $opt->setcol(['id', 'tag', 'lien', 'contenu', 'intro', 'titre', 'datemodif', 'datecreation', 'secure', 'liento']); - - $aff->option($app, $opt); - - $filtertagor = $app->filtertagor($table, $opt->tagor()); - $filtersecure = $app->filtersecure($table, $opt->secure()); - - $filter = array_intersect($filtertagor, $filtersecure); - $table2 = []; - foreach ($table as $art) { - if (in_array($art->id(), $filter)) { - $table2[] = $art; - } - } - - $app->artlistsort($table2, $opt->sortby(), $opt->order()); - - - - $aff->home2table($app, $table2); - - echo '</section>'; - + include('home.php'); } -echo '</body>'; -?> +?>
\ No newline at end of file diff --git a/public/w/menu.php b/public/w/menu.php new file mode 100644 index 0000000..b2495f2 --- /dev/null +++ b/public/w/menu.php @@ -0,0 +1,50 @@ +<?php + + +if ($app->session() >= $app::EDITOR) { + + if ($_GET['aff'] == 'admin' && $app->session() >= $app::ADMIN) { + echo '<section>'; + echo '<h1>Admin</h1>'; + + $aff->admincss($config, $app); + $aff->adminpassword($config); + $aff->admindb($config); + if ($app->setbdd($config)) { + //var_dump($app->tablelist($config->dbname())); + echo '<p>database status : OK</p>'; + } + $aff->admintable($config, $app->tablelist($config->dbname())); + + echo '</section>'; + } elseif ($_GET['aff'] == 'media') { + echo '<h1>Media</h1>'; + echo '<section>'; + + $aff->addmedia($app); + $aff->medialist($app); + + echo '</section>'; + + } elseif ($_GET['aff'] == 'record') { + echo '<h1>Record</h1>'; + echo '<section>'; + + $aff->recordlist($app); + + echo '</section>'; + + } elseif ($_GET['aff'] == 'map') { + $app->bddinit($config); + $aff->map($app, $config->domain()); + } else { + echo '<h1>Private</h1><p>You dont have the permission to access this page.</p>'; + + } + + +} else { + echo '<h1>Private</h1><p>You should be connected to access this page.</p>'; +} + +?>
\ No newline at end of file |