<?php
include_once("include/read_config_class.php");
include_once("include/my_pagina_class.php");
include_once("include/net.php");
include_once ("include/classListbox.php");
function menu_owner ($ownerid, $object, $object_index) {
echo "
<div id='menuowner'>
<div id='menubar'>
<div class='menuendspacer'></div>
<div id='menubaritem1' style='width: 100px'>
<a href='javascript:oneshowallhide(\"ownerinfo\",\"activealerts\",\"disablealerts\",\"managealerts\")'>Owner Info</a>
</div>
<!-- <div id='menubaritem2' style='width: 120px'>
<a href='javascript:oneshowallhide(\"activealerts\",\"ownerinfo\",\"disablealerts\",\"managealerts\")'>Enabled Alerts</a>
</div>
<div id='menubaritem3' style='width: 120px'>
<a href='javascript:oneshowallhide(\"disablealerts\",\"ownerinfo\",\"activealerts\",\"managealerts\")'>Disabled Alerts</a>
</div>-->
<div id='menubaritem4' style='width: 120px'>
<a href='javascript:oneshowallhide(\"managealerts\",\"disablealerts\",\"ownerinfo\",\"activealerts\")'>Manage Alerts</a>
</div>
<div id='menubaritem5' style='width: 120px'>
<a href='host_form.php?view_type=view&host_id=$object_index'>Return to Scans</a>
</div>
</div>
</div>
<div align='center' id='ownerinfo'>";
if ($ownerid != '') {
$query = mysql_query("SELECT owner_id, name AS 'Owner Name', email AS 'Owner Email', telephone AS 'Telephone Number', section AS Room FROM owners WHERE owner_id = $ownerid") or die (mysql_error());
$data = mysql_fetch_assoc ($query);
mysql_data_seek($query, 0);
$title="<h1>Owner Info</h1>";
draw_all ($title,$query,0);
} else {
$query = mysql_query ("SELECT * FROM ownership WHERE object = '$object' AND object_index = '$object_index'") or die (mysql_error());
$num_owners = mysql_num_rows ($query);
if ($num_owners != 0) {
echo "<h1>Select an owner</h1>";
} else {
echo "<h1>No owners defined</h1>";
}
}
echo "
</div>
";
echo "<div style='display: none;' id='activealerts'>";
$title = "<div align='center'>Enabled Alerts <input id='disable_alerts' class='lowred' type='submit' name='savechanges' value='Save Changes'></div>";
$bottom = "<div align='center'>Enabled Alerts <input id='disable_alerts' class='lowred' type='submit' name='savechanges' value='Save Changes'></div>";
$query = "SELECT send_alerts.alert_name AS 'Alert Name', plugin_name AS Plugin, alert_level AS 'Level' FROM alert_type,send_alerts WHERE status = 'on' AND send_alerts.alert_name = alert_type.alert_name AND send_alerts.owner_id = $ownerid AND object = '$object' AND object_index = $object_index";
echo "<form id='disable_alerts' action='owners.php' method='get' onsubmit='return checkform(this);'>";
draw_table ($title,$query,650,$bottom);
echo "<input type='hidden' name='option' value='disable_alerts'>";
echo "<input type='hidden' name='object' value='$object'>";
echo "<input type='hidden' name='object_index' value='$object_index'>";
echo "<input type='hidden' name='ownerid' value='$ownerid'>";
echo "</form>";
echo "</div>";
echo "<div style='display: none;' id='disablealerts'>";
$result_active_alerts = mysql_query("SELECT send_alerts.alert_name AS 'Alert Name' FROM alert_type,send_alerts WHERE status = 'on' AND send_alerts.alert_name = alert_type.alert_name AND send_alerts.owner_id = $ownerid AND object = '$object' AND object_index = $object_index") or die ('Querry failed: ' . mysql_error());
while ($linea = mysql_fetch_array($result_active_alerts, MYSQL_ASSOC)) {
foreach ($linea as $field_col => $valor_col) {
$active_alerts[] = $linea["Alert Name"];
}
}
$query_disabled_alerts = "SELECT alert_name AS 'Alert Name', plugin_name AS Plugin, alert_level AS 'Level' FROM alert_type WHERE status = 'on' ";
if (isset($active_alerts)){
foreach ($active_alerts as $active_alert) {
$query_disabled_alerts = "$query_disabled_alerts AND alert_name != '$active_alert' ";
}
}
$title = "<div align='center'>Disabled Alerts <input id='enable_alerts' class='lowred' type='submit' name='savechanges' value='Save Changes'></div>";
$bottom = "<div align='center'>Disabled Alerts <input id='enable_alerts' class='lowred' type='submit' name='savechanges' value='Save Changes'></div>";
echo "<form id='enable_alerts' action='owners.php' method='get' onsubmit='return checkform(this);'>";
draw_table ($title,$query_disabled_alerts,650,$bottom);
echo "<input type='hidden' name='option' value='enable_alerts'>";
echo "<input type='hidden' name='object' value='$object'>";
echo "<input type='hidden' name='object_index' value='$object_index'>";
echo "<input type='hidden' name='ownerid' value='$ownerid'>";
echo "</form>";
echo "</div>";
echo "<div align='center' style='display: none;' id='managealerts'>";
ui_enable_disable_alerts ($object,$object_index,$ownerid);
echo "</div>";
}
function ui_enable_disable_alerts ($object,$object_index,$ownerid) {
$result_active_alerts = mysql_query("SELECT send_alerts.alert_name AS 'Alert Name' FROM alert_type,send_alerts WHERE status = 'on' AND send_alerts.alert_name = alert_type.alert_name AND send_alerts.owner_id = $ownerid AND object = '$object' AND object_index = $object_index") or die ('Querry failed: ' . mysql_error());
$active_alerts = array();
while ($linea = mysql_fetch_array($result_active_alerts, MYSQL_ASSOC)) {
foreach ($linea as $field_col => $valor_col) {
$active_alerts[] = $linea["Alert Name"];
}
}
$query_disabled_alerts = "SELECT alert_name AS 'Alert Name' FROM alert_type WHERE status = 'on' ";
if (isset($active_alerts)){
foreach ($active_alerts as $active_alert) {
$query_disabled_alerts = "$query_disabled_alerts AND alert_name != '$active_alert' ";
}
}
$result_disabled_alerts = mysql_query($query_disabled_alerts);
while ($linea = mysql_fetch_array($result_disabled_alerts, MYSQL_ASSOC)) {
foreach ($linea as $field_col => $valor_col) {
$disabled_alerts[] = $linea["Alert Name"];
}
}
echo "<div class='roundedcornr_box'>
<div class='roundedcornr_top'><div></div></div>
<div class='roundedcornr_content'><p>";
echo "<div align='center'><h1>Manage Alerts</h1>";
echo "<form name='main' action='owners.php' method='GET'>";
echo "<input type='hidden' name='Disabled'>";
echo "<input type='hidden' name='Enabled'>";
echo "<input type='hidden' name='option' value='manage_alerts'>";
echo "<input type='hidden' name='object' value='$object'>";
echo "<input type='hidden' name='object_index' value='$object_index'>";
echo "<input type='hidden' name='ownerid' value='$ownerid'>";
echo "<table class='cancerbero' style='border: solid 0'>";
echo "<tr>";
echo "<td style='vertical-align: top;'>";
echo "<br>Disabled Alerts:<br><br>";
echo "<select multiple name='DisabledItems' size='15'>";
if ($disabled_alerts) {
foreach ($disabled_alerts as $disable_alert) {
echo "<option value='$disable_alert'>$disable_alert</option>";
}
} else {
echo "<option value=''>No more alerts</option>";
}
echo "</select>";
echo "</td>";
echo "<td style='border: solid 0'>";
echo "<input type='button' name='AddBtn' value=' >> ' OnClick='addItems(this.form.DisabledItems, this.form.EnabledItems); removeItems(this.form.DisabledItems);'> <br><br>";
echo "<input type='button' name='RemoveBtn' value=' << ' OnClick=\"addItems(this.form.EnabledItems, this.form.DisabledItems); removeItems(this.form.EnabledItems);\"> <br>";
echo "</td>";
echo "<td style='vertical-align: top;'>";
echo "<br>Enabled Alerts:<br><br>";
echo "<select multiple name='EnabledItems' size='15'>";
if ($active_alerts) {
foreach ($active_alerts as $active_alert) {
echo "<option value='$active_alert'>$active_alert</option>";
}
} else {
echo "<option value=''>No more alerts</option>";
}
echo "</select>";
echo "</td>";
echo "</tr>";
echo "</table><br><br>";
echo "<input type='button' value='Submit' OnClick=\"this.form.Disabled.value = makeStringFromSelect(this.form.DisabledItems); this.form.Enabled.value = makeStringFromSelect(this.form.EnabledItems); this.form.submit();\">";
echo "<br><br></form>";
echo "</div>";
echo "</p></div>";
echo "<div class='roundedcornr_bottom'><div></div></div></div>";
}
function print_users ($object, $object_index, $sum_mails_per_host = 0) {
$query_owners = "SELECT email as 'Owner', ownership.object, ownership.object_index FROM owners, ownership WHERE owners.owner_id = ownership.owner_id AND ownership.object = '$object' AND ownership.object_index = $object_index";
$result_owners = mysql_query($query_owners);
if (mysql_num_rows($result_owners) != 0) {
$title="<h1>Owners</h1>";
draw_table ($title,$query_owners,250);
}
echo "<br>";
if ($sum_mails_per_host != 0) {
$query_users = "SELECT distinct CONCAT(u.email,' (',((v.Mails/$sum_mails_per_host)*100),'%)') AS 'Email',v.host_id FROM users u,users_per_host v WHERE u.email = v.email order by '%' desc";
$result_users = mysql_query($query_users);
if (mysql_num_rows($result_users) != 0) {
$title="<h1>Users</h1>";
draw_table ($title,$query_users,250);
}
}
echo "<br>";
}
function menu_bar ($option,$object_id) {
$menu = "\n";
foreach ($option as $option_name => $value) {
switch($option_name) {
case 'rescan':
if ($value == 1) $menu = "$menu <a href='host_form.php?view_type=rescan_host&host_id=$object_id'><IMG title='Rescan host' alt='Rescan Host' src='icons/rescan.png' border='0'></a>";
break;
case 'edit':
if ($value == 1) $menu = "$menu <a href='host_form.php?view_type=edit&host_id=$object_id'><IMG title='Add comment' alt='Add Comment' src='icons/edit.png' border='0'></a>";
if ($value == 2) $menu = "$menu <a href='config.php?conf=range&range=$object_id&save=select'><IMG title='Edit Range' alt='Edit Range' src='icons/edit.png' border='0'></a>";
if ($value == 3) $menu = "$menu <a href='config.php?conf=sensor&sensor=$object_id&save=select'><IMG title='Edit Sensor' alt='Edit Sensor' src='icons/edit.png' border='0'></a>";
if ($value == 4) $menu = "$menu <a href='owner_manager.php?conf=modify&owner_id=$object_id'><IMG title='Edit owner' alt='Edit owner' src='icons/edit.png' border='0'></a>";
break;
case 'whitelist':
if ($value == 1) $menu = "$menu <a href='host_form.php?view_type=add_host_white_list&host_id=$object_id'><IMG title='Add host to the white list' alt='Add host to the white list' src='icons/no-scan.png' border='0'></a>";
if ($value == 2) $menu = "$menu <a href='host_form.php?view_type=del_host_white_list&host_id=$object_id'><IMG title='Remove host from the white list' alt='Remove host from the white list' src='icons/no-whitelist.png' border='0'></a>";
if ($value == 3) {
$query_data = mysql_query ("select range, sensor_id from ranges where ranges.range_id = $object_id") or die (mysql_error());
$data = mysql_fetch_assoc ($query_data);
$menu = "$menu <a href='config.php?conf=sensor&whitelist=$data[range]&sensor=$data[sensor_id]&savewl=save'><IMG title='Add range to the white list' alt='Add range to the white list' src='icons/no-scan.png' border='0'></a>";
}
if ($value == 4) {
$query_data = mysql_query ("select white_list, white_list_id, sensor_id from ranges, white_list where ranges.range_id = white_list.range_id and ranges.range_id = $object_id") or die (mysql_error());
$data = mysql_fetch_assoc ($query_data);
$menu = "$menu <a href='config.php?conf=sensor&whitelist=$data[white_list]&whitelistid=$data[white_list_id]&savewl=delete'><IMG title='Remove range from the white list' alt='Remove range from the white list' src='icons/no-whitelist.png' border='0'></a>";
}
break;
case 'trash':
if ($value == 1) $menu = "$menu <a href='host_form.php?view_type=delete_host&host_id=$object_id'><IMG title='Delete host' alt='Delete host' src='icons/delete.png' border='0'></a>";
if ($value == 2) $menu = "$menu <a href='config.php?conf=sensor&save=delete&sensor=$object_id'><IMG title='Delete sensor' alt='Delete sensor' src='icons/delete.png' border='0'></a>";
if ($value == 3) $menu = "$menu <a href='config.php?conf=range&save=delete&range=$object_id'><IMG title='Delete range' alt='Delete range' src='icons/delete.png' border='0'></a>";
if ($value == 4) $menu = "$menu <a href='owner_manager.php?conf=delete&owner_id=$object_id'><IMG title='Delete owner' alt='Delete owner' src='icons/delete.png' border='0'></a>";
if ($value == 5) $menu = "$menu <a href='host_form.php?view_type=delete_scan&scan_rec_id=$object_id'><IMG title='Delete scan' alt='Delete scan' src='icons/delete.png' border='0'></a>";
break;
case 'owners':
$menu = "$menu <a href='javascript:showhide(\"addusers\")'><IMG title='Add Owner of this object' alt='Add Owner of this object' src='icons/users.png' border='0'></a>";
break;
case 'owners_manager':
if ($value == 1) $menu = "$menu <a href='owner_manager.php?conf=add'><IMG title='Add a new owner' alt='Add a new owner' src='icons/users.png' border='0'></a>";
break;
case 'ask_dns':
if ($value == 1) $menu = "$menu <a href='host_form.php?view_type=ask_dns&host_id=$object_id'><IMG title='DNS name has changed' alt='DNS name has changed' src='icons/ask_dns.png' border='0'></a>";
break;
default:
echo "";
}
}
return $menu;
}
function delete_ranges ($range,$range_name) {
echo "Deleting range $range_name<br>";
echo "Deleting ports...";
$query_delete_ports = mysql_query("DELETE FROM ports WHERE range_id = $range") or die (mysql_error());
if ($query_delete_ports){
echo "...Done <br>";
}
echo "Deleting scans...";
$query_delete_scans = mysql_query("DELETE FROM scans WHERE range_id = $range") or die (mysql_error());
if ($query_delete_scans){
echo "...Done <br>";
}
echo "Deleting users...";
$query_delete_users = mysql_query("DELETE FROM users WHERE range_id = $range") or die (mysql_error());
if ($query_delete_users){
echo "...Done <br>";
}
echo "Deleting hosts...";
$query_delete_hosts = mysql_query("DELETE FROM hosts WHERE range_id = $range") or die (mysql_error());
if ($query_delete_hosts){
echo "...Done <br>";
}
echo "Deleting white lists associated...";
$query_delete_white_lists = mysql_query("DELETE FROM white_list WHERE range_id = $range") or die (mysql_error());
if ($query_delete_white_lists) {
echo "...Done <br>";
}
echo "Deleting range...";
$query_delete_range = mysql_query("DELETE FROM ranges WHERE range_id = $range") or die (mysql_error());
if ($query_delete_range) {
echo "...Done <br>";
}
return;
}
function show_colspan_cell ($data,$colspan) {
echo "<tr>\n";
echo "<th colspan=$colspan>\n";
echo "$data\n";
echo "</th>\n";
echo "</tr>\n";
return;
}
function show_header ($header) {
$config = new ReadConfig;
$general = $config->General('gui_debug');
switch($header) {
case 'host_id':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'sensor_id':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'range_id':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'Priority':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'object':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'object_index':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'owner_id':
if ($general['gui_debug'] == 1) {
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 255, 150);'><h3>$header</h3></td>\n";
}
break;
case 'scan_rec_id':
# don't print header.
break;
case 'range_name':
# don't print header.
break;
default:
echo "\t\t<td align='center' style='vertical-align: bottom; background-color: rgb(255, 204, 153);'><h3>$header</h3></td>\n";
}
return;
}
function draw_all ($title,$result,$ping = 1) {
$num_fields = mysql_num_fields($result);
echo "<table class='cancerbero' width = 250>\n";
show_colspan_cell($title,2);
$linea = mysql_fetch_assoc ($result);
if (!isset($linea["object_index"]) || !isset($linea["object"])) {
$object_index = "";
$object = "";
} else {
$object_index = $linea["object_index"];
$object = $linea["object"];
}
$add_user_form = "\n<div style='display: none;' id='addusers'>\n
\t<h3> Add the owner of this $object</h3>
\t<form id='add_users' action='owners.php' method='get' onsubmit='return checkform(this);'>\n
\t<h3>eMail: <input class='input' type='text' name='useremail' size='20' maxlength='100'></h3>\n
\t<input type='hidden' name='object_index' value='$object_index'>\n
\t<input type='hidden' name='object' value='$object'>\n
\t<input type='hidden' name='option' value='add_owners'>\n
\t<div align='center'><input class='lowred' type='submit' name='save' value='save'></div>\n
\t</form>\n
\t</div>\n";
show_colspan_cell($add_user_form,2);
foreach ($linea as $field_col => $valor_col) {
echo "\t<tr>\n";
$header = show_header($field_col);
$entry = show_line ($field_col,$valor_col,$linea);
echo "\t</tr>\n";
}
if ($ping) {
$ip = $linea['Ip'];
$linea = array('host_id'=>$object_index,'Ip'=>$ip);
echo "\t<tr>\n";
echo "\t\t<td align='center' style='vertical-align: top; background-color: rgb(255, 204, 153);'><h3>Ping</h3></td>\n";
$entry = show_line ("Ping",$ping,$linea);
echo "\t</tr>\n";
}
echo "\t</tr>\n";
echo "</tr>\n";
echo "</table>\n";
return;
}
function draw_host ($title,$result,$host_id,$ping = 1) {
$num_fields = mysql_num_fields($result);
echo "<table class='cancerbero' width = 250>\n";
show_colspan_cell($title,2);
$linea = mysql_fetch_assoc ($result);
$host_id = $linea["host_id"];
$ip = $linea["Ip"];
$add_user_form = "\n<div style='display: none;' id='addusers'>\n
\t<h3> Add the owner of this Host</h3>
\t<form id='add_users' action='owners.php' method='get' onsubmit='return checkform(this);'>\n
\t<h3>Name: <input class='input' type='text' name='username' size='20' maxlength='100'></h3>\n
\t<h3>eMail: <input class='input' type='text' name='useremail' size='20' maxlength='100'></h3>\n
\t<h3>Room: <input class='input' type='text' name='userroom' size='20' maxlength='20'></h3>\n
\t<h3>Telf.: <input class='input' type='text' name='usertel' size='15' maxlength='15'></h3>\n
\t<input type='hidden' name='object_index' value='$host_id'>\n
\t<input type='hidden' name='object' value='Host'>\n
\t<input type='hidden' name='option' value='add_owners'>\n
\t<div align='center'><input class='lowred' type='submit' name='save' value='save'></div>\n
\t</div>\n";
show_colspan_cell($add_user_form,2);
foreach ($linea as $field_col => $valor_col) {
echo "\t<tr>\n";
$header = show_header($field_col);
$entry = show_line ($field_col,$valor_col,$linea);
echo "\t</tr>\n";
}
if ($ping) {
$linea = array("host_id"=>$host_id,"Ip"=>$ip);
echo "\t<tr>\n";
echo "\t\t<td align='center' style='vertical-align: top; background-color: rgb(255, 204, 153);'><h3>Ping</h3></td>\n";
$entry = show_line ("Ping",$ping,$linea);
echo "\t</tr>\n";
}
echo "\t</tr>\n";
echo "</tr>\n";
echo "</table>\n";
return;
}
function draw_table ($title,$query,$width,$bottom='') {
$page = new MyPagina;
$page->sql = $query; // the (basic) sql statement (use the SQL whatever you like)
if ($title == "<h1>Last 10 IPs Scanned Info</h1>") {
$result = mysql_query($query) or die (mysql_error());
} else {
$result = $page->get_page_result(); // result set
}
$nav_links = $page->navigation(" | ", "currentStyle"); // the navigation links (define a CSS class selector for the current link)
$nav_info = $page->page_info("to"); // information about the number of records on page ("to" is the text between the number)
$num_fields = mysql_num_fields($result);
echo "<table class='cancerbero' width = $width>\n";
show_colspan_cell($title,$num_fields);
echo "<tr>\n";
for ($i=0;$i<($num_fields);$i++) {
$val_name = mysql_field_name ($result, $i);
$header = show_header($val_name);
}
echo "\t</tr>\n";
while ($linea = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($linea as $field_col => $valor_col) {
$entry = show_line ($field_col,$valor_col,$linea);
}
echo "\t</tr>\n";
}
show_colspan_cell($bottom,$num_fields);
echo "</table>\n";
#echo "</div>\n";
$page_info = $page->page_info();
$total = $page->get_total_rows();
$num_page = $page->set_page()+1;
$total_pages = $page->get_num_pages();
$message = ($total > NUM_ROWS) ? "<hr>Displaying results $page_info of $total record <br>Page: $num_page of $total_pages" : '';
#echo "<hr>\n";
if ( $message != '' ){
echo "<div align='center'><h2>".$message."</h2></div>";
echo "<div align='center'><p>".$nav_links."</p></div>";
}
return;
}
function show_line ($field_col,$valor_col,$line) {
$config = new ReadConfig;
$general = $config->General('gui_debug');
if (isset($line["host_id"]))
$host_id = $line["host_id"];
if ($field_col == "Ping") {
$ip = $line["Ip"];
}
switch($field_col) {
case 'host_id':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> <a href='host_form.php?view_type=view&host_id=$host_id'>$valor_col</a></h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'sensor_id':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> <a href='stats.php?stat=subsearch&type=sensor_stats&sensor=$valor_col&sensor_name=$line[Sensor]'>$valor_col</a></h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'range_id':
if (!isset($line["sensor_id"])) $line["sensor_id"] = "";
if (!isset($line["Sensor"])) $line["Sensor"] = "";
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> <a href='stats.php?stat=subsearch&type=range&sensor=$line[sensor_id]&sensor_name=$line[Sensor]&range=$valor_col&range_name=$line[Range]'>$valor_col</a></h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'scan_rec_id':
# don't print scan_rec_id
$entry = "";
break;
case 'range_name':
# don't print range_name
$entry = "";
break;
case 'Priority':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> $valor_col</h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'object':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> $valor_col</h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'object_index':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> $valor_col</h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'owner_id':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 150)'><h3> $valor_col</h3></td>\n";
if ($general['gui_debug'] == 1) {
echo "$entry";
}
break;
case 'Hostname':
$entry = "\t\t<td align = 'center' style='vertical-align: bottom; background-color: rgb(255, 255, 255)'><h3> <a href='host_form.php?view_type=view&host_id=$host_id'>$valor_col</a></h3></td>\n";
# <a href='host_form.php?view_type=edit&host_id=$host_id'><IMG src='icons/edit.png' border='0'></a> </h3></td>\n";
echo "$entry";
break;
case 'Ping':
$ping = 0;
#Ping supresed for demo version, the host will be randomly up or down
#$ping = rand (0,1);
$ping = shell_exec("fping -a -t50 $ip 2>&1");
#-----------------------------------------------
if ($ping) {
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><IMG SRC='icons/sip2.png' title='Is conected now' alt='is conected now' align='middle'></td>\n";
} else {
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><IMG SRC='icons/stop.png' title='Is NOT conected now' alt='is not connected now' align='middle'></span></td>";
}
echo "$entry";
break;
case 'Ip':
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='host_form.php?view_type=view&host_id=$host_id'>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case "Scan ID":
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='host_form.php?view_type=view_scan&scan_rec_id=$valor_col'>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case 'Email':
$adress = split (" ",$valor_col,2);
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='host_form.php?view_type=view_mail&search=Search&mail=$adress[0]'>$valor_col</a> <a href='host_form.php?view_type=delete_mail&email=$adress[0]&host_mail_id=$host_id'><img src='icons/delete_small.png' title='Delete Email' alt='Delete Email' align='bottom' border='0'></a></h3></td>\n";
echo "$entry";
break;
case 'Owner':
$adress = split (" ",$valor_col,2);
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='owners.php?option=view_owners&owner=$adress[0]&object=$line[object]&object_index=$line[object_index]'>$valor_col</a> <a href='owners.php?option=delete_owner&owner=$adress[0]&object=$line[object]&object_index=$line[object_index]'><img src='icons/delete_small.png' align='bottom' title='Delete Owner' alt='Delete Owner' border='0'></a></h3></td>\n";
echo "$entry";
break;
case 'Owner Email':
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='owner_manager.php?conf=owner&owner_id=$line[owner_id]'>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case 'Owner Name':
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='owner_manager.php?conf=owner&owner_id=$line[owner_id]'>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case "Alert Name":
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><input type='checkbox' name='$valor_col'>$valor_col </h3></td>\n";
echo "$entry";
break;
case "%":
$percentage = number_format($valor_col,2);
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>$percentage</h3></td>\n";
echo "$entry";
break;
case 'Service':
if ($valor_col) {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='stats.php?stat=subsearch&type=service&data=$valor_col'>$valor_col</a></h3></td>\n";
} else {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>Unknown</h3></td>\n";
}
echo "$entry";
break;
case "OS":
if ($valor_col) {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='stats.php?stat=subsearch&type=os_guessed&data=$valor_col'>$valor_col</a></h3></td>\n";
} else {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>Unknown</h3></td>\n";
}
echo "$entry";
break;
case "Port":
if ($valor_col) {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='stats.php?stat=subsearch&type=port&data=$valor_col'>$valor_col</a></h3></td>\n";
} else {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>Unknown</h3></td>\n";
}
echo "$entry";
break;
case 'Sensor':
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='owners.php?option=view_owners&object=Sensor&object_index=$line[sensor_id]' onmouseover=\"return escape('Sensor: $valor_col.<br>Click here to go to sensor display info.')\" >$valor_col</a></h3></td>\n";
echo "$entry";
break;
case 'Range':
#if (!isset($line["sensor_id"])) $line["sensor_id"] = "";
#if (!isset($line["Sensor"])) $line["Sensor"] = "";
$info = ($line['range_name'])? $line['range_name']:$valor_col;
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a title=$valor_col href='owners.php?option=view_owners&object=Range&object_index=$line[range_id]'>$info</a></h3></td>\n";
echo "$entry";
break;
case 'Range Name':
#if (!isset($line["sensor_id"])) $line["sensor_id"] = "";
#if (!isset($line["Sensor"])) $line["Sensor"] = "";
#$info = ($line['Range Name'])? $valor_col:"";
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a title=$line[Range] href='owners.php?option=view_owners&object=Range&object_index=$line[range_id]'>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case "Num of ranges":
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href=stats.php?stat=subsearch&type=range&sensor=$line[sensor_id]&sensor_name=$line[Sensor]>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case "Last Scan":
if ($valor_col == "1970-01-01") {
$valor_col = "Never";
}
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>$valor_col</h3></td>\n";
echo "$entry";
break;
case "Plugin Status":
$plugin_name_no_spaces = str_replace (" ", "", $line['Plugin Name']);
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><SELECT onmouseover=\"return escape('Select here if plugin is activated or not. Alerts of switched off Plugins cannot be configured and no alerts will be generated or emailed.')\" class='input' name='$plugin_name_no_spaces'>\n";
echo "$entry";
if ($valor_col == "on") {
$entry = "<option value=$valor_col selected>$valor_col</option>\n<option value=off>off</option></select></h3></td>";
} else {
$entry = "<option value=$valor_col selected>$valor_col</option>\n<option value=on>on</option></select></h3></td>";
}
echo "$entry";
break;
case "Plugin Name":
$entry = "\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href='config.php?conf=alerts&plugin_name=$valor_col'>$valor_col</a></h3></td>\n";
echo "$entry";
break;
case "Alert Status":
$plugin_name_no_spaces = str_replace (" ", "", $line['Name']);
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><SELECT onmouseover=\"return escape('Select here if alert is activated or not. Switched off Alerts cannot be configured and no alerts will be generated or emailed.')\" class='input' name='status_$plugin_name_no_spaces'>\n";
echo "$entry";
if ($valor_col == "on") {
$entry = "<option value=$valor_col selected>$valor_col</option>\n<option value=off>off</option></select></h3></td>";
} else {
$entry = "<option value=$valor_col selected>$valor_col</option>\n<option value=on>on</option></select></h3></td>";
}
echo "$entry";
break;
case "Alert Level":
$plugin_name_no_spaces = str_replace (" ", "", $line['Name']);
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><SELECT onmouseover=\"return escape('Select here the level of this alert.')\" class='input' name='level_$plugin_name_no_spaces'>\n";
echo "$entry";
if ($valor_col == "Critical") {
$entry = "<option value=Doom>Doom</option>\n<option value=$valor_col selected>$valor_col</option>\n<option value=Medium>Medium</option>\n<option value=Soft>Soft</option></select></h3></td>";
} elseif ($valor_col == "Medium") {
$entry = "<option value=Doom>Doom</option>\n<option value=Critical>Critical</option>\n<option value=$valor_col selected>$valor_col</option>\n<option value=Soft>Soft</option></select></h3></td>";
} elseif ($valor_col == "Soft") {
$entry = "<option value=Doom>Doom</option>\n<option value=Critical>Critical</option>\n<option value=Medium>Medium</option>\n<option value=$valor_col selected>$valor_col</option></select></h3></td>";
} else {
$entry = "<option value=$valor_col selected>$valor_col</option>\n<option value=Critical>Critical</option><option value=Medium>Medium</option><option value=Soft>Soft</option></select></h3></td>";
}
echo "$entry";
break;
case "Loop Mode":
if ($valor_col == 1) {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>On</h3></td>\n";
} else {
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'>Off</td>\n";
}
echo "$entry";
break;
case "Alerts":
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3><a href=host_form.php?view_type=view_alerts&scan_rec_id={$line['Scan ID']} >$valor_col</a></h3></td>\n";
echo "$entry";
break;
case "Checked":
$sensor = "null";
$range = "null";
$level = "null";
$alert = "null";
$status = "null";
$order_by = "ID";
$order_way = "ASC";
if (isset ($_GET['sensors']))
$sensor=$_GET['sensors'];
if (isset ($_GET['ranges']))
$range=$_GET['ranges'];
if (isset ($_GET['levels']))
$level=$_GET['levels'];
if (isset ($_GET['alerts']))
$alert=$_GET['alerts'];
if (isset ($_GET['status']))
$status=$_GET['status'];
if (isset ($_GET['order_by']))
$order_by=$_GET['order_by'];
if (isset ($_GET['order_way']))
$order_way=$_GET['order_way'];
echo"<td><form id='form_{$line['ID']}' name='form_{$line['ID']}' method='get' action=''>";
$oListBox= new classListBox("checked");
$oListBox->set_query("SELECT alert_checked,alert_id FROM alerts WHERE alert_id = {$line['ID']}","alert_id");
$oListBox->set_getback(true);
$oListBox->display_checked();
echo "
<INPUT type = hidden name=alertid value = '{$line['ID']}'>
<INPUT type = hidden name=sensors value = '$sensor'>
<INPUT type = hidden name=ranges value = '$range'>
<INPUT type = hidden name=levels value = '$level'>
<INPUT type = hidden name=alerts value = '$alert'>
<INPUT type = hidden name=status value = '$status'>
<INPUT type = hidden name=order_by value = '$order_by'>
<INPUT type = hidden name=order_way value = '$order_way'>
<INPUT type = hidden name=view_type value = 'view_alerts'>
<INPUT type = hidden name=scan_rec_id value = '{$line['scan_rec_id']}'>
";
echo "</form></td>\n";
$entry = "";
break;
default:
$entry="\t\t<td align = 'center' style='vertical-align: middle; background-color: rgb(255, 255, 255)'><h3>$valor_col</h3></td>\n";
echo "$entry";
}
return $entry;
}
function form_speed_nmap ($type, $opts) {
switch($type) {
case "Scan":
$speed_opts = mysql_query("SELECT nmap_option_name,nmap_cfg_id FROM nmap_cfg where nmap_type_cfg = 'Scan'") or die (mysql_error());
echo "<SELECT class='input' onmouseover=\"return escape('This is the nmap timing options applied in the scan of the host. Is JUST the default value for this sensor\'s range, the real value s defined for each range in the \'Config->Range\' menu.')\" name='nmap_opts'>";
break;
case "Sweep":
$speed_opts = mysql_query("SELECT nmap_option_name,nmap_cfg_id FROM nmap_cfg where nmap_type_cfg = 'Sweep'") or die (mysql_error());
echo "<SELECT class='input' onmouseover=\"return escape('Timing options used for Nmap in each sweep.')\" name='nmap_sweep_opts'>";
}
while ($options = mysql_fetch_row($speed_opts)) {
if ($options[1] == $opts ) {
echo "<option value=$options[1] selected>$options[0]</option>";
} else {
echo "<option value=$options[1]>$options[0]</option>";
}
}
echo "</SELECT>";
return;
}
?>