aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--README.md11
-rw-r--r--class/class.w.aff.php194
-rw-r--r--class/class.w.app.php93
-rw-r--r--class/class.w.art.php28
-rw-r--r--class/class.w.media.php51
-rw-r--r--class/class.w.opt.php49
-rw-r--r--config.sample.json0
-rw-r--r--fn/fn.php66
-rw-r--r--public/css/style.css0
-rw-r--r--public/css/styleadmin.css68
-rw-r--r--public/css/stylebase.css7
-rw-r--r--public/css/stylehome.css55
-rw-r--r--public/css/styleinfo.css80
-rw-r--r--public/css/stylemedia.css99
-rw-r--r--public/w/home.php19
-rw-r--r--public/w/index.php87
-rw-r--r--public/w/menu.php17
18 files changed, 678 insertions, 248 deletions
diff --git a/.gitignore b/.gitignore
index 74c3183..115d1b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,4 @@ config.json
error_log
public/media/*
public/ACRRecordings/*
-public/css/lecture/*
+public/css/read/*
diff --git a/README.md b/README.md
index 8aab688..1a58eca 100644
--- a/README.md
+++ b/README.md
@@ -17,8 +17,15 @@ The project is ispired by the *web publishing function* in *google docs* that cr
There is 3 levels of privacy :
0. public
-1. resctricted by reader code (read only)
-2. non published : admin only
+1. reader : resctricted by reader code (read only)
+2. non published : editor and admin only
+
+And 4 levels of users :
+
+1. Reader
+2. Invite
+3. Editor
+4. Administrator
[Webpage of the project (in french)](http://vincent.club1.fr/w/?id=w)
diff --git a/class/class.w.aff.php b/class/class.w.aff.php
index 198f61e..d47ca7a 100644
--- a/class/class.w.aff.php
+++ b/class/class.w.aff.php
@@ -79,7 +79,7 @@ class Aff
color: <?= $art->couleurlien() ?>;
}
- section a[target="_blank"] {
+ section a.external {
color: <?= $art->couleurlienblank() ?>;
}
<?= $art->csstemplate($app) ?>
@@ -161,8 +161,10 @@ class Aff
<input type="hidden" name="id" value="<?= $art->id() ?>">
</form>
<div id="submit">
+ <a href="./">β†–</a>
<input type="submit" name="action" value="update" accesskey="s" onclick="document.getElementById('artedit').submit();" form="artedit">
<input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Delete this article', 'artedit')" form="artedit">
+ <a href="?id=<?= $art->id() ?>" target="_blank">πŸ‘</a>
</div>
@@ -221,7 +223,7 @@ public function head($title, $tool)
}
-public function arthead(Art $art, $cssread = '', $edit = 0)
+public function arthead(Art $art, $cssdir, $cssread = '', $edit = 0)
{
?>
<head>
@@ -230,7 +232,7 @@ public function arthead(Art $art, $cssread = '', $edit = 0)
<meta name="viewport" content="width=device-width" />
<link rel="shortcut icon" href="../media/logo.png" type="image/x-icon">
<link href="/css/stylebase.css" rel="stylesheet" />
- <?= $edit == 0 ? '<link href="/css/lecture/' . $cssread . '" rel="stylesheet" />' : '<link href="/css/styleedit.css" rel="stylesheet" />' ?>
+ <?= $edit == 0 ? '<link href="' . $cssdir . $cssread . '" rel="stylesheet" />' : '<link href="/css/styleedit.css" rel="stylesheet" />' ?>
<title><?= $edit == 1 ? '✏' : '' ?> <?= $art->titre() ?></title>
<script src="../rsc/js/app.js"></script>
</head>
@@ -311,30 +313,50 @@ public function header()
}
-public function home2table(App $app, $getlist)
+public function home2table(App $app, $getlist, $masslist)
{
+ echo '<div id="main">';
+ echo '<h2>Articles</h2>';
echo '<form action="./" method="post">';
?>
<div id="massedit">
+ <h3>Mass Edit</h3>
<select name="massedit" required>
+ <option value="public">set as public</option>
+ <option value="private">set as private</option>
+ <option value="not published">set as not published</option>
+ <option value="erasetag">erase all tags</option>
+ <option value="erasetemplate">erase template</option>
<option value="delete">delete</option>
- <option value="0">set as public</option>
- <option value="1">set as private</option>
- <option value="2">set as not published</option>
</select>
- <input type="submit" value="submit" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <input type="submit" name="massaction" value="do" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <input type="text" name="targettag" placeholder="add tag">
+ <input type="submit" name="massaction" value="add tag" onclick="confirmSubmit(event, 'Are you sure')" >
+
+ <select name="masstemplate">
+ <?php
+ foreach ($masslist as $art) {
+ echo '<option value="' . $art->id() . '">' . $art->id() . '</option>';
+ }
+ ?>
+ </select>
+
+ <input type="submit" name="massaction" value="set template" onclick="confirmSubmit(event, 'Are you sure')" >
+
<input type="hidden" name="action" value="massedit">
</div>
<?php
if ($app->session() >= $app::EDITOR) {
echo '<table id="home2table">';
- echo '<tr><th>x</th><th>title</th><th>tag</th><th>summary</th><th>β†˜ to</th><th>β†— from</th><th>last modification</th><th>date of creation</th><th>privacy</th><th>βš™ edit</th></tr>';
+ echo '<tr><th>x</th><th>title</th><th>tag</th><th>summary</th><th>β†˜ to</th><th>β†— from</th><th>last modification</th><th>date of creation</th><th>privacy</th><th>display</th></tr>';
foreach ($getlist as $item) {
echo '<tr>';
- echo '<td><input type="checkbox" name="id[]" value='.$item->id().'></td>';
- echo '<td><a href="?id=' . $item->id() . '">' . $item->titre() . '</a></td>';
+ echo '<td><input type="checkbox" name="id[]" value=' . $item->id() . '></td>';
+ echo '<td><a href="?id=' . $item->id() . '&edit=1">' . $item->titre() . '</a></td>';
echo '<td>' . $item->tag('sort') . '</td>';
echo '<td>' . $item->intro() . '</td>';
echo '<td><a href="?lien=' . $item->id() . '">' . $item->liento('sort') . '</a></td>';
@@ -342,19 +364,21 @@ public function home2table(App $app, $getlist)
echo '<td>' . $item->datemodif('hrdi') . '</td>';
echo '<td>' . $item->datecreation('hrdi') . '</td>';
echo '<td>' . $item->secure('string') . '</td>';
- echo '<td><a href="?id=' . $item->id() . '&edit=1">edit</a></td>';
+ echo '<td><a href="?id=' . $item->id() . '" target="_blank">πŸ‘</a></td>';
echo '</tr>';
}
echo ' </table> ';
echo ' </form> ';
+ echo '</div>';
}
}
public function option(App $app, Opt $opt)
{
if ($app->session() >= $app::EDITOR) {
- echo '<div id="options"><form action="./" method="get" >';
-
+ echo '<div id="options">';
+ echo '<h2>Options</h2>';
+ echo '<form action="./" method="get" >';
echo '<input type="submit" name="submit" value="filter">';
echo 'β¬…<input type="submit" name="submit" value="reset">';
@@ -363,7 +387,12 @@ public function option(App $app, Opt $opt)
$this->optionprivacy($opt);
$this->optiontag($opt);
-
+ if ($opt->invert() == 1) {
+ echo '<input type="checkbox" name="invert" value="1" id="invert" checked>';
+ } else {
+ echo '<input type="checkbox" name="invert" value="1" id="invert">';
+ }
+ echo '<label for="invert">invert</></br>';
echo '<input type="submit" name="submit" value="filter">';
@@ -389,11 +418,11 @@ public function optiontag(Opt $opt)
foreach ($opt->taglist() as $tagfilter => $count) {
if ($count > $limit && $in == false) {
- echo '<details open><summary>>'.$limit.'</summary>';
+ echo '<details open><summary>>' . $limit . '</summary>';
$in = true;
}
if ($count == $limit && $in == true && $out == false) {
- echo '</details><details><summary>'.$limit.'</summary>';
+ echo '</details><details><summary>' . $limit . '</summary>';
$out = true;
}
@@ -404,7 +433,7 @@ public function optiontag(Opt $opt)
echo '<li><input type="checkbox" name="tagfilter[]" id="' . $tagfilter . '" value="' . $tagfilter . '" /><label for="' . $tagfilter . '">' . $tagfilter . ' (' . $count . ')</label></li>';
}
}
- if($in = true || $out = true) {
+ if ($in = true || $out = true) {
echo '</details>';
}
echo '</ul></fieldset>';
@@ -551,51 +580,49 @@ public function nav($app)
}
}
- public function medialist(App $app, $dir = "../media/")
+ public function medialist(array $getlistermedia, $dir)
{
- echo '<details open>';
- echo '<summary>Media List</summary>';
-
- echo '<article class="gest">';
-
- echo '<form action="" method="post">';
-
- echo '<ul class="grid">';
-
- foreach ($app->getlistermedia($dir) as $item) {
- echo '<li class="little">';
- ?>
- <input type="checkbox" id="<?= $item->id() ?>" name="<?= $item->id() ?>" value="1">
- <label for="<?= $item->id() ?>"><?= $item->id() ?></label>
- <input type="hidden" name="id" value="<?= $item->id() ?>">
-
- <?php
-
- $filepath = $dir . DIRECTORY_SEPARATOR . $item->id() . '.' . $item->extension();
-
- echo '<label for="' . $item->id() . '"><img class="thumbnail" src="' . $filepath . '" alt="' . $item->id() . '"></label>';
+ ?>
+ <details open>
+ <summary>Media List</summary>
- echo '<span class="infobulle">';
- echo 'width = ' . $item->width() . ' px';
- echo '<br/>';
- echo 'height = ' . $item->height() . ' px';
- echo '<br/>';
- echo 'filesize = ' . readablesize($item->size());
- echo '<br/>';
+ <form action="" method="post">
- echo '<input type="text" value="![' . $item->id() . '](/' . $item->id() . '.' . $item->extension() . ')">';
- echo '<br/>';
+ <table id=mediatable>
+ <tr><th>x</th><th>Name</th><th>extension</th><th>width</th><th>height</th><th>size</th><th>code</th><th>thumbnail</th></tr>
+ <?php
- echo '<a href="' . $filepath . '" target="_blank" ><img src="' . $filepath . '" alt="' . $item->id() . '"></a>';
- echo '</span>';
+ foreach ($getlistermedia as $item) {
+ $filepath = $dir . $item->id() . '.' . $item->extension();
+ echo '<tr>';
+ echo '<td><input type="checkbox" name="id[]" value=' . $item->id() . ' id="' . $item->id() . '"></td>';
+ echo '<td><label for="' . $item->id() . '">' . $item->id() . '</label></td>';
+ echo '<td>' . $item->extension() . '</td>';
+ echo '<td>' . $item->width() . '</td>';
+ echo '<td>' . $item->height() . '</td>';
+ echo '<td>' . readablesize($item->size()) . '</td>';
+ if ($item->type() == 'image') {
+ echo '<td><input type="text" value="![' . $item->id() . '](/' . $item->id() . '.' . $item->extension() . ')"></td>';
+ echo '<td class="tooltip">πŸ‘<span class="infobulle"><a href="' . $filepath . '" target="_blank" ><img class="thumbnail" src="' . $filepath . '" alt="' . $item->id() . '"></a></span></td>';
+ } elseif ($item->type() == 'sound') {
+ echo '<td><input type="text" value="[' . $item->id() . '](' . $filepath . ')"></td>';
+ echo '<td><a href="' . $filepath . '" target="_blank" >β™ͺ</a></td>';
+ } else {
+ echo '<td><input type="text" value="[' . $item->id() . '](' . $filepath . ')"></td>';
+ echo '<td><a href="' . $filepath . '" target="_blank" >∞</a></td>';
+ }
+ echo '</tr>';
+ echo '';
- echo '</li>';
}
- echo '</ul>';
?>
+
+
+ </table>
+
<select name="action" id="">
<option value="">compress /2</option>
<option value="">downscale /2</option>
@@ -606,13 +633,10 @@ public function nav($app)
</form>
</div>
-
- <?php
+ </details>
- echo '</article>';
- echo '</details>';
-
+ <?php
}
@@ -704,6 +728,8 @@ public function nav($app)
<details colse>
<summary>Default CSS</summary>
+ <p>This CSS will apply to all your articles.</p>
+
<form action="?aff=admin" method="post" >
<input type="hidden" name="action" value="editconfig">
<select name="cssread" required>
@@ -730,7 +756,7 @@ public function nav($app)
echo '<details>';
echo '<summary>Edit current CSS</summary>';
echo '<form>';
- echo '<textarea style="height:400px;">' . $cssread . '</textarea>';
+ echo '<textarea id="cssarea">' . $cssread . '</textarea>';
echo '<input type="submit" value="edit">';
echo '</form>';
echo '</details>';
@@ -764,21 +790,24 @@ public function nav($app)
<details>
<summary>Database credentials</summary>
+ <p>Fill this sections with the database settings you want to connect to</p>
+
<form action="./" method="post">
<input type="hidden" name="action" value="editconfig">
- <input title="host" type="text" name="host" id="host" value="<?= $config->host() ?>" placeholder="host">
- <input title="dbname" type="text" name="dbname" id="dbname" value="<?= $config->dbname() ?>" placeholder="dbname">
- <input title="user" type="text" name="user" id="user" value="<?= $config->user() ?>" placeholder="user">
- <input title="password" type="text" name="password" id="user" value="<?= $config->password() ?>" placeholder="password">
+ <label for="host">Host</label>
+ <input title="host" type="text" name="host" id="host" value="<?= $config->host() ?>">
+ <label for="dbname">DataBase name</label>
+ <input title="dbname" type="text" name="dbname" id="dbname" value="<?= $config->dbname() ?>">
+ <label for="user">User name</label>
+ <input title="user" type="text" name="user" id="user" value="<?= $config->user() ?>">
+ <label for="password">Password</label>
+ <input title="password" type="text" name="password" id="password" value="<?= $config->password() ?>">
<input type="submit" value="edit" id="">
</form>
</details>
-
-
-
</article>
<?php
@@ -795,9 +824,12 @@ public function nav($app)
<details>
<summary>Admin</summary>
+ <p>Edit your own admin password. You can find it in the config.json file, in the root of your website folder.</p>
+
<form action="./" method="post">
<input type="hidden" name="action" value="editconfig">
- <input title="admin password" type="password" name="admin" id="admin" value="<?= $config->admin() ?>" placeholder="admin">
+ <label for="admin">Administrator password (10)</label>
+ <input title="admin password" type="password" name="admin" id="admin" value="<?= $config->admin() ?>" >
<input type="submit" value="edit" id="">
</form>
@@ -805,11 +837,16 @@ public function nav($app)
<details>
<summary>Others</summary>
+ <p>Use this section to set all the others users passwords. They cant access this page, so they cant change it by themselves.</p>
+
<form action="./" method="post">
<input type="hidden" name="action" value="editconfig">
- <input title="editor" type="text" name="editor" id="editor" value="<?= $config->editor() ?>" placeholder="editor">
- <input title="invite" type="text" name="invite" id="invite" value="<?= $config->invite() ?>" placeholder="invite">
- <input title="read" type="text" name="read" id="read" value="<?= $config->read() ?>" placeholder="read">
+ <label for="editor">Editor password (3)</label>
+ <input title="editor" type="text" name="editor" id="editor" value="<?= $config->editor() ?>">
+ <label for="invite">Invite password (2)</label>
+ <input title="invite" type="text" name="invite" id="invite" value="<?= $config->invite() ?>" >
+ <label for="read">Reader password (1)</label>
+ <input title="read" type="text" name="read" id="read" value="<?= $config->read() ?>">
<input type="submit" value="edit" id="">
</form>
@@ -823,9 +860,19 @@ public function nav($app)
}
- public function admintable(Config $config, array $arttables)
+ public function admintable(Config $config, string $status, array $arttables)
{
?>
+
+ <article>
+
+ <h2>Table</h2>
+
+
+
+ <p>Database status : <strong><?= $status ?></strong></p>
+
+
<p>Current Table : <strong><?= $config->arttable(); ?></strong></p>
<details>
<summary>Select Table</summary>
@@ -857,11 +904,14 @@ public function nav($app)
<form action="./" method="post">
<input type="hidden" name="actiondb" value="addtable">
- <input type="text" name="tablename" maxlength="30" required>
+ <input type="text" name="tablename" placeholder="table name" maxlength="30" required>
<input type="submit" value="create">
</form>
</details>
+
+ </article>
+
<?php
}
diff --git a/class/class.w.app.php b/class/class.w.app.php
index 5e1ddb0..29d3fef 100644
--- a/class/class.w.app.php
+++ b/class/class.w.app.php
@@ -7,8 +7,10 @@ class App
const CONFIG_FILE = '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config.json';
- const CSS_READ_DIR = '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR;
+ const CSS_READ_DIR = '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'read' . DIRECTORY_SEPARATOR;
const SQL_READ_DIR = '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
+ const MEDIA_DIR = '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR;
+ const MEDIA_EXTENSIONS = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac', 'pdf');
const ADMIN = 10;
@@ -207,6 +209,8 @@ class App
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);
@@ -283,15 +287,15 @@ class App
$filteredlist = [];
foreach ($artlist as $art) {
- if(empty($tagchecked)) {
+ if (empty($tagchecked)) {
$filteredlist[] = $art->id();
} else {
$inter = (array_intersect($art->tag('array'), $tagchecked));
- if($tagcompare == 'OR') {
+ if ($tagcompare == 'OR') {
if (!empty($inter)) {
$filteredlist[] = $art->id();
}
- } elseif($tagcompare == 'AND') {
+ } elseif ($tagcompare == 'AND') {
if (!array_diff($tagchecked, $art->tag('array'))) {
$filteredlist[] = $art->id();
}
@@ -430,12 +434,12 @@ class App
if (isset($file) and $file['media']['error'] == 0 and $file['media']['size'] < $maxsize) {
$infosfichier = pathinfo($file['media']['name']);
$extension_upload = $infosfichier['extension'];
- $extensions_autorisees = array('jpeg', 'jpg', 'JPG', 'png', 'gif', 'mp3', 'mp4', 'mov', 'wav', 'flac');
+ $extensions_autorisees = $this::MEDIA_EXTENSIONS;
if (in_array($extension_upload, $extensions_autorisees)) {
- if (!file_exists('..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload)) {
+ if (!file_exists($this::MEDIA_DIR . $id . '.' . $extension_upload)) {
$extension_upload = strtolower($extension_upload);
- $uploadok = move_uploaded_file($file['media']['tmp_name'], '..' . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload);
+ $uploadok = move_uploaded_file($file['media']['tmp_name'], $this::MEDIA_DIR . $id . '.' . $extension_upload);
if ($uploadok) {
$message = 'uploadok';
} else {
@@ -455,25 +459,21 @@ class App
}
- public function getmedia($entry)
+ public function getmedia($entry, $dir)
{
$fileinfo = pathinfo($entry);
$filepath = $fileinfo['dirname'] . '.' . $fileinfo['extension'];
- list($width, $height, $type, $attr) = getimagesize($filepath);
-
- echo 'filepath : ' . $filepath;
-
- $donnes = array(
+ $donnees = array(
'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']),
- 'path' => $fileinfo['dirname'],
+ 'path' => $dir,
'extension' => $fileinfo['extension']
);
- return new Art($donnees);
+ return new Media($donnees);
}
@@ -483,23 +483,33 @@ class App
$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);
+ // var_dump($entry);
- $donnees = array(
- 'id' => str_replace('.' . $fileinfo['extension'], '', $fileinfo['filename']),
- 'path' => $fileinfo['dirname'],
- 'extension' => $fileinfo['extension'],
- 'size' => $filesize,
- 'width' => $width,
- 'height' => $height
- );
+ // $fileinfo = pathinfo($entry);
+
+ // var_dump($fileinfo);
- $list[] = new Media($donnees);
+
+ // $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' => dirname($entry),
+ // 'extension' => $fileinfo['extension']
+ // );
+
+ // $media = new Media($donnees);
+
+ $media = $this->getmedia($entry, $dir);
+
+
+ $media->analyse();
+ $list[] = $media;
}
}
@@ -552,17 +562,17 @@ class App
//_________________________________________________________ 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 'ccss_change_ok';
- } else {
- return 'ccss_change_error';
- }
- }
+ // 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)
{
@@ -574,10 +584,10 @@ class App
$extension_upload = $infosfichier['extension'];
$extensions_autorisees = array('css');
if (in_array($extension_upload, $extensions_autorisees)) {
- if (!file_exists('..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload)) {
+ if (!file_exists($this::CSS_READ_DIR . $id . '.' . $extension_upload)) {
$extension_upload = strtolower($extension_upload);
- $uploadok = move_uploaded_file($file['css']['tmp_name'], '..' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'lecture' . DIRECTORY_SEPARATOR . $id . '.' . $extension_upload);
+ $uploadok = move_uploaded_file($file['css']['tmp_name'], $this::CSS_READ_DIR . $id . '.' . $extension_upload);
if ($uploadok) {
$message = 'uploadok';
} else {
@@ -594,6 +604,7 @@ class App
}
return $message;
+
}
public function dirlist($dir, $extension)
diff --git a/class/class.w.art.php b/class/class.w.art.php
index ffdb670..2238f71 100644
--- a/class/class.w.art.php
+++ b/class/class.w.art.php
@@ -56,12 +56,12 @@ class Art
$now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
$this->settitre($this->id());
- $this->setsoustitre($this->id());
- $this->setintro('resumΓ©');
- $this->settag('sans tag,');
+ $this->setsoustitre('');
+ $this->setintro('');
+ $this->settag('');
$this->setdatecreation($now);
$this->setcss('');
- $this->sethtml('contenu');
+ $this->sethtml('');
$this->setsecure(2);
$this->setcouleurtext('#000000');
$this->setcouleurbkg('#FFFFFF');
@@ -206,6 +206,7 @@ class Art
}
$html = str_replace('href="=', 'href="?id=', $html);
+ $html = str_replace('href="../media/', ' class="file" target="_blank" href="../media/', $html);
$html = str_replace('href="http', ' class="external" target="_blank" href="http', $html);
$html = str_replace('<img src="/', '<img src="../media/', $html);
$html = str_replace('<iframe', '<div class="iframe"><div class="container"><iframe class="video" ', $html);
@@ -314,14 +315,19 @@ class Art
public function settag($tag)
{
- if (strlen($tag) < self::LEN and is_string($tag)) {
- $tag = strip_tags(trim(strtolower($tag)));
- $tag = str_replace('*', '', $tag);
- $tag = str_replace(' ', '', $tag);
+ if(is_string($tag)) {
- $taglist = explode(",", $tag);
- $taglist = array_filter($taglist);
- $this->tag = $taglist;
+ 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;
}
}
diff --git a/class/class.w.media.php b/class/class.w.media.php
index e5056c9..2d27be7 100644
--- a/class/class.w.media.php
+++ b/class/class.w.media.php
@@ -9,6 +9,11 @@ class Media
private $size;
private $width;
private $height;
+ private $length;
+
+ const IMAGE = array('jpg', 'jpeg', 'gif', 'png');
+ const SOUND = array('mp3', 'flac');
+ const VIDEO = array('mp4', 'mov', 'avi');
@@ -31,6 +36,24 @@ class Media
}
+ 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 ____________________________________________________
@@ -69,6 +92,11 @@ class Media
return $this->height;
}
+ public function length()
+ {
+ return $this->length;
+ }
+
// ___________________________________________________ S E T __________________________________________________
public function setid($id)
@@ -92,6 +120,21 @@ class Media
}
}
+ 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)) {
@@ -113,6 +156,14 @@ class Media
}
}
+ public function setlength($length)
+ {
+ if ($this->type == 'sound') {
+ $this->length = $length;
+ }
+ }
+
+
diff --git a/class/class.w.opt.php b/class/class.w.opt.php
index fc71312..684cb09 100644
--- a/class/class.w.opt.php
+++ b/class/class.w.opt.php
@@ -10,6 +10,7 @@ class Opt
private $lienfrom = ['min' => '0', 'max' => '0'];
private $col = ['id'];
private $taglist = [];
+ private $invert = 0;
private $artvarlist;
@@ -40,15 +41,6 @@ class Opt
}
}
- public function dump()
- {
- var_dump($this);
- }
-
-
-
-
-
// _______________________________________________ G E T _______________________________________________
public function sortby()
@@ -95,14 +87,19 @@ class Opt
}
}
- public function artvarlist()
+ public function taglist()
{
- return $this->artvarlist;
+ return $this->taglist;
}
- public function taglist()
+ public function invert()
{
- return $this->taglist;
+ return $this->invert;
+ }
+
+ public function artvarlist()
+ {
+ return $this->artvarlist;
}
@@ -126,19 +123,13 @@ class Opt
public function settagfilter($tagfilter)
{
if (is_array($tagfilter)) {
- // $tagfilterlist = [];
- // foreach ($tagfilter as $tag) {
- // if (array_key_exists($tag, $this->taglist())) {
- // $tagfilterlist[] = $tag;
- // }
- // }
$this->tagfilter = $tagfilter;
}
}
public function settagcompare($tagcompare)
{
- if(in_array($tagcompare, ['OR', 'AND'])) {
+ if (in_array($tagcompare, ['OR', 'AND'])) {
$this->tagcompare = $tagcompare;
}
}
@@ -187,10 +178,6 @@ class Opt
}
}
- public function setartvarlist(array $artvarlist)
- {
- $this->artvarlist = $artvarlist;
- }
public function settaglist(array $artlist)
{
@@ -208,6 +195,20 @@ class Opt
$this->taglist = $taglist;
}
+ public function setinvert(int $invert)
+ {
+ if ($invert == 0 || $invert == 1) {
+ $this->invert = $invert;
+ }
+ }
+
+
+ public function setartvarlist(array $artvarlist)
+ {
+ $this->artvarlist = $artvarlist;
+ }
+
+
}
diff --git a/config.sample.json b/config.sample.json
deleted file mode 100644
index e69de29..0000000
--- a/config.sample.json
+++ /dev/null
diff --git a/fn/fn.php b/fn/fn.php
index 54adef6..1da28b0 100644
--- a/fn/fn.php
+++ b/fn/fn.php
@@ -85,17 +85,17 @@ function readablesize($bytes)
function hrdi(DateInterval $diff)
{
$str = "";
- if ($diff->y > 1) return $str . $diff->y . ' ans';
- if ($diff->y == 1) return $str . ' 1 an et ' . $diff->m . ' mois';
- if ($diff->m > 1) return $str . $diff->m . ' mois';
- if ($diff->m == 1) return $str . ' 1 mois et ' . $diff->d . ($diff->d > 1 ? ' jours' : ' jour');
- if ($diff->d > 1) return $str . $diff->d . ' jours';
- if ($diff->d == 1) return $str . ' 1 jour et ' . $diff->h . ($diff->h > 1 ? ' heures' : ' heure');
- if ($diff->h > 1) return $str . $diff->h . ' heures';
- if ($diff->h == 1) return $str . ' 1 heure et ' . $diff->i . ($diff->i > 1 ? ' minutes' : ' minute');
+ if ($diff->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 . ' quelques secondes';
+ return $str . ' a few secondes';
}
@@ -128,9 +128,53 @@ function array_update($base, $new)
return $base;
}
+function contains($needle, $haystack)
+{
+ return strpos($haystack, $needle) !== false;
+}
-
-
+// Retrieve JPEG width and height without downloading/reading entire image.
+function getjpegsize($img_loc) {
+ $handle = fopen($img_loc, "rb") or die("Invalid file stream.");
+ $new_block = NULL;
+ if(!feof($handle)) {
+ $new_block = fread($handle, 32);
+ $i = 0;
+ if($new_block[$i]=="\xFF" && $new_block[$i+1]=="\xD8" && $new_block[$i+2]=="\xFF" && $new_block[$i+3]=="\xE0") {
+ $i += 4;
+ if($new_block[$i+2]=="\x4A" && $new_block[$i+3]=="\x46" && $new_block[$i+4]=="\x49" && $new_block[$i+5]=="\x46" && $new_block[$i+6]=="\x00") {
+ // Read block size and skip ahead to begin cycling through blocks in search of SOF marker
+ $block_size = unpack("H*", $new_block[$i] . $new_block[$i+1]);
+ $block_size = hexdec($block_size[1]);
+ while(!feof($handle)) {
+ $i += $block_size;
+ $new_block .= fread($handle, $block_size);
+ if($new_block[$i]=="\xFF") {
+ // New block detected, check for SOF marker
+ $sof_marker = array("\xC0", "\xC1", "\xC2", "\xC3", "\xC5", "\xC6", "\xC7", "\xC8", "\xC9", "\xCA", "\xCB", "\xCD", "\xCE", "\xCF");
+ if(in_array($new_block[$i+1], $sof_marker)) {
+ // SOF marker detected. Width and height information is contained in bytes 4-7 after this byte.
+ $size_data = $new_block[$i+2] . $new_block[$i+3] . $new_block[$i+4] . $new_block[$i+5] . $new_block[$i+6] . $new_block[$i+7] . $new_block[$i+8];
+ $unpacked = unpack("H*", $size_data);
+ $unpacked = $unpacked[1];
+ $height = hexdec($unpacked[6] . $unpacked[7] . $unpacked[8] . $unpacked[9]);
+ $width = hexdec($unpacked[10] . $unpacked[11] . $unpacked[12] . $unpacked[13]);
+ return array($width, $height);
+ } else {
+ // Skip block marker and read block size
+ $i += 2;
+ $block_size = unpack("H*", $new_block[$i] . $new_block[$i+1]);
+ $block_size = hexdec($block_size[1]);
+ }
+ } else {
+ return FALSE;
+ }
+ }
+ }
+ }
+ }
+ return FALSE;
+}
diff --git a/public/css/style.css b/public/css/style.css
deleted file mode 100644
index e69de29..0000000
--- a/public/css/style.css
+++ /dev/null
diff --git a/public/css/styleadmin.css b/public/css/styleadmin.css
index aacca33..a3fcc5c 100644
--- a/public/css/styleadmin.css
+++ b/public/css/styleadmin.css
@@ -1,3 +1,71 @@
+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 {
diff --git a/public/css/stylebase.css b/public/css/stylebase.css
index 581994d..c733e79 100644
--- a/public/css/stylebase.css
+++ b/public/css/stylebase.css
@@ -1,13 +1,14 @@
:root {
--color1: lightgrey;
--color2: lightslategrey;
- --color3: white;
+ --color3: #ececec;
--color4: grey;
}
body {
margin: 0;
font-family: monospace;
+ background-color: var(--color4);
}
@@ -26,7 +27,7 @@ nav {
right: 0;
z-index: 10;
background-color: var(--color1);
- border: ridge 1px grey;
+ border: ridge;
}
div#menu {
@@ -42,7 +43,7 @@ nav a {
}
nav a:hover {
- background-color: var(--color2);
+ background-color: var(--color3);
}
nav #loginpass {
diff --git a/public/css/stylehome.css b/public/css/stylehome.css
index beaae93..aa8daf2 100644
--- a/public/css/stylehome.css
+++ b/public/css/stylehome.css
@@ -1,39 +1,51 @@
-div#options {
- background-color: var(--color1);
+section.home {
+ margin-top: 27px;
+ display: inline-flex;
+ width: 100%;
}
-#home2table {
+div#main {
+ border: ridge;
+ height: fit-content;
+ margin: 5px;
background-color: var(--color3);
}
-header {
- background-color: var(--color1);
-}
+div#options {
+ border: ridge;
+ margin: 5px;
+ background-color: var(--color3);
+ width: 15%;
+ list-style: none;
+ max-width: 200px;
+}
+fieldset {
+ background-color: var(--color1);
+ border: outset;
+}
+legend {
+ font-weight: bold;
+}
-section.home {
- margin-top: 20px;
- display: inline-flex;
- width: 100%;
+div#massedit {
+ background-color: var(--color1);
}
header {
position: fixed;
width: 100%;
- border: ridge 1px grey;
+ border: ridge;
+ background-color: var(--color1);
}
-
-div#options {
- width: 15%;
- list-style: none;
-}
-
-
-#home2table {
- width: 85%;
+h2 {
+ font-size: large;
+ margin: 0;
+ border: outset;
+ background-color: var(--color1);
}
#options ul {
@@ -42,6 +54,9 @@ div#options {
padding: 0;
}
+#home2table {
+ background-color: var(--color3);
+}
#home2table tr:hover {
background-color: var(--color1);
diff --git a/public/css/styleinfo.css b/public/css/styleinfo.css
new file mode 100644
index 0000000..a3fcc5c
--- /dev/null
+++ b/public/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/css/stylemedia.css b/public/css/stylemedia.css
index a2f9800..d721a9b 100644
--- a/public/css/stylemedia.css
+++ b/public/css/stylemedia.css
@@ -1,61 +1,84 @@
-section {
- padding: 0;
+article {
+ border: 1px var(--color4) solid;
+ margin: 2px;
+ padding: 2px;
+ border: ridge;
+ max-width: 700px;
+ background-color: var(--color3);
}
-.infobulle {
- display: none;
+h1 {
+ border: ridge;
+ background-color: var(--color1);
}
-.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;
+h2 {
+ margin-top: 0;
+ margin-bottom: 5px;
}
-span.infobulle img {
- width: 100%;
+
+form {
+ display: inline-grid;
+ width: 98%;
+ margin: 1%;
}
-.grid {
- display: flex;
- flex-wrap: wrap;
- padding: 4%;
- margin-right: 120px;
- list-style: none;
+label {
+ font-weight: bold;
+ font-style: italic;
}
-.little {
- width: 100px;
- height: 150px;
- margin: 10px;
- background-color: white;
+summary {
+ background-color: var(--color1);
+ border: outset;
+ font-weight: bold;
+}
+summary:focus {
+ outline: none;
}
-.infobulle input[type="text"] {
- font-family: monospace;
- font-size: 0.9em;
- margin: 3px;
+details {
+ background-color: var(--color1);
+ border: 1px var(--color4) solid;
}
-img.thumbnail {
- max-width: 100%;
- max-height: 100px;
+
+#mediatable {
+ background-color: var(--color3);
+}
+
+#mediatable tr:hover {
+ background-color: var(--color1);
}
-section.gest {
- padding-bottom: 300px;
+#mediatable th {
+ background-color: var(--color1);
+ border: ridge 1px grey;
}
-input[type="file"] {
- font-size: 1.3em;
+.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"] {
diff --git a/public/w/home.php b/public/w/home.php
index 4966c62..7115918 100644
--- a/public/w/home.php
+++ b/public/w/home.php
@@ -19,7 +19,7 @@ if ($app->session() >= $app::EDITOR) {
}
if(isset($_GET['submit']) && $_GET['submit'] == 'reset') {
$opt = new Opt(Art::classvarlist());
- } else {
+ } elseif(isset($_SESSION['opt'])) {
$opt->hydrate($_SESSION['opt']);
}
@@ -37,17 +37,26 @@ if ($app->session() >= $app::EDITOR) {
$filter = array_intersect($filtertagfilter, $filtersecure);
$table2 = [];
+ $table2invert = [];
foreach ($table as $art) {
- if (in_array($art->id(), $filter)) {
- $table2[] = $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());
- $aff->home2table($app, $table2);
+ $aff->home2table($app, $table2, $app->getlister());
}
diff --git a/public/w/index.php b/public/w/index.php
index d9b9d5c..5a3fe4e 100644
--- a/public/w/index.php
+++ b/public/w/index.php
@@ -154,25 +154,84 @@ if (isset($_POST['action'])) {
case 'massedit':
if (isset($_POST['id'])) {
foreach ($_POST['id'] as $id) {
- $art = new Art(['id' => $id]);
- if ($_POST['massedit'] == 'delete' && $app->exist($id)) {
- $app->delete($art);
- }
- if ($_POST['massedit'] >= 0 && $app->exist($id)) {
+ if ($app->exist($id)) {
$art = $app->get($id);
- $art->setsecure($_POST['massedit']);
- $app->update($art);
+
+ 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;
}
- break;
-
}
-
}
+
+
+
+
if (isset($_POST['actiondb'])) {
$app->setbdd($config);
@@ -200,7 +259,7 @@ if (isset($_GET['id'])) {
if (!isset($_GET['edit'])) {
$_GET['edit'] = 0;
}
- $aff->arthead($art, $config->cssread(), $_GET['edit']);
+ $aff->arthead($art, $app::CSS_READ_DIR, $config->cssread(), $_GET['edit']);
} else {
$aff->head($_GET['id'], '');
@@ -235,15 +294,13 @@ if (isset($_GET['message'])) {
$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 '<h4>' . $_GET['tag'] . '</h4>';
- $aff->tag($app->getlister(['id', 'titre', 'intro', 'tag'], 'id'), $_GET['tag'], $app);
+ $aff->tag($app->getlister(['id', 'titre', 'intro', 'tag']), $_GET['tag'], $app);
} elseif (array_key_exists('lien', $_GET)) {
$app->bddinit($config);
echo '<h4><a href="?id=' . $_GET['lien'] . '">' . $_GET['lien'] . '</a></h4>';
diff --git a/public/w/menu.php b/public/w/menu.php
index b2495f2..58cc93e 100644
--- a/public/w/menu.php
+++ b/public/w/menu.php
@@ -11,19 +11,22 @@ if ($app->session() >= $app::EDITOR) {
$aff->adminpassword($config);
$aff->admindb($config);
if ($app->setbdd($config)) {
- //var_dump($app->tablelist($config->dbname()));
- echo '<p>database status : OK</p>';
+ $status = "OK";
+ } else {
+ $status = "Not Connected";
}
- $aff->admintable($config, $app->tablelist($config->dbname()));
+ $aff->admintable($config, $status, $app->tablelist($config->dbname()));
echo '</section>';
} elseif ($_GET['aff'] == 'media') {
echo '<h1>Media</h1>';
echo '<section>';
+ echo '<article>';
$aff->addmedia($app);
- $aff->medialist($app);
+ $aff->medialist($app->getlistermedia($app::MEDIA_DIR), $app::MEDIA_DIR);
+ echo '</article>';
echo '</section>';
} elseif ($_GET['aff'] == 'record') {
@@ -34,7 +37,11 @@ if ($app->session() >= $app::EDITOR) {
echo '</section>';
- } elseif ($_GET['aff'] == 'map') {
+ } elseif ($_GET['aff'] == 'info') {
+
+
+
+ } elseif ($_GET['aff'] == 'map' && $app->session() >= $app::INVITE) {
$app->bddinit($config);
$aff->map($app, $config->domain());
} else {