forked from Business/AccountHub
Remove lang() and lang2() and rewrite references
This commit is contained in:
parent
deca0d330d
commit
3763d0d485
64
api.php
64
api.php
@ -48,27 +48,27 @@ switch ($VARS['action']) {
|
||||
$errmsg = "";
|
||||
if (authenticate_user($VARS['username'], $VARS['password'], $errmsg)) {
|
||||
insertAuthLog(12, null, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "OK", "msg" => lang("login successful", false)]));
|
||||
exit(json_encode(["status" => "OK", "msg" => $Strings->get("login successful", false)]));
|
||||
} else {
|
||||
insertAuthLog(13, $uid, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
if (!is_empty($errmsg)) {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang2("ldap error", ['error' => $errmsg], false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->build("ldap error", ['error' => $errmsg], false)]));
|
||||
}
|
||||
if (user_exists($VARS['username'])) {
|
||||
switch (get_account_status($VARS['username'])) {
|
||||
case "LOCKED_OR_DISABLED":
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("account locked", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("account locked", false)]));
|
||||
case "TERMINATED":
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("account terminated", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("account terminated", false)]));
|
||||
case "CHANGE_PASSWORD":
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("password expired", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("password expired", false)]));
|
||||
case "NORMAL":
|
||||
break;
|
||||
default:
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("account state error", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("account state error", false)]));
|
||||
}
|
||||
}
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
break;
|
||||
case "userinfo":
|
||||
@ -78,7 +78,7 @@ switch ($VARS['action']) {
|
||||
$data['pin'] = (is_null($data['pin']) || $data['pin'] == "" ? false : true);
|
||||
exit(json_encode(["status" => "OK", "data" => $data]));
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
} else if (!is_empty($VARS['uid'])) {
|
||||
if ($database->has('accounts', ['uid' => $VARS['uid']])) {
|
||||
@ -86,7 +86,7 @@ switch ($VARS['action']) {
|
||||
$data['pin'] = (is_null($data['pin']) || $data['pin'] == "" ? false : true);
|
||||
exit(json_encode(["status" => "OK", "data" => $data]));
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
@ -119,7 +119,7 @@ switch ($VARS['action']) {
|
||||
exit(json_encode(["status" => "OK", "valid" => true]));
|
||||
} else {
|
||||
insertAuthLog(7, null, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("2fa incorrect", false), "valid" => false]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("2fa incorrect", false), "valid" => false]));
|
||||
}
|
||||
break;
|
||||
case "acctstatus":
|
||||
@ -133,13 +133,13 @@ switch ($VARS['action']) {
|
||||
switch (get_account_status($VARS['username'])) {
|
||||
case "LOCKED_OR_DISABLED":
|
||||
insertAuthLog(5, $uid, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("account locked", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("account locked", false)]));
|
||||
case "TERMINATED":
|
||||
insertAuthLog(5, $uid, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("account terminated", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("account terminated", false)]));
|
||||
case "CHANGE_PASSWORD":
|
||||
insertAuthLog(5, $uid, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("password expired", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("password expired", false)]));
|
||||
case "NORMAL":
|
||||
insertAuthLog(4, $uid, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "OK"]));
|
||||
@ -149,14 +149,14 @@ switch ($VARS['action']) {
|
||||
exit(json_encode(["status" => "OK", "alert" => true]));
|
||||
default:
|
||||
insertAuthLog(5, $uid, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("account state error", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("account state error", false)]));
|
||||
}
|
||||
} else {
|
||||
insertAuthLog(5, null, "Username: " . strtolower($VARS['username']) . ", Key: " . getCensoredKey());
|
||||
if (!is_empty($errmsg)) {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang2("ldap error", ['error' => $errmsg], false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->build("ldap error", ['error' => $errmsg], false)]));
|
||||
}
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
break;
|
||||
case "ismanagerof":
|
||||
@ -166,10 +166,10 @@ switch ($VARS['action']) {
|
||||
$managerid = $VARS['manager'];
|
||||
$employeeid = $VARS['employee'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false), "user" => $VARS['employee']]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false), "user" => $VARS['employee']]));
|
||||
}
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false), "user" => $VARS['manager']]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false), "user" => $VARS['manager']]));
|
||||
}
|
||||
} else {
|
||||
if (user_exists_local($VARS['manager'])) {
|
||||
@ -177,10 +177,10 @@ switch ($VARS['action']) {
|
||||
$managerid = $database->select('accounts', 'uid', ['username' => strtolower($VARS['manager'])]);
|
||||
$employeeid = $database->select('accounts', 'uid', ['username' => strtolower($VARS['employee'])]);
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false), "user" => strtolower($VARS['employee'])]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false), "user" => strtolower($VARS['employee'])]));
|
||||
}
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false), "user" => strtolower($VARS['manager'])]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false), "user" => strtolower($VARS['manager'])]));
|
||||
}
|
||||
}
|
||||
if ($database->has('managers', ['AND' => ['managerid' => $managerid, 'employeeid' => $employeeid]])) {
|
||||
@ -194,13 +194,13 @@ switch ($VARS['action']) {
|
||||
if ($database->has("accounts", ['uid' => $VARS['uid']])) {
|
||||
$managerid = $VARS['uid'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else if ($VARS['username']) {
|
||||
if ($database->has("accounts", ['username' => strtolower($VARS['username'])])) {
|
||||
$managerid = $database->select('accounts', 'uid', ['username' => strtolower($VARS['username'])]);
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
@ -218,13 +218,13 @@ switch ($VARS['action']) {
|
||||
if ($database->has("accounts", ['uid' => $VARS['uid']])) {
|
||||
$empid = $VARS['uid'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else if ($VARS['username']) {
|
||||
if ($database->has("accounts", ['username' => strtolower($VARS['username'])])) {
|
||||
$empid = $database->select('accounts', 'uid', ['username' => strtolower($VARS['username'])]);
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
@ -250,13 +250,13 @@ switch ($VARS['action']) {
|
||||
if ($database->has("accounts", ['uid' => $VARS['uid']])) {
|
||||
$user = $database->select('accounts', ['username'], ['uid' => $VARS['uid']])[0]['username'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else if ($VARS['username']) {
|
||||
if ($database->has("accounts", ['username' => strtolower($VARS['username'])])) {
|
||||
$user = $VARS['username'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
@ -296,7 +296,7 @@ switch ($VARS['action']) {
|
||||
$user = $database->get("onetimekeys", ["[>]accounts" => ["uid" => "uid"]], ["username", "realname", "accounts.uid"], ["key" => $VARS['code']]);
|
||||
exit(json_encode(["status" => "OK", "user" => $user]));
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("no such code or code expired", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("no such code or code expired", false)]));
|
||||
}
|
||||
case "listapps":
|
||||
$apps = EXTERNAL_APPS;
|
||||
@ -312,7 +312,7 @@ switch ($VARS['action']) {
|
||||
if ($database->has("groups", ['groupid' => $VARS['gid']])) {
|
||||
$groupid = $VARS['gid'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("group does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("group does not exist", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
@ -339,13 +339,13 @@ switch ($VARS['action']) {
|
||||
if ($database->has("accounts", ['uid' => $VARS['uid']])) {
|
||||
$empid = $VARS['uid'];
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else if ($VARS['username']) {
|
||||
if ($database->has("accounts", ['username' => strtolower($VARS['username'])])) {
|
||||
$empid = $database->select('accounts', 'uid', ['username' => strtolower($VARS['username'])]);
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("user does not exist", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("user does not exist", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
@ -375,13 +375,13 @@ switch ($VARS['action']) {
|
||||
if (user_exists_local($VARS['username'])) {
|
||||
$pin = $database->get("accounts", "pin", ["username" => strtolower($VARS['username'])]);
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
} else if (!is_empty($VARS['uid'])) {
|
||||
if ($database->has('accounts', ['uid' => $VARS['uid']])) {
|
||||
$pin = $database->get("accounts", "pin", ["uid" => strtolower($VARS['uid'])]);
|
||||
} else {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
} else {
|
||||
http_response_code(400);
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
dieifnotloggedin();
|
||||
|
||||
$APPS["404_error"]["title"] = lang("404 error", false);
|
||||
$APPS["404_error"]["title"] = $Strings->get("404 error", false);
|
||||
$APPS["404_error"]["icon"] = "times";
|
||||
$APPS["404_error"]["type"] = "warning";
|
||||
$APPS["404_error"]["content"] = "<h4>" . lang("page not found", false) . "</h4>";
|
||||
$APPS["404_error"]["content"] = "<h4>" . $Strings->get("page not found", false) . "</h4>";
|
||||
?>
|
@ -6,12 +6,12 @@
|
||||
|
||||
dieifnotloggedin();
|
||||
|
||||
$oldpass = lang("current password", false);
|
||||
$newpass = lang("new password", false);
|
||||
$conpass = lang("confirm password", false);
|
||||
$change = lang("change password", false);
|
||||
$oldpass = $Strings->get("current password", false);
|
||||
$newpass = $Strings->get("new password", false);
|
||||
$conpass = $Strings->get("confirm password", false);
|
||||
$change = $Strings->get("change password", false);
|
||||
|
||||
$APPS["change_password"]["title"] = lang("change password", false);
|
||||
$APPS["change_password"]["title"] = $Strings->get("change password", false);
|
||||
$APPS["change_password"]["icon"] = "key";
|
||||
$APPS["change_password"]["content"] = <<<CONTENTEND
|
||||
<form action="action.php" method="POST">
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
dieifnotloggedin();
|
||||
|
||||
$newpin = lang("new pin", false);
|
||||
$conpin = lang("confirm pin", false);
|
||||
$change = lang("change pin", false);
|
||||
$pinexp = lang("pin explanation", false);
|
||||
$newpin = $Strings->get("new pin", false);
|
||||
$conpin = $Strings->get("confirm pin", false);
|
||||
$change = $Strings->get("change pin", false);
|
||||
$pinexp = $Strings->get("pin explanation", false);
|
||||
|
||||
|
||||
$APPS["change_pin"]["title"] = lang("change pin", false);
|
||||
$APPS["change_pin"]["title"] = $Strings->get("change pin", false);
|
||||
$APPS["change_pin"]["icon"] = "th";
|
||||
$APPS["change_pin"]["content"] = <<<CONTENTEND
|
||||
<div class="alert alert-info"><i class="fa fa-info-circle"></i> $pinexp</div>
|
||||
|
@ -13,12 +13,12 @@ use Endroid\QrCode\QrCode;
|
||||
// extra login utils
|
||||
require_once __DIR__ . "/../lib/login.php";
|
||||
|
||||
$APPS["setup_2fa"]["title"] = lang("setup 2fa", false);
|
||||
$APPS["setup_2fa"]["title"] = $Strings->get("setup 2fa", false);
|
||||
$APPS["setup_2fa"]["icon"] = "lock";
|
||||
if (userHasTOTP($_SESSION['username'])) {
|
||||
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("2fa active", false) . '</div>'
|
||||
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . $Strings->get("2fa active", false) . '</div>'
|
||||
. '<a href="action.php?action=rm2fa&source=security" class="btn btn-warning btn-sm btn-block">'
|
||||
. lang("remove 2fa", false) . '</a>';
|
||||
. $Strings->get("remove 2fa", false) . '</a>';
|
||||
} else if ($_GET['2fa'] == "generate") {
|
||||
$codeuri = newTOTP($_SESSION['username']);
|
||||
$userdata = $database->select('accounts', ['email', 'authsecret', 'realname'], ['username' => $_SESSION['username']])[0];
|
||||
@ -32,12 +32,12 @@ if (userHasTOTP($_SESSION['username'])) {
|
||||
$totp = Factory::loadFromProvisioningUri($codeuri);
|
||||
$codesecret = $totp->getSecret();
|
||||
$chunk_secret = trim(chunk_split($codesecret, 4, ' '));
|
||||
$lang_manualsetup = lang("manual setup", false);
|
||||
$lang_secretkey = lang("secret key", false);
|
||||
$lang_label = lang("label", false);
|
||||
$lang_issuer = lang("issuer", false);
|
||||
$lang_entercode = lang("enter otp code", false);
|
||||
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("scan 2fa qrcode", false) . '</div>' . <<<END
|
||||
$lang_manualsetup = $Strings->get("manual setup", false);
|
||||
$lang_secretkey = $Strings->get("secret key", false);
|
||||
$lang_label = $Strings->get("label", false);
|
||||
$lang_issuer = $Strings->get("issuer", false);
|
||||
$lang_entercode = $Strings->get("enter otp code", false);
|
||||
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . $Strings->get("scan 2fa qrcode", false) . '</div>' . <<<END
|
||||
<style nonce="$SECURE_NONCE">
|
||||
.margintop-15px {
|
||||
margin-top: 15px;
|
||||
@ -57,7 +57,7 @@ if (userHasTOTP($_SESSION['username'])) {
|
||||
<input type="hidden" name="secret" value="$codesecret" />
|
||||
<button type="submit" class="btn btn-success btn-sm btn-block">
|
||||
END
|
||||
. lang("confirm 2fa", false) . <<<END
|
||||
. $Strings->get("confirm 2fa", false) . <<<END
|
||||
</button>
|
||||
</form>
|
||||
<div class="panel panel-default margintop-15px">
|
||||
@ -73,7 +73,7 @@ END
|
||||
</div>
|
||||
END;
|
||||
} else {
|
||||
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("2fa explained", false) . '</div>'
|
||||
$APPS["setup_2fa"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . $Strings->get("2fa explained", false) . '</div>'
|
||||
. '<a class="btn btn-success btn-sm btn-block" href="home.php?page=security&2fa=generate">'
|
||||
. lang("enable 2fa", false) . '</a>';
|
||||
. $Strings->get("enable 2fa", false) . '</a>';
|
||||
}
|
@ -11,7 +11,7 @@ use Endroid\QrCode\QrCode;
|
||||
|
||||
if (MOBILE_ENABLED) {
|
||||
|
||||
$APPS["sync_mobile"]["title"] = lang("sync mobile", false);
|
||||
$APPS["sync_mobile"]["title"] = $Strings->get("sync mobile", false);
|
||||
$APPS["sync_mobile"]["icon"] = "mobile";
|
||||
|
||||
if (!is_empty($_GET['delsynccode'])) {
|
||||
@ -40,9 +40,9 @@ if (MOBILE_ENABLED) {
|
||||
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH);
|
||||
$qrcode = $qrCode->writeDataUri();
|
||||
$chunk_code = trim(chunk_split($code, 5, ' '));
|
||||
$lang_done = lang("done adding sync code", false);
|
||||
$lang_done = $Strings->get("done adding sync code", false);
|
||||
$APPS["sync_mobile"]["content"] = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> '
|
||||
. lang("scan sync qrcode", false)
|
||||
. $Strings->get("scan sync qrcode", false)
|
||||
. '</div>'
|
||||
. <<<END
|
||||
<style nonce="$SECURE_NONCE">
|
||||
@ -59,13 +59,13 @@ if (MOBILE_ENABLED) {
|
||||
<div class="panel panel-default margintop-15px">
|
||||
<div class="panel-body">
|
||||
END
|
||||
. "<b>" . lang("manual setup", false) . "</b><br /><label>" . lang("username", false) . ":</label>"
|
||||
. "<b>" . $Strings->get("manual setup", false) . "</b><br /><label>" . $Strings->get("username", false) . ":</label>"
|
||||
. '<div class="well well-sm mono-chunk">' . $_SESSION['username'] . '</div>'
|
||||
. "<label>" . lang("sync key", false) . "</label>"
|
||||
. "<label>" . $Strings->get("sync key", false) . "</label>"
|
||||
. <<<END
|
||||
<div class="well well-sm mono-chunk">$chunk_code</div>
|
||||
END
|
||||
. "<label>" . lang("url", false) . "</label>"
|
||||
. "<label>" . $Strings->get("url", false) . "</label>"
|
||||
. <<<END
|
||||
<div class="well well-sm mono-chunk">$url</div>
|
||||
</div>
|
||||
@ -74,17 +74,17 @@ END
|
||||
END;
|
||||
} else {
|
||||
$activecodes = $database->select("mobile_codes", ["codeid", "code"], ["uid" => $_SESSION['uid']]);
|
||||
$content = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("sync explained", false) . '</div>'
|
||||
$content = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . $Strings->get("sync explained", false) . '</div>'
|
||||
. '<a class="btn btn-success btn-sm btn-block" href="home.php?page=sync&mobilecode=generate">'
|
||||
. lang("generate sync", false) . '</a>';
|
||||
$content .= "<br /><b>" . lang("active sync codes", false) . ":</b><br />";
|
||||
. $Strings->get("generate sync", false) . '</a>';
|
||||
$content .= "<br /><b>" . $Strings->get("active sync codes", false) . ":</b><br />";
|
||||
$content .= "<div class='list-group'>";
|
||||
if (count($activecodes) > 0) {
|
||||
foreach ($activecodes as $c) {
|
||||
$content .= "<div class='list-group-item mobilekey'><span id=\"mobilecode\">" . trim(chunk_split($c['code'], 5, ' ')) . "</span> <span class='tinybuttons'><a class='btn btn-primary btn-sm' href='home.php?page=sync&mobilecode=generate&showsynccode=" . $c['codeid'] . "'><i class='fa fa-qrcode'></i></a> <a class='btn btn-danger btn-sm' href='home.php?page=sync&delsynccode=" . $c['codeid'] . "'><i class='fa fa-trash'></i></a></span></div>";
|
||||
}
|
||||
} else {
|
||||
$content .= "<div class='list-group-item'>" . lang("no active codes", false) . "</div>";
|
||||
$content .= "<div class='list-group-item'>" . $Strings->get("no active codes", false) . "</div>";
|
||||
}
|
||||
$content .= "</div>";
|
||||
$content .= <<<END
|
||||
|
14
home.php
14
home.php
@ -98,7 +98,7 @@ if (!is_empty($_GET['page'])) {
|
||||
if (isset($pg['icon'])) {
|
||||
$item .= '<i class="fa fa-' . $pg['icon'] . ' fa-fw"></i>';
|
||||
}
|
||||
$item .= lang($pg['title'], false) . '</a>';
|
||||
$item .= $Strings->get($pg['title'], false) . '</a>';
|
||||
echo '<li class="hidden-sm hidden-md">' . $item . "</li>";
|
||||
$more .= '<li>' . $item . "</li>";
|
||||
} else {
|
||||
@ -117,7 +117,7 @@ if (!is_empty($_GET['page'])) {
|
||||
?>
|
||||
<i class="fa fa-<?php echo $pg['icon']; ?> fa-fw"></i>
|
||||
<?php } ?>
|
||||
<?php lang($pg['title']) ?>
|
||||
<?php $Strings->get($pg['title']) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
@ -128,14 +128,14 @@ if (!is_empty($_GET['page'])) {
|
||||
if ($counter > 4) {
|
||||
?>
|
||||
<li class="dropdown hidden-lg hidden-xs">
|
||||
<a href="" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v fa-fw"></i> <?php lang("more"); ?></a>
|
||||
<a href="" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v fa-fw"></i> <?php $Strings->get("more"); ?></a>
|
||||
<ul class="dropdown-menu"><?php echo $more; ?></ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="home.php"><i class="fa fa-user fa-fw"></i> <span class=""><?php echo $_SESSION['realname'] ?></span></a></li>
|
||||
<li><a href="action.php?action=signout"><i class="fa fa-sign-out fa-fw"></i> <span class=""><?php lang("sign out") ?></span></a></li>
|
||||
<li><a href="action.php?action=signout"><i class="fa fa-sign-out fa-fw"></i> <span class=""><?php $Strings->get("sign out") ?></span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
@ -177,9 +177,9 @@ if (!is_empty($_GET['page'])) {
|
||||
if (!is_empty($_GET['msg']) && array_key_exists($_GET['msg'], MESSAGES)) {
|
||||
// optional string generation argument
|
||||
if (is_empty($_GET['arg'])) {
|
||||
$alertmsg = lang(MESSAGES[$_GET['msg']]['string'], false);
|
||||
$alertmsg = $Strings->get(MESSAGES[$_GET['msg']]['string'], false);
|
||||
} else {
|
||||
$alertmsg = lang2(MESSAGES[$_GET['msg']]['string'], ["arg" => $_GET['arg']], false);
|
||||
$alertmsg = $Strings->build(MESSAGES[$_GET['msg']]['string'], ["arg" => $_GET['arg']], false);
|
||||
}
|
||||
$alerttype = MESSAGES[$_GET['msg']]['type'];
|
||||
$alerticon = "square-o";
|
||||
@ -242,7 +242,7 @@ END;
|
||||
if (!isset($APPS[$app])) {
|
||||
continue;
|
||||
}
|
||||
$apptitle = ($APPS[$app]['i18n'] === TRUE ? lang($APPS[$app]['title'], false) : $APPS[$app]['title']);
|
||||
$apptitle = ($APPS[$app]['i18n'] === TRUE ? $Strings->get($APPS[$app]['title'], false) : $APPS[$app]['title']);
|
||||
$appicon = (is_empty($APPS[$app]['icon']) ? "" : "fa fa-fw fa-" . $APPS[$app]['icon']);
|
||||
$apptype = (is_empty($APPS[$app]['type']) ? "default" : $APPS[$app]['type']);
|
||||
$appcontent = $APPS[$app]['content'];
|
||||
|
38
index.php
38
index.php
@ -13,7 +13,7 @@ if ($_SESSION['loggedin'] && !is_empty($_SESSION['password'])) {
|
||||
die();
|
||||
// This branch will likely run if the user signed in from a different app.
|
||||
} else if ($_SESSION['loggedin'] && is_empty($_SESSION['password'])) {
|
||||
$alert = lang("sign in again", false);
|
||||
$alert = $Strings->get("sign in again", false);
|
||||
$alerttype = "info";
|
||||
}
|
||||
|
||||
@ -29,13 +29,13 @@ if ($VARS['progress'] == "1") {
|
||||
$status = get_account_status($VARS['username'], $error);
|
||||
switch ($status) {
|
||||
case "LOCKED_OR_DISABLED":
|
||||
$alert = lang("account locked", false);
|
||||
$alert = $Strings->get("account locked", false);
|
||||
break;
|
||||
case "TERMINATED":
|
||||
$alert = lang("account terminated", false);
|
||||
$alert = $Strings->get("account terminated", false);
|
||||
break;
|
||||
case "CHANGE_PASSWORD":
|
||||
$alert = lang("password expired", false);
|
||||
$alert = $Strings->get("password expired", false);
|
||||
$alerttype = "info";
|
||||
$_SESSION['username'] = strtolower($VARS['username']);
|
||||
$_SESSION['uid'] = $database->get('accounts', 'uid', ['username' => strtolower($VARS['username'])]);
|
||||
@ -55,7 +55,7 @@ if ($VARS['progress'] == "1") {
|
||||
if (!is_empty($error)) {
|
||||
$alert = $error;
|
||||
} else {
|
||||
$alert = lang("login error", false);
|
||||
$alert = $Strings->get("login error", false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -76,17 +76,17 @@ if ($VARS['progress'] == "1") {
|
||||
$alert = $autherror;
|
||||
insertAuthLog(2, null, "Username: " . $VARS['username']);
|
||||
} else {
|
||||
$alert = lang("login incorrect", false);
|
||||
$alert = $Strings->get("login incorrect", false);
|
||||
insertAuthLog(2, null, "Username: " . $VARS['username']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // User does not exist anywhere
|
||||
$alert = lang("login incorrect", false);
|
||||
$alert = $Strings->get("login incorrect", false);
|
||||
insertAuthLog(2, null, "Username: " . $VARS['username']);
|
||||
}
|
||||
} else {
|
||||
$alert = lang("captcha error", false);
|
||||
$alert = $Strings->get("captcha error", false);
|
||||
insertAuthLog(8, null, "Username: " . $VARS['username']);
|
||||
}
|
||||
} else if ($VARS['progress'] == "2") {
|
||||
@ -101,7 +101,7 @@ if ($VARS['progress'] == "1") {
|
||||
header('Location: home.php');
|
||||
die("Logged in, go to home.php");
|
||||
} else {
|
||||
$alert = lang("2fa incorrect", false);
|
||||
$alert = $Strings->get("2fa incorrect", false);
|
||||
insertAuthLog(6, null, "Username: " . $VARS['username']);
|
||||
}
|
||||
} else if ($VARS['progress'] == "chpasswd") {
|
||||
@ -110,22 +110,22 @@ if ($VARS['progress'] == "1") {
|
||||
$error = [];
|
||||
$result = change_password($VARS['oldpass'], $VARS['newpass'], $VARS['conpass'], $error);
|
||||
if ($result === TRUE) {
|
||||
$alert = lang(MESSAGES["password_updated"]["string"], false);
|
||||
$alert = $Strings->get(MESSAGES["password_updated"]["string"], false);
|
||||
$alerttype = MESSAGES["password_updated"]["type"];
|
||||
}
|
||||
switch (count($error)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$alert = lang(MESSAGES[$error[0]]["string"], false);
|
||||
$alert = $Strings->get(MESSAGES[$error[0]]["string"], false);
|
||||
$alerttype = MESSAGES[$error[0]]["type"];
|
||||
break;
|
||||
case 2:
|
||||
$alert = lang2(MESSAGES[$error[0]]["string"], ["arg" => $error[1]], false);
|
||||
$alert = $Strings->build(MESSAGES[$error[0]]["string"], ["arg" => $error[1]], false);
|
||||
$alerttype = MESSAGES[$error[0]]["type"];
|
||||
break;
|
||||
default:
|
||||
$alert = lang(MESSAGES["generic_op_error"]["string"], false);
|
||||
$alert = $Strings->get(MESSAGES["generic_op_error"]["string"], false);
|
||||
$alerttype = MESSAGES["generic_op_error"]["type"];
|
||||
}
|
||||
} else {
|
||||
@ -165,7 +165,7 @@ if ($VARS['progress'] == "1") {
|
||||
</div>
|
||||
<div class="panel panel-orange">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php lang("sign in"); ?></h3>
|
||||
<h3 class="panel-title"><?php $Strings->get("sign in"); ?></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form action="" method="POST">
|
||||
@ -199,8 +199,8 @@ if ($VARS['progress'] == "1") {
|
||||
|
||||
if (!$multiauth && !$change_password) {
|
||||
?>
|
||||
<input type="text" class="form-control" name="username" placeholder="<?php lang("username"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
|
||||
<input type="password" class="form-control" name="password" placeholder="<?php lang("password"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><br />
|
||||
<input type="text" class="form-control" name="username" placeholder="<?php $Strings->get("username"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
|
||||
<input type="password" class="form-control" name="password" placeholder="<?php $Strings->get("password"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><br />
|
||||
<?php if (CAPTCHA_ENABLED) { ?>
|
||||
<div class="captcheck_container" data-stylenonce="<?php echo $SECURE_NONCE; ?>"></div>
|
||||
<br />
|
||||
@ -210,9 +210,9 @@ if ($VARS['progress'] == "1") {
|
||||
} else if ($multiauth) {
|
||||
?>
|
||||
<div class="alert alert-info">
|
||||
<?php lang("2fa prompt"); ?>
|
||||
<?php $Strings->get("2fa prompt"); ?>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="authcode" placeholder="<?php lang("authcode"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
|
||||
<input type="text" class="form-control" name="authcode" placeholder="<?php $Strings->get("authcode"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
|
||||
<input type="hidden" name="progress" value="2" />
|
||||
<input type="hidden" name="username" value="<?php echo $VARS['username']; ?>" />
|
||||
<?php
|
||||
@ -226,7 +226,7 @@ if ($VARS['progress'] == "1") {
|
||||
}
|
||||
?>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<?php lang("continue"); ?>
|
||||
<?php $Strings->get("continue"); ?>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -325,8 +325,8 @@ function sendLoginAlertEmail($username, $appname = SITE_TITLE) {
|
||||
$mail->setFrom(FROM_EMAIL, 'Account Alerts');
|
||||
$mail->addAddress(ADMIN_EMAIL, "System Admin");
|
||||
$mail->isHTML(false);
|
||||
$mail->Subject = lang("admin alert email subject", false);
|
||||
$mail->Body = lang2("admin alert email message", ["username" => $username, "datetime" => date("Y-m-d H:i:s"), "ipaddr" => getClientIP(), "appname" => $appname], false);
|
||||
$mail->Subject = $Strings->get("admin alert email subject", false);
|
||||
$mail->Body = $Strings->build("admin alert email message", ["username" => $username, "datetime" => date("Y-m-d H:i:s"), "ipaddr" => getClientIP(), "appname" => $appname], false);
|
||||
|
||||
if (!$mail->send()) {
|
||||
return $mail->ErrorInfo;
|
||||
|
@ -21,7 +21,7 @@ if ($VARS['action'] == "ping") {
|
||||
}
|
||||
|
||||
if (MOBILE_ENABLED !== TRUE) {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("mobile login disabled", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("mobile login disabled", false)]));
|
||||
}
|
||||
|
||||
// Make sure we have a username and access key
|
||||
@ -60,7 +60,7 @@ switch ($VARS['action']) {
|
||||
engageRateLimit();
|
||||
if (get_account_status($username) != "NORMAL") {
|
||||
insertAuthLog(20, null, "Username: " . $username . ", Key: " . $key);
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login failed try on web", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login failed try on web", false)]));
|
||||
}
|
||||
if (authenticate_user($username, $VARS['password'], $autherror)) {
|
||||
$uid = $database->get("accounts", "uid", ["username" => $username]);
|
||||
@ -72,14 +72,14 @@ switch ($VARS['action']) {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $autherror]));
|
||||
} else {
|
||||
insertAuthLog(20, null, "Username: " . $username . ", Key: " . $key);
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
}
|
||||
case "user_info":
|
||||
engageRateLimit();
|
||||
if (get_account_status($username) != "NORMAL") {
|
||||
insertAuthLog(20, null, "Username: " . $username . ", Key: " . $key);
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login failed try on web", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login failed try on web", false)]));
|
||||
}
|
||||
if (authenticate_user($username, $VARS['password'], $autherror)) {
|
||||
$userinfo = $database->get("accounts", ["uid", "username", "realname", "email"], ["username" => $username]);
|
||||
@ -91,7 +91,7 @@ switch ($VARS['action']) {
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $autherror]));
|
||||
} else {
|
||||
insertAuthLog(20, null, "Username: " . $username . ", Key: " . $key);
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
}
|
||||
}
|
||||
case "start_session":
|
||||
@ -107,7 +107,7 @@ switch ($VARS['action']) {
|
||||
}
|
||||
}
|
||||
insertAuthLog(20, null, "Username: " . $username . ", Key: " . $key);
|
||||
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
|
||||
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("login incorrect", false)]));
|
||||
case "listapps":
|
||||
$apps = EXTERNAL_APPS;
|
||||
// Format paths as absolute URLs
|
||||
|
40
required.php
40
required.php
@ -131,46 +131,6 @@ function is_empty($str) {
|
||||
return (is_null($str) || !isset($str) || $str == '');
|
||||
}
|
||||
|
||||
/**
|
||||
* I18N string getter. If the key doesn't exist, outputs the key itself.
|
||||
* @param string $key I18N string key
|
||||
* @param boolean $echo whether to echo the result or return it (default echo)
|
||||
*/
|
||||
function lang($key, $echo = true) {
|
||||
global $Strings;
|
||||
return $Strings->get($key, $echo);
|
||||
}
|
||||
|
||||
/**
|
||||
* I18N string getter (with builder). If the key doesn't exist, outputs the key itself.
|
||||
* @param string $key I18N string key
|
||||
* @param array $replace key-value array of replacements.
|
||||
* If the string value is "hello {abc}" and you give ["abc" => "123"], the
|
||||
* result will be "hello 123".
|
||||
* @param boolean $echo whether to echo the result or return it (default echo)
|
||||
*/
|
||||
function lang2($key, $replace, $echo = true) {
|
||||
global $Strings;
|
||||
return $Strings->build($key, $replace, $echo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add strings to the i18n global array.
|
||||
* @param array $strings ['key' => 'value']
|
||||
*/
|
||||
function addLangStrings($strings) {
|
||||
$GLOBALS['STRINGS'] = array_merge($GLOBALS['STRINGS'], $strings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add strings to the i18n global array. Accepts an array of language code
|
||||
* keys, with the values a key-value array of strings.
|
||||
* @param array $strings ['en_us' => ['key' => 'value']]
|
||||
*/
|
||||
function addMultiLangStrings($strings) {
|
||||
throw new Exception("Calling broken function addMultiLangStrings()");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an email address is valid.
|
||||
* @param string $email Email to check
|
||||
|
Loading…
x
Reference in New Issue
Block a user