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)==":")
specialurl($file,true);
else
print(getcontent($file,true,true));
{
$md=strpos('.md',$file)>=0;
print(getcontent($file,$md,true));
exit;
}
case 'realopen':
$file=urldecode($_POST['file']);
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 ($filedetail['extension']=="css") header("Content-type: text/css");
print file_get_contents(CONTENT_DIR . $file);
header('Content-type: '.mime_content_type(CONTENT_DIR . $file),true);
print file_get_contents(CONTENT_DIR . $file, false);
exit;
}
else
{
@ -157,7 +161,7 @@ else
<!DOCTYPE html>
<html>
<head>
<title><?php echo TITLE; ?>
<title><?php echo TITLE." - ".$file; ?>
</title>
<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" />
@ -169,6 +173,7 @@ else
<?php print(($_SESSION['md_admin'] == true)?'<link rel="stylesheet" href="/css/codemirror.min.css" />':''); ?>
</head>
<body>
<div id="title" style="display: none;"><?php echo TITLE; ?></div>
<div id="head" class="">
<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"); ?>">

View File

@ -9,6 +9,7 @@
var external = RegExp('^((f|ht)tps?:)?//');
var javascript = RegExp('^javascript:');
var textual = RegExp('\.md$');
var emoji;
var LANG;
$(function(){
@ -53,12 +54,18 @@ $(function(){
e.preventDefault();
tocshow();
});
$(window).on('popstate', function(e){
window.location.reload();
});
majlink('head');
});
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({
type: "POST",
url: "/index.php",
@ -119,7 +126,7 @@ function majlink(context)
{
$('#'+context+' a').click(function(e) {
dest=$(this).attr('href');
if (!external.test(dest) && !javascript.test(dest))
if (!external.test(dest) && !javascript.test(dest) && textual.test(dest))
{
e.preventDefault();
openlink(dest,true);

View File

@ -253,7 +253,7 @@ function filesJSON($path,$all,$first=true)
$dir= new DirectoryIterator($path);
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();
if ( $node->isDir() && !$node->isDot() )
{