Commit 27f94b2e authored by David Morley's avatar David Morley Committed by GitHub

Merge pull request #93 from diasporg/fixes2

few misses
parents 0095c9f0 b99ff749
......@@ -71,25 +71,26 @@ if (stristr($outputssl, 'openRegistrations')) {
echo 'Your pod has ssl and is valid<br>';
$publickey = md5(uniqid($domain, true));
$sql = 'INSERT INTO pods (domain, email, terms, publickey) VALUES ($1, $2, $3, $4, $5)';
$sql = 'INSERT INTO pods (domain, email, terms, publickey) VALUES ($1, $2, $3, $4)';
$result = pg_query_params($dbh, $sql, [$_domain, $_email, $_terms, $publickey]);
$result || die('Error in SQL query: ' . pg_last_error());
$to = $adminemail;
$subject = 'New pod added to ' . $_SERVER['HTTP_HOST'];
$headers = ['From: ' . $_email, 'Reply-To: ' . $_email, 'Cc: ' . $_email];
if ($_email) {
$to = $adminemail;
$subject = 'New pod added to ' . $_SERVER['HTTP_HOST'];
$headers = ['From: ' . $_email, 'Reply-To: ' . $_email, 'Cc: ' . $_email];
$message_lines = [
'https://' . $_SERVER['HTTP_HOST'],
'Stats Url: https://api.uptimerobot.com/getMonitors?format=json&noJsonCallback=1&customUptimeRatio=7-30-60-90&apiKey=' . $_stats_apikey,
'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.',
'Give it a few hours!',
];
@mail($to, $subject, implode("\r\n", $message_lines), implode("\r\n", $headers));
$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.',
'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!';
} else {
......
......@@ -8,7 +8,7 @@ $dbh || die('Error in connection: ' . pg_last_error());
$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\'.*\'(.*)\'/'],
'hubzilla' => ['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\'.*\'(.*)\'/'],
];
foreach ($softwares as $software => $details) {
......
......@@ -4,7 +4,6 @@
$debug = isset($_GET['debug']) || (isset($argv) && in_array('debug', $argv, true));
$newline = PHP_SAPI === 'cli' ? "\n" : '<br>';
// Other parameters.
$_domain = $_GET['domain'] ?? '';
require_once __DIR__ . '/../config.php';
......@@ -70,7 +69,6 @@ while ($row = pg_fetch_assoc($result)) {
_debug('Cert expire date', $sslexpire);
_debug('TTL', $ttl);
//get new json from nodeinfo
$jsonssl = json_decode($outputssl);
if (!$jsonssl) {
......@@ -114,14 +112,22 @@ while ($row = pg_fetch_assoc($result)) {
_debug('Signup Open', $signup);
$ip = dns_get_record($_domain, DNS_A)[0]['ip'] ?? null;
$ipv6 = dns_get_record($_domain, DNS_AAAA)[0]['ipv6'] ?? null;
$iplookup = [];
exec(escapeshellcmd('delv @' . $dnsserver . ' ' . $domain), $iplookup);
if ($iplookup) {
_debug('Iplookup', $iplookup, true);
$dnssec = in_array('; fully validated', $iplookup, true) ?? false;
$iplookupv4 = [];
exec(escapeshellcmd('delv @' . $dnsserver . ' ' . $domain), $iplookupv4);
if ($iplookupv4) {
_debug('Iplookupv4', $iplookupv4, true);
$dnssec = in_array('; fully validated', $iplookupv4, true) ?? false;
$getaonly = array_values(preg_grep('/\s+IN\s+A\s+.*/', $iplookupv4));
preg_match('/A\s(.*)/', $getaonly[0], $aversion);
$ip = trim($aversion[1]);
}
$iplookupv6 = [];
exec(escapeshellcmd('delv @' . $dnsserver . ' ' . $domain . ' AAAA '), $iplookupv6);
if ($iplookupv6) {
_debug('Iplookupv6', $iplookupv6, true);
$getaaaaonly = array_values(preg_grep('/\s+IN\s+AAAA\s+.*/', $iplookupv6));
preg_match('/A\s(.*)/', $getaaaaonly[0], $aaaaversion);
$ipv6 = trim($aaaaversion[1]);
}
$ip || $score -= 2;
......@@ -133,15 +139,14 @@ while ($row = pg_fetch_assoc($result)) {
$country = !empty($location['country_code']) ? iconv('UTF-8', 'UTF-8//IGNORE', $location['country_code']) : null;
$city = !empty($location['city']) ? iconv('UTF-8', 'UTF-8//IGNORE', $location['city']) : null;
$state = !empty($location['region']) ? iconv('UTF-8', 'UTF-8//IGNORE', $location['region']) : null;
$lat = !empty($location['latitude']) ? $location['latitude'] : null;
$long = !empty($location['longitude']) ? $location['longitude'] : null;
$lat = !empty($location['latitude']) ? $location['latitude'] : 0;
$long = !empty($location['longitude']) ? $location['longitude'] : 0;
echo $newline;
$statslastdate = date('Y-m-d H:i:s');
$diff = (new DateTime())->diff(new DateTime($dateadded));
$months = $diff->m + ($diff->y * 12);
$diff = (new DateTime())->diff(new DateTime($dateadded));
$months = $diff->m + ($diff->y * 12);
$responsetime = 0;
$sqlttl = 'SELECT round(avg(ttl) * 1000) AS ttl FROM checks WHERE domain = $1';
......@@ -164,14 +169,12 @@ while ($row = pg_fetch_assoc($result)) {
$hidden = $score <= 70;
_debug('Hidden', $hidden ? 'yes' : 'no');
// lets cap the scores or you can go too high or too low to never be effected by them
if ($score > 100) {
$score = 100;
} elseif ($score < 0) {
$score = 0;
}
$weightedscore = ($uptime + $score + ($active_users_monthly / 19999) - ((10 - $weight) * .12));
//sql it
$timenow = date('Y-m-d H:i:s');
$sql_set = 'UPDATE pods SET secure = $2, hidden = $3, ip = $4, ipv6 = $5, monthsmonitored = $6, uptime_alltime = $7, status = $8, date_laststats = $9, date_updated = $10, responsetime = $11, score = $12, adminrating = $13, country = $14, city = $15, state = $16, lat = $17, long = $18, userrating = $19, shortversion = $20, masterversion = $21, signup = $22, total_users = $23, active_users_halfyear = $24, active_users_monthly = $25, local_posts = $26, name = $27, comment_counts = $28, service_facebook = $29, service_tumblr = $30, service_twitter = $31, service_wordpress = $32, weightedscore = $33, service_xmpp = $34, softwarename = $35, sslvalid = $36, dnssec = $37, sslexpire = $38 WHERE domain = $1';
......
SCRIPT_DIR = "$( cd "$( dirname "$0" )" && pwd )"
TIME = `date +%k`
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
TIME=`date +%k`
if [ -s /tmp/index.google ];then
echo "already running die"
......
......@@ -97,7 +97,7 @@ $numrows = pg_num_rows($result);
$row['service_wordpress'] === 't' && print '<div class="smlogo smlogo-wordpress" title="Publish to WordPress"></div>';
$row['service_xmpp'] === 't' && print '<div class="smlogo smlogo-xmpp"><img src="/images/icon-xmpp.png" width="16" height="16" title="XMPP chat server" alt="XMPP chat server"></div>';
echo '</td>';
echo '<td><a href="https://' . $row['domain'] . $row['terms'] . '">&#128279;</a></td></tr>';
echo '<td>' . ($row['terms'] ? '<a href="https://' . $row['domain'] . $row['terms'] . '">&#128279;</a>' : '&nbsp;') . '</td></tr>';
}
?>
</tbody>
......
<?php
//* Copyright (c) 2011-2016, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */
$debug = 1;
// Other parameters.
$_domain = $_GET['domain'] ?? null;
require_once __DIR__ . '/config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT stats_apikey FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
$apikey = pg_fetch_all($result);
$upti = curl_init();
$key = $apikey[0]['stats_apikey'];
$data = ['all_time_uptime_ratio' => 1, 'format' => 'json', 'custom_uptime_ratios' => '7-30-60-90', 'response_times' => 1, 'response_times_average' => 86400, 'api_key' => $key];
curl_setopt($upti, CURLOPT_URL, 'https://api.uptimerobot.com/v2/getMonitors');
curl_setopt($upti, CURLOPT_HEADER, 0);
curl_setopt($upti, CURLOPT_POST, 1);
curl_setopt($upti, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($upti, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($upti, CURLOPT_CONNECTTIMEOUT, 8);
$uptr = json_decode(curl_exec($upti));
curl_close($upti);
echo '<b>UptimeRobot Json displayed in Human</b><br><br>';
echo 'Name: ' . $uptr->monitors[0]->friendly_name . '<br>';
echo 'Url: ' . $uptr->monitors[0]->url . '<br>';
echo 'Interval: ' . $uptr->monitors[0]->interval . 'ms<br>';
echo 'Uptime: ' . $uptr->monitors[0]->all_time_uptime_ratio . '%<br>';
echo 'Response Time: ' . round($uptr->monitors[0]->average_response_time) . 'ms<br>';
if ($uptr->monitors[0]->status == 2) {
$live = 'Up';
}
if ($uptr->monitors[0]->status == 0) {
$live = 'Paused';
}
if ($uptr->monitors[0]->status == 1) {
$live = 'Not Checked Yet';
}
if ($uptr->monitors[0]->status == 8) {
$live = 'Seems Down';
}
if ($uptr->monitors[0]->status == 9) {
$live = 'Down';
}
echo 'Status: ' . $live;
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