mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-27 16:08:55 +02:00
more fixes and updates from sid3windr
git-svn-id: http://www.observium.org/svn/observer/trunk@579 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -26,12 +26,39 @@ if($_COOKIE['username'] && $_COOKIE['password']){
|
||||
$_SESSION['password'] = mres($_COOKIE['password']);
|
||||
}
|
||||
|
||||
$auth_success = 0;
|
||||
|
||||
$encrypted = md5($_SESSION['password']);
|
||||
$sql = "SELECT * FROM `users` WHERE `username`='".$_SESSION['username']."' AND `password`='".$encrypted."'";
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
if($row['username'] && $row['username'] == $_SESSION['username']) {
|
||||
if ($config['auth_mechanism'] == "mysql")
|
||||
{
|
||||
$encrypted = md5($_SESSION['password']);
|
||||
$sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username']."' AND `password`='".$encrypted."'";
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
if($row['username'] && $row['username'] == $_SESSION['username']) {
|
||||
$auth_success = 1;
|
||||
}
|
||||
}
|
||||
else if ($config['auth_mechanism'] == "ldap")
|
||||
{
|
||||
$ds=@ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']);
|
||||
if ($ds)
|
||||
{
|
||||
if (ldap_bind($ds, $config['auth_ldap_prefix'] . $_SESSION['username'] . $config['auth_ldap_suffix'], $_SESSION['password']))
|
||||
{
|
||||
$auth_success = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "ERROR: no valid auth_mechanism defined.";
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($auth_success) {
|
||||
$sql = "SELECT * FROM `users` WHERE `username`='".$_SESSION['username']."'";
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
$_SESSION['userlevel'] = $row['level'];
|
||||
$_SESSION['user_id'] = $row['user_id'];
|
||||
if(!$_SESSION['authenticated']) {
|
||||
@@ -39,11 +66,12 @@ if($row['username'] && $row['username'] == $_SESSION['username']) {
|
||||
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'logged in')");
|
||||
header("Location: ".$_SERVER['REQUEST_URI']);
|
||||
}
|
||||
if(isset($_POST['remember'])){
|
||||
if(isset($_POST['remember'])) {
|
||||
setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
|
||||
setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
|
||||
}
|
||||
} elseif ($_SESSION['username']) {
|
||||
}
|
||||
elseif ($_SESSION['username']) {
|
||||
$auth_message = "Authentication Failed";
|
||||
unset ($_SESSION['authenticated']);
|
||||
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'authentication failure')");
|
||||
|
||||
Reference in New Issue
Block a user