diff --git a/api.php b/api.php index 0baeca5974bbe50b0dcbc114c138c477d3b96682..477ac6b06f291a7be1e0061d00f9895bbb0c84c5 100644 --- a/api.php +++ b/api.php @@ -15,15 +15,7 @@ $_format = $_GET['format'] ?? ''; $_method = $_GET['method'] ?? ''; $_callback = $_GET['callback'] ?? ''; -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); +require_once __DIR__ . '/boot.php'; if ($_format === 'georss') { echo << __DIR__ . '/backup', -//log directory - full dir path -$log_dir = __DIR__ . '/log'; + //log directory - full dir path + 'log_dir' => __DIR__ . '/log', -//location of pg dump - full dir path -$pg_dump_dir = '/usr/bin'; + //location of pg dump - full dir path + 'pg_dump_dir' => '/usr/bin', -//db host -$pghost = 'localhost'; + //db host + 'pghost' => 'localhost', -//db username -$pguser = ''; + //db port + 'pgport' => 5432, -//db password -$pgpass = ''; + //db username + 'pguser' => '', -//db name -$pgdb = ''; + //db password + 'pgpass' => '', -//admin email for forms -$adminemail = ''; + //db name + 'pgdb' => '', -//DNS server for dnssec testing. 1.1.1.1 tests the best -$dnsserver = ''; + //admin email for forms + 'adminemail' => '', -//CA for curl to use - full file path (pull.sh will update this monthly) -$cafullpath = ''; + //DNS server for dnssec testing. 1.1.1.1 tests the best + 'dnsserver' => '', -//Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/ -$mapboxkey = ''; + //CA for curl to use - full file path (pull.sh will update this monthly) + 'cafullpath' => '', -//Geolite2-city database file in mmdb format - full file path (pull.sh will update this monthly) -$geoip2db = ''; + //Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/ + 'mapboxkey' => '', + + //Geolite2-city database file in mmdb format - full file path (pull.sh will update this monthly) + 'geoip2db' => '', +]; diff --git a/db/add.php b/db/add.php index e4e6e5576ad1f96fd0979fe16c4731a74907eb9c..f71cb8eb4ad5a67801c0d904afc416960df15e29 100644 --- a/db/add.php +++ b/db/add.php @@ -8,17 +8,7 @@ declare(strict_types=1); 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); - +require_once __DIR__ . '/../boot.php'; if (!($_domain = $_GET['domain'] ?? null)) { die('no pod domain given'); @@ -126,7 +116,7 @@ if (!$stop) { } if ($_email) { - $to = $adminemail; + $to = c('adminemail'); $subject = 'New pod added to ' . $_SERVER['HTTP_HOST']; $headers = ['From: ' . $_email, 'Reply-To: ' . $_email, 'Cc: ' . $_email]; @@ -144,4 +134,4 @@ if (!$stop) { } else { echo 'Could not validate your pod, check your setup!
Take a look at your /nodeinfo'; } -} \ No newline at end of file +} diff --git a/db/api-more.php b/db/api-more.php index b76d5bf494dff7caeee376cb635f6a9ab0505976..932911a48ee2087d8543150199f4924f797f134f 100644 --- a/db/api-more.php +++ b/db/api-more.php @@ -15,15 +15,7 @@ use RedBeanPHP\R; // Other parameters. $_format = $_GET['format'] ?? ''; -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); +require_once __DIR__ . '/../boot.php'; try { $pod = R::getRow(' diff --git a/db/backup.php b/db/backup.php index 6b337d2f31b4d7ab2ce7a121dca6e6e1ed27ad62..ce3e23a1ead710497b06164fced25bfc6ab13191 100644 --- a/db/backup.php +++ b/db/backup.php @@ -11,19 +11,19 @@ if (PHP_SAPI !== 'cli') { exit; } -require_once __DIR__ . '/../config.php'; +$c = require __DIR__ . '/../config.php'; $keep = (60 * 60 * 6) * 1; $dump_date = date('Ymd_Hs'); -$file_name = $backup_dir . '/dump_' . $dump_date . '.sql'; -system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --clean --format=tar --username=$pguser $pgdb >> $file_name"); -echo "pg backup of $pgdb made"; -$dirh = dir($backup_dir); +$file_name = "{$c['backup_dir']}/dump_{$dump_date}.sql"; +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 {$c['pgdb']} made"; +$dirh = dir($c['backup_dir']); while ($entry = $dirh->read()) { - $old_file_time = (date('U') - $keep); - $file_created = filectime("$backup_dir/$entry"); + $old_file_time = date('U') - $keep; + $file_created = filectime("{$c['backup_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'; } } diff --git a/db/edit.php b/db/edit.php index 3399b973326688e0724d4383b34d31295c1dfc0c..d29ef1e26f69b5c803e6c0e562421ac068311ced 100644 --- a/db/edit.php +++ b/db/edit.php @@ -22,13 +22,7 @@ $_email = $_GET['email'] ?? ''; $_podmin_statement = $_GET['podmin_statement'] ?? ''; $_podmin_notify = $_GET['podmin_notify'] ?? 0; -require_once __DIR__ . '/../vendor/autoload.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); +require_once __DIR__ . '/../boot.php'; try { $pod = R::findOne('pods', 'domain = ?', [$_domain]); @@ -89,7 +83,7 @@ if ('save' === $_action) { } $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'; $message = 'Data for ' . $_domain . ' updated. If it was not you reply and let me know!'; @mail($to, $subject, $message, implode("\r\n", $headers)); diff --git a/db/gettoken.php b/db/gettoken.php index 3427ed09264e67986b1c90ec04f6c7b8590a39e1..9b793f853263eb464dcc4dfe5062692929bed02a 100644 --- a/db/gettoken.php +++ b/db/gettoken.php @@ -14,14 +14,7 @@ use RedBeanPHP\R; // Other parameters. $_email = $_GET['email'] ?? ''; -require_once __DIR__ . '/../vendor/autoload.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); - +require_once __DIR__ . '/../boot.php'; try { $pod = R::findOne('pods', 'domain = ?', [$_domain]); @@ -33,7 +26,7 @@ try { // Set up common variables. $uuid = md5(uniqid($_domain, true)); $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 = []; if ($_email) { @@ -41,7 +34,7 @@ if ($_email) { $to = $_email; $subject = 'Temporary edit key for ' . $_SERVER['HTTP_HOST']; - $headers[] = 'Bcc: ' . $adminemail; + $headers[] = 'Bcc: ' . c('adminemail'); $expire = time() + 8700; $output = 'Link sent to your email.'; } elseif (!$pod['email']) { @@ -49,7 +42,7 @@ if ($_email) { } else { $to = $pod['email']; $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[] = 'Email found: ' . $pod['email']; $expire = time() + 8700; diff --git a/db/monthly_stats.php b/db/monthly_stats.php index 0952acce561f5c6fed2fd8d1ebdf111275927218..bf6da2cebcb5d5a3b52ebc647010760dee344de0 100644 --- a/db/monthly_stats.php +++ b/db/monthly_stats.php @@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') { 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); +require_once __DIR__ . '/../boot.php'; try { $monthly_totals = R::getAll(" @@ -39,8 +31,8 @@ try { } catch (\RedBeanPHP\RedException $e) { die('Error in SQL query: ' . $e->getMessage()); } -foreach ($monthly_totals as $monthly) { +foreach ($monthly_totals as $monthly) { // Format date to timestamp. $timestamp = $monthly['yymm'] . '-01 01:01:01-01'; diff --git a/db/podcrawler.php b/db/podcrawler.php index a9e0bc0a826223bda1390c0ae1fa22860ce6ecad..f50c842df1da9ca3af96594a3d0a5d923e28cb16 100644 --- a/db/podcrawler.php +++ b/db/podcrawler.php @@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') { 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); +require_once __DIR__ . '/../boot.php'; try { $sql = ' diff --git a/db/pull-masterversions.php b/db/pull-masterversions.php index ebff6a1f8b4d98c024e717d0dc2bf71fcf13668d..644acb97ca7ea6e3cf667ae53344c4fbfaa83d6c 100644 --- a/db/pull-masterversions.php +++ b/db/pull-masterversions.php @@ -13,15 +13,7 @@ if (PHP_SAPI !== 'cli') { 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); +require_once __DIR__ . '/../boot.php'; $softwares = [ 'diaspora' => ['repo' => 'diaspora/diaspora', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'], @@ -39,11 +31,11 @@ $opts = [ ]; foreach ($softwares as $software => $details) { - if ($details['gittype'] == 'github') { + 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)); + $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 = ''; } @@ -63,11 +55,11 @@ foreach ($softwares as $software => $details) { die('Error in SQL query: ' . $e->getMessage()); } } - } elseif ($details['gittype'] == 'gitlab') { + } 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)); + $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 = ''; } @@ -89,6 +81,5 @@ foreach ($softwares as $software => $details) { } } - printf('%s:%s:%s ', $software, $masterversion, $devlastcommit ?: 'n/a'); } diff --git a/db/pull.php b/db/pull.php index 5c722e459e3c73ad3fc2a206444db977df480e1b..faf18fc84b07b8f03240c69645e7bb4fb6614c79 100644 --- a/db/pull.php +++ b/db/pull.php @@ -30,20 +30,13 @@ $_domain = $_GET['domain'] ?? null; // Must have a domain, except if called from CLI. $_domain || PHP_SAPI === 'cli' || die('No valid input'); -require_once __DIR__ . '/../vendor/autoload.php'; -require_once __DIR__ . '/../config.php'; +require_once __DIR__ . '/../boot.php'; -define('PODUPTIME', microtime(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); +$sqldebug && R::fancyDebug(true); try { // Setup GeoIP Database - $reader = new Reader($geoip2db); + $reader = new Reader(c('geoip2db')); $sql = ' SELECT domain, score, date_created, weight, podmin_notify, email, masterversion, shortversion, status @@ -114,7 +107,7 @@ foreach ($pods as $pod) { curl_setopt($chss, CURLOPT_TIMEOUT, 30); curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1); curl_setopt($chss, CURLOPT_CERTINFO, 1); - curl_setopt($chss, CURLOPT_CAINFO, $cafullpath); + curl_setopt($chss, CURLOPT_CAINFO, c('cafullpath')); $outputssl = curl_exec($chss); $outputsslerror = curl_error($chss); $info = curl_getinfo($chss, CURLINFO_CERTINFO); @@ -297,7 +290,7 @@ foreach ($pods as $pod) { _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->throwExceptionOnError(false); @@ -355,7 +348,7 @@ foreach ($pods as $pod) { if ($score == 49 && $notify && !$develop && $dbscore == 50) { $to = $email; - $headers = ['From: ' . $adminemail, 'Bcc: ' . $adminemail]; + $headers = ['From: ' . c('adminemail'), 'Bcc: ' . c('adminemail')]; $subject = 'Monitoring notice from poduptime'; $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)); diff --git a/db/pull.sh b/db/pull.sh index 8c53b14d5a5dd2fec16cbb5f2bbd0ba04b3dce2f..b9fe6fa346959af5ee066f2ae4b5a722895f069f 100755 --- a/db/pull.sh +++ b/db/pull.sh @@ -46,14 +46,14 @@ if [ "$HOUR" = 23 ] || [ "$1" = 'init' ]; then fi if [ "$DAY" = 23 ] || [ "$1" = 'init' ]; then 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 echo "$HAPPY" else echo "$SAD" fi 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 echo "$HAPPY" else diff --git a/db/saverating.php b/db/saverating.php index 2ea148dc4f38f390889181c930296175068fe25c..a74e2440791fca2edfe5a63aceb9aa286c0916cd 100644 --- a/db/saverating.php +++ b/db/saverating.php @@ -15,15 +15,7 @@ use RedBeanPHP\R; ($_comment = $_POST['comment'] ?? null) || die('A comment is required'); ($_rating = $_POST['rating'] ?? null) || die('A rating is required'); -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); +require_once __DIR__ . '/../boot.php'; try { $r = R::dispense('ratingcomments'); diff --git a/db/status.php b/db/status.php index 044c5a9cbf1f667cebed59d110cc49d3c99cb4e7..606bec3bf067892f5fae5d04f26fe6e035b454f8 100644 --- a/db/status.php +++ b/db/status.php @@ -6,7 +6,7 @@ declare(strict_types=1); -$dur = (time() - filemtime('last.data')); +$dur = time() - filemtime('last.data'); echo $dur; if ($dur > 4500) { http_response_code(500); diff --git a/go.php b/go.php index 78d442ba8b79ca6b6acfd3c498470efaeec82fac..b63a0a3164ed5169f6eb76802d52e24b34df5cb0 100644 --- a/go.php +++ b/go.php @@ -13,15 +13,7 @@ use RedBeanPHP\R; // Other parameters. $_domain = $_GET['domain'] ?? ''; -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); +require_once __DIR__ . '/boot.php'; try { if ($_domain) { diff --git a/index.php b/index.php index 998c3681ff8d47b3a439f2f5b54b9ce19698f256..b86c16d957ecdf07d869f1a2bbd392500272c54d 100644 --- a/index.php +++ b/index.php @@ -7,8 +7,7 @@ declare(strict_types=1); use Carbon\Carbon; -require_once __DIR__ . '/vendor/autoload.php'; -require_once __DIR__ . '/config.php'; +require_once __DIR__ . '/boot.php'; $lastfile = 'db/last.data'; $input = isset($_GET['input']) ? substr($_GET['input'], 1) : null; diff --git a/podstat-counts.php b/podstat-counts.php index d1c571207326ee0b2fefcc70714ea8051b6a9086..b69bb1609b6ab13e974eb5d00cee2c70620586d6 100644 --- a/podstat-counts.php +++ b/podstat-counts.php @@ -11,15 +11,7 @@ use RedBeanPHP\R; // Required parameters. ($_domain = $_GET['domain'] ?? null) || die('no domain given'); -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); +require_once __DIR__ . '/boot.php'; $sql = " SELECT diff --git a/podstat-uptime.php b/podstat-uptime.php index 74581a5f6aab6e056cdb92c290e02489b1c63485..1ec1e6cf3a0723451e097780a995b2ea97a17500 100644 --- a/podstat-uptime.php +++ b/podstat-uptime.php @@ -11,15 +11,7 @@ use RedBeanPHP\R; // Required parameters. ($_domain = $_GET['domain'] ?? null) || die('no domain given'); -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); +require_once __DIR__ . '/boot.php'; $sql = " SELECT diff --git a/rate.php b/rate.php index dd3d009385c4b295d25489286ccbd55e87028dd8..ac2def0ba9d931e25cae63227c61420c9e74d2b3 100644 --- a/rate.php +++ b/rate.php @@ -10,15 +10,8 @@ use RedBeanPHP\R; ($_domain = $_GET['domain'] ?? null) || die('domain not specified'); -require_once __DIR__ . '/vendor/autoload.php'; -require_once __DIR__ . '/config.php'; +require_once __DIR__ . '/boot.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); ?> diff --git a/showmap.php b/showmap.php index efaddfecef82fe9a2825ec848ca52782e04b5b45..f1234126915ef8154318c06bbb9994ff79545850 100644 --- a/showmap.php +++ b/showmap.php @@ -9,15 +9,7 @@ declare(strict_types=1); use Poduptime\PodStatus; 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); +require_once __DIR__ . '/boot.php'; // CloudFlare country code pull. $country_code = $_SERVER['HTTP_CF_IPCOUNTRY'] ?? ''; @@ -84,7 +76,7 @@ EOF; ?> ] }; - var tiles = L.tileLayer('https://{s}.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.jpg70?access_token=', { + var tiles = L.tileLayer('https://{s}.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.jpg70?access_token=', { maxZoom: 18, attribution: '© Mapbox © OpenStreetMap Improve this map' }); diff --git a/statsviewjs.php b/statsviewjs.php index 33875261961c680f49bbeb8c4795dc1d1bb0a7cb..01d3742a367061704be4807635bbfdf7e4ef132a 100644 --- a/statsviewjs.php +++ b/statsviewjs.php @@ -9,15 +9,7 @@ declare(strict_types=1); use Poduptime\PodStatus; 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); +require_once __DIR__ . '/boot.php'; try { $totals = R::getAll(' diff --git a/tabledata.php b/tabledata.php index 80fc3523ce56600932372f4f88934007cde5b727..abe0c679d8c0170260684a5fe81c429a518f48af 100644 --- a/tabledata.php +++ b/tabledata.php @@ -10,15 +10,7 @@ use Carbon\Carbon; use Poduptime\PodStatus; 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); +require_once __DIR__ . '/boot.php'; try { $pods = R::getAll(' diff --git a/wizard.php b/wizard.php index 72451c5610010ec9176753580b74dced0aa892d0..c51ee85a678489db38426cd4828e3773d35ce49a 100644 --- a/wizard.php +++ b/wizard.php @@ -9,15 +9,7 @@ declare(strict_types=1); use Poduptime\PodStatus; use RedBeanPHP\R; -define('PODUPTIME', microtime(true)); - -require_once __DIR__ . '/vendor/autoload.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); +require_once __DIR__ . '/boot.php'; $page = (int) ($_GET['page'] ?? 1); $softwarename = $_GET['softwarename'] ?? null;