<?php
// Datum: 28.04.10
// Author: Chrigi
// Version: 2.02
// File: index.php (zones)
//
// LICENSE
// Copyright (C) 2007-2010 Chrigi
// This file is part of Zonomania.
//
// Zonomania 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 3 of the License, or
// (at your option) any later version.
//
// Foobar 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 Zonomania. If not, see <http://www.gnu.org/licenses/>.
//
// DESCRIPTION
// Zonomania is a webbased application to document a SAN (Storage Area Network) environment.
// It is powerful in the hand of a SAN Administrator to manage, engineer and plan a SAN.
//
// What before has been done with table sheets, can now be done with Zonomania.
// Zonomania easily handles SAN servers, HBAs, zones, aliases, switches and LUNs.
// You always have an eye on firmware revisions, available switchports or fill levels of storage arrays.
// With Zonomania you keep track of your configuration items manually and Zonomania verifies
// the documentation online with your SAN devices. It also draws performance graphs from EVAperf csv files.
//
// As for now Zonomania is designed for an HP EVA SAN environement.
// Any enhancements, especially the integration of other storage systems, are welcome.
//
//
///////////////////////////////////////////////////////////////////////////////////////
error_reporting(E_ALL);
include("../var/dbconnect.php"); // zur DB verbinden
include("../var/config.php"); // configuration things
session_start();
$error_add = $_GET['error_add'];
$error_del = $_GET['error_del'];
$name = $_GET['name'];
$description = $_GET['description'];
$zonetype = $_GET['zonetype'];
$fabric = $_GET['fabric'];
$add = $_GET['add'];
$zone = $_GET['zone'];
$alias = $_GET['alias'];
$max = $_GET['max']; // von welcher Zone sollen die Members angezeigt werden
$txt = $_GET['txt']; // soll die Tabelle als txt ausgegeben werden
if (!$txt) $txt = FALSE;
$verify = $_GET['verify']; // soll eine Zone verifiziert werden
if (!$verify) $verify = FALSE;
else {
require_once('../var/sshdinge.php');
$ports_real = verify_zone($fabric, $verify);
if ($DEV_LOG_LEVEL > 2) error_log(date("M d H:i:s ")."### zones/index.php INHALT VON ports_real: ".implode(' | ', $ports_real)."\n", 3, $DEV_LOG_FILE);
}
if (!$add) $add = FALSE;
if (!$zone) $zone = FALSE;
if (!$alias) $alias = FALSE;
if (!$max) $max = FALSE;
$query_zones = "SELECT zones_id, fabric, name, description, zonetype FROM zm_zones ORDER BY name";
$query_zosys = "SELECT zm_sysgroup.sysgroup_id, zm_sysgroup.name AS sysgroup_name, zm_zosys.zosys_id, zm_zosys.zones_id, zm_zosys.systems_id, zm_systems.name AS systemname, zm_systems.port_id, zm_systems.description, zm_switch.shortname
FROM zm_zosys, zm_systems, zm_switch, zm_sysgroup
WHERE zm_zosys.systems_id = zm_systems.systems_id
AND zm_switch.switch_id = zm_systems.switch_id
AND zm_systems.sysgroup_id = zm_sysgroup.sysgroup_id";
$query_alzo = "SELECT zm_alzo.alzo_id, zm_alzo.zones_id, zm_alzo.alias_id, zm_alias.name AS aliasname, zm_alias.description
FROM zm_alzo, zm_alias
WHERE zm_alzo.alias_id = zm_alias.alias_id";
$query_systems = "SELECT zm_switch.shortname, zm_systems.port_id, zm_systems.systems_id, zm_systems.name, zm_systems.fabric, zm_systems.wwn_id, zm_systems.description
FROM zm_systems, zm_switch
WHERE zm_systems.switch_id = zm_switch.switch_id ORDER BY zm_systems.name";
$query_alias = "SELECT zm_alias.name, zm_alias.description, zm_alias.alias_id, zm_alias.fabric FROM zm_alias ORDER BY zm_alias.name";
$output_zones = mysql_query($query_zones);
if (!$output_zones) {
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL QUERY zones: $query_zones\n", 3, $DEV_LOG_FILE);
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL ERROR: ".mysql_error()."\n", 3, $DEV_LOG_FILE);
}
$output_zosys = mysql_query($query_zosys);
if (!$output_zosys) {
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL QUERY zosys: $query_zosys\n", 3, $DEV_LOG_FILE);
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL ERROR: ".mysql_error()."\n", 3, $DEV_LOG_FILE);
}
$output_alzo = mysql_query($query_alzo);
if (!$output_alzo) {
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL QUERY alzo: $query_alzo\n", 3, $DEV_LOG_FILE);
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL ERROR: ".mysql_error()."\n", 3, $DEV_LOG_FILE);
}
$output_systems = mysql_query($query_systems);
if (!$output_systems) {
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL QUERY systems: $query_systems\n", 3, $DEV_LOG_FILE);
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL ERROR: ".mysql_error()."\n", 3, $DEV_LOG_FILE);
}
$output_alias = mysql_query($query_alias);
if (!$output_alias) {
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL QUERY alias: $query_alias\n", 3, $DEV_LOG_FILE);
error_log(date("M d H:i:s ")."### zones/index.php FAILED SQL ERROR: ".mysql_error()."\n", 3, $DEV_LOG_FILE);
}
// zones in array abfüllen
$i = 0;
$anz_zonen_a = 0; $anz_zonen_b = 0;
while ($row = mysql_fetch_object($output_zones)) {
$zones_id[$i] = $row->zones_id;
$zones_fabric[$i] = $row->fabric;
$zones_name[$i] = $row->name;
$zones_description[$i] = $row->description;
$zones_zonetype[$i] = $row->zonetype;
if ($zones_fabric[$i] == "A") $anz_zonen_a++; // ergründung der anzahl zonen
else $anz_zonen_b++;
if (($zone || $alias) && $error_del == $zones_id[$i]) $act_zone = $zones_name[$i]; // zone_id in namen umwandeln für "device/alias zonen"
$i++;
}
// zosys in array abfüllen
$i = 0;
while ($row = mysql_fetch_object($output_zosys)) {
$zosys_id[$i] = $row->zosys_id;
$zosys_zone[$i] = $row->zones_id;
$zosys_system[$i] = $row->systems_id;
$zosys_system_name[$i] = $row->systemname;
$zosys_system_port[$i] = $row->port_id;
$zosys_system_switch[$i] = $row->shortname;
$zosys_system_desc[$i] = $row->description;
$zosys_system_sysgroup[$i] = $row->sysgroup_name;
$zosys_system_sysgroup_id[$i] = $row->sysgroup_id;
$i++;
}
// alzo in array abfüllen
$i = 0;
while ($row = mysql_fetch_object($output_alzo)) {
$alzo_id[$i] = $row->alzo_id;
$alzo_zone[$i] = $row->zones_id;
$alzo_alias[$i] = $row->alias_id;
$alzo_alias_name[$i] = $row->aliasname;
$alzo_alias_desc[$i] = $row->description;
$i++;
}
// systeme in array abfüllen
$i = 0;
while ($row = mysql_fetch_object($output_systems)) {
$systems_id[$i] = $row->systems_id;
$systems_name[$i] = $row->name;
$systems_fabric[$i] = $row->fabric;
$systems_wwn[$i] = $row->wwn_id;
$systems_switch[$i] = $row->shortname;
$systems_port[$i] = $row->port_id;
$systems_desc[$i] = $row->description;
$i++;
}
// alias in array abfüllen
$i = 0;
while ($row = mysql_fetch_object($output_alias)) {
$alias_name[$i] = $row->name;
$alias_id[$i] = $row->alias_id;
$alias_fabric[$i] = $row->fabric;
$alias_desc[$i] = $row->description;
$i++;
}
//
// HEADER
//******************************
echo $HEADER_LESS;
?>
<script type="text/javascript">
function hideShow(tag, el_id) {
tr=document.getElementsByTagName(tag)
for (i=0;i<tr.length;i++) {
if (tr[i].getAttribute('myname') == el_id) {
if ( tr[i].style.display == 'none' ) tr[i].style.display = '';
else tr[i].style.display = 'none';
}
}
}
function changeStyleodd(obj) {
if (obj.className == 'select') {
obj.className='odd';
} else {
obj.className='select';
}
}
function changeStyleeven(obj) {
if (obj.className == 'select') {
obj.className='even';
} else {
obj.className='select';
}
}
</script>
<?php
//
// HTML BODY
//******************************
if ($_SESSION['user'] == 'yaganaka' && $add) echo "<body onload='this.document.form1.name.focus();'>";
else echo "<body>";
//
// MENU
//******************************
echo "<div id='header' style=\"background-image:url($BG_HEADER); background-repeat:repeat-x;\">";
echo $TITELBILD;
echo $ZONEN_MENU;
//
// SYMBOLLEISTE
//******************************
if ($_SESSION['user'] == 'yaganaka') {
$caller = $_SERVER['PHP_SELF']; // Pfad und Name des aufrufenden Script, notwendig für return
echo "<p class='symbolleiste'>";
echo "<a class='symbolleiste' href='../functions/toggle_view.php?set_view=A&caller=$caller'> A</a>";
echo "<a class='symbolleiste' href='../functions/toggle_view.php?set_view=B&caller=$caller'> B</a>";
echo "<a class='symbolleiste' href='../functions/toggle_view.php?set_view=all&caller=$caller'> A & B</a>";
if ($max == 'all') echo "<a class='symbolleiste' href='./index.php?error_add=&error_del=&name=&description=&zonetype=&fabric=&add=0&max=0'> Schliessen</a>";
else echo "<a class='symbolleiste' href='./index.php?error_add=&error_del=&name=&description=&zonetype=&fabric=&add=0&max=all'> Öffnen</a>";
echo "<a class='symbolleiste' href='./index.php?error_add=&error_del=&name=&description=&add=1'> Neue Zone</a>";
echo "<a class='symbolleiste' href='./index.php?txt=1'> CSV</a>";
echo "<a class='symbolleiste' href='#' onclick=\"window.open('".$ROOT."help.php?for=Zonen', 'hilfe', 'width=400,height=700,left=100,top=200');\"> Hilfe</a>";
echo "<a class='symbolleiste' href='./index.php?error_add=&error_del=&name=&description=&add=0'> Abbrechen</a>";
echo "</p>";
}
echo "</div>";
//
// ERROR MELDUNGEN
//******************************
echo "<div id='container' style=\"background-image:url($BG_CONTAINER);\">";
if ($_SESSION['user'] == 'yaganaka') {
if ($error_add == "ok") echo "<p class='ok'><img class='error' src='$IMG_OK' />Zone erfolgreich erstellt/ modifiziert.</p>";
elseif ($error_del == "ok") echo "<p class='ok'><img class='error' src='$IMG_OK' />Zone erfolgreich gelöscht.</p>";
elseif ($error_add == "name") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Ungültiger Name</p>";
elseif ($error_del == "id") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Bitte eine Zone auswählen</p>";
elseif ($error_del == "inuse") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Die Zone enthält noch einen Device oder Alias.</p>";
elseif ($error_add == "zonetype") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Bitte Zonentyp angeben</p>";
elseif ($error_add == "fabric") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Bitte Fabric angeben</p>";
elseif ($error_add == "name_exist") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Zone existiert bereits.</p>";
elseif ($error_add == "name_mod") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Name falsch. Modifikation abgebrochen.</p>";
elseif ($error_add == "zonetype_mod") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Zonentyp falsch. Modifikation abgebrochen.</p>";
elseif ($error_add == "fabric_mod") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Fabric falsch. Modifikation abgebrochen.</p>";
elseif ($error_add == "name_exist_mod") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Zone existiert bereits. Modifikation abgebrochen.</p>";
elseif ($error_del > 0 && $error_del < 100000 && !$zone && !$alias) echo "<p class='warning'><img class='error' src='$IMG_WARNING' />ACHTUNG! Du modifizierst die Zone: $name</p>";
elseif ($error_del == "unzone_ok") echo "<p class='ok'><img class='error' src='$IMG_OK' />Device/ Alias erfolgreich aus der Zone entfernt.</p>";
elseif ($error_del == "unzone_prob") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Mindestens ein Device oder Alias auswählen!</p>";
elseif ($error_add == "zone_ok") echo "<p class='ok'><img class='error' src='$IMG_OK' />Device/ Alias erfolgreich zur Zone hinzugefügt.</p>";
elseif ($error_add == "system_exists") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Device bereits in Zone!</p>";
elseif ($error_add == "alias_exists") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Alias bereits in Zone!</p>";
elseif ($error_add == "nosystem") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Kein Device ausgewählt!</p>";
elseif ($error_add == "noalias") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Kein Alias ausgewählt!</p>";
elseif ($error_del == "alias") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Alias auswählen!</p>";
elseif ($error_add == "no_aliasmember") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Keine Devices in Alias. Bitte zuerst Devices zu Alias hinzufügen!</p>";
elseif ($error_add == "double_zone_entry") echo "<p class='notok'><img class='error' src='$IMG_NOTOK' />Member kann der Zone nicht hinzugefügt werden, da ein Device des Alias bereits Member dieser Zone ist.</p>";
}
//
// NEUE ZONE ERFASSEN
//*******************************************
if ($_SESSION['user'] == 'yaganaka' && $add) {
echo "<form name='form1' method='post' action='functions/insert_zone.php?zone_id=$error_del'>";
if (!$error_add && !$error_del) echo "<p class='formtitle'> </p>";
echo "<table border='0' cellspacing='0' cellpadding='0' align='center' width='300'>";
echo "<tr>";
echo "<td>Name*:</td>";
echo "<td colspan='2'><input class='feld' type='text' name='name' size='20' maxlength='99' value='$name' tabindex='1' ></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Beschreibung:</td>";
echo "<td colspan='2'><input class='feld' type='text' name='description' size='20' maxlength='100' value='$description' tabindex='2' ></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Fabric*:</td>";
echo "<td><input type='radio' name='fabric' value='A' ";
if ($fabric == 'A') echo "checked='' ";
echo "tabindex='3' />A</td>";
echo "<td><input type='radio' name='fabric' value='B' ";
if ($fabric == 'B') echo "checked='' ";
echo "tabindex='4' />B</td>";
echo "</tr>";
echo "<tr>";
echo "<td title='Befinden sich in dieser Zone Switchports oder WWNs?'>Zonentyp*:</td>";
echo "<td><input type='radio' title='In dieser Zone befinden sich nur Ports' name='zonetype' value='hz' ";
if ($zonetype == 'hz') echo "checked='' ";
echo "tabindex='5' />HardZone</td>";
echo "<td><input type='radio' title='In dieser Zone befinden sich nur WWNs' name='zonetype' value='sz' ";
if ($zonetype == 'sz') echo "checked='' ";
echo "tabindex='6' />SoftZone</td>";
echo "</tr>";
echo "</table>";
echo "<p class='normal'><input class='ok' title='Zone Hinzufügen' type='submit' value='OK' tabindex='7'></p>";
echo "</form>";
echo "<br/><hr class='index'/>";
}
//
// DEVICE ZONEN
//*******************************************
if ($_SESSION['user'] == 'yaganaka' && $zone) {
echo "<form name='zone' method='post' action='../systems/functions/zone_system.php?zone_id=$error_del&fabric=$fabric'>";
if (!$error_add && (!$error_del || !is_int($error_del))) echo "<p class='formtitle'>Device zu einer Zone hinzufügen</p>";
echo "<p class='normal'>";
echo " <select size='1' name='system' width='20' tabindex='1'>";
echo " <option value=''>--- DEVICE ---</option>";
for ($i=0; $i < count($systems_id); $i++) {
if ($systems_fabric[$i] == $fabric && $systems_wwn[$i] != $INTERLINK_ID) echo "<option value='$systems_id[$i]'>$systems_name[$i] ($systems_switch[$i]/$systems_port[$i]) $systems_desc[$i]</option>";
}
echo "</select>";
echo "</p>";
echo "<p class='normal'>zu <strong>$act_zone</strong> hinzufügen <br/> </p>";
echo "<p class='normal'><input class='ok' title='Device zonen' type='submit' value='OK' tabindex='2'></p>";
echo "</form>";
echo "<br/><hr class='index'/>";
}
//
// ALIAS ZONEN
//*******************************************
if ($_SESSION['user'] == 'yaganaka' && $alias) {
echo "<form name='alias' method='post' action='../alias/functions/zone_alias.php?zone_id=$error_del&fabric=$fabric'>";
if (!$error_add && (!$error_del || !is_int($error_del))) echo "<p class='formtitle'>Alias zu einer Zone hinzufügen</p>";
echo "<p class='normal'>";
echo "<select size='1' name='alias' width='20' tabindex='1'>";
echo "<option value=''>--- ALIAS ---</option>";
for ($i=0; $i < count($alias_id); $i++) {
if ($alias_fabric[$i] == $fabric) echo "<option value='$alias_id[$i]'>$alias_name[$i] ($alias_desc[$i])</option>";
}
echo "</select>";
echo "</p>";
echo "<p class='normal'>zu <strong>$act_zone</strong> hinzufügen <br/> </p>";
echo "<p class='normal'><input class='ok' title='Alias zonen' type='submit' value='OK' tabindex='2'></p>";
echo "</form>";
echo "<br/><hr class='index'/>";
}
//
// HAUPTTABELLEN
//*******************************************
foreach ($ALL_FABRICS as $this_fabric) {
$table = '';
$table = $table."<form name='unzone' method='post' action='functions/unzone.php' onSubmit=\"return confirm('Willst du die ausgewählten Member wirklich aus der Zone entfernen?');\">";
if ($_SESSION['view'] == $this_fabric || $_SESSION['view'] == 'all') {
$table = $table."<a name='fabric$this_fabric'></a><h2>Fabric $this_fabric</h2>";
$table = $table."<table class='systems' id='anyid' cellpadding='0' cellspacing='0' align='center' width='$TABLE_WIDTH'>";
}
else $table = $table."<table style='display:none;' class='systems' id='anyid' cellpadding='0' cellspacing='0' align='center' width='$TABLE_WIDTH'>";
if ($_SESSION['view'] == $this_fabric || $_SESSION['view'] == 'all') $csv = $csv."\n\nFabric $this_fabric\n";
$table = $table."<tr><th>Name:</th><th>Beschreibung:</th><th>Fabric:</th><th>Typ:</th>";
if ($_SESSION['user'] == 'yaganaka') $table = $table."<th class='unsortable'> </th>";
$table = $table."</tr>";
$tr_class = 'odd'; $class = 'nada';
for ($i=0; $i < count($zones_id); $i++) { // für alle Zonen
if ($zones_fabric[$i] == $this_fabric) { // von Fabric A/B
// Memberliste zusammenstellen
$members = ''; $members_csv = '';
// VERIFY?
if ($verify == $zones_name[$i] && $fabric == $this_fabric) {
for ($j=0; $j < count($zosys_id); $j++) {
$sys_ok = FALSE;
if ($zosys_zone[$j] == $zones_id[$i]) { // für alle Systeme
for ($k=0; $k < count($ports_real); $k++) {
$switch_port = explode(",", $ports_real[$k]);
if ((int)$switch_port[0] == (int)$zosys_system_switch[$j] && (int)$switch_port[1] == (int)$zosys_system_port[$j]) {
$members = $members."<img class='button' src='$IMG_VERIFY_OK' /><input type='checkbox' name='system_id[]' value='$zosys_id[$j]'> <a title='Device Infos' class='$class' href='../systems/functions/set_chkport.php?level=2&to_check=$zosys_system_sysgroup[$j]&sysgroup_id=$zosys_system_sysgroup_id[$j]'><strong>$zosys_system_name[$j]</strong></a> ($zosys_system_switch[$j]/$zosys_system_port[$j]) $zosys_system_desc[$j]<br/>";
$ports_real[$k] = ''; $sys_ok = TRUE; // merken welche realen Ports und welches system bereits ausgegeben wurden
}
}
// systeme die im zm eingetragen sind, aber real nicht in der Zone sind
if (!$sys_ok) $members = $members."<img class='button' src='$IMG_VERIFY_NOK' /><input type='checkbox' name='system_id[]' value='$zosys_id[$j]'> <a title='Device Infos' class='$class' href='../systems/functions/set_chkport.php?level=2&to_check=$zosys_system_sysgroup[$j]&sysgroup_id=$zosys_system_sysgroup_id[$j]'><strong>$zosys_system_name[$j]</strong></a> ($zosys_system_switch[$j]/$zosys_system_port[$j]) $zosys_system_desc <font color='#FF0000'>PORT REAL NICHT IN ZONE</font><br/>";
}
}
for ($j=0; $j < count($alzo_id); $j++) { // für alle Alias
$alias_ok = FALSE;
if ($alzo_zone[$j] == $zones_id[$i]) {
for ($k=0; $k < count($ports_real); $k++) {
// komisches Zeichen am Anfang des Alias (ASCII HEX: 13, effektiv: ^S) entfernen
$zeichen = preg_split('//', $ports_real[$k], -1, PREG_SPLIT_NO_EMPTY); // in einzelne Zeichen zerlegen
$ports_real_neu = '';
for ($t=0; $t < count($zeichen); $t++) {
if (ord($zeichen[$t]) != 13) $ports_real_neu = $ports_real_neu.$zeichen[$t]; // falls ASCII Wert des Zeichens = 13 ist, nicht schreiben
}
//$table = $table."<tt>k=$k: ports_real_neu = #$ports_real_neu#<br/>alzo_alias_name[$j] = $alzo_alias_name[$j]<br/></tt>";
if ($ports_real_neu == $alzo_alias_name[$j]) {
$members = $members."<img class='button' src='$IMG_VERIFY_OK' /><input type='checkbox' name='alias_id[]' value='$alzo_id[$j]'> <a href='../alias/index.php?error_add=&error_del=&add=0&max=$alzo_alias[$j]#fabric$zones_fabric[$i]'><strong>$alzo_alias_name[$j]</strong></a> (ALIAS $alzo_alias[$j]) $alzo_alias_desc[$j]<br/>";
$ports_real[$k] = ''; $alias_ok = TRUE; // merken welche realen Ports und welches alias bereits ausgegeben wurden
}
}
// systeme die im zm eingetragen sind, aber real nicht in der Zone sind
if (!$alias_ok) $members = $members."<img class='button' src='$IMG_VERIFY_NOK' /><input type='checkbox' name='alias_id[]' value='$alzo_id[$j]'> <a href='../alias/index.php?error_add=&error_del=&add=0&max=$alzo_alias[$j]#fabric$zones_fabric[$i]'><strong>$alzo_alias_name[$j]</strong></a> (ALIAS $alzo_alias[$j]) $alzo_alias_desc[$j] <font color='#FF0000'>ALIAS REAL NICHT IN ZONE</font><br/>";
}
}
for ($k=0; $k < count($ports_real); $k++) {
// ports/alias die real in der zone sind, aber im zm nicht eingetragen sind
if ($ports_real[$k] != '') {
$switch_port = explode(",", $ports_real[$k]);
if (is_numeric($switch_port[0])) {
if ((int)$switch_port[0] < 100) {
if ((int)$switch_port[0] < 10) $switch_port[0] = "00".(int)$switch_port[0];
else $switch_port[0] = "0".(int)$switch_port[0];
}
// zu diesem Port zugehörigen Device abfragen
$query_switchport = "SELECT zm_systems.name, zm_systems.description FROM zm_systems, zm_switch WHERE zm_systems.switch_id = zm_switch.switch_id AND zm_systems.port_id = '$switch_port[1]' AND zm_switch.shortname = '$switch_port[0]'";
$output_switchport = mysql_query($query_switchport) or die("MySQL INSERT ERROR: Fehler beim abfragen der Anzahl Switchports. Check SQL Syntax!<br/><br/>STATEMENT:<br/>$query_switchport");
$switch_port_infos = mysql_fetch_row($output_switchport);
$members = $members."<img class='button' src='$IMG_VERIFY_NOK' /> <font color='#FF0000'>PORT REAL IN ZONE: </font><strong>$switch_port_infos[0]</strong> ($switch_port[0]/$switch_port[1]) $switch_port_infos[1]<br/>";
} else $members = $members."<img class='button' src='$IMG_VERIFY_NOK' /> <font color='#FF0000'>ALIAS REAL IN ZONE: </font><strong>$ports_real[$k]</strong><br/>";
}
}
// nicht VERIFY
} else {
for ($j=0; $j < count($zosys_id); $j++) { // für alle Systeme
if ($zosys_zone[$j] == $zones_id[$i]) {
if ($_SESSION['user'] == 'yaganaka') $members = $members."<input type='checkbox' name='system_id[]' value='$zosys_id[$j]'> <a title='Device Infos' class='$class' href='../systems/functions/set_chkport.php?level=2&to_check=$zosys_system_sysgroup[$j]&sysgroup_id=$zosys_system_sysgroup_id[$j]'><strong>$zosys_system_name[$j]</strong></a> ($zosys_system_switch[$j]/$zosys_system_port[$j]) $zosys_system_desc[$j]<br/>";
else $members = $members."<a title='Device Infos' class='$class' href='../systems/functions/set_chkport.php?level=2&to_check=$zosys_system_sysgroup[$j]&sysgroup_id=$zosys_system_sysgroup_id[$j]'><strong>$zosys_system_name[$j]</strong></a> ($zosys_system_switch[$j]/$zosys_system_port[$j]) $zosys_system_desc[$j]<br/>";
$members_csv = $members_csv."$zosys_system_name[$j] ($zosys_system_switch[$j]/$zosys_system_port[$j]); ";
if ($zosys_system_sysgroup[$j] == $_SESSION['selected_device']) $max_sel = $zones_id[$i]; // falls ein Device ausgeählt ist, sollen die entsprechenden Zonen aufgepoppt sein
}
}
for ($j=0; $j < count($alzo_id); $j++) { // für alle Alias
if ($alzo_zone[$j] == $zones_id[$i]) {
if ($_SESSION['user'] == 'yaganaka') $members = $members."<input type='checkbox' name='alias_id[]' value='$alzo_id[$j]'> <a href='../alias/index.php?error_add=&error_del=&add=0&max=$alzo_alias[$j]#fabric$zones_fabric[$i]'><strong>$alzo_alias_name[$j]</strong></a> (ALIAS $alzo_alias[$j]) $alzo_alias_desc[$j]<br/>";
else $members = $members."<a href='../alias/index.php?error_add=&error_del=&add=0&max=$alzo_alias[$j]#fabric$zones_fabric[$i]'><strong>$alzo_alias_name[$j]</strong></a> (ALIAS $alzo_alias[$j]) $alzo_alias_desc[$j]<br/>";
// Member des Alias herausfinden und anzeigen
$query_alsys = "SELECT zm_sysgroup.sysgroup_id, zm_sysgroup.name AS sysgroup_name, zm_systems.name, zm_switch.shortname, zm_systems.port_id, zm_systems.description
FROM zm_alsys, zm_systems, zm_switch, zm_sysgroup
WHERE zm_alsys.systems_id = zm_systems.systems_id
AND zm_systems.switch_id = zm_switch.switch_id
AND zm_systems.sysgroup_id = zm_sysgroup.sysgroup_id
AND zm_alsys.alias_id = '$alzo_alias[$j]'";
$output_alsys = mysql_query($query_alsys) or die("<p><strong>alsys Abfrage in zones/index.php fehlgeschlagen:</strong><br/> ".mysql_error()."</p><p><strong>SQL Statement:</strong><br/> ".$query_alsys."</p>");
while ($row = mysql_fetch_object($output_alsys)) {
$members = $members." <a title='Device Infos' class='$class' href='../systems/functions/set_chkport.php?level=2&to_check=$row->sysgroup_name&sysgroup_id=$row->sysgroup_id'><strong>$row->name</strong></a> ($row->shortname/$row->port_id) $row->description<br/>";
if ($row->sysgroup_name == $_SESSION['selected_device']) $max_sel = $zones_id[$i];
}
$members_csv = $members_csv."$alzo_alias_name[$j] ($alzo_alias_desc[$j]); ";
}
}
}
if ($members == '') $members = '<strong>no members</strong>';
// Tabelle ausgeben
if ($max == $zones_id[$i]) $table = $table."<tr class='select' onclick='changeStyle".$tr_class."(this)' id='$zones_id[$i]'>";
else $table = $table."<tr class='$tr_class' onclick='changeStyle".$tr_class."(this)' id='$zones_id[$i]'>";
$table = $table."<td width='200'><a name='$zones_id[$i]'></a><img onclick='hideShow(\"tr\", $zones_id[$i])' style='float:right; border:0px;' title='Members anzeigen' src='$IMG_MAX' />";
$table = $table."<p class='$class'><strong>$zones_name[$i]</strong></p></td>";
$table = $table."<td><p>$zones_description[$i]</p></td>";
$table = $table."<td><p align='center'>$zones_fabric[$i]</p></td><td><p align='center'>$zones_zonetype[$i]</p></td>";
if ($_SESSION['view'] == $this_fabric || $_SESSION['view'] == 'all') $csv = $csv."$zones_name[$i],$zones_description[$i],$zones_zonetype[$i],$members_csv\n";
if ($_SESSION['user'] == 'yaganaka') {
$table = $table."<td width='115'>";
// verify zone
$table = $table."<a href='index.php?verify=$zones_name[$i]&fabric=$zones_fabric[$i]&max=$zones_id[$i]#$zones_id[$i]'><img title='verify Zone' class='button' src='$IMG_VERIFY' /></a> ";
// edit
$table = $table."<a href='index.php?error_add=&error_del=$zones_id[$i]&name=$zones_name[$i]&description=$zones_description[$i]&zonetype=$zones_zonetype[$i]&fabric=$zones_fabric[$i]&add=1&max=$zones_id[$i]'><img title='edit' class='button' src='$BUT_EDIT' /></a> ";
// delete zone
$table = $table."<a href='functions/delete_zone.php?id=$zones_id[$i]' onClick=\"return confirm('Willst du die Zone: $zones_name[$i] wirklich löschen?');\"><img title='delete' class='button' src='$BUT_DELETE' /></a> ";
// add device
$table = $table."<a href='index.php?error_add=&error_del=$zones_id[$i]&zone=1&fabric=$zones_fabric[$i]&add=0&alias=0&max=$zones_id[$i]'><img title='Device zonen' class='button' src='$IMG_DEV_ADD' /></a> ";
// add alias
$table = $table."<a href='index.php?error_add=&error_del=$zones_id[$i]&fabric=$zones_fabric[$i]&add=0&alias=1&max=$zones_id[$i]'><img title='Alias zonen' class='button' src='$IMG_ALIAS_ADD' /></a> ";
// remove device
$table = $table."<button class='standard' title='unzone' type=submit name='unzone_system' value='$zones_id[$i]'><img class='button' src='$UNDO_DEVICE' /></button>";
$table = $table."</td></tr>";
}
// 2. Row
if ($max == $zones_id[$i]) $table = $table."<tr class='select' myname='$zones_id[$i]' onclick='changeStyle".$tr_class."(this)'>";
elseif ($max == 'all' || $max_sel == $zones_id[$i]) $table = $table."<tr class='$tr_class' myname='$zones_id[$i]' onclick='changeStyle".$tr_class."(this)'>";
else $table = $table."<tr class='$tr_class' myname='$zones_id[$i]' style='display:none;' onclick='changeStyle".$tr_class."(this)'>";
$table = $table."<td bgcolor='white'> </td>";
if ($_SESSION['user'] == 'yaganaka') $table = $table."<td colspan='4'><p>$members</p></td>";
else $table = $table."<td colspan='3'><p>$members</p></td>";
$table = $table."</tr>";
// alternate row colors
if ($tr_class == 'odd') $tr_class = 'even';
else $tr_class = 'odd';
}
}
$table = $table."</table>";
$table = $table."</form>";
if (!$txt) echo $table;
}
//
// CSV OUTPUT
//*******************************************
if ($txt) {
$handle = fopen ($TMP_DIR."zonomania_zone.csv", "w");
fwrite($handle, $csv);
fclose($handle);
echo "<p align='center'><br/><br/><textarea name='txt' cols='$TEXTAREA_COLS' rows='$TEXTAREA_ROWS' >$csv</textarea></p>";
echo "<p align='center'><br/><a href='".$TMP_DIR_REL."zonomania_zone.csv'>als .csv herunterladen</a></p><p class='klein'>rechte Maustaste - Ziel speichern unter</p>";
}
echo "</div>";
//
// FUSSZEILE
//*******************************************
echo "<div id='footer' style=\"background-image:url($BG_FOOTER); background-repeat:repeat-x;\">";
echo $FOOTER;
echo "</div>";
echo "</body>";
echo "</html>";
mysql_close($db_connection); // Verbindung zur DB schliessen
?>