/** * Delete Host * * @param array $hosts * @param array $hosts[0, ...]['hostid'] Host ID to delete * @return array|boolean */ public static function delete($hosts) { $hosts = zbx_toArray($hosts); $hostids = zbx_objectValues($hosts, 'hostid'); if (empty($hostids)) { return true; } try { self::BeginTransaction(__METHOD__); $options = array('hostids' => $hostids, 'editable' => 1, 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => 1); $del_hosts = self::get($options); foreach ($hostids as $hnum => $hostid) { if (!isset($del_hosts[$hostid])) { self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION); } } $result = delete_host($hostids, false); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot delete host'); } self::EndTransaction(true, __METHOD__); return array('hostids' => $hostids); } catch (APIException $e) { self::EndTransaction(false, __METHOD__); $error = $e->getErrors(); $error = reset($error); self::setError(__METHOD__, $e->getCode(), $error); return false; } }
unset($_REQUEST['form']); unset($_REQUEST['hostid']); } } else { /* group operations */ $result = true; $hosts = get_request('hosts', array()); $del_hosts = array(); $sql = 'SELECT host,hostid ' . ' FROM hosts ' . ' WHERE ' . DBin_node('hostid') . ' AND ' . DBcondition('hostid', $hosts) . ' AND ' . DBcondition('hostid', $available_hosts); $db_hosts = DBselect($sql); DBstart(); while ($db_host = DBfetch($db_hosts)) { $del_hosts[$db_host['hostid']] = $db_host['hostid']; /* add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST,'Host ['.$db_host['host'].']');*/ } $result = delete_host($del_hosts, $unlink_mode); $result = DBend($result); show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); } unset($_REQUEST['delete']); } else { if (($_REQUEST['config'] == 0 || $_REQUEST['config'] == 3) && inarr_isset(array('add_to_group', 'hostid'))) { // if(!uint_in_array($_REQUEST['add_to_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))){ if (!isset($available_groups[$_REQUEST['add_to_group']])) { access_deny(); } DBstart(); $result = add_host_to_group($_REQUEST['hostid'], $_REQUEST['add_to_group']); $result = DBend($result); show_messages($result, S_HOST_UPDATED, S_CANNOT_UPDATE_HOST); } else {
/** * Delete Template * * @param array $templateids * @param array $templateids['templateids'] * @return boolean */ public static function delete($templates) { $templates = zbx_toArray($templates); $templateids = array(); $options = array('templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => 1, 'extendoutput' => 1, 'preservekeys' => 1); $del_templates = self::get($options); foreach ($templates as $gnum => $template) { if (!isset($del_templates[$template['templateid']])) { self::setError(__METHOD__, ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION); return false; } $templateids[] = $template['templateid']; } if (!empty($templateids)) { $result = delete_host($templateids, false); } else { self::setError(__METHOD__, ZBX_API_ERROR_PARAMETERS, 'Empty input parameter [ templateids ]'); $result = false; } if ($result) { return array('templateids' => $templateids); } else { self::setError(__METHOD__); return false; } }
/** * Delete Host * * {@source} * @access public * @static * @since 1.8 * @version 1 * * @param array $hostids * @return boolean */ public static function delete($hostids) { $result = delete_host($hostids, false); if ($result) { return $hostids; } else { self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error'); return false; } }
<?php include '../standard_header.inc.php'; $hostDN = $_POST['dn']; $hostname = $_POST['name']; $dhcphlpcont = $_POST['dhcphlpcont']; $hostDN = htmlentities($hostDN); $hostname = htmlentities($hostname); /* echo "AU dn:"; print_r($auDN); echo "<br>"; echo "hostdn:"; print_r($hostDN); echo "<br>"; echo "hostname:"; print_r($hostname); echo "<br>"; */ $seconds = 1; $url = 'hostoverview.php'; echo "\n<html>\n<head>\n\t<title>AU Management</title>\n\t<link rel='stylesheet' href='../styles.css' type='text/css'>\n</head>\n<body>\n<table border='0' cellpadding='30' cellspacing='0'> \n<tr><td>"; if ($hostDN != "") { if (delete_host($hostDN)) { if ($dhcphlpcont != "") { update_dhcpmtime($auDN); } $mesg = "Rechner <b>" . $hostname . "</b> erfolgreich gelöscht!<br><br>"; } else { $mesg = "Fehler beim löschen von Rechner <b>" . $hostname . "</b> !<br><br>"; } } $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br>\t\t\t\t\n\t\t\tFalls nicht, klicken Sie hier <a href=" . $url . " style='publink'>back</a>"; redirect($seconds, $url, $mesg, $addSessionId = TRUE); echo "</td></tr></table></body>\n</html>";