Source
* @param int $host_interfaces[]['details']['community'] Interface community for SNMP non version 3 interface.
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
function italic($str) {
if (is_array($str)) {
foreach ($str as $key => $val) {
if (is_string($val)) {
$em = new CTag('em', true);
$em->addItem($val);
$str[$key] = $em;
}
}
}
elseif (is_string($str)) {
$em = new CTag('em', true, '');
$em->addItem($str);
$str = $em;
}
return $str;
}
function bold($str) {
if (is_array($str)) {
foreach ($str as $key => $val) {
if (is_string($val)) {
$str[$key] = new CTag('b', true, $val);
}
}
return $str;
}
return new CTag('b', true, $str);
}
function make_decoration($haystack, $needle, $class = null) {
$result = $haystack;
$tmpHaystack = mb_strtolower($haystack);
$tmpNeedle = mb_strtolower($needle);
$pos = mb_strpos($tmpHaystack, $tmpNeedle);
if ($pos !== false) {
$start = CHtml::encode(mb_substr($haystack, 0, $pos));
$end = CHtml::encode(mb_substr($haystack, $pos + mb_strlen($needle)));
$found = CHtml::encode(mb_substr($haystack, $pos, mb_strlen($needle)));
if (is_null($class)) {
$result = [$start, bold($found), $end];
}
else {
$result = [$start, (new CSpan($found))->addClass($class), $end];
}
}
return $result;
}
function prepareUrlParam($value, $name = null) {
if (is_array($value)) {
$result = '';
foreach ($value as $key => $param) {
$result .= prepareUrlParam($param, isset($name) ? $name.'['.$key.']' : $key);
}
}
else {
$result = '&'.$name.'='.urlencode($value);
}
return $result;
}