Common files update

This commit is contained in:
bye 2024-07-03 14:20:33 +01:00
parent 8ac041536a
commit db40cfd3fb
2 changed files with 24 additions and 2 deletions

View file

@ -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();
}

View file

@ -1,6 +1,6 @@
<?php
function get_string($key="generic.generic") {
function get_string($key="generic.generic", $substitutes=[]) {
global $LANG;
$key_path = explode('.', $key);
@ -15,10 +15,20 @@ function get_string($key="generic.generic") {
}
}
if (count($substitutes) > 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;