random.php 613 Bytes
Newer Older
dmorley's avatar
dmorley committed
1
<?php
2 3
require_once __DIR__ . '/config.php';

dmorley's avatar
cleanup  
dmorley committed
4
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
5 6
$dbh || die('Error in connection: ' . pg_last_error());

7
$sql    = "SELECT * FROM pods WHERE adminrating <> -1 AND hidden <> 'yes' AND uptimelast7 > 95 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1";
dmorley's avatar
cleanup  
dmorley committed
8
$result = pg_query($dbh, $sql);
9 10
$result || die('Error in SQL query1: ' . pg_last_error());

dmorley's avatar
dmorley committed
11
$row = pg_fetch_all($result);
12 13 14 15 16
if ($row[0]['secure'] == 'true') {
  $ssl = 's';
} else {
  $ssl = '';
}
17
header('Location: http' . $ssl . '://' . $row[0]['domain'] . '/users/sign_up');