Location: PHPKode > projects > Zonomania > zonomania202/zones/functions/delete_zone.php
<?php
// Datum: 12.03.09
// Author: Chrigi
// Version: 1.9
// File: delete_zones.php (functions)
//
// 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.
//
//
///////////////////////////////////////////////////////////////////////////////////////

include("../../var/config.php"); // configuration things
include("../../var/functions.php"); // function things

$id = $_GET["id"];
$error = 'ok';

if (!$id) $error = 'id';	// ist eine zone ausgewählt worden?

include("../../var/dbconnect.php"); // zur DB verbinden

// prüfen ob die zone noch verwendet wird
$statement_zosys = "SELECT zm_zosys.zones_id FROM zm_zosys GROUP BY zones_id";
$statement_alzo = "SELECT zm_alzo.zones_id FROM zm_alzo GROUP BY zones_id";

$output_zosys = mysql_query($statement_zosys) or die("SQL Syntax Error: Check Syntax from statement_zosys");
$output_alzo = mysql_query($statement_alzo) or die("SQL Syntax Error: Check Syntax from statement_alzo");

while ($row = mysql_fetch_object($output_zosys)) {
	if ($id == $row->zones_id) {
		$error = 'inuse';
		break;
	}
}
if ($error == 'ok') {		// falls bereits ein error vorhanden, muss nicht weitergemacht werden
	while ($row = mysql_fetch_object($output_alzo)) {
		if ($id == $row->zones_id) {
			$error = 'inuse';
			break;
		}
	}
}


// ZONE LÖSCHEN
///////////////////////////////////////////////////////////////////////////////////////
if ($error == 'ok') {
	// zone name herausfinden und Event erstellen
	if ($LOG_LEVEL > 0) {
		$statement = "SELECT zm_zones.name, zm_zones.description, zm_zones.zonetype, zm_zones.fabric FROM zm_zones WHERE zm_zones.zones_id = '$id'";
		$doit = mysql_query($statement) or die("<p><strong>zone löschen, events fehlgeschlagen:</strong><br/> ".mysql_error()."</p><p><strong>SQL Statement:</strong><br/> ".$statement."</p>");
		$zone_name = mysql_fetch_row($doit);
		createEvent('info', $zone_name[0], 'zone deleted', "desc: $zone_name[1], typ: $zone_name[2], fabric: $zone_name[3]");
	}
	$statement = "DELETE FROM zm_zones WHERE zones_id = '$id'";
	$doit = mysql_query($statement) or die("MySQL Error: blödes system kann nicht gelöscht werden! check SQL Syntax");
}

mysql_close($db_connection); // Verbindung zur DB schliessen
header("Location: ../index.php?error_add=&error_del=$error");
?>
Return current item: Zonomania