fix: error for special URL when in subdir

This commit is contained in:
administrateur 2021-03-30 14:25:11 +02:00
parent 3cd5f7adb8
commit f33d0896ea
4 changed files with 15 additions and 14 deletions

View File

@ -1,3 +1,3 @@
[Home](/index.md) [Home](/index.md)
[Sitemap](:SITEMAP) [Sitemap](/:SITEMAP)
[Glossary](:GLOSSAIRE) [Glossary](/:GLOSSAIRE)

View File

@ -85,7 +85,7 @@ else if (isset($_POST['action']))
print('{ "id" : "id1", "icon" : "fas fa-atlas", "parent" : "#", "text" : "'.$_SERVER["SERVER_NAME"].'" }'); print('{ "id" : "id1", "icon" : "fas fa-atlas", "parent" : "#", "text" : "'.$_SERVER["SERVER_NAME"].'" }');
exit; exit;
default: default:
$content=specialurl(":ADMIN",true); $content=specialurl("/:ADMIN",true);
} }
} }
switch ($_POST['action']) switch ($_POST['action'])
@ -98,7 +98,7 @@ else if (isset($_POST['action']))
exit; exit;
case 'open': case 'open':
$file=urldecode($_POST['file']); $file=urldecode($_POST['file']);
if (substr($file,0,1)==":") if (substr($file,0,2)=="/:")
specialurl($file,true); specialurl($file,true);
else else
{ {
@ -128,9 +128,9 @@ else if (isset($_POST['action']))
} }
else if (ACCESS_PRIVATE && !isset($_SESSION['md_admin'])) else if (ACCESS_PRIVATE && !isset($_SESSION['md_admin']))
{ {
$content=specialurl(":ADMIN",false); $content=specialurl("/:ADMIN",false);
} }
else if (substr($file,0,1)==":") else if (substr($file,0,2)=="/:")
{ {
$content=specialurl($file,false); $content=specialurl($file,false);
} }
@ -195,11 +195,11 @@ else
print(($_SESSION['md_admin'] == true)?'<li class="nav-item dropdown"> print(($_SESSION['md_admin'] == true)?'<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="button">'.$LANG['ADMIN'].'</a> <a class="nav-link dropdown-toggle" href="javascript:void(0)" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="button">'.$LANG['ADMIN'].'</a>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item" href=":CONFIG">'.$LANG['CONFIG'].'</a> <a class="dropdown-item" href="/:CONFIG">'.$LANG['CONFIG'].'</a>
<a class="dropdown-item" href=":PASSWORD">'.$LANG['PASSWORD'].'</a> <a class="dropdown-item" href="/:PASSWORD">'.$LANG['PASSWORD'].'</a>
<hr> <hr>
<a class="dropdown-item" href="https://'.$_SERVER['SERVER_NAME'].'?logout">'.$LANG['LOGOUT'].'</a> <a class="dropdown-item" href="https://'.$_SERVER['SERVER_NAME'].'?logout">'.$LANG['LOGOUT'].'</a>
</div></li>':'<li class="nav-item"><a class="nav-link " href=":ADMIN">'.$LANG['ADMIN'].'</a></li>'); </div></li>':'<li class="nav-item"><a class="nav-link " href="/:ADMIN">'.$LANG['ADMIN'].'</a></li>');
?> ?>
<li class="nav-item"><a class="nav-link " href="<?php print($LANG['ABOUTMD'].'">'.$LANG['ABOUT']); ?></a></li> <li class="nav-item"><a class="nav-link " href="<?php print($LANG['ABOUTMD'].'">'.$LANG['ABOUT']); ?></a></li>
</ul> </ul>

View File

@ -10,6 +10,7 @@
var external = RegExp('^((f|ht)tps?:)?//'); var external = RegExp('^((f|ht)tps?:)?//');
var javascript = RegExp('^javascript:'); var javascript = RegExp('^javascript:');
var textual = RegExp('\.md$'); var textual = RegExp('\.md$');
var internal = RegExp('^\/:');
var emoji; var emoji;
var LANG; var LANG;
$(function(){ $(function(){
@ -126,7 +127,7 @@ function majlink(context)
{ {
$('#'+context+' a').click(function(e) { $('#'+context+' a').click(function(e) {
dest=$(this).attr('href'); dest=$(this).attr('href');
if (!external.test(dest) && !javascript.test(dest) && textual.test(dest)) if (!external.test(dest) && !javascript.test(dest) && (textual.test(dest) || internal.test(dest)))
{ {
e.preventDefault(); e.preventDefault();
openlink(dest,true); openlink(dest,true);

View File

@ -55,22 +55,22 @@ function specialurl($url,$quit)
global $LANG; global $LANG;
switch ($url) switch ($url)
{ {
case ':APROPOS': case '/:APROPOS':
$extra = new ParsedownExtraplus(); $extra = new ParsedownExtraplus();
$content=$extra->text($LANG['ABOUTMARKDOC']); $content=$extra->text($LANG['ABOUTMARKDOC']);
break; break;
case ':ADMIN': case '/:ADMIN':
if (isset($_SESSION['md_admin']) === false || $_SESSION['md_admin'] !== true) 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&hellip;" 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>'; $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&hellip;" 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 else
$content = '<h1>'.$LANG['ALREADYLOG'].'</h1>'; $content = '<h1>'.$LANG['ALREADYLOG'].'</h1>';
break; break;
case ':SITEMAP': case '/:SITEMAP':
$content='<h1>'.$LANG['SITEMAP'].'</h1>'; $content='<h1>'.$LANG['SITEMAP'].'</h1>';
foreach(plan(CONTENT_DIR) as $file) foreach(plan(CONTENT_DIR) as $file)
$content.='<p class="fileletter"><a href="'.$file.'">'.$file.'</a></p>' ; $content.='<p class="fileletter"><a href="'.$file.'">'.$file.'</a></p>' ;
break; break;
case ':GLOSSAIRE': case '/:GLOSSAIRE':
$content='<h1>'.$LANG['GLOSSARY'].'</h1>'; $content='<h1>'.$LANG['GLOSSARY'].'</h1>';
foreach(glossary(CONTENT_DIR) as $letter => $files) foreach(glossary(CONTENT_DIR) as $letter => $files)
{ {