Update zabbix.rpc.php

This commit is contained in:
Namhyeon Go 2019-04-08 10:19:23 +09:00 committed by GitHub
parent e974610602
commit 025f22d7f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,34 @@
<?php
// @file zabbix.rpc.php
if(!check_function_exists("zabbix_get_base_url")) {
function zabbix_get_base_url() {
return "http://localhost";
}
}
if(!check_function_exists("zabbix_authenticate")) {
function zabbix_authenticate($username, $password) {
$response = false;
if(loadHelper("webpagetool")) {
$response = get_web_json(zabbix_get_base_url() . "/zabbix/api_jsonrpc.php", "post", array(
"headers" => array(
"Content-Type" => "application/json-rpc",
),
"data" => array(
"jsonrpc" => "2.0",
"method" => "user.login",
"params" => array(
"user" => $username,
"password" => $password,
),
"id" => 1,
"auth" => null,
),
));
}
return $response;
}
}