index.php 6.16 KB
Newer Older
1
<?php
noplanman's avatar
noplanman committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

use RedBeanPHP\R;

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');

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

17
$lastfile     = 'db/last.data';
18
$detailedview = isset($_GET['detailedview']);
19 20
$mapview      = isset($_GET['mapview']);
$cleanup      = isset($_GET['cleanup']);
David Morley's avatar
David Morley committed
21
$statsview    = isset($_GET['statsview']);
22 23
$podmin       = isset($_GET['podmin']);
$podminedit   = isset($_GET['podminedit']);
24
$simpleview   = !($detailedview || $mapview || $cleanup || $podmin || $podminedit || $statsview);
25
?>
26
<!doctype html>
David Morley's avatar
David Morley committed
27
<html lang="en">
28 29
<head>
  <meta charset="utf-8">
30 31
  <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"/>
32 33
  <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="bower_components/bootstrap/dist/css/bootstrap.min.css">
34
  <link rel="stylesheet" href="css/poduptime.css"/>
35 36
  <link rel="stylesheet" href="bower_components/facebox/src/facebox.css"/>
  <link rel="stylesheet" href="bower_components/jquery-ui/themes/base/jquery-ui.min.css"/>
37
  <link rel="stylesheet" href="bower_components/tablesorter/dist/css/theme.bootstrap_4.min.css"/>
dmorley's avatar
dmorley committed
38
  <meta property="og:url" content="https://<?php echo $_SERVER['HTTP_HOST'] ?>"/>
39
  <meta property="og:title" content="Social Network Pod Finder"/>
40 41 42 43
  <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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

<?php
$navs = [
  'views'  => [
    ['text' => 'Simple View', 'href' => '/', 'active' => $simpleview],
    ['text' => 'Detailed View', 'href' => '/?detailedview', 'active' => $detailedview],
    ['text' => 'Map View', 'href' => '/?mapview', 'active' => $mapview],
    ['text' => 'Network Stats', 'href' => '/?statsview', 'active' => $statsview],
  ],
  'podmin' => [
    ['text' => 'Add a pod', 'href' => '/?podmin', 'active' => $podmin],
    ['text' => 'Edit a pod', 'href' => '/?podminedit', 'active' => $podminedit],
    ['text' => 'Host a pod', 'href' => 'https://diasporafoundation.org/', 'active' => false],
  ],
  '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],
  ],
];
?>

noplanman's avatar
noplanman committed
69 70 71 72
<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>
noplanman's avatar
noplanman committed
73
  <a class="navbar-brand" href="/">Poduptime</a>
noplanman's avatar
noplanman committed
74
  <div class="collapse navbar-toggleable hidden-md-up" id="navbar">
noplanman's avatar
noplanman committed
75
    <ul class="navbar-nav">
76 77 78 79 80 81 82 83 84 85 86
      <?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>' : ''
        );
      }
      ?>
noplanman's avatar
noplanman committed
87
    </ul>
88 89 90 91
  </div>
</nav>
<div class="container-fluid">
  <div class="row">
noplanman's avatar
noplanman committed
92
    <div class="sidebar col-md-3 col-lg-2 hidden-sm-down">
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

      <?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>
110
        <hr>
111 112 113 114 115
      <?php endforeach; ?>

      <p>
        <small>Data refreshed: <br><?php echo date('M d y H:i', filemtime($lastfile)); ?> EST</small>
      </p>
116
    </div>
noplanman's avatar
noplanman committed
117
    <div class="main col-md-9 col-lg-10 offset-md-3 offset-lg-2">
118
      <a href="go.php" class="btn btn-sm btn-success">Confused? Auto pick a pod for you.</a>
119 120
      <div class="row placeholders">
      </div>
David Morley's avatar
David Morley committed
121
        <?php
122
        if ($detailedview) {
123
          include_once __DIR__ . '/showfull.php';
David Morley's avatar
David Morley committed
124
        } elseif ($mapview) {
125
          include_once __DIR__ . '/showmap.php';
David Morley's avatar
David Morley committed
126 127
        } elseif ($statsview) {
          include_once __DIR__ . '/statsview.php';
David Morley's avatar
David Morley committed
128
        } elseif ($podmin) {
129
          include_once __DIR__ . '/podmin.php';
David Morley's avatar
David Morley committed
130
        } elseif ($podminedit) {
131
          include_once __DIR__ . '/podminedit.php';
132
        } elseif ($cleanup) {
133
          include_once __DIR__ . '/cleanup.php';
dmorley's avatar
dmorley committed
134
        } else {
135
          include_once __DIR__ . '/show.php';
David Morley's avatar
David Morley committed
136 137
        }
        ?>
138
    </div>
139 140
  </div>
</div>
David Morley's avatar
David Morley committed
141
<script src="bower_components/jquery/dist/jquery.min.js"></script>
David Morley's avatar
David Morley committed
142 143
<script src="bower_components/tablesorter/dist/js/jquery.tablesorter.min.js"></script>
<script src="js/podup.js"></script>
David Morley's avatar
David Morley committed
144 145
<script src="bower_components/tether/dist/js/tether.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
David Morley's avatar
David Morley committed
146
<script src="bower_components/facebox/src/facebox.js"></script>
David Morley's avatar
David Morley committed
147
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
David Morley's avatar
David Morley committed
148 149
<script src="bower_components/chart.js/dist/Chart.min.js"></script>
<?php $statsview && include_once __DIR__ . '/statsviewjs.php'; ?>
David Morley's avatar
David Morley committed
150 151
</body>
</html>