Commit 5d63bcda authored by dmorley's avatar dmorley Committed by GitHub

WIP better delete (#127)

* better delete

* enum q

* enum

* Delete updated (#134)

* fix for some really old and incompatable pods - this should be done a… (#131)

* fix for some really old and incompatable pods - this should be done at some point also using the data from the checks table

* socialhome not pulling version code properly, update location for that

* some cleanup and fix the stats that just grind (#133)

* some cleanup and fix the stats that just grind

* limit the full page for now, so much dead pods

* add ganggo version pull

* remove unused item

* oops

* Remove temporary RedBean assignment fix, as corrected upstream by using partial beans.
see https://github.com/gabordemooij/redbean/issues/547

* Use enum for pod status.
parent 47a36f1b
...@@ -18,6 +18,7 @@ define('PODUPTIME', microtime(true)); ...@@ -18,6 +18,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
if ($_format === 'georss') { if ($_format === 'georss') {
echo <<<EOF echo <<<EOF
......
{ {
"require": { "require": {
"noplanman/xec": "0.1.0", "noplanman/xec": "0.1.0",
"gabordemooij/redbean": "^4.3", "gabordemooij/redbean": "^5.0",
"jaybizzle/crawler-detect" :"1.*" "jaybizzle/crawler-detect" :"1.*",
"commerceguys/enum": "^1.0"
},
"autoload": {
"classmap": ["lib"]
} }
} }
...@@ -4,21 +4,58 @@ ...@@ -4,21 +4,58 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "bc5abd96addbeeb7bbb644b518cbb065", "content-hash": "b753491dc03e2084e9587d0bbafad98c",
"content-hash": "f9ad6b81330128ff4847301b4835b7c2",
"packages": [ "packages": [
{
"name": "commerceguys/enum",
"version": "v1.0",
"source": {
"type": "git",
"url": "https://github.com/commerceguys/enum.git",
"reference": "1d9db2dbeb1a02500e7a14589ae2f9cb402c5c95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/commerceguys/enum/zipball/1d9db2dbeb1a02500e7a14589ae2f9cb402c5c95",
"reference": "1d9db2dbeb1a02500e7a14589ae2f9cb402c5c95",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"CommerceGuys\\Enum\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bojan Zivanovic"
}
],
"description": "A PHP 5.4+ enumeration library.",
"time": "2015-02-27T21:36:56+00:00"
},
{ {
"name": "gabordemooij/redbean", "name": "gabordemooij/redbean",
"version": "v4.3.3", "version": "v5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/gabordemooij/redbean.git", "url": "https://github.com/gabordemooij/redbean.git",
"reference": "1c7ec69850e9f7966ff7feb87b01d8f43a9753d3" "reference": "44229acdf493e2229c1e33e3add211f23c05ee4d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/gabordemooij/redbean/zipball/1c7ec69850e9f7966ff7feb87b01d8f43a9753d3", "url": "https://api.github.com/repos/gabordemooij/redbean/zipball/44229acdf493e2229c1e33e3add211f23c05ee4d",
"reference": "1c7ec69850e9f7966ff7feb87b01d8f43a9753d3", "reference": "44229acdf493e2229c1e33e3add211f23c05ee4d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -46,27 +83,28 @@ ...@@ -46,27 +83,28 @@
"keywords": [ "keywords": [
"orm" "orm"
], ],
"time": "2016-10-03 21:25:17" "time": "2017-10-19T21:38:38+00:00"
}, },
{ {
"name": "jaybizzle/crawler-detect", "name": "jaybizzle/crawler-detect",
"version": "v1.2.36", "version": "v1.2.61",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/JayBizzle/Crawler-Detect.git", "url": "https://github.com/JayBizzle/Crawler-Detect.git",
"reference": "186cdc021f972a7e06963a84ef692d75f5b325c6" "reference": "9f22764fa72f6a30211fe16cf28a1f43642136de"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/186cdc021f972a7e06963a84ef692d75f5b325c6", "url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/9f22764fa72f6a30211fe16cf28a1f43642136de",
"reference": "186cdc021f972a7e06963a84ef692d75f5b325c6", "reference": "9f22764fa72f6a30211fe16cf28a1f43642136de",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.0" "php": ">=5.3.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "4.*" "phpunit/phpunit": "4.8.*",
"satooshi/php-coveralls": "1.*"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
...@@ -94,7 +132,7 @@ ...@@ -94,7 +132,7 @@
"crawlerdetect", "crawlerdetect",
"php crawler detect" "php crawler detect"
], ],
"time": "2017-03-03 21:13:00" "time": "2018-03-19T20:27:17+00:00"
}, },
{ {
"name": "noplanman/xec", "name": "noplanman/xec",
...@@ -146,7 +184,7 @@ ...@@ -146,7 +184,7 @@
"shell", "shell",
"timeout" "timeout"
], ],
"time": "2017-03-12 19:16:23" "time": "2017-03-12T19:16:23+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
......
...@@ -29,6 +29,7 @@ if (!filter_var(gethostbyname($_domain), FILTER_VALIDATE_IP)) { ...@@ -29,6 +29,7 @@ if (!filter_var(gethostbyname($_domain), FILTER_VALIDATE_IP)) {
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
$pods = R::getAll(' $pods = R::getAll('
...@@ -57,11 +58,6 @@ foreach ($pods as $pod) { ...@@ -57,11 +58,6 @@ foreach ($pods as $pod) {
$p['token'] = $uuid; $p['token'] = $uuid;
$p['tokenexpire'] = date('Y-m-d H:i:s', $expire); $p['tokenexpire'] = date('Y-m-d H:i:s', $expire);
// @todo Temporary fix! https://github.com/gabordemooij/redbean/issues/547
foreach ($p->getProperties() as $key => $value) {
$p[$key] = $value;
}
R::store($p); R::store($p);
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
...@@ -110,11 +106,6 @@ if (stristr($outputssl, 'openRegistrations')) { ...@@ -110,11 +106,6 @@ if (stristr($outputssl, 'openRegistrations')) {
$p['podmin_notify'] = $_podmin_notify; $p['podmin_notify'] = $_podmin_notify;
$p['publickey'] = $publickey; $p['publickey'] = $publickey;
// @todo Temporary fix! https://github.com/gabordemooij/redbean/issues/547
foreach ($p->getProperties() as $key => $value) {
$p[$key] = $value;
}
R::store($p); R::store($p);
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
......
...@@ -18,6 +18,7 @@ define('PODUPTIME', microtime(true)); ...@@ -18,6 +18,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
$pod = R::getRow(' $pod = R::getRow('
...@@ -32,7 +33,12 @@ try { ...@@ -32,7 +33,12 @@ try {
if ($_format === 'json') { if ($_format === 'json') {
echo json_encode($pod); echo json_encode($pod);
} else { } else {
echo 'Status: ' . $pod['status'] . '<br>'; if ($pod['status'] === PodStatus::Up) {
echo 'Status: Up<br>';
}
if ($pod['status'] === PodStatus::Down) {
echo 'Status: Down<br>';
}
echo 'Last Git Pull: ' . $pod['hgitdate'] . '<br>'; echo 'Last Git Pull: ' . $pod['hgitdate'] . '<br>';
echo 'Uptime This Month ' . $pod['uptimelast7'] . '<br>'; echo 'Uptime This Month ' . $pod['uptimelast7'] . '<br>';
echo 'Months Monitored: ' . $pod['monthsmonitored'] . '<br>'; echo 'Months Monitored: ' . $pod['monthsmonitored'] . '<br>';
......
<?php <?php
use RedBeanPHP\R; use RedBeanPHP\R;
use CommerceGuys\Enum\AbstractEnum;
// Required parameters. // Required parameters.
($_domain = $_GET['domain'] ?? null) || die('no pod domain given'); ($_domain = $_GET['domain'] ?? null) || die('no pod domain given');
...@@ -17,12 +18,6 @@ $_podmin_notify = $_GET['podmin_notify'] ?? 0; ...@@ -17,12 +18,6 @@ $_podmin_notify = $_GET['podmin_notify'] ?? 0;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../config.php'; require_once __DIR__ . '/../config.php';
define('PODUPTIME', microtime(true));
// Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection');
try { try {
$pod = R::findOne('pods', 'domain = ?', [$_domain]); $pod = R::findOne('pods', 'domain = ?', [$_domain]);
$pod || die('domain not found'); $pod || die('domain not found');
...@@ -35,8 +30,35 @@ $pod['tokenexpire'] >= date('Y-m-d H:i:s') || die('token expired'); ...@@ -35,8 +30,35 @@ $pod['tokenexpire'] >= date('Y-m-d H:i:s') || die('token expired');
// Delete and exit. // Delete and exit.
if ('delete' === $_action) { if ('delete' === $_action) {
R::trash($pod); try {
die('pod removed from DB'); $pod['status'] = PodStatus::User_Deleted;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
die('pod deleted');
}
// Pause and exit.
if ('pause' === $_action) {
try {
$pod['status'] = PodStatus::Paused;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
die('pod paused');
}
// Un-Pause and exit.
if ('unpause' === $_action) {
try {
$pod['status'] = PodStatus::Recheck;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
die('pod unpaused');
} }
// Save and exit. // Save and exit.
...@@ -49,11 +71,6 @@ if ('save' === $_action) { ...@@ -49,11 +71,6 @@ if ('save' === $_action) {
$pod['podmin_statement'] = $_podmin_statement; $pod['podmin_statement'] = $_podmin_statement;
$pod['podmin_notify'] = $_podmin_notify; $pod['podmin_notify'] = $_podmin_notify;
// @todo Temporary fix for RedBean property handling, hope this gets fixed soon!
foreach ($pod->getProperties() as $key => $value) {
$pod[$key] = $value;
}
R::store($pod); R::store($pod);
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
...@@ -69,23 +86,38 @@ if ('save' === $_action) { ...@@ -69,23 +86,38 @@ if ('save' === $_action) {
} }
// Forms. // Forms.
?> ?>
Authorized to edit <b><?php echo $_domain; ?></b> until <?php echo $pod['tokenexpire']; ?><br> Authorized to edit <b><?php echo $_domain; ?></b> until <?php echo $pod['tokenexpire']; ?><br>
<form action="edit.php" method="get"> <form>
<input type="hidden" name="edit">
<input type="hidden" name="domain" value="<?php echo $_domain; ?>"> <input type="hidden" name="domain" value="<?php echo $_domain; ?>">
<input type="hidden" name="token" value="<?php echo $_token; ?>"> <input type="hidden" name="token" value="<?php echo $_token; ?>">
<label>Email <input type="text" size="20" name="email" value="<?php echo $pod['email']; ?>"></label><br> <label>Email <input type="text" size="40" name="email" value="<?php echo $pod['email']; ?>"></label><br>
<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="100" rows="7" name="podmin_statement"><?php echo $pod['podmin_statement']; ?></textarea></label><br> <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" size="2" name="weight" value="<?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>Weight <input type="text" size="2" name="weight" value="<?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 to hidden status? <input type="checkbox" name="podmin_notify" <?php echo $pod['podmin_notify'] ? 'checked' : ''; ?> ></label><br> <label>Notify if pod falls to hidden status? <input type="checkbox" name="podmin_notify" <?php echo $pod['podmin_notify'] ? 'checked' : ''; ?> ></label><br>
<input type="submit" name="action" value="save"> <input type="submit" name="action" value="save">
</form> </form>
<br> <br>
<br>Your pod status is currently: <?php echo PodStatus::getKey((int)$pod['status']); ?>
<br> <br>
<br> <form>
<form action="edit.php" method="get"> <input type="hidden" name="edit">
<input type="hidden" name="domain" value="<?php echo $_domain; ?>">
<input type="hidden" name="token" value="<?php echo $_token; ?>">
<input type="submit" name="action" value="delete">
</form>
<form>
<input type="hidden" name="edit">
<input type="hidden" name="domain" value="<?php echo $_domain; ?>">
<input type="hidden" name="token" value="<?php echo $_token; ?>">
<input type="submit" name="action" value="pause">
</form>
<form>
<input type="hidden" name="edit">
<input type="hidden" name="domain" value="<?php echo $_domain; ?>"> <input type="hidden" name="domain" value="<?php echo $_domain; ?>">
<input type="hidden" name="token" value="<?php echo $_token; ?>"> <input type="hidden" name="token" value="<?php echo $_token; ?>">
WARNING: This can not be undone, you will need to add your pod again if you want back on list: <input type="submit" name="action" value="delete"> <input type="submit" name="action" value="unpause">
</form> </form>
<?php <?php
...@@ -16,6 +16,7 @@ define('PODUPTIME', microtime(true)); ...@@ -16,6 +16,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
$pod = R::findOne('pods', 'domain = ?', [$_domain]); $pod = R::findOne('pods', 'domain = ?', [$_domain]);
...@@ -26,7 +27,7 @@ try { ...@@ -26,7 +27,7 @@ try {
// Set up common variables. // Set up common variables.
$uuid = md5(uniqid($_domain, true)); $uuid = md5(uniqid($_domain, true));
$link = sprintf('https://%1$s/db/edit.php?domain=%2$s&token=%3$s', $_SERVER['HTTP_HOST'], $_domain, $uuid); $link = sprintf('https://%1$s/?edit&domain=%2$s&token=%3$s', $_SERVER['HTTP_HOST'], $_domain, $uuid);
$headers = ['From: ' . $adminemail]; $headers = ['From: ' . $adminemail];
$message_lines = []; $message_lines = [];
...@@ -53,11 +54,6 @@ try { ...@@ -53,11 +54,6 @@ try {
$pod['token'] = $uuid; $pod['token'] = $uuid;
$pod['tokenexpire'] = date('Y-m-d H:i:s', $expire); $pod['tokenexpire'] = date('Y-m-d H:i:s', $expire);
// @todo Temporary fix! https://github.com/gabordemooij/redbean/issues/547
foreach ($pod->getProperties() as $key => $value) {
$pod[$key] = $value;
}
R::store($pod); R::store($pod);
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
......
...@@ -20,6 +20,7 @@ define('PODUPTIME', microtime(true)); ...@@ -20,6 +20,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
$pod = R::getRow('SELECT id, email FROM pods WHERE domain = ?', [$_domain]); $pod = R::getRow('SELECT id, email FROM pods WHERE domain = ?', [$_domain]);
......
CREATE INDEX idx_clicks ON clicks (domain); CREATE INDEX idx_clicks ON clicks (domain);
UPDATE pods SET status=0 WHERE status = 'Down';
UPDATE pods SET status=1 WHERE status = 'Up';
/*
0 = Down
1 = Up
2 = Recheck
3 = Paused
4 = System Deleted
5 = User Deleted
*/
ALTER TABLE pods ALTER COLUMN status TYPE smallint USING status::smallint;
...@@ -11,13 +11,15 @@ define('PODUPTIME', microtime(true)); ...@@ -11,13 +11,15 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
$softwares = [ $softwares = [
'diaspora' => ['url' => 'https://raw.githubusercontent.com/diaspora/diaspora/master/config/defaults.yml', 'regex' => '/number:.*"(.*)"/'], 'diaspora' => ['url' => 'https://raw.githubusercontent.com/diaspora/diaspora/master/config/defaults.yml', 'regex' => '/number:.*"(.*)"/'],
'friendica' => ['url' => 'https://raw.githubusercontent.com/friendica/friendica/master/boot.php', 'regex' => '/define.*\'FRIENDICA_VERSION\'.*\'(.*)\'/'], 'friendica' => ['url' => 'https://raw.githubusercontent.com/friendica/friendica/master/boot.php', 'regex' => '/define.*\'FRIENDICA_VERSION\'.*\'(.*)\'/'],
'redmatrix' => ['url' => 'https://raw.githubusercontent.com/redmatrix/hubzilla/master/boot.php', 'regex' => '/define.*\'STD_VERSION\'.*\'(.*)\'/'], 'redmatrix' => ['url' => 'https://raw.githubusercontent.com/redmatrix/hubzilla/master/boot.php', 'regex' => '/define.*\'STD_VERSION\'.*\'(.*)\'/'],
'socialhome' => ['url' => 'https://raw.githubusercontent.com/jaywink/socialhome/master/bower.json', 'regex' => '/version":.*"(.*)"/'], 'socialhome' => ['url' => 'https://raw.githubusercontent.com/jaywink/socialhome/master/socialhome/__init__.py', 'regex' => '/__version__ =.*"(.*)"/'],
'social-relay' => ['url' => 'https://raw.githubusercontent.com/jaywink/social-relay/master/social_relay/config.py', 'regex' => '/VERSION.*"(.*)"/'], 'social-relay' => ['url' => 'https://raw.githubusercontent.com/jaywink/social-relay/master/social_relay/config.py', 'regex' => '/VERSION.*"(.*)"/'],
'ganggo' => ['url' => 'https://raw.githubusercontent.com/ganggo/ganggo/master/package.json', 'regex' => '/"version": "(.*)"/'],
]; ];
foreach ($softwares as $software => $details) { foreach ($softwares as $software => $details) {
......
...@@ -19,10 +19,11 @@ define('PODUPTIME', microtime(true)); ...@@ -19,10 +19,11 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
$sql = ' $sql = '
SELECT domain, score, date_created, adminrating, weight, hidden, podmin_notify, email SELECT domain, score, date_created, adminrating, weight, hidden, podmin_notify, email, masterversion, shortversion
FROM pods FROM pods
'; ';
...@@ -31,7 +32,8 @@ try { ...@@ -31,7 +32,8 @@ try {
$sql .= ' WHERE domain = ?'; $sql .= ' WHERE domain = ?';
$pods = R::getAll($sql, [$_domain]); $pods = R::getAll($sql, [$_domain]);
} elseif (PHP_SAPI === 'cli') { } elseif (PHP_SAPI === 'cli') {
$pods = R::getAll($sql); $sql .= ' WHERE status < ?';
$pods = R::getAll($sql, [PodStatus::Paused]);
} }
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
...@@ -46,6 +48,8 @@ foreach ($pods as $pod) { ...@@ -46,6 +48,8 @@ foreach ($pods as $pod) {
$hiddennow = $pod['hidden']; $hiddennow = $pod['hidden'];
$email = $pod['email']; $email = $pod['email'];
$notify = $pod['podmin_notify']; $notify = $pod['podmin_notify'];
$masterv = $pod['masterversion'];
$shortv = $pod['shortversion'];
try { try {
$ratings = R::getAll(' $ratings = R::getAll('
...@@ -125,7 +129,7 @@ foreach ($pods as $pod) { ...@@ -125,7 +129,7 @@ foreach ($pods as $pod) {
} }
if ($jsonssl !== null) { if ($jsonssl !== null) {
$status = 'Up'; $status = PodStatus::Up;
try { try {
$c = R::dispense('checks'); $c = R::dispense('checks');
...@@ -158,7 +162,7 @@ foreach ($pods as $pod) { ...@@ -158,7 +162,7 @@ foreach ($pods as $pod) {
$score -= 1; $score -= 1;
$shortversion = '0.error'; $shortversion = '0.error';
$status = 'Down'; $status = PodStatus::Down;
} }
_debug('Version code', $shortversion); _debug('Version code', $shortversion);
...@@ -228,6 +232,11 @@ foreach ($pods as $pod) { ...@@ -228,6 +232,11 @@ foreach ($pods as $pod) {
} }
_debug('Masterversion', $masterversion); _debug('Masterversion', $masterversion);
$masterversioncheck = explode('.',$masterversion);
$shortversioncheck = explode('.',$shortversion);
if (($masterversioncheck[1] - $shortversioncheck[1]) > 1) {
_debug('Outdated', 'Yes');$score -= 2;
}
$hidden = $score <= 70; $hidden = $score <= 70;
_debug('Hidden', $hidden ? 'yes' : 'no'); _debug('Hidden', $hidden ? 'yes' : 'no');
...@@ -244,6 +253,9 @@ foreach ($pods as $pod) { ...@@ -244,6 +253,9 @@ foreach ($pods as $pod) {
$score = 100; $score = 100;
} elseif ($score < 0) { } elseif ($score < 0) {
$score = 0; $score = 0;
if ($masterv <> $shortv) {
$status = PodStatus::System_Deleted;
}
} }
_debug('Score', $score); _debug('Score', $score);
$weightedscore = ($uptime + $score - (10 - $weight)) / 2; $weightedscore = ($uptime + $score - (10 - $weight)) / 2;
...@@ -289,11 +301,6 @@ foreach ($pods as $pod) { ...@@ -289,11 +301,6 @@ foreach ($pods as $pod) {
$p['dnssec'] = $dnssec; $p['dnssec'] = $dnssec;
$p['sslexpire'] = $sslexpire; $p['sslexpire'] = $sslexpire;
// @todo Temporary fix! https://github.com/gabordemooij/redbean/issues/547
foreach ($p->getProperties() as $key => $value) {
$p[$key] = $value;
}
R::store($p); R::store($p);
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
......
...@@ -20,6 +20,7 @@ define('PODUPTIME', microtime(true)); ...@@ -20,6 +20,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
$r = R::dispense('rating_comments'); $r = R::dispense('rating_comments');
......
...@@ -27,7 +27,7 @@ CREATE TABLE pods ( ...@@ -27,7 +27,7 @@ CREATE TABLE pods (
active_users_monthly int, active_users_monthly int,
local_posts int, local_posts int,
uptime_alltime numeric(5,2), uptime_alltime numeric(5,2),
status text, status smallint,
latency smallint, latency smallint,
service_facebook boolean, service_facebook boolean,
service_twitter boolean, service_twitter boolean,
......
...@@ -14,6 +14,7 @@ define('PODUPTIME', microtime(true)); ...@@ -14,6 +14,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
if ($_domain) { if ($_domain) {
......
...@@ -10,6 +10,7 @@ define('PODUPTIME', microtime(true)); ...@@ -10,6 +10,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
// CloudFlare country code pull. // CloudFlare country code pull.
$country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? ''; $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? '';
...@@ -21,6 +22,7 @@ $cleanup = isset($_GET['cleanup']); ...@@ -21,6 +22,7 @@ $cleanup = isset($_GET['cleanup']);
$statsview = isset($_GET['statsview']); $statsview = isset($_GET['statsview']);
$podmin = isset($_GET['podmin']); $podmin = isset($_GET['podmin']);
$podminedit = isset($_GET['podminedit']); $podminedit = isset($_GET['podminedit']);
$edit = isset($_GET['edit']);
$simpleview = !($detailedview || $mapview || $cleanup || $podmin || $podminedit || $statsview); $simpleview = !($detailedview || $mapview || $cleanup || $podmin || $podminedit || $statsview);
?> ?>
<!doctype html> <!doctype html>
...@@ -129,6 +131,8 @@ $navs = [ ...@@ -129,6 +131,8 @@ $navs = [
include_once __DIR__ . '/podmin.php'; include_once __DIR__ . '/podmin.php';
} elseif ($podminedit) { } elseif ($podminedit) {
include_once __DIR__ . '/podminedit.php'; include_once __DIR__ . '/podminedit.php';
} elseif ($edit) {
include_once __DIR__ . '/db/edit.php';
} elseif ($cleanup) { } elseif ($cleanup) {
include_once __DIR__ . '/cleanup.php'; include_once __DIR__ . '/cleanup.php';
} else { } else {
......
<?php
use CommerceGuys\Enum\AbstractEnum;
final class PodStatus extends AbstractEnum
{
const Down = 0;
const Up = 1;
const Recheck = 2;
const Paused = 3;
const System_Deleted = 4;
const User_Deleted = 5;
}
...@@ -13,6 +13,7 @@ define('PODUPTIME', microtime(true)); ...@@ -13,6 +13,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection. // Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true); R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
R::testConnection() || die('Error in DB connection'); R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
$sql = " $sql = "
SELECT SELECT
...@@ -22,21 +23,10 @@ $sql = " ...@@ -22,21 +23,10 @@ $sql = "
round(avg(online::INT),2)*100 AS uptime, round(avg(online::INT),2)*100 AS uptime,
round(avg(latency),2) * 1000 AS latency, round(avg(latenc