fix: Clean up errors in the webui (#4438)

This commit is contained in:
Tony Murray
2016-09-15 02:46:26 -05:00
committed by Neil Lathwood
parent 83d7bbdd1b
commit 36f6338ad6
6 changed files with 22 additions and 15 deletions

View File

@@ -47,11 +47,11 @@ class ObjectCache implements ArrayAccess
if (isset($GLOBALS['_ObjCache'][$obj])) { if (isset($GLOBALS['_ObjCache'][$obj])) {
$this->data = $GLOBALS['_ObjCacheSkell'][$obj]; $this->data = $GLOBALS['_ObjCacheSkell'][$obj];
} else { } else {
if (!is_array($GLOBALS['_ObjCacheSkell'])) { if (!isset($GLOBALS['_ObjCacheSkell']) || !is_array($GLOBALS['_ObjCacheSkell'])) {
$GLOBALS['_ObjCacheSkell'] = array(); $GLOBALS['_ObjCacheSkell'] = array();
} }
if (!is_array($GLOBALS['_ObjCache'])) { if (!isset($GLOBALS['_ObjCache']) || !is_array($GLOBALS['_ObjCache'])) {
$GLOBALS['_ObjCache'] = array(); $GLOBALS['_ObjCache'] = array();
} }
@@ -60,7 +60,7 @@ class ObjectCache implements ArrayAccess
include $config['install_dir'].'/includes/caches/'.$obj.'.inc.php'; include $config['install_dir'].'/includes/caches/'.$obj.'.inc.php';
$this->data = $data; $this->data = $data;
$GLOBALS['_ObjCacheSkell'][$obj] = $this->data; $GLOBALS['_ObjCacheSkell'][$obj] = $this->data;
if (!is_array($GLOBALS['_ObjCache'][$obj])) { if (!(isset($GLOBALS['_ObjCache'][$obj]) && is_array($GLOBALS['_ObjCache'][$obj]))) {
$GLOBALS['_ObjCache'][$obj] = $this->data; $GLOBALS['_ObjCache'][$obj] = $this->data;
} }
} }
@@ -96,7 +96,7 @@ class ObjectCache implements ArrayAccess
} elseif (isset($GLOBALS['_ObjCache'][$this->obj][$obj]['value'])) { } elseif (isset($GLOBALS['_ObjCache'][$this->obj][$obj]['value'])) {
return $GLOBALS['_ObjCache'][$this->obj][$obj]['value']; return $GLOBALS['_ObjCache'][$this->obj][$obj]['value'];
} else { } else {
$GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = dbFetchRows($this->data[$obj]['query'], $this->data[$obj]['params']); $GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = dbFetchRows($this->data[$obj]['query'], isset($this->data[$obj]['params']) ? $this->data[$obj]['params'] : array());
if (sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value']) == 1 && sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]) == 1) { if (sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value']) == 1 && sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]) == 1) {
$GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = current($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]); $GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = current($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]);
} }

View File

@@ -36,6 +36,7 @@ function authenticate($username, $password)
array('memberOf') array('memberOf')
); );
$entries = ldap_get_entries($ldap_connection, $search); $entries = ldap_get_entries($ldap_connection, $search);
unset($entries[0]['memberof']['count']); //remove the annoying count
foreach ($entries[0]['memberof'] as $entry) { foreach ($entries[0]['memberof'] as $entry) {
$group_cn = get_cn($entry); $group_cn = get_cn($entry);
@@ -162,11 +163,13 @@ function get_userlevel($username)
array('memberOf') array('memberOf')
); );
$entries = ldap_get_entries($ldap_connection, $search); $entries = ldap_get_entries($ldap_connection, $search);
unset($entries[0]['memberof']['count']);
// Loop the list and find the highest level // Loop the list and find the highest level
foreach ($entries[0]['memberof'] as $entry) { foreach ($entries[0]['memberof'] as $entry) {
$group_cn = get_cn($entry); $group_cn = get_cn($entry);
if ($config['auth_ad_groups'][$group_cn]['level'] > $userlevel) { if (isset($config['auth_ad_groups'][$group_cn]['level']) &&
$config['auth_ad_groups'][$group_cn]['level'] > $userlevel) {
$userlevel = $config['auth_ad_groups'][$group_cn]['level']; $userlevel = $config['auth_ad_groups'][$group_cn]['level'];
} }
} }
@@ -353,13 +356,13 @@ function get_cn($dn)
{ {
$dn = str_replace('\\,', '~C0mmA~', $dn); $dn = str_replace('\\,', '~C0mmA~', $dn);
preg_match('/[^,]*/', $dn, $matches, PREG_OFFSET_CAPTURE, 3); preg_match('/[^,]*/', $dn, $matches, PREG_OFFSET_CAPTURE, 3);
$matches[0][0] = str_replace('~C0mmA~', ',', $matches[0][0]); return str_replace('~C0mmA~', ',', $matches[0][0]);
return $matches[0][0];
} }
function sid_from_ldap($sid) function sid_from_ldap($sid)
{ {
$sidHex = unpack('H*hex', $sid); $sidUnpacked = unpack('H*hex', $sid);
$sidHex = array_shift($sidUnpacked);
$subAuths = unpack('H2/H2/n/N/V*', $sid); $subAuths = unpack('H2/H2/n/N/V*', $sid);
$revLevel = hexdec(substr($sidHex, 0, 2)); $revLevel = hexdec(substr($sidHex, 0, 2));
$authIdent = hexdec(substr($sidHex, 4, 12)); $authIdent = hexdec(substr($sidHex, 4, 12));

View File

@@ -56,7 +56,7 @@ if (!empty($filter_device)) {
foreach ($results as $data) { foreach ($results as $data) {
$tmp_output .= '"<option value=\"'.$data['hostname'].'\""+'; $tmp_output .= '"<option value=\"'.$data['hostname'].'\""+';
if ($data['hostname'] == $vars['hostname']) { if (isset($vars['hostname']) && $data['hostname'] == $vars['hostname']) {
$tmp_output .= '"selected"+'; $tmp_output .= '"selected"+';
} }
$tmp_output .= '">'.$data['hostname'].'</option>"+'; $tmp_output .= '">'.$data['hostname'].'</option>"+';
@@ -67,7 +67,7 @@ if (!empty($filter_device)) {
'; ';
} }
if (empty($filter_device)) { if (empty($filter_device) && isset($_POST['hostname'])) {
$filter_device = mres($_POST['hostname']); $filter_device = mres($_POST['hostname']);
} }
@@ -96,7 +96,7 @@ $tmp_output .= '
rowCount: ['. $results_limit .', 25,50,100,250,-1], rowCount: ['. $results_limit .', 25,50,100,250,-1],
'; ';
if ($no_form !== true) { if (isset($no_form) && $no_form !== true) {
$tmp_output .= ' $tmp_output .= '
templates: { templates: {
header: searchbar header: searchbar
@@ -109,8 +109,8 @@ $tmp_output .= '
{ {
return { return {
id: "graylog", id: "graylog",
hostname: "' . $filter_device . '", hostname: "' . (isset($filter_device) ? $filter_device : '') . '",
range: "' . mres($_POST['range']) . '" range: "' . (isset($_POST['range']) ? mres($_POST['range']) : '') . '"
}; };
}, },
url: "ajax_table.php", url: "ajax_table.php",

View File

@@ -19,6 +19,8 @@ if (isset($config['enable_bgp']) && $config['enable_bgp']) {
if (isset($config['site_style']) && ($config['site_style'] == 'dark' || $config['site_style'] == 'mono')) { if (isset($config['site_style']) && ($config['site_style'] == 'dark' || $config['site_style'] == 'mono')) {
$navbar = 'navbar-inverse'; $navbar = 'navbar-inverse';
} else {
$navbar = '';
} }
?> ?>
@@ -142,6 +144,7 @@ if (is_module_enabled('poller', 'mib')) {
<ul class="dropdown-menu scrollable-menu"> <ul class="dropdown-menu scrollable-menu">
<?php <?php
$param = array();
if (is_admin() === true || is_read() === true) { if (is_admin() === true || is_read() === true) {
$sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`"; $sql = "SELECT `type`,COUNT(`type`) AS total_type FROM `devices` AS D WHERE 1 GROUP BY `type` ORDER BY `type`";
} else { } else {

View File

@@ -1,4 +1,5 @@
<?php <?php
$no_refresh = true;
require_once 'includes/common/graylog.inc.php'; require_once 'includes/common/graylog.inc.php';
echo implode('', $common_output); echo implode('', $common_output);

View File

@@ -12,7 +12,7 @@
* the source code distribution for details. * the source code distribution for details.
*/ */
if ($config['influxdb']['enable'] === true) { if (isset($config['influxdb']['enable']) && $config['influxdb']['enable'] === true) {
include $config['install_dir'].'/lib/influxdb-php/vendor/autoload.php'; include $config['install_dir'].'/lib/influxdb-php/vendor/autoload.php';
}//end if }//end if