go.php 629 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 8 9 10 11 12
$url = $_GET['url'];

if ($url) {
header('Location:' .$url);
} else {
$sql    = "SELECT secure,domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup = 1 ORDER BY RANDOM() LIMIT 1";
dmorley's avatar
cleanup  
dmorley committed
13
$result = pg_query($dbh, $sql);
noplanman's avatar
noplanman committed
14
$result || die('Error in SQL query: ' . pg_last_error());
dmorley's avatar
dmorley committed
15
$row = pg_fetch_all($result);
noplanman's avatar
noplanman committed
16
$scheme = $row[0]['secure'] === 'true' ? 'https://' : 'http://';
17 18
header('Location:' . $scheme . $row[0]['domain'] . '/users/sign_up');
}