Skip to content

Commit

Permalink
Change asset() function in showtime.php to return absolute URL
Browse files Browse the repository at this point in the history
remp/remp#1282

(cherry picked from commit c695752)
  • Loading branch information
Matus Kalafut authored and rootpd committed Jul 25, 2023
1 parent 17feb13 commit 000875a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion Campaign/public/showtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,22 @@
* @return string
*/
function asset($path, $secure = null) {
return '//' . $_SERVER['HTTP_HOST'] . '/' . trim($path, '/');
return ((isSecure() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/' . trim($path, '/'));
}

function isSecure(): bool
{
if ((isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] === 'on') || ($_SERVER['HTTPS'] === '1')))
|| (isset($_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] === 443)) {
return true;
}

if ((!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
|| (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on')) {
return true;
}

return false;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion changelogs/CHANGELOG-v3.1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [3.1] - 2023-07-24

- [3.1.1] [Campaign]: Changed `asset()` function in `showtime.php` to return absolute URL. remp/remp#1282

### [Beam]

- Added make commands `update-dev` and `update-prod` to update development and production environments respectively after new code is pulled. remp/remp#1281
Expand All @@ -25,7 +27,7 @@

---

[3.1]: https://github.com/remp2020/remp/compare/3.0.0...3.1.0
[3.1.1]: https://github.com/remp2020/remp/compare/3.1.0...3.1.1

[Beam]: https://github.com/remp2020/remp/tree/master/Beam
[Campaign]: https://github.com/remp2020/remp/tree/master/Campaign
Expand Down

0 comments on commit 000875a

Please sign in to comment.