From 920610490ea8c0e7ed4d8711eb5c7fc885239457 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 22 Dec 2018 04:58:54 +0100 Subject: login level session separate by basepath --- app/class/aff.php | 1018 ----------------------------------------- app/class/app4.php | 657 -------------------------- app/class/application.php | 5 + app/class/config.php | 4 +- app/class/controller.php | 3 + app/class/controllermedia.php | 17 +- app/class/modelmedia.php | 1 - app/class/modeluser.php | 43 +- app/class/w.article.php | 32 -- app/class/w.home.php | 85 ---- app/class/w.menu.php | 56 --- 11 files changed, 41 insertions(+), 1880 deletions(-) delete mode 100644 app/class/aff.php delete mode 100644 app/class/app4.php delete mode 100644 app/class/w.article.php delete mode 100644 app/class/w.home.php delete mode 100644 app/class/w.menu.php (limited to 'app/class') diff --git a/app/class/aff.php b/app/class/aff.php deleted file mode 100644 index 6f9f07e..0000000 --- a/app/class/aff.php +++ /dev/null @@ -1,1018 +0,0 @@ - -

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 !)
- -
- session() >= $app::EDITOR) { - - ?> - -
- - textarea{font-size: ' . $fontsize . '}'; - $tablist = ['section' => $art->md(), 'css' => $art->css(), 'aside' => $art->aside(), 'footer' => $art->footer()]; - - $this->tabs($tablist, 'section'); - - ?> - -
- - - - - 👁 - - id() ?> - - - -
- - - - - - -
- - - '; - foreach ($tablist as $key => $value) { - echo '
'; - if ($key == $opentab) { - echo ''; - } else { - echo ''; - } - echo ''; - echo '
'; - echo ''; - echo '
'; - echo '
'; - } - - echo ''; -} - -public function editorhelp() -{ - ?> -

Help !

-

To save your article, press the HOME, UPDATE, or DISPLAY buttons. You can use the keyboard shortcuts as well.

-
ALT + W : home
-
ALT + X : update
-
ALT + C : display
-

Markdown

-

The html section use Markdown encoding. Actualy, W is using Michel Fortin's Markdown Extra.

-

Links

-
[text](=article_id)
-

where article_id is the article's id you want to point to.

-

Images

-
[altimage](/img_id.extension)
-

Where img_id is the id of your image and its extension.

-

Shortcuts

-
%TITLE%
-

Show the title of your article.

-
%DESCRIPTION%
-

Show the description of your article.

-
%SUMMARY%
-

Generate a summary, the list of all your head titles using #, ##, ###...

-
%%tag_name%%
-

Generate a menu, a list of links to all articles under this tag.

-

vv

-

vv

-

vv

-

- - - - - - - - - <?= $title ?> - - - - - - - - - - ' : '' ?> - <?= $edit == 1 ? '✏' : '' ?> <?= $art->title() ?> - - - - - - - - - - - ❓ <?= $id ?> - - - - - '; - echo ' '; - echo ' '; -} - -public function linkfrom($getlist, $linkfrom, 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->title() . '' . $item->tag('sort') . '' . $item->description() . '' . $item->linkto('sort') . '' . $item->linkfrom('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

- -

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 -
- - - - -
-
-
- \ No newline at end of file diff --git a/app/class/app4.php b/app/class/app4.php deleted file mode 100644 index b791846..0000000 --- a/app/class/app4.php +++ /dev/null @@ -1,657 +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(Art2 $art) - { - - if ($this->exist($art->id())) { - echo 'idalreadyexist'; - } else { - - var_dump($art); - - $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('json')); - $q->bindValue(':javascript', $art->javascript()); - $q->bindValue(':html', $art->html()); - $q->bindValue(':header', $art->header()); - $q->bindValue(':section', $art->md()); - $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('json')); - $q->bindValue(':template', $art->template('json')); - $q->bindValue(':affcount', $art->affcount()); - $q->bindValue(':editcount', $art->editcount()); - - $q->execute(); - } - } - - public function delete(Art2 $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 Art2($donnees); - - $req->closeCursor(); - - } - - - - - - public function update(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'; - - $request = 'UPDATE ' . $this->arttable . ' SET id = :id, title = :title, description = :description, tag = :tag, date = :date, datecreation = :datecreation, datemodif = :datemodif, daterender = :daterender, css = :css, quickcss = :quickcss, javascript = :javascript, html = :html, header = :header, section = :section, nav = :nav, aside = :aside, footer = :footer, render = :footer, secure = :secure, invitepassword = :invitepassword, interface = :interface, linkfrom = :linkfrom, template = :template, affcount = :affcount, editcount = :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('json')); - $q->bindValue(':javascript', $art->javascript()); - $q->bindValue(':html', $art->html()); - $q->bindValue(':header', $art->header()); - $q->bindValue(':section', $art->md()); - $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('json')); - $q->bindValue(':template', $art->template('json')); - $q->bindValue(':affcount', $art->affcount()); - $q->bindValue(':editcount', $art->editcount()); - - $q->execute(); - } - - 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(*)']; - } - - - - - - //____________________________________________ 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', 'title', 'id', 'description', '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 Art2($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 Art2($donnees); - } - return $artlist; - - } - - public function listcalclinkfrom(&$artlist) - { - foreach ($artlist as $art) { - $art->calclinkto($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(); - } - - - - // __________________________________________ 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 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; - - - - } - - - - - // ________________________________________________________ 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->title() . '}'; - } elseif ($item->secure() == 1) { - $style = $style . $lb . $item->id() . '(' . $item->title() . ')'; - - } else { - $style = $style . $lb . $item->id() . '((' . $item->title() . '))'; - } - foreach ($item->linkfrom('array') as $linkfrom) { - $map = $map . $lb . $item->id() . ' --> ' . $linkfrom; - $link = $link . $lb . 'click ' . $linkfrom . ' "./?id=' . $linkfrom . '"'; - - } - $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/app/class/application.php b/app/class/application.php index 8e50c19..4926a1b 100644 --- a/app/class/application.php +++ b/app/class/application.php @@ -50,6 +50,11 @@ class Application { ?>

Configuration

+ +

Version :

+ +

+

diff --git a/app/class/config.php b/app/class/config.php index 36a5116..d6164ca 100644 --- a/app/class/config.php +++ b/app/class/config.php @@ -19,9 +19,7 @@ abstract class Config protected static $defaultart = ''; protected static $defaultfavicon = ''; protected static $showeditmenu = true; - protected static $editsymbol = 'pen'; - protected static $version = ''; - + protected static $editsymbol = 'pen'; diff --git a/app/class/controller.php b/app/class/controller.php index b0681bb..956d3b5 100644 --- a/app/class/controller.php +++ b/app/class/controller.php @@ -5,6 +5,9 @@ class Controller protected $user; protected $router; + /** + * @var Modeluser + */ protected $usermanager; protected $plates; diff --git a/app/class/controllermedia.php b/app/class/controllermedia.php index 4421f65..91f5a03 100644 --- a/app/class/controllermedia.php +++ b/app/class/controllermedia.php @@ -29,12 +29,17 @@ class Controllermedia extends Controller $dir = rtrim($_GET['path'] ?? Model::MEDIA_DIR, DIRECTORY_SEPARATOR); - $medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR); - $faviconlist = $this->mediamanager->getlistermedia(Model::FAVICON_DIR); - - $dirlist = $this->mediamanager->listdir(Model::MEDIA_DIR); + if(is_dir($dir)) { + $medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR); + $faviconlist = $this->mediamanager->getlistermedia(Model::FAVICON_DIR); + + $dirlist = $this->mediamanager->listdir(Model::MEDIA_DIR); + + $this->showtemplate('media', ['medialist' => $medialist, 'faviconlist' => $faviconlist, 'dirlist' => $dirlist, 'dir' => $dir]); + } else { + $this->routedirect('media'); + } - $this->showtemplate('media', ['medialist' => $medialist, 'faviconlist' => $faviconlist, 'dirlist' => $dirlist, 'dir' => $dir]); } else { $this->routedirect('home'); } @@ -57,7 +62,7 @@ class Controllermedia extends Controller { if ($this->user->iseditor()) { $dir = $_POST['dir'] ?? Model::MEDIA_DIR; - $name = $_POST['foldername'] ?? 'new folder'; + $name = idclean($_POST['foldername']) ?? 'new-folder'; $this->mediamanager->adddir($dir, $name); } $this->redirect($this->router->generate('media') . '?path=' . $dir . DIRECTORY_SEPARATOR . $name); diff --git a/app/class/modelmedia.php b/app/class/modelmedia.php index 6fbcece..42c826c 100644 --- a/app/class/modelmedia.php +++ b/app/class/modelmedia.php @@ -141,7 +141,6 @@ class Modelmedia extends Model public function adddir($dir, $name) { - $name = idclean($name); $newdir = $dir . DIRECTORY_SEPARATOR . $name; if(!is_dir($newdir)) { return mkdir($newdir); diff --git a/app/class/modeluser.php b/app/class/modeluser.php index 9dc2af1..a0f0966 100644 --- a/app/class/modeluser.php +++ b/app/class/modeluser.php @@ -1,66 +1,65 @@ $user->level()]; + $_SESSION['user' . Config::basepath()] = ['level' => $user->level()]; } public function readsession() { $userdatas = []; - if(array_key_exists('user', $_SESSION)) { - $userdatas = $_SESSION['user']; + if (array_key_exists('user' . Config::basepath(), $_SESSION)) { + $userdatas = $_SESSION['user' . Config::basepath()]; } $user = new User($userdatas); return $user; } - + public function login($pass) - { + { $user = new User(['level' => $this->passlevel($pass)]); return $user; } - + public function passlevel($pass) { 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 ($this->invitetest(strip_tags($pass))) { - return $level = self::INVITE; + 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 ($this->invitetest(strip_tags($pass))) { + return $level = self::INVITE; } else { - return $level = self::FREE; + return $level = self::FREE; } } public function invitetest($pass) { $invitepasslist = []; - if(in_array($pass, $invitepasslist)) { + if (in_array($pass, $invitepasslist)) { return true; } else { return false; } } - public function logout() - { + public function logout() + { $user = new User(['level' => self::FREE]); return $user; - } + } } diff --git a/app/class/w.article.php b/app/class/w.article.php deleted file mode 100644 index 6c504f8..0000000 --- a/app/class/w.article.php +++ /dev/null @@ -1,32 +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', 'title']), $config->fontsize(), $app->getlistermedia($app::MEDIA_DIR, 'image')); - $aff->aside($app); - echo '
'; - } else { - echo '
'; - - - $art->autotaglistupdate($app->taglist($app->getlister(['id', 'title', 'description', '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/app/class/w.home.php b/app/class/w.home.php deleted file mode 100644 index a23c60f..0000000 --- a/app/class/w.home.php +++ /dev/null @@ -1,85 +0,0 @@ -header(); - -echo '
'; - - -if ($app->session() >= $app::EDITOR) { - - $app->bddinit($config); - - $opt = new Opt(Art2::classvarlist()); - $opt->setcol(['id', 'tag', 'linkfrom', 'contenu', 'description', 'title', 'datemodif', 'datecreation', 'secure']); - $table = $app->getlisteropt($opt); - $app->listcalclinkfrom($table); - $opt->settaglist($table); - $opt->submit(); - - - - - - - - - - - - $opt->setcol(['id', 'tag', 'linkfrom', 'contenu', 'description', 'title', 'datemodif', 'datecreation', 'secure', 'linkto']); - - - $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/app/class/w.menu.php b/app/class/w.menu.php deleted file mode 100644 index ecce576..0000000 --- a/app/class/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 -- cgit v1.2.3