Website Summary Files Commits Branches @commit @diff @stats
path: root / views / archive / index.php
blob: c1ad329ff52b38d26cd618b7fdcb87cac21803d9 (plain) (blame)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
    $exists = null;
    $page = null;
    $user = null;
    $archives = null;

    try {
        list($exists, $url) = doesWebsiteExist($url);
        normalizeUrl($url);

        $page = Database\Webpage::fromDB($url);
        $archives = $page->allArchives();
        $user = Database\Cookie::fromDB($TOKEN);
    }
    catch(Exception $e) {
    }
?>

<?php if ($page !== null): ?>
    <h1 id="page-header"><?= $page->URL ?></h1>

    <p id="page-info">
        Viewed <b><?= $page->totalViewCount() ?></b> times
        across <b><?= count($archives) ?></b> archives,
        created between
        <b><?php echo explode(' ', end($archives)->Date, 2)[0]; reset($archives); ?></b>
        and
        <b><?= explode(' ', current($archives)->Date, 2)[0] ?></b>
    </p>

    <section id="page-buttons">
        <span class="flex-expand"></span>
        <form action="/archive/create" method="POST">
            <input type="hidden" name="url" value="<?= $url ?>">
            <input type="submit" value="Archive Now!" class="standalone-button">
        </form>
        <form action="/list/add" method="GET">
            <input type="hidden" name="wid" value="<?= current($archives)->WID ?>">
            <input type="submit" value="Add to a list!" class="standalone-button">
        </form>
        <span class="flex-expand"></span>
    </section>

    <iframe src="<?= "/archives/{$page->WID}/index.php" ?>" scrolling="no" sandbox></iframe>

    <h2>Archives by date:</h2>
    <?php
        foreach ($archives as $page) {
            include __DIR__ . '/item.php';
        }
        include_once __DIR__ . '/item_show.php';
    ?>

<?php elseif(!$exists): ?>
    <h2>"<?= $url ?>" Does not exist!</h2>
    <p>Submit another request or check the spelling of the site and try again</p>
    <a href="/">Go back!</a>


<?php else: ?>
    <h2>"<?= $url ?>" hasn't been archived yet!</h2>
    <form action="/archive/create" method="POST">
        <input type="hidden" name="url" value="<?= $url ?>">
        <input type="submit" value="Archive Now!">
    </form>

<?php endif; ?>