diff --git a/common/account_utils.php b/common/account_utils.php index 884d8da..8ee181f 100644 --- a/common/account_utils.php +++ b/common/account_utils.php @@ -72,3 +72,15 @@ function get_user_display_name($userId, $escape = true) { return $display_name; } + +function requires_auth($redirect = '/auth/login') { + global $path_raw; + + if ($_SESSION['auth']) { + return true; + } + + http_response_code(307); + header('Location: '.$redirect.'?callback='.urlencode($path_raw)); + exit(); +} diff --git a/common/strings.php b/common/strings.php index 618ad18..93333e7 100644 --- a/common/strings.php +++ b/common/strings.php @@ -1,6 +1,6 @@ 0) { + foreach ($substitutes as $key => $substitute) { + $re = '/{{('. $key .')}}/'; + $subst = $substitute; + + $result = preg_replace($re, $subst, $result, 1); + } + } + return $result; } -function patch_lang($lang="en") { +function patch_lang($lang="en"): void +{ global $LANG, $DOC_ROOT;