diff options
author | mischa <mischa@rx.high5.nl> | 2022-08-09 07:32:41 +0000 |
---|---|---|
committer | mischa <mischa@rx.high5.nl> | 2022-08-09 07:32:41 +0000 |
commit | bdbc900c161d7c6a6d9c986fc7ed26ab4b782baa (patch) | |
tree | 228fde1cad77587d8b9a111e097ea49776261037 | |
parent | a1d717c8a88b6556348d43ecf4d1ceb78b169572 (diff) |
rework check_language function, user_main.tpl: userid -> sessidmain
-rw-r--r-- | functions.inc.php | 48 | ||||
-rw-r--r-- | templates/users_main.tpl | 2 |
2 files changed, 20 insertions, 30 deletions
diff --git a/functions.inc.php b/functions.inc.php index 3f0b3b6..6311346 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -34,12 +34,10 @@ function check_session () return $SESSID_USERNAME; } -function check_user_session () -{ - session_start (); - if (!$_SESSION['sessid']['username']) - { - header ("Location: login.php"); +function check_user_session() { + session_start(); + if (!isset($_SESSION['sessid']['username'])) { + header("Location: login.php"); exit; } $USERID_USERNAME = $_SESSION['sessid']['username']; @@ -53,33 +51,25 @@ function check_user_session () // Action: checks what language the browser uses // Call: check_language // -function check_language () -{ - global $CONF; - $supported_languages = array ('en'); - $lang_array = preg_split ('/(\s*,\s*)/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); - if (is_array ($lang_array)) - { - $lang_first = strtolower ((trim (strval ($lang_array[0])))); - $lang_first = substr ($lang_first, 0, 2); - if (in_array ($lang_first, $supported_languages)) - { - $lang = $lang_first; - } - else - { - $lang = $CONF['default_language']; - } - } - else - { - $lang = $CONF['default_language']; - } - return $lang; +function check_language() { + global $CONF; + $supported_languages = array ('en'); + if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $lang_array = preg_split ('/(\s*,\s*)/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + if (is_array($lang_array)) { + $lang_first = strtolower((trim(strval($lang_array[0])))); + $lang_first = substr($lang_first, 0, 2); + if (in_array($lang_first, $supported_languages)) { + return $lang_first; + } + } + } + return $CONF['default_language']; } + // // check_string // Action: checks if a string is valid and returns TRUE is this is the case. diff --git a/templates/users_main.tpl b/templates/users_main.tpl index 3b455ad..4cbf7ea 100644 --- a/templates/users_main.tpl +++ b/templates/users_main.tpl @@ -2,7 +2,7 @@ <table> <tr> <td> </td> - <td><?php print $_SESSION['userid']['username']; ?></td> + <td><?php print $_SESSION['sessid']['username']; ?></td> </tr> <?php if ($CONF['vacation'] == 'YES') { ?> <tr> |