private static function host($action, $params) { CHost::$error = array(); switch ($action) { case 'add': $result = CHost::add($params); break; case 'get': $result = CHost::get($params); break; case 'getById': $result = CHost::getById($params); break; case 'getId': $result = CHost::getId($params); break; case 'update': $result = CHost::update($params); break; case 'massUpdate': $result = CHost::massUpdate($params); break; case 'delete': $result = CHost::delete($params); break; default: self::$result = array('error' => ZBX_API_ERROR_NO_METHOD, 'data' => 'Method: "' . $action . '" doesn\'t exist.'); return; //exit function } if ($result !== false) { self::$result = array('result' => $result); } else { self::$result = CHost::$error; } }
unset($_REQUEST['hostid']); } unset($_REQUEST['delete']); } else { if (isset($_REQUEST['chstatus']) && isset($_REQUEST['hostid'])) { DBstart(); $result = update_host_status($_REQUEST['hostid'], $_REQUEST['chstatus']); $result = DBend($result); show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST_STATUS); unset($_REQUEST['chstatus']); unset($_REQUEST['hostid']); } else { if ($_REQUEST['go'] == 'delete') { $hostids = get_request('hosts', array()); $hosts = zbx_toObject($hostids, 'hostid'); $go_result = CHost::delete($hosts); show_messages($go_result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); } else { if (str_in_array($_REQUEST['go'], array('activate', 'disable'))) { $status = $_REQUEST['go'] == 'activate' ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $hosts = get_request('hosts', array()); $act_hosts = available_hosts($hosts, 1); DBstart(); $go_result = update_host_status($act_hosts, $status); $go_result = DBend($go_result); show_messages($go_result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST); } } } } }