/** * Delete IP Address * * Removes an IPAddress */ function deleteIP() { if ($_SESSION['client']['userdbo']->getType() != "Administrator") { throw new SWUserException("[ACCESS_DENIED]"); } foreach ($this->post['ipaddresses'] as $IPDBO) { // Remove the IP address from the database delete_IPAddressDBO($IPDBO); // Success $this->setMessage(array("type" => "[IP_DELETED]", "args" => array($IPDBO->getIPString()))); } }
/** * Delete ServerDBO from database * * @param ServerDBO &$dbo ServerDBO to delete * @return boolean True on success */ function delete_ServerDBO(&$dbo) { $DB = DBConnection::getDBConnection(); if ($dbo->getPurchases() != null) { // Can not delete Server until all purchases are removed throw new DBException("[SERVER_NOT_FREE]"); } // Delete all IP Addresses if (($ip_dbo_array = $dbo->getIPAddresses()) != null) { foreach ($ip_dbo_array as $ip_dbo) { delete_IPAddressDBO($ip_dbo); } } // Build DELETE query $sql = $DB->build_delete_sql("server", "id = " . $dbo->getID()); // Run query if (!mysql_query($sql, $DB->handle())) { throw new DBException(mysql_error($DB->handle())); } }