feat: mode privé & ajouts icon awesome
This commit is contained in:
parent
2ae134226a
commit
74fe8b0f97
|
@ -11,4 +11,4 @@ define('ACCESS_IP', '');
|
|||
define('HISTORY_FILE', 'history');
|
||||
define('MAX_HISTORY_FILES', 5);
|
||||
define('LANGUAGE', 'en');
|
||||
|
||||
define('PRIVATE',false);
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
![moi](/moi.jpg?80-left)**Hordé Nicolas**
|
||||
|
||||
> *Passionate about computer and more particularly development. I started from a young age (17 years) in system programming. I handle about thirty programming languages among which there are many low level languages: wink:! I am also the author of MarkDoc, the Markdown-based documentation management system you are currently viewing *
|
||||
> *Passionate about computer and more particularly development. I started from a young age (17 years) in system programming. I handle about thirty programming languages among which there are many low level languages :wink:! I am also the author of MarkDoc, the Markdown-based documentation management system you are currently viewing *
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
4. Restricted access by ip address
|
||||
5. Admin access logging
|
||||
6. Table of contents
|
||||
7. Password protected area
|
||||
|
||||
## Planned
|
||||
|
||||
1. Complete File Manager
|
||||
2. Password protected area
|
||||
3. Keeping the history of edited files and changes
|
||||
4. Configuration viewer
|
||||
5. Emoji menu in Markdown editor
|
||||
|
|
|
@ -14,7 +14,8 @@ Install Emoji data and copy Emoji data to the "emoji-data"
|
|||
```
|
||||
wget https://github.com/iamcal/emoji-data/archive/v6.0.0.zip
|
||||
unzip v6.0.0.zip
|
||||
mv emoji-data-v6.0.0 emoji-data
|
||||
mv emoji-data-6.0.0 emoji-data
|
||||
rm -rf v6.0.0.zip
|
||||
```
|
||||
|
||||
## Multiples hosts
|
||||
|
@ -44,6 +45,7 @@ define('ACCESS_IP', '');
|
|||
define('HISTORY_FILE', 'history.txt');
|
||||
define('MAX_HISTORY_FILES', 5);
|
||||
define('LANG', 'en');
|
||||
define('ACCESS_PRIVATE', 'en');
|
||||
```
|
||||
|
||||
**NOTE**:
|
||||
|
|
39
index.php
39
index.php
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
### Global defines
|
||||
define('PRIVATE', true);
|
||||
define('ROOT_DIR', realpath(dirname(__FILE__)) .'/');
|
||||
define('LIB_DIR', ROOT_DIR.'lib/');
|
||||
define('HOST_DIR',ROOT_DIR.'hosts/'.$_SERVER['SERVER_NAME'].'/');
|
||||
|
@ -48,9 +49,9 @@ if (isset($_GET['logout'])) {
|
|||
}
|
||||
else if (isset($_POST['action']))
|
||||
{
|
||||
switch ($_POST['action']) {
|
||||
case 'ident':
|
||||
if (isset($_SESSION['md_admin']) === false || $_SESSION['md_admin'] !== true)
|
||||
if ((isset($_SESSION['md_admin']) === false || $_SESSION['md_admin'] !== true))
|
||||
{
|
||||
if ($_POST['action']=='ident')
|
||||
{
|
||||
if (isset($_POST['md_password']) && empty($_POST['md_password']) === false)
|
||||
{
|
||||
|
@ -73,11 +74,22 @@ else if (isset($_POST['action']))
|
|||
}
|
||||
}
|
||||
else
|
||||
$content='<h1>Aucun mot de passe renseigné !</h1>';
|
||||
$content='<h1>'.$LANG['NOPASS'].'</h1>';
|
||||
|
||||
}
|
||||
else
|
||||
$content='<h1>Vous êtes déjà logué !</h1>';
|
||||
break;
|
||||
else if (ACCESS_PRIVATE)
|
||||
switch ($_POST['action'])
|
||||
{
|
||||
case 'allchildren':
|
||||
case 'children':
|
||||
print('{ "id" : "id1", "icon" : "fas fa-atlas", "parent" : "#", "text" : "'.$_SERVER["SERVER_NAME"].'" }');
|
||||
exit;
|
||||
default:
|
||||
$content=specialurl(":ADMIN",true);
|
||||
}
|
||||
}
|
||||
switch ($_POST['action'])
|
||||
{
|
||||
case 'children':
|
||||
print(json_encode(filesJSON(CONTENT_DIR,false)));
|
||||
exit;
|
||||
|
@ -87,13 +99,13 @@ else if (isset($_POST['action']))
|
|||
case 'open':
|
||||
$file=urldecode($_POST['file']);
|
||||
if (substr($file,0,1)==":")
|
||||
print(specialurl($file));
|
||||
specialurl($file,true);
|
||||
else
|
||||
print(getcontent($file));
|
||||
print(getcontent($file,true,true));
|
||||
exit;
|
||||
case 'realopen':
|
||||
$file=urldecode($_POST['file']);
|
||||
print(getcontent($file,false));
|
||||
print(getcontent($file,false,true));
|
||||
exit;
|
||||
case 'save':
|
||||
$file=urldecode($_POST['file']);
|
||||
|
@ -101,7 +113,6 @@ else if (isset($_POST['action']))
|
|||
exit;
|
||||
case 'search':
|
||||
$results=searchstr(CONTENT_DIR,$_POST['search']);
|
||||
//print_r($results);
|
||||
$content=sprintf($LANG['FOUND'],$results['totalFiles']);
|
||||
foreach($results['files'] as $key => $value)
|
||||
$content.='<p class="filefound"><a href="'.$key.'">'.$key.'</a></p><p class="textfound">'.$value.'</p>';
|
||||
|
@ -112,9 +123,13 @@ else if (isset($_POST['action']))
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (ACCESS_PRIVATE && !isset($_SESSION['md_admin']))
|
||||
{
|
||||
$content=specialurl(":ADMIN",false);
|
||||
}
|
||||
else if (substr($file,0,1)==":")
|
||||
{
|
||||
$content=specialurl($file);
|
||||
$content=specialurl($file,false);
|
||||
}
|
||||
else if ($filedetail['extension']=="md")
|
||||
{
|
||||
|
|
|
@ -172,7 +172,7 @@ $(function(){
|
|||
$("#files").on("select_node.jstree", function (e, nodes) {
|
||||
file="/"+$("#files").jstree("get_path",nodes.node,"/").replace(/^.+?[/]/, '');
|
||||
if ($("#files").jstree("is_leaf",nodes.node))
|
||||
editlink(file);
|
||||
openlink(file,false);
|
||||
else
|
||||
alertBox(LANG['NOTCODED'],'danger');
|
||||
});
|
||||
|
@ -226,6 +226,11 @@ function alertBox(message, className) {
|
|||
|
||||
function openlink(dest,majtree)
|
||||
{
|
||||
if (dest.match(/.(jpg|jpeg|png|gif|webp|svg|ico)$/i))
|
||||
{
|
||||
imagemode(dest);
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/index.php",
|
||||
|
@ -316,10 +321,6 @@ function viewmode(data)
|
|||
|
||||
function editlink(dest)
|
||||
{
|
||||
if (dest.match(/.(jpg|jpeg|png|gif|webp|svg|ico)$/i))
|
||||
imagemode(dest);
|
||||
else
|
||||
{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/index.php",
|
||||
|
@ -332,7 +333,6 @@ function editlink(dest)
|
|||
alertBox(LANG['AJAXERROR'], 'danger');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function majlink(context)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"MENU": "Menu",
|
||||
"HOME" : "Home",
|
||||
"GLOSSARY" : "Glossary",
|
||||
"SITEMAP" : "Sitemap",
|
||||
"MARKDOC" : "About MarkDoc",
|
||||
"ABOUTMARKDOC" : "# MarkDoc\r\n\r\n**PHP Markdown-based documentation management system, Free & OpenSource :heart_eyes: for easily create your documentation website**\r\n \r\nThis website is heavily formated with markdown format !\r\n```\r\n __ __ _ _____ \r\n | \\\/ | | | | __ \\ \r\n | \\ \/ | __ _ _ __| | _| | | | ___ ___ \r\n | |\\\/| |\/ _` | '__| |\/ \/ | | |\/ _ \\ \/ __|\r\n | | | | (_| | | | <| |__| | (_) | (__ \r\n |_| |_|\\__,_|_| |_|\\_\\_____\/ \\___\/ \\___|\r\n``` \r\n\r\n![gplV3](https:\/\/www.gnu.org\/graphics\/gplv3-127x51.png) Sous licence GPLv3 [Licence](\/special\/gpl-3.0.md) - *Sources downloadables on [GitHub](https:\/\/github.com\/dahut87\/MarkDoc)*\r\n \r\nBased on Pheditor \"PHP file editor\" released under MIT license\r\n \r\n *Specials thanks to Hamid Samak*\r\n \r\n Made in 2020 by Nicolas H.\r\n \r\n---\r\n \r\nFor more informations, visit the demo website running MarkDoc engine at : [https:\/\/markdoc.palon.fr](https:\/\/markdoc.palon.fr)",
|
||||
"ADMIN" : "Admin",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"MENU": "Menu",
|
||||
"HOME" : "Accueil",
|
||||
"GLOSSARY" : "Glossaire",
|
||||
"SITEMAP" : "Plan du site",
|
||||
"MARKDOC" : "A propos de MarkDoc",
|
||||
"ABOUTMARKDOC" : "# MarkDoc\r\n\r\n**Syst\u00E8me de gestion de documents Mardown \u00E9crits en PHP, Gratuit & OpenSource :heart_eyes: afin de facilement cr\u00E9er vos sites internet de documentation**\r\n \r\nCe site est lourdement format\u00E9 au format Markdown !\r\n```\r\n __ __ _ _____ \r\n | \\\/ | | | | __ \\ \r\n | \\ \/ | __ _ _ __| | _| | | | ___ ___ \r\n | |\\\/| |\/ _` | '__| |\/ \/ | | |\/ _ \\ \/ __|\r\n | | | | (_| | | | <| |__| | (_) | (__ \r\n |_| |_|\\__,_|_| |_|\\_\\_____\/ \\___\/ \\___|\r\n``` \r\n \r\n![gplV3](https:\/\/www.gnu.org\/graphics\/gplv3-127x51.png) Sous licence GPLv3 [Licence](\/special\/gpl-3.0.md) - *Sources t\u00E9l\u00E9chargeables sur [GitHub](https:\/\/github.com\/dahut87\/MarkDoc)*\r\n \r\nBas\u00E9 sur Pheditor \"PHP file editor\" sous licence MIT\r\n \r\n*Merci \u00E0 Hamid Samak*\r\n \r\nR\u00E9alis\u00E9 en 2020 par Nicolas H.\r\n \r\n---\r\n \r\nPour plus d'informations, visitez le site internet de d\u00E9monstration \u00E0 l'url suivante : [https:\/\/markdoc.palon.fr](https:\/\/markdoc.palon.fr)",
|
||||
"ADMIN" : "Admin",
|
||||
|
|
|
@ -25,7 +25,7 @@ function logprotect()
|
|||
$log = [];
|
||||
}
|
||||
if (isset($log[$_SERVER['REMOTE_ADDR']]) && $log[$_SERVER['REMOTE_ADDR']]['num'] > 3 && time() - $log[$_SERVER['REMOTE_ADDR']]['time'] < 86400) {
|
||||
die($LANG['BLOCKIP']);
|
||||
die("<h1>".$LANG['BLOCKIP']."</h1>");
|
||||
}
|
||||
foreach ($log as $key => $value) {
|
||||
if (time() - $value['time'] > 86400) {
|
||||
|
@ -50,28 +50,26 @@ function redirect($address = null)
|
|||
exit;
|
||||
}
|
||||
|
||||
function specialurl($url)
|
||||
function specialurl($url,$quit)
|
||||
{
|
||||
global $LANG;
|
||||
switch ($url)
|
||||
{
|
||||
case ':APROPOS':
|
||||
$content = $LANG['ABOUTMARKDOC'];
|
||||
$extra = new ParsedownExtraplus();
|
||||
print($extra->text($content));
|
||||
exit;
|
||||
$content=$extra->text($LANG['ABOUTMARKDOC']);
|
||||
break;
|
||||
case ':ADMIN':
|
||||
if (isset($_SESSION['md_admin']) === false || $_SESSION['md_admin'] !== true)
|
||||
$content = '<form method="post"><div style="text-align:center"><h1></h1>' . (isset($error) ? '<p style="color:#dd0000">' . $error . '</p>' : null) . '<input id="mdsimple_password" name="md_password" type="password" value="" placeholder="Password…" tabindex="1"><br><br><input type="hidden" id="action" name="action" value="ident"><input type="submit" value="'.$LANG['LOGIN'].'" tabindex="2"></div></form><script type="text/javascript">$("#md_password").focus();</script>';
|
||||
else
|
||||
$content = '<h1>'.$LANG['ALREADYLOG'].'</h1>';
|
||||
print($content);
|
||||
exit;
|
||||
break;
|
||||
case ':SITEMAP':
|
||||
$content='<h1>'.$LANG['SITEMAP'].'</h1>';
|
||||
foreach(plan(CONTENT_DIR) as $file)
|
||||
$content.='<p class="fileletter"><a href="'.$file.'">'.$file.'</a></p>' ;
|
||||
return $content;
|
||||
break;
|
||||
case ':GLOSSAIRE':
|
||||
$content='<h1>'.$LANG['GLOSSARY'].'</h1>';
|
||||
foreach(glossary(CONTENT_DIR) as $letter => $files)
|
||||
|
@ -80,8 +78,15 @@ function specialurl($url)
|
|||
foreach($files as $file)
|
||||
$content.='<p class="fileletter"><a href="'.$file.'">'.$file.'</a></p>' ;
|
||||
}
|
||||
return $content;
|
||||
break;
|
||||
}
|
||||
if ($quit)
|
||||
{
|
||||
print($content);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
return $content;
|
||||
}
|
||||
|
||||
function plan($path){
|
||||
|
@ -218,7 +223,7 @@ function setcontent($url,$data)
|
|||
return $content;
|
||||
}
|
||||
|
||||
function getcontent($url,$md=true)
|
||||
function getcontent($url,$md=true,$header=false)
|
||||
{
|
||||
global $LANG;
|
||||
$file = CONTENT_DIR.$url;
|
||||
|
@ -232,6 +237,7 @@ function getcontent($url,$md=true)
|
|||
else
|
||||
$content='**'.$LANG['404X2'].'**';
|
||||
}
|
||||
if ($header) header('Content-type: '.mime_content_type($file),true);
|
||||
if ($md==true)
|
||||
{
|
||||
$extra = new ParsedownExtraplus();
|
||||
|
@ -253,22 +259,31 @@ function filesJSON($path,$all,$first=true)
|
|||
{
|
||||
$data['text'] = $node->getFilename();
|
||||
$data['children'] = filesJSON($path.$node->getFilename()."/",$all,false);
|
||||
$data['icon'] = "far fa-folder";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($all)
|
||||
{
|
||||
$data['text'] = $node->getFilename();
|
||||
if ($node->getExtension() == VIEWABLE_FORMAT)
|
||||
$data['icon'] = "fas fa-book";
|
||||
else if (strpos(IMAGE_EXT,$node->getExtension())>=0)
|
||||
$data['icon'] = "far fa-images";
|
||||
else
|
||||
$data['icon'] = "far fa-file";
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = pathinfo($node->getFilename());
|
||||
$data['text'] = $file['filename'];
|
||||
$data['icon'] = "fas fa-book-open";
|
||||
}
|
||||
$data['icon'] = "jstree-file";
|
||||
}
|
||||
$alldata[]=$data;
|
||||
}
|
||||
if ($first)
|
||||
return array('text'=>$_SERVER['SERVER_NAME'],'children'=>$alldata,'state' => array('opened'=>true));
|
||||
return array('icon'=>"fas fa-atlas",'text'=>$_SERVER['SERVER_NAME'],'children'=>$alldata,'state' => array('opened'=>true));
|
||||
else
|
||||
return $alldata;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue