diff options
Diffstat (limited to 'public/w')
-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 |
4 files changed, 186 insertions, 137 deletions
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 |