Commit 46c5f3f3 authored by Armando Lüscher's avatar Armando Lüscher

Merge branch 'podmin-notice-freedom' into 'develop'

Podmin notice freedom

See merge request !208
parents 33a44a8c c175345f
......@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic
- Config syntax has changed to array style (#155)
- Added `pghost` config to set database port
- Added `CONTRIBUTING.md`
- Podmin can choose at what fail score to send the notice out
- Podmin email shares details on why pod is failing
- Only retrieve location data for remote servers / IPs
### Changed
......
......@@ -13,9 +13,10 @@ require_once __DIR__ . '/../boot.php';
($_domain = $_GET['domain'] ?? null) || die('no pod domain given');
// Other parameters.
$_email = $_GET['email'] ?? '';
$_podmin_statement = $_GET['podmin_statement'] ?? '';
$_podmin_notify = $_GET['podmin_notify'] ?? 0;
$_email = $_GET['email'] ?? '';
$_podmin_statement = $_GET['podmin_statement'] ?? '';
$_podmin_notify = $_GET['podmin_notify'] ?? 0;
$_podmin_notify_level = $_GET['podmin_notify_level'] ?? 50;
$_domain = strtolower($_domain);
if (!filter_var(gethostbyname($_domain), FILTER_VALIDATE_IP)) {
......@@ -58,20 +59,22 @@ foreach ($pods as $pod) {
}
echo <<<EOF
<script>
window.onload = function() {
$("#weight").ionRangeSlider();
}
</script>
<form action="/">
<input type="hidden" name="edit">
<input type="hidden" name="domain" value="{$_domain}">
<input type="hidden" name="token" value="{$uuid}">
<label>Email <input type="text" size="20" name="email"></label><br>
<label>Podmin Statement (You can include links to your terms and policies and information about your pod you wish to share with users.) <br><textarea cols="100" rows="7" name="podmin_statement"></textarea></label><br>
<label>Weight <input type="text" data-min="0" data-step="1" data-max="10" name="weight" id="weight"> This lets you weight your pod lower on the list if you have too much traffic coming in, 10 is the norm use lower to move down the list.</label><br>
<input type="submit" name="action" value="save">
</form>
<script>
window.onload = function() {
$("#weight").ionRangeSlider();
$("#podmin_notify_level").ionRangeSlider();
}
</script>
<form action="/">
<input type="hidden" name="edit">
<input type="hidden" name="domain" value="{$_domain}">
<input type="hidden" name="token" value="{$uuid}">
<label>Email <input type="text" size="20" name="email"></label><br>
<label>Podmin Statement (You can include links to your terms and policies and information about your pod you wish to share with users.) <br><textarea cols="100" rows="7" name="podmin_statement"></textarea></label><br>
<label>Weight <input type="text" data-min="0" data-step="1" data-max="10" name="weight" id="weight"> This lets you weight your pod lower on the list if you have too much traffic coming in, 10 is the norm use lower to move down the list.</label><br>
<label>Notify when your score falls to <input type="text" data-min="1" data-step="1" data-max="99" data-from="50" name="podmin_notify_level" id="podmin_notify_level"></label><br>
<input type="submit" name="action" value="save">
</form>
EOF;
$stop = true;
......@@ -101,12 +104,13 @@ if (!$stop) {
$publickey = md5(uniqid($_domain, true));
try {
$p = R::dispense('pods');
$p['domain'] = $_domain;
$p['email'] = $_email;
$p['podmin_statement'] = $_podmin_statement;
$p['podmin_notify'] = $_podmin_notify;
$p['publickey'] = $publickey;
$p = R::dispense('pods');
$p['domain'] = $_domain;
$p['email'] = $_email;
$p['podmin_statement'] = $_podmin_statement;
$p['podmin_notify'] = $_podmin_notify;
$p['podmin_notify_level'] = $_podmin_notify_level;
$p['publickey'] = $publickey;
R::store($p);
} catch (\RedBeanPHP\RedException $e) {
......
......@@ -16,11 +16,12 @@ use RedBeanPHP\R;
strlen($_token) > 6 || die('bad token');
// Other parameters.
$_action = $_GET['action'] ?? '';
$_weight = $_GET['weight'] ?? 10;
$_email = $_GET['email'] ?? '';
$_podmin_statement = $_GET['podmin_statement'] ?? '';
$_podmin_notify = $_GET['podmin_notify'] ?? 0;
$_action = $_GET['action'] ?? '';
$_weight = $_GET['weight'] ?? 10;
$_email = $_GET['email'] ?? '';
$_podmin_statement = $_GET['podmin_statement'] ?? '';
$_podmin_notify = $_GET['podmin_notify'] ?? 0;
$_podmin_notify_level = $_GET['podmin_notify_level'] ?? 50;
require_once __DIR__ . '/../boot.php';
......@@ -72,10 +73,12 @@ if ('save' === $_action) {
$_weight <= 10 || die('10 is max weight');
try {
$pod['email'] = $_email;
$pod['weight'] = $_weight;
$pod['podmin_statement'] = $_podmin_statement;
$pod['podmin_notify'] = $_podmin_notify;
$pod['email'] = $_email;
$pod['weight'] = $_weight;
$pod['podmin_statement'] = $_podmin_statement;
$pod['podmin_notify'] = $_podmin_notify;
$pod['podmin_notify_level'] = $_podmin_notify_level;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
......@@ -97,6 +100,7 @@ if ('save' === $_action) {
<script>
window.onload = function() {
$("#weight").ionRangeSlider();
$("#podmin_notify_level").ionRangeSlider();
}
</script>
Authorized to edit <b><?php echo $_domain; ?></b> for <?php echo (new Carbon($pod['tokenexpire']))->diffForHumans(null, true); ?><br>
......@@ -108,6 +112,8 @@ Authorized to edit <b><?php echo $_domain; ?></b> for <?php echo (new Carbon($po
<label>Podmin Statement (You can use HTML to include links to your terms and policies and information about your pod you wish to share with users.) <br><textarea cols="150" rows="10" name="podmin_statement"><?php echo $pod['podmin_statement']; ?></textarea></label><br>
<label>Weight <input type="text" data-min="0" data-step="1" data-max="10" name="weight" id="weight" data-from="<?php echo $pod['weight']; ?>"> This lets you weight your pod lower on the list if you have too much traffic coming in, 10 is the norm use lower to move down the list.</label><br>
<label>Notify if pod falls off the list? <input type="checkbox" name="podmin_notify" <?php echo $pod['podmin_notify'] ? 'checked' : ''; ?> ></label><br>
<label>Notify when your score falls to <input type="text" data-min="1" data-step="1" data-max="99" name="podmin_notify_level" id="podmin_notify_level" data-from="<?php echo $pod['podmin_notify_level']; ?>"></label><br>
<input type="submit" name="action" value="save">
</form>
<br>
......
......@@ -5,7 +5,6 @@ ALTER TABLE pods RENAME COLUMN pingdomurl TO stats_apikey;
ALTER TABLE pods RENAME COLUMN xmpp TO service_xmpp;
ALTER TABLE pods RENAME COLUMN uptimelast7 TO uptime_alltime;
ALTER TABLE pods RENAME COLUMN responsetimelast7 TO latency;
ALTER TABLE pods RENAME COLUMN dateUpdated TO date_updated;
ALTER TABLE pods RENAME COLUMN dateLaststats TO date_laststats;
ALTER TABLE pods RENAME COLUMN dateCreated TO date_created;
......
ALTER TABLE pods ADD podmin_notify_level int DEFAULT 50;
......@@ -40,7 +40,7 @@ try {
$reader = new Reader(c('geoip2db'));
$sql = '
SELECT domain, score, date_created, weight, podmin_notify, email, masterversion, shortversion, status, detectedlanguage
SELECT domain, score, date_created, weight, podmin_notify, podmin_notify_level, email, masterversion, shortversion, status, detectedlanguage
FROM pods
';
......@@ -63,17 +63,18 @@ try {
}
foreach ($pods as $pod) {
$domain = $pod['domain'];
$score = (int) $pod['score'];
$dbscore = $score;
$dateadded = $pod['date_created'];
$weight = $pod['weight'];
$email = $pod['email'];
$notify = $pod['podmin_notify'];
$masterv = $pod['masterversion'];
$shortv = $pod['shortversion'];
$dbstatus = $pod['status'];
$language = $pod['detectedlanguage'];
$domain = $pod['domain'];
$score = (int) $pod['score'];
$dbscore = $score;
$dateadded = $pod['date_created'];
$weight = $pod['weight'];
$email = $pod['email'];
$notify = $pod['podmin_notify'];
$notify_level = $pod['podmin_notify_level'];
$masterv = $pod['masterversion'];
$shortv = $pod['shortversion'];
$dbstatus = $pod['status'];
$language = $pod['detectedlanguage'];
try {
$ratings = R::getAll('
......@@ -348,7 +349,7 @@ foreach ($pods as $pod) {
debug('Uptime', $uptime);
if ($score == 49 && $notify && !$develop && $dbscore == 50) {
if ($score == ($notify_level - 1) && $notify && !$develop && $dbscore == $notify_level) {
$to = $email;
$headers = ['From: ' . c('adminemail'), 'Bcc: ' . c('adminemail')];
$subject = 'Monitoring notice from poduptime';
......
......@@ -40,6 +40,7 @@ CREATE TABLE pods (
tokenexpire timestamp,
podmin_statement text,
podmin_notify boolean,
podmin_notify_level int DEFAULT 50,
sslexpire timestamp,
dnssec boolean,
comment_counts int,
......
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