diff --git a/README b/README index e10fcb627..056316d25 100644 --- a/README +++ b/README @@ -22,8 +22,8 @@ Changelog Pre-Release 0.3.3 -Much prettier front page. - +Much prettier front page +Tidied up service checking layout Release 0.3.2.1 ( 27th March 2008 ) diff --git a/addhost.php b/addhost.php index fc82c38c9..fbfe699c7 100755 --- a/addhost.php +++ b/addhost.php @@ -11,7 +11,7 @@ if($argv[1] && $argv[2] && $argv[3]) { list($hostshort) = explode(".", $host); if ( isDomainResolves($argv[1])){ if ( isPingable($argv[1])) { - if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) { + if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) { $snmphost = trim(`snmpget -Oqv -$snmpver -c $community $host sysName.0 | sed s/\"//g`); if ($snmphost == $host || $hostshort = $host) { $return = createHost ($host, $community, $snmpver); diff --git a/adduser.php b/adduser.php index 8d6559291..5a68b365b 100755 --- a/adduser.php +++ b/adduser.php @@ -5,7 +5,7 @@ include("config.php"); include("includes/functions.php"); if($argv[1] && $argv[2] && $argv[3]) { - mysql_query("INSERT INTO `users` (`username`,`password`,`level`) VALUES ('".$argv[1]."',MD5('".$argv[2]."'),'".$argv[3]."')"); + mysql_query("INSERT INTO `users` (`username`,`password`,`level`) VALUES ('".mres($argv[1])."',MD5('".$argv[2]."'),'".mres($argv[3])."')"); if(mysql_affected_rows()) { echo("User ".$argv[1]." added successfully\n"); } diff --git a/html/graph.php b/html/graph.php index be9ba7cd8..ffd7ca997 100644 --- a/html/graph.php +++ b/html/graph.php @@ -126,10 +126,11 @@ $graph = graph_netscreen_cpu ($hostname . "/netscreen-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); } elseif($os == "Fortigate") { $graph = graph_fortigate_cpu ($hostname . "/fortigate-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); + } elseif($os == "JunOS") { + $graph = graph_cpu_generic_single($hostname . "/junos-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); } - - break; + case 'temp': $graph = temp_graph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical); break; diff --git a/html/includes/add-srv.inc b/html/includes/add-srv.inc index e6943e56c..102d542eb 100644 --- a/html/includes/add-srv.inc +++ b/html/includes/add-srv.inc @@ -3,8 +3,8 @@ $updated = '1'; $sql = "INSERT INTO `services` (`service_host`,`service_ip`,`service_type`,`service_desc`,`service_param`,`service_ignore`) - VALUES ('" . $_POST['device']. "','" . $_POST['ip'] . "','" . $_POST['type'] . "', - '" . $_POST['descr'] . "','" . $_POST['params'] . "','0')"; + VALUES ('" . mres($_POST['device']). "','" . mres($_POST['ip']) . "','" . mres($_POST['type']) . "', + '" . mres($_POST['descr']) . "','" . mres($_POST['params']) . "','0')"; $query = mysql_query($sql); $affected = mysql_affected_rows() . "records affected"; diff --git a/html/includes/authenticate.inc b/html/includes/authenticate.inc index 53fe64f28..a816d0674 100644 --- a/html/includes/authenticate.inc +++ b/html/includes/authenticate.inc @@ -22,7 +22,7 @@ if($_GET['logout']) { } - $sql = "select username, level, user_id from users where username='" . $_SESSION['username'] . "' and password='" . $_SESSION['encrypted'] . "'"; + $sql = "select username, level, user_id from users where username='" . mres($_SESSION['username']) . "' and password='" . mres($_SESSION['encrypted']) . "'"; $query = mysql_query($sql); $row = mysql_fetch_row($query); diff --git a/html/includes/del-srv.inc b/html/includes/del-srv.inc index 04c9f133b..76eb69273 100644 --- a/html/includes/del-srv.inc +++ b/html/includes/del-srv.inc @@ -2,7 +2,7 @@ $updated = '1'; - $sql = "DELETE FROM `services` WHERE service_id = '" . $_POST['service']. "'"; + $sql = "DELETE FROM `services` WHERE service_id = '" . mres($_POST['service']). "'"; $query = mysql_query($sql); $rows = mysql_affected_rows(); diff --git a/html/index.php b/html/index.php index 592efb29f..62b7d547a 100755 --- a/html/index.php +++ b/html/index.php @@ -94,12 +94,15 @@ function popUp(URL) {
Add Device"); if($_POST['hostname'] && $_POST['community']) { if($_SESSION['userlevel'] > '5') { - $hostname = $_POST['hostname']; - $community = $_POST['community']; - $snmpver = $_POST['snmpver']; + $hostname = mres($_POST['hostname']); + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); echo(""); $result = addHost($hostname, $community, $snmpver); diff --git a/html/pages/adduser.php b/html/pages/adduser.php index ff000c815..0eb0e364d 100644 --- a/html/pages/adduser.php +++ b/html/pages/adduser.php @@ -8,7 +8,7 @@ if($_SESSION['userlevel'] != '10') { echo("You do not have the if($_POST['action'] == "add") { - mysql_query("INSERT INTO `users` (`username`, `realname`, `password`, `level`) VALUES ('" . $_POST['new_username'] . "', '" . $_POST['new_realname'] . "', MD5('" . $_POST['new_password'] . "'), '" . $_POST['new_level'] . "')"); + mysql_query("INSERT INTO `users` (`username`, `realname`, `password`, `level`) VALUES ('" . mres($_POST['new_username']) . "', '" . mres($_POST['new_realname']) . "', MD5('" . mres(_POST['new_password']) . "'), '" . mres($_POST['new_level']) . "')"); if(mysql_affected_rows()) { echo("User " . $_GET['username'] . " added!"); } diff --git a/html/pages/alerts.php b/html/pages/alerts.php index 2c96939d4..4e7187906 100644 --- a/html/pages/alerts.php +++ b/html/pages/alerts.php @@ -2,7 +2,7 @@ if($_GET['del']) { - $id = $_GET['del']; + $id = mres($_GET['del']); $query = "DELETE FROM `alerts` WHERE `id` = '$id'"; mysql_query($query); } diff --git a/html/pages/bills.php b/html/pages/bills.php index 22ff69432..6ea9f6f18 100644 --- a/html/pages/bills.php +++ b/html/pages/bills.php @@ -4,7 +4,7 @@ echo("| ")
if($_GET['bill']) {
- $bill_id = $_GET['bill'];
+ $bill_id = mres($_GET['bill']);
include("includes/billing.php");
} else {
diff --git a/html/pages/delhost.php b/html/pages/delhost.php
index 726536c16..fd4c64d0f 100644
--- a/html/pages/delhost.php
+++ b/html/pages/delhost.php
@@ -6,9 +6,9 @@ if($_SESSION['userlevel'] < 10) {
}
if($_POST['id']) {
- delHost($_POST['id']);
-} elseif ($_GET['id']) {
- delHost($_GET['id']);
+ delHost(mres($_POST['id']));
+} elseif (mres($_GET['id'])) {
+ delHost(mres($_GET['id']));
}
?>
diff --git a/html/pages/deluser.php b/html/pages/deluser.php
index 6bec8d474..e8a0a5dc1 100644
--- a/html/pages/deluser.php
+++ b/html/pages/deluser.php
@@ -8,12 +8,12 @@ if($_SESSION['userlevel'] != '10') { echo("You do not have the
if($_GET['action'] == "del") {
- $delete_username = mysql_result(mysql_query("SELECT username FROM users WHERE user_id = '" . $_GET['user_id'] . "'"),0);
+ $delete_username = mysql_result(mysql_query("SELECT username FROM users WHERE user_id = '" . mres($_GET['user_id']) . "'"),0);
if($_GET['confirm'] == "yes") {
- mysql_query("DELETE FROM `devices_perms` WHERE `user_id` = '" . $_GET['user_id'] . "'");
- mysql_query("DELETE FROM `users` WHERE `user_id` = '" . $_GET['user_id'] . "'");
+ mysql_query("DELETE FROM `devices_perms` WHERE `user_id` = '" . mres($_GET['user_id']) . "'");
+ mysql_query("DELETE FROM `users` WHERE `user_id` = '" . mres($_GET['user_id']) . "'");
if(mysql_affected_rows()) { echo("User '$delete_username' deleted!"); }
diff --git a/html/pages/device.php b/html/pages/device.php
index b17b3e5fd..8cdb51622 100644
--- a/html/pages/device.php
+++ b/html/pages/device.php
@@ -1,5 +1,7 @@
+if($_GET['id']) {$_GET['id'] = mres($_GET['id']); }
+
if(devicepermitted($_GET['id'])) {
$selected['iface'] = "selected";
@@ -7,7 +9,8 @@ $selected['iface'] = "selected";
if(!$_GET['section']) {
$_GET['section'] = "dev-overview";
}
-$section = $_GET['section'];
+$section = mres($_GET['section']);
+$section = str_replace(".", "", $section);
$select[$section] = "selected";
diff --git a/html/pages/device/dev-graphs.inc b/html/pages/device/dev-graphs.inc
index c8bdafe22..96f54a805 100644
--- a/html/pages/device/dev-graphs.inc
+++ b/html/pages/device/dev-graphs.inc
@@ -8,6 +8,12 @@ while($device = mysql_fetch_array($device_query)) {
echo(" ");
switch ($device['os']) {
+ case "JunOS":
+ echo(" Processor Utilisation ");
+ $graph_type = "cpu"; include ("includes/print-device-graph.php");
+ break;
+
+
case "Fortigate":
echo("Processor Utilisation ");
$graph_type = "fortigate_cpu"; include ("includes/print-device-graph.php");
diff --git a/includes/functions.php b/includes/functions.php
index 608198a63..0b5b899b8 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -22,6 +22,12 @@ include_once($config['install_dir'] . "/includes/syslog.php");
function mres($string) {
// short function wrapper because the real one is stupidly long and ugly. aestetics.
return mysql_real_escape_string($string);
+}
+
+function validate_hostip($host) {
+
+
+
}
function write_dev_attrib($device_id, $attrib_type, $attrib_value) {
diff --git a/includes/graphing.php b/includes/graphing.php
index b34eb7104..8facc7ff7 100644
--- a/includes/graphing.php
+++ b/includes/graphing.php
@@ -315,6 +315,21 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
return $imgfile;
}
+function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) {
+ global $config;
+ $database = $config['rrd_dir'] . "/" . $rrd;
+ $imgfile = "graphs/" . "$graph";
+ $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
+ if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
+ $options .= " DEF:cpu=$database:cpu:AVERAGE";
+ $options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
+ $options .= " AREA:cpu#ffee99: LINE1.25:cpu#aa2200:Load\ %";
+ $options .= " GPRINT:cpu:LAST:%6.2lf\ GPRINT:cpu:AVERAGE:%6.2lf\ ";
+ $options .= " GPRINT:cpu:MAX:%6.2lf\ GPRINT:cpu:AVERAGE:%6.2lf\\\\n";
+ $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
+ return $imgfile;
+}
+
function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
global $config, $installdir;
diff --git a/includes/polling/device-junos.inc.php b/includes/polling/device-junos.inc.php
index dc55522a7..b23200cde 100644
--- a/includes/polling/device-junos.inc.php
+++ b/includes/polling/device-junos.inc.php
@@ -1,5 +1,7 @@
diff --git a/poll-device.php b/poll-device.php
index b45882645..9b6b9a01b 100755
--- a/poll-device.php
+++ b/poll-device.php
@@ -143,6 +143,10 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/polling/device-fortigate.inc.php");
break;
+ case "JunOS":
+ include("includes/polling/device-junos.inc.php");
+ break;
+
case "IOS":
$version = str_replace("Cisco IOS Software,", "", $sysDescr);
$version = str_replace("IOS (tm) ", "", $version);
|