From a608ebc1a7370f5cdc9cdf05bebf45dc4c1eb9c4 Mon Sep 17 00:00:00 2001 From: Alma Armas Date: Tue, 29 Sep 2020 13:03:55 -0700 Subject: [PATCH] Always return absolute URLs for avatars --- Web/Models/Entities/Club.php | 6 ++++-- Web/Models/Entities/User.php | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Web/Models/Entities/Club.php b/Web/Models/Entities/Club.php index 10a97154..a88fd780 100644 --- a/Web/Models/Entities/Club.php +++ b/Web/Models/Entities/Club.php @@ -40,9 +40,11 @@ class Club extends RowModel function getAvatarUrl(): string { - $avPhoto = $this->getAvatarPhoto(); + $serverUrl = "http" . ($_SERVER["HTTPS"] === "on" ? "s" : "") . "://"; + $serverUrl .= $_SERVER["HTTP_HOST"]; + $avPhoto = $this->getAvatarPhoto(); - return is_null($avPhoto) ? "/assets/packages/static/openvk/img/camera_200.png" : $avPhoto->getURL(); + return is_null($avPhoto) ? "$serverUrl/assets/packages/static/openvk/img/camera_200.png" : $avPhoto->getURL(); } function getAvatarLink(): string diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 07ca6dee..8ebaaf6c 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -94,14 +94,17 @@ class User extends RowModel function getAvatarUrl(): string { + $serverUrl = "http" . ($_SERVER["HTTPS"] === "on" ? "s" : "") . "://"; + $serverUrl .= $_SERVER["HTTP_HOST"]; + if($this->getRecord()->deleted) - return "/assets/packages/static/openvk/img/camera_200.png"; + return "$serverUrl/assets/packages/static/openvk/img/camera_200.png"; else if($this->isBanned()) - return "/assets/packages/static/openvk/img/banned.jpg"; + return "$serverUrl/assets/packages/static/openvk/img/banned.jpg"; $avPhoto = $this->getAvatarPhoto(); if(is_null($avPhoto)) - return "/assets/packages/static/openvk/img/camera_200.png"; + return "$serverUrl/assets/packages/static/openvk/img/camera_200.png"; else return $avPhoto->getURL(); }