make sure selection of dropdown boxes on devices page is not empty

git-svn-id: http://www.observium.org/svn/observer/trunk@727 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans 2010-01-25 23:42:23 +00:00
parent b86a6447b8
commit 12d8935964

View File

@ -11,10 +11,14 @@
<option value=''>All OSes</option>
<?php
$query = mysql_query("SELECT `os` FROM `devices` GROUP BY `os` ORDER BY `os`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['os']."'");
if($data['os'] == $_POST['os']) { echo("selected"); }
echo(">".$data['os']."</option>");
while ($data = mysql_fetch_array($query))
{
if ($data['os'])
{
echo("<option value='".$data['os']."'");
if ($data['os'] == $_POST['os']) { echo("selected"); }
echo(">".$data['os']."</option>");
}
}
?>
</select>
@ -23,10 +27,14 @@
<option value=''>All Versions</option>
<?php
$query = mysql_query("SELECT `version` FROM `devices` GROUP BY `version` ORDER BY `version`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['version']."'");
if($data['version'] == $_POST['version']) { echo("selected"); }
echo(">".$data['version']."</option>");
while ($data = mysql_fetch_array($query))
{
if ($data['version'])
{
echo("<option value='".$data['version']."'");
if ($data['version'] == $_POST['version']) { echo("selected"); }
echo(">".$data['version']."</option>");
}
}
?>
</select>
@ -36,10 +44,14 @@
<option value=''>All Platforms</option>
<?php
$query = mysql_query("SELECT `hardware` FROM `devices` GROUP BY `hardware` ORDER BY `hardware`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['hardware']."'");
if($data['hardware'] == $_POST['hardware']) { echo("selected"); }
echo(">".$data['hardware']."</option>");
while ($data = mysql_fetch_array($query))
{
if ($data['hardware'])
{
echo("<option value='".$data['hardware']."'");
if ($data['hardware'] == $_POST['hardware']) { echo("selected"); }
echo(">".$data['hardware']."</option>");
}
}
?>
</select>
@ -48,10 +60,14 @@
<option value=''>All Featuresets</option>
<?php
$query = mysql_query("SELECT `features` FROM `devices` GROUP BY `features` ORDER BY `features`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['features']."'");
if($data['features'] == $_POST['features']) { echo("selected"); }
echo(">".$data['features']."</option>");
while ($data = mysql_fetch_array($query))
{
if ($data['features'])
{
echo("<option value='".$data['features']."'");
if ($data['features'] == $_POST['features']) { echo("selected"); }
echo(">".$data['features']."</option>");
}
}
?>
</select>
@ -61,15 +77,18 @@
<option value=''>All Locations</option>
<?php
$query = mysql_query("SELECT `location` FROM `devices` GROUP BY `location` ORDER BY `location`");
while($data = mysql_fetch_array($query)) {
echo("<option value='".$data['location']."'");
if($data['location'] == $_POST['location']) { echo("selected"); }
echo(">".$data['location']."</option>");
while ($data = mysql_fetch_array($query))
{
if ($data['location'])
{
echo("<option value='".$data['location']."'");
if ($data['location'] == $_POST['location']) { echo("selected"); }
echo(">".$data['location']."</option>");
}
}
?>
</select>
<input type=submit value=Search>
</td>
<td width=10>
</td>
@ -81,18 +100,18 @@
print_optionbar_end();
if($_POST['hostname']) { $where = " AND hostname LIKE '%".$_POST['hostname']."%'"; }
if($_POST['os']) { $where = " AND os = '".$_POST['os']."'"; }
if($_POST['version']) { $where .= " AND version = '".$_POST['version']."'"; }
if($_POST['hardware']) { $where .= " AND hardware = '".$_POST['hardware']."'"; }
if($_POST['features']) { $where .= " AND features = '".$_POST['features']."'"; }
if($_POST['location']) { $where .= " AND location = '".$_POST['location']."'"; }
if($_GET['location']) { $where = "AND location = '$_GET[location]'"; }
if($_GET['location'] == "Unset") { $where = "AND location = ''"; }
if($_GET['type']) { $where = "AND type = '$_GET[type]'"; }
if ($_POST['hostname']) { $where = " AND hostname LIKE '%".$_POST['hostname']."%'"; }
if ($_POST['os']) { $where = " AND os = '".$_POST['os']."'"; }
if ($_POST['version']) { $where .= " AND version = '".$_POST['version']."'"; }
if ($_POST['hardware']) { $where .= " AND hardware = '".$_POST['hardware']."'"; }
if ($_POST['features']) { $where .= " AND features = '".$_POST['features']."'"; }
if ($_POST['location']) { $where .= " AND location = '".$_POST['location']."'"; }
if ($_GET['location']) { $where = "AND location = '$_GET[location]'"; }
if ($_GET['location'] == "Unset") { $where = "AND location = ''"; }
if ($_GET['type']) { $where = "AND type = '$_GET[type]'"; }
$sql = "select * from devices WHERE 1 $where ORDER BY `ignore`, `status`, `hostname`";
if($_GET['status'] == "alerted") {
if ($_GET['status'] == "alerted") {
$sql = "select * from devices " . $device_alert_sql . " GROUP BY `device_id` ORDER BY `ignore`, `status`, `os`, `hostname`";
}
@ -100,8 +119,8 @@ echo('<table cellpadding="7" cellspacing="0" class="devicetable" width="100%">
<tr class="tablehead"><th></th><th>Device</th><th>Operating System</th><th>Platform</th><th>Uptime</th></tr>');
$device_query = mysql_query($sql);
while($device = mysql_fetch_array($device_query)) {
if( devicepermitted($device['device_id']) ) {
while ($device = mysql_fetch_array($device_query)) {
if ( devicepermitted($device['device_id']) ) {
include("includes/hostbox.inc");
}
}