diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 20189f67b..f241c1a9a 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -75,7 +75,7 @@ function generatedevicelink($device, $text=0, $start=0, $end=0) } $text = htmlentities($text); $link = overlib_link($url, $text, $contents, $class); - if(devicepermitted($device['device_id'])) { + if(device_permitted($device['device_id'])) { return $link; } else { return $device['hostname']; @@ -156,13 +156,14 @@ function bill_permitted($bill_id) return $allowed; } -function interfacepermitted($interface_id, $device_id = NULL) +function port_permitted($interface_id, $device_id = NULL) { global $_SESSION; global $permissions; - if(!$device_id) { $device_id = mysql_result(mysql_query("SELECT `device_id` from ports WHERE interface_id = '".$interface_id."'"),0); } + if(!is_numeric($device_id)) { $device_id = get_device_id_by_interface_id($interface_id); } + if ($_SESSION['userlevel'] >= "5") { $allowed = TRUE; - } elseif ( devicepermitted($device_id)) { + } elseif ( device_permitted($device_id)) { $allowed = TRUE; } elseif ( $permissions['port'][$interface_id]) { $allowed = TRUE; @@ -172,7 +173,29 @@ function interfacepermitted($interface_id, $device_id = NULL) return $allowed; } -function devicepermitted($device_id) +function application_permitted($app_id, $device_id = NULL) +{ + global $_SESSION; global $permissions; + if(is_numeric($app_id)) + { + if(!$device_id) { $device_id = device_by_id_cache ($app_id); } + if ($_SESSION['userlevel'] >= "5") { + $allowed = TRUE; + } elseif ( device_permitted($device_id)) { + $allowed = TRUE; + } elseif ( $permissions['application'][$app_id]) { + $allowed = TRUE; + } else { + $allowed = FALSE; + } + } else { + $allowed = FALSE; + } + return $allowed; +} + + +function device_permitted($device_id) { global $_SESSION; global $permissions; if ($_SESSION['userlevel'] >= "5") { @@ -250,7 +273,7 @@ function generate_if_link($args, $text = NULL) $url = $config['base_url']."/device/".$args['device_id']."/interface/" . $args['interface_id'] . "/"; - if(interfacepermitted($args['interface_id'])) { + if(port_permitted($args['interface_id'])) { return overlib_link($url, $text, $content, $class); } else { return fixifName($text); diff --git a/html/includes/graphs/application/apache_bytes.inc.php b/html/includes/graphs/application/apache_bytes.inc.php index fb62e3479..677dece2d 100755 --- a/html/includes/graphs/application/apache_bytes.inc.php +++ b/html/includes/graphs/application/apache_bytes.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/apache_cpu.inc.php b/html/includes/graphs/application/apache_cpu.inc.php index 668baccc6..c41a98378 100755 --- a/html/includes/graphs/application/apache_cpu.inc.php +++ b/html/includes/graphs/application/apache_cpu.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/apache_hits.inc.php b/html/includes/graphs/application/apache_hits.inc.php index f696e0ebc..061caaf3c 100755 --- a/html/includes/graphs/application/apache_hits.inc.php +++ b/html/includes/graphs/application/apache_hits.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/apache_scoreboard.inc.php b/html/includes/graphs/application/apache_scoreboard.inc.php index 89e02e406..70c5733b2 100755 --- a/html/includes/graphs/application/apache_scoreboard.inc.php +++ b/html/includes/graphs/application/apache_scoreboard.inc.php @@ -2,12 +2,7 @@ include("includes/graphs/common.inc.php"); -$query = mysql_query("SELECT * FROM `applications` AS A, `devices` AS D WHERE A.app_id = '".mres($_GET['id'])."' - AND A.device_id = D.device_id"); - -$app = mysql_fetch_array($query); - -$apache_rrd = $config['rrd_dir'] . "/" . $app['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; if(is_file($apache_rrd)) { $rrd_filename = $apache_rrd; diff --git a/html/includes/graphs/application/auth.inc.php b/html/includes/graphs/application/auth.inc.php new file mode 100644 index 000000000..d73038bb6 --- /dev/null +++ b/html/includes/graphs/application/auth.inc.php @@ -0,0 +1,12 @@ + diff --git a/html/includes/graphs/customer/auth.inc.php b/html/includes/graphs/customer/auth.inc.php new file mode 100755 index 000000000..921d689bb --- /dev/null +++ b/html/includes/graphs/customer/auth.inc.php @@ -0,0 +1,10 @@ += "5") +{ + $id = mres($_GET['id']); + $title = generatedevicelink($device); + $auth = TRUE; +} + +?> diff --git a/html/includes/graphs/device/auth.inc.php b/html/includes/graphs/device/auth.inc.php index 3109b12c2..8fdbe9994 100644 --- a/html/includes/graphs/device/auth.inc.php +++ b/html/includes/graphs/device/auth.inc.php @@ -1,11 +1,10 @@ diff --git a/html/includes/graphs/diskio/auth.inc.php b/html/includes/graphs/diskio/auth.inc.php new file mode 100644 index 000000000..89bd5d7f8 --- /dev/null +++ b/html/includes/graphs/diskio/auth.inc.php @@ -0,0 +1,24 @@ + diff --git a/html/includes/graphs/diskio/bits.inc.php b/html/includes/graphs/diskio/bits.inc.php index 83aceb370..5b6058f2d 100644 --- a/html/includes/graphs/diskio/bits.inc.php +++ b/html/includes/graphs/diskio/bits.inc.php @@ -1,14 +1,5 @@ ".$rrd_cmd.""); } -# $thing = popen($config['rrdtool'] . " -",'w'); -# fputs($thing, "graph $graphfile $rrd_options"); -# pclose($thing); - if(is_file($graphfile)) { - header('Content-type: image/png'); - $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); - unlink($graphfile); - } else { - header('Content-type: image/png'); - $string = "Graph Generation Error"; - $im = imagecreate($width, $height); - $orange = imagecolorallocate($im, 255, 255, 255); - $px = (imagesx($im) - 7.5 * strlen($string)) / 2; - imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0)); - imagepng($im); - imagedestroy($im); + if($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; } + $rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches; + $woo = shell_exec($rrd_cmd); + if($_GET['debug']) { echo("
".$rrd_cmd."
"); } +# $thing = popen($config['rrdtool'] . " -",'w'); +# fputs($thing, "graph $graphfile $rrd_options"); +# pclose($thing); + if(is_file($graphfile)) { + header('Content-type: image/png'); + $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); + unlink($graphfile); + } else { + header('Content-type: image/png'); + $string = "Graph Generation Error"; + $im = imagecreate($width, $height); + $orange = imagecolorallocate($im, 255, 255, 255); + $px = (imagesx($im) - 7.5 * strlen($string)) / 2; + imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0)); + imagepng($im); + imagedestroy($im); + } } + } else { + $fd = fopen($config['install_dir']."/html/images/no-48.png",r);fpassthru($fd);fclose($fd); } - ?> diff --git a/html/includes/graphs/mempool/auth.inc.php b/html/includes/graphs/mempool/auth.inc.php new file mode 100755 index 000000000..3a8b7614c --- /dev/null +++ b/html/includes/graphs/mempool/auth.inc.php @@ -0,0 +1,18 @@ + diff --git a/html/includes/graphs/mempool/usage.inc.php b/html/includes/graphs/mempool/usage.inc.php index 1a709bf08..db38b0cfd 100644 --- a/html/includes/graphs/mempool/usage.inc.php +++ b/html/includes/graphs/mempool/usage.inc.php @@ -5,27 +5,23 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " -u 100 -l 0 -E -b 1024 "; $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:' 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']), 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,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++; - } + $rrd_options .= " COMMENT:' Used\\n'"; + 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']), 24),0,24); + $descr = str_replace(":", "\:", $descr); + + $rrd_options .= " DEF:mempoolfree=$rrd_filename:free:AVERAGE "; + $rrd_options .= " DEF:mempoolused=$rrd_filename:used:AVERAGE "; + $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"; ?> diff --git a/html/includes/graphs/port/auth.inc.php b/html/includes/graphs/port/auth.inc.php index 3c0751793..13f221032 100644 --- a/html/includes/graphs/port/auth.inc.php +++ b/html/includes/graphs/port/auth.inc.php @@ -1,14 +1,11 @@ diff --git a/html/includes/graphs/processor/auth.inc.php b/html/includes/graphs/processor/auth.inc.php new file mode 100755 index 000000000..0e9df72f1 --- /dev/null +++ b/html/includes/graphs/processor/auth.inc.php @@ -0,0 +1,15 @@ + diff --git a/html/includes/graphs/processor/usage.inc.php b/html/includes/graphs/processor/usage.inc.php index c1179e3aa..9f3291762 100755 --- a/html/includes/graphs/processor/usage.inc.php +++ b/html/includes/graphs/processor/usage.inc.php @@ -1,5 +1,4 @@ diff --git a/html/includes/graphs/sensor/auth.inc.php b/html/includes/graphs/sensor/auth.inc.php index 07c6d7cb1..1fd0d832b 100644 --- a/html/includes/graphs/sensor/auth.inc.php +++ b/html/includes/graphs/sensor/auth.inc.php @@ -1,8 +1,23 @@ diff --git a/html/includes/graphs/sensor/current.inc.php b/html/includes/graphs/sensor/current.inc.php index 8e6ed8ecf..9c7755e63 100644 --- a/html/includes/graphs/sensor/current.inc.php +++ b/html/includes/graphs/sensor/current.inc.php @@ -4,18 +4,14 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("current-" . $sensor['sensor_descr'] . ".rrd"); + $rrd_options .= " COMMENT:' Last Max\\n'"; - $current = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='current' AND sensor_id = '".mres($_GET['id'])."'")); - - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $current['device_id'] . "'"),0); - - $current['sensor_descr_fixed'] = substr(str_pad($current['sensor_descr'], 28),0,28); - - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("current-" . $current['sensor_descr'] . ".rrd"); + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); $rrd_options .= " DEF:current=$rrd_filename:current:AVERAGE"; - $rrd_options .= " LINE1.5:current#cc0000:'" . $current['sensor_descr_fixed']."'"; + $rrd_options .= " LINE1.5:current#cc0000:'" . $sensor['sensor_descr_fixed']."'"; $rrd_options .= " GPRINT:current:LAST:%3.0lfA"; $rrd_options .= " GPRINT:current:MAX:%3.0lfA\\\\l"; diff --git a/html/includes/graphs/sensor/fanspeed.inc.php b/html/includes/graphs/sensor/fanspeed.inc.php new file mode 100644 index 000000000..982d250f0 --- /dev/null +++ b/html/includes/graphs/sensor/fanspeed.inc.php @@ -0,0 +1,18 @@ + diff --git a/html/includes/graphs/sensor/frequency.inc.php b/html/includes/graphs/sensor/frequency.inc.php index a6ad07fa0..a81e5c83b 100644 --- a/html/includes/graphs/sensor/frequency.inc.php +++ b/html/includes/graphs/sensor/frequency.inc.php @@ -4,18 +4,14 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("freq-" . $sensor['sensor_descr'] . ".rrd"); + $rrd_options .= " COMMENT:' Last Max\\n'"; - $frequency = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_class='freq' AND sensor_id = '".mres($_GET['id'])."'")); - - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $frequency['device_id'] . "'"),0); - - $frequency['sensor_descr_fixed'] = substr(str_pad($frequency['sensor_descr'], 28),0,28); - - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("freq-" . $frequency['sensor_descr'] . ".rrd"); + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); $rrd_options .= " DEF:freq=$rrd_filename:freq:AVERAGE"; - $rrd_options .= " LINE1.5:freq#cc0000:'" . $frequency['sensor_descr_fixed']."'"; + $rrd_options .= " LINE1.5:freq#cc0000:'" . $sensor['sensor_descr_fixed']."'"; $rrd_options .= " GPRINT:freq:LAST:%3.0lfHz"; $rrd_options .= " GPRINT:freq:MAX:%3.0lfHz\\\\l"; diff --git a/html/includes/graphs/sensor/humidity.inc.php b/html/includes/graphs/sensor/humidity.inc.php index 512668163..3c6757bbb 100644 --- a/html/includes/graphs/sensor/humidity.inc.php +++ b/html/includes/graphs/sensor/humidity.inc.php @@ -7,29 +7,23 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " COMMENT:' Last Max\\n'"; - $humidity = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND sensor_id = '".mres($_GET['id'])."'")); + $rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("humidity-" . $sensor['sensor_descr'] . ".rrd"); - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $humidity['device_id'] . "'"),0); - - $humidity['sensor_descr_fixed'] = substr(str_pad($humidity['sensor_descr'], 28),0,28); - - $rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("humidity-" . $humidity['sensor_descr'] . ".rrd"); + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 28),0,28); $rrd_options .= " DEF:humidity=$rrd_filename:humidity:AVERAGE"; $rrd_options .= " DEF:humidity_max=$rrd_filename:humidity:MAX"; $rrd_options .= " DEF:humidity_min=$rrd_filename:humidity:MIN"; - $rrd_options .= " CDEF:humiditywarm=humidity_max,".$humidity['sensor_limit'].",GT,humidity,UNKN,IF"; + $rrd_options .= " CDEF:humiditywarm=humidity_max,".$sensor['sensor_limit'].",GT,humidity,UNKN,IF"; $rrd_options .= " CDEF:humiditycold=humidity_min,20,LT,humidity,UNKN,IF"; $rrd_options .= " AREA:humidity_max#c5c5c5"; $rrd_options .= " AREA:humidity_min#ffffffff"; - - # $rrd_options .= " AREA:humidity#bbd392"; # $rrd_options .= " AREA:humiditywarm#FFCCCC"; # $rrd_options .= " AREA:humiditycold#CCCCFF"; - $rrd_options .= " LINE1:humidity#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($humidity['sensor_descr_fixed'])))."'"; # Ugly hack :( + $rrd_options .= " LINE1:humidity#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($sensor['sensor_descr_fixed'])))."'"; # Ugly hack :( $rrd_options .= " LINE1:humiditywarm#660000"; $rrd_options .= " GPRINT:humidity:LAST:%3.0lf%%"; $rrd_options .= " GPRINT:humidity:MAX:%3.0lf%%\\\\l"; diff --git a/html/includes/graphs/sensor/temperature.inc.php b/html/includes/graphs/sensor/temperature.inc.php index 86ce17a23..d0b8da519 100644 --- a/html/includes/graphs/sensor/temperature.inc.php +++ b/html/includes/graphs/sensor/temperature.inc.php @@ -7,14 +7,13 @@ include("includes/graphs/common.inc.php"); $rrd_options .= " COMMENT:' Cur Min Max\\n'"; - $sensor = mysql_fetch_array(mysql_query("SELECT * FROM sensors where sensor_id = '".mres($_GET['id'])."'")); - $device = device_by_id_cache($sensor['device_id']); + ### FIXME: Overwrite default because it won't work here yet + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; + $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22); $sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])); - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/temp-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " DEF:temp=$rrd_filename:temp:AVERAGE"; $rrd_options .= " DEF:temp_max=$rrd_filename:temp:MAX"; $rrd_options .= " DEF:temp_min=$rrd_filename:temp:MIN"; diff --git a/html/includes/graphs/sensor/voltage.inc.php b/html/includes/graphs/sensor/voltage.inc.php index 2d5e6ca59..239b27f41 100644 --- a/html/includes/graphs/sensor/voltage.inc.php +++ b/html/includes/graphs/sensor/voltage.inc.php @@ -4,15 +4,14 @@ $scale_min = "0"; include("includes/graphs/common.inc.php"); -$rrd_options .= " -A "; +$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; +$rrd_options .= " -A "; $rrd_options .= " COMMENT:' Last Max\\n'"; $sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22); $sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])); -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/volt-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - $rrd_options .= " DEF:volt=$rrd_filename:volt:AVERAGE"; $rrd_options .= " DEF:volt_max=$rrd_filename:volt:MAX"; $rrd_options .= " DEF:volt_min=$rrd_filename:volt:MIN"; diff --git a/html/includes/graphs/storage/usage.inc.php b/html/includes/graphs/storage/usage.inc.php index aa71be974..c02ad16af 100644 --- a/html/includes/graphs/storage/usage.inc.php +++ b/html/includes/graphs/storage/usage.inc.php @@ -9,18 +9,17 @@ $rrd_options .= " -b 1024"; $iter = "1"; - $sql = mysql_query("SELECT * FROM storage where storage_id = '".mres($_GET['id'])."'"); + $rrd_options .= " COMMENT:' Size Free % Used\\n'"; - while($storage = mysql_fetch_array($sql)) { + $hostname = gethostbyid($storage['device_id']); 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"; $iter = "0"; } $descr = substr(str_pad($storage[storage_descr], 12),0,12); $descr = str_replace(":","\:",$descr); - $rrd = $config['rrd_dir'] . "/" . $hostname . "/" . safename("storage-" . $storage['storage_mib'] . "-" . $storage['storage_descr'] . ".rrd"); - $rrd_options .= " DEF:$storage[storage_id]used=$rrd:used:AVERAGE"; - $rrd_options .= " DEF:$storage[storage_id]free=$rrd:free:AVERAGE"; + $rrd_options .= " DEF:$storage[storage_id]used=$rrd_filename:used:AVERAGE"; + $rrd_options .= " DEF:$storage[storage_id]free=$rrd_filename:free:AVERAGE"; $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'"; @@ -28,6 +27,5 @@ $rrd_options .= " -b 1024"; $rrd_options .= " GPRINT:$storage[storage_id]free:LAST:%6.2lf%sB"; $rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\\\n"; $iter++; - } ?> diff --git a/html/includes/print-interface-adsl.inc.php b/html/includes/print-interface-adsl.inc.php index 12626f488..d215f1016 100644 --- a/html/includes/print-interface-adsl.inc.php +++ b/html/includes/print-interface-adsl.inc.php @@ -53,7 +53,7 @@ echo(formatRates($interface['ifInOctets_rate'] * 8)." ".formatRates($interface['ifOutOctets_rate'] * 8)); echo("
"); $interface['graph_type'] = "port_bits"; - echo(generateiflink($interface, "", $interface['graph_type'])); @@ -61,35 +61,35 @@ echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate'])); echo("
"); $interface['graph_type'] = "port_adsl_speed"; - echo(generateiflink($interface, "", $interface['graph_type'])); echo(""); echo("".formatRates($interface['adslAturCurrAttainableRate']) . "/". formatRates($interface['adslAtucCurrAttainableRate'])); echo("
"); $interface['graph_type'] = "port_adsl_attainable"; - echo(generateiflink($interface, "", $interface['graph_type'])); echo(""); echo("".$interface['adslAturCurrAtn'] . "dB/". $interface['adslAtucCurrAtn'] . "dB"); echo("
"); $interface['graph_type'] = "port_adsl_attenuation"; - echo(generateiflink($interface, "", $interface['graph_type'])); echo(""); echo("".$interface['adslAturCurrSnrMgn'] . "dB/". $interface['adslAtucCurrSnrMgn'] . "dB"); echo("
"); $interface['graph_type'] = "port_adsl_snr"; - echo(generateiflink($interface, "", $interface['graph_type'])); echo(""); echo("".$interface['adslAturCurrOutputPwr'] . "dBm/". $interface['adslAtucCurrOutputPwr'] . "dBm"); echo("
"); $interface['graph_type'] = "port_adsl_power"; - echo(generateiflink($interface, "", $interface['graph_type'])); diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index 38521ded8..b48e1251c 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -27,7 +27,7 @@ $mac = ""; } else { $mac = ""; } - echo(" + echo(" "); echo(" @@ -235,28 +235,30 @@ echo(""); $type = $graph_type; - $daily_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=210&height=100"; - $daily_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150"; + $daily_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=210&height=100"; + $daily_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150"; - $weekly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=210&height=100"; - $weekly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=500&height=150"; + $weekly_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=210&height=100"; + $weekly_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=500&height=150"; - $monthly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=210&height=100"; - $monthly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=500&height=150"; + $monthly_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=210&height=100"; + $monthly_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=500&height=150"; - $yearly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100"; - $yearly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150"; + $yearly_traffic = "graph.php?id=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100"; + $yearly_url = "graph.php?id=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150"; echo(""); - echo("', LEFT".$config['overlib_defaults'].");\" - onmouseout=\"return nd();\"> "); - echo("', LEFT".$config['overlib_defaults'].");\" - onmouseout=\"return nd();\"> "); - echo("', LEFT, WIDTH, 350".$config['overlib_defaults'].");\" - onmouseout=\"return nd();\"> "); - echo("', LEFT, WIDTH, 350".$config['overlib_defaults'].");\" - onmouseout=\"return nd();\"> "); +include("includes/print-interface-graphs.inc.php"); + +# echo("', LEFT".$config['overlib_defaults'].");\" +# onmouseout=\"return nd();\"> "); +# echo("', LEFT".$config['overlib_defaults'].");\" +# onmouseout=\"return nd();\"> "); +# echo("', LEFT, WIDTH, 350".$config['overlib_defaults'].");\" +# onmouseout=\"return nd();\"> "); +# echo("', LEFT, WIDTH, 350".$config['overlib_defaults'].");\" +# onmouseout=\"return nd();\"> "); echo(""); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 1843b8db2..e603fb229 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -181,7 +181,7 @@ echo('
  • '); -if(devicepermitted($_GET['id']) && $config['show_overview_tab']) { +if(device_permitted($_GET['id']) && $config['show_overview_tab']) { echo("
  • @@ -40,7 +40,7 @@ echo("
  • "); } -if(devicepermitted($_GET['id'])) { +if(device_permitted($_GET['id'])) { echo('
  • Graphs @@ -48,7 +48,7 @@ if(devicepermitted($_GET['id'])) {
  • '); } -if(devicepermitted($_GET['id'])) { +if(device_permitted($_GET['id'])) { $health = mysql_result(mysql_query("select count(*) from storage WHERE device_id = '" . $device['device_id'] . "'"), 0) + mysql_result(mysql_query("select count(sensor_id) from sensors WHERE device_id = '" . $device['device_id'] . "'"), 0) + @@ -69,7 +69,7 @@ if(devicepermitted($_GET['id'])) { } } -if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(app_id) from applications WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') +if(device_permitted($_GET['id']) && @mysql_result(mysql_query("select count(app_id) from applications WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo('
  • @@ -89,7 +89,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(app_i #
  • '); #} -if(devicepermitted($_GET['id']) && is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { +if(device_permitted($_GET['id']) && is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { echo('
  • CollectD @@ -97,7 +97,7 @@ if(devicepermitted($_GET['id']) && is_dir($config['collectd_dir'] . "/" . $devic
  • '); } -if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(interface_id) from ports WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { +if(device_permitted($_GET['id']) && @mysql_result(mysql_query("select count(interface_id) from ports WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo('
  • Ports @@ -105,7 +105,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(inter
  • '); } -if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { +if(device_permitted($_GET['id']) && @mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo('
  • VLANs @@ -113,7 +113,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(vlan_
  • '); } -if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { +if(device_permitted($_GET['id']) && @mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo('
  • VRFs @@ -122,7 +122,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(*) fr } -if(devicepermitted($_GET['id']) && $config['enable_bgp'] && $device['bgpLocalAs']) { +if(device_permitted($_GET['id']) && $config['enable_bgp'] && $device['bgpLocalAs']) { echo('
  • BGP @@ -149,13 +149,13 @@ if($_SESSION['userlevel'] >= "5" && mysql_result(mysql_query("SELECT count(*) FR
  • '); } -if(devicepermitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$_GET['id']."'"), 0) > '0') { +if(device_permitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$_GET['id']."'"), 0) > '0') { echo('
  • Inventory
  • '); -} elseif ( devicepermitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `hrDevice` WHERE device_id = '".$_GET['id']."'"), 0) > '0') { +} elseif ( device_permitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `hrDevice` WHERE device_id = '".$_GET['id']."'"), 0) > '0') { echo('
  • Inventory @@ -163,7 +163,7 @@ if(devicepermitted($_GET['id']) && $config['enable_inventory'] && @mysql_result(
  • '); } -if(devicepermitted($_GET['id']) && mysql_result(mysql_query("select count(service_id) from services WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { +if(device_permitted($_GET['id']) && mysql_result(mysql_query("select count(service_id) from services WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo('
  • Services @@ -172,7 +172,7 @@ if(devicepermitted($_GET['id']) && mysql_result(mysql_query("select count(servic '); } -if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(toner_id) from toner WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { +if(device_permitted($_GET['id']) && @mysql_result(mysql_query("select count(toner_id) from toner WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo('
  • Toner @@ -180,7 +180,7 @@ if(devicepermitted($_GET['id']) && @mysql_result(mysql_query("select count(toner
  • '); } -if(devicepermitted($_GET['id'])) { +if(device_permitted($_GET['id'])) { echo('
  • Events @@ -188,7 +188,7 @@ if(devicepermitted($_GET['id'])) {
  • '); } -if(devicepermitted($_GET['id']) && $config['enable_syslog']) { +if(device_permitted($_GET['id']) && $config['enable_syslog']) { echo('
  • Syslog diff --git a/html/pages/device/bgp.inc.php b/html/pages/device/bgp.inc.php index f1a4775b2..e1dc514bd 100644 --- a/html/pages/device/bgp.inc.php +++ b/html/pages/device/bgp.inc.php @@ -86,14 +86,14 @@ print_optionbar_end(); foreach(explode(" ", $_GET['opta']) as $graph_type) { if($graph_type == "cbgp_prefixes") { list($afi, $safi) = explode(".", $_GET['optb']); $afisafi = "&afi=$afi&safi=$safi"; } if($graph_type == "bgp_updates" || $valid_afi_safi[$afi][$safi]) { - $daily_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100$afisafi"; - $daily_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150$afisafi"; - $weekly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100$afisafi"; - $weekly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150$afisafi"; - $monthly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100$afisafi"; - $monthly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150$afisafi"; - $yearly_traffic = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100$afisafi"; - $yearly_url = $config['base_url'] . "/graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150$afisafi"; + $daily_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100$afisafi"; + $daily_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150$afisafi"; + $weekly_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100$afisafi"; + $weekly_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150$afisafi"; + $monthly_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100$afisafi"; + $monthly_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150$afisafi"; + $yearly_traffic = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100$afisafi"; + $yearly_url = $config['base_url'] . "/graph.php?id=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150$afisafi"; echo(""); echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index b0a83edda..db545e896 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -67,7 +67,7 @@ if($_GET['optc'] == thumbs) { echo("
    "); } else { if($_GET['opta'] == "details" ) { $port_details = 1; } - echo("
    "); + echo("
    "); $i = "1"; $interface_query = mysql_query("select * from ports WHERE device_id = '".$device['device_id']."' AND deleted = '0' ORDER BY `ifIndex` ASC"); while($interface = mysql_fetch_assoc($interface_query)) { diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 23b213815..821c9c8f2 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -121,7 +121,7 @@ echo('
    $device_query = mysql_query($sql); while ($device = mysql_fetch_array($device_query)) { - if ( devicepermitted($device['device_id']) ) { + if ( device_permitted($device['device_id']) ) { include("includes/hostbox.inc"); } } diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 6872b1bff..746c5f159 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -24,7 +24,7 @@ while($device = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); while($device = mysql_fetch_array($sql)){ - if(devicepermitted($device['device_id'])) { + if(device_permitted($device['device_id'])) { echo("
    ".generatedevicelink($device, shorthost($device['hostname']))."
    Device Down
    @@ -37,7 +37,7 @@ if($config['warn']['ifdown']) { $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while($interface = mysql_fetch_array($sql)){ - if(interfacepermitted($interface['interface_id'])) { + if(port_permitted($interface['interface_id'])) { echo("
    ".generatedevicelink($interface, shorthost($interface['hostname']))."
    Port Down
    @@ -51,7 +51,7 @@ while($interface = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while($service = mysql_fetch_array($sql)){ - if(devicepermitted($service['device_id'])) { + if(device_permitted($service['device_id'])) { echo("
    ".generatedevicelink($service, shorthost($service['hostname']))."
    Service Down
    @@ -63,7 +63,7 @@ while($service = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); while($peer = mysql_fetch_array($sql)){ - if(devicepermitted($peer['device_id'])) { + if(device_permitted($peer['device_id'])) { echo("
    ".generatedevicelink($peer, shorthost($peer['hostname']))."
    BGP Down
    @@ -75,7 +75,7 @@ while($peer = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); while($device = mysql_fetch_array($sql)){ - if(devicepermitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { + if(device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { echo("
    ".generatedevicelink($device, shorthost($device['hostname']))."
    Device
    Rebooted

    diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index b6effdad8..b07f19a4a 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -24,7 +24,7 @@ while($device = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); while($device = mysql_fetch_array($sql)){ - if(devicepermitted($device['device_id'])) { + if(device_permitted($device['device_id'])) { echo("
    ".generatedevicelink($device, shorthost($device['hostname']))."
    Device Down
    @@ -37,7 +37,7 @@ if($config['warn']['ifdown']) { $sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while($interface = mysql_fetch_array($sql)){ - if(interfacepermitted($interface['interface_id'])) { + if(port_permitted($interface['interface_id'])) { echo("
    ".generatedevicelink($interface, shorthost($interface['hostname']))."
    Port Down
    @@ -51,7 +51,7 @@ while($interface = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while($service = mysql_fetch_array($sql)){ - if(devicepermitted($service['device_id'])) { + if(device_permitted($service['device_id'])) { echo("
    ".generatedevicelink($service, shorthost($service['hostname']))."
    Service Down
    @@ -63,7 +63,7 @@ while($service = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); while($peer = mysql_fetch_array($sql)){ - if(devicepermitted($peer['device_id'])) { + if(device_permitted($peer['device_id'])) { echo("
    ".generatedevicelink($peer, shorthost($peer['hostname']))."
    BGP Down
    @@ -75,7 +75,7 @@ while($peer = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); while($device = mysql_fetch_array($sql)){ - if(devicepermitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { + if(device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { echo("
    ".generatedevicelink($device, shorthost($device['hostname']))."
    Device
    Rebooted

    diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index f683d1595..fc30d4599 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -14,16 +14,19 @@ if(is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; } if(isset($config['graph'][$type][$subtype])) { $descr = $config['graph'][$type][$subtype]; } else { $descr = $graph_type; } - $descr = mysql_result(mysql_query("SELECT `graph_descr` FROM `graph_types` WHERE `graph_type` = '".$type."' AND `graph_subtype` = '".$subtype."'"),0); + #$descr = mysql_result(mysql_query("SELECT `graph_descr` FROM `graph_types` WHERE `graph_type` = '".$type."' AND `graph_subtype` = '".$subtype."'"),0); - if(is_file("includes/graphs/".$type."/auth.inc.php")) + $descr = $config['graph_types'][$type][$subtype]['descr']; + + if(is_file("includes/graphs/".$type."/auth.inc.php")) { include("includes/graphs/".$type."/auth.inc.php"); - } else { - #### FIXME. UGLY ERROR - echo("Missing auth for this graph type! This is a bug. Please report it."); - exit(); } + + if(!$auth) + { + include("includes/error-no-perm.inc.php"); + } else { if(isset($config['graph'][$type][$subtype])) { $title .= " :: ".$config['graph'][$type][$subtype]; } else { $title .= " :: ".$graph_type; } @@ -117,5 +120,7 @@ if(is_numeric($_GET['optd'])) { $to = $_GET['optd']; } else { $to = $now; } echo("
    "); +} + ?> diff --git a/html/pages/health/memory.inc.php b/html/pages/health/memory.inc.php index dbe6a4726..a59d812eb 100644 --- a/html/pages/health/memory.inc.php +++ b/html/pages/health/memory.inc.php @@ -7,7 +7,7 @@ $graph_type = "mempool_usage"; $i = '1'; $mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname"); while($mempool = mysql_fetch_array($mempools)) { - if(devicepermitted($mempool['device_id'])) { + if(device_permitted($mempool['device_id'])) { if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } $proc_url = "?page=device/".$device['device_id']."/health/memory/"; diff --git a/html/pages/health/processors.inc.php b/html/pages/health/processors.inc.php index 970e2c9b0..a0fee4106 100644 --- a/html/pages/health/processors.inc.php +++ b/html/pages/health/processors.inc.php @@ -8,7 +8,7 @@ $graph_type = "processor_usage"; $procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname"); while($proc = mysql_fetch_array($procs)) { - if(devicepermitted($proc['device_id'])) { + if(device_permitted($proc['device_id'])) { if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php index 06ca1dce6..6b26c3a2b 100644 --- a/html/pages/health/storage.inc.php +++ b/html/pages/health/storage.inc.php @@ -21,7 +21,7 @@ $row = 1; while($drive = mysql_fetch_array($query)) { - if(devicepermitted($drive['device_id'])){ + if(device_permitted($drive['device_id'])){ $skipdrive = 0; diff --git a/html/pages/ipv4.inc.php b/html/pages/ipv4.inc.php index 02a6dd393..7cabbd561 100644 --- a/html/pages/ipv4.inc.php +++ b/html/pages/ipv4.inc.php @@ -71,7 +71,7 @@ while($interface = mysql_fetch_array($query)) { $error_img = generateiflink($interface,"Interface Errors",errors); } else { $error_img = ""; } - if( interfacepermitted($interface['interface_id']) ) + if( port_permitted($interface['interface_id']) ) { echo('
    diff --git a/html/pages/ipv6.inc.php b/html/pages/ipv6.inc.php index f33dea0a7..b2879eb64 100644 --- a/html/pages/ipv6.inc.php +++ b/html/pages/ipv6.inc.php @@ -73,7 +73,7 @@ if(!$ignore) { $error_img = generateiflink($interface,"Interface Errors",errors); } else { $error_img = ""; } - if( interfacepermitted($interface['interface_id']) ) + if( port_permitted($interface['interface_id']) ) { echo(" diff --git a/html/pages/ports/default.inc.php b/html/pages/ports/default.inc.php index 185a9980e..834d4f4cc 100644 --- a/html/pages/ports/default.inc.php +++ b/html/pages/ports/default.inc.php @@ -138,7 +138,7 @@ while($interface = mysql_fetch_array($query)) { $error_img = generateiflink($interface,"Interface Errors",errors); } else { $error_img = ""; } - if( interfacepermitted($interface['interface_id'], $interface['device_id']) ) + if( port_permitted($interface['interface_id'], $interface['device_id']) ) { $interface = ifLabel($interface, $device); echo(" diff --git a/html/pages/ports/deleted.inc.php b/html/pages/ports/deleted.inc.php index 46ccd2e67..eee2e5f14 100644 --- a/html/pages/ports/deleted.inc.php +++ b/html/pages/ports/deleted.inc.php @@ -5,14 +5,14 @@ if($_GET['optb'] == "purge" && $_GET['optc'] == "all") { $sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id"; $query = mysql_query($sql); while($interface = mysql_fetch_assoc($query)) { - if(interfacepermitted($interface['interface_id'], $interface['device_id'])){ + if(port_permitted($interface['interface_id'], $interface['device_id'])){ delete_port($interface['interface_id']); echo("
    Deleted ".generatedevicelink($interface)." - ".generateiflink($interface)."
    "); } } } elseif($_GET['optb'] == "purge" && $_GET['optc']) { $interface = mysql_fetch_assoc(mysql_query("SELECT * from `ports` AS P, `devices` AS D WHERE `interface_id` = '".mres($_GET['optc'])."' AND D.device_id = P.device_id")); - if(interfacepermitted($interface['interface_id'], $interface['device_id'])) + if(port_permitted($interface['interface_id'], $interface['device_id'])) delete_port($interface['interface_id']); echo("
    Deleted ".generatedevicelink($interface)." - ".generateiflink($interface)."
    "); } @@ -29,7 +29,7 @@ $sql = "SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D $query = mysql_query($sql); while($interface = mysql_fetch_assoc($query)) { $interface = ifLabel($interface, $interface); - if(interfacepermitted($interface['interface_id'], $interface['device_id'])){ + if(port_permitted($interface['interface_id'], $interface['device_id'])){ if(is_integer($i_deleted/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } echo(""); diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index f95da23c4..702f8f146 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -28,8 +28,8 @@ while($pw_a = mysql_fetch_array($query)) { P.cpwVcID = '".$pw_a['cpwVcID']."' AND P.interface_id = I.interface_id")); - if(!interfacepermitted($pw_a['interface_id'])) { $skip = "yes"; } - if(!interfacepermitted($pw_b['interface_id'])) { $skip = "yes"; } + if(!port_permitted($pw_a['interface_id'])) { $skip = "yes"; } + if(!port_permitted($pw_b['interface_id'])) { $skip = "yes"; } if($skip) { diff --git a/includes/common.php b/includes/common.php index 21a65abf8..c927431f7 100644 --- a/includes/common.php +++ b/includes/common.php @@ -2,6 +2,8 @@ ## Common Functions + + function get_port_by_id($port_id) { if(is_numeric($port_id)) { @@ -12,7 +14,41 @@ function get_port_by_id($port_id) } else { return FALSE; } +} +function get_application_by_id($application_id) +{ + if(is_numeric($application_id)) { + $application = mysql_fetch_assoc(mysql_query("SELECT * FROM `applications` WHERE `app_id` = '".$application_id."'")); + } + if(is_array($application)){ + return $application; + } else { + return FALSE; + } +} + +function get_sensor_by_id($sensor_id) +{ + if(is_numeric($sensor_id)) { + $sensor = mysql_fetch_assoc(mysql_query("SELECT * FROM `sensors` WHERE `sensor_id` = '".$sensor_id."'")); + } + if(is_array($sensor)){ + return $sensor; + } else { + return FALSE; + } +} + +function get_device_id_by_interface_id($interface_id) { + if(is_numeric($interface_id)) { + $device_id = mysql_result(mysql_query("SELECT `device_id` FROM `ports` WHERE `interface_id` = '".$interface_id."'"),0); + } + if(is_numeric($device_id)){ + return $device_id; + } else { + return FALSE; + } } function ifclass($ifOperStatus, $ifAdminStatus) diff --git a/includes/functions.php b/includes/functions.php index 37ab9ccee..0703ebc5d 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -89,17 +89,6 @@ function device_array($device_id) return $device; } -function get_device_id_by_interface_id($interface_id) { - if(is_numeric($interface_id)) { - $device_id = mysql_result(mysql_query("SELECT `device_id` FROM `ports` WHERE `interface_id` = '".$interface_id."'"),0); - } - if(is_numeric($device_id)){ - return $device_id; - } else { - return FALSE; - } -} - function getHostOS($device) { global $config; diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index 879bc6e2d..d145f4ff0 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -2,11 +2,11 @@ ## Polls Apache statistics from script via SNMP -$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; +$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd"; $apache_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $apache_cmd .= " nsExtendOutputFull.6.97.112.97.99.104.101"; -$apache = `$apache_cmd`; -echo($apache_cmd); +$apache = shell_exec($apache_cmd); +echo(" apache"); list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $apache);
    ' . generatedevicelink($interface) . '
    " . generatedevicelink($interface) . "