Commit 920a7c4e authored by David Morley's avatar David Morley

Merge branch 'develop' into allservices

# Conflicts:
#	db/migrations/2.3.0-2.4.0.sql
parents 2dcc68fa 46c5f3f3
......@@ -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
......
......@@ -8,7 +8,7 @@ Environmental items you need (debian based system assumed):
OS Dependencies:
```
php7.2 php7.2-curl php7.2-pgsql php-geoip php7.2-cli php7.2-common php7.2-bcmath php7.2-json php7.2-readline php7.2-mbstring php7.2-xml php-cgi git curl postgresql postgresql-contrib dnsutils bind9 npm nodejs composer
php7.2 php7.2-curl php7.2-pgsql php7.2-bcmath php-geoip php7.2-cli php7.2-common php7.2-bcmath php7.2-json php7.2-readline php7.2-mbstring php7.2-xml php-cgi git curl postgresql postgresql-contrib dnsutils bind9 npm nodejs composer
```
Yarn is a separate install: https://yarnpkg.com
......
......@@ -13,6 +13,7 @@
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-bcmath": "*",
"gabordemooij/redbean": "^5.1",
"nesbot/carbon": "^1.33",
"commerceguys/enum": "^1.0",
......
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "9ac3659b3b8b6f4a29e9a44e0dfd105f",
"content-hash": "fda17d0424e9e1c45facb411a5473f27",
"packages": [
{
"name": "commerceguys/enum",
......@@ -864,7 +864,8 @@
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*"
"ext-libxml": "*",
"ext-bcmath": "*"
},
"platform-dev": [],
"platform-overrides": {
......
......@@ -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 services text;
ALTER TABLE pods DROP COLUMN service_facebook, DROP COLUMN service_wordpress, DROP COLUMN service_tumblr, DROP COLUMN service_twitter;
\ No newline at end of file
ALTER TABLE pods DROP COLUMN service_facebook, DROP COLUMN service_wordpress, DROP COLUMN service_tumblr, DROP COLUMN service_twitter;
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('
......@@ -341,7 +342,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';
......
......@@ -37,6 +37,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