index.php 7.19 KB
Newer Older
1
<?php
noplanman's avatar
noplanman committed
2

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

declare(strict_types=1);
8

9
use Carbon\Carbon;
noplanman's avatar
noplanman committed
10

11
require_once __DIR__ . '/boot.php';
noplanman's avatar
noplanman committed
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"/>
dmorley's avatar
dmorley 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"/>
dmorley's avatar
dmorley committed
36
    <link rel="stylesheet" href="node_modules/featherlight/release/featherlight.min.css"/>
37 38 39 40 41 42 43
    <link rel="stylesheet" href="node_modules/tablesorter/dist/css/theme.bootstrap_4.min.css"/>
    <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">
dmorley's avatar
dmorley committed
44
</head>
David Morley's avatar
David Morley committed
45
<body>
46 47
<?php
$navs = [
48
    'views' => [
dmorley's avatar
dmorley committed
49 50 51 52 53
        ['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],
54 55
    ],
    'links' => [
dmorley's avatar
dmorley committed
56
        ['text' => 'Git', 'href' => 'https://git.feneas.org/diasporg/Poduptime', 'active' => false],
57
        ['text' => 'Contact', 'href' => 'https://dia.so/support', 'active' => false],
dmorley's avatar
dmorley committed
58 59
        ['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],
dmorley's avatar
dmorley committed
60
        ['text' => 'How to host a pod', 'href' => 'https://fediverse.party/', 'active' => false],
61
    ],
62 63
];
?>
64 65 66 67 68 69 70
<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>
dmorley's avatar
dmorley committed
71
                    <ul class="navbar-nav">
72 73 74 75 76 77 78 79 80 81
                        <?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>' : ''
                            );
                        }
                        ?>
dmorley's avatar
dmorley committed
82
                    </ul>
83 84 85 86
                </div>
                <div class="col-sm-4 offset-md-1 py-4">
                    <h4 class="text-white">Views</h4>
                    <ul class="navbar-nav">
87 88 89 90 91 92 93 94 95 96 97
                        <?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>' : ''
                            );
                        }
                        ?>
98 99 100 101 102 103 104 105 106 107 108 109 110 111
                    </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>
112
    </div>
113 114 115
</header>
<main role="main">
    <div class="main">
David Morley's avatar
David Morley committed
116
        <?php
dmorley's avatar
dmorley committed
117
        if ($mapview) {
118
            include_once __DIR__ . '/showmap.php';
David Morley's avatar
David Morley committed
119
        } elseif ($statsview) {
120
            include_once __DIR__ . '/statsview.php';
David Morley's avatar
David Morley committed
121
        } elseif ($podmin) {
122
            include_once __DIR__ . '/podmin.php';
David Morley's avatar
David Morley committed
123
        } elseif ($podminedit) {
124
            include_once __DIR__ . '/podminedit.php';
dmorley's avatar
dmorley committed
125
        } elseif ($edit) {
126
            include_once __DIR__ . '/db/edit.php';
dmorley's avatar
dmorley committed
127 128 129 130
        } elseif ($add) {
            include_once __DIR__ . '/db/add.php';
        } elseif ($gettoken) {
            include_once __DIR__ . '/db/gettoken.php';
dmorley's avatar
dmorley committed
131
        } else {
dmorley's avatar
dmorley committed
132
            include_once __DIR__ . '/showfull.php';
133
            $fullview = true;
David Morley's avatar
David Morley committed
134 135
        }
        ?>
136
    </div>
137
</main>
dmorley's avatar
dmorley committed
138
<footer class="ml-3 text-muted">
dmorley's avatar
dmorley committed
139
    <small>Data refreshed <?php echo Carbon::createFromTimestamp(filemtime($lastfile))->diffForHumans(); ?></small>
140
</footer>
dmorley's avatar
dmorley committed
141
<input type="hidden" name="input" value="<?php echo $input ?>"/>
dmorley's avatar
dmorley committed
142 143
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tablesorter/dist/js/jquery.tablesorter.combined.min.js"></script>
dmorley's avatar
dmorley committed
144
<script src="node_modules/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js"></script>
dmorley's avatar
dmorley committed
145
<script src="node_modules/tablesorter/dist/js/widgets/widget-columnSelector.min.js"></script>
dmorley's avatar
dmorley committed
146
<script src="node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
dmorley's avatar
dmorley committed
147
<script src="node_modules/featherlight/release/featherlight.min.js"></script>
dmorley's avatar
dmorley committed
148
<script src="node_modules/chart.js/dist/Chart.min.js"></script>
dmorley's avatar
dmorley committed
149 150 151
<script src="node_modules/ion-rangeslider/js/ion.rangeSlider.min.js"></script>
<?php
$statsview && include_once __DIR__ . '/statsviewjs.php';
152
$fullview && printf('<script src="js/podup.js"></script>');
dmorley's avatar
dmorley committed
153
?>
David Morley's avatar
David Morley committed
154 155
</body>
</html>