diff --git a/app/Controllers/Install.php b/app/Controllers/Install.php index 6cdb342266fe92ccb602aae87ee606426ac0b155..cc9e26d48de297334fd9222e22c9736a4338091e 100644 --- a/app/Controllers/Install.php +++ b/app/Controllers/Install.php @@ -44,7 +44,7 @@ class Install extends Controller $dotenv->load(); } catch (\Throwable $e) { - return $this->createEnv(); + $this->createEnv(); } // Check if the created .env file is writable to continue install process @@ -139,8 +139,6 @@ class Install extends Controller // Could not create the .env file, redirect to a view with manual instructions on how to add it return view('install/manual_config'); } - - return redirect()->back(); } public function instanceConfig() diff --git a/app/Entities/AnalyticsWebsiteByEntryPage.php b/app/Entities/AnalyticsWebsiteByEntryPage.php index 4a8e75acb09e831b33a5e742d0ff43407be961c7..344d60fb2bc4dd136977c656d84b715a015c5a96 100644 --- a/app/Entities/AnalyticsWebsiteByEntryPage.php +++ b/app/Entities/AnalyticsWebsiteByEntryPage.php @@ -20,10 +20,4 @@ class AnalyticsWebsiteByEntryPage extends Entity 'date' => 'datetime', 'hits' => 'integer', ]; - - public function getLabels() - { - $split = explode('/', $this->attributes['labels']); - return $split[count($split) - 1]; - } } diff --git a/app/Helpers/url_helper.php b/app/Helpers/url_helper.php index 7f9e157bad1bc45de966101b25948ca42b42ff07..1e35a594abc6b6f6368f459cffb7e306f7ffd817 100644 --- a/app/Helpers/url_helper.php +++ b/app/Helpers/url_helper.php @@ -8,13 +8,13 @@ if (!function_exists('host_url')) { */ function host_url() { - if (isset($_SERVER['host'])) { + if (isset($_SERVER['HTTP_HOST'])) { $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; - return $protocol + $_SERVER['host']; + return $protocol . $_SERVER['HTTP_HOST'] . '/'; } return false; diff --git a/app/Models/AnalyticsPodcastByCountryModel.php b/app/Models/AnalyticsPodcastByCountryModel.php index 053b4b02f656cb4e395ceaa82c0f06d8e624b3c8..162170a5cf7c0c47c904e8b969537d0b9844c4eb 100644 --- a/app/Models/AnalyticsPodcastByCountryModel.php +++ b/app/Models/AnalyticsPodcastByCountryModel.php @@ -32,10 +32,9 @@ class AnalyticsPodcastByCountryModel extends Model */ public function getDataWeekly(int $podcastId): array { - $locale = service('request')->getLocale(); if ( !($found = cache( - "{$podcastId}_analytics_podcast_by_country_weekly_{$locale}" + "{$podcastId}_analytics_podcast_by_country_weekly" )) ) { $found = $this->select('`country_code` as `labels`') @@ -49,7 +48,7 @@ class AnalyticsPodcastByCountryModel extends Model ->findAll(10); cache()->save( - "{$podcastId}_analytics_podcast_by_country_weekly_{$locale}", + "{$podcastId}_analytics_podcast_by_country_weekly", $found, 600 ); @@ -66,10 +65,9 @@ class AnalyticsPodcastByCountryModel extends Model */ public function getDataYearly(int $podcastId): array { - $locale = service('request')->getLocale(); if ( !($found = cache( - "{$podcastId}_analytics_podcast_by_country_yearly_{$locale}" + "{$podcastId}_analytics_podcast_by_country_yearly" )) ) { $found = $this->select('`country_code` as `labels`') @@ -83,7 +81,7 @@ class AnalyticsPodcastByCountryModel extends Model ->findAll(10); cache()->save( - "{$podcastId}_analytics_podcast_by_country_yearly_{$locale}", + "{$podcastId}_analytics_podcast_by_country_yearly", $found, 600 ); diff --git a/app/Models/AnalyticsPodcastByPlayerModel.php b/app/Models/AnalyticsPodcastByPlayerModel.php index f6491c2aee4478191601d4dc04634c69cfda172d..bb03fcf81ed2840bf4be5b0192ec154f720c30c6 100644 --- a/app/Models/AnalyticsPodcastByPlayerModel.php +++ b/app/Models/AnalyticsPodcastByPlayerModel.php @@ -112,6 +112,7 @@ class AnalyticsPodcastByPlayerModel extends Model ->where([ '`podcast_id`' => $podcastId, '`app` !=' => '', + '`os` !=' => '', '`bot`' => 0, '`date` >' => date('Y-m-d', strtotime('-1 week')), ]) diff --git a/app/Models/AnalyticsWebsiteByEntryPageModel.php b/app/Models/AnalyticsWebsiteByEntryPageModel.php index 308beb5cc49b02c3f5e56df87b983385dd998775..179f4d57e8442c48a01c68405d3ef71588ecf84c 100644 --- a/app/Models/AnalyticsWebsiteByEntryPageModel.php +++ b/app/Models/AnalyticsWebsiteByEntryPageModel.php @@ -33,7 +33,9 @@ class AnalyticsWebsiteByEntryPageModel extends Model public function getData(int $podcastId): array { if (!($found = cache("{$podcastId}_analytics_website_by_entry_page"))) { - $found = $this->select('`entry_page` as `labels`') + $found = $this->select( + 'IF(`entry_page`=\'/\',\'/\',SUBSTRING_INDEX(`entry_page`,\'/\',-1)) as `labels`' + ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, diff --git a/app/Models/AnalyticsWebsiteByRefererModel.php b/app/Models/AnalyticsWebsiteByRefererModel.php index afaeded0f4c7b350fefe6b61054f5438365f908e..b7805b94f1a407b12e3962fa4393d03b03d6009a 100644 --- a/app/Models/AnalyticsWebsiteByRefererModel.php +++ b/app/Models/AnalyticsWebsiteByRefererModel.php @@ -64,7 +64,9 @@ class AnalyticsWebsiteByRefererModel extends Model if ( !($found = cache("{$podcastId}_analytics_website_by_domain_weekly")) ) { - $found = $this->select('`domain` as `labels`') + $found = $this->select( + 'SUBSTRING_INDEX(`domain`, \'.\', -2) as `labels`' + ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, @@ -95,7 +97,9 @@ class AnalyticsWebsiteByRefererModel extends Model if ( !($found = cache("{$podcastId}_analytics_website_by_domain_yearly")) ) { - $found = $this->select('`domain` as `labels`') + $found = $this->select( + 'SUBSTRING_INDEX(`domain`, \'.\', -2) as `labels`' + ) ->selectSum('`hits`', '`values`') ->where([ '`podcast_id`' => $podcastId, diff --git a/app/Views/install/instance_config.php b/app/Views/install/instance_config.php index 522bf87b8a4ddecc7b1fc098fddb48db2968ac49..bdd63deecf345430cfc2d6e293f7faa4eaa588fb 100644 --- a/app/Views/install/instance_config.php +++ b/app/Views/install/instance_config.php @@ -15,7 +15,10 @@ 'id' => 'hostname', 'name' => 'hostname', 'class' => 'form-input mb-4', - 'value' => old('hostname', host_url() ?? config('App')->baseURL), + 'value' => old( + 'hostname', + empty(host_url()) ? config('App')->baseURL : host_url() + ), 'required' => 'required', ]) ?>