diff --git a/hosts/localhost/content/apropos.md b/hosts/localhost/content/about.md similarity index 100% rename from hosts/localhost/content/apropos.md rename to hosts/localhost/content/about.md diff --git a/hosts/localhost/content/usage.md b/hosts/localhost/content/usage.md index 3e1641b..419444e 100644 --- a/hosts/localhost/content/usage.md +++ b/hosts/localhost/content/usage.md @@ -43,6 +43,7 @@ define('LOG_FILE', 'log.txt'); define('ACCESS_IP', ''); define('HISTORY_FILE', 'history.txt'); define('MAX_HISTORY_FILES', 5); +define('LANG', 'en'); ``` **NOTE**: diff --git a/index.php b/index.php index b064527..1d05ba6 100644 --- a/index.php +++ b/index.php @@ -102,7 +102,7 @@ else if (isset($_POST['action'])) case 'search': $results=searchstr(CONTENT_DIR,$_POST['search']); //print_r($results); - $content="
Il y a ".$results['totalFiles']." occurence(s) trouvée(s):
"; + $content=sprintf($LANG['FOUND'],$results['totalFiles']); foreach($results['files'] as $key => $value) $content.=''.$value.'
'; if ($_POST['type']=="js") @@ -155,7 +155,7 @@ elseThere is %s results :
", + "FOUND" : "There is(are) %d results for this search:
", "404" : "Error 404: file not found !", "404X2" : "Error 404 on searching customized 404 error file !", "CONFIG" : "Configuration", @@ -22,5 +25,11 @@ "AJAXERROR" : "Ajax error when loading data !", "SELECTERROR" : "Error when selecting item.", "NOTCODED" : "Fonction is not yet implemented.", - "BLOCKIP" : "This IP address is blocked due to unsuccessful login attempts." + "BLOCKIP" : "This IP address is blocked due to unsuccessful login attempts.", + "NOIP": "Your IP address is not allowed to access this page.", + "FORK": "Fork me on GitHub", + "CREATED": "File created.", + "SAVED": "Filed saved.", + "PROTECTED": "File is protected.", + "INDETERMINED": "Indeterminated Error." } \ No newline at end of file diff --git a/lang/fr.json b/lang/fr.json index f334692..969b7df 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -2,17 +2,20 @@ "MENU": "Menu", "HOME" : "Accueil", "GLOSSARY" : "Glossaire", - "MARKDOC" : "A propos de MarKdoc", + "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", "ABOUT" : "A propos", - "SEARCH" : "Rechercher", + "ABOUTMD" : "apropos.md", + "SEARCH" : "Chercher", "VIEW" : "Voir", + "TOC" : "TDM", "SAVE" : "Sauver", "LOGIN" : "Se connecter", "NOPASS" : "Aucun mot de passe n'a été saisi !", "ALREADYLOG" : "Vous êtes déjà connecté !", "BADPASS" : "Le mot de passe est incorrect !", - "FOUND" : "Il y a %s occurence(s) trouvée(s):
", + "FOUND" : "Il y a %d occurence(s) trouvée(s):
", "404" : "Erreur 404: fichier non trouvé !", "404X2" : "Erreur 404 sur fichier 404 personnalisé !", "CONFIG" : "Configuration", @@ -22,5 +25,11 @@ "AJAXERROR" : "Erreur ajax durant chargement !", "SELECTERROR" : "Erreur de selection.", "NOTCODED" : "La fonction n'est pas implementée.", - "BLOCKIP" : "Cette adresse IP est bloquée à cause de trop de tentatives de connexion non réussies." + "BLOCKIP" : "Cette adresse IP est bloquée à cause de trop de tentatives de connexion non réussies.", + "NOIP": "Cette adresse IP n'est pas autorisée à consulter cette page.", + "FORK": "Fork moi sur GitHub", + "CREATED": "Fichier créé.", + "SAVED": "Fichier enregistré.", + "PROTECTED": "Fichier protégé.", + "INDETERMINED": "Erreur indéterminée." } diff --git a/lib/functions.php b/lib/functions.php index 640f8dd..1f4a57d 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -11,19 +11,21 @@ function testip() { + global $LANG; if (empty(ACCESS_IP) === false && ACCESS_IP != $_SERVER['REMOTE_ADDR']) - die('Your IP address is not allowed to access this page.'); + die($LANG['NOIP']); } function logprotect() { + global $LANG; if (file_exists(LOG_DIR)) { $log = unserialize(file_get_contents(LOG_DIR)); if (empty($log)) { $log = []; } if (isset($log[$_SERVER['REMOTE_ADDR']]) && $log[$_SERVER['REMOTE_ADDR']]['num'] > 3 && time() - $log[$_SERVER['REMOTE_ADDR']]['time'] < 86400) { - die('This IP address is blocked due to unsuccessful login attempts.'); + die($LANG['BLOCKIP']); } foreach ($log as $key => $value) { if (time() - $value['time'] > 86400) { @@ -50,60 +52,35 @@ function redirect($address = null) function specialurl($url) { - switch ($url) { + global $LANG; + switch ($url) + { case ':APROPOS': - $content = '# MarkDoc - -**PHP Markdown-based documentation management system, Free & OpenSource :heart_eyes: for easily create your documentation website** - -This website is heavily formated with markdown format ! -``` - __ __ _ _____ - | \/ | | | | __ \ - | \ / | __ _ _ __| | _| | | | ___ ___ - | |\/| |/ _` | \'__| |/ / | | |/ _ \ / __| - | | | | (_| | | | <| |__| | (_) | (__ - |_| |_|\__,_|_| |_|\_\_____/ \___/ \___| -``` - -![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)* - -Based on Pheditor "PHP file editor" released under MIT license - -*Specials thanks to Hamid Samak* - -Made in 2020 by Nicolas H. - ---- - -For more informations, visit the demo website running MarkDoc engine at : [https://markdoc.palon.fr](https://markdoc.palon.fr)'; - $extra = new ParsedownExtraplus(); - print($extra->text($content)); - exit; + $content = $LANG['ABOUTMARKDOC']; + $extra = new ParsedownExtraplus(); + print($extra->text($content)); + exit; case ':ADMIN': - if (isset($_SESSION['md_admin']) === false || $_SESSION['md_admin'] !== true) - $content = ''; - else - $content = "'.$letter.'
'; + foreach($files as $file) + $content.='' ; + } return $content; - case ':GLOSSAIRE': - $content="'.$letter.'
'; - foreach($files as $file) - $content.='' ; - } - return $content; - case ':GLOSSAIRE': - - return $content; } } @@ -220,27 +197,29 @@ function history($file) function setcontent($url,$data) { + global $LANG; $file = CONTENT_DIR.$url; if (!file_exists($file)) { file_put_contents($file, $data); - $content='success|Fichier créé.'; + $content='success|'.$LANG['CREATED']; } else if (is_writable($file)) { file_put_contents($file, $data); history($file); - $content='success|Fichier enregistré.'; + $content='success|'.$LANG['SAVED']; } else if (!is_writable($file)) - $content='danger|Fichier protégé.'; + $content='danger|'.$LANG['PROTECTED']; else - $content='danger|Erreur indéterminée.'; + $content='danger|'.$LANG['INDETERMINED']; return $content; } function getcontent($url,$md=true) { + global $LANG; $file = CONTENT_DIR.$url; if (file_exists($file)) $content=file_get_contents($file); @@ -250,7 +229,7 @@ function getcontent($url,$md=true) if (file_exists(CONTENT_DIR . "special/404.md")) $content=getcontent("special/404.md"); else - $content="** Erreur 404 sur erreur 404 : pas de fichier 404.md**"; + $content='**'.$LANG['404X2'].'**'; } if ($md==true) { @@ -295,6 +274,7 @@ function filesJSON($path,$all,$first=true) function getnav() { + global $LANG; $menu=getcontent("special/nav.md"); $menuitems=explode("\n",$menu); $data=""; @@ -304,6 +284,6 @@ function getnav() $a = new SimpleXMLElement($item); $data.=''.$a[0].''; } - $data.='Sur MarkDoc...'; + $data.=''.$LANG['MARKDOC'].''; return $data; }