Unverified Commit 6da68df9 authored by David Morley's avatar David Morley Committed by GitHub

use API for pulls of master version - enforce some security (#159)

* use API for pulls of master version - enforce some security

* add migration

* fix podcrawler

* fix podcrawler

* add diasp.org json active pods
update composer to 7.2 php

* add diasp.org json active pods
update composer to 7.2 php

* remove wizard junk from this branch

* remove wizard junk from this branch

* Revamp masterversionpull fixes (#163)

* Use PHP_SAPI constant to save function call.

* Fix podcrawler to properly filter out only pods that support the diaspora protocol.

* Fix DB write logic and clean up pull.php code a bit.

* Use the best nodeinfo available

* Use the best nodeinfo available, need to default to 1.0

* same order each time vs random

* fix link

* little more universality

* freindica version edit, support as best as can

* using jasonrobinson.me as an example last updated at 2018-04-12 17:23:41.55 is now hidden, giving more time padding for dev branches.
parent 0dd92196
# 2x+
## Podmins
* Can no longer access db/pull.php to test their pod, they can however get to a debug screen from the edit pod area
## DB
* Add development and release dates to masterversions table https://github.com/diasporg/Poduptime/issues/143
## Cleanup
* Use the git API for release versions, check development releases on pods https://github.com/diasporg/Poduptime/issues/143
* Forbid access to files that should be cli only https://github.com/diasporg/Poduptime/issues/152
## End Users
* Show version and update in full view cleaner https://github.com/diasporg/Poduptime/issues/143
* Edit will send to email on file and be less delay, runner of site does not really have anyway to verify email address
# 2.2.0
## Podmins
......
......@@ -38,6 +38,7 @@ touch add.log in location you configured in config.php
run `db/pull.sh` manually or with cron to update your data
run `db/pull.sh debug` to debug output
run `db/pull.sh sqldebug` to debug sql
run `db/pull.sh develop` to run without email alerts to end users
run `db/pull.sh Check_System_Deleted` to re-check system deleted pods as needed
......
{
"config": {
"platform": {
"php": "7.2"
}
},
"require": {
"noplanman/xec": "0.1.0",
"gabordemooij/redbean": "^5.0",
"jaybizzle/crawler-detect" :"1.*",
"commerceguys/enum": "^1.0"
"commerceguys/enum": "^1.0",
"php" : "^7.2"
},
"autoload": {
"classmap": ["lib"]
......
{
"_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": "b753491dc03e2084e9587d0bbafad98c",
"content-hash": "e5874c9bc9ad133f4e558cf61972ae67",
"packages": [
{
"name": "commerceguys/enum",
......@@ -87,23 +87,23 @@
},
{
"name": "jaybizzle/crawler-detect",
"version": "v1.2.62",
"version": "v1.2.63",
"source": {
"type": "git",
"url": "https://github.com/JayBizzle/Crawler-Detect.git",
"reference": "f9767578e00f87a081835b49adc7c71074a5b46c"
"reference": "3566bc69d0839ab2dfd739a660b00f25a6f02031"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/f9767578e00f87a081835b49adc7c71074a5b46c",
"reference": "f9767578e00f87a081835b49adc7c71074a5b46c",
"url": "https://api.github.com/repos/JayBizzle/Crawler-Detect/zipball/3566bc69d0839ab2dfd739a660b00f25a6f02031",
"reference": "3566bc69d0839ab2dfd739a660b00f25a6f02031",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.8.*",
"phpunit/phpunit": "^4.8|^5.5|^6.5",
"satooshi/php-coveralls": "1.*"
},
"type": "library",
......@@ -132,7 +132,7 @@
"crawlerdetect",
"php crawler detect"
],
"time": "2018-03-27T18:25:43+00:00"
"time": "2018-05-21T19:56:44+00:00"
},
{
"name": "noplanman/xec",
......@@ -194,5 +194,8 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
"platform-dev": [],
"platform-overrides": {
"php": "7.2"
}
}
......@@ -26,7 +26,6 @@ body {
.main {
padding: 20px;
}
.placeholders {
margin-bottom: 30px;
text-align: center;
......@@ -42,59 +41,63 @@ body {
display: inline-block;
}
.rating {
font-size:9px;
font-size:9px;
}
.tfont {
font-size:12px;
font-size:12px;
}
.smlogo {
width: 16px;
height: 16px;
background: url('/images/smlogo.png') 0 0;
display: inline-block;
margin: 0 2px;
width: 16px;
height: 16px;
background: url('/images/smlogo.png') 0 0;
display: inline-block;
margin: 0 2px;
}
.smlogo-twitter {
background-position: 0 -776px;
background-position: 0 -776px;
}
.smlogo-facebook {
background-position: 0 -824px;
background-position: 0 -824px;
}
.smlogo-tumblr {
background-position: 0 -792px;
background-position: 0 -792px;
}
.smlogo-wordpress {
background-position: 0 -656px;
background-position: 0 -656px;
}
.smlogo-xmpp {
background: none;
background: none;
}
.smlogo-xmpp img {
vertical-align: unset;
vertical-align: unset;
}
#map {
height: 580px;
}
#map { height: 580px; }
.mycluster {
width: 35px;
height: 35px;
background-color: blue;
text-align: left;
font-size: 17px;
background: url('/bower_components/leaflet/dist/images/marker-icon-2x.png') repeat-y right bottom;
background-size: 25px 37px;
width: 35px;
height: 35px;
background-color: blue;
text-align: left;
font-size: 17px;
background: url('/bower_components/leaflet/dist/images/marker-icon-2x.png') repeat-y right bottom;
background-size: 25px 37px;
}
.icon {
color: red;
color: red;
}
table {
empty-cells: show;
empty-cells: show;
}
#facebox {
z-index: 1000 !important;
z-index: 1000 !important;
}
#facebox .content {
width: 800px !important;
width: 800px !important;
}
.tablesorter-header {
background-size: 10px 15px !important;
background-size: 10px 15px !important;
}
.modal-xlg {
max-width: 92%;
}
......@@ -64,7 +64,7 @@ foreach ($pods as $pod) {
}
echo <<<EOF
<form action="edit.php" method="get">
<form action="/?edit" method="get">
<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>
......@@ -82,8 +82,14 @@ EOF;
}
}
if ($infos = json_decode(file_get_contents('https://' . $_domain . '/.well-known/nodeinfo'), true)) {
$link = max($infos['links'])['href'];
} else {
$link= 'https://' . $_domain . '/.well-known/nodeinfo';
}
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, 'https://' . $_domain . '/nodeinfo/1.0');
curl_setopt($chss, CURLOPT_URL, $link);
curl_setopt($chss, CURLOPT_POST, 0);
curl_setopt($chss, CURLOPT_HEADER, 0);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5);
......@@ -118,19 +124,17 @@ if (stristr($outputssl, 'openRegistrations')) {
$message_lines = [
'https://' . $_SERVER['HTTP_HOST'],
'Pod: https://' . $_SERVER['HTTP_HOST'] . '/db/pull.php?debug=1&domain=' . $_domain,
'',
'Your pod will not show up right away, as it needs to pass a few checks first.',
'Your pod ' . $_domain . ' will not show up right away, as it needs to pass a few checks first.',
'Give it a few hours!',
];
@mail($to, $subject, implode("\r\n", $message_lines), implode("\r\n", $headers));
}
echo 'Data successfully inserted! Your pod will be reviewed and live on the list in a few hours!';
echo 'Data successfully inserted! Your pod will be checked and live on the list in a few hours!';
} else {
$log->lwrite('Could not validate your pod, check your setup! ' . $_domain);
echo 'Could not validate your pod, check your setup!<br>Take a look at <a href="https://' . $_domain . '/nodeinfo/1.0">your /nodeinfo</a>';
echo 'Could not validate your pod, check your setup!<br>Take a look at <a href="' . $link . '">your /nodeinfo</a>';
}
$log->lclose();
<?php
if (PHP_SAPI !== 'cli') {
header('HTTP/1.0 403 Forbidden');
exit;
}
require_once __DIR__ . '/../config.php';
$keep = (60 * 60 * 6) * 1;
......
......@@ -120,4 +120,24 @@ if ('save' === $_action) {
<input type="hidden" name="token" value="<?php echo $_token; ?>">
<input type="submit" name="action" value="unpause">
</form>
<button type="button" class="openBtn" value="<?php echo $_domain; ?>">Do a debug test pull of your pod</button>
<!-- Modal -->
<div class="modal fade" id="podpull" role="dialog">
<div class="modal-dialog modal-xlg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Pod debug data</h4>
</div>
<div class="modal-body">
Loading.....
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
......@@ -38,16 +38,16 @@ if ($_email) {
$subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST'];
$headers[] = 'Bcc: ' . $adminemail;
$expire = time() + 2700;
$output = 'Link sent to your email';
$output = 'Link sent to your email.';
} elseif (!$pod['email']) {
die('domain is registered but no email associated, to add an email use the add a pod feature');
die('Domain is registered but no email associated, to add an email use the add a pod feature.');
} else {
$to = $adminemail;
$subject = 'FORWARD REQUEST: Temporary edit key for ' . $_SERVER['HTTP_HOST'];
$message_lines[] = 'User trying to edit pod without email address.';
$to = $pod['email'];
$subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST'];
$message_lines[] = 'Looks like you did not enter your email address, be sure to update it if you forgot the one we have for you.';
$message_lines[] = 'Email found: ' . $pod['email'];
$expire = time() + 9700;
$output = 'Link sent to administrator to review and verify, if approved they will forward the edit key to you.';
$expire = time() + 2700;
$output = 'Link sent to email we have for this pod on file.';
}
try {
......
ALTER TABLE masterversions ADD devlastcommit timestamp;
ALTER TABLE masterversions ADD releasedate timestamp;
<?php
if (PHP_SAPI !== 'cli') {
header('HTTP/1.0 403 Forbidden');
exit;
}
use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.php';
......
<?php
if (php_sapi_name() == "cli") {
$json = json_decode(file_get_contents('https://the-federation.info/pods.json'));
if ($json) {
foreach ($json->pods ?? [] as $poddata) {
echo exec("php-cgi add.php domain={$poddata->host}") . "\r\n";
if (PHP_SAPI !== 'cli') {
header('HTTP/1.0 403 Forbidden');
exit;
}
use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.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');
R::usePartialBeans(true);
try {
$sql = '
SELECT domain, status
FROM pods
';
$pods = R::getAll($sql);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
//get all existing pod domains
$existingpods = array_column($pods, 'domain');
$foundpods = [];
//pulling all nodes for now
if ($pods = json_decode(file_get_contents('https://the-federation.info/graphql?query=%7Bnodes%7Bhost%20platform%7Bname%7Dprotocols%7Bname%7D%7D%7D&raw'), true)) {
foreach ($pods['data']['nodes'] ?? [] as $poddata) {
$protocols = array_column($poddata['protocols'] ?? [], 'name');
//limiting to diaspora compatible for now
if (in_array('diaspora', $protocols, true)) {
$foundpods[] = $poddata['host'];
}
}
} else {
header('HTTP/1.0 403 Forbidden');
}
if ($pods = json_decode(file_get_contents('https://diasp.org/pods.json'), true)) {
foreach ($pods ?? [] as $poddata) {
$foundpods[] = $poddata['host'];
}
}
$results = array_diff($foundpods, $existingpods);
foreach ($results as $result) {
echo exec("php-cgi add.php domain={$result}") . "\r\n";
}
<?php
//* Copyright (c) 2017, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */
if (PHP_SAPI !== 'cli') {
header('HTTP/1.0 403 Forbidden');
exit;
}
use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.php';
......@@ -14,32 +19,70 @@ R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
$softwares = [
'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\'.*\'(.*)\'/'],
'redmatrix' => ['url' => 'https://raw.githubusercontent.com/redmatrix/hubzilla/master/boot.php', 'regex' => '/define.*\'STD_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.*"(.*)"/'],
'ganggo' => ['url' => 'https://raw.githubusercontent.com/ganggo/ganggo/master/package.json', 'regex' => '/"version": "(.*)"/'],
'diaspora' => ['repo' => 'diaspora/diaspora', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'friendica' => ['repo' => 'friendica/friendica', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
'hubzilla' => ['repo' => 'hubzilla%2fcore', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'],
'pleroma' => ['repo' => 'pleroma%2fpleroma', 'gitsite' => 'git.pleroma.social', 'gittype' => 'gitlab', 'devbranch' => 'develop'],
'socialhome' => ['repo' => 'jaywink/socialhome', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
'social-relay' => ['repo' => 'jaywink/social-relay', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
'ganggo' => ['repo' => 'ganggo/ganggo', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => ''],
];
$opts = [
'http' => ['method' => 'GET', 'header' => ['User-Agent: Poduptime']]
];
foreach ($softwares as $software => $details) {
$mv = curl_init();
curl_setopt($mv, CURLOPT_URL, $details['url']);
curl_setopt($mv, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($mv, CURLOPT_RETURNTRANSFER, 1);
$outputmv = curl_exec($mv);
curl_close($mv);
if ($masterversion = preg_match($details['regex'], $outputmv, $version) ? $version[1] : '') {
try {
$m = R::dispense('masterversions');
$m['software'] = $software;
$m['version'] = $masterversion;
R::store($m);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
if ($details['gittype'] == 'github') {
$context = stream_context_create($opts);
$releasejson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/repos/' . $details["repo"] . '/releases/latest', false, $context));
if ($details["devbranch"]) {
$commitjson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/repos/' . $details["repo"] . '/commits/' . $details["devbranch"], false, $context));
} else {
$commitjson = '';
}
if ($masterversion = $releasejson->tag_name ? str_replace('v', '', $releasejson->tag_name) : '') {
try {
$m = R::dispense('masterversions');
$m['software'] = $software;
$m['version'] = $masterversion;
if ($releasedate = $releasejson ? $releasejson->published_at : '') {
$m['releasedate'] = $releasedate;
}
if ($devlastcommit = $commitjson ? $commitjson->commit->author->date : '') {
$m['devlastcommit'] = $devlastcommit;
}
R::store($m);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
}
} elseif ($details['gittype'] == 'gitlab') {
$context = stream_context_create($opts);
$releasejson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/api/v4/projects/' . $details["repo"] . '/repository/tags', false, $context));
if ($details["devbranch"]) {
$commitjson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/api/v4/projects/' . $details["repo"] . '/repository/commits/' . $details["devbranch"], false, $context));
} else {
$commitjson = '';
}
if ($masterversion = $releasejson[0]->name ? str_replace('v', '', $releasejson[0]->name) : '') {
try {
$m = R::dispense('masterversions');
$m['software'] = $software;
$m['version'] = $masterversion;
if ($releasedate = $releasejson[0] ? $releasejson[0]->commit->created_at : '') {
$m['releasedate'] = $releasedate;
}
if ($devlastcommit = $commitjson ? $commitjson->created_at : '') {
$m['devlastcommit'] = $devlastcommit;
}
R::store($m);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
}
}
}
printf('%s:%s ', $software, $masterversion ?: 'n/a');
printf('%s:%s:%s ', $software, $masterversion, $devlastcommit ?: 'n/a');
}
<?php
//* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */
if ($_SERVER['SERVER_ADDR'] !== $_SERVER['REMOTE_ADDR']) {
header('HTTP/1.0 403 Forbidden');
exit;
}
use RedBeanPHP\R;
$debug = isset($_GET['debug']) || (isset($argv) && in_array('debug', $argv, true));
$newline = PHP_SAPI === 'cli' ? "\n" : '<br>';
$debug = isset($_GET['debug']) || (isset($argv) && in_array('debug', $argv, true));
$sqldebug = isset($_GET['sqldebug']) || (isset($argv) && in_array('sqldebug', $argv, true));
$write = !(isset($_GET['nowrite']) || (isset($argv) && in_array('nowrite', $argv, true)));
$newline = PHP_SAPI === 'cli' ? "\n\n" : '<br><br>';
$_domain = $_GET['domain'] ?? null;
......@@ -18,6 +25,7 @@ define('PODUPTIME', microtime(true));
// Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
$sqldebug && R::fancyDebug(true);
R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
......@@ -83,8 +91,14 @@ foreach ($pods as $pod) {
$admin_rating = -1;
}
if ($infos = json_decode(file_get_contents('https://' . $domain . '/.well-known/nodeinfo'), true)) {
$link = max($infos['links'])['href'];
} else {
$link = 'https://' . $domain . '/nodeinfo/1.0';
}
$chss = curl_init();
curl_setopt($chss, CURLOPT_URL, 'https://' . $domain . '/nodeinfo/1.0');
curl_setopt($chss, CURLOPT_URL, $link);
curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($chss, CURLOPT_TIMEOUT, 30);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
......@@ -109,8 +123,8 @@ foreach ($pods as $pod) {
$jsonssl = json_decode($outputssl);
$xdver = $jsonssl->software->version ?? 0;
$dverr = explode('-', trim($xdver));
$shortversion = $dverr[0];
preg_match_all('((?:\d(.|-)?)+(\.|-)\d+\.*)', $xdver, $dverr);
$shortversion = $dverr[0][0];
$signup = ($jsonssl->openRegistrations ?? false) === true;
$softwarename = $jsonssl->software->name ?? 'unknown';
$name = $jsonssl->metadata->nodeName ?? $softwarename;
......@@ -131,7 +145,7 @@ foreach ($pods as $pod) {
$service_twitter = in_array('twitter', $jsonssl->services->outbound, true);
$service_tumblr = in_array('tumblr', $jsonssl->services->outbound, true);
$service_wordpress = in_array('wordpress', $jsonssl->services->outbound, true);
}
}
}
if ($jsonssl !== null) {
......@@ -145,11 +159,15 @@ foreach ($pods as $pod) {
$c['local_posts'] = $local_posts;
$c['comment_counts'] = $comment_counts;
$c['shortversion'] = $shortversion;
R::store($c);
if ($write) {
R::store($c);
} else {
echo $c;
}
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
$status = PodStatus::Up;
}
......@@ -162,7 +180,11 @@ foreach ($pods as $pod) {
$c['online'] = false;
$c['error'] = $outputsslerror;
$c['latency'] = $latency;
R::store($c);
if ($write) {
R::store($c);
} else {
echo $c;
}
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
......@@ -228,19 +250,47 @@ foreach ($pods as $pod) {
_debug('Uptime', $uptime);
try {
$masterversion = R::getCell('SELECT version FROM masterversions WHERE software = ? ORDER BY id DESC LIMIT 1', [$softwarename]);
$masterdata = R::getRow('SELECT version, devlastcommit, releasedate FROM masterversions WHERE software = ? ORDER BY id DESC LIMIT 1', [$softwarename]);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
$masterversion = $masterdata['version'];
_debug('Masterversion', $masterversion);
$masterversioncheck = explode('.',$masterversion);
$shortversioncheck = explode('.',$shortversion);
if (($masterversioncheck[1] - $shortversioncheck[1]) > 1 && strpos($xdver,'dev') === false) {
//dev search added to address frendica using very odd versioning for dev code, we should look to pull dev versions and use them rather than assume dev is always ahead of prod code
_debug('Days since master code release', date_diff((new DateTime($masterdata['releasedate'])),(new DateTime()))->format('%d'));
try {
$lastpodupdates = R::getRow('SELECT DISTINCT ON (shortversion) shortversion, date_checked FROM checks WHERE domain = ? AND shortversion IS NOT NULL ORDER BY shortversion DESC LIMIT 1', [$domain]);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
$devlastdays = $masterdata['devlastcommit'] ? date_diff((new DateTime($masterdata['devlastcommit'])),(new DateTime()))->format('%a') : 30;//tmp//if no dev branch then what?
_debug('Dev git last commit was ', $devlastdays);
if (strpos($xdver,'dev') !== false || strpos($xdver,'rc') !== false || $shortversioncheck > $masterversioncheck) {
//tmp//if pod is on the development branch - see when you last updated your pod and when the last commit was made to dev branch - if the repo is active and your not updating every 120 days why are you on dev branch?
$updategap = date_diff((new DateTime($lastpodupdates['date_checked'])),(new DateTime($masterdata['devlastcommit'])))->format('%a');
if ($updategap + $devlastdays > 130) {
_debug('Outdated', 'Yes');$score -= 2;
}
} elseif (($masterversioncheck[1] - $shortversioncheck[1]) > 1) {
///tmp/If pod is two versions off AND it's been more than 60 days since that release came out AND your on the master production branch
_debug('Outdated', 'Yes');$score -= 2;
$updategap = date_diff((new DateTime($lastpodupdates['date_checked'])),(new DateTime($masterdata['releasedate'])))->format('%a');
} elseif ($updategap - date_diff((new DateTime($masterdata['releasedate'])),(new DateTime()))->format('%a') > 90) {
_debug('Outdated', 'Yes');$score -= 2;
$updategap = date_diff((new DateTime($lastpodupdates['date_checked'])),(new DateTime($masterdata['releasedate'])))->format('%a');
} else {
$updategap = date_diff((new DateTime($lastpodupdates['date_checked'])),(new DateTime($masterdata['releasedate'])))->format('%a');
}
_debug('Pod code was updated after ', $updategap);
$hidden = $score <= 70;
_debug('Hidden', $hidden ? 'yes' : 'no');
......@@ -306,7 +356,11 @@ foreach ($pods as $pod) {
$p['softwarename'] = $softwarename;
}
R::store($p);
if ($write) {
R::store($p);
} else {
echo $p;
}
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
......
......@@ -94,6 +94,8 @@ CREATE TABLE masterversions (
id serial8 UNIQUE PRIMARY KEY,
software text,
version text,
devlastcommit timestamp,
releasedate timestamp,
date_checked timestamp DEFAULT current_timestamp
);
......
......@@ -2,13 +2,15 @@ If new install import tables.sql and do not perform migrations
If upgrading migrations are:
v1.0 -> v2.0 = migration00001.sql
v1.0 -> v2.0 = migration00001.sql
v2.0 -> v2.1 = migration00002.sql
v2.0 -> v2.1 = migration00002.sql
v2.1 -> v2.1.3 = migration00003.sql
v2.1 -> v2.1.3 = migration00003.sql
v2.1.4 -> v2.x = migration00004.sql
v2.1.4 -> v2.2 = migration00004.sql
v2.2 -> v2.3 = migrations00005.sql
To support the original apiv1 you should import:
pods_apiv1.sql
......
......@@ -116,7 +116,7 @@ $navs = [
</p>
</div>
<div class="main col-md-10 col-lg-11 offset-md-3 offset-lg-1">
<a href="go.php" class="btn btn-sm btn-success">Confused? Auto pick a pod for you.</a>
<a href="go.php" class="btn btn-sm btn-outline-warning">Confused on how to find a pod? Auto Pick </a>
<div class="row placeholders">
</div>
<?php
......@@ -141,12 +141,12 @@ $navs = [
</div>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/tablesorter/dist/js/jquery.tablesorter.min.js"></script>
<script src="js/podup.js"></script>
<script src="bower_components/tether/dist/js/tether.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/facebox/src/facebox.js"></script>
<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<script src="bower_components/chart.js/dist/Chart.min.js"></script>
<?php $statsview && include_once __DIR__ . '/statsviewjs.php'; ?>
<script src="js/podup.js"></script>
</body>
</html>
......@@ -10,5 +10,10 @@ $.facebox.settings.loadingImage = 'bower_components/facebox/src/loading.gif'
$('.popover-dismiss').popover({
trigger: 'focus'
})
$('.openBtn').on('click',function(){
$('#podpull').modal({show:true});
$('.modal-body').load('/db/pull.php?debug=1&nowrite=1&domain='+$(this).val(),function(){
});
});
});
......@@ -68,7 +68,7 @@ try {
} else {
$classver = 'black';
}
echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $pod['shortversion'] . ' master version is: ' . $pod['masterversion'] . '" data-toggle="tooltip" data-placement="bottom">' . $version . '</div></td>';
echo '<td class="' . $classver . '"><div title="' . $pre . ' version: ' . $pod['shortversion'] . ' master version is: ' . ($pod['masterversion'] ? $pod['masterversion'] : 'unknown') . '" data-toggle="tooltip" data-placement="bottom">' . $version . '</div></td>';
echo '<td>' . $pod['softwarename'] . '</td>';
echo '<td><a rel="facebox" href="podstat.php?domain=' . $pod['domain'] . '">' . ($pod['uptime_alltime'] > 0 ? $pod['uptime_alltime'] . '%' : '') . '</a></td>';