index.php 5.95 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
  <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
34
  <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
David Morley's avatar
David Morley committed
35
  <link rel="stylesheet" href="css/poduptime.css"/>
36
  <link rel="stylesheet" href="bower_components/facebox/src/facebox.css"/>
dmorley's avatar
dmorley committed
37
  <link rel="stylesheet" href="node_modules/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
index  
David Morley committed
45
<body>
noplanman's avatar
noplanman committed
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">
noplanman's avatar
noplanman committed
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">
dmorley's avatar
dmorley committed
92
    <div class="sidebar col-md-3 col-lg-1 hidden-sm-down">
noplanman's avatar
noplanman committed
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>
noplanman's avatar
noplanman committed
111 112 113
      <?php endforeach; ?>

      <p>
dmorley's avatar
dmorley committed
114
        <small>Data refreshed: <br><?php echo date('M d Y H:i', filemtime($lastfile)); ?> EST</small>
noplanman's avatar
noplanman committed
115
      </p>
116
    </div>
dmorley's avatar
dmorley committed
117
    <div class="main col-md-10 col-lg-11 offset-md-3 offset-lg-1">
118
      <a href="go.php" class="btn btn-sm btn-outline-warning">Confused on how to find a pod? Auto Pick </a>
119 120
      <div class="row placeholders">
      </div>
David Morley's avatar
David Morley committed
121
        <?php
122
        if ($detailedview) {
noplanman's avatar
noplanman committed
123
          include_once __DIR__ . '/showfull.php';
David Morley's avatar
David Morley committed
124
        } elseif ($mapview) {
noplanman's avatar
noplanman committed
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) {
noplanman's avatar
noplanman committed
129
          include_once __DIR__ . '/podmin.php';
David Morley's avatar
David Morley committed
130
        } elseif ($podminedit) {
noplanman's avatar
noplanman committed
131
          include_once __DIR__ . '/podminedit.php';
dmorley's avatar
dmorley committed
132 133
        } elseif ($edit) {
          include_once __DIR__ . '/db/edit.php';
dmorley's avatar
dmorley committed
134
        } else {
noplanman's avatar
noplanman committed
135
          include_once __DIR__ . '/show.php';
David Morley's avatar
David Morley committed
136 137
        }
        ?>
138
    </div>
139 140
  </div>
</div>
dmorley's avatar
dmorley committed
141 142 143 144
<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
145
<script src="bower_components/facebox/src/facebox.js"></script>
dmorley's avatar
dmorley committed
146
<script src="node_modules/chart.js/dist/Chart.min.js"></script>
David Morley's avatar
David Morley committed
147
<?php $statsview && include_once __DIR__ . '/statsviewjs.php'; ?>
David Morley's avatar
index  
David Morley committed
148 149
</body>
</html>