mirror of https://github.com/byecorps/id.git
Common files update
This commit is contained in:
parent
8ac041536a
commit
db40cfd3fb
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue