From 7b2e48276b2a3ceff83c906d38077f8d0479c3df Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Thu, 18 Oct 2018 01:08:46 +0200 Subject: 2.92 new architecture + quickcss class --- .gitignore | 6 +- class/class.w.aff.php | 1186 -------------------------------------- class/class.w.app.php | 732 ----------------------- class/class.w.art.php | 501 ---------------- class/class.w.config.php | 199 ------- class/class.w.media.php | 173 ------ class/class.w.opt.php | 272 --------- class/class.w.record.php | 116 ---- fn/fn.w.php | 180 ------ public/index.php | 11 - public/test.php | 277 +++++---- public/test2.php | 84 +++ public/w/article.php | 33 -- public/w/css/styleadmin.css | 80 --- public/w/css/stylebase.css | 85 --- public/w/css/styleedit.css | 250 -------- public/w/css/stylehome.css | 117 ---- public/w/css/styleinfo.css | 80 --- public/w/css/stylemedia.css | 103 ---- public/w/css/stylerecord.css | 79 --- public/w/home.php | 85 --- public/w/index.php | 359 +----------- public/w/menu.php | 56 -- public/w/rsc/css/styleadmin.css | 80 +++ public/w/rsc/css/stylebase.css | 85 +++ public/w/rsc/css/styleedit.css | 250 ++++++++ public/w/rsc/css/stylehome.css | 117 ++++ public/w/rsc/css/styleinfo.css | 80 +++ public/w/rsc/css/stylemedia.css | 103 ++++ public/w/rsc/css/stylerecord.css | 79 +++ w/class/class.w.aff.php | 1161 +++++++++++++++++++++++++++++++++++++ w/class/class.w.app.php | 770 +++++++++++++++++++++++++ w/class/class.w.art.php | 501 ++++++++++++++++ w/class/class.w.art2.php | 585 +++++++++++++++++++ w/class/class.w.config.php | 188 ++++++ w/class/class.w.media.php | 173 ++++++ w/class/class.w.opt.php | 272 +++++++++ w/class/class.w.quickcss.php | 291 ++++++++++ w/class/class.w.record.php | 116 ++++ w/controller/w.article.php | 33 ++ w/controller/w.home.php | 85 +++ w/controller/w.menu.php | 56 ++ w/fn/w.fn.php | 180 ++++++ w/w.router.php | 359 ++++++++++++ 44 files changed, 5825 insertions(+), 4803 deletions(-) delete mode 100644 class/class.w.aff.php delete mode 100644 class/class.w.app.php delete mode 100644 class/class.w.art.php delete mode 100644 class/class.w.config.php delete mode 100644 class/class.w.media.php delete mode 100644 class/class.w.opt.php delete mode 100644 class/class.w.record.php delete mode 100644 fn/fn.w.php delete mode 100644 public/index.php create mode 100644 public/test2.php delete mode 100644 public/w/article.php delete mode 100644 public/w/css/styleadmin.css delete mode 100644 public/w/css/stylebase.css delete mode 100644 public/w/css/styleedit.css delete mode 100644 public/w/css/stylehome.css delete mode 100644 public/w/css/styleinfo.css delete mode 100644 public/w/css/stylemedia.css delete mode 100644 public/w/css/stylerecord.css delete mode 100644 public/w/home.php delete mode 100644 public/w/menu.php create mode 100644 public/w/rsc/css/styleadmin.css create mode 100644 public/w/rsc/css/stylebase.css create mode 100644 public/w/rsc/css/styleedit.css create mode 100644 public/w/rsc/css/stylehome.css create mode 100644 public/w/rsc/css/styleinfo.css create mode 100644 public/w/rsc/css/stylemedia.css create mode 100644 public/w/rsc/css/stylerecord.css create mode 100644 w/class/class.w.aff.php create mode 100644 w/class/class.w.app.php create mode 100644 w/class/class.w.art.php create mode 100644 w/class/class.w.art2.php create mode 100644 w/class/class.w.config.php create mode 100644 w/class/class.w.media.php create mode 100644 w/class/class.w.opt.php create mode 100644 w/class/class.w.quickcss.php create mode 100644 w/class/class.w.record.php create mode 100644 w/controller/w.article.php create mode 100644 w/controller/w.home.php create mode 100644 w/controller/w.menu.php create mode 100644 w/fn/w.fn.php create mode 100644 w/w.router.php diff --git a/.gitignore b/.gitignore index 2798f9f..7cae8e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ vendor/* .vscode/* -config.w.json +w/w.config.json error_log public/w/media/* -public/w/css/read/* +public/w/css/* +public/w/js/* +public/index.html diff --git a/class/class.w.aff.php b/class/class.w.aff.php deleted file mode 100644 index e716630..0000000 --- a/class/class.w.aff.php +++ /dev/null @@ -1,1186 +0,0 @@ -setsession($session); - } - - - - // ____________________________________________________ C O N F I G ______________________________________________ - - - public function configform() - { - ?> -

Config file does not exist yet, or maybe you deleted it ? Anyway, it is time to set it :

-
- - Database settings
-
-
-
-
- Domain name settings
-
- W_cms settings
-
- - - - - (You can change everything later, set at least your admin password, and don't forget it !)
- -
- secure() == 1) { - echo 'This article is private'; - } - if ($art->secure() == 2) { - echo "This article is not published yet"; - } - - if ($app->session() >= $art->secure()) { - ?> - -
-

titre() ?>

-
soustitre() ?>
-
-
html($app) ?>
- session() >= self::$edit) { - - ?> - -
- - textarea{font-size: ' . $fontsize . '}'; - $tablist = ['html' => $art->md(), 'css' => $art->css(), 'aside' => 'NOT WORKING', 'footer' => 'NOT WORKING']; - - $this->tabs($tablist, 'html'); - - ?> - -
- - - - - 👁 - - id() ?> - - - -
- - - - - - -
- - - '; - foreach ($tablist as $key => $value) { - echo '
'; - if ($key == $opentab) { - echo ''; - } else { - echo ''; - } - echo ''; - echo '
'; - echo ''; - echo '
'; - echo '
'; - } - - echo ''; -} - - - -public function copy(Art $art, $list) -{ - ?> -
-
-
- - - '; - ?> - - - - - - - - - -
-
-
- - - - - - - - - <?= $title ?> - - - - - - - - - - ' : '' ?> - <?= $edit == 1 ? '✏' : '' ?> <?= $art->titre() ?> - - - - - - - - - - - ❓ <?= $id ?> - - - - - '; - echo ' '; - echo ' '; -} - -public function lien($getlist, $lien, App $app) -{ - echo '
'; - echo ' '; - echo '
'; -} - - - -public function dump($getlist) -{ - echo ' '; -} - -public function header() -{ - echo '
'; - $this->search(); - echo '
'; -} - - -public function home2table(App $app, $getlist, $masslist) -{ - echo '
'; - echo '

Articles

'; - echo '
'; - - ?> -
-

Mass Edit

- - - - - - - - - - - - -
- - session() >= $app::EDITOR) { - echo ''; - echo ''; - foreach ($getlist as $item) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
xtitletagsummary↘ to↗ fromlast modificationdate of creationprivacydisplay
' . $item->titre() . '' . $item->tag('sort') . '' . $item->intro() . '' . $item->liento('sort') . '' . $item->lien('sort') . '' . $item->datemodif('hrdi') . '' . $item->datecreation('hrdi') . '' . $item->secure('string') . '👁
'; - echo '
'; - echo '
'; - } -} - -public function option(App $app, Opt $opt) -{ - if ($app->session() >= $app::EDITOR) { - echo '
'; - echo '

Options

'; - echo '
'; - echo ''; - echo '⬅'; - - - $this->optionsort($opt); - $this->optionprivacy($opt); - $this->optiontag($opt); - - if ($opt->invert() == 1) { - echo ''; - } else { - echo ''; - } - echo '
'; - - } - -} - -public function optiontag(Opt $opt) -{ - - echo '
Tag
'; - -} - -public function optionprivacy(Opt $opt) -{ - echo '
Privacity
'; -} - -public function optionsort(Opt $opt) -{ - echo '
Sort'; - echo ''; - echo '
'; - echo 'order() == '1' ? "checked" : "") . ' />'; - echo '
'; - echo 'order() == '-1' ? "checked" : "") . ' />'; - - echo '
'; - -} - -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']; - ?> -

Map

- -
- - - - - -
- - - - - - - -
- - graph - -
- - - session() >= $app::EDITOR) { - echo ' '; - } -} - -public function nav($app) -{ - echo ' - session() >= $app::EDITOR) { - - ?> -
- Add Media -
- - - - -
-
- -
- Media List - -
- - - - id() . '.' . $item->extension(); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - if ($item->type() == 'image') { - echo ''; - echo ''; - } elseif ($item->type() == 'sound') { - echo ''; - echo ''; - } else { - echo ''; - echo ''; - } - echo ''; - echo ''; - - } - - - ?> - - -
xNameextensionwidthheightsizecodethumbnail
' . $item->extension() . '' . $item->width() . '' . $item->height() . '' . readablesize($item->size()) . '👁' . $item->id() . '
- - - - -
- - -
- - - '; - echo 'Media List'; - - echo '
'; - - echo '
'; - - echo '
    '; - - foreach ($app->getlisterrecord($dir) as $item) { - echo '
  • '; - - ?> - - - - - id()) . '.' . $item->extension(); - - echo '
    '; - var_dump($item->size()); - var_dump(intval($item->size())); - echo 'filesize = ' . readablesize(intval($item->size())); - echo '
    '; - echo 'extension = ' . $item->extension(); - echo '
    '; - - ?> - - - - - - '; - } - - echo '
'; - - ?> - - - -
- - - - '; - echo ''; - - - } - - - //______________________________________________________ A D M _________________________________________________ - - - - public function admincss(Config $config, $app) - { - ?> -
-

CSS

-

Current global css : cssread() ?>

-
- Default CSS - -

This CSS will apply to all your articles.

- -
- - - -
-
- - - cssread(); - if (is_file($cssfile)) { - $cssread = file_get_contents($cssfile); - echo '
'; - echo 'Edit current CSS'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo '
'; - echo '
'; - } - - ?> -
- Add CSS file -
- - - - -
-
- -
- - -
- - -

Database

- -
- Database credentials - -

Fill this sections with the database settings you want to connect to

- -
- - - - - - - - - - -
- -
- - -
- - -
- -

Passwords

- -
- Admin - -

Edit your own admin password. You can find it in the config.w.json file, in the root of your website folder.

- -
- - - - -
- -
-
- Others - -

Use this section to set all the others users passwords. They cant access this page, so they cant change it by themselves.

- -
- - - - - - - - -
- -
-
- - - - - - -
- -

Table

- - - -

Database status :

- - -

Current Table : arttable(); ?>

-
- Select Table -

The table is where all your articles are stored, select the one you want to use.

- -
- - - -
- -
- -
- Add table - -

Create new table in your database. You need at least one to use W_cms

- -
- - - -
- -
- -
- Duplicate Table -

If you want to save versions of your work.

- -
- - - - - - -
- -
- -
- - -
-

Display

-
- Update favicon -
- - -
-
-
- Change desktop background color -
- - - - -
-
-
- = 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/class/class.w.app.php b/class/class.w.app.php deleted file mode 100644 index 91d0a41..0000000 --- a/class/class.w.app.php +++ /dev/null @@ -1,732 +0,0 @@ -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 '

Error 500, database offline

'; - if ($this->session() >= self::EDITOR) { - echo '

Error : ' . $e->getMessage() . '

'; - if ($this->session() == self::ADMIN) { - echo '

Go to the Admin Panel to edit your database credentials

'; - } else { - echo '

Logout and and come back with an admin password to edit the database connexions settings.

'; - } - } else { - echo '

Homepage for admin login (connect on the top right side)

'; - } - exit; - } - - return $caught; - - } - - public function settable(Config $config) - { - if (!empty($config->arttable())) { - $this->arttable = $config->arttable(); - } else { - echo '

Table Error

'; - - if ($this->session() >= self::EDITOR) { - if ($this->session() == self::ADMIN) { - echo '

Go to the Admin Panel to select or add an Article table

'; - } else { - echo '

Logout and and come back with an admin password to edit table settings.

'; - } - } else { - echo '

Homepage for admin login (connect on the top right side)

'; - } - $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 '

cet id existe deja

'; - } 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 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(); - } - - - - - //____________________________________________ 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 changecss($lecturecss) - // { - // if (file_exists(self::CONFIG_FILE)) { - // $current = file_get_contents(self::CONFIG_FILE); - // $current = str_replace($this->lecturecss(), $lecturecss, $current); - // file_put_contents(self::CONFIG_FILE, $current); - // return 'css_change_ok'; - // } else { - // return 'css_change_error'; - // } - // } - - public function addcss(array $file, $maxsize = 2 ** 24, $id) - { - $message = 'runing'; - $id = strtolower(strip_tags($id)); - $id = str_replace(' ', '_', $id); - if (isset($file) and $file['css']['error'] == 0 and $file['css']['size'] < $maxsize) { - $infosfichier = pathinfo($file['css']['name']); - $extension_upload = $infosfichier['extension']; - $extensions_autorisees = array('css'); - if (in_array($extension_upload, $extensions_autorisees)) { - if (!file_exists($this::CSS_READ_DIR . $id . '.' . $extension_upload)) { - - $extension_upload = strtolower($extension_upload); - $uploadok = move_uploaded_file($file['css']['tmp_name'], $this::CSS_READ_DIR . $id . '.' . $extension_upload); - if ($uploadok) { - $message = 'uploadok'; - } else { - $message = 'uploaderror'; - } - } else { - $message = 'filealreadyexist'; - - } - } - } else { - $message = 'filetoobig'; - - } - - return $message; - - } - - 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/class/class.w.art.php b/class/class.w.art.php deleted file mode 100644 index 001b29d..0000000 --- a/class/class.w.art.php +++ /dev/null @@ -1,501 +0,0 @@ -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 = ''; - $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('
', $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/class/class.w.config.php b/class/class.w.config.php deleted file mode 100644 index 68b0987..0000000 --- a/class/class.w.config.php +++ /dev/null @@ -1,199 +0,0 @@ -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 cssread() - { - return $this->cssread; - } - - 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 setcssread($cssread) - { - $this->cssread = strip_tags($cssread); - } - - 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/class/class.w.media.php b/class/class.w.media.php deleted file mode 100644 index 2d27be7..0000000 --- a/class/class.w.media.php +++ /dev/null @@ -1,173 +0,0 @@ -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/class/class.w.opt.php b/class/class.w.opt.php deleted file mode 100644 index 7164cb7..0000000 --- a/class/class.w.opt.php +++ /dev/null @@ -1,272 +0,0 @@ - '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/class/class.w.record.php b/class/class.w.record.php deleted file mode 100644 index e488383..0000000 --- a/class/class.w.record.php +++ /dev/null @@ -1,116 +0,0 @@ -hydrate($donnees); - } - - public function hydrate(array $donnees) - { - foreach ($donnees as $key => $value) { - $method = 'set' . $key; - - if (method_exists($this, $method)) { - $this->$method($value); - } - } - } - - - -// _________________________________________________ G E T ____________________________________________________ - - public function id() - { - return $this->id; - } - - public function path() - { - return $this->path; - } - - public function extension() - { - return $this->extension; - } - - public function size() - { - return $this->size; - } - - public function datetime() - { - return $this->datetime; - } - - public function number() - { - return $this->number; - } - -// ___________________________________________________ S E T __________________________________________________ - - public function setid($id) - { - if (strlen($id) < 100 and is_string($id)) { - $this->id = strip_tags(strtolower($id)); - } - } - - public function setpath($path) - { - if (strlen($path) < 40 and is_string($path)) { - $this->path = strip_tags(strtolower($path)); - } - } - - public function setextension($extension) - { - if (strlen($extension) < 7 and is_string($extension)) { - $this->extension = strip_tags(strtolower($extension)); - } - } - - public function setsize($size) - { - if (40 and is_int($size)) { - $this->size = strip_tags(strtolower($size)); - } - } - - public function setdatetime($datetime) - { - if (is_int($datetime)) { - $this->datetime = strip_tags(strtolower($datetime)); - } - } - - public function setnumber($number) - { - if (is_int($number)) { - $this->number = strip_tags(strtolower($number)); - } - } - - - - - -} - -?> \ No newline at end of file diff --git a/fn/fn.w.php b/fn/fn.w.php deleted file mode 100644 index 6f63a07..0000000 --- a/fn/fn.w.php +++ /dev/null @@ -1,180 +0,0 @@ -getMessage()); - } - return $bdd; -} - -function my_autoloader($class) -{ - require('../../class/class.w.' . strtolower($class) . '.php'); -} - -function secure() -{ - if (!isset($_SESSION['id'])) { - header("location: ./"); - } -} - -function head($title) -{ - ?> - - - - - <?= $title ?> - - y > 1) return $str . $diff->y . ' years'; - if ($diff->y == 1) return $str . ' 1 year and ' . $diff->m . ' months'; - if ($diff->m > 1) return $str . $diff->m . ' months'; - if ($diff->m == 1) return $str . ' 1 month and ' . $diff->d . ($diff->d > 1 ? ' days' : ' day'); - if ($diff->d > 1) return $str . $diff->d . ' days'; - if ($diff->d == 1) return $str . ' 1 day and ' . $diff->h . ($diff->h > 1 ? ' hours' : ' hour'); - if ($diff->h > 1) return $str . $diff->h . ' hours'; - if ($diff->h == 1) return $str . ' 1 hour and ' . $diff->i . ($diff->i > 1 ? ' minutes' : ' minute'); - if ($diff->i > 1) return $str . $diff->i . ' minutes'; - if ($diff->i == 1) return $str . ' 1 minute'; - return $str . ' a few secondes'; -} - - - -function arrayclean($input) -{ - $output = []; - foreach ($input as $key => $value) { - if (is_array($value)) { - $output[$key] = array_filter($value); - } else { - $output[$key] = $value; - } - } - return $output; -} - - - - -function array_update($base, $new) -{ - foreach ($base as $key => $value) { - if (array_key_exists($key, $new)) { - if (gettype($base[$key]) == gettype($new[$key])) { - $base[$key] = $new[$key]; - } - } - } - return $base; -} - -function contains($needle, $haystack) -{ - return strpos($haystack, $needle) !== false; -} - - -function str_clean(string $string) -{ - return str_replace(' ', '_', strtolower(strip_tags($string))); -} - -function sumparser($text) -{ - preg_match_all('#(.+)#iU', $text, $out); - - - $sum = []; - foreach ($out[2] as $key => $value) { - $sum[$value][$out[1][$key]] = $out[3][$key]; - } - - - $sumstring = ''; - $last = 0; - foreach ($sum as $title => $list) { - foreach ($list as $h => $link) { - if($h > $last) { - for ($i = 1; $i <= ($h - $last); $i++) { - $sumstring .= '
    '; - } - $sumstring .= '
  • '.$link.'
  • ' ; - } elseif ($h < $last) { - for ($i = 1; $i <= ($last - $h); $i++) { - $sumstring .= '
'; - } - $sumstring .= '
  • '.$link.'
  • ' ; - } elseif ($h = $last) { - $sumstring .= '
  • '.$link.'
  • ' ; - } - $last = $h; - } - } - for ($i = 1; $i <= ($last); $i++) { - $sumstring .= ''; - } - return $sumstring; -} - - -?> \ No newline at end of file diff --git a/public/index.php b/public/index.php deleted file mode 100644 index ab7ff55..0000000 --- a/public/index.php +++ /dev/null @@ -1,11 +0,0 @@ - -

    Vincent Peugnet

    -

    W

    - -

    @

    -v.peugnet@free.fr - -

    📐

    - - - \ No newline at end of file diff --git a/public/test.php b/public/test.php index 6e5e835..aee0004 100644 --- a/public/test.php +++ b/public/test.php @@ -1,119 +1,186 @@ tiTre2:laguerre dqs fdddddddfdfdsfs fdsfdksdfjnsdjkhsf lkfljkfhjldshsf fsdf -fdgfgdfgdfgdsggggggggggggg -dfgdsfgdh -dh - -gh -g -hg -fhhhhhhhhhhhhhhhhhhgfghfghfgh -

    -fhfgfgdfgdfgdsggggggggggggg -dfgdsfgdh

    -dh
    dh
    dh
    dh
    dh
    dh
    dh
    dh
    dh
    - -gh

    -g -hg

    -fhhhhhhhhhhhhhhhhhhgfghfghfgh -gh -g -hg -fhhhhhhhhhhhhhhhhhhgfghfghfgh -

    -fhfgfgdfgdfgdsggggggggggggg -dfgdsfgdh

    -dh
    dh
    dh
    dh
    dh
    dh
    dh
    dh
    dh
    - -gh

    -g -hg

    -fhhhhhhhhhhhhhhhhhhgfghfghfgh -gh -

    YOLO

    -

    PROUT

    -

    LOLDELAMORT

    -hg -fhhhhhhhhhhhhhhhhhhgfghfghfgh - -

    -fhfgfgdfgdfgdsggggggggggggg -dfgdsfgdh

    -dh
    dh
    dh
    dh
    dh
    dh
    dh
    dh
    dh
    - -gh

    -g -hg

    -fhhhhhhhhhhhhhhhhhhgfghfghfgh - -fhf -g -hffffgggggggggggggggggggggggggggggggggggggdsf

    titre 3- les hommes

    la fin'; - - -function sumparser($text) -{ - preg_match_all('#(.+)#iU', $text, $out); - - var_dump($out); - - $sum = []; - foreach ($out[2] as $key => $value) { - $sum[$value][$out[1][$key]] = $out[3][$key]; + + +require('../w/class/class.w.quickcss.php'); + +$quick = new Quickcss; + + + +var_dump($quick); + + + + +$color = ['color', 'background-color', 'border-color']; +$size = ['width', 'height', 'margin', 'padding', 'border-width']; +$font = ['font-size']; +$unique = ['background-image', 'opacity', 'border-style', 'text-align']; +$params = array_merge($color, $size, $font, $unique); + + + + + + +// $presets = ['body' => ['font-size' => 'px']]; +// $quickcss = ['section' => ['color' => '#a74545', 'font-size' => '32px'], 'p' => ['background-color' => '#458da7', 'width' => '7px']]; + +$presets = []; +$quickcss = []; + +if (isset($_POST['quickcss'])) { + $quickcss = $_POST['quickcss']; +} + +if (isset($_POST['presets'])) { + $presets = $_POST['presets']; +} + + +if (isset($_POST['active'])) { + $active = $_POST['active']; + echo '

    active

    '; + var_dump($active); + $intersect = array_intersect_key($quickcss, $active); + + foreach ($intersect as $element => $css) { + $intersect[$element] = array_intersect_key($quickcss[$element], $active[$element]); } + + echo '

    intersect

    '; + var_dump($intersect); + + $quickcss = $intersect; + + +} + + +if (!empty($_POST['new']['element']) && !empty($_POST['new']['param']) && in_array($_POST['new']['param'], $params)) { + $new = array($_POST['new']['element'] => array($_POST['new']['param'] => '')); + var_dump($new); + + $quickcss = array_merge_recursive($quickcss, $new); +} + + + + +echo '

    quickcss

    '; + +var_dump($quickcss); + +echo '

    presets

    '; - var_dump($sum); - - $sumstring = ''; - $last = 0; - foreach ($sum as $title => $list) { - foreach ($list as $h => $link) { - if($h > $last) { - for ($i = 1; $i <= ($h - $last); $i++) { - $sumstring .= '
      '; - } - $sumstring .= '
    • '.$link.'
    • ' ; - } elseif ($h < $last) { - for ($i = 1; $i <= ($last - $h); $i++) { - $sumstring .= '
    '; - } - $sumstring .= '
  • '.$link.'
  • ' ; - } elseif ($h = $last) { - $sumstring .= '
  • '.$link.'
  • ' ; - } - $last = $h; +var_dump($presets); + +foreach ($presets as $element => $preset) { + foreach ($preset as $param => $unit) { + if (array_key_exists($element, $quickcss) && array_key_exists($param, $quickcss[$element])) { + $quickcss[$element][$param] .= $unit; } } - for ($i = 1; $i <= ($last); $i++) { - $sumstring .= ''; +} + + +$jsonquickcss = json_encode($quickcss); + +var_dump($jsonquickcss); + +$string = ''; +foreach ($quickcss as $key => $css) { + $string .= PHP_EOL . $key . ' {'; + foreach ($css as $param => $value) { + + $string .= PHP_EOL . ' ' . $param . ': ' . $value . ';'; + + } + $string .= PHP_EOL . '}' . PHP_EOL; +} + +var_dump($string); + + + + +echo '
    '; + +foreach ($quickcss as $element => $css) { + echo '

    ' . $element . '

    '; + foreach ($css as $param => $value) { + + echo ''; + + if (in_array($param, $color)) { + echo ''; + echo ''; + } + + if (in_array($param, $size)) { + echo ''; + echo ''; + + $unit = preg_replace('/\d/', '', $quickcss[$element][$param]); + ?> + + ' . $param . ''; + echo ''; + + $unit = preg_replace('/\d/', '', $quickcss[$element][$param]); + ?> + + Add element'; + +echo ''; +echo ''; + +echo '
    '; + +echo '
    '; + +?> + + + + + +
    +

    Yolo babyzesssssss

    +

    + Note that the values of array need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be included in the result. -echo $sumstring; +If a value has several occurrences, the latest key will be used as its value, and all others will be lost. +

    -echo $text.'
    '; \ No newline at end of file +
    \ No newline at end of file diff --git a/public/test2.php b/public/test2.php new file mode 100644 index 0000000..a0cbafa --- /dev/null +++ b/public/test2.php @@ -0,0 +1,84 @@ + + + + + +
    + +setjson($_SESSION['css']); + +$quick->calc(); + +$quick->form('test2.php'); + +$_SESSION['css'] = $quick->tojson(); + + +?> + +
    + + + + + + + + +BODY +
    + SECTION +

    H1Bonjour tout le monde

    + +

    PDes bails de oufs qui toueeeett

    + +
    + ARTICLE +

    H2YOLO

    +

    P Des bails noirs très noir....

    +
    + + +
    + + + diff --git a/public/w/article.php b/public/w/article.php deleted file mode 100644 index 307caa4..0000000 --- a/public/w/article.php +++ /dev/null @@ -1,33 +0,0 @@ -exist($_GET['id'])) { - - $art = $app->get($_GET['id']); - - if (isset($_GET['edit']) and $_GET['edit'] == 1 and $app->session() >= $app::EDITOR) { - echo '
    '; - $aff->edit($art, $app, $app->getlister(['id', 'titre']), $config->fontsize(), $app->getlistermedia($app::MEDIA_DIR, 'image')); - //$aff->copy($art, $app->getlister(['id', 'titre'])); - $aff->aside($app); - echo '
    '; - } else { - echo '
    '; - - - $art->autotaglistupdate($app->taglist($app->getlister(['id', 'titre', 'intro', 'tag']), $art->autotaglist())); - - - $aff->lecture($art, $app); - echo '
    '; - - } -} else { - echo 'This article does not exist yet'; - - if ($app->session() >= $app::EDITOR) { - echo '
    '; - } - -} - -?> \ No newline at end of file diff --git a/public/w/css/styleadmin.css b/public/w/css/styleadmin.css deleted file mode 100644 index a3fcc5c..0000000 --- a/public/w/css/styleadmin.css +++ /dev/null @@ -1,80 +0,0 @@ -section { - margin-bottom: 100px; -} - -article { - border: 1px var(--color4) solid; - margin: 2px; - padding: 2px; - border: ridge; - max-width: 500px; - background-color: var(--color3); -} - -h1 { - border: ridge; - background-color: var(--color1); -} - -h2 { - margin-top: 0; - margin-bottom: 5px; -} - - -form { - display: inline-grid; - width: 98%; - margin: 1%; -} - -textarea#cssarea { - height: 400px; -} - -label { - font-weight: bold; - font-style: italic; -} - -summary { - background-color: var(--color1); - border: outset; - font-weight: bold; -} - -summary:focus { - outline: none; -} - -details { - background-color: var(--color1); - border: 1px var(--color4) solid; -} - - - -@media (max-width: 600px) { - nav { - width: unset; - position: relative; - display: block; - } - - div#menu { - display: block; - } -} - - -@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/w/css/stylebase.css b/public/w/css/stylebase.css deleted file mode 100644 index 017b075..0000000 --- a/public/w/css/stylebase.css +++ /dev/null @@ -1,85 +0,0 @@ -:root { - --color1: lightgrey; - --color2: lightslategrey; - --color3: #ececec; - --color4: grey; -} - - -@keyframes alert { - from {top: 30px;} - to {top: -50px;} -} - -body { - margin: 0; - font-family: sans-serif; - background-color: var(--color4); -} - - -span.alert { - position: fixed; - background-color: var(--color1); - z-index: 100; - border: ridge red; - width: 200px; - text-align: center; - padding: 5px; - top: 30px; - font-weight: bold; - left: calc(50% - 100px); - animation: alert 1s linear 2s forwards; -} - - -form{ - margin: 0; -} - - - -nav { - position: fixed; - top: 0; - right: 0; - z-index: 10; - background-color: var(--color1); - border: ridge; -} - -div#menu { - display: none; -} - -nav:hover div#menu { - display: block; -} - -nav a { - display: block; -} - -nav a:hover { - background-color: var(--color3); -} - -nav #loginpass { - width: 100%; -} - - -@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/w/css/styleedit.css b/public/w/css/styleedit.css deleted file mode 100644 index fe6745f..0000000 --- a/public/w/css/styleedit.css +++ /dev/null @@ -1,250 +0,0 @@ -.edit { - background-color: var(--color1); -} - -#linklist { - background-color: var(--color1); -} - -#submit { - background-color: var(--color1); -} - -#copy { - background-color: var(--color1); -} - - -#artedit { - background-color: var(--color1); -} - -details { - background-color: var(--color1); -} - - - -.sidebar { - position: fixed; - width: 250px; - height: 100%; - overflow: scroll; - overflow-x: hidden; -} - -div#submit { - position: relative; -} - -textarea { - position: fixed; - width: calc(100% - 250px); - right: 0px; - height: 100%; - font-size: 1em; - padding: 2%; - padding-right: calc(50% - 500px); - resize: none; - -} - - -div#copy { - position: fixed; - bottom: 0; -} - -div#linklist { - position: fixed; - bottom: 0; - right: 0; - min-width: 10%; - max-width: 50%; - max-height: 50%; - overflow-y: auto; - -} - -div#linklist div#roll { - display: none; -} - -div#linklist:hover div#roll { - display: block; - width: auto; -} - -div#roll ul { - list-style: none; - margin: 0; - padding: 0; -} - - - -details label { - margin-top: 4px; -} - - -details select, details input, details label, details textarea#css { - width: 100%; -} - -details input[type="checkbox"] -{ - width: auto; -} - -ul { - list-style: none; - padding: 0; - margin: 2px; -} - -fieldset { - margin: 0; - padding: 0; - border: none; -} - -summary, div#linklist, div#copy, div#submit { - border: ridge 1px grey; - -} - -span#headid { - font-weight: bold; - padding-left: 1%; - padding-right: 1%; - border: ridge; - background-color: var(--color3); - -} - -input#fontsize { - width: 40px; -} - -summary { - background-color: var(--color1); - border: outset; - font-weight: bold; -} - -summary:focus { - outline: none; -} - -div#help { - padding: 2px; -} - -div#help pre { - background-color: white; - margin-bottom: 2px; -} - -div#help p { - background-color: var(--color3); - margin-top: 4px; -} - -div#help h3 {margin-bottom: 8px;} - -span.i { - background-color: var(--color2); - color: white; -} - - - -/* ------------------------------ TABS ----------------------------- */ - - - -.tabs -{ - position: absolute; - left: 250px; - top: 28px; -} - -.tabs .tab -{ - float: left; -} - -.tabs .tab .content -{ - position: absolute; - background-color: white; - left: 0px; - width: 100%; - border: 1px #000 solid; -} - -.checkboxtab -{ - display: none; -} - -.tab label -{ - margin-right: 10px; - border: outset; - background-color: var(--color1); -} - -.checkboxtab:checked ~ label -{ - border: inset; -} - -.checkboxtab:checked ~ .content -{ - z-index: 1; -} - - - - - - - -@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/w/css/stylehome.css b/public/w/css/stylehome.css deleted file mode 100644 index 98822f0..0000000 --- a/public/w/css/stylehome.css +++ /dev/null @@ -1,117 +0,0 @@ -section.home { - margin-top: 27px; - display: inline-flex; - width: 100%; -} - -div#main { - border: ridge; - height: fit-content; - margin: 5px; - background-color: var(--color3); -} - -div#map { - border: ridge; - height: fit-content; - margin: 5px; - background-color: var(--color3); -} - -div#options { - border: ridge; - margin: 5px; - background-color: var(--color3); - width: 15%; - list-style: none; - max-width: 200px; - height: fit-content; - -} - -fieldset { - background-color: var(--color1); - border: outset; -} - -legend { - font-weight: bold; -} - -div#massedit { - background-color: var(--color1); -} - -header { - position: fixed; - width: 100%; - border: ridge; - background-color: var(--color1); -} - -h2 { - font-size: large; - margin: 0; - border: outset; - background-color: var(--color1); -} - -#options ul { - list-style: none; - margin: 0; - padding: 0; -} - -#home2table { - background-color: var(--color3); -} - -#home2table tr:hover { - background-color: var(--color1); -} - -#home2table th { - background-color: var(--color1); - border: ridge 1px grey; -} - - - -@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/w/css/styleinfo.css b/public/w/css/styleinfo.css deleted file mode 100644 index a3fcc5c..0000000 --- a/public/w/css/styleinfo.css +++ /dev/null @@ -1,80 +0,0 @@ -section { - margin-bottom: 100px; -} - -article { - border: 1px var(--color4) solid; - margin: 2px; - padding: 2px; - border: ridge; - max-width: 500px; - background-color: var(--color3); -} - -h1 { - border: ridge; - background-color: var(--color1); -} - -h2 { - margin-top: 0; - margin-bottom: 5px; -} - - -form { - display: inline-grid; - width: 98%; - margin: 1%; -} - -textarea#cssarea { - height: 400px; -} - -label { - font-weight: bold; - font-style: italic; -} - -summary { - background-color: var(--color1); - border: outset; - font-weight: bold; -} - -summary:focus { - outline: none; -} - -details { - background-color: var(--color1); - border: 1px var(--color4) solid; -} - - - -@media (max-width: 600px) { - nav { - width: unset; - position: relative; - display: block; - } - - div#menu { - display: block; - } -} - - -@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/w/css/stylemedia.css b/public/w/css/stylemedia.css deleted file mode 100644 index d721a9b..0000000 --- a/public/w/css/stylemedia.css +++ /dev/null @@ -1,103 +0,0 @@ -article { - border: 1px var(--color4) solid; - margin: 2px; - padding: 2px; - border: ridge; - max-width: 700px; - background-color: var(--color3); -} - -h1 { - border: ridge; - background-color: var(--color1); -} - -h2 { - margin-top: 0; - margin-bottom: 5px; -} - - -form { - display: inline-grid; - width: 98%; - margin: 1%; -} - - -label { - font-weight: bold; - font-style: italic; -} - -summary { - background-color: var(--color1); - border: outset; - font-weight: bold; -} - -summary:focus { - outline: none; -} - -details { - background-color: var(--color1); - border: 1px var(--color4) solid; -} - - -#mediatable { - background-color: var(--color3); -} - -#mediatable tr:hover { - background-color: var(--color1); -} - -#mediatable th { - background-color: var(--color1); - border: ridge 1px grey; -} - -.tooltip span { - display: none; - color: #000; - text-decoration: none; - padding: 3px; -} - -.tooltip:hover span { - display: block; - position: absolute; - background-color: var(--color3); - border: ridge; - margin-left: 30px; - margin-top: 0px; -} - - -img.thumbnail { - max-width: 100%; - max-height: 150px; -} - -input[type="checkbox"] { - width: unset; - 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/w/css/stylerecord.css b/public/w/css/stylerecord.css deleted file mode 100644 index 409bcd4..0000000 --- a/public/w/css/stylerecord.css +++ /dev/null @@ -1,79 +0,0 @@ -section { - padding: 0; -} - -.infobulle { - display: none; -} - -.little:hover .infobulle { - display: inline-block; - position: relative; - background-color: white; - z-index: 5; - top: 5px; - width: 300px; - font-family: monospace; - font-size: 0.9em; - line-height: 1.1em; -} - -span.infobulle img { - width: 100%; -} - -.grid { - display: flex; - flex-wrap: wrap; - padding: 4%; - margin-right: 120px; - list-style: none; - -} - -.little { - width: 100px; - height: 150px; - margin: 10px; - background-color: white; - -} - -.infobulle input[type="text"] { - font-family: monospace; - font-size: 0.9em; - margin: 3px; -} - -img.thumbnail { - max-width: 100%; - max-height: 100px; -} - -section.gest { - padding-bottom: 300px; -} - -input[type="file"] { - font-size: 1.3em; -} - -input[type="checkbox"] { - width: unset; - padding: unset; - margin: unset; - height: unset; -} - - -@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/w/home.php b/public/w/home.php deleted file mode 100644 index 3094d03..0000000 --- a/public/w/home.php +++ /dev/null @@ -1,85 +0,0 @@ -header(); - -echo '
    '; - - -if ($app->session() >= $app::EDITOR) { - - $app->bddinit($config); - - $opt = new Opt(Art::classvarlist()); - $opt->setcol(['id', 'tag', 'lien', 'contenu', 'intro', 'titre', 'datemodif', 'datecreation', 'secure']); - $table = $app->getlisteropt($opt); - $app->listcalclien($table); - $opt->settaglist($table); - $opt->submit(); - - - - - - - - - - - - $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 = []; - $table2invert = []; - foreach ($table as $art) { - if (in_array($art->id(), $filter)) { - $table2[] = $art; - } else { - $table2invert[] = $art; - } - - - } - - if(!empty($opt->invert())) { - $table2 = $table2invert; - } - - $app->artlistsort($table2, $opt->sortby(), $opt->order()); - - - echo '
    '; - - - $aff->home2table($app, $table2, $app->getlister()); - - - - - echo '
    '; - $aff->mapheader(); - if(isset($_GET['map'])) { - $aff->mermaid($app->map($table2)); - } - echo '
    '; - - - - - - echo '
    '; - -} - - - -echo '
    '; - -?> \ No newline at end of file diff --git a/public/w/index.php b/public/w/index.php index a5b3e03..bc5047e 100644 --- a/public/w/index.php +++ b/public/w/index.php @@ -1,362 +1,5 @@ readconfig(); -if (!$config) { - $message = 'config_file_error'; - echo $message; - if (isset($_POST['config']) && $_POST['config'] == 'create') { - $config = $app->createconfig($_POST); - $app->savejson($config->tojson()); - header('Location: ./'); - - } else { - $aff->configform(); - } - exit; -} - - -// _________________________________________________________ S E S ___________________________________________________________ - - -if (!isset($_SESSION['level'])) { - $session = 0; -} else { - $session = $_SESSION['level']; -} - -$app->setsession($session); - - - - -// _______________________________________________________ A C T I O N __________________________________________________________________ - - -if (isset($_POST['action'])) { - switch ($_POST['action']) { - - case 'login': - $_SESSION['level'] = $app->login($_POST['pass'], $config); - if (isset($_GET['id'])) { - header('Location: ?id=' . $_GET['id']); - } else { - header('Location: ./'); - } - break; - - case 'logout': - $_SESSION['level'] = $app->logout(); - if (isset($_GET['id'])) { - header('Location: ?id=' . $_GET['id']); - } else { - header('Location: ./'); - } - break; - - case 'addmedia': - $message = $app->addmedia($_FILES, 2 ** 24, $_POST['id']); - header('Location: ./?aff=media&message=' . $message); - break; - - case 'addcss': - $message = $app->addcss($_FILES, 2 ** 24, $_POST['id']); - header('Location: ./?aff=admin&message=' . $message); - break; - - case 'editcss': - file_put_contents($app::CSS_READ_DIR . $config->cssread(), $_POST['editcss']); - header('Location: ./?aff=admin'); - break; - - case 'editconfig': - $config->hydrate($_POST); - $app->savejson($config->tojson()); - header('Location: ./?aff=admin'); - break; - - - } -} - - - -// _____________________________________________________ D A T A B A S E __________________________________________________________________ - -if (isset($_POST['action'])) { - $app->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); - $art->updatelien(); - $art->autotaglistcalc($app->taglist($app->getlister(['id', 'titre', 'tag']), $art->autotaglist())); - $app->update($art); - if($config->fontsize() != $_POST['fontsize']) { - $config->setfontsize($_POST['fontsize']); - $app->savejson($config->tojson()); - } - header('Location: ?id=' . $art->id() . '&edit=1&message='.$art->id().'_saved'); - } - break; - - case 'display': - if ($app->exist($_GET['id'])) { - $art = new Art($_POST); - $art->updatelien(); - $art->autotaglistcalc($app->taglist($app->getlister(['id', 'titre', 'tag']), $art->autotaglist())); - $app->update($art); - if($config->fontsize() != $_POST['fontsize']) { - $config->setfontsize($_POST['fontsize']); - $app->savejson($config->tojson()); - } - header('Location: ?id=' . $art->id().'&message='.$art->id().'_saved'); - } - break; - - case 'home': - if ($app->exist($_GET['id'])) { - $art = new Art($_POST); - $art->updatelien(); - $art->autotaglistcalc($app->taglist($app->getlister(['id', 'titre', 'tag']), $art->autotaglist())); - $app->update($art); - if($config->fontsize() != $_POST['fontsize']) { - $config->setfontsize($_POST['fontsize']); - $app->savejson($config->tojson()); - } - header('Location: ./?message='.$art->id().'_saved'); - } - break; - - case 'copy': - if ($app->exist($_GET['id'])) { - $copy = $app->get($_POST['copy']); - $art = $app->get($_POST['id']); - if (!empty($_POST['css'])) { - $art->setcss($copy->css()); - } - if (!empty($_POST['color'])) { - $art->setcouleurtext($copy->couleurtext()); - $art->setcouleurbkg($copy->couleurbkg()); - $art->setcouleurlien($copy->couleurlien()); - $art->setcouleurlienblank($copy->couleurlienblank()); - } - if (!empty($_POST['html'])) { - $art->sethtml($copy->md()); - } - if (!empty($_POST['template'])) { - $art->settemplate($copy->template()); - } - $app->update($art); - header('Location: ?id=' . $art->id() . '&edit=1'); - } - break; - - case 'delete': - if ($app->exist($_GET['id'])) { - $art = new Art($_POST); - $app->delete($art); - header('Location: ?id=' . $art->id()); - } - break; - - case 'massedit': - if (isset($_POST['id'])) { - foreach ($_POST['id'] as $id) { - if ($app->exist($id)) { - $art = $app->get($id); - - switch ($_POST['massaction']) { - case 'do': - switch ($_POST['massedit']) { - case 'delete': - $app->delete($art); - break; - - case 'erasetag': - $art->settag(''); - $app->update($art); - break; - - case 'erasetemplate': - $art->settemplate(''); - $app->update($art); - break; - - case 'not published': - $art->setsecure(2); - $app->update($art); - break; - - case 'private': - $art->setsecure(1); - $app->update($art); - break; - - case 'public': - $art->setsecure(0); - $app->update($art); - break; - } - break; - - case 'set template': - if (isset($_POST['masstemplate'])) { - $art->settemplate($_POST['masstemplate']); - $app->update($art); - } - break; - - case 'add tag': - if (isset($_POST['targettag'])) { - $art = $app->get($id); - $tagstring = strip_tags(trim(strtolower($_POST['targettag']))); - $taglist = str_replace(' ', '', $tagstring); - $taglist = explode(",", $taglist); - foreach ($taglist as $tag) { - if (!in_array($tag, $art->tag('array'))) { - $newtaglist = $art->tag('array'); - array_push($newtaglist, $tag); - $art->settag($newtaglist); - } - } - $app->update($art); - } - break; - - } - - - - - } - header('Location: ./'); - } - break; - } - } -} - - - - - -if (isset($_POST['actiondb'])) { - $app->setbdd($config); - - switch ($_POST['actiondb']) { - - case 'addtable': - if (isset($_POST['tablename'])) { - $message = $app->addtable($config->dbname(), $_POST['tablename']); - header('Location: ./?aff=admin&message=' . $message); - } - break; - - case 'duplicatetable': - $message = $app->tableduplicate($config->dbname(), $_POST['arttable'], $_POST['tablename']); - header('Location: ./?aff=admin&message=' . $message); - break; - - } -} - - - - -// _______________________________________________________ H E A D _____________________________________________________________ - -if (isset($_GET['id'])) { - $app->bddinit($config); - if ($app->exist($_GET['id'])) { - $art = $app->get($_GET['id']); - if (!isset($_GET['edit'])) { - $_GET['edit'] = 0; - } - $aff->arthead($art, $app::CSS_READ_DIR, $config->cssread(), $_GET['edit']); - } else { - // $aff->head($_GET['id'], '', 'white'); - $aff->noarthead($_GET['id'], $app::CSS_READ_DIR, $config->cssread()); - - } -} elseif (isset($_GET['aff'])) { - $aff->head($_GET['aff'], $_GET['aff'], $config->color4()); -} else { - $aff->head('home', 'home', $config->color4()); -} - - - - - - - -// _____________________________________________________ A L E R T _______________________________________________________________ - -if (isset($_GET['message'])) { - echo '' . $_GET['message'] . ''; -} - - - - - - - - -// ______________________________________________________ B O D Y _______________________________________________________________ - - -$aff->nav($app); - -if (array_key_exists('id', $_GET)) { - $app->bddinit($config); - include('article.php'); -} elseif (array_key_exists('tag', $_GET)) { - $app->bddinit($config); - echo '

    ' . $_GET['tag'] . '

    '; - $aff->tag($app->getlister(['id', 'titre', 'intro', 'tag']), $_GET['tag'], $app); -} elseif (array_key_exists('lien', $_GET)) { - $app->bddinit($config); - echo '

    ' . $_GET['lien'] . '

    '; - $aff->lien($app->getlister(['id', 'titre', 'intro', 'lien']), $_GET['lien'], $app); -} elseif (array_key_exists('aff', $_GET)) { - include('menu.php'); -} else { - include('home.php'); -} - - +require('../../w/w.router.php'); ?> \ No newline at end of file diff --git a/public/w/menu.php b/public/w/menu.php deleted file mode 100644 index 8e89ed1..0000000 --- a/public/w/menu.php +++ /dev/null @@ -1,56 +0,0 @@ -session() >= $app::EDITOR) { - - if ($_GET['aff'] == 'admin' && $app->session() >= $app::ADMIN) { - echo '
    '; - echo '

    Admin

    '; - - $aff->admincss($config, $app); - $aff->adminpassword($config); - $aff->admindb($config); - if ($app->setbdd($config)) { - $status = "OK"; - } else { - $status = "Not Connected"; - } - $aff->admintable($config, $status, $app->tablelist($config->dbname())); - $aff->admindisplay($config->color4()); - - echo '
    '; - } elseif ($_GET['aff'] == 'media') { - echo '

    Media

    '; - echo '
    '; - echo '
    '; - - $aff->addmedia($app); - $aff->medialist($app->getlistermedia($app::MEDIA_DIR), $app::MEDIA_DIR); - - echo '
    '; - echo '
    '; - - } elseif ($_GET['aff'] == 'record') { - echo '

    Record

    '; - echo '
    '; - - $aff->recordlist($app); - - echo '
    '; - - } elseif ($_GET['aff'] == 'info') { - - - - } else { - - echo '

    Private

    You dont have the permission to access this page.

    '; - - } - - -} else { - echo '

    Private

    You should be connected to access this page.

    '; -} - -?> \ No newline at end of file diff --git a/public/w/rsc/css/styleadmin.css b/public/w/rsc/css/styleadmin.css new file mode 100644 index 0000000..a3fcc5c --- /dev/null +++ b/public/w/rsc/css/styleadmin.css @@ -0,0 +1,80 @@ +section { + margin-bottom: 100px; +} + +article { + border: 1px var(--color4) solid; + margin: 2px; + padding: 2px; + border: ridge; + max-width: 500px; + background-color: var(--color3); +} + +h1 { + border: ridge; + background-color: var(--color1); +} + +h2 { + margin-top: 0; + margin-bottom: 5px; +} + + +form { + display: inline-grid; + width: 98%; + margin: 1%; +} + +textarea#cssarea { + height: 400px; +} + +label { + font-weight: bold; + font-style: italic; +} + +summary { + background-color: var(--color1); + border: outset; + font-weight: bold; +} + +summary:focus { + outline: none; +} + +details { + background-color: var(--color1); + border: 1px var(--color4) solid; +} + + + +@media (max-width: 600px) { + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } +} + + +@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/w/rsc/css/stylebase.css b/public/w/rsc/css/stylebase.css new file mode 100644 index 0000000..017b075 --- /dev/null +++ b/public/w/rsc/css/stylebase.css @@ -0,0 +1,85 @@ +:root { + --color1: lightgrey; + --color2: lightslategrey; + --color3: #ececec; + --color4: grey; +} + + +@keyframes alert { + from {top: 30px;} + to {top: -50px;} +} + +body { + margin: 0; + font-family: sans-serif; + background-color: var(--color4); +} + + +span.alert { + position: fixed; + background-color: var(--color1); + z-index: 100; + border: ridge red; + width: 200px; + text-align: center; + padding: 5px; + top: 30px; + font-weight: bold; + left: calc(50% - 100px); + animation: alert 1s linear 2s forwards; +} + + +form{ + margin: 0; +} + + + +nav { + position: fixed; + top: 0; + right: 0; + z-index: 10; + background-color: var(--color1); + border: ridge; +} + +div#menu { + display: none; +} + +nav:hover div#menu { + display: block; +} + +nav a { + display: block; +} + +nav a:hover { + background-color: var(--color3); +} + +nav #loginpass { + width: 100%; +} + + +@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/w/rsc/css/styleedit.css b/public/w/rsc/css/styleedit.css new file mode 100644 index 0000000..fe6745f --- /dev/null +++ b/public/w/rsc/css/styleedit.css @@ -0,0 +1,250 @@ +.edit { + background-color: var(--color1); +} + +#linklist { + background-color: var(--color1); +} + +#submit { + background-color: var(--color1); +} + +#copy { + background-color: var(--color1); +} + + +#artedit { + background-color: var(--color1); +} + +details { + background-color: var(--color1); +} + + + +.sidebar { + position: fixed; + width: 250px; + height: 100%; + overflow: scroll; + overflow-x: hidden; +} + +div#submit { + position: relative; +} + +textarea { + position: fixed; + width: calc(100% - 250px); + right: 0px; + height: 100%; + font-size: 1em; + padding: 2%; + padding-right: calc(50% - 500px); + resize: none; + +} + + +div#copy { + position: fixed; + bottom: 0; +} + +div#linklist { + position: fixed; + bottom: 0; + right: 0; + min-width: 10%; + max-width: 50%; + max-height: 50%; + overflow-y: auto; + +} + +div#linklist div#roll { + display: none; +} + +div#linklist:hover div#roll { + display: block; + width: auto; +} + +div#roll ul { + list-style: none; + margin: 0; + padding: 0; +} + + + +details label { + margin-top: 4px; +} + + +details select, details input, details label, details textarea#css { + width: 100%; +} + +details input[type="checkbox"] +{ + width: auto; +} + +ul { + list-style: none; + padding: 0; + margin: 2px; +} + +fieldset { + margin: 0; + padding: 0; + border: none; +} + +summary, div#linklist, div#copy, div#submit { + border: ridge 1px grey; + +} + +span#headid { + font-weight: bold; + padding-left: 1%; + padding-right: 1%; + border: ridge; + background-color: var(--color3); + +} + +input#fontsize { + width: 40px; +} + +summary { + background-color: var(--color1); + border: outset; + font-weight: bold; +} + +summary:focus { + outline: none; +} + +div#help { + padding: 2px; +} + +div#help pre { + background-color: white; + margin-bottom: 2px; +} + +div#help p { + background-color: var(--color3); + margin-top: 4px; +} + +div#help h3 {margin-bottom: 8px;} + +span.i { + background-color: var(--color2); + color: white; +} + + + +/* ------------------------------ TABS ----------------------------- */ + + + +.tabs +{ + position: absolute; + left: 250px; + top: 28px; +} + +.tabs .tab +{ + float: left; +} + +.tabs .tab .content +{ + position: absolute; + background-color: white; + left: 0px; + width: 100%; + border: 1px #000 solid; +} + +.checkboxtab +{ + display: none; +} + +.tab label +{ + margin-right: 10px; + border: outset; + background-color: var(--color1); +} + +.checkboxtab:checked ~ label +{ + border: inset; +} + +.checkboxtab:checked ~ .content +{ + z-index: 1; +} + + + + + + + +@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/w/rsc/css/stylehome.css b/public/w/rsc/css/stylehome.css new file mode 100644 index 0000000..98822f0 --- /dev/null +++ b/public/w/rsc/css/stylehome.css @@ -0,0 +1,117 @@ +section.home { + margin-top: 27px; + display: inline-flex; + width: 100%; +} + +div#main { + border: ridge; + height: fit-content; + margin: 5px; + background-color: var(--color3); +} + +div#map { + border: ridge; + height: fit-content; + margin: 5px; + background-color: var(--color3); +} + +div#options { + border: ridge; + margin: 5px; + background-color: var(--color3); + width: 15%; + list-style: none; + max-width: 200px; + height: fit-content; + +} + +fieldset { + background-color: var(--color1); + border: outset; +} + +legend { + font-weight: bold; +} + +div#massedit { + background-color: var(--color1); +} + +header { + position: fixed; + width: 100%; + border: ridge; + background-color: var(--color1); +} + +h2 { + font-size: large; + margin: 0; + border: outset; + background-color: var(--color1); +} + +#options ul { + list-style: none; + margin: 0; + padding: 0; +} + +#home2table { + background-color: var(--color3); +} + +#home2table tr:hover { + background-color: var(--color1); +} + +#home2table th { + background-color: var(--color1); + border: ridge 1px grey; +} + + + +@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/w/rsc/css/styleinfo.css b/public/w/rsc/css/styleinfo.css new file mode 100644 index 0000000..a3fcc5c --- /dev/null +++ b/public/w/rsc/css/styleinfo.css @@ -0,0 +1,80 @@ +section { + margin-bottom: 100px; +} + +article { + border: 1px var(--color4) solid; + margin: 2px; + padding: 2px; + border: ridge; + max-width: 500px; + background-color: var(--color3); +} + +h1 { + border: ridge; + background-color: var(--color1); +} + +h2 { + margin-top: 0; + margin-bottom: 5px; +} + + +form { + display: inline-grid; + width: 98%; + margin: 1%; +} + +textarea#cssarea { + height: 400px; +} + +label { + font-weight: bold; + font-style: italic; +} + +summary { + background-color: var(--color1); + border: outset; + font-weight: bold; +} + +summary:focus { + outline: none; +} + +details { + background-color: var(--color1); + border: 1px var(--color4) solid; +} + + + +@media (max-width: 600px) { + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } +} + + +@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/w/rsc/css/stylemedia.css b/public/w/rsc/css/stylemedia.css new file mode 100644 index 0000000..d721a9b --- /dev/null +++ b/public/w/rsc/css/stylemedia.css @@ -0,0 +1,103 @@ +article { + border: 1px var(--color4) solid; + margin: 2px; + padding: 2px; + border: ridge; + max-width: 700px; + background-color: var(--color3); +} + +h1 { + border: ridge; + background-color: var(--color1); +} + +h2 { + margin-top: 0; + margin-bottom: 5px; +} + + +form { + display: inline-grid; + width: 98%; + margin: 1%; +} + + +label { + font-weight: bold; + font-style: italic; +} + +summary { + background-color: var(--color1); + border: outset; + font-weight: bold; +} + +summary:focus { + outline: none; +} + +details { + background-color: var(--color1); + border: 1px var(--color4) solid; +} + + +#mediatable { + background-color: var(--color3); +} + +#mediatable tr:hover { + background-color: var(--color1); +} + +#mediatable th { + background-color: var(--color1); + border: ridge 1px grey; +} + +.tooltip span { + display: none; + color: #000; + text-decoration: none; + padding: 3px; +} + +.tooltip:hover span { + display: block; + position: absolute; + background-color: var(--color3); + border: ridge; + margin-left: 30px; + margin-top: 0px; +} + + +img.thumbnail { + max-width: 100%; + max-height: 150px; +} + +input[type="checkbox"] { + width: unset; + 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/w/rsc/css/stylerecord.css b/public/w/rsc/css/stylerecord.css new file mode 100644 index 0000000..409bcd4 --- /dev/null +++ b/public/w/rsc/css/stylerecord.css @@ -0,0 +1,79 @@ +section { + padding: 0; +} + +.infobulle { + display: none; +} + +.little:hover .infobulle { + display: inline-block; + position: relative; + background-color: white; + z-index: 5; + top: 5px; + width: 300px; + font-family: monospace; + font-size: 0.9em; + line-height: 1.1em; +} + +span.infobulle img { + width: 100%; +} + +.grid { + display: flex; + flex-wrap: wrap; + padding: 4%; + margin-right: 120px; + list-style: none; + +} + +.little { + width: 100px; + height: 150px; + margin: 10px; + background-color: white; + +} + +.infobulle input[type="text"] { + font-family: monospace; + font-size: 0.9em; + margin: 3px; +} + +img.thumbnail { + max-width: 100%; + max-height: 100px; +} + +section.gest { + padding-bottom: 300px; +} + +input[type="file"] { + font-size: 1.3em; +} + +input[type="checkbox"] { + width: unset; + padding: unset; + margin: unset; + height: unset; +} + + +@media (max-width: 600px) { + nav { + width: unset; + position: relative; + display: block; + } + + div#menu { + display: block; + } +} \ No newline at end of file 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 @@ +setsession($session); + } + + + + // ____________________________________________________ C O N F I G ______________________________________________ + + + public function configform() + { + ?> +

    Config file does not exist yet, or maybe you deleted it ? Anyway, it is time to set it :

    +
    + + Database settings
    +
    +
    +
    +
    + Domain name settings
    +
    + W_cms settings
    +
    + + + + + (You can change everything later, set at least your admin password, and don't forget it !)
    + +
    + secure() == 1) { + echo 'This article is private'; + } + if ($art->secure() == 2) { + echo "This article is not published yet"; + } + + if ($app->session() >= $art->secure()) { + ?> + +
    +

    titre() ?>

    +
    soustitre() ?>
    +
    +
    html($app) ?>
    + session() >= self::$edit) { + + ?> + +
    + + textarea{font-size: ' . $fontsize . '}'; + $tablist = ['html' => $art->md(), 'css' => $art->css(), 'aside' => 'NOT WORKING', 'footer' => 'NOT WORKING']; + + $this->tabs($tablist, 'html'); + + ?> + +
    + + + + + 👁 + + id() ?> + + + +
    + + + + + + +
    + + + '; + foreach ($tablist as $key => $value) { + echo '
    '; + if ($key == $opentab) { + echo ''; + } else { + echo ''; + } + echo ''; + echo '
    '; + echo ''; + echo '
    '; + echo '
    '; + } + + echo ''; +} + + + +public function copy(Art $art, $list) +{ + ?> +
    +
    +
    + + + '; + ?> + + + + + + + + + +
    +
    +
    + + + + + + + + + <?= $title ?> + + + + + + + + + + ' : '' ?> + <?= $edit == 1 ? '✏' : '' ?> <?= $art->titre() ?> + + + + + + + + + + + ❓ <?= $id ?> + + + + + '; + echo '
      '; + foreach ($getlist as $item) { + if (in_array($tag, $item->tag('array'))) { + echo '
    • ' . $item->titre() . ' - ' . $item->intro(); + if ($app->session() >= $app::EDITOR) { + echo ' - modifier
    • '; + } else { + echo ''; + } + } + } + echo '
    '; + echo ' '; +} + +public function lien($getlist, $lien, App $app) +{ + echo '
    '; + echo '
      '; + foreach ($getlist as $item) { + if (in_array($lien, $item->lien('array'))) { + echo '
    • ' . $item->titre() . ' - ' . $item->intro(); + if ($app->session() >= $app::EDITOR) { + echo ' - modifier - liens
    • '; + } else { + echo ''; + } + } + } + echo '
    '; + echo '
    '; +} + + + +public function dump($getlist) +{ + echo '
      '; + foreach ($getlist as $item) { + echo '
    • '; + var_dump($item); + echo '
    • '; + } + echo '
    '; +} + +public function header() +{ + echo '
    '; + $this->search(); + echo '
    '; +} + + +public function home2table(App $app, $getlist, $masslist) +{ + echo '
    '; + echo '

    Articles

    '; + echo '
    '; + + ?> +
    +

    Mass Edit

    + + + + + + + + + + + + +
    + + session() >= $app::EDITOR) { + echo ''; + echo ''; + foreach ($getlist as $item) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
    xtitletagsummary↘ to↗ fromlast modificationdate of creationprivacydisplay
    ' . $item->titre() . '' . $item->tag('sort') . '' . $item->intro() . '' . $item->liento('sort') . '' . $item->lien('sort') . '' . $item->datemodif('hrdi') . '' . $item->datecreation('hrdi') . '' . $item->secure('string') . '👁
    '; + echo '
    '; + echo '
    '; + } +} + +public function option(App $app, Opt $opt) +{ + if ($app->session() >= $app::EDITOR) { + echo '
    '; + echo '

    Options

    '; + echo '
    '; + echo ''; + echo '⬅'; + + + $this->optionsort($opt); + $this->optionprivacy($opt); + $this->optiontag($opt); + + if ($opt->invert() == 1) { + echo ''; + } else { + echo ''; + } + echo '
    '; + + } + +} + +public function optiontag(Opt $opt) +{ + + echo '
    Tag
      '; + + + echo 'tagcompare() == "OR" ? "checked" : "") . ' >'; + echo 'tagcompare() == "AND" ? "checked" : "") . '>'; + + //echo ''; + + $in = false; + $out = false; + $limit = 1; + foreach ($opt->taglist() as $tagfilter => $count) { + + if ($count > $limit && $in == false) { + echo '
      >' . $limit . ''; + $in = true; + } + if ($count == $limit && $in == true && $out == false) { + echo '
      ' . $limit . ''; + $out = true; + } + + if (in_array($tagfilter, $opt->tagfilter())) { + + echo '
    • '; + } else { + echo '
    • '; + } + } + if ($in = true || $out = true) { + echo '
      '; + } + echo '
    '; + +} + +public function optionprivacy(Opt $opt) +{ + echo '
    Privacity
      '; + echo '
    • secure() == 4 ? "checked" : "") . ' />
    • '; + echo '
    • secure() == 2 ? "checked" : "") . ' />
    • '; + echo '
    • secure() == 1 ? "checked" : "") . ' />
    • '; + echo '
    • secure() == 0 ? "checked" : "") . ' />
    • '; + echo '
    '; +} + +public function optionsort(Opt $opt) +{ + echo '
    Sort'; + echo ''; + echo '
    '; + echo 'order() == '1' ? "checked" : "") . ' />'; + echo '
    '; + echo 'order() == '-1' ? "checked" : "") . ' />'; + + echo '
    '; + +} + +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']; + ?> +

    Map

    + +
    + + + + + +
    + + + + + + + +
    + + graph + +
    + + + session() >= $app::EDITOR) { + echo ' '; + } +} + +public function nav($app) +{ + echo ' + session() >= $app::EDITOR) { + + ?> +
    + Add Media +
    + + + + +
    +
    + +
    + Media List + +
    + + + + id() . '.' . $item->extension(); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if ($item->type() == 'image') { + echo ''; + echo ''; + } elseif ($item->type() == 'sound') { + echo ''; + echo ''; + } else { + echo ''; + echo ''; + } + echo ''; + echo ''; + + } + + + ?> + + +
    xNameextensionwidthheightsizecodethumbnail
    ' . $item->extension() . '' . $item->width() . '' . $item->height() . '' . readablesize($item->size()) . '👁' . $item->id() . '
    + + + + +
    + + +
    + + + '; + echo 'Media List'; + + echo '
    '; + + echo '
    '; + + echo '
      '; + + foreach ($app->getlisterrecord($dir) as $item) { + echo '
    • '; + + ?> + + + + + id()) . '.' . $item->extension(); + + echo '
      '; + var_dump($item->size()); + var_dump(intval($item->size())); + echo 'filesize = ' . readablesize(intval($item->size())); + echo '
      '; + echo 'extension = ' . $item->extension(); + echo '
      '; + + ?> + + + + + + '; + } + + echo '
    '; + + ?> + + + +
    + + + + '; + echo ''; + + + } + + + //______________________________________________________ A D M _________________________________________________ + + + + public function admincss(Config $config, $app) + { + ?> +
    +

    CSS

    + +

    CSS file :

    + +

    + + '; + echo 'Edit current CSS'; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo '
    '; + echo ''; + } + + ?> + +
    + + +
    + + +

    Database

    + +
    + Database credentials + +

    Fill this sections with the database settings you want to connect to

    + +
    + + + + + + + + + + +
    + +
    + + +
    + + +
    + +

    Passwords

    + +
    + Admin + +

    Edit your own admin password. You can find it in the config.w.json file, in the root of your website folder.

    + +
    + + + + +
    + +
    +
    + Others + +

    Use this section to set all the others users passwords. They cant access this page, so they cant change it by themselves.

    + +
    + + + + + + + + +
    + +
    +
    + + + + + + +
    + +

    Table

    + + + +

    Database status :

    + + +

    Current Table : arttable(); ?>

    +
    + Select Table +

    The table is where all your articles are stored, select the one you want to use.

    + +
    + + + +
    + +
    + +
    + Add table + +

    Create new table in your database. You need at least one to use W_cms

    + +
    + + + +
    + +
    + +
    + Duplicate Table +

    If you want to save versions of your work.

    + +
    + + + + + + +
    + +
    + +
    + + +
    +

    Display

    +
    + Update favicon +
    + + +
    +
    +
    + Change desktop background color +
    + + + + +
    +
    +
    + = 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 @@ +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 '

    Error 500, database offline

    '; + if ($this->session() >= self::EDITOR) { + echo '

    Error : ' . $e->getMessage() . '

    '; + if ($this->session() == self::ADMIN) { + echo '

    Go to the Admin Panel to edit your database credentials

    '; + } else { + echo '

    Logout and and come back with an admin password to edit the database connexions settings.

    '; + } + } else { + echo '

    Homepage for admin login (connect on the top right side)

    '; + } + exit; + } + + return $caught; + + } + + public function settable(Config $config) + { + if (!empty($config->arttable())) { + $this->arttable = $config->arttable(); + } else { + echo '

    Table Error

    '; + + if ($this->session() >= self::EDITOR) { + if ($this->session() == self::ADMIN) { + echo '

    Go to the Admin Panel to select or add an Article table

    '; + } else { + echo '

    Logout and and come back with an admin password to edit table settings.

    '; + } + } else { + echo '

    Homepage for admin login (connect on the top right side)

    '; + } + $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 '

    cet id existe deja

    '; + } 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 'idalreadyexist'; + } 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 @@ +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 = ''; + $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('
    ', $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 @@ +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 = ''; + $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('
    ', $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 @@ +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 @@ +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 @@ + '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 @@ + ['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 '
    '; + echo '
    '; + $this->inputs($this->quickcss); + echo '
    '; + echo '
    '; + + } + + public function inputs($quickcss) + { + echo '

    Add element

    '; + + echo ''; + echo ''; + foreach (array_keys($quickcss) as $element) { + echo ''; + + echo ''; + + foreach ($quickcss as $element => $css) { + echo '

    ' . $element . '

    '; + foreach ($css as $param => $value) { + + echo '
    '; + echo ''; + echo ''; + echo '
    '; + + echo '
    '; + + if (in_array($param, self::COLOR)) { + echo ''; + } + + 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 '
    '; + } + } + + + } + + + + + + + // ____________________________________ I N P U T __________________________________ + + public function sizeinput($element, $param, $value) + { + echo ''; + + $unit = preg_replace('/\d/', '', $value); + ?> + + '; + + $unit = preg_replace('/\d/', '', $value); + ?> + + '; + } + + public function selectinput($element, $param, $value) + { + echo ''; + } + + +} + + + +?> \ 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 @@ +hydrate($donnees); + } + + public function hydrate(array $donnees) + { + foreach ($donnees as $key => $value) { + $method = 'set' . $key; + + if (method_exists($this, $method)) { + $this->$method($value); + } + } + } + + + +// _________________________________________________ G E T ____________________________________________________ + + public function id() + { + return $this->id; + } + + public function path() + { + return $this->path; + } + + public function extension() + { + return $this->extension; + } + + public function size() + { + return $this->size; + } + + public function datetime() + { + return $this->datetime; + } + + public function number() + { + return $this->number; + } + +// ___________________________________________________ S E T __________________________________________________ + + public function setid($id) + { + if (strlen($id) < 100 and is_string($id)) { + $this->id = strip_tags(strtolower($id)); + } + } + + public function setpath($path) + { + if (strlen($path) < 40 and is_string($path)) { + $this->path = strip_tags(strtolower($path)); + } + } + + public function setextension($extension) + { + if (strlen($extension) < 7 and is_string($extension)) { + $this->extension = strip_tags(strtolower($extension)); + } + } + + public function setsize($size) + { + if (40 and is_int($size)) { + $this->size = strip_tags(strtolower($size)); + } + } + + public function setdatetime($datetime) + { + if (is_int($datetime)) { + $this->datetime = strip_tags(strtolower($datetime)); + } + } + + public function setnumber($number) + { + if (is_int($number)) { + $this->number = strip_tags(strtolower($number)); + } + } + + + + + +} + +?> \ No newline at end of file diff --git a/w/controller/w.article.php b/w/controller/w.article.php new file mode 100644 index 0000000..307caa4 --- /dev/null +++ b/w/controller/w.article.php @@ -0,0 +1,33 @@ +exist($_GET['id'])) { + + $art = $app->get($_GET['id']); + + if (isset($_GET['edit']) and $_GET['edit'] == 1 and $app->session() >= $app::EDITOR) { + echo '
    '; + $aff->edit($art, $app, $app->getlister(['id', 'titre']), $config->fontsize(), $app->getlistermedia($app::MEDIA_DIR, 'image')); + //$aff->copy($art, $app->getlister(['id', 'titre'])); + $aff->aside($app); + echo '
    '; + } else { + echo '
    '; + + + $art->autotaglistupdate($app->taglist($app->getlister(['id', 'titre', 'intro', 'tag']), $art->autotaglist())); + + + $aff->lecture($art, $app); + echo '
    '; + + } +} else { + echo 'This article does not exist yet'; + + if ($app->session() >= $app::EDITOR) { + echo '
    '; + } + +} + +?> \ No newline at end of file diff --git a/w/controller/w.home.php b/w/controller/w.home.php new file mode 100644 index 0000000..3094d03 --- /dev/null +++ b/w/controller/w.home.php @@ -0,0 +1,85 @@ +header(); + +echo '
    '; + + +if ($app->session() >= $app::EDITOR) { + + $app->bddinit($config); + + $opt = new Opt(Art::classvarlist()); + $opt->setcol(['id', 'tag', 'lien', 'contenu', 'intro', 'titre', 'datemodif', 'datecreation', 'secure']); + $table = $app->getlisteropt($opt); + $app->listcalclien($table); + $opt->settaglist($table); + $opt->submit(); + + + + + + + + + + + + $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 = []; + $table2invert = []; + foreach ($table as $art) { + if (in_array($art->id(), $filter)) { + $table2[] = $art; + } else { + $table2invert[] = $art; + } + + + } + + if(!empty($opt->invert())) { + $table2 = $table2invert; + } + + $app->artlistsort($table2, $opt->sortby(), $opt->order()); + + + echo '
    '; + + + $aff->home2table($app, $table2, $app->getlister()); + + + + + echo '
    '; + $aff->mapheader(); + if(isset($_GET['map'])) { + $aff->mermaid($app->map($table2)); + } + echo '
    '; + + + + + + echo '
    '; + +} + + + +echo '
    '; + +?> \ No newline at end of file diff --git a/w/controller/w.menu.php b/w/controller/w.menu.php new file mode 100644 index 0000000..8e89ed1 --- /dev/null +++ b/w/controller/w.menu.php @@ -0,0 +1,56 @@ +session() >= $app::EDITOR) { + + if ($_GET['aff'] == 'admin' && $app->session() >= $app::ADMIN) { + echo '
    '; + echo '

    Admin

    '; + + $aff->admincss($config, $app); + $aff->adminpassword($config); + $aff->admindb($config); + if ($app->setbdd($config)) { + $status = "OK"; + } else { + $status = "Not Connected"; + } + $aff->admintable($config, $status, $app->tablelist($config->dbname())); + $aff->admindisplay($config->color4()); + + echo '
    '; + } elseif ($_GET['aff'] == 'media') { + echo '

    Media

    '; + echo '
    '; + echo '
    '; + + $aff->addmedia($app); + $aff->medialist($app->getlistermedia($app::MEDIA_DIR), $app::MEDIA_DIR); + + echo '
    '; + echo '
    '; + + } elseif ($_GET['aff'] == 'record') { + echo '

    Record

    '; + echo '
    '; + + $aff->recordlist($app); + + echo '
    '; + + } elseif ($_GET['aff'] == 'info') { + + + + } else { + + echo '

    Private

    You dont have the permission to access this page.

    '; + + } + + +} else { + echo '

    Private

    You should be connected to access this page.

    '; +} + +?> \ No newline at end of file diff --git a/w/fn/w.fn.php b/w/fn/w.fn.php new file mode 100644 index 0000000..72c98c1 --- /dev/null +++ b/w/fn/w.fn.php @@ -0,0 +1,180 @@ +getMessage()); + } + return $bdd; +} + +function my_autoloader($class) +{ + require(__DIR__.'/../class/class.w.' . strtolower($class) . '.php'); +} + +function secure() +{ + if (!isset($_SESSION['id'])) { + header("location: ./"); + } +} + +function head($title) +{ + ?> + + + + + <?= $title ?> + + y > 1) return $str . $diff->y . ' years'; + if ($diff->y == 1) return $str . ' 1 year and ' . $diff->m . ' months'; + if ($diff->m > 1) return $str . $diff->m . ' months'; + if ($diff->m == 1) return $str . ' 1 month and ' . $diff->d . ($diff->d > 1 ? ' days' : ' day'); + if ($diff->d > 1) return $str . $diff->d . ' days'; + if ($diff->d == 1) return $str . ' 1 day and ' . $diff->h . ($diff->h > 1 ? ' hours' : ' hour'); + if ($diff->h > 1) return $str . $diff->h . ' hours'; + if ($diff->h == 1) return $str . ' 1 hour and ' . $diff->i . ($diff->i > 1 ? ' minutes' : ' minute'); + if ($diff->i > 1) return $str . $diff->i . ' minutes'; + if ($diff->i == 1) return $str . ' 1 minute'; + return $str . ' a few secondes'; +} + + + +function arrayclean($input) +{ + $output = []; + foreach ($input as $key => $value) { + if (is_array($value)) { + $output[$key] = array_filter($value); + } else { + $output[$key] = $value; + } + } + return $output; +} + + + + +function array_update($base, $new) +{ + foreach ($base as $key => $value) { + if (array_key_exists($key, $new)) { + if (gettype($base[$key]) == gettype($new[$key])) { + $base[$key] = $new[$key]; + } + } + } + return $base; +} + +function contains($needle, $haystack) +{ + return strpos($haystack, $needle) !== false; +} + + +function str_clean(string $string) +{ + return str_replace(' ', '_', strtolower(strip_tags($string))); +} + +function sumparser($text) +{ + preg_match_all('#(.+)#iU', $text, $out); + + + $sum = []; + foreach ($out[2] as $key => $value) { + $sum[$value][$out[1][$key]] = $out[3][$key]; + } + + + $sumstring = ''; + $last = 0; + foreach ($sum as $title => $list) { + foreach ($list as $h => $link) { + if($h > $last) { + for ($i = 1; $i <= ($h - $last); $i++) { + $sumstring .= '
      '; + } + $sumstring .= '
    • '.$link.'
    • ' ; + } elseif ($h < $last) { + for ($i = 1; $i <= ($last - $h); $i++) { + $sumstring .= '
    '; + } + $sumstring .= '
  • '.$link.'
  • ' ; + } elseif ($h = $last) { + $sumstring .= '
  • '.$link.'
  • ' ; + } + $last = $h; + } + } + for ($i = 1; $i <= ($last); $i++) { + $sumstring .= ''; + } + return $sumstring; +} + + +?> \ No newline at end of file diff --git a/w/w.router.php b/w/w.router.php new file mode 100644 index 0000000..e1c7b62 --- /dev/null +++ b/w/w.router.php @@ -0,0 +1,359 @@ +readconfig(); +if (!$config) { + $message = 'config_file_error'; + echo $message; + if (isset($_POST['config']) && $_POST['config'] == 'create') { + $config = $app->createconfig($_POST); + $app->savejson($config->tojson()); + header('Location: ./'); + + } else { + $aff->configform(); + } + exit; +} + + +// _________________________________________________________ S E S ___________________________________________________________ + + +if (!isset($_SESSION['level'])) { + $session = 0; +} else { + $session = $_SESSION['level']; +} + +$app->setsession($session); + + + + +// _______________________________________________________ A C T I O N __________________________________________________________________ + + +if (isset($_POST['action'])) { + switch ($_POST['action']) { + + case 'login': + $_SESSION['level'] = $app->login($_POST['pass'], $config); + if (isset($_GET['id'])) { + header('Location: ?id=' . $_GET['id']); + } else { + header('Location: ./'); + } + break; + + case 'logout': + $_SESSION['level'] = $app->logout(); + if (isset($_GET['id'])) { + header('Location: ?id=' . $_GET['id']); + } else { + header('Location: ./'); + } + break; + + case 'addmedia': + $message = $app->addmedia($_FILES, 2 ** 24, $_POST['id']); + header('Location: ./?aff=media&message=' . $message); + break; + + + + case 'editcss': + file_put_contents($app::GLOBAL_CSS_DIR, $_POST['editcss']); + header('Location: ./?aff=admin'); + break; + + case 'editconfig': + $config->hydrate($_POST); + $app->savejson($config->tojson()); + header('Location: ./?aff=admin'); + break; + + + } +} + + + +// _____________________________________________________ D A T A B A S E __________________________________________________________________ + +if (isset($_POST['action'])) { + $app->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); + $art->updatelien(); + $art->autotaglistcalc($app->taglist($app->getlister(['id', 'titre', 'tag']), $art->autotaglist())); + $app->update($art); + if($config->fontsize() != $_POST['fontsize']) { + $config->setfontsize($_POST['fontsize']); + $app->savejson($config->tojson()); + } + header('Location: ?id=' . $art->id() . '&edit=1&message='.$art->id().'_saved'); + } + break; + + case 'display': + if ($app->exist($_GET['id'])) { + $art = new Art($_POST); + $art->updatelien(); + $art->autotaglistcalc($app->taglist($app->getlister(['id', 'titre', 'tag']), $art->autotaglist())); + $app->update($art); + if($config->fontsize() != $_POST['fontsize']) { + $config->setfontsize($_POST['fontsize']); + $app->savejson($config->tojson()); + } + header('Location: ?id=' . $art->id().'&message='.$art->id().'_saved'); + } + break; + + case 'home': + if ($app->exist($_GET['id'])) { + $art = new Art($_POST); + $art->updatelien(); + $art->autotaglistcalc($app->taglist($app->getlister(['id', 'titre', 'tag']), $art->autotaglist())); + $app->update($art); + if($config->fontsize() != $_POST['fontsize']) { + $config->setfontsize($_POST['fontsize']); + $app->savejson($config->tojson()); + } + header('Location: ./?message='.$art->id().'_saved'); + } + break; + + case 'copy': + if ($app->exist($_GET['id'])) { + $copy = $app->get($_POST['copy']); + $art = $app->get($_POST['id']); + if (!empty($_POST['css'])) { + $art->setcss($copy->css()); + } + if (!empty($_POST['color'])) { + $art->setcouleurtext($copy->couleurtext()); + $art->setcouleurbkg($copy->couleurbkg()); + $art->setcouleurlien($copy->couleurlien()); + $art->setcouleurlienblank($copy->couleurlienblank()); + } + if (!empty($_POST['html'])) { + $art->sethtml($copy->md()); + } + if (!empty($_POST['template'])) { + $art->settemplate($copy->template()); + } + $app->update($art); + header('Location: ?id=' . $art->id() . '&edit=1'); + } + break; + + case 'delete': + if ($app->exist($_GET['id'])) { + $art = new Art($_POST); + $app->delete($art); + header('Location: ?id=' . $art->id()); + } + break; + + case 'massedit': + if (isset($_POST['id'])) { + foreach ($_POST['id'] as $id) { + if ($app->exist($id)) { + $art = $app->get($id); + + switch ($_POST['massaction']) { + case 'do': + switch ($_POST['massedit']) { + case 'delete': + $app->delete($art); + break; + + case 'erasetag': + $art->settag(''); + $app->update($art); + break; + + case 'erasetemplate': + $art->settemplate(''); + $app->update($art); + break; + + case 'not published': + $art->setsecure(2); + $app->update($art); + break; + + case 'private': + $art->setsecure(1); + $app->update($art); + break; + + case 'public': + $art->setsecure(0); + $app->update($art); + break; + } + break; + + case 'set template': + if (isset($_POST['masstemplate'])) { + $art->settemplate($_POST['masstemplate']); + $app->update($art); + } + break; + + case 'add tag': + if (isset($_POST['targettag'])) { + $art = $app->get($id); + $tagstring = strip_tags(trim(strtolower($_POST['targettag']))); + $taglist = str_replace(' ', '', $tagstring); + $taglist = explode(",", $taglist); + foreach ($taglist as $tag) { + if (!in_array($tag, $art->tag('array'))) { + $newtaglist = $art->tag('array'); + array_push($newtaglist, $tag); + $art->settag($newtaglist); + } + } + $app->update($art); + } + break; + + } + + + + + } + header('Location: ./'); + } + break; + } + } +} + + + + + +if (isset($_POST['actiondb'])) { + $app->setbdd($config); + + switch ($_POST['actiondb']) { + + case 'addtable': + if (isset($_POST['tablename'])) { + $message = $app->addtable($config->dbname(), $_POST['tablename']); + header('Location: ./?aff=admin&message=' . $message); + } + break; + + case 'duplicatetable': + $message = $app->tableduplicate($config->dbname(), $_POST['arttable'], $_POST['tablename']); + header('Location: ./?aff=admin&message=' . $message); + break; + + } +} + + + + +// _______________________________________________________ H E A D _____________________________________________________________ + +if (isset($_GET['id'])) { + $app->bddinit($config); + if ($app->exist($_GET['id'])) { + $art = $app->get($_GET['id']); + if (!isset($_GET['edit'])) { + $_GET['edit'] = 0; + } + $aff->arthead($art, $app::GLOBAL_CSS_DIR, $_GET['edit']); + } else { + // $aff->head($_GET['id'], '', 'white'); + $aff->noarthead($_GET['id'], $app::GLOBAL_CSS_DIR); + + } +} elseif (isset($_GET['aff'])) { + $aff->head($_GET['aff'], $_GET['aff'], $config->color4()); +} else { + $aff->head('home', 'home', $config->color4()); +} + + + + + + + +// _____________________________________________________ A L E R T _______________________________________________________________ + +if (isset($_GET['message'])) { + echo '' . $_GET['message'] . ''; +} + + + + + + + + +// ______________________________________________________ B O D Y _______________________________________________________________ + + +$aff->nav($app); + +if (array_key_exists('id', $_GET)) { + $app->bddinit($config); + include(__DIR__.'/controller/w.article.php'); +} elseif (array_key_exists('tag', $_GET)) { + $app->bddinit($config); + echo '

    ' . $_GET['tag'] . '

    '; + $aff->tag($app->getlister(['id', 'titre', 'intro', 'tag']), $_GET['tag'], $app); +} elseif (array_key_exists('lien', $_GET)) { + $app->bddinit($config); + echo '

    ' . $_GET['lien'] . '

    '; + $aff->lien($app->getlister(['id', 'titre', 'intro', 'lien']), $_GET['lien'], $app); +} elseif (array_key_exists('aff', $_GET)) { + include(__DIR__.'/controller/w.menu.php'); +} else { + include(__DIR__.'/controller/w.home.php'); +} + + + +?> \ No newline at end of file -- cgit v1.2.3