Pokaż plik<?php
    //$type = $_GET['type'];
    $type = substr($_GET['path'], strrpos($_GET['path'], '.')+1) == 'txt' ? 'plaintext' : substr($_GET['path'], strrpos($_GET['path'], '.')+1);
    $file = file_get_contents($_SERVER['DOCUMENT_ROOT'] . $_GET['path']);
    if (strpos(mime_content_type($_SERVER['DOCUMENT_ROOT'] . $_GET['path']), 'text') === false) {
        echo '<script>location.replace("'.$_GET['path'].'")</script>
        <a style="font-size:5em;color:currentColor;" href="'.$_GET['path'].'">Pokaż plik</a>';
    } else {
        echo '<meta name="theme-color" content="#1e1e1e">
        <link rel="stylesheet" href="https://www.piotrsokolowski.tk/cdn/highlightjs/css/vscode-default.css">
        <link href="https://fonts.googleapis.com/css?family=Fira+Code&display=swap" rel="stylesheet">
        <script src="https://www.piotrsokolowski.tk/cdn/highlightjs/js/highlight.min.js"></script>
        <script>hljs.initHighlightingOnLoad();</script>
        <style>
            html,body {margin:0;padding:10px;background:#1E1E1E;}
            code {overflow:unset!important;white-space:pre-wrap;}
        </style>
        <pre><code><a style="font-size:1em;color:white;" href="'.$_GET['path'].'">Pokaż plik</a></code><code class="'.$type.'">'.rtrim(preg_replace('/\t/', '    ', htmlspecialchars($file))).'</code></pre>';
    }
?>