From 2418bc314d7efa3ce94673b87b04e9450dfb7c1d Mon Sep 17 00:00:00 2001 From: david Date: Mon, 9 Jul 2018 17:14:22 -0700 Subject: [PATCH] cleaner lookups, utf8 does not seem needed to fix now, something to watch still in dev --- Changelog.md | 1 + config.php.example | 8 ++++---- db/add.php | 2 +- db/backup.php | 8 ++++---- db/pull.php | 12 ++++++------ 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Changelog.md b/Changelog.md index b4b2405..bbc38a5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -15,6 +15,7 @@ * 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 * Move from bower to yarn for packages +* NOTE config.php.examples change to full paths for 2 items! ## End Users * Show version and update in full view cleaner https://github.com/diasporg/Poduptime/issues/143 diff --git a/config.php.example b/config.php.example index 53106b1..ed719e8 100644 --- a/config.php.example +++ b/config.php.example @@ -5,10 +5,10 @@ declare(strict_types=1); -//backup directory - app directory path +//backup directory - full dir path $backup_dir = '/backup'; -//log directory - app directory path +//log directory - full dir path $log_dir = '/log'; //location of pg dump - full dir path @@ -32,11 +32,11 @@ $adminemail = ''; //DNS server for dnssec testing. 1.1.1.1 tests the best $dnsserver = ''; -//CA for curl to use - full path +//CA for curl to use - full file path $cafullpath = ''; //Mapbox.com API key. https://www.mapbox.com/help/how-access-tokens-work/ $mapboxkey = ''; -//GeoIp2 city database file in mmdb format - full path +//GeoIp2 city database file in mmdb format - full file path $geoip2db = ''; \ No newline at end of file diff --git a/db/add.php b/db/add.php index 75094cc..abeaea3 100644 --- a/db/add.php +++ b/db/add.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/../config.php'; define('PODUPTIME', microtime(true)); $log = new Logging(); -$log->lfile(__DIR__ . '/../' . $log_dir . '/add.log'); +$log->lfile( $log_dir . '/add.log'); if (!($_domain = $_GET['domain'] ?? null)) { $log->lwrite('no domain given'); die('no pod domain given'); diff --git a/db/backup.php b/db/backup.php index 0df2f21..510bad4 100644 --- a/db/backup.php +++ b/db/backup.php @@ -15,15 +15,15 @@ require_once __DIR__ . '/../config.php'; $keep = (60 * 60 * 6) * 1; $dump_date = date('Ymd_Hs'); -$file_name = __DIR__ . '/..' . $backup_dir . '/dump_' . $dump_date . '.sql'; +$file_name = $backup_dir . '/dump_' . $dump_date . '.sql'; system("export PGPASSWORD=$pgpass && $pg_dump_dir/pg_dump --username=$pguser $pgdb >> $file_name"); echo "pg backup of $pgdb made"; -$dirh = dir(__DIR__ . '/..' . $backup_dir); +$dirh = dir($backup_dir); while ($entry = $dirh->read()) { $old_file_time = (date('U') - $keep); - $file_created = filectime(__DIR__ . '/..' . "$backup_dir/$entry"); + $file_created = filectime( "$backup_dir/$entry"); if ($file_created < $old_file_time && !is_dir($entry)) { - if (unlink(__DIR__ . '/..' . "$backup_dir/$entry")) { + if (unlink( "$backup_dir/$entry")) { echo 'Cleaned up old backups'; } } diff --git a/db/pull.php b/db/pull.php index 219eebb..c625658 100644 --- a/db/pull.php +++ b/db/pull.php @@ -240,12 +240,12 @@ foreach ($pods as $pod) { _debug('Iplookupv6', $iplookupv6, true); $geo = $reader->city($ip); - $countryname = !empty($geo->country->name) ? iconv('UTF-8', 'UTF-8//IGNORE', $geo->country->name) : null; - $country = !empty($geo->country->isoCode) ? iconv('UTF-8', 'UTF-8//IGNORE', $geo->country->isoCode) : null; - $city = !empty($geo->city->name) ? iconv('UTF-8', 'UTF-8//IGNORE', $geo->city->name) : null; - $state = !empty($geo->mostSpecificSubdivision->name) ? iconv('UTF-8', 'UTF-8//IGNORE', $geo->mostSpecificSubdivision->name) : null; - $lat = !empty($geo->location->latitude) ? $geo->location->latitude : 0; - $long = !empty($geo->location->longitude) ? $geo->location->longitude : 0; + $countryname = $geo->country->name ?? null ?: 0; + $country = $geo->country->isoCode ?? null ?: 0; + $city = $geo->city->name ?? null ?: 0; + $state = $geo->mostSpecificSubdivision->name ?? null ?: 0; + $lat = $geo->location->latitude ?? null ?: 0; + $long = $geo->location->longitude ?? null ?: 0; _debug('Location', json_encode($geo->raw), true); -- GitLab