Verified Commit 667696f2 authored by noplanman's avatar noplanman

Better config and application boot script.

parent 94899783
...@@ -15,15 +15,7 @@ $_format = $_GET['format'] ?? ''; ...@@ -15,15 +15,7 @@ $_format = $_GET['format'] ?? '';
$_method = $_GET['method'] ?? ''; $_method = $_GET['method'] ?? '';
$_callback = $_GET['callback'] ?? ''; $_callback = $_GET['callback'] ?? '';
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/boot.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);
if ($_format === 'georss') { if ($_format === 'georss') {
echo <<<EOF echo <<<EOF
......
<?php
use RedBeanPHP\R;
require_once __DIR__ . '/vendor/autoload.php';
function c($param = null, $default = null)
{
static $config;
if ($config === null) {
$config = require __DIR__ . '/config.php';
}
if ($param === null) {
return $config;
}
if (array_key_exists($param, $config)) {
return $config[$param];
}
return $default;
}
define('PODUPTIME', microtime(true));
// Set up global DB connection.
R::setup('pgsql:host=' . c('pghost') . ';dbname=' . c('pgdb'), c('pguser'), c('pgpass'), true);
R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
...@@ -4,38 +4,43 @@ ...@@ -4,38 +4,43 @@
* Config for Poduptime. * Config for Poduptime.
*/ */
//backup directory - full dir path return [
$backup_dir = __DIR__ . '/backup'; //backup directory - full dir path
'backup_dir' => __DIR__ . '/backup',
//log directory - full dir path //log directory - full dir path
$log_dir = __DIR__ . '/log'; 'log_dir' => __DIR__ . '/log',
//location of pg dump - full dir path //location of pg dump - full dir path
$pg_dump_dir = '/usr/bin'; 'pg_dump_dir' => '/usr/bin',
//db host //db host
$pghost = 'localhost'; 'pghost' => 'localhost',
//db username //db port
$pguser = ''; 'pgport' => 5432,
//db password //db username
$pgpass = ''; 'pguser' => '',
//db name //db password
$pgdb = ''; 'pgpass' => '',
//admin email for forms //db name
$adminemail = ''; 'pgdb' => '',
//DNS server for dnssec testing. 1.1.1.1 tests the best //admin email for forms
$dnsserver = ''; 'adminemail' => '',
//CA for curl to use - full file path (pull.sh will update this monthly) //DNS server for dnssec testing. 1.1.1.1 tests the best
$cafullpath = ''; 'dnsserver' => '',
//Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/ //CA for curl to use - full file path (pull.sh will update this monthly)
$mapboxkey = ''; 'cafullpath' => '',
//Geolite2-city database file in mmdb format - full file path (pull.sh will update this monthly) //Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/
$geoip2db = ''; 'mapboxkey' => '',
//Geolite2-city database file in mmdb format - full file path (pull.sh will update this monthly)
'geoip2db' => '',
];
...@@ -8,17 +8,7 @@ declare(strict_types=1); ...@@ -8,17 +8,7 @@ declare(strict_types=1);
use RedBeanPHP\R; use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.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);
if (!($_domain = $_GET['domain'] ?? null)) { if (!($_domain = $_GET['domain'] ?? null)) {
die('no pod domain given'); die('no pod domain given');
...@@ -126,7 +116,7 @@ if (!$stop) { ...@@ -126,7 +116,7 @@ if (!$stop) {
} }
if ($_email) { if ($_email) {
$to = $adminemail; $to = c('adminemail');
$subject = 'New pod added to ' . $_SERVER['HTTP_HOST']; $subject = 'New pod added to ' . $_SERVER['HTTP_HOST'];
$headers = ['From: ' . $_email, 'Reply-To: ' . $_email, 'Cc: ' . $_email]; $headers = ['From: ' . $_email, 'Reply-To: ' . $_email, 'Cc: ' . $_email];
...@@ -144,4 +134,4 @@ if (!$stop) { ...@@ -144,4 +134,4 @@ if (!$stop) {
} else { } else {
echo 'Could not validate your pod, check your setup!<br>Take a look at <a href="' . $link . '">your /nodeinfo</a>'; echo 'Could not validate your pod, check your setup!<br>Take a look at <a href="' . $link . '">your /nodeinfo</a>';
} }
} }
\ No newline at end of file
...@@ -15,15 +15,7 @@ use RedBeanPHP\R; ...@@ -15,15 +15,7 @@ use RedBeanPHP\R;
// Other parameters. // Other parameters.
$_format = $_GET['format'] ?? ''; $_format = $_GET['format'] ?? '';
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.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 { try {
$pod = R::getRow(' $pod = R::getRow('
......
...@@ -11,19 +11,19 @@ if (PHP_SAPI !== 'cli') { ...@@ -11,19 +11,19 @@ if (PHP_SAPI !== 'cli') {
exit; exit;
} }
require_once __DIR__ . '/../config.php'; $c = require __DIR__ . '/../config.php';
$keep = (60 * 60 * 6) * 1; $keep = (60 * 60 * 6) * 1;
$dump_date = date('Ymd_Hs'); $dump_date = date('Ymd_Hs');
$file_name = $backup_dir . '/dump_' . $dump_date . '.sql'; $file_name = "{$c['backup_dir']}/dump_{$dump_date}.sql";
system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --clean --format=tar --username=$pguser $pgdb >> $file_name"); system("export PGPASSWORD={$c['pgpass']} && {$c['pg_dump_dir']}/pg_dump --clean --format=tar --username={$c['pguser']} {$c['pgdb']} >> {$file_name}");
echo "pg backup of $pgdb made"; echo "pg backup of {$c['pgdb']} made";
$dirh = dir($backup_dir); $dirh = dir($c['backup_dir']);
while ($entry = $dirh->read()) { while ($entry = $dirh->read()) {
$old_file_time = (date('U') - $keep); $old_file_time = date('U') - $keep;
$file_created = filectime("$backup_dir/$entry"); $file_created = filectime("{$c['backup_dir']}/{$entry}");
if ($file_created < $old_file_time && !is_dir($entry)) { if ($file_created < $old_file_time && !is_dir($entry)) {
if (unlink("$backup_dir/$entry")) { if (unlink("{$c['backup_dir']}/{$entry}")) {
echo 'Cleaned up old backups'; echo 'Cleaned up old backups';
} }
} }
......
...@@ -22,13 +22,7 @@ $_email = $_GET['email'] ?? ''; ...@@ -22,13 +22,7 @@ $_email = $_GET['email'] ?? '';
$_podmin_statement = $_GET['podmin_statement'] ?? ''; $_podmin_statement = $_GET['podmin_statement'] ?? '';
$_podmin_notify = $_GET['podmin_notify'] ?? 0; $_podmin_notify = $_GET['podmin_notify'] ?? 0;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.php';
require_once __DIR__ . '/../config.php';
// 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 { try {
$pod = R::findOne('pods', 'domain = ?', [$_domain]); $pod = R::findOne('pods', 'domain = ?', [$_domain]);
...@@ -89,7 +83,7 @@ if ('save' === $_action) { ...@@ -89,7 +83,7 @@ if ('save' === $_action) {
} }
$to = $_email; $to = $_email;
$headers = ['From: ' . $adminemail, 'Cc: ' . $pod['email'], 'Bcc: ' . $adminemail]; $headers = ['From: ' . c('adminemail'), 'Cc: ' . $pod['email'], 'Bcc: ' . c('adminemail')];
$subject = 'Edit notice from poduptime'; $subject = 'Edit notice from poduptime';
$message = 'Data for ' . $_domain . ' updated. If it was not you reply and let me know!'; $message = 'Data for ' . $_domain . ' updated. If it was not you reply and let me know!';
@mail($to, $subject, $message, implode("\r\n", $headers)); @mail($to, $subject, $message, implode("\r\n", $headers));
......
...@@ -14,14 +14,7 @@ use RedBeanPHP\R; ...@@ -14,14 +14,7 @@ use RedBeanPHP\R;
// Other parameters. // Other parameters.
$_email = $_GET['email'] ?? ''; $_email = $_GET['email'] ?? '';
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.php';
require_once __DIR__ . '/../config.php';
// 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 { try {
$pod = R::findOne('pods', 'domain = ?', [$_domain]); $pod = R::findOne('pods', 'domain = ?', [$_domain]);
...@@ -33,7 +26,7 @@ try { ...@@ -33,7 +26,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/?edit&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: ' . c('adminemail')];
$message_lines = []; $message_lines = [];
if ($_email) { if ($_email) {
...@@ -41,7 +34,7 @@ if ($_email) { ...@@ -41,7 +34,7 @@ if ($_email) {
$to = $_email; $to = $_email;
$subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST']; $subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST'];
$headers[] = 'Bcc: ' . $adminemail; $headers[] = 'Bcc: ' . c('adminemail');
$expire = time() + 8700; $expire = time() + 8700;
$output = 'Link sent to your email.'; $output = 'Link sent to your email.';
} elseif (!$pod['email']) { } elseif (!$pod['email']) {
...@@ -49,7 +42,7 @@ if ($_email) { ...@@ -49,7 +42,7 @@ if ($_email) {
} else { } else {
$to = $pod['email']; $to = $pod['email'];
$subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST']; $subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST'];
$headers[] = 'Bcc: ' . $adminemail; $headers[] = 'Bcc: ' . c('adminemail');
$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[] = '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']; $message_lines[] = 'Email found: ' . $pod['email'];
$expire = time() + 8700; $expire = time() + 8700;
......
...@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') { ...@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') {
use RedBeanPHP\R; use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.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 { try {
$monthly_totals = R::getAll(" $monthly_totals = R::getAll("
...@@ -39,8 +31,8 @@ try { ...@@ -39,8 +31,8 @@ try {
} catch (\RedBeanPHP\RedException $e) { } catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
} }
foreach ($monthly_totals as $monthly) {
foreach ($monthly_totals as $monthly) {
// Format date to timestamp. // Format date to timestamp.
$timestamp = $monthly['yymm'] . '-01 01:01:01-01'; $timestamp = $monthly['yymm'] . '-01 01:01:01-01';
......
...@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') { ...@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') {
use RedBeanPHP\R; use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.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 { try {
$sql = ' $sql = '
......
...@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') { ...@@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') {
use RedBeanPHP\R; use RedBeanPHP\R;
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.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);
$softwares = [ $softwares = [
'diaspora' => ['repo' => 'diaspora/diaspora', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'], 'diaspora' => ['repo' => 'diaspora/diaspora', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'],
...@@ -39,11 +31,11 @@ $opts = [ ...@@ -39,11 +31,11 @@ $opts = [
]; ];
foreach ($softwares as $software => $details) { foreach ($softwares as $software => $details) {
if ($details['gittype'] == 'github') { if ($details['gittype'] === 'github') {
$context = stream_context_create($opts); $context = stream_context_create($opts);
$releasejson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/repos/' . $details["repo"] . '/releases/latest', false, $context)); $releasejson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/repos/' . $details['repo'] . '/releases/latest', false, $context));
if ($details["devbranch"]) { if ($details['devbranch']) {
$commitjson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/repos/' . $details["repo"] . '/commits/' . $details["devbranch"], false, $context)); $commitjson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/repos/' . $details['repo'] . '/commits/' . $details['devbranch'], false, $context));
} else { } else {
$commitjson = ''; $commitjson = '';
} }
...@@ -63,11 +55,11 @@ foreach ($softwares as $software => $details) { ...@@ -63,11 +55,11 @@ foreach ($softwares as $software => $details) {
die('Error in SQL query: ' . $e->getMessage()); die('Error in SQL query: ' . $e->getMessage());
} }
} }
} elseif ($details['gittype'] == 'gitlab') { } elseif ($details['gittype'] === 'gitlab') {
$context = stream_context_create($opts); $context = stream_context_create($opts);
$releasejson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/api/v4/projects/' . $details["repo"] . '/repository/tags', false, $context)); $releasejson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/api/v4/projects/' . $details['repo'] . '/repository/tags', false, $context));
if ($details["devbranch"]) { if ($details['devbranch']) {
$commitjson = json_decode(file_get_contents('https://' . $details["gitsite"] . '/api/v4/projects/' . $details["repo"] . '/repository/commits/' . $details["devbranch"], false, $context)); $commitjson = json_decode(file_get_contents('https://' . $details['gitsite'] . '/api/v4/projects/' . $details['repo'] . '/repository/commits/' . $details['devbranch'], false, $context));
} else { } else {
$commitjson = ''; $commitjson = '';
} }
...@@ -89,6 +81,5 @@ foreach ($softwares as $software => $details) { ...@@ -89,6 +81,5 @@ foreach ($softwares as $software => $details) {
} }
} }
printf('%s:%s:%s ', $software, $masterversion, $devlastcommit ?: 'n/a'); printf('%s:%s:%s ', $software, $masterversion, $devlastcommit ?: 'n/a');
} }
...@@ -30,20 +30,13 @@ $_domain = $_GET['domain'] ?? null; ...@@ -30,20 +30,13 @@ $_domain = $_GET['domain'] ?? null;
// Must have a domain, except if called from CLI. // Must have a domain, except if called from CLI.
$_domain || PHP_SAPI === 'cli' || die('No valid input'); $_domain || PHP_SAPI === 'cli' || die('No valid input');
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.php';
require_once __DIR__ . '/../config.php';
define('PODUPTIME', microtime(true)); $sqldebug && R::fancyDebug(true);
// Set up global DB connection.
R::setup("pgsql:host={$pghost};dbname={$pgdb}", $pguser, $pgpass, true);
$sqldebug && R::debug(true);
R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try { try {
// Setup GeoIP Database // Setup GeoIP Database
$reader = new Reader($geoip2db); $reader = new Reader(c('geoip2db'));
$sql = ' $sql = '
SELECT domain, score, date_created, weight, podmin_notify, email, masterversion, shortversion, status SELECT domain, score, date_created, weight, podmin_notify, email, masterversion, shortversion, status
...@@ -114,7 +107,7 @@ foreach ($pods as $pod) { ...@@ -114,7 +107,7 @@ foreach ($pods as $pod) {
curl_setopt($chss, CURLOPT_TIMEOUT, 30); curl_setopt($chss, CURLOPT_TIMEOUT, 30);
curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1); curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chss, CURLOPT_CERTINFO, 1); curl_setopt($chss, CURLOPT_CERTINFO, 1);
curl_setopt($chss, CURLOPT_CAINFO, $cafullpath); curl_setopt($chss, CURLOPT_CAINFO, c('cafullpath'));
$outputssl = curl_exec($chss); $outputssl = curl_exec($chss);
$outputsslerror = curl_error($chss); $outputsslerror = curl_error($chss);
$info = curl_getinfo($chss, CURLINFO_CERTINFO); $info = curl_getinfo($chss, CURLINFO_CERTINFO);
...@@ -297,7 +290,7 @@ foreach ($pods as $pod) { ...@@ -297,7 +290,7 @@ foreach ($pods as $pod) {
_debug('Signup Open', $signup); _debug('Signup Open', $signup);
$dnsserver = !empty($dnsserver) ? $dnsserver : '1.1.1.1'; $dnsserver = c('dnsserver') ?: '1.1.1.1';
$delv = new NPM\Xec\Command("delv @{$dnsserver} {$domain}"); $delv = new NPM\Xec\Command("delv @{$dnsserver} {$domain}");
$delv->throwExceptionOnError(false); $delv->throwExceptionOnError(false);
...@@ -355,7 +348,7 @@ foreach ($pods as $pod) { ...@@ -355,7 +348,7 @@ foreach ($pods as $pod) {
if ($score == 49 && $notify && !$develop && $dbscore == 50) { if ($score == 49 && $notify && !$develop && $dbscore == 50) {
$to = $email; $to = $email;
$headers = ['From: ' . $adminemail, 'Bcc: ' . $adminemail]; $headers = ['From: ' . c('adminemail'), 'Bcc: ' . c('adminemail')];
$subject = 'Monitoring notice from poduptime'; $subject = 'Monitoring notice from poduptime';
$message = 'Notice for ' . $domain . '. Your score is ' . $score . ' and your pod will fall off the list soon.'; $message = 'Notice for ' . $domain . '. Your score is ' . $score . ' and your pod will fall off the list soon.';
@mail($to, $subject, $message, implode("\r\n", $headers)); @mail($to, $subject, $message, implode("\r\n", $headers));
......
...@@ -46,14 +46,14 @@ if [ "$HOUR" = 23 ] || [ "$1" = 'init' ]; then ...@@ -46,14 +46,14 @@ if [ "$HOUR" = 23 ] || [ "$1" = 'init' ]; then
fi fi
if [ "$DAY" = 23 ] || [ "$1" = 'init' ]; then if [ "$DAY" = 23 ] || [ "$1" = 'init' ]; then
printf "%s" "Updating CA..." printf "%s" "Updating CA..."
CACERT_FILE="$(php -r "include __DIR__ . '/../config.php'; echo \$cafullpath;")" CACERT_FILE="$(php -r "echo (require __DIR__ . '/../config.php')['cafullpath'];")"
if curl -Lss https://curl.haxx.se/ca/cacert.pem -o "$CACERT_FILE"; then if curl -Lss https://curl.haxx.se/ca/cacert.pem -o "$CACERT_FILE"; then
echo "$HAPPY" echo "$HAPPY"
else else
echo "$SAD" echo "$SAD"
fi fi
printf "%s" "Updating GeoIP2 DB..." printf "%s" "Updating GeoIP2 DB..."
GEODB_FILE="$(php -r "include __DIR__ . '/../config.php'; echo \$geoip2db;")" GEODB_FILE="$(php -r "echo (require __DIR__ . '/../config.php')['geoip2db'];")"
if funzip <(curl -Lss http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) > "$GEODB_FILE"; then if funzip <(curl -Lss http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz) > "$GEODB_FILE"; then
echo "$HAPPY" echo "$HAPPY"
else else
......
...@@ -15,15 +15,7 @@ use RedBeanPHP\R; ...@@ -15,15 +15,7 @@ use RedBeanPHP\R;
($_comment = $_POST['comment'] ?? null) || die('A comment is required'); ($_comment = $_POST['comment'] ?? null) || die('A comment is required');
($_rating = $_POST['rating'] ?? null) || die('A rating is required'); ($_rating = $_POST['rating'] ?? null) || die('A rating is required');
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../boot.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 { try {
$r = R::dispense('ratingcomments'); $r = R::dispense('ratingcomments');
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
declare(strict_types=1); declare(strict_types=1);
$dur = (time() - filemtime('last.data')); $dur = time() - filemtime('last.data');
echo $dur; echo $dur;
if ($dur > 4500) { if ($dur > 4500) {
http_response_code(500); http_response_code(500);
......
...@@ -13,15 +13,7 @@ use RedBeanPHP\R; ...@@ -13,15 +13,7 @@ use RedBeanPHP\R;
// Other parameters. // Other parameters.
$_domain = $_GET['domain'] ?? ''; $_domain = $_GET['domain'] ?? '';
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/boot.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 { try {
if ($_domain) { if ($_domain) {
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
declare(strict_types=1); declare(strict_types=1);
use Carbon\Carbon; use Carbon\Carbon;
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/boot.php';
require_once __DIR__ . '/config.php';
$lastfile = 'db/last.data'; $lastfile = 'db/last.data';
$input = isset($_GET['input']) ? substr($_GET['input'], 1) : null; $input = isset($_GET['input']) ? substr($_GET['input'], 1) : null;
......
...@@ -11,15 +11,7 @@ use RedBeanPHP\R; ...@@ -11,15 +11,7 @@ use RedBeanPHP\R;
// Required parameters. // Required parameters.
($_domain = $_GET['domain'] ?? null) || die('no domain given'); ($_domain = $_GET['domain'] ?? null) || die('no domain given');
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/boot.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);
$sql = " $sql = "
SELECT SELECT
......
...@@ -11,15 +11,7 @@ use RedBeanPHP\R; ...@@ -11,15 +11,7 @@ use RedBeanPHP\R;
// Required parameters. // Required parameters.
($_domain = $_GET['domain'] ?? null) || die('no domain given'); ($_domain = $_GET['domain'] ?? null) || die('no domain given');
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/boot.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);
$sql = " $sql = "
SELECT SELECT
......
...@@ -10,15 +10,8 @@ use RedBeanPHP\R; ...@@ -10,15 +10,8 @@ use RedBeanPHP\R;
($_domain = $_GET['domain'] ?? null) || die('domain not specified'); ($_domain = $_GET['domain'] ?? null) || die('domain not specified');
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/boot.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);
?> ?>
<html> <html>
<head> <head>
......
...@@ -9,15 +9,7 @@ declare(strict_types=1); ...@@ -9,15 +9,7 @@ declare(strict_types=1);
use Poduptime\PodStatus; use Poduptime\PodStatus;
use RedBeanPHP\R; use RedBeanPHP\R;