aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-05-24 19:03:42 +0200
committervincent-peugnet <v.peugnet@free.fr>2018-05-24 19:03:42 +0200
commitacc42674db6482ee6d432c4a9c174ed7dfcea063 (patch)
tree5caa9871eaa04e6756ad78a0d9797ccba3407004
parenta511593da994da9ba3fc47adcdb32fe63ac73b5e (diff)
downloadwcms-acc42674db6482ee6d432c4a9c174ed7dfcea063.tar.gz
wcms-acc42674db6482ee6d432c4a9c174ed7dfcea063.zip
W 2.2
-rw-r--r--README.md1
-rw-r--r--class/class.w.aff.php (renamed from class/class.aff.php)251
-rw-r--r--class/class.w.app.php (renamed from class/class.app.php)12
-rw-r--r--class/class.w.art.php (renamed from class/class.art.php)0
-rw-r--r--class/class.w.media.php (renamed from class/class.media.php)0
-rw-r--r--fn/fn.php2
-rw-r--r--public/css/stylebase.css6
-rw-r--r--public/css/stylemedia.css (renamed from public/css/stylem.css)19
-rw-r--r--public/index.php11
-rw-r--r--public/m/index.php160
-rw-r--r--public/w/index.php67
11 files changed, 261 insertions, 268 deletions
diff --git a/README.md b/README.md
index 0cc9b0c..8aab688 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,7 @@ There is 3 levels of privacy :
## W
+- 2.2 : all tools are now under the same folder **/W**, class are named **class.w.** to prevent name problems, edit symbol, new menu, better media display.
- 2.1 : dynamic template : you can link a article to another to use the CSS parameters of the this one.
## M
diff --git a/class/class.aff.php b/class/class.w.aff.php
index 3ae4662..888736a 100644
--- a/class/class.aff.php
+++ b/class/class.w.aff.php
@@ -160,20 +160,38 @@ public function copy(Art $art, $list)
</div>
<?php
-}
+ }
-public function head($title, $tool)
-{
+ public function head($title, $tool)
+ {
?>
- <head>
- <meta charset="utf8" />
- <meta name="viewport" content="width=device-width" />
- <link href="/css/stylebase.css" rel="stylesheet" />
- <link href="/css/style<?= $tool ?>.css" rel="stylesheet" />
- <title><?= $title ?></title>
- <script src="../rsc/js/app.js"></script>
- </head>
- <?php
+ <head>
+ <meta charset="utf8" />
+ <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" />
+ <link href="/css/style<?= $tool ?>.css" rel="stylesheet" />
+ <title><?= $title ?></title>
+ <script src="../rsc/js/app.js"></script>
+ </head>
+ <?php
+
+ }
+
+ public function arthead(Art $art, $pre = '')
+ {
+ ?>
+ <head>
+ <meta charset="utf8" />
+ <meta name="description" content="<?= $art->intro() ?>" />
+ <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" />
+ <link href="/css/stylew.css" rel="stylesheet" />
+ <title><?= $pre ?> <?= $art->titre() ?></title>
+ <script src="../rsc/js/app.js"></script>
+ </head>
+ <?php
}
@@ -328,108 +346,175 @@ public function head($title, $tool)
public function nav($app)
{
- ?>
- <nav>
- <?= $this->session() ?>
- </br>
- <a class="button" href="?">home</a>
-
- </br>
- <?php
-
- if (isset($_GET['id'])) {
- if ($this->session() == 0) {
- ?>
- <form action="./?id=<?= $_GET['id'] ?>" method="post">
- <input type="hidden" name="action" value="login">
- <input type="password" name="pass" id="pass" placeholder="password">
- <input type="submit" value="login">
- </form>
- <?php
+ echo '<nav>';
+ echo $this->session();
+ echo '</br>';
- }
- if ($this->session() >= 1) {
- ?>
- <form action="./?id=<?= $_GET['id'] ?>" method="post">
- <input type="hidden" name="action" value="logout">
- <input type="submit" value="logout">
- </form>
- <?php
-
- if ($this->session() == 2 and $app->exist($_GET['id'])) {
- ?>
- <a class="button" href="?id=<?= $_GET['id'] ?>" target="_blank">display</a>
- </br>
- <a class="button" href="?id=<?= $_GET['id'] ?>&edit=1" >edit</a>
- <?php
-
- }
+ echo '<a class="button" href="?">home</a>';
+ if ($this->session() == 0) {
+ if(isset($_GET['id'])) {
+ echo '<form action="./?id='. $_GET['id'].'" method="post">';
+ } else {
+ echo '<form action="." method="post">';
}
- } else {
- if ($this->session() == 0) {
- ?>
- <form action="?" method="post">
- <input type="hidden" name="action" value="login">
- <input type="password" name="pass" id="pass" placeholder="password">
- <input type="submit" value="login">
- </form>
- <?php
+ ?>
+ <input type="hidden" name="action" value="login">
+ <input type="password" name="pass" id="pass" placeholder="password">
+ <input type="submit" value="login">
+ </form>
+ <?php
+ }
+ if ($this->session() > 0) {
+ if(isset($_GET['id'])) {
+ echo '<form action="./?id='. $_GET['id'].'" method="post">';
+ } else {
+ echo '<form action="." method="post">';
}
- if ($this->session() >= 1) {
- ?>
- <form action="?" method="post">
- <input type="hidden" name="action" value="logout">
- <input type="submit" value="logout">
- </form>
- <?php
+ ?>
+ <input type="hidden" name="action" value="logout">
+ <input type="submit" value="logout">
+ </form>
+ <?php
+ }
+ if ($this->session() == 2 && isset($_GET['id']) && $app->exist($_GET['id'])) {
+ if (isset($_GET['edit']) && $_GET['edit'] == 1) {
+ echo '<a class="button" href="?id=' . $_GET['id'] . '" target="_blank">display</a>';
+ } else {
+ echo '<a class="button" href="?id=' . $_GET['id'] . '&edit=1" >edit</a>';
}
}
+ if ($this->session() == 2 && !isset($_GET['id'])) {
+ echo '<a class="button" href="?aff=media" >Media</a>';
+ echo '<a class="button" href="?aff=record" >Record</a>';
+ echo '<a class="button" href="?aff=admin" >Admin</a>';
+ }
+
?>
</nav>
<?php
}
+ // ____________________________________________________ M E D ________________________________________________
+
+ public function media()
+ {
+ echo '<body>';
+ echo '<section>';
+
+ $this->addmedia();
+ $this->medialist();
+
+ echo '</section>';
+ echo '</body>';
+
+ }
+
public function addmedia()
{
if ($this->session() >= 2) {
?>
- <details close>
- <summary>Add Media</summary>
- <h1>Ajouter un media</h1>
- <form action="./" method="post" enctype="multipart/form-data">
- <input type="hidden" name="action" value="addmedia">
- <input type="file" accept="*" name="media" required>
- <input type="text" name="id" id="" placeholder="nom du fichier" required>
- <input type="submit" value="envoi">
+ <details close>
+ <summary>Add Media</summary>
+ <form action="./" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="action" value="addmedia">
+ <input type="file" accept="*" name="media" required>
+ <input type="text" name="id" id="" placeholder="nom du fichier" required>
+ <input type="submit" value="envoi">
+ </form>
+ </details>
+ <?php
+
+ }
+ }
+
+ public function medialist(App $app, $dir = "../media/")
+ {
+ 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>';
+
+ 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/>';
+
+ echo '<input type="text" value="![' . $item->id() . '](/' . $item->id() . '.' . $item->extension() . ')">';
+ echo '<br/>';
+
+
+ echo '<a href="' . $filepath . '" target="_blank" ><img src="' . $filepath . '" alt="' . $item->id() . '"></a>';
+ echo '</span>';
+
+ echo '</li>';
+ }
+
+ echo '</ul>';
+
+ ?>
+ <select name="action" id="">
+ <option value="">compress /2</option>
+ <option value="">downscale /2</option>
+ <option value="">upscale *2</option>
+ </select>
+ <input type="submit" value="edit">
+ <input type="submit" value="delete">
</form>
- </details>
+ </div>
+
+
<?php
+
+ echo '</article>';
+ echo '</details>';
+
+
}
-}
+
//______________________________________________________ S E T _________________________________________________
-public function setsession($session)
-{
- if ($session <= 2 and $session >= 0) {
- $session = intval($session);
- $this->session = $session;
+ public function setsession($session)
+ {
+ if ($session <= 2 and $session >= 0) {
+ $session = intval($session);
+ $this->session = $session;
+ }
}
-}
//______________________________________________________ G E T _________________________________________________
-public function session()
-{
- return $this->session;
-}
+ public function session()
+ {
+ return $this->session;
+ }
}
diff --git a/class/class.app.php b/class/class.w.app.php
index 8ca1b1f..d668c2b 100644
--- a/class/class.app.php
+++ b/class/class.w.app.php
@@ -143,8 +143,10 @@ class App
public function addmedia(array $file, $maxsize, $id)
{
+ $message = 'runing';
$maxsize = 2 ** 40;
$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'];
@@ -155,19 +157,21 @@ class App
$extension_upload = strtolower($extension_upload);
$uploadok = move_uploaded_file($file['media']['tmp_name'], '../media/' . $id . '.' . $extension_upload);
if ($uploadok) {
- header('Location: ./?message=uploadok');
+ $message = 'uploadok';
} else {
- header('Location: ./?message=uploaderror');
+ $message = 'uploadokerror';
}
} else {
- header('Location: ./?message=filealreadyexist');
+ $message = 'filealreadyexist';
}
}
} else {
- header('Location: ./?message=filetoobig');
+ $message = 'filetoobig';
}
+
+ return $message;
}
diff --git a/class/class.art.php b/class/class.w.art.php
index 2b67611..2b67611 100644
--- a/class/class.art.php
+++ b/class/class.w.art.php
diff --git a/class/class.media.php b/class/class.w.media.php
index e5056c9..e5056c9 100644
--- a/class/class.media.php
+++ b/class/class.w.media.php
diff --git a/fn/fn.php b/fn/fn.php
index ce9bdae..6b17a3b 100644
--- a/fn/fn.php
+++ b/fn/fn.php
@@ -17,7 +17,7 @@ function session()
function secure()
{
if (!isset($_SESSION['id'])) {
- header("location: /");
+ header("location: ./");
}
}
diff --git a/public/css/stylebase.css b/public/css/stylebase.css
index 46d43f4..92ea674 100644
--- a/public/css/stylebase.css
+++ b/public/css/stylebase.css
@@ -40,17 +40,11 @@ a:hover{
text-decoration: underline;
}
-img {
- width: 90%;
- max-width: 1000px;
-}
-
form {
margin-bottom: 0px;
}
section {
- text-align: justify;
padding: 3%;
line-height: 1.2em;
}
diff --git a/public/css/stylem.css b/public/css/stylemedia.css
index 4e18678..9e46c3f 100644
--- a/public/css/stylem.css
+++ b/public/css/stylemedia.css
@@ -1,4 +1,6 @@
-
+section {
+ padding: 0;
+}
.infobulle {
display: none;
@@ -25,6 +27,7 @@ span.infobulle img {
flex-wrap: wrap;
padding: 4%;
margin-right: 120px;
+ list-style: none;
}
@@ -43,9 +46,21 @@ span.infobulle img {
}
img.thumbnail {
- width: 100%;
+ 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;
} \ No newline at end of file
diff --git a/public/index.php b/public/index.php
index 40202a3..ab7ff55 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,6 +1,11 @@
<html>
-<a href="/w/">w</a>
-<br/>
-<a href="/m/">m</a>
+<h1>Vincent Peugnet</h1>
+<a href="/w/"><h2>W</h2></a>
+
+<h2>@</h2>
+<a href="mailto:v.peugnet@free.fr">v.peugnet@free.fr</a>
+
+<h1>📐</h1>
+
</html> \ No newline at end of file
diff --git a/public/m/index.php b/public/m/index.php
deleted file mode 100644
index e29c801..0000000
--- a/public/m/index.php
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-
-// _____________________________________________________ R E Q U I R E ________________________________________________________________
-
-
-$config = require('../../config.php');
-
-
-
-require('../../fn/fn.php');
-require('../../class/class.art.php');
-require('../../class/class.media.php');
-require('../../class/class.app.php');
-require('../../class/class.aff.php');
-session();
-if (!isset($_SESSION['level'])) {
- $level = 0;
-} else {
- $level = $_SESSION['level'];
-}
-$app = new App($config);
-$aff = new Aff($level);
-
-
-
-// ______________________________________________________ H E A D _____________________________________________________________
-$titre = 'home';
-$aff->head($titre, 'm');
-
-// _____________________________________________________ A L E R T _______________________________________________________________
-
-if (isset($_GET['message'])) {
- echo '<h4>' . $_GET['message'] . '</h4>';
-}
-
-
-
-// ____________________________________________________ A C T I O N _______________________________________________________________
-
-
-if (isset($_POST['action'])) {
- switch ($_POST['action']) {
- case 'addmedia':
- $app->addmedia($_FILES, 2 ** 30, $_POST['id']);
- break;
-
- case 'login':
- $_SESSION['level'] = $app->login($_POST['pass']);
- 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;
- }
-}
-
-// ______________________________________________________ B O D Y _______________________________________________________________
-
-
-
-echo '<body>';
-$aff->nav($app);
-$aff->addmedia();
-
-
-echo '<details open>';
-echo '<summary>Media List</summary>';
-echo '<h1>Media</h1>';
-
-echo '<section class="gest">';
-
-$dir = "../media/";
-
-echo '<form action="" method="post">';
-
-echo '<div class="grid">';
-
-if ($handle = opendir($dir)) {
- 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);
-
- echo '<div class="little">';
-
-
- ?>
- <label for="<?= $entry ?>"><?= $entry ?></label>
- <input type="hidden" name="" value="">
- <input type="checkbox" id="<?= $entry ?>" name="<?= $entry ?>" value="1">
-
- <?php
-
- echo '<img class="thumbnail" src="' . $filepath . '" alt="' . $fileinfo['filename'] . '">';
-
- echo '<span class="infobulle">';
- echo 'width = ' . $width . ' px';
- echo '<br/>';
- echo 'height = ' . $height . ' px';
- echo '<br/>';
- echo 'filesize = ' . readablesize($filesize);
- echo '<br/>';
-
- echo '<input type="text" value="![' . $fileinfo['filename'] . '](/' . $entry . ')">';
- echo '<br/>';
-
-
- echo '<img src="' . $filepath . '" alt="' . $fileinfo['filename'] . '">';
- echo '</span>';
-
-
- echo '</div>';
- }
-}
-closedir($handle);
-}
-
-echo '</div>';
-
-?>
-<select name="action" id="">
- <option value="">compress /2</option>
- <option value="">downscale /2</option>
- <option value="">upscale *2</option>
-</select>
-<input type="submit" value="edit">
-<input type="submit" value="delete">
-</form>
-</div>
-
-
-<?php
-
-
-echo '</section>';
-echo '</details>';
-
-var_dump($app->getlistermedia($dir));
-
-echo '</body>';
-
-
-?>
-
-
-
diff --git a/public/w/index.php b/public/w/index.php
index 71f1728..9a40e9f 100644
--- a/public/w/index.php
+++ b/public/w/index.php
@@ -12,9 +12,10 @@ use Michelf\MarkdownExtra;
require('../../fn/fn.php');
-require('../../class/class.art.php');
-require('../../class/class.app.php');
-require('../../class/class.aff.php');
+require('../../class/class.w.art.php');
+require('../../class/class.w.app.php');
+require('../../class/class.w.aff.php');
+require('../../class/class.w.media.php');
session();
if (!isset($_SESSION['level'])) {
$level = 0;
@@ -76,7 +77,7 @@ if (isset($_POST['action'])) {
if (isset($_GET['id'])) {
header('Location: ?id=' . $_GET['id']);
} else {
- header('Location: ?');
+ header('Location: ./');
}
break;
@@ -85,10 +86,15 @@ if (isset($_POST['action'])) {
if (isset($_GET['id'])) {
header('Location: ?id=' . $_GET['id']);
} else {
- header('Location: ?');
+ header('Location: ./');
}
break;
+ case 'addmedia':
+ $message = $app->addmedia($_FILES, 2 ** 10, $_POST['id']);
+ header('Location: ./?aff=media&message='.$message);
+ break;
+
}
}
@@ -97,15 +103,39 @@ if (isset($_POST['action'])) {
// _______________________________________________________ H E A D _____________________________________________________________
-$titre = 'home';
+
if (isset($_GET['id'])) {
- $titre = $_GET['id'];
if ($app->exist($_GET['id'])) {
$art = $app->get($_GET['id']);
- $titre = $art->titre();
+ if (isset($_GET['edit']) && $_GET['edit'] == 1) {
+ $aff->arthead($art, '✏');
+ }
+ $aff->arthead($art, '');
+ } else {
+ $aff->head($_GET['id'], 'w');
+
}
+} elseif (isset($_GET['aff'])) {
+ $aff->head($_GET['aff'], $_GET['aff']);
+} else {
+ $aff->head('home', 'w');
+}
+
+
+
+
+
+
+
+// _____________________________________________________ A L E R T _______________________________________________________________
+
+if (isset($_GET['message'])) {
+ echo '<span class="alert"><h4>' . $_GET['message'] . '</h4></span>';
}
-$aff->head($titre, 'w');
+
+
+
+
@@ -155,6 +185,23 @@ if (isset($_GET['id'])) {
echo '<h4>' . $_GET['lien'] . '</h4>';
$aff->lien($app->getlister(['id', 'titre', 'intro', 'lien'], 'id'), $_GET['lien']);
+} elseif (isset($_GET['aff'])) {
+ if ($_GET['aff'] == 'admin') {
+ echo '<h1>Admin</h1>';
+ } elseif ($_GET['aff'] == 'media') {
+ echo '<section>';
+
+ $aff->addmedia();
+ $aff->medialist($app);
+
+ echo '</section>';
+
+ } elseif ($_GET['aff'] == 'record') {
+ echo '<h1>Record</h1>';
+ } else {
+ header('Location: ./');
+ }
+
} else {
if (isset($_GET['tri'])) {
$tri = strip_tags($_GET['tri']);
@@ -167,7 +214,9 @@ if (isset($_GET['id'])) {
$desc = 'ASC';
}
$aff->home2table($app->getlister(['id', 'titre', 'intro', 'lien', 'datecreation', 'datemodif'], $tri, $desc));
+
}
+
echo '</body>';