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

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

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

noplanman's avatar
noplanman committed
18
$lastfile     = 'db/last.data';
19
$detailedview = isset($_GET['detailedview']);
noplanman's avatar
noplanman committed
20
$mapview      = isset($_GET['mapview']);
David Morley's avatar
David Morley committed
21
$statsview    = isset($_GET['statsview']);
noplanman's avatar
noplanman committed
22 23
$podmin       = isset($_GET['podmin']);
$podminedit   = isset($_GET['podminedit']);
dmorley's avatar
dmorley committed
24
$edit         = isset($_GET['edit']);
dmorley's avatar
dmorley committed
25
$simpleview   = !($detailedview || $mapview || $podmin || $podminedit || $statsview);
noplanman's avatar
noplanman committed
26
?>
27
<!doctype html>
David Morley's avatar
David Morley committed
28
<html lang="en">
29 30
<head>
  <meta charset="utf-8">
31 32
  <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"/>
33 34
  <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">
David Morley's avatar
David Morley committed
35
  <link rel="stylesheet" href="css/poduptime.css"/>
36 37
  <link rel="stylesheet" href="bower_components/facebox/src/facebox.css"/>
  <link rel="stylesheet" href="bower_components/jquery-ui/themes/base/jquery-ui.min.css"/>
David Morley's avatar
David Morley committed
38
  <link rel="stylesheet" href="bower_components/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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

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

      <?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>
111
        <hr>
noplanman's avatar
noplanman committed
112 113 114 115 116
      <?php endforeach; ?>

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