diff --git a/server_files/controllers/informations.php b/server_files/controllers/informations.php index 9e463f1..46b5659 100644 --- a/server_files/controllers/informations.php +++ b/server_files/controllers/informations.php @@ -41,6 +41,14 @@ if (isset($_POST["attribute_team"])) { } } +if (isset($_POST["view_as"]) && $_SESSION["role"] == Role::ADMIN) { + if (!isset($_SESSION["admin"])) + $_SESSION["admin"] = $_SESSION["user_id"]; + $_SESSION["user_id"] = $user->getId(); + header("Location: /"); + exit(); +} + class AttributeTeam { private $team_id; diff --git a/server_files/model.php b/server_files/model.php index 26f5c15..07aeeaa 100644 --- a/server_files/model.php +++ b/server_files/model.php @@ -19,6 +19,15 @@ function loadUserValues() if ($user->getTeamId() !== null) $_SESSION["team"] = Team::fromId($user->getTeamId()); } + + if (isset($_GET["view-as-admin"])) { + if (isset($_SESSION["admin"])) { + $_SESSION["user_id"] = $_SESSION["admin"]; + unset($_SESSION["admin"]); + } + header("Location: /"); + exit(); + } } function quitTeam($user_id = -1) @@ -277,17 +286,23 @@ function exportProblemsData() { function displayVideo($link) { - if (preg_match("#(https?\://|)(www\.|)youtube\.com\/watch\?v=(.*)#", $link, $matches)) { + if (preg_match("#(https?://|)(www\.|)youtube\.com/watch\?v=(.*)#", $link, $matches)) { $code = $matches[3]; - echo "

\n"; + /** @noinspection HtmlDeprecatedAttribute */ + /** @noinspection HtmlDeprecatedTag */ + echo "

\n"; } - elseif (preg_match("#(https?\://|)(www\.|)vimeo\.com/([0-9]*)#", $link, $matches)) { + elseif (preg_match("#(https?://|)(www\.|)vimeo\.com/([0-9]*)#", $link, $matches)) { $code = $matches[3]; - echo "
"; + /** @noinspection HtmlDeprecatedAttribute */ + /** @noinspection HtmlDeprecatedTag */ + echo "
"; } - elseif (preg_match("#(https?\://|)(www\.|)dailymotion\.com/video/(.*)#", $link, $matches)) { + elseif (preg_match("#(https?://|)(www\.|)dailymotion\.com/video/(.*)#", $link, $matches)) { $code = $matches[3]; + /** @noinspection HtmlDeprecatedAttribute */ + /** @noinspection HtmlDeprecatedTag */ echo "
"; } } \ No newline at end of file diff --git a/server_files/views/header.php b/server_files/views/header.php index 336dc07..0331485 100644 --- a/server_files/views/header.php +++ b/server_files/views/header.php @@ -96,6 +96,11 @@