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

use RedBeanPHP\R;
4
use Carbon\Carbon;
noplanman's avatar
noplanman committed
5 6 7 8 9 10 11 12 13

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
14
R::usePartialBeans(true);
noplanman's avatar
noplanman committed
15 16 17 18

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

noplanman's avatar
noplanman committed
19
$lastfile     = 'db/last.data';
20
$detailedview = isset($_GET['detailedview']);
noplanman's avatar
noplanman committed
21
$mapview      = isset($_GET['mapview']);
David Morley's avatar
David Morley committed
22
$statsview    = isset($_GET['statsview']);
noplanman's avatar
noplanman committed
23 24
$podmin       = isset($_GET['podmin']);
$podminedit   = isset($_GET['podminedit']);
dmorley's avatar
dmorley committed
25
$edit         = isset($_GET['edit']);
dmorley's avatar
dmorley committed
26
$simpleview   = !($detailedview || $mapview || $podmin || $podminedit || $statsview);
noplanman's avatar
noplanman committed
27
?>
28
<!doctype html>
David Morley's avatar
David Morley committed
29
<html lang="en">
30 31
<head>
  <meta charset="utf-8">
32 33
  <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"/>
34
  <meta name="description" content="Diaspora Pod Live Status. Find a Diaspora pod to sign up for, rate pods, find one close to you!"/>
dmorley's avatar
dmorley committed
35
  <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
David Morley's avatar
David Morley committed
36
  <link rel="stylesheet" href="css/poduptime.css"/>
37
  <link rel="stylesheet" href="bower_components/facebox/src/facebox.css"/>
dmorley's avatar
dmorley committed
38
  <link rel="stylesheet" href="node_modules/tablesorter/dist/css/theme.bootstrap_4.min.css"/>
dmorley's avatar
dmorley committed
39
  <meta property="og:url" content="https://<?php echo $_SERVER['HTTP_HOST'] ?>"/>
40
  <meta property="og:title" content="Social Network Pod Finder"/>
41 42 43 44
  <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
45
</head>
David Morley's avatar
index  
David Morley committed
46
<body>
noplanman's avatar
noplanman committed
47 48 49 50 51 52 53

<?php
$navs = [
  'views'  => [
    ['text' => 'Simple View', 'href' => '/', 'active' => $simpleview],
    ['text' => 'Detailed View', 'href' => '/?detailedview', 'active' => $detailedview],
    ['text' => 'Map View', 'href' => '/?mapview', 'active' => $mapview],
54
    ['text' => 'Network Stats View', 'href' => '/?statsview', 'active' => $statsview],
noplanman's avatar
noplanman committed
55 56 57 58 59 60 61 62
    ['text' => 'Add a pod', 'href' => '/?podmin', 'active' => $podmin],
    ['text' => 'Edit a pod', 'href' => '/?podminedit', 'active' => $podminedit],
  ],
  'links'  => [
    ['text' => 'Github', 'href' => 'https://github.com/diasporg/Poduptime', 'active' => false],
    ['text' => 'Contact', 'href' => 'https://dia.so/support', 'active' => false],
    ['text' => 'Wiki', 'href' => 'https://github.com/diasporg/Poduptime/wiki', 'active' => false],
    ['text' => 'API', 'href' => 'https://github.com/diasporg/Poduptime/wiki/API', 'active' => false],
63
    ['text' => 'How to host a pod', 'href' => 'https://diasporafoundation.org/', 'active' => false],
noplanman's avatar
noplanman committed
64 65 66
  ],
];
?>
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

<nav class="navbar navbar-inverse bg-primary fixed-top">
  <button class="navbar-toggler navbar-toggler-right hidden-md-up" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="/">Poduptime</a>
  <div class="collapse navbar-toggleable hidden-md-up" id="navbar">
    <ul class="navbar-nav">
      <?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>' : ''
        );
      }
      ?>
    </ul>
  </div>
</nav>
<div class="container-fluid">
  <div class="row">
    <div class="sidebar col-md-3 col-lg-1 hidden-sm-down">

      <?php foreach ($navs as $nav) : ?>
        <ul class="nav nav-pills flex-column">
          <?php
          /** @var array $nav */
          /** @var array $nav_item */
          foreach ($nav 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>' : ''
            );
          }
          ?>
        </ul>
        <hr>
      <?php endforeach; ?>

      <p>
        <small>Data refreshed: <br><?php echo Carbon::createFromTimestamp(filemtime($lastfile))->diffForHumans(); ?></small>
      </p>
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
<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>
                  <?php
                  foreach ($navs['links'] as $nav_item) {
                    printf(
                      '<a href="%2$s">%3$s%4$s</a> | ',
                      $nav_item['active'] ? ' active' : '',
                      $nav_item['href'],
                      $nav_item['text'],
                      $nav_item['active'] ? ' <span class="sr-only">(current)</span>' : ''
                    );
                  }
                  ?>
                </div>
                <div class="col-sm-4 offset-md-1 py-4">
                    <h4 class="text-white">Views</h4>
                    <ul class="navbar-nav">
                      <?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>' : ''
                        );
                      }
                      ?>
                    </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>
162
    </div>
163 164 165 166
</header>
<main role="main">
    <div class="main">
      <a href="go.php" class="btn btn-sm btn-success">Confused? Auto pick a pod for you.</a>
167 168
      <div class="row placeholders">
      </div>
David Morley's avatar
David Morley committed
169
        <?php
170
        if ($detailedview) {
noplanman's avatar
noplanman committed
171
          include_once __DIR__ . '/showfull.php';
David Morley's avatar
David Morley committed
172
        } elseif ($mapview) {
noplanman's avatar
noplanman committed
173
          include_once __DIR__ . '/showmap.php';
David Morley's avatar
David Morley committed
174 175
        } elseif ($statsview) {
          include_once __DIR__ . '/statsview.php';
David Morley's avatar
David Morley committed
176
        } elseif ($podmin) {
noplanman's avatar
noplanman committed
177
          include_once __DIR__ . '/podmin.php';
David Morley's avatar
David Morley committed
178
        } elseif ($podminedit) {
noplanman's avatar
noplanman committed
179
          include_once __DIR__ . '/podminedit.php';
dmorley's avatar
dmorley committed
180 181
        } elseif ($edit) {
          include_once __DIR__ . '/db/edit.php';
dmorley's avatar
dmorley committed
182
        } else {
noplanman's avatar
noplanman committed
183
          include_once __DIR__ . '/show.php';
David Morley's avatar
David Morley committed
184 185
        }
        ?>
186
    </div>
187 188
  </div>
</div>
189 190 191 192 193
</main>
<br>
<footer class="bd-footer text-muted">
    <p>Data refreshed: <?php echo date('M d Y H:i', filemtime($lastfile)); ?> EST </p>
</footer>
dmorley's avatar
dmorley committed
194 195 196 197
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/tablesorter/dist/js/jquery.tablesorter.combined.min.js"></script>
<script src="js/podup.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
David Morley's avatar
David Morley committed
198
<script src="bower_components/facebox/src/facebox.js"></script>
dmorley's avatar
dmorley committed
199
<script src="node_modules/chart.js/dist/Chart.min.js"></script>
David Morley's avatar
David Morley committed
200
<?php $statsview && include_once __DIR__ . '/statsviewjs.php'; ?>
David Morley's avatar
index  
David Morley committed
201 202
</body>
</html>