diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php
index 661a7a8f5..a882e83fd 100644
--- a/html/pages/authlog.inc.php
+++ b/html/pages/authlog.inc.php
@@ -1,215 +1,38 @@
Authlog";
+echo "
";
+if ($_SESSION['userlevel'] >= '10') {
+ echo '';
-$no_refresh = true;
+ foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) {
+ if ($bg == $list_colour_a) {
+ $bg = $list_colour_b;
+ }
+ else {
+ $bg = $list_colour_a;
+ }
-$pagetitle[] = 'Preferences';
+ echo "
+ |
+ ".$entry['datetime'].'
+ |
+
+ '.$entry['user'].'
+ |
+
+ '.$entry['address'].'
+ |
+
+ '.$entry['result'].'
+ |
+ |
+ ';
+ }//end foreach
-echo 'User Preferences
';
-echo '
';
+ $pagetitle[] = 'Authlog';
-if ($_SESSION['userlevel'] == 11) {
- demo_account();
+ echo '
';
}
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']) {
- changepassword($_SESSION['username'], $_POST['new_pass']);
- $changepass_message = 'Password Changed.';
- }
- else {
- $changepass_message = "Passwords don't match.";
- }
- }
- else {
- $changepass_message = 'Incorrect password';
- }
- }
-
- include 'includes/update-preferences-password.inc.php';
-
-
-
- if (passwordscanchange($_SESSION['username'])) {
- echo 'Change Password
';
- echo '
';
- echo "";
- echo $changepass_message;
- echo "
";
- echo '
';
- }//end if
-
- if ($config['twofactor'] === true) {
- if ($_POST['twofactorremove'] == 1) {
- include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php';
- if (!isset($_POST['twofactor'])) {
- echo '';
- }
- else {
- $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
- if (empty($twofactor['twofactor'])) {
- echo 'Error: How did you even get here?!
';
- }
- 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 'Error while disabling TwoFactor.
';
- }
- else {
- echo 'TwoFactor Disabled.
';
- }
- }
- else {
- session_destroy();
- echo 'Error: Supplied TwoFactor Token is wrong, you\'ve been logged out.
';
- }
- }//end if
- }
- else {
- $twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
- echo '';
- echo 'Two-Factor Authentication
';
- if (!empty($twofactor['twofactor'])) {
- $twofactor = json_decode($twofactor['twofactor'], true);
- $twofactor['text'] = "
";
- if ($twofactor['counter'] !== false) {
- $twofactor['uri'] = 'otpauth://hotp/'.$_SESSION['username'].'?issuer=LibreNMS&counter='.$twofactor['counter'].'&secret='.$twofactor['key'];
- $twofactor['text'] .= "
";
- }
- else {
- $twofactor['uri'] = 'otpauth://totp/'.$_SESSION['username'].'?issuer=LibreNMS&secret='.$twofactor['key'];
- }
-
- echo '
';
- echo '
-
-
-
';
- echo '';
- echo '
';
- }
- 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']));
- if (empty($chk['twofactor'])) {
- $twofactor = array('key' => twofactor_genkey());
- if ($_POST['twofactortype'] == 'counter') {
- $twofactor['counter'] = 1;
- }
- else {
- $twofactor['counter'] = false;
- }
-
- if (!dbUpdate(array('twofactor' => json_encode($twofactor)), 'users', 'username = ?', array($_SESSION['username']))) {
- echo '
Error inserting TwoFactor details. Please try again later and contact Administrator if error persists.
';
- }
- else {
- echo '
Added TwoFactor credentials. Please reload page.
';
- }
- }
- else {
- echo '
TwoFactor credentials already exists.
';
- }
- }
- else {
- echo '
';
- }//end if
- }//end if
- echo '
';
- }//end if
- }//end if
+ include 'includes/error-no-perm.inc.php';
}//end if
-
-
-echo "Device Permissions
";
-echo "
";
-echo "";
-if ($_SESSION['userlevel'] == '10') {
- echo "
Global Administrative Access";
-}
-
-if ($_SESSION['userlevel'] == '5') {
- echo "
Global Viewing Access";
-}
-
-if ($_SESSION['userlevel'] == '1') {
- foreach (dbFetchRows('SELECT * FROM `devices_perms` AS P, `devices` AS D WHERE `user_id` = ? AND P.device_id = D.device_id', array($_SESSION['user_id'])) as $perm) {
- // FIXME generatedevicelink?
- echo "
".$perm['hostname'].'';
- $dev_access = 1;
- }
-
- if (!$dev_access) {
- echo 'No access!';
- }
-}
-
-echo '
';