Commit 2a39ce81 authored by dmorley's avatar dmorley

terms manual for podmin. add click and checks rough

parent 65dff383
......@@ -39,7 +39,7 @@ $numrows = pg_num_rows($result);
$tt = 0;
while ($row = pg_fetch_array($result)) {
$tt++;
if ($row['secure']) {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'green';
$tip = 'This pod uses SSL encryption for traffic.';
......
......@@ -16,6 +16,10 @@ if (!($_email = $_POST['email'] ?? null)) {
$log->lwrite('no email given ' . $_domain);
die('no email given');
}
if (!($_terms = $_POST['terms'] ?? null)) {
$log->lwrite('terms link required ' . $_domain);
die('no terms link');
}
if (!$_url) {
$log->lwrite('no api given ' . $_domain);
die('no API key for your stats');
......@@ -78,8 +82,8 @@ if (stristr($output, 'nodeName')) {
$valid = true;
}
if ($valid) {
$sql = 'INSERT INTO pods (domain, statsurl, email) VALUES ($1, $2, $3)';
$result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email]);
$sql = 'INSERT INTO pods (domain, statsurl, email, terms) VALUES ($1, $2, $3, $4)';
$result = pg_query_params($dbh, $sql, [$_domain, $_url, $_email, $_terms]);
$result || die('Error in SQL query: ' . pg_last_error());
$to = $adminemail;
......
......@@ -11,13 +11,14 @@ $_weight = $_GET['weight'] ?? '';
$_email = $_GET['email'] ?? '';
$_oldemail = $_GET['oldemail'] ?? '';
$_statsurl = $_GET['statsurl'] ?? '';
$_terms = $_GET['terms'] ?? '';
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain,email,token,tokenexpire,statsurl,weight FROM pods WHERE domain = $1';
$sql = 'SELECT domain,email,token,tokenexpire,statsurl,weight,terms FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
......@@ -38,8 +39,8 @@ while ($row = pg_fetch_array($result)) {
if ($_save === $row['token']) {
$_weight <= 10 || die('10 is max weight');
$sql = 'UPDATE pods SET email = $1, statsurl = $2, weight = $3 WHERE domain = $4';
$result = pg_query_params($dbh, $sql, [$_email, $_statsurl, $_weight, $_domain]);
$sql = 'UPDATE pods SET email = $1, statsurl = $2, weight = $3, terms = $4 WHERE domain = $5';
$result = pg_query_params($dbh, $sql, [$_email, $_statsurl, $_weight, $_terms, $_domain]);
if (!$result) {
die('Error in SQL query: ' . pg_last_error());
}
......@@ -62,6 +63,7 @@ while ($row = pg_fetch_array($result)) {
echo '<input type="hidden" name="domain" value="' . $_domain . '">';
echo 'Stats Key <input type="text" size="50" name="statsurl" value="' . $row['statsurl'] . '"">Uptimerobot API key for this monitor<br>';
echo 'Email <input type="text" size="20" name="email" value="' . $row['email'] . '"><br>';
echo 'Terms Link <input type="text" size="20" name="terms" value="' . $row['terms'] . '"><br>';
echo 'Weight <input type="text" size="2" name="weight" value="' . $row['weight'] . '"> This lets you weight your pod lower on the list if you have too much trafic coming in, 10 is the norm use lower to move down the list.<br>';
echo '<input type="submit" name="submit">';
echo '</form><br><br><br>';
......
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 ADD terms text, 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 RENAME COLUMN pingdomurl TO statsurl;
......
......@@ -168,10 +168,20 @@ while ($row = pg_fetch_all($result)) {
if (!$output && !$outpulssl && !$domain) {
continue;
echo 'no connection to pod';
$sql = 'INSERT INTO checks (domain, online, error) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$domain, false, $outputsslerror]);
$result || die('Error in SQL query: ' . pg_last_error());
}
if ($outputssl) {
$secure = 'true';
$outputresults = $outputssl;
$sql = 'INSERT INTO checks (domain, online) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$domain, true]);
$result || die('Error in SQL query: ' . pg_last_error());
} elseif ($output) {
$secure = 'false';
$outputresults = $output;
......
......@@ -38,7 +38,7 @@ CREATE TABLE pods (
service_xmpp boolean,
token text,
tokenexpire timestamp,
terms text DEFAULT '/terms',
terms text,
sslexpire timestamp,
dnssec boolean,
comment_counts int,
......
......@@ -28,7 +28,7 @@ if ($_url) {
$result || die('Error in SQL query: ' . pg_last_error());
$row = pg_fetch_all($result);
$scheme = $row[0]['secure'] ? 'https://' : 'http://';
$scheme = $row[0]['secure'] === 't' ? 'https://' : 'http://';
$sql = 'INSERT INTO clicks (domain, autoclick) VALUES ($1, $2)';
$result = pg_query_params($dbh, $sql, [$row[0]['domain'], '1']);
......
......@@ -6,6 +6,7 @@ Create a monitor for your pod, then in "My Settings" create a monitor-specific A
<form action="https://podupti.me/db/add.php" method="post">
<label>Monitor API Key: <input type="text" name="url" class="xlarge span8" placeholder="m58978-80abdb799f6ccf15e3e4ttwe"> (don't copy the period on the end)</label><br>
<label>Pod Domain Name: <input type="text" name="domain" class="xlarge span4" placeholder="domain.com"></label><br>
<label>Pod Terms Link: <input type="text" name="domain" class="xlarge span4" value="/terms" placeholder="/terms"></label><br>
<label>Your Email: <input type="text" name="email" class="xlarge span4" placeholder="user@domain.com"></label><br>
<input type="submit" value="submit">
</form>
......@@ -32,7 +32,7 @@ $numrows = pg_num_rows($result);
<?php
while ($row = pg_fetch_array($result)) {
if ($row['secure']) {
if ($row['secure'] === 't') {
$scheme = 'https://';
$class = 'text-success';
} else {
......
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