diff --git a/hosts/localhost/config.php b/hosts/localhost/config.php index a9159fd..a092b58 100644 --- a/hosts/localhost/config.php +++ b/hosts/localhost/config.php @@ -11,4 +11,4 @@ define('ACCESS_IP', ''); define('HISTORY_FILE', 'history'); define('MAX_HISTORY_FILES', 5); define('LANGUAGE', 'en'); - \ No newline at end of file +define('PRIVATE',false); \ No newline at end of file diff --git a/hosts/localhost/content/about.md b/hosts/localhost/content/about.md index f3d7238..f44cc6f 100644 --- a/hosts/localhost/content/about.md +++ b/hosts/localhost/content/about.md @@ -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 * diff --git a/hosts/localhost/content/features.md b/hosts/localhost/content/features.md index 5b18729..bbdf75d 100644 --- a/hosts/localhost/content/features.md +++ b/hosts/localhost/content/features.md @@ -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 diff --git a/hosts/localhost/content/usage.md b/hosts/localhost/content/usage.md index 419444e..0ba9fb3 100644 --- a/hosts/localhost/content/usage.md +++ b/hosts/localhost/content/usage.md @@ -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**: diff --git a/index.php b/index.php index 4808951..07aa690 100644 --- a/index.php +++ b/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,11 +49,11 @@ 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) + if (isset($_POST['md_password']) && empty($_POST['md_password']) === false) { if (hash('sha512', $_POST['md_password']) === PASSWORD) { @@ -71,50 +72,64 @@ else if (isset($_POST['action'])) $log[$_SERVER['REMOTE_ADDR']]['time'] = time(); file_put_contents(LOG_DIR, serialize($log)); } - } + } else - $content='
'.$value.'
'; - if ($_POST['type']=="js") - { - print($content); - exit; - } + $results=searchstr(CONTENT_DIR,$_POST['search']); + $content=sprintf($LANG['FOUND'],$results['totalFiles']); + foreach($results['files'] as $key => $value) + $content.=''.$value.'
'; + if ($_POST['type']=="js") + { + print($content); + exit; + } } } +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") { diff --git a/js/functions.js b/js/functions.js index 56ae9cf..b7254c0 100644 --- a/js/functions.js +++ b/js/functions.js @@ -17,7 +17,7 @@ $(function(){ plugins: [ "types" ], core: { - strings:{ loading: LANG['LOADING'] }, + strings:{ loading: LANG['LOADING'] }, check_callback: true, data : { type: "POST", diff --git a/js/functionsadmin.js b/js/functionsadmin.js index 5fd840c..676b2d1 100644 --- a/js/functionsadmin.js +++ b/js/functionsadmin.js @@ -56,7 +56,7 @@ $(function(){ plugins: ["contextmenu", "dnd" ], core: { - strings:{ loading: LANG['LOADING'] }, + strings:{ loading: LANG['LOADING'] }, check_callback: true, data : { type: "POST", @@ -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,23 +321,18 @@ 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", - data: { action: "realopen", file: encodeURIComponent(dest) }, - success: function(data){ - editmode(data); - editfile=dest; - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - alertBox(LANG['AJAXERROR'], 'danger'); - } - }); - } + $.ajax({ + type: "POST", + url: "/index.php", + data: { action: "realopen", file: encodeURIComponent(dest) }, + success: function(data){ + editmode(data); + editfile=dest; + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + alertBox(LANG['AJAXERROR'], 'danger'); + } + }); } function majlink(context) diff --git a/lang/en.json b/lang/en.json index 32ddffc..5196dfb 100644 --- a/lang/en.json +++ b/lang/en.json @@ -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", diff --git a/lang/fr.json b/lang/fr.json index 969b7df..c9de554 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -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", diff --git a/lib/functions.php b/lib/functions.php index ad2b3f4..4fba651 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -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("