<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/styles/default.min.css">
<link rel="stylesheet" href="/adg/style/css/gruvbox-dark.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>


<div style="margin-top: 20px;margin-left: 20px;margin-right: 20px;">
<?php
    $res = check_log_file();
    if (!$res['error']) {
        echo $res['message'];
    }

    $list = scandir(ROOT . '/logs');
    $list_file = [];
    foreach ($list as $file) {
        if (strripos($file, '.txt')) {
            $list_file[] = $file;
        }
    }

    //скачивание файла

    foreach ($list_file as $file) {
        echo '<div>';
            echo '<a href="/adg.php?page=show_logs&file=' . escape($file) . '" style="color:black">';
                echo escape($file);
            echo '</a>';
        echo '</div>';
    }

    $file_show = ROOT . '/logs/';

    if (isset($_GET['file'])) {
        $file_show .= get('file');
    } else {
        $file_show .= 'log.txt';
    }

    if (file_exists($file_show)) {
?>
    <pre>
        <code><?php echo file_get_contents($file_show); ?></code>
    </pre>
<?php } else { ?>
    Файл логов не найден
<?php } ?>
</div>
