diff --git a/config.php.default b/config.php.default index 490f9b6685..7e0713cc0b 100755 --- a/config.php.default +++ b/config.php.default @@ -21,7 +21,8 @@ $config['community'] = "public"; $config['base_url'] = "http://observer2.as8681.net"; ### Authentication model -$config['auth_mechanism'] = "mysql"; # default, other options: ldap +$config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth +#$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth # LDAP module configuration $config['auth_ldap_server'] = "ldap.yourserver.com"; diff --git a/html/includes/authenticate.inc.php b/html/includes/authenticate.inc.php index 521a5e0cb0..bf01c8672f 100644 --- a/html/includes/authenticate.inc.php +++ b/html/includes/authenticate.inc.php @@ -3,7 +3,6 @@ @ini_set("session.gc_maxlifetime","0"); session_start(); - if(isset($_GET['logout']) && $_SESSION['authenticated']) { mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('" . $_SESSION['username'] . "', '".$_SERVER["REMOTE_ADDR"]."', 'logged out')"); unset($_SESSION); @@ -24,21 +23,35 @@ if(isset($_COOKIE['username']) && isset($_COOKIE['password'])){ $_SESSION['password'] = mres($_COOKIE['password']); } +if(isset($_SERVER['REMOTE_USER'])) { + $_SESSION['username'] = mres($_SERVER['REMOTE_USER']); + // we don't set a password here because we're using HTTP AUTH +} + $auth_success = 0; -if ($_SESSION['username']) +if (isset($_SESSION['username'])) { - if ($config['auth_mechanism'] == "mysql" || !$config['auth_mechanism']) + if ($config['auth_mechanism'] == "mysql" || $config['auth_mechanism'] == "http-auth" || !$config['auth_mechanism']) { - $encrypted = md5($_SESSION['password']); - $sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username']."' AND `password`='".$encrypted."'"; - $query = mysql_query($sql); + $sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username']; + if ($config['auth_mechanism'] != "http-auth") + { + $encrypted = md5($_SESSION['password']); + $sql .= "' AND `password`='".$encrypted."';"; + } else { + $sql .= "';"; + } + $query = mysql_query($sql); $row = @mysql_fetch_array($query); if($row['username'] && $row['username'] == $_SESSION['username']) { $auth_success = 1; - } + } else { + $_SESSION['username'] = $config['http_auth_guest']; + $auth_success = 1; + } } - else if ($config['auth_mechanism'] == "ldap") + else if ($config['auth_mechanism'] == "ldap") { $ds=@ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']); if ($ds) @@ -82,10 +95,9 @@ if ($auth_success) { setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/"); } } -elseif ($_SESSION['username']) { +elseif (isset($_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')"); } - ?> diff --git a/html/includes/graphs/device_storage.inc.php b/html/includes/graphs/device_storage.inc.php index 9761752419..17ed85ed1d 100644 --- a/html/includes/graphs/device_storage.inc.php +++ b/html/includes/graphs/device_storage.inc.php @@ -20,8 +20,8 @@ include("common.inc.php"); $rrd_options .= " CDEF:$storage[storage_id]size=$storage[storage_id]used,$storage[storage_id]free,+"; $rrd_options .= " CDEF:$storage[storage_id]perc=$storage[storage_id]used,$storage[storage_id]size,/,100,*"; $rrd_options .= " LINE1.25:$storage[storage_id]perc#" . $colour . ":'$descr'"; - $rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%SB"; - $rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%SB"; + $rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\l"; $iter++; } diff --git a/html/includes/graphs/mempool.inc.php b/html/includes/graphs/mempool.inc.php index c240b7e839..9b6fc14487 100644 --- a/html/includes/graphs/mempool.inc.php +++ b/html/includes/graphs/mempool.inc.php @@ -6,20 +6,24 @@ include("common.inc.php"); $iter = "1"; $sql = mysql_query("SELECT * FROM `mempools` AS C, `devices` AS D where C.`mempool_id` = '".mres($_GET['id'])."' AND C.device_id = D.device_id"); - $rrd_options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n"; + $rrd_options .= " COMMENT:' Used\\n'"; while($mempool = mysql_fetch_array($sql)) { if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; } elseif($iter=="7") {$colour="FF0084"; unset($iter); } - $descr = substr(str_pad(short_hrDeviceDescr($mempool['mempool_descr']), 28),0,28); + $descr = substr(str_pad(short_hrDeviceDescr($mempool['mempool_descr']), 24),0,24); $descr = str_replace(":", "\:", $descr); $rrd = $config['rrd_dir'] . "/".$mempool['hostname']."/" . safename("mempool-".$mempool['mempool_type']."-".$mempool['mempool_index'].".rrd"); $rrd_options .= " DEF:mempoolfree=$rrd:free:AVERAGE "; $rrd_options .= " DEF:mempoolused=$rrd:used:AVERAGE "; - $rrd_options .= " CDEF:mempooltotal=mempoolused,mempoolused,mempoolfree,+,/,100,* "; - $rrd_options .= " LINE1:mempooltotal#" . $colour . ":'" . $descr . "' "; - $rrd_options .= " GPRINT:mempooltotal:LAST:%3.0lf"; - $rrd_options .= " GPRINT:mempooltotal:MAX:%3.0lf\\\l "; + $rrd_options .= " CDEF:mempooltotal=mempoolused,mempoolfree,+ "; + $rrd_options .= " CDEF:mempoolperc=mempoolused,mempoolused,mempoolfree,+,/,100,* "; + $rrd_options .= " LINE1:mempoolperc#" . $colour . ":'" . $descr . "' "; + $rrd_options .= " GPRINT:mempoolused:LAST:%6.2lf%sB"; + #$rrd_options .= " GPRINT:mempooltotal:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:mempoolperc:LAST:%3.0lf%%\\\\n"; + #$rrd_options .= " GPRINT:mempoolperc:MAX:%3.0lf"; + $iter++; } diff --git a/html/includes/graphs/storage.inc.php b/html/includes/graphs/storage.inc.php index a94673879d..d65a657862 100644 --- a/html/includes/graphs/storage.inc.php +++ b/html/includes/graphs/storage.inc.php @@ -23,8 +23,8 @@ $rrd_options .= " -b 1024"; $rrd_options .= " CDEF:$storage[storage_id]size=$storage[storage_id]used,$storage[storage_id]free,+"; $rrd_options .= " CDEF:$storage[storage_id]perc=$storage[storage_id]used,$storage[storage_id]size,/,100,*"; $rrd_options .= " LINE1.25:$storage[storage_id]perc#" . $colour . ":'$descr'"; - $rrd_options .= " GPRINT:$storage[storage_id]free:LAST:%6.2lf%SB"; - $rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%SB"; + $rrd_options .= " GPRINT:$storage[storage_id]free:LAST:%6.2lf%sB"; + $rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\n"; $iter++; } diff --git a/includes/static-config.php b/includes/static-config.php index 847b28f74c..e0086ff63e 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -98,7 +98,11 @@ if($config['enable_nagios']) { die; } $nagios_db = mysql_select_db($config['nagios_db_name'], $nagios_link); +} +# If we're on SSL, let's properly detect it +if(isset($_SERVER['HTTPS'])) { + $config['base_url'] = preg_replace('/^http:/','https:', $config['base_url']); } ### Connect to database