From 563c63fb808e7aded03650c21b373b11a24fa4e7 Mon Sep 17 00:00:00 2001 From: David Morley Date: Wed, 8 Feb 2017 13:05:34 -0800 Subject: [PATCH] some responsiveness cleanup & few features (#98) * some responsiveness cleanup * few sql ones * basic email ping on bad pod * cleanup * fix facebox --- css/dashboard.css | 2 +- css/newstyle.css | 21 ++++++--------------- db/add.php | 5 +++-- db/edit.php | 7 ++++--- db/migration00001.sql | 2 +- db/pods_apiv1.sql | 2 +- db/pull.php | 22 ++++++++++++++++++---- db/tables.sql | 1 + index.php | 23 +++++++++++------------ podmin.php | 1 + show.php | 7 ++++--- showmap.php | 5 ++--- 12 files changed, 53 insertions(+), 45 deletions(-) diff --git a/css/dashboard.css b/css/dashboard.css index 126afd9..07a85d3 100644 --- a/css/dashboard.css +++ b/css/dashboard.css @@ -77,7 +77,7 @@ body { @media (min-width: 768px) { .main { padding-right: 40px; - padding-left: 40px; + padding-left: 80px; } } diff --git a/css/newstyle.css b/css/newstyle.css index a90eaa5..d8dd01e 100644 --- a/css/newstyle.css +++ b/css/newstyle.css @@ -1,19 +1,9 @@ -.db-wrapper { -vertical-align: top; -} .rating { font-size:9px; } -.content { -margin-left: 2px !important; -width: 99%; -} .tfont { font-size:12px; } -#results { -width: 750px; -} .smlogo { width: 16px; height: 16px; @@ -39,10 +29,6 @@ background: none; .smlogo-xmpp img { vertical-align: unset; } -.morehover { -display: inline-block; -vertical-align: super; -} #map { height: 580px; } .mycluster { width: 35px; @@ -59,4 +45,9 @@ color: red; table { empty-cells: show; } - +#facebox { +z-index: 1000 !important; +} +#facebox .content { +width: 800px !important; +} diff --git a/db/add.php b/db/add.php index d857451..01ada48 100644 --- a/db/add.php +++ b/db/add.php @@ -11,6 +11,7 @@ if (!($_domain = $_GET['domain'] ?? null)) { $_email = $_GET['email'] ?? ''; $_podmin_statement = $_GET['podmin_statement'] ?? ''; +$_podmin_notify = $_GET['podmin_notify'] ?? ''; $_domain = strtolower($_domain); if (!filter_var(gethostbyname($_domain), FILTER_VALIDATE_IP)) { @@ -74,8 +75,8 @@ if (stristr($outputssl, 'openRegistrations')) { echo 'Your pod has ssl and is valid
'; $publickey = md5(uniqid($domain, true)); - $sql = 'INSERT INTO pods (domain, email, podmin_statement, publickey) VALUES ($1, $2, $3, $4)'; - $result = pg_query_params($dbh, $sql, [$_domain, $_email, $_podmin_statement, $publickey]); + $sql = 'INSERT INTO pods (domain, email, podmin_statement, $podmin_notify, publickey) VALUES ($1, $2, $3, $4, $5)'; + $result = pg_query_params($dbh, $sql, [$_domain, $_email, $_podmin_statement, $_podmin_notify, $publickey]); $result || die('Error in SQL query: ' . pg_last_error()); if ($_email) { diff --git a/db/edit.php b/db/edit.php index fb939b2..56f4bc1 100644 --- a/db/edit.php +++ b/db/edit.php @@ -36,8 +36,8 @@ while ($row = pg_fetch_array($result)) { if ('save' === $_action) { $_weight <= 10 || die('10 is max weight'); - $sql = 'UPDATE pods SET email = $1, weight = $2, podmin_statement = $3 WHERE domain = $4'; - $result = pg_query_params($dbh, $sql, [$_email, $_weight, $_podmin_statement, $_domain]); + $sql = 'UPDATE pods SET email = $1, weight = $2, podmin_statement = $3, podmin_notify = $4 WHERE domain = $5'; + $result = pg_query_params($dbh, $sql, [$_email, $_weight, $_podmin_statement, $_podmin_notify, $_domain]); $result || die('Error in SQL query: ' . pg_last_error()); $to = $_email; @@ -56,8 +56,9 @@ while ($row = pg_fetch_array($result)) {
-
+

+

diff --git a/db/migration00001.sql b/db/migration00001.sql index be77e2c..6f30264 100644 --- a/db/migration00001.sql +++ b/db/migration00001.sql @@ -1,4 +1,4 @@ -ALTER TABLE pods ADD podmin_statement text, ADD sslexpire timestamp, ADD dnssec boolean, ADD masterversion text, ADD shortversion text, ADD publickey text; +ALTER TABLE pods ADD podmin_statement text, ADD sslexpire timestamp, ADD dnssec boolean, ADD masterversion text, ADD shortversion text, ADD publickey text, ADD podmin_notify boolean; 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 stats_apikey; diff --git a/db/pods_apiv1.sql b/db/pods_apiv1.sql index a6275a0..8ccacbc 100644 --- a/db/pods_apiv1.sql +++ b/db/pods_apiv1.sql @@ -21,6 +21,6 @@ ALTER TABLE pods_apiv1 ALTER COLUMN signup TYPE text USING signup::text; ALTER TABLE pods_apiv1 ADD Hgitdate text, ADD Hgitref text, ADD Hruntime text, ADD Hencoding text, ADD longversion text, ADD ptr text, ADD whois text, ADD postalcode text, ADD connection text, ADD pingdomlast text; -ALTER TABLE pods_apiv1 DROP terms, DROP sslexpire, DROP dnssec, DROP masterversion, DROP shortversion, DROP publickey; +ALTER TABLE pods_apiv1 DROP podmin_statement, DROP sslexpire, DROP dnssec, DROP publickey, DROP podmin_notify; UPDATE pods_apiv1 SET hgitdate = 'unsupported'; diff --git a/db/pull.php b/db/pull.php index 691dc50..2211077 100644 --- a/db/pull.php +++ b/db/pull.php @@ -13,10 +13,10 @@ $dbh || die('Error in connection: ' . pg_last_error()); //foreach pod check it and update db if ($_domain) { - $sql = 'SELECT domain,stats_apikey,score,date_created,adminrating,weight FROM pods WHERE domain = $1'; + $sql = 'SELECT domain,score,date_created,adminrating,weight,hidden,podmin_notify,email FROM pods WHERE domain = $1'; $result = pg_query_params($dbh, $sql, [$_domain]); } elseif (PHP_SAPI === 'cli') { - $sql = 'SELECT domain,stats_apikey,score,date_created,adminrating,weight FROM pods'; + $sql = 'SELECT domain,score,date_created,adminrating,weight,hidden,podmin_notify,email FROM pods'; $result = pg_query($dbh, $sql); } else { die('No valid input'); @@ -29,6 +29,9 @@ while ($row = pg_fetch_assoc($result)) { $dateadded = $row['date_created']; $admindb = (int) $row['adminrating']; $weight = $row['weight']; + $hiddennow = $row['hidden']; + $email = $row['email']; + $notify = $row['podmin_notify']; $sqlforr = 'SELECT admin,rating FROM rating_comments WHERE domain = $1'; $ratings = pg_query_params($dbh, $sqlforr, [$domain]); $ratings || die('Error in SQL query2: ' . pg_last_error()); @@ -158,10 +161,12 @@ while ($row = pg_fetch_assoc($result)) { $responsetime = pg_fetch_result($resultttl, 0); $uptime = 0; - $sqlonline = 'SELECT round(avg(online::int),2) * 100 AS online FROM checks WHERE domain = $1'; + $sqlonline = 'SELECT avg(online::int) * 100 AS online FROM checks WHERE domain = $1'; $resultonline = pg_query_params($dbh, $sqlonline, [$domain]); $resultonline || die('Error in SQL query resultchecks: ' . pg_last_error()); - $uptime = pg_fetch_result($resultonline, 0); + $uptime = round(pg_fetch_result($resultonline, 0),2); + + _debug('Uptime', $uptime); $sqlmasters = 'SELECT version FROM masterversions WHERE software = $1 ORDER BY date_checked LIMIT 1'; $resultmasters = pg_query_params($dbh, $sqlmasters, [$softwarename]); @@ -172,6 +177,15 @@ while ($row = pg_fetch_assoc($result)) { $hidden = $score <= 70; _debug('Hidden', $hidden ? 'yes' : 'no'); + + if ($hiddennow === 'f' && $hidden && $notify === 't') { + $to = $email; + $headers = ['From: ' . $adminemail, 'Bcc: ' . $adminemail]; + $subject = 'Monitoring notice from poduptime'; + $message = 'Notice for ' . $domain . '. Your score fell to ' . $score . ' and your pod is now marked as hidden.'; + @mail($to, $subject, $message, implode("\r\n", $headers)); + _debug('Mail Notice', 'sent to '.$email); + } if ($score > 100) { $score = 100; } elseif ($score < 0) { diff --git a/db/tables.sql b/db/tables.sql index 1a59266..7aa6aab 100644 --- a/db/tables.sql +++ b/db/tables.sql @@ -38,6 +38,7 @@ CREATE TABLE pods ( publickey text, tokenexpire timestamp, podmin_statement text, + podmin_notify boolean, sslexpire timestamp, dnssec boolean, comment_counts int, diff --git a/index.php b/index.php index 272477b..6972991 100644 --- a/index.php +++ b/index.php @@ -1,19 +1,19 @@ - Diaspora Pod Uptime Status - Find your new social home on a hosted pod - + Open Source Social Network Pod Uptime Status + @@ -21,7 +21,7 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi - + @@ -34,7 +34,7 @@ $simpleview = !($advancedview || $mapview || $cleanup || $podmin || $podminedi