Source
xxxxxxxxxx
'geomaps_attribution' => 'Map data: © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Verify that function exists and can be called as a function.
*
* @param array $names
*
* @return bool
*/
function zbx_is_callable(array $names) {
foreach ($names as $name) {
if (!is_callable($name)) {
return false;
}
}
return true;
}
/************ REQUEST ************/
function redirect($url) {
$curl = (new CUrl($url))->removeArgument(CSRF_TOKEN_NAME);
header('Location: '.$curl->getUrl());
exit;
}
/**
* Check the HTTP request method.
*
* @param string $method HTTP request method
*
* @return bool true, if the request method matches
*/
function isRequestMethod($method) {
return (strtolower($method) === strtolower($_SERVER['REQUEST_METHOD']));
}
/**
* Check if request exist.
*
* @param string $name
*
* @return bool
*/
function hasRequest($name) {
return isset($_REQUEST[$name]);
}
/**
* Check request, if exist request - return request value, else return default value.
*
* @param string $name
* @param mixed $def
*
* @return mixed
*/
function getRequest($name, $def = null) {
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : $def;
}
function countRequest($str = null) {
if (!empty($str)) {
$count = 0;
foreach ($_REQUEST as $name => $value) {
if (strpos($name, $str) !== false) {
$count++;
}
}
return $count;
}
else {
return count($_REQUEST);
}
}