diff --git a/app.php b/app.php index 5cfcc36..b74d422 100644 --- a/app.php +++ b/app.php @@ -1,5 +1,4 @@ ; rel=preload; as=script", fals get(MESSAGES[$_GET['msg']]['string'], false); + if (!empty($_GET['msg'])) { + if (array_key_exists($_GET['msg'], MESSAGES)) { + // optional string generation argument + if (empty($_GET['arg'])) { + $alertmsg = $Strings->get(MESSAGES[$_GET['msg']]['string'], false); + } else { + $alertmsg = $Strings->build(MESSAGES[$_GET['msg']]['string'], ["arg" => strip_tags($_GET['arg'])], false); + } + $alerttype = MESSAGES[$_GET['msg']]['type']; + $alerticon = "square-o"; + switch (MESSAGES[$_GET['msg']]['type']) { + case "danger": + $alerticon = "times"; + break; + case "warning": + $alerticon = "exclamation-triangle"; + break; + case "info": + $alerticon = "info-circle"; + break; + case "success": + $alerticon = "check"; + break; + } } else { - $alertmsg = $Strings->build(MESSAGES[$_GET['msg']]['string'], ["arg" => strip_tags($_GET['arg'])], false); - } - $alerttype = MESSAGES[$_GET['msg']]['type']; - $alerticon = "square-o"; - switch (MESSAGES[$_GET['msg']]['type']) { - case "danger": - $alerticon = "times"; - break; - case "warning": - $alerticon = "exclamation-triangle"; - break; - case "info": - $alerticon = "info-circle"; - break; - case "success": - $alerticon = "check"; - break; + // We don't have a message for this, so just assume an error and escape stuff. + $alertmsg = htmlentities($Strings->get($_GET['msg'], false)); + $alerticon = "times"; + $alerttype = "danger"; } echo << diff --git a/index.php b/index.php index 3c992b3..1f8f76f 100644 --- a/index.php +++ b/index.php @@ -47,7 +47,7 @@ if (Login::checkLoginServer()) { $username_ok = true; break; default: - if (!is_empty($error)) { + if (!empty($error)) { $alert = $error; } else { $alert = $Strings->get("login error", false); diff --git a/lib/Strings.lib.php b/lib/Strings.lib.php index b094bbf..b03058f 100644 --- a/lib/Strings.lib.php +++ b/lib/Strings.lib.php @@ -21,6 +21,10 @@ class Strings { $this->load("en"); + if ($language == "en") { + return; + } + if (file_exists(__DIR__ . "/../langs/$language/")) { $this->language = $language; $this->load($language); diff --git a/mobile/index.php b/mobile/index.php index 5cc4575..de36d52 100644 --- a/mobile/index.php +++ b/mobile/index.php @@ -75,7 +75,7 @@ if (mobile_enabled() !== TRUE) { } // Make sure we have a username and access key -if (is_empty($VARS['username']) || is_empty($VARS['key'])) { +if (empty($VARS['username']) || empty($VARS['key'])) { http_response_code(401); die(json_encode(["status" => "ERROR", "msg" => "Missing username and/or access key."])); } diff --git a/required.php b/required.php index c296dcb..c67229f 100644 --- a/required.php +++ b/required.php @@ -133,6 +133,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } /** + * @deprecated * Checks if a string or whatever is empty. * @param $str The thingy to check * @return boolean True if it's empty or whatever.