From 574f4918e5902a11c7bff9a773d2d6ac5a78a471 Mon Sep 17 00:00:00 2001 From: Celestina Rempai Date: Sat, 6 Feb 2021 20:38:39 +0000 Subject: [PATCH] Fix avatar erros --- Web/Models/Entities/Club.php | 6 ++---- Web/Models/Entities/User.php | 12 +++--------- bootstrap.php | 8 ++++++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index edc807fa..c6528503 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -40,10 +40,8 @@ class Club extends RowModel function getAvatarUrl(): string { - $url = ((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] . '/'; - $url = explode('?', $url); - $serverUrl = $url[0]; - $avPhoto = $this->getAvatarPhoto(); + $serverUrl = ovk_scheme(true) . $_SERVER["SERVER_NAME"]; + $avPhoto = $this->getAvatarPhoto(); return is_null($avPhoto) ? "$serverUrl/assets/packages/static/openvk/img/camera_200.png" : $avPhoto->getURL(); } diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index ed6425c0..fe82e30f 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -103,9 +103,7 @@ class User extends RowModel function getAvatarUrl(): string { - $url = ((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME']; - $url = explode('?', $url); - $serverUrl = $url[0]; + $serverUrl = ovk_scheme(true) . $_SERVER["SERVER_NAME"]; if($this->getRecord()->deleted) return "$serverUrl/assets/packages/static/openvk/img/camera_200.png"; @@ -370,20 +368,16 @@ class User extends RowModel if(!$this->getRecord()->status) { $unfilled[] = "status"; - $incompleteness += 10; + $incompleteness += 15; } if(!$this->getRecord()->telegram) { $unfilled[] = "telegram"; - $incompleteness += 10; + $incompleteness += 15; } if(!$this->getRecord()->email) { $unfilled[] = "email"; $incompleteness += 20; } - if(!$this->getRecord()->phone) { - $unfilled[] = "phone"; - $incompleteness += 20; - } if(!$this->getRecord()->city) { $unfilled[] = "city"; $incompleteness += 20; diff --git a/bootstrap.php b/bootstrap.php index 0f9d47d0..070dbc4f 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -156,9 +156,13 @@ function ovk_is_ssl(): bool return $GLOBALS["requestIsSSL"]; } -function ovk_scheme(): string +function ovk_scheme(bool $with_slashes = false): string { - return ovk_is_ssl() ? "https" : "http"; + $scheme = ovk_is_ssl() ? "https" : "http"; + if($with_slashes) + $scheme .= "://"; + + return $scheme; } return (function() {