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

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

declare(strict_types=1);

9
use Carbon\Carbon;
10
use RedBeanPHP\R;
noplanman's avatar
noplanman committed
11 12 13 14 15 16 17 18 19

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/config.php';

define('PODUPTIME', microtime(true));

// Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection');
dmorley's avatar
dmorley committed
20
R::usePartialBeans(true);
noplanman's avatar
noplanman committed
21 22 23 24

// CloudFlare country code pull.
$country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';

25
$lastfile     = 'db/last.data';
26
$detailedview = isset($_GET['detailedview']);
27
$mapview      = isset($_GET['mapview']);
David Morley's avatar
David Morley committed
28
$statsview    = isset($_GET['statsview']);
29 30
$podmin       = isset($_GET['podmin']);
$podminedit   = isset($_GET['podminedit']);
dmorley's avatar
dmorley committed
31
$edit         = isset($_GET['edit']);
dmorley's avatar
dmorley committed
32 33
$add          = isset($_GET['add']);
$gettoken     = isset($_GET['gettoken']);
dmorley's avatar
dmorley committed
34
$simpleview   = !($detailedview || $mapview || $podmin || $podminedit || $statsview);
35
?>
36
<!doctype html>
David Morley's avatar
David Morley committed
37
<html lang="en">
38
<head>
39 40 41 42 43 44
    <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
45
    <link rel="stylesheet" href="node_modules/featherlight/release/featherlight.min.css"/>
46 47 48 49 50 51 52
    <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
53
</head>
David Morley's avatar
David Morley committed
54
<body>
55 56 57

<?php
$navs = [
58 59 60 61 62 63 64 65 66
    'views' => [
        ['text' => 'Simple View', 'href' => '/', 'active' => $simpleview],
        ['text' => 'Detailed View', 'href' => '/?detailedview', 'active' => $detailedview],
        ['text' => 'Map View', 'href' => '/?mapview', 'active' => $mapview],
        ['text' => 'Network Stats View', 'href' => '/?statsview', 'active' => $statsview],
        ['text' => 'Add a pod', 'href' => '/?podmin', 'active' => $podmin],
        ['text' => 'Edit a pod', 'href' => '/?podminedit', 'active' => $podminedit],
    ],
    'links' => [
dmorley's avatar
dmorley committed
67
        ['text' => 'Git', 'href' => 'https://git.feneas.org/diasporg/Poduptime', 'active' => false],
68
        ['text' => 'Contact', 'href' => 'https://dia.so/support', 'active' => false],
dmorley's avatar
dmorley committed
69 70
        ['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
71
        ['text' => 'How to host a pod', 'href' => 'https://fediverse.party/', 'active' => false],
72
    ],
73 74
];
?>
75

76 77 78 79 80 81 82
<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
83
                    <ul class="navbar-nav">
84 85 86
                    <?php
                    foreach ($navs['links'] as $nav_item) {
                        printf(
dmorley's avatar
dmorley committed
87
                            '<li class="nav-item"><a href="%1$s">%2$s%3$s</a></li>',
88 89 90 91 92 93
                            $nav_item['href'],
                            $nav_item['text'],
                            $nav_item['active'] ? ' <span class="sr-only">(current)</span>' : ''
                        );
                    }
                    ?>
dmorley's avatar
dmorley committed
94
                    </ul>
95 96 97 98
                </div>
                <div class="col-sm-4 offset-md-1 py-4">
                    <h4 class="text-white">Views</h4>
                    <ul class="navbar-nav">
99 100 101 102 103 104 105 106 107 108 109
                        <?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>' : ''
                            );
                        }
                        ?>
110 111 112 113 114 115 116 117 118 119 120 121 122 123
                    </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>
124
    </div>
125 126 127
</header>
<main role="main">
    <div class="main">
dmorley's avatar
dmorley committed
128 129
        <a href="go.php" class="m-1 btn btn-sm btn-info">Confused? Auto pick a pod for you.</a>
        <div class="row">
130
        </div>
David Morley's avatar
David Morley committed
131
        <?php
132
        if ($detailedview) {
133
            include_once __DIR__ . '/showfull.php';
David Morley's avatar
David Morley committed
134
        } elseif ($mapview) {
135
            include_once __DIR__ . '/showmap.php';
David Morley's avatar
David Morley committed
136
        } elseif ($statsview) {
137
            include_once __DIR__ . '/statsview.php';
David Morley's avatar
David Morley committed
138
        } elseif ($podmin) {
139
            include_once __DIR__ . '/podmin.php';
David Morley's avatar
David Morley committed
140
        } elseif ($podminedit) {
141
            include_once __DIR__ . '/podminedit.php';
dmorley's avatar
dmorley committed
142
        } elseif ($edit) {
143
            include_once __DIR__ . '/db/edit.php';
dmorley's avatar
dmorley committed
144 145 146 147
        } elseif ($add) {
            include_once __DIR__ . '/db/add.php';
        } elseif ($gettoken) {
            include_once __DIR__ . '/db/gettoken.php';
dmorley's avatar
dmorley committed
148
        } else {
149
            include_once __DIR__ . '/show.php';
David Morley's avatar
David Morley committed
150 151
        }
        ?>
152
    </div>
153
</main>
dmorley's avatar
dmorley committed
154
<footer class="m-2 p-2 text-muted">
dmorley's avatar
dmorley committed
155
    <small>Data refreshed <?php echo Carbon::createFromTimestamp(filemtime($lastfile))->diffForHumans(); ?></small>
156
</footer>
dmorley's avatar
dmorley committed
157 158
<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
159 160
<script src="node_modules/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
dmorley's avatar
dmorley committed
161 162
<script src="node_modules/popper.js/dist/popper.js"></script>
<script src="node_modules/featherlight/release/featherlight.min.js"></script>
dmorley's avatar
dmorley committed
163
<script src="node_modules/chart.js/dist/Chart.min.js"></script>
David Morley's avatar
David Morley committed
164
<?php $statsview && include_once __DIR__ . '/statsviewjs.php'; ?>
165
<script src="js/podup.js"></script>
David Morley's avatar
David Morley committed
166 167
</body>
</html>