index.php 7.28 KB
Newer Older
1
<?php
2

3 4 5 6 7
/**
 * Main entry point for podupti.me.
 */

declare(strict_types=1);
8

9
use Carbon\Carbon;
10

11
require_once __DIR__ . '/boot.php';
12

13 14 15 16 17 18 19 20 21 22 23
$lastfile   = 'db/last.data';
$input      = isset($_GET['input']) ? substr($_GET['input'], 1) : null;
$mapview    = isset($_GET['mapview']) || $input === 'map';
$statsview  = isset($_GET['statsview']) || $input === 'stats';
$podmin     = isset($_GET['podmin']) || $input === 'podmin';
$podminedit = isset($_GET['podminedit']) || $input === 'podminedit';
$edit       = isset($_GET['edit']) || $input === 'edit';
$add        = isset($_GET['add']) || $input === 'add';
$gettoken   = isset($_GET['gettoken']) || $input === 'gettoken';
$simpleview = !($mapview || $podmin || $podminedit || $statsview);
$fullview   = false;
24
?>
25
<!doctype html>
David Morley's avatar
David Morley committed
26
<html lang="en">
27
<head>
28 29 30 31 32 33
    <meta charset="utf-8">
    <title>Open Source Social Network Pod Uptime Status</title>
    <meta name="keywords" content="diaspora, federated pods, <?php echo $_SERVER['HTTP_HOST'] ?>, friendica, hubzilla, open source social, open source social network"/>
    <meta name="description" content="Diaspora Pod Live Status. Find a Diaspora pod to sign up for, rate pods, find one close to you!"/>
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/poduptime.css"/>
David Morley's avatar
David Morley committed
34 35
    <link rel="stylesheet" href="node_modules/ion-rangeslider/css/ion.rangeSlider.css"/>
    <link rel="stylesheet" href="node_modules/ion-rangeslider/css/ion.rangeSlider.skinHTML5.css"/>
36
    <link rel="stylesheet" href="node_modules/featherlight/release/featherlight.min.css"/>
37
    <link rel="stylesheet" href="node_modules/tablesorter/dist/css/theme.bootstrap_4.min.css"/>
38
    <link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css"/>
39 40 41 42 43 44
    <meta property="og:url" content="https://<?php echo $_SERVER['HTTP_HOST'] ?>"/>
    <meta property="og:title" content="Social Network Pod Finder"/>
    <meta property="og:type" content="website"/>
    <meta property="og:description" content="Diaspora Pod Live Status. Find a Diaspora pod to sign up for, rate pods, find one close to you!"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=yes">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
David Morley's avatar
David Morley committed
45
</head>
David Morley's avatar
David Morley committed
46
<body>
47 48
<?php
$navs = [
49
    'views' => [
David Morley's avatar
David Morley committed
50 51 52 53 54
        ['text' => 'Table View', 'href' => '/', 'active' => $simpleview],
        ['text' => 'Map View', 'href' => '/map', 'active' => $mapview],
        ['text' => 'Network Stats View', 'href' => '/stats', 'active' => $statsview],
        ['text' => 'Add a pod', 'href' => '/podmin', 'active' => $podmin],
        ['text' => 'Edit a pod', 'href' => '/podminedit', 'active' => $podminedit],
55 56
    ],
    'links' => [
David Morley's avatar
David Morley committed
57
        ['text' => 'Git', 'href' => 'https://git.feneas.org/diasporg/Poduptime', 'active' => false],
58
        ['text' => 'Contact', 'href' => 'https://dia.so/support', 'active' => false],
David Morley's avatar
David Morley committed
59 60
        ['text' => 'Wiki', 'href' => 'https://git.feneas.org/diasporg/Poduptime/wikis/home', 'active' => false],
        ['text' => 'API', 'href' => 'https://git.feneas.org/diasporg/Poduptime/wikis/API', 'active' => false],
David Morley's avatar
David Morley committed
61
        ['text' => 'How to host a pod', 'href' => 'https://fediverse.party/', 'active' => false],
62
    ],
63 64
];
?>
65 66 67 68 69 70 71
<header>
    <div class="collapse bg-dark" id="navbarHeader">
        <div class="container">
            <div class="row">
                <div class="col-sm-8 col-md-7 py-4">
                    <h4 class="text-white">About</h4>
                    <p class="text-muted">Poduptime helps you find a diaspora, friendica, hubzilla or socialhome pod to use and join the federated social network.</p>
David Morley's avatar
David Morley committed
72
                    <ul class="navbar-nav">
73 74 75 76 77 78 79 80 81 82
                        <?php
                        foreach ($navs['links'] as $nav_item) {
                            printf(
                                '<li class="nav-item"><a href="%1$s">%2$s%3$s</a></li>',
                                $nav_item['href'],
                                $nav_item['text'],
                                $nav_item['active'] ? ' <span class="sr-only">(current)</span>' : ''
                            );
                        }
                        ?>
David Morley's avatar
David Morley committed
83
                    </ul>
84 85 86 87
                </div>
                <div class="col-sm-4 offset-md-1 py-4">
                    <h4 class="text-white">Views</h4>
                    <ul class="navbar-nav">
88 89 90 91 92 93 94 95 96 97 98
                        <?php
                        foreach ($navs['views'] as $nav_item) {
                            printf(
                                '<li class="nav-item"><a class="nav-link%1$s" href="%2$s">%3$s%4$s</a></li>',
                                $nav_item['active'] ? ' active' : '',
                                $nav_item['href'],
                                $nav_item['text'],
                                $nav_item['active'] ? ' <span class="sr-only">(current)</span>' : ''
                            );
                        }
                        ?>
99 100 101 102 103 104 105 106 107 108 109 110 111 112
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="navbar navbar-dark bg-dark box-shadow">
        <div class="container d-flex justify-content-between">
            <a href="/" class="navbar-brand d-flex align-items-center">
                <strong>Poduptime</strong>
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarHeader" aria-controls="navbarHeader" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
        </div>
113
    </div>
114 115 116
</header>
<main role="main">
    <div class="main">
David Morley's avatar
David Morley committed
117
        <?php
David Morley's avatar
David Morley committed
118
        if ($mapview) {
119
            include_once __DIR__ . '/showmap.php';
David Morley's avatar
David Morley committed
120
        } elseif ($statsview) {
121
            include_once __DIR__ . '/statsview.php';
David Morley's avatar
David Morley committed
122
        } elseif ($podmin) {
123
            include_once __DIR__ . '/podmin.php';
David Morley's avatar
David Morley committed
124
        } elseif ($podminedit) {
125
            include_once __DIR__ . '/podminedit.php';
David Morley's avatar
David Morley committed
126
        } elseif ($edit) {
127
            include_once __DIR__ . '/db/edit.php';
128 129 130 131
        } elseif ($add) {
            include_once __DIR__ . '/db/add.php';
        } elseif ($gettoken) {
            include_once __DIR__ . '/db/gettoken.php';
dmorley's avatar
dmorley committed
132
        } else {
David Morley's avatar
David Morley committed
133
            include_once __DIR__ . '/showfull.php';
134
            $fullview = true;
David Morley's avatar
David Morley committed
135 136
        }
        ?>
137
    </div>
138
</main>
David Morley's avatar
David Morley committed
139
<footer class="ml-3 text-muted">
140
    <small>Data refreshed <?php echo Carbon::createFromTimestamp(filemtime($lastfile))->diffForHumans(); ?></small>
141
</footer>
David Morley's avatar
David Morley committed
142
<input type="hidden" name="input" value="<?php echo $input ?>"/>
David Morley's avatar
David Morley committed
143 144
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tablesorter/dist/js/jquery.tablesorter.combined.min.js"></script>
David Morley's avatar
David Morley committed
145
<script src="node_modules/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js"></script>
David Morley's avatar
David Morley committed
146
<script src="node_modules/tablesorter/dist/js/widgets/widget-columnSelector.min.js"></script>
David Morley's avatar
David Morley committed
147
<script src="node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
148
<script src="node_modules/featherlight/release/featherlight.min.js"></script>
David Morley's avatar
David Morley committed
149
<script src="node_modules/chart.js/dist/Chart.min.js"></script>
David Morley's avatar
David Morley committed
150 151 152
<script src="node_modules/ion-rangeslider/js/ion.rangeSlider.min.js"></script>
<?php
$statsview && include_once __DIR__ . '/statsviewjs.php';
153
$fullview && printf('<script src="js/podup.js"></script>');
David Morley's avatar
David Morley committed
154
?>
David Morley's avatar
David Morley committed
155 156
</body>
</html>