Commit 65dff383 authored by dmorley's avatar dmorley

cleanup a bit

parent ed83cb98
...@@ -83,7 +83,7 @@ $numrows = pg_num_rows($result); ...@@ -83,7 +83,7 @@ $numrows = pg_num_rows($result);
echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>'; echo '<td class="' . $classver . '"><div title="' . $pre . ' codename: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" class="tipsy">' . $version . '</div></td>';
echo '<td>' . $row['uptime_alltime'] . '</td>'; echo '<td>' . $row['uptime_alltime'] . '</td>';
echo '<td>' . $row['responsetimems'] . '</td>'; echo '<td>' . $row['responsetimems'] . '</td>';
echo '<td>'; echo $row['signup'] ? 'Open' : 'Closed'; echo '</td>'; echo '<td>' . ($row['signup'] ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $row['total_users'] . '</td>'; echo '<td>' . $row['total_users'] . '</td>';
echo '<td>' . $row['active_users_halfyear'] . '</td>'; echo '<td>' . $row['active_users_halfyear'] . '</td>';
echo '<td>' . $row['active_users_monthly'] . '</td>'; echo '<td>' . $row['active_users_monthly'] . '</td>';
......
ALTER TABLE pods ADD terms text, ADD sslexpire timestamp, ADD uptime_custom text, ADD dnssec boolean, ADD masterversion text, ADD shortversion text; ALTER TABLE pods ADD terms text DEFAULT '/terms', ADD sslexpire timestamp, ADD uptime_custom text, ADD dnssec boolean, ADD masterversion text, ADD shortversion text;
ALTER TABLE pods DROP Hgitdate, DROP Hgitref, DROP Hruntime, DROP Hencoding, DROP longversion, DROP ptr, DROP whois, DROP postalcode, DROP connection, DROP pingdomlast; ALTER TABLE pods DROP Hgitdate, DROP Hgitref, DROP Hruntime, DROP Hencoding, DROP longversion, DROP ptr, DROP whois, DROP postalcode, DROP connection, DROP pingdomlast;
ALTER TABLE pods RENAME COLUMN pingdomurl TO statsurl; ALTER TABLE pods RENAME COLUMN pingdomurl TO statsurl;
ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp; ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp;
ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime; ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime;
ALTER TABLE pods RENAME COLUMN responsetimelast7 TO responsetimems; ALTER TABLE pods RENAME COLUMN responsetimelast7 TO responsetime;
ALTER TABLE pods ALTER COLUMN ipv6 TYPE boolean USING ipv6::boolean; ALTER TABLE pods ALTER COLUMN ipv6 TYPE boolean USING ipv6::boolean;
ALTER TABLE pods ALTER hidden DROP DEFAULT; ALTER TABLE pods ALTER hidden DROP DEFAULT;
......
...@@ -291,13 +291,13 @@ while ($row = pg_fetch_all($result)) { ...@@ -291,13 +291,13 @@ while ($row = pg_fetch_all($result)) {
$uptime = isset($matchper[1][0]) ? preg_replace('/,/', '.', $matchper[1][0]) : 0; $uptime = isset($matchper[1][0]) ? preg_replace('/,/', '.', $matchper[1][0]) : 0;
$statslastdate = date('Y-m-d H:i:s'); $statslastdate = date('Y-m-d H:i:s');
if (strpos($pingdom, "class=\"up\"")) { if (strpos($pingdom, "class=\"up\"")) {
$live = 'up'; $status = 'up';
} elseif (strpos($pingdom, "class=\"down\"")) { } elseif (strpos($pingdom, "class=\"down\"")) {
$live = 'down'; $status = 'down';
} elseif (strpos($pingdom, "class=\"paused\"")) { } elseif (strpos($pingdom, "class=\"paused\"")) {
$live = 'paused'; $status = 'paused';
} else { } else {
$live = 'error'; $status = 'error';
$score = $score - 2; $score = $score - 2;
} }
} else { } else {
...@@ -330,25 +330,26 @@ while ($row = pg_fetch_all($result)) { ...@@ -330,25 +330,26 @@ while ($row = pg_fetch_all($result)) {
$responsetime = $uptr->monitors->monitor{'0'}->responsetime{'0'}->value; $responsetime = $uptr->monitors->monitor{'0'}->responsetime{'0'}->value;
$uptimerobotstat = $uptr->stat; $uptimerobotstat = $uptr->stat;
$uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio; $uptime = $uptr->monitors->monitor{'0'}->alltimeuptimeratio;
$uptime_custom = $uptr->monitors->monitor{'0'}->customuptimeratio;
$diff = abs(strtotime(date('Y-m-d H:i:s')) - strtotime($dateadded)); $diff = abs(strtotime(date('Y-m-d H:i:s')) - strtotime($dateadded));
$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24)); $months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
if ($uptr->monitors->monitor{'0'}->status == 2) { if ($uptr->monitors->monitor{'0'}->status == 2) {
$live = 'Up'; $status = 'Up';
} }
if ($uptr->monitors->monitor{'0'}->status == 0) { if ($uptr->monitors->monitor{'0'}->status == 0) {
$live = 'Paused'; $status = 'Paused';
} }
if ($uptr->monitors->monitor{'0'}->status == 1) { if ($uptr->monitors->monitor{'0'}->status == 1) {
$live = 'Not Checked Yet'; $status = 'Not Checked Yet';
} }
if ($uptr->monitors->monitor{'0'}->status == 8) { if ($uptr->monitors->monitor{'0'}->status == 8) {
$live = 'Seems Down'; $status = 'Seems Down';
} }
if ($uptr->monitors->monitor{'0'}->status == 9) { if ($uptr->monitors->monitor{'0'}->status == 9) {
$live = 'Down'; $status = 'Down';
} }
$pingdomdate = date('Y-m-d H:i:s'); $pingdomdate = date('Y-m-d H:i:s');
if ($uptimerobotstat == 'fail' || $live <> 'Up') { if ($uptimerobotstat == 'fail' || $status <> 'Up') {
$score = $score - 2; $score = $score - 2;
} }
} }
...@@ -375,9 +376,9 @@ while ($row = pg_fetch_all($result)) { ...@@ -375,9 +376,9 @@ while ($row = pg_fetch_all($result)) {
//sql it //sql it
$timenow = date('Y-m-d H:i:s'); $timenow = date('Y-m-d H:i:s');
$sql = 'UPDATE pods SET secure = $2, hidden = $3, ip = $4, ipv6 = $5, monthsmonitored = $6, uptime_alltime = $7, status = $8, dateLaststats = $9, dateUpdated = $10, responsetimems = $11, score = $12, adminrating = $13, country = $14, city = $15, state = $16, lat = $17, long = $18, userrating = $19, shortversion = $20, masterversion = $21, signup = $22, total_users = $23, active_users_halfyear = $24, active_users_monthly = $25, local_posts = $26, name = $27, comment_counts = $28, service_facebook = $29, service_tumblr = $30, service_twitter = $31, service_wordpress = $32, weightedscore = $33, service_xmpp = $34, softwarename = $35, sslvalid = $36 $sql = 'UPDATE pods SET secure = $2, hidden = $3, ip = $4, ipv6 = $5, monthsmonitored = $6, uptime_alltime = $7, status = $8, dateLaststats = $9, dateUpdated = $10, responsetime = $11, score = $12, adminrating = $13, country = $14, city = $15, state = $16, lat = $17, long = $18, userrating = $19, shortversion = $20, masterversion = $21, signup = $22, total_users = $23, active_users_halfyear = $24, active_users_monthly = $25, local_posts = $26, name = $27, comment_counts = $28, service_facebook = $29, service_tumblr = $30, service_twitter = $31, service_wordpress = $32, weightedscore = $33, service_xmpp = $34, softwarename = $35, sslvalid = $36, uptime_custom = $37
WHERE domain = $1'; WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$domain, $secure, $hidden, $ip, $ipv6, $months, $uptime, $live, $statslastdate, $timenow, $responsetime, $score, $adminrating, $country, $city, $state, $lat, $long, $userrating, $shortversion, $masterversion, $signup, $total_users, $active_users_halfyear, $active_users_monthly, $local_posts, $name, $comment_counts, $service_facebook, $service_tumblr, $service_twitter, $service_wordpress, $weightedscore, $service_xmpp, $softwarename, $outputsslerror]); $result = pg_query_params($dbh, $sql, [$domain, $secure, $hidden, $ip, $ipv6, $months, $uptime, $status, $statslastdate, $timenow, $responsetime, $score, $adminrating, $country, $city, $state, $lat, $long, $userrating, $shortversion, $masterversion, $signup, $total_users, $active_users_halfyear, $active_users_monthly, $local_posts, $name, $comment_counts, $service_facebook, $service_tumblr, $service_twitter, $service_wordpress, $weightedscore, $service_xmpp, $softwarename, $outputsslerror, $uptime_custom]);
$result || die('Error in SQL query3: ' . pg_last_error()); $result || die('Error in SQL query3: ' . pg_last_error());
if ($debug) { if ($debug) {
......
...@@ -9,7 +9,7 @@ CREATE TABLE pods ( ...@@ -9,7 +9,7 @@ CREATE TABLE pods (
weightedscore numeric(5,2) DEFAULT 10, weightedscore numeric(5,2) DEFAULT 10,
adminrating decimal DEFAULT 10, adminrating decimal DEFAULT 10,
userrating decimal DEFAULT 10, userrating decimal DEFAULT 10,
hidden boolean DEFAULT 'yes', hidden boolean DEFAULT true,
ip text, ip text,
country text, country text,
city text, city text,
...@@ -30,7 +30,7 @@ CREATE TABLE pods ( ...@@ -30,7 +30,7 @@ CREATE TABLE pods (
uptime_alltime numeric(5,2), uptime_alltime numeric(5,2),
uptime_custom text, uptime_custom text,
status text, status text,
responsetimems text, responsetime text,
service_facebook boolean, service_facebook boolean,
service_twitter boolean, service_twitter boolean,
service_tumblr boolean, service_tumblr boolean,
...@@ -38,7 +38,7 @@ CREATE TABLE pods ( ...@@ -38,7 +38,7 @@ CREATE TABLE pods (
service_xmpp boolean, service_xmpp boolean,
token text, token text,
tokenexpire timestamp, tokenexpire timestamp,
terms text, terms text DEFAULT '/terms',
sslexpire timestamp, sslexpire timestamp,
dnssec boolean, dnssec boolean,
comment_counts int, comment_counts int,
......
...@@ -17,7 +17,10 @@ if ($_url) { ...@@ -17,7 +17,10 @@ if ($_url) {
$row = pg_fetch_all($result); $row = pg_fetch_all($result);
$row || die('unknown url'); $row || die('unknown url');
//Add click counter +1 for $row[0]['domain'] clicks in future, separate click table $sql = 'INSERT INTO clicks (domain, manualclick) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$host, '1']);
$result || die('Error in SQL query: ' . pg_last_error());
header('Location:' . $_url); header('Location:' . $_url);
} else { } else {
$sql = 'SELECT secure,domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup ORDER BY RANDOM() LIMIT 1'; $sql = 'SELECT secure,domain FROM pods WHERE score > 90 AND masterversion = shortversion AND signup ORDER BY RANDOM() LIMIT 1';
...@@ -26,5 +29,12 @@ if ($_url) { ...@@ -26,5 +29,12 @@ if ($_url) {
$row = pg_fetch_all($result); $row = pg_fetch_all($result);
$scheme = $row[0]['secure'] ? 'https://' : 'http://'; $scheme = $row[0]['secure'] ? 'https://' : 'http://';
$sql = 'INSERT INTO clicks (domain, autoclick) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$row[0]['domain'], '1']);
$result || die('Error in SQL query: ' . pg_last_error());
header('Location:' . $scheme . $row[0]['domain'] . '/users/sign_up'); header('Location:' . $scheme . $row[0]['domain'] . '/users/sign_up');
} }
pg_free_result($result);
pg_close($dbh);
...@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? ''; ...@@ -8,7 +8,7 @@ $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass"); $dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error()); $dbh || die('Error in connection: ' . pg_last_error());
$sql = "SELECT * FROM pods WHERE adminrating <> -1 AND NOT hidden AND signup ORDER BY uptime_alltime DESC"; $sql = "SELECT * FROM pods WHERE NOT hidden AND signup ORDER BY uptime_alltime DESC";
$result = pg_query($dbh, $sql); $result = pg_query($dbh, $sql);
$result || die('Error in SQL query: ' . pg_last_error()); $result || die('Error in SQL query: ' . pg_last_error());
......
...@@ -76,9 +76,9 @@ $numrows = pg_num_rows($result); ...@@ -76,9 +76,9 @@ $numrows = pg_num_rows($result);
} }
echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" data-toggle="tooltip" data-placement="bottom">' . $version . '</div></td>'; echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $row['shortversion'] . ' master version is: ' . $row['masterversion'] . '" data-toggle="tooltip" data-placement="bottom">' . $version . '</div></td>';
echo '<td>' . $row['uptime_alltime'] . '%</td>'; echo '<td>' . $row['uptime_alltime'] . '%</td>';
echo '<td>'; echo $row['ipv6'] ? 'Yes' : 'No'; echo '</td>'; echo '<td>' . ($row['ipv6'] ? 'Yes' : 'No') . '</td>';
echo '<td>' . $row['responsetimems'] . '</td>'; echo '<td>' . $row['responsetimems'] . '</td>';
echo '<td>'; echo $row['signup'] ? 'Open' : 'Closed'; echo '</td>'; echo '<td>' . ($row['signup'] ? 'Open' : 'Closed') . '</td>';
echo '<td>' . $row['total_users'] . '</td>'; echo '<td>' . $row['total_users'] . '</td>';
echo '<td>' . $row['active_users_halfyear'] . '</td>'; echo '<td>' . $row['active_users_halfyear'] . '</td>';
echo '<td>' . $row['active_users_monthly'] . '</td>'; echo '<td>' . $row['active_users_monthly'] . '</td>';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment