aboutsummaryrefslogtreecommitdiff
path: root/_site/rewrites/article.php
blob: eb98798c0fc749adc5a7c89039e31bf7ac084aaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

if (!isset($_GET['i'])) {
    header("Location: /articles");
    die();
}

if (strpos($_GET['i'], "/") !== false && strpos($_GET['i'], ".") !== false && strpos($_GET['i'], "\\") !== false) {
    header("Location: /articles");
    die();
}

if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/../_posts/" . $_GET['i'] . ".md") || !is_file($_SERVER['DOCUMENT_ROOT'] . "/../_posts/" . $_GET['i'] . ".md")) {
    header("Location: /articles");
    die();
}

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/markdown.php";
$Parsedown = new Parsedown();

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/articles/getlist.php";
$list = getArticlesList();
$item = $list[$_GET['i']];

$_TITLE = $item["title"];
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/header.php";

?>

<div class="container" style="margin-top:30px;">
    <div class="card" style="margin-bottom:20px;">
        <div class="card-body">
            <h1><?= $_TITLE ?></h1>
            <p>Published on <?php

                $dt = DateTime::createFromFormat('Ymd', $item["date"]);
                echo($dt->format("M jS, Y"));

                ?>, by <?= implode(" and ", $item["author"]) ?></p>
        </div>
    </div>

    <article>
        <?= $item["content"]["full"] ?>
    </article>
</div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/dom/footer.php"; ?>