Location: PHPKode > projects > Limph > limph-1.9.7/ungrouped.php
<?php
 /*
   Limph Is Monitoring Pingable Hosts
   Copyright (C) 2006 Jonathan Ciesla
   
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  */
require_once("config.php");
require_once("functionlib.php");
session_start();
favicon();

$link = dbms_connect($dbhost, $dbuser, $dbpass, $dbname);

$user_id = dbms_escape_string($_SESSION['limphid']);

$admin_level =$_SESSION['limphadmin'];
authentication($admin_level,1);
  
$edithost=$_POST['edithost'];
if($edithost=="yes"){
  $number = $_POST['host'];
 
  $group = $_POST['group'];
  $parent = $_POST['parent'];
  if($parent){$parent = parent_check($parent, $number);}else{$parent="0";};
  
  $query = "UPDATE hosts SET hostgroup='$group',parent='$parent' WHERE number = '$number';";
  $result = dbms_query($query);
 };

echo "<link rel=stylesheet href=css.php>";
echo "<title>$sitetitle</title>";
echo "<h1>$sitetitle</h1>";

echo "<table border=1 align=center>";
echo "<tr><th align=center>Ungrouped Hosts</th></tr>";
echo "<tr>";
echo "<td align=center bgcolor=#808080>";
$query = "SELECT name,status,enabled,number,port,visible,hostgroup,parent FROM hosts WHERE hostgroup = '0' ORDER BY name ASC;";
$result = dbms_query($query);
echo "<table border=0 align=center>";
while($line = dbms_fetch_array($result, "NUM")){  //host loop
  echo "<tr>"; 
  if($line[1]=="1"){ $flag = "bgcolor=#00FF00"; }; #Up
  if($line[5]=="0"){ $flag = "bgcolor=#FF00FF"; }; #Unreachable
  if($line[1]=="0"){ $flag = "bgcolor=#FF0000"; }; #Down
  if($line[2]=="0"){ $flag = "bgcolor=#808080"; }; #Disabled
  echo "<td align=center $flag>";
  //display host
  if($line[4]!="0"){
    echo $line[0] . " - " . $line[4];
  } else {
    echo $line[0];
  };
  echo "</td><td>";
  echo "<form action=ungrouped.php method=post>";
  echo "Group:<select name=group>";
  echo "<option value=\"\">";
  $query1 = "SELECT number,name FROM groups ORDER BY name;";
  $result1 = dbms_query($query1);
  while($line1=dbms_fetch_array($result1, "NUM")){
    if($line1[0]==$line[6]){
      $flag = "selected";
    } else {
      $flag = "";
    };
    echo "<option value={$line1['0']} $flag>{$line1['1']}";
  };
  dbms_free_result($result1);
  echo "</select>";
  echo "</td><td>";
  echo "Parent:<select name=parent>";
  echo "<option value=\"\">";
  $query2 = "SELECT number,name FROM hosts ORDER BY name;";
  $result2 = dbms_query($query2);
  while($line2=dbms_fetch_array($result2, "NUM")){
    if($line2[0]==$line[7]){
      $flag = "selected";
    } else {
      $flag = "";
    };
    echo "<option value={$line2['0']} $flag>{$line2['1']}";
  };
  dbms_free_result($result2);
  echo "</select>";
  echo "</td><td>";
  echo "<input type=hidden name=host value={$line['3']}>";
  echo "<input type=hidden name=edithost value=yes>";
  echo "<input type=submit value=Update>";
  echo "</form>";
  echo "</td>";  
  echo "</tr>";
 };  //end host loop

echo "</table>";
dbms_free_result($result);
echo "</td>";
echo "</tr>";
echo "</table>";

echo "<br />";
echo "<form action=univ.php method=post>";
echo "<input type=submit value=Back />";
echo "</form>";

?>
Return current item: Limph