mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
PSR2 Cleanup: /html edition
Travis tests for code conformance. Ignore warnings for now. Fixed all errors, left most warnings.
This commit is contained in:
@@ -9,22 +9,18 @@ echo '<hr>';
|
||||
|
||||
if ($_SESSION['userlevel'] == 11) {
|
||||
demo_account();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ($_POST['action'] == 'changepass') {
|
||||
if (authenticate($_SESSION['username'], $_POST['old_pass'])) {
|
||||
if ($_POST['new_pass'] == '' || $_POST['new_pass2'] == '') {
|
||||
$changepass_message = 'Password must not be blank.';
|
||||
}
|
||||
else if ($_POST['new_pass'] == $_POST['new_pass2']) {
|
||||
} elseif ($_POST['new_pass'] == $_POST['new_pass2']) {
|
||||
changepassword($_SESSION['username'], $_POST['new_pass']);
|
||||
$changepass_message = 'Password Changed.';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$changepass_message = "Passwords don't match.";
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$changepass_message = 'Incorrect password';
|
||||
}
|
||||
}
|
||||
@@ -79,31 +75,26 @@ else {
|
||||
echo '<input type="hidden" name="twofactorremove" value="1" />';
|
||||
echo twofactor_form(false);
|
||||
echo '</form></div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
|
||||
if (empty($twofactor['twofactor'])) {
|
||||
echo '<div class="alert alert-danger">Error: How did you even get here?!</div><script>window.location = "preferences/";</script>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$twofactor = json_decode($twofactor['twofactor'], true);
|
||||
}
|
||||
|
||||
if (verify_hotp($twofactor['key'], $_POST['twofactor'], $twofactor['counter'])) {
|
||||
if (!dbUpdate(array('twofactor' => ''), 'users', 'username = ?', array($_SESSION['username']))) {
|
||||
echo '<div class="alert alert-danger">Error while disabling TwoFactor.</div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<div class="alert alert-success">TwoFactor Disabled.</div>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
session_destroy();
|
||||
echo '<div class="alert alert-danger">Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.</div><script>window.location = "' . $config['base_url'] . '";</script>';
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
|
||||
echo '<script src="js/jquery.qrcode.min.js"></script>';
|
||||
echo '<div class="well"><h3>Two-Factor Authentication</h3>';
|
||||
@@ -123,8 +114,7 @@ else {
|
||||
<input type='text' name='twofactorcounter' autocomplete='off' disabled class='form-control input-sm' value='".$twofactor['counter']."' />
|
||||
</div>
|
||||
</div>";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key'];
|
||||
}
|
||||
|
||||
@@ -141,8 +131,7 @@ else {
|
||||
<input type="hidden" name="twofactorremove" value="1" />
|
||||
<button class="btn btn-danger" type="submit">Disable TwoFactor</button>
|
||||
</form>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (isset($_POST['gentwofactorkey']) && isset($_POST['twofactortype'])) {
|
||||
include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php';
|
||||
$chk = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
|
||||
@@ -150,23 +139,19 @@ else {
|
||||
$twofactor = array('key' => twofactor_genkey());
|
||||
if ($_POST['twofactortype'] == 'counter') {
|
||||
$twofactor['counter'] = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$twofactor['counter'] = false;
|
||||
}
|
||||
|
||||
if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) {
|
||||
echo '<div class="alert alert-danger">Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.</div>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<div class="alert alert-success">Added TwoFactor credentials. Please reload page.</div><script>window.location = "preferences/";</script>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<div class="alert alert-danger">TwoFactor credentials already exists.</div>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo '<form method="post" class="form-horizontal" role="form">
|
||||
<input type="hidden" name="gentwofactorkey" value="1" />
|
||||
<div class="form-group">
|
||||
|
||||
Reference in New Issue
Block a user