fix: history problem, mime type errors

This commit is contained in:
administrateur 2021-03-26 13:47:57 +01:00
parent 70ce8fa367
commit 31ebbb4464
3 changed files with 18 additions and 6 deletions

View File

@ -101,8 +101,11 @@ else if (isset($_POST['action']))
if (substr($file,0,1)==":") if (substr($file,0,1)==":")
specialurl($file,true); specialurl($file,true);
else else
print(getcontent($file,true,true)); {
$md=strpos('.md',$file)>=0;
print(getcontent($file,$md,true));
exit; exit;
}
case 'realopen': case 'realopen':
$file=urldecode($_POST['file']); $file=urldecode($_POST['file']);
print(getcontent($file,false,true)); print(getcontent($file,false,true));
@ -139,8 +142,9 @@ else if ($filedetail['extension']!="" && strpos(ALLOWED_EXT, $filedetail['extens
{ {
if (file_exists(CONTENT_DIR . $file)) if (file_exists(CONTENT_DIR . $file))
{ {
if ($filedetail['extension']=="css") header("Content-type: text/css"); header('Content-type: '.mime_content_type(CONTENT_DIR . $file),true);
print file_get_contents(CONTENT_DIR . $file); print file_get_contents(CONTENT_DIR . $file, false);
exit;
} }
else else
{ {
@ -157,7 +161,7 @@ else
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title><?php echo TITLE; ?> <title><?php echo TITLE." - ".$file; ?>
</title> </title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/css/prism.css" /> <link rel="stylesheet" type="text/css" href="/css/prism.css" />
@ -169,6 +173,7 @@ else
<?php print(($_SESSION['md_admin'] == true)?'<link rel="stylesheet" href="/css/codemirror.min.css" />':''); ?> <?php print(($_SESSION['md_admin'] == true)?'<link rel="stylesheet" href="/css/codemirror.min.css" />':''); ?>
</head> </head>
<body> <body>
<div id="title" style="display: none;"><?php echo TITLE; ?></div>
<div id="head" class=""> <div id="head" class="">
<span id="forkongithub"><a href="https://github.com/dahut87/MarkDoc"><?php print($LANG['FORK']); ?></a></span> <span id="forkongithub"><a href="https://github.com/dahut87/MarkDoc"><?php print($LANG['FORK']); ?></a></span>
<nav class="navbar fixed-top navbar-expand-md <?php print(($_SESSION['md_admin'] == true)?"navbar-custom":"bg-dark navbar-dark"); ?>"> <nav class="navbar fixed-top navbar-expand-md <?php print(($_SESSION['md_admin'] == true)?"navbar-custom":"bg-dark navbar-dark"); ?>">

View File

@ -9,6 +9,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 emoji; var emoji;
var LANG; var LANG;
$(function(){ $(function(){
@ -53,12 +54,18 @@ $(function(){
e.preventDefault(); e.preventDefault();
tocshow(); tocshow();
}); });
$(window).on('popstate', function(e){
window.location.reload();
});
majlink('head'); majlink('head');
}); });
function openlink(dest,majtree) function openlink(dest,majtree)
{ {
$("#content").html('<div class="container h-100"><div class="row h-100 justify-content-center align-items-center"><div class="col-12 fa-3x container"><i class="fas fa-spinner fa-spin"></i></div></div></div>');
document.title = $("#title").text()+" - "+dest;
history.pushState({href: dest}, "", dest);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/index.php", url: "/index.php",
@ -119,7 +126,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)) if (!external.test(dest) && !javascript.test(dest) && textual.test(dest))
{ {
e.preventDefault(); e.preventDefault();
openlink(dest,true); openlink(dest,true);

View File

@ -253,7 +253,7 @@ function filesJSON($path,$all,$first=true)
$dir= new DirectoryIterator($path); $dir= new DirectoryIterator($path);
foreach($dir as $node) foreach($dir as $node)
{ {
if (($node->getFilename() =="special") || (SHOW_HIDDEN_FILES === false && substr($node->getFilename(), 0, 1) === '.') || (($node->getExtension() != VIEWABLE_FORMAT && $all==false) && $node->isFile())) continue; if (($node->getFilename() =="images") || ($node->getFilename() =="documents") || ($node->getFilename() =="special") || (SHOW_HIDDEN_FILES === false && substr($node->getFilename(), 0, 1) === '.') || (($node->getExtension() != VIEWABLE_FORMAT && $all==false) && $node->isFile())) continue;
$data = array(); $data = array();
if ( $node->isDir() && !$node->isDot() ) if ( $node->isDir() && !$node->isDot() )
{ {