本文整理汇总了PHP中zbx_strlen函数 的典型用法代码示例。如果您正苦于以下问题:PHP zbx_strlen函数的具体用法?PHP zbx_strlen怎么用?PHP zbx_strlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zbx_strlen函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addItem
public function addItem($value, $caption = '', $selected = null, $enabled = 'yes')
{
if ($value instanceof CComboItem || $value instanceof COptGroup) {
parent::addItem($value);
} else {
$title = false;
// if caption is too long ( > 44 symbols), we add new class - 'selectShorten',
// so that the select box would not stretch
if (zbx_strlen($caption) > 44 && !$this->hasClass('selectShorten')) {
$this->setAttribute('class', $this->getAttribute('class') . ' selectShorten');
$title = true;
}
if (is_null($selected)) {
$selected = 'no';
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 'yes';
}
} elseif (strcmp($value, $this->value) == 0) {
$selected = 'yes';
}
} else {
$selected = 'yes';
}
$citem = new CComboItem($value, $caption, $selected, $enabled);
if ($title) {
$citem->setTitle($caption);
}
parent::addItem($citem);
}
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:31, 代码来源:class.ccombobox.php
示例2: add_audit_details
function add_audit_details($action, $resourcetype, $resourceid, $resourcename, $details = null)
{
if (zbx_strlen($resourcename) > 255) {
$resourcename = zbx_substr($resourcename, 0, 252) . '...';
}
$ip = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$values = array('userid' => CWebUser::$data['userid'], 'clock' => time(), 'ip' => substr($ip, 0, 39), 'action' => $action, 'resourcetype' => $resourcetype, 'resourceid' => $resourceid, 'resourcename' => $resourcename, 'details' => $details);
try {
DB::insert('auditlog', array($values));
return true;
} catch (DBException $e) {
return false;
}
}
开发者ID:itnihao, 项目名称:zatree-2.2, 代码行数:14, 代码来源:audit.inc.php
示例3: make_decoration
function make_decoration($haystack, $needle, $class = null)
{
$result = $haystack;
$pos = zbx_stripos($haystack, $needle);
if ($pos !== false) {
$start = zbx_substring($haystack, 0, $pos);
$end = zbx_substring($haystack, $pos + zbx_strlen($needle));
$found = zbx_substring($haystack, $pos, $pos + zbx_strlen($needle));
if (is_null($class)) {
$result = array($start, bold($found), $end);
} else {
$result = array($start, new CSpan($found, $class), $end);
}
}
return $result;
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:16, 代码来源:html.inc.php
示例4: make_decoration
function make_decoration($haystack, $needle, $class = null)
{
$result = $haystack;
$pos = stripos($haystack, $needle);
if ($pos !== FALSE) {
$start = zbx_substring($haystack, 0, $pos);
// $middle = substr($haystack, $pos, zbx_strlen($needle));
$middle = $needle;
$end = substr($haystack, $pos + zbx_strlen($needle));
if (is_null($class)) {
$result = array($start, bold($middle), $end);
} else {
$result = array($start, new CSpan($middle, $class), $end);
}
}
return $result;
}
开发者ID:phedders, 项目名称:zabbix, 代码行数:17, 代码来源:html.inc.php
示例5: validate
/**
* Checks if the given string is:
* - empty
* - not too long
* - matches a certain regex
*
* @param string $value
*
* @return bool
*/
public function validate($value)
{
if (zbx_empty($value)) {
if ($this->empty) {
return true;
} else {
$this->error($this->messageEmpty);
return false;
}
}
if ($this->maxLength && zbx_strlen($value) > $this->maxLength) {
$this->error($this->messageMaxLength, $this->maxLength);
return false;
}
if ($this->regex && !zbx_empty($value) && !preg_match($this->regex, $value)) {
$this->error($this->messageRegex, $value);
return false;
}
return true;
}
开发者ID:SandipSingh14, 项目名称:Zabbix_, 代码行数:30, 代码来源:CStringValidator.php
示例6: checkExpression
public function checkExpression($expression)
{
$length = zbx_strlen($expression);
$symbolNum = 0;
try {
if (zbx_empty(trim($expression))) {
throw new Exception('Empty expression.');
}
// Check expr start symbol
$startSymbol = zbx_substr(trim($expression), 0, 1);
if ($startSymbol != '(' && $startSymbol != '{' && $startSymbol != '-' && !zbx_ctype_digit($startSymbol)) {
throw new Exception('Incorrect trigger expression.');
}
for ($symbolNum = 0; $symbolNum < $length; $symbolNum++) {
$symbol = zbx_substr($expression, $symbolNum, 1);
// SDI($symbol);
$this->parseOpenParts($this->previous['last']);
$this->parseCloseParts($symbol);
// SDII($this->currExpr);
if ($this->inParameter($symbol)) {
$this->setPreviousSymbol($symbol);
continue;
}
$this->checkSymbolSequence($symbol);
$this->setPreviousSymbol($symbol);
// SDII($this->symbols);
}
$symbolNum = 0;
$simpleExpression = $expression;
$this->checkBraces();
$this->checkParts($simpleExpression);
$this->checkSimpleExpression($simpleExpression);
} catch (Exception $e) {
$symbolNum = $symbolNum > 0 ? --$symbolNum : $symbolNum;
$this->errors[] = $e->getMessage();
$this->errors[] = 'Check expression part starting from " ' . zbx_substr($expression, $symbolNum) . ' "';
}
}
开发者ID:songyuanjie, 项目名称:zabbix-stats, 代码行数:38, 代码来源:class.ctriggerexpression.php
示例7: add_audit_ext
function add_audit_ext($action, $resourcetype, $resourceid, $resourcename, $table_name, $values_old, $values_new)
{
global $USER_DETAILS;
if (!isset($USER_DETAILS["userid"])) {
check_authorisation();
}
if ($action == AUDIT_ACTION_UPDATE) {
$values_diff = array();
foreach ($values_new as $id => $value) {
if ($values_old[$id] !== $value) {
array_push($values_diff, $id);
}
}
if (0 == count($values_diff)) {
return true;
}
}
$auditid = get_dbid('auditlog', 'auditid');
if (zbx_strlen($resourcename) > 255) {
$details = substr($resourcename, 0, 252) . '...';
}
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
/*SDI(
'INSERT INTO auditlog (auditid,userid,clock,ip,action,resourcetype,resourceid,resourcename)'.
' values ('.$auditid.','.$USER_DETAILS['userid'].','.time().','.zbx_dbstr($ip).
','.$action.','.$resourcetype.','.$resourceid.','.zbx_dbstr($resourcename).')');*/
$result = DBexecute('INSERT INTO auditlog (auditid,userid,clock,ip,action,resourcetype,resourceid,resourcename)' . ' values (' . $auditid . ',' . $USER_DETAILS['userid'] . ',' . time() . ',' . zbx_dbstr($ip) . ',' . $action . ',' . $resourcetype . ',' . $resourceid . ',' . zbx_dbstr($resourcename) . ')');
if ($result && $action == AUDIT_ACTION_UPDATE) {
foreach ($values_diff as $id) {
$auditdetailid = get_dbid('auditlog_details', 'auditdetailid');
$result &= DBexecute('insert into auditlog_details (auditdetailid,auditid,table_name,field_name,oldvalue,newvalue)' . ' values (' . $auditdetailid . ',' . $auditid . ',' . zbx_dbstr($table_name) . ',' . zbx_dbstr($id) . ',' . zbx_dbstr($values_old[$id]) . ',' . zbx_dbstr($values_new[$id]) . ')');
}
}
if ($result) {
$result = $auditid;
}
return $result;
}
开发者ID:songyuanjie, 项目名称:zabbix-stats, 代码行数:38, 代码来源:audit.inc.php
示例8: addItem
public function addItem($value, $caption = '', $selected = NULL, $enabled = 'yes')
{
// if($enabled=='no') return; /* disable item method 1 */
if (is_object($value) && zbx_strtolower(get_class($value)) == 'ccomboitem') {
parent::addItem($value);
} else {
if (zbx_strlen($caption) > 44) {
$this->setAttribute('class', 'select selectShorten');
}
if (is_null($selected)) {
$selected = 'no';
if (is_array($this->value)) {
if (str_in_array($value, $this->value)) {
$selected = 'yes';
}
} else {
if (strcmp($value, $this->value) == 0) {
$selected = 'yes';
}
}
}
parent::addItem(new CComboItem($value, $caption, $selected, $enabled));
}
}
开发者ID:songyuanjie, 项目名称:zabbix-stats, 代码行数:24, 代码来源:class.ccombobox.php
示例9: access_deny
if (get_request('hostid') && !API::Host()->isWritable(array($_REQUEST['hostid']))) {
access_deny();
}
/*
* Actions
*/
if (isset($_REQUEST['add_expression'])) {
$_REQUEST['expression'] = $_REQUEST['expr_temp'];
$_REQUEST['expr_temp'] = '';
} elseif (isset($_REQUEST['and_expression'])) {
$_REQUEST['expr_action'] = '&';
} elseif (isset($_REQUEST['or_expression'])) {
$_REQUEST['expr_action'] = '|';
} elseif (isset($_REQUEST['replace_expression'])) {
$_REQUEST['expr_action'] = 'r';
} elseif (isset($_REQUEST['remove_expression']) && zbx_strlen($_REQUEST['remove_expression'])) {
$_REQUEST['expr_action'] = 'R';
$_REQUEST['expr_target_single'] = $_REQUEST['remove_expression'];
} elseif (isset($_REQUEST['clone']) && isset($_REQUEST['triggerid'])) {
unset($_REQUEST['triggerid']);
$_REQUEST['form'] = 'clone';
} elseif (isset($_REQUEST['save'])) {
$trigger = array('expression' => $_REQUEST['expression'], 'description' => $_REQUEST['description'], 'priority' => $_REQUEST['priority'], 'status' => $_REQUEST['status'], 'type' => $_REQUEST['type'], 'comments' => $_REQUEST['comments'], 'url' => $_REQUEST['url'], 'dependencies' => zbx_toObject(get_request('dependencies', array()), 'triggerid'));
if (get_request('triggerid')) {
// update only changed fields
$oldTrigger = API::Trigger()->get(array('triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'selectDependencies' => array('triggerid')));
if (!$oldTrigger) {
access_deny();
}
$oldTrigger = reset($oldTrigger);
$oldTrigger['dependencies'] = zbx_toHash(zbx_objectValues($oldTrigger['dependencies'], 'triggerid'));
开发者ID:SandipSingh14, 项目名称:Zabbix_, 代码行数:31, 代码来源:triggers.php
示例10: checkInput
protected function checkInput(&$hosts, $method)
{
$create = $method == 'create';
$update = $method == 'update';
$hostDBfields = $update ? array('hostid' => null) : array('host' => null);
if ($update) {
$dbHosts = $this->get(array('output' => array('hostid', 'host', 'flags'), 'hostids' => zbx_objectValues($hosts, 'hostid'), 'editable' => true, 'preservekeys' => true));
} else {
$groupids = array();
foreach ($hosts as $host) {
if (!isset($host['groups'])) {
continue;
}
$groupids = array_merge($groupids, zbx_objectValues($host['groups'], 'groupid'));
}
if ($groupids) {
$dbGroups = API::HostGroup()->get(array('output' => array('groupid'), 'groupids' => $groupids, 'editable' => true, 'preservekeys' => true));
}
}
foreach ($hosts as $host) {
// validate mandatory fields
if (!check_db_fields($hostDBfields, $host)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Wrong fields for host "%s".', isset($host['host']) ? $host['host'] : ''));
}
if ($update) {
$hostId = $host['hostid'];
// validate host permissions
if (!isset($dbHosts[$hostId])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
}
if (isset($host['groups']) && (!is_array($host['groups']) || !$host['groups'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('No groups for host "%s".', $dbHosts[$hostId]['host']));
}
} else {
if (!isset($host['groups']) || !is_array($host['groups']) || !$host['groups']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('No groups for host "%s".', $host['host']));
}
foreach ($host['groups'] as $group) {
if (!isset($dbGroups[$group['groupid']])) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
}
}
}
}
$inventoryFields = getHostInventories();
$inventoryFields = zbx_objectValues($inventoryFields, 'db_field');
$hostNames = array();
foreach ($hosts as &$host) {
if (isset($host['inventory']) && !empty($host['inventory'])) {
if (isset($host['inventory_mode']) && $host['inventory_mode'] == HOST_INVENTORY_DISABLED) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot set inventory fields for disabled inventory.'));
}
$fields = array_keys($host['inventory']);
foreach ($fields as $field) {
if (!in_array($field, $inventoryFields)) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect inventory field "%s".', $field));
}
}
}
$updateDiscoveredValidator = new CUpdateDiscoveredValidator(array('allowed' => array('hostid', 'status', 'inventory'), 'messageAllowedField' => _('Cannot update "%1$s" for a discovered host.')));
if ($update) {
// cannot update certain fields for discovered hosts
$this->checkPartialValidator($host, $updateDiscoveredValidator, $dbHosts[$host['hostid']]);
} else {
// if visible name is not given or empty it should be set to host name
if (!isset($host['name']) || zbx_empty(trim($host['name']))) {
$host['name'] = $host['host'];
}
if (!isset($host['interfaces'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('No interfaces for host "%s".', $host['host']));
}
}
if (isset($host['interfaces'])) {
if (!is_array($host['interfaces']) || empty($host['interfaces'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('No interfaces for host "%s".', $host['host']));
}
}
if (isset($host['host'])) {
// Check if host name isn't longer than 64 chars
if (zbx_strlen($host['host']) > 64) {
self::exception(ZBX_API_ERROR_PARAMETERS, _n('Maximum host name length is %1$d characters, "%2$s" is %3$d character.', 'Maximum host name length is %1$d characters, "%2$s" is %3$d characters.', 64, $host['host'], zbx_strlen($host['host'])));
}
if (!preg_match('/^' . ZBX_PREG_HOST_FORMAT . '$/', $host['host'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect characters used for host name "%s".', $host['host']));
}
if (isset($hostNames['host'][$host['host']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Duplicate host. Host with the same host name "%s" already exists in data.', $host['host']));
}
$hostNames['host'][$host['host']] = $update ? $host['hostid'] : 1;
}
if (isset($host['name'])) {
if ($update) {
// if visible name is empty replace it with host name
if (zbx_empty(trim($host['name']))) {
if (!isset($host['host'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Visible name cannot be empty if host name is missing.'));
}
$host['name'] = $host['host'];
}
}
//.........这里部分代码省略.........
开发者ID:hujingguang, 项目名称:work, 代码行数:101, 代码来源:CHost.php
示例11: checkValueTypes
public static function checkValueTypes($table, &$values)
{
global $DB;
$tableSchema = self::getSchema($table);
foreach ($values as $field => $value) {
if (!isset($tableSchema['fields'][$field])) {
unset($values[$field]);
continue;
}
if (is_null($values[$field])) {
if ($tableSchema['fields'][$field]['null']) {
$values[$field] = 'NULL';
} elseif (isset($tableSchema['fields'][$field]['default'])) {
$values[$field] = $tableSchema['fields'][$field]['default'];
} else {
self::exception(self::DBEXECUTE_ERROR, _s('Mandatory field "%1$s" is missing in table "%2$s".', $field, $table));
}
}
if (isset($tableSchema['fields'][$field]['ref_table'])) {
if ($tableSchema['fields'][$field]['null']) {
$values[$field] = zero2null($values[$field]);
}
}
if ($values[$field] === 'NULL') {
if (!$tableSchema['fields'][$field]['null']) {
self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "NULL" for NOT NULL field "%1$s".', $field));
}
} else {
switch ($tableSchema['fields'][$field]['type']) {
case self::FIELD_TYPE_CHAR:
$length = zbx_strlen($values[$field]);
$values[$field] = zbx_dbstr($values[$field]);
if ($length > $tableSchema['fields'][$field]['length']) {
self::exception(self::SCHEMA_ERROR, _s('Value "%1$s" is too long for field "%2$s" - %3$d characters. Allowed length is %4$d characters.', $values[$field], $field, $length, $tableSchema['fields'][$field]['length']));
}
break;
case self::FIELD_TYPE_ID:
case self::FIELD_TYPE_UINT:
if (!zbx_ctype_digit($values[$field])) {
self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "%1$s" for unsigned int field "%2$s".', $values[$field], $field));
}
$values[$field] = zbx_dbstr($values[$field]);
break;
case self::FIELD_TYPE_INT:
if (!zbx_is_int($values[$field])) {
self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "%1$s" for int field "%2$s".', $values[$field], $field));
}
$values[$field] = zbx_dbstr($values[$field]);
break;
case self::FIELD_TYPE_FLOAT:
if (!is_numeric($values[$field])) {
self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "%1$s" for float field "%2$s".', $values[$field], $field));
}
$values[$field] = zbx_dbstr($values[$field]);
break;
case self::FIELD_TYPE_TEXT:
$length = zbx_strlen($values[$field]);
$values[$field] = zbx_dbstr($values[$field]);
if ($DB['TYPE'] == ZBX_DB_DB2) {
if ($length > 2048) {
self::exception(self::SCHEMA_ERROR, _s('Value "%1$s" is too long for field "%2$s" - %3$d characters. Allowed length is 2048 characters.', $values[$field], $field, $length));
}
}
break;
}
}
}
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:68, 代码来源:DB.php
示例12: checkDns
/**
* Validates the "dns" field.
*
* @throws APIException if the field is invalid.
*
* @param array $interface
*/
protected function checkDns(array $interface)
{
if (zbx_strlen($interface['dns']) > 64) {
self::exception(ZBX_API_ERROR_PARAMETERS, _n('Maximum DNS name length is %1$d characters, "%2$s" is %3$d character.', 'Maximum DNS name length is %1$d characters, "%2$s" is %3$d characters.', 64, $interface['dns'], zbx_strlen($interface['dns'])));
}
if (!empty($interface['dns']) && !preg_match('/^' . ZBX_PREG_DNS_FORMAT . '$/', $interface['dns'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect interface DNS parameter "%s" provided.', $interface['dns']));
}
}
开发者ID:itnihao, 项目名称:zatree-2.2, 代码行数:16, 代码来源:CHostInterface.php
示例13: zbx_str2links
function zbx_str2links($text)
{
$result = array();
if (empty($text)) {
return $result;
}
preg_match_all('#https?://[^\\n\\t\\r ]+#u', $text, $matches, PREG_OFFSET_CAPTURE);
$start = 0;
foreach ($matches[0] as $match) {
$result[] = zbx_substr($text, $start, $match[1] - $start);
$result[] = new CLink($match[0], $match[0], null, null, true);
$start = $match[1] + zbx_strlen($match[0]);
}
$result[] = zbx_substr($text, $start, zbx_strlen($text));
return $result;
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:16, 代码来源:func.inc.php
示例14: __construct
public function __construct($url = null)
{
$this->url = null;
$this->port = null;
$this->host = null;
$this->protocol = null;
$this->username = null;
$this->password = null;
$this->file = null;
$this->reference = null;
$this->path = null;
$this->query = null;
$this->arguments = array();
if (empty($url)) {
$this->formatArguments();
$this->url = $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?' . $this->getQuery();
} else {
$this->url = urldecode($url);
$tmp_pos = strpos($this->url, '?');
$this->query = $tmp_pos !== false ? substr($this->url, $tmp_pos + 1) : '';
$tmp_pos = strpos($this->query, '#');
if ($tmp_pos !== false) {
$this->query = zbx_substring($this->query, 0, $tmp_pos);
}
$this->formatArguments($this->query);
}
$protocolSepIndex = strpos($this->url, '://');
if ($protocolSepIndex !== false) {
$this->protocol = strtolower(zbx_substring($this->url, 0, $protocolSepIndex));
$this->host = substr($this->url, $protocolSepIndex + 3);
$tmp_pos = strpos($this->host, '/');
if ($tmp_pos !== false) {
$this->host = zbx_substring($this->host, 0, $tmp_pos);
}
$atIndex = strpos($this->host, '@');
if ($atIndex !== false) {
$credentials = zbx_substring($this->host, 0, $atIndex);
$colonIndex = strpos(credentials, ':');
if ($colonIndex !== false) {
$this->username = zbx_substring($credentials, 0, $colonIndex);
$this->password = substr($credentials, $colonIndex);
} else {
$this->username = $credentials;
}
$this->host = substr($this->host, $atIndex + 1);
}
$host_ipv6 = strpos($this->host, ']');
if ($host_ipv6 !== false) {
if ($host_ipv6 < zbx_strlen($this->host) - 1) {
$host_ipv6++;
$host_less = substr($this->host, $host_ipv6);
$portColonIndex = strpos($host_less, ':');
if ($portColonIndex !== false) {
$this->host = zbx_substring($this->host, 0, $host_ipv6);
$this->port = substr($host_less, $portColonIndex + 1);
}
}
} else {
$portColonIndex = strpos($this->host, ':');
if ($portColonIndex !== false) {
$this->host = zbx_substring($this->host, 0, $portColonIndex);
$this->port = substr($this->host, $portColonIndex + 1);
}
}
$this->file = substr($this->url, $protocolSepIndex + 3);
$this->file = substr($this->file, strpos($this->file, '/'));
if ($this->file == $this->host) {
$this->file = '';
}
} else {
$this->file = $this->url;
}
$tmp_pos = strpos($this->file, '?');
if ($tmp_pos !== false) {
$this->file = zbx_substring($this->file, 0, $tmp_pos);
}
$refSepIndex = strpos($url, '#');
if ($refSepIndex !== false) {
$this->file = zbx_substring($this->file, 0, $refSepIndex);
$this->reference = substr($url, strpos($url, '#') + 1);
}
$this->path = $this->file;
if (zbx_strlen($this->query) > 0) {
$this->file .= '?' . $this->query;
}
if (zbx_strlen($this->reference) > 0) {
$this->file .= '#' . $this->reference;
}
if (isset($_COOKIE['zbx_sessionid'])) {
$this->setArgument('sid', substr($_COOKIE['zbx_sessionid'], 16, 16));
}
}
开发者ID:phedders, 项目名称:zabbix, 代码行数:92, 代码来源:class.curl.php
示例15: foreach
foreach ($expressions as $exprPart) {
if (isset($macrosData[$exprPart['expression']])) {
continue;
}
$fname = 'test_data_' . md5($exprPart['expression']);
$macrosData[$exprPart['expression']] = get_request($fname, '');
$info = get_item_function_info($exprPart['expression']);
if (!is_array($info) && isset($definedErrorPhrases[$info])) {
$allowedTesting = false;
$control = new CTextBox($fname, $macrosData[$exprPart['expression']], 30);
$control->setAttribute('disabled', 'disabled');
} else {
$octet = $info['value_type'] == 'HHMMSS';
$validation = $info['validation'];
if (substr($validation, 0, COMBO_PATTERN_LENGTH) == COMBO_PATTERN) {
$vals = explode(',', substr($validation, COMBO_PATTERN_LENGTH, zbx_strlen($validation) - COMBO_PATTERN_LENGTH - 4));
$control = new CComboBox($fname, $macrosData[$exprPart['expression']]);
foreach ($vals as $v) {
$control->addItem($v, $v);
}
} else {
$control = new CTextBox($fname, $macrosData[$exprPart['expression']], 30);
}
$fields[$fname] = array($info['type'], O_OPT, null, $validation, 'isset({test_expression})', $exprPart['expression']);
}
$data_table->addRow(new CRow(array($exprPart['expression'], is_array($info) || !isset($definedErrorPhrases[$info]) ? $info['value_type'] : new CCol($definedErrorPhrases[$info], 'disaster'), $control)));
}
}
//---------------------------------- CHECKS ------------------------------------
$fields['test_expression'] = array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null);
if (!check_fields($fields)) {
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:31, 代码来源:tr_testexpr.php
示例16: explode_exp
function explode_exp($expression, $html = false, $resolve_macro = false, $src_host = null, $dst_host = null)
{
$exp = !$html ? '' : array();
$trigger = array();
for ($i = 0, $state = '', $max = zbx_strlen($expression); $i < $max; $i++) {
if ($expression[$i] == '{') {
if ($expression[$i + 1] == '$') {
$usermacro = '';
$state = 'USERMACRO';
} elseif ($expression[$i + 1] == '#') {
$lldmacro = '';
$state = 'LLDMACRO';
} else {
$functionid = '';
$state = 'FUNCTIONID';
continue;
}
} elseif ($expression[$i] == '}') {
if ($state == 'USERMACRO') {
$usermacro .= '}';
if ($resolve_macro) {
$function_data['expression'] = $usermacro;
$function_data = API::UserMacro()->resolveTrigger($function_data);
$usermacro = $function_data['expression'];
}
if ($html) {
array_push($exp, $usermacro);
} else {
$exp .= $usermacro;
}
$state = '';
continue;
} elseif ($state == 'LLDMACRO') {
$lldmacro .= '}';
if ($html) {
array_push($exp, $lldmacro);
} else {
$exp .= $lldmacro;
}
$state = '';
continue;
} elseif ($functionid == 'TRIGGER.VALUE') {
if ($html) {
array_push($exp, '{' . $functionid . '}');
} else {
$exp .= '{' . $functionid . '}';
}
$state = '';
continue;
}
$sql = 'SELECT h.host,i.itemid,i.key_,f.function,f.triggerid,f.parameter,i.itemid,i.status,i.type,i.flags' . ' FROM items i,functions f,hosts h' . ' WHERE f.functionid=' . $functionid . ' AND i.itemid=f.itemid' . ' AND h.hostid=i.hostid';
if (is_numeric($functionid) && ($function_data = DBfetch(DBselect($sql)))) {
if ($resolve_macro) {
$trigger = $function_data;
$function_data = API::UserMacro()->resolveItem($function_data);
$function_data['expression'] = $function_data['parameter'];
$function_data = API::UserMacro()->resolveTrigger($function_data);
$function_data['parameter'] = $function_data['expression'];
}
if (!is_null($src_host) && !is_null($dst_host) && strcmp($src_host, $function_data['host']) == 0) {
$function_data['host'] = $dst_host;
}
if ($html) {
$style = $function_data['status'] == ITEM_STATUS_DISABLED ? 'disabled' : 'unknown';
if ($function_data['status'] == ITEM_STATUS_ACTIVE) {
$style = 'enabled';
}
if ($function_data['flags'] == ZBX_FLAG_DISCOVERY_CREATED || $function_data['type'] == ITEM_TYPE_HTTPTEST) {
$link = new CSpan($function_data['host'] . ':' . $function_data['key_'], $style);
} elseif ($function_data['flags'] == ZBX_FLAG_DISCOVERY_PROTOTYPE) {
$link = new CLink($function_data['host'] . ':' . $function_data['key_'], 'disc_prototypes.php?form=update&itemid=' . $function_data['itemid'] . '&parent_discoveryid=' . $trigger['discoveryRuleid'] . '&switch_node=' . id2nodeid($function_data['itemid']), $style);
} else {
$link = new CLink($function_data['host'] . ':' . $function_data['key_'], 'items.php?form=update&itemid=' . $function_data['itemid'] . '&switch_node=' . id2nodeid($function_data['itemid']), $style);
}
array_push($exp, array('{', $link, '.', bold($function_data['function'] . '('), $function_data['parameter'], bold(')'), '}'));
} else {
$exp .= '{' . $function_data['host'] . ':' . $function_data['key_'] . '.' . $function_data['function'] . '(' . $function_data['parameter'] . ')}';
}
} else {
if ($html) {
array_push($exp, new CSpan('*ERROR*', 'on'));
} else {
$exp .= '*ERROR*';
}
}
$state = '';
continue;
}
switch ($state) {
case 'FUNCTIONID':
$functionid .= $expression[$i];
break;
case 'USERMACRO':
$usermacro .= $expression[$i];
break;
case 'LLDMACRO':
$lldmacro .= $expression[$i];
break;
default:
if ($html) {
//.........这里部分代码省略.........
开发者ID:SandipSingh14, 项目名称:Zabbix_, 代码行数:101, 代码来源:triggers.inc.php
示例17: CSpan
if (!isset($step['url'])) {
$step['url'] = '';
}
if (!isset($step['posts'])) {
$step['posts'] = '';
}
if (!isset($step['required'])) {
$step['required'] = '';
}
$numSpan = new CSpan($i++ . ':');
$numSpan->addClass('rowNum');
$numSpan->setAttribute('id', 'current_step_' . $stepid);
$name = new CSpan($step['name'], 'link');
$name->setAttributes(array('id' => 'name_' . $stepid, 'name_step' => $stepid));
if (zbx_strlen($step['url']) > 70) {
$url = new CSpan(substr($step['url'], 0, 35) . SPACE . '...' . SPACE . substr($step['url'], zbx_strlen($step['url']) - 25, 25));
$url->setHint($step['url']);
} else {
$url = $step['url'];
}
if ($this->data['templated']) {
$removeButton = SPACE;
$dragHandler = SPACE;
} else {
$removeButton = new CButton('remove_' . $stepid, _('Remove'), 'javascript: removeStep(this);', 'link_menu');
$removeButton->setAttribute('remove_step', $stepid);
$dragHandler = new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move');
}
$row = new CRow(array($dragHandler, $numSpan, $name, $step['timeout'] . SPACE . _('sec'), $url, htmlspecialchars($step['required']), $step['status_codes'], $removeButton), 'sortable', 'steps_' . $stepid);
$stepsTable->addRow($row);
}
开发者ID:itnihao, 项目名称:zatree-2.2, 代码行数:31, 代码来源:configuration.httpconf.edit.php
示例18: imagecolorallocate
$darkgreen = imagecolorallocate($im, 0, 150, 0);
$bluei = imagecolorallocate($im, 0, 0, 255);
$darkblue = imagecolorallocate($im, 0, 0, 150);
$yellow = imagecolorallocate($im, 255, 255, 0);
$darkyellow = imagecolorallocate($im, 150, 150, 0);
$cyan = imagecolorallocate($im, 0, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 150, 150, 150);
$white = imagecolorallocate($im, 255, 255, 255);
$bg = imagecolorallocate($im, 6 + 6 * 16, 7 + 7 * 16, 8 + 8 * 16);
$x = imagesx($im);
$y = imagesy($im);
imagefilledrectangle($im, 0, 0, $x, $y, $white);
imagerectangle($im, 0, 0, $x - 1, $y - 1, $black);
$str = _s('%1$s (year %2$s)', $dbTrigger['description'], zbx_date2str('Y'));
$x = imagesx($im) / 2 - imagefontwidth(4) * zbx_strlen($str) / 2;
imageText($im, 10, 0, $x, 14, $darkred, $str);
$now = time(null);
$count_now = array();
$true = array();
$false = array();
$start = mktime(0, 0, 0, 1, 1, date('Y'));
$wday = date('w', $start);
if ($wday == 0) {
$wday = 7;
}
$start = $start - ($wday - 1) * SEC_PER_DAY;
$weeks = (int) (date('z') / 7 + 1);
for ($i = 0; $i < $weeks; $i++) {
$period_start = $start + SEC_PER_WEEK * $i;
$period_end = $start + SEC_PER_WEEK * ($i + 1);
开发者ID:SandipSingh14, 项目名称:Zabbix_, 代码行数:31, 代码来源:chart4.php
示例19: makeSImgStr
private function makeSImgStr($id)
{
$tr = new CRow();
$count = isset($this->tree[$id]['nodeimg']) ? zbx_strlen($this->tree[$id]['nodeimg']) : 0;
for ($i = 0; $i < $count; $i++) {
$td = new CCol();
switch ($this->tree[$id]['nodeimg'][$i]) {
case 'O':
$td->setAttribute('style', 'width: 22px');
$img = new CImg('images/general/tree/zero.gif', 'o', '22', '14');
break;
case 'I':
$td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
$img = new CImg('images/general/tree/zero.gif', 'i', '22', '14');
break;
case 'L':
$td->setAttribute('valign', 'top');
$div = new CTag('div', 'yes');
$div->setAttribute('style', 'height: 10px; width:22px; margin-left: -3px; background-image:url(images/general/tree/pointc.gif);');
if ($this->tree[$id]['nodetype'] == 2) {
$img = new CImg('images/general/tree/plus.gif', 'y', '22', '14');
$img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '",this);');
$img->setAttribute('id', 'idi_' . $id);
$img->setAttribute('class', 'pointer');
} else {
$img = new CImg('images/general/tree/pointl.gif', 'y', '22', '14');
}
$div->addItem($img);
$img = $div;
break;
case 'T':
$td->setAttribute('valign', 'top');
if ($this->tree[$id]['nodetype'] == 2) {
$td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
$img = new CImg('images/general/tree/plus.gif', 't', '22', '14');
$img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '",this);');
$img->setAttribute('id', 'idi_' . $id);
$img->setAttribute('class', 'pointer');
$img->setAttribute('style', 'top:2px;left:-3px;position:relative;');
} else {
$td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
$img = new CImg('images/general/tree/pointl.gif', 't', '22', '14');
}
break;
}
$td->addItem($img);
$tr->addItem($td);
}
return $tr;
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:50, 代码来源:CTree.php
krishnaik06/Machine-Learning-in-90-days
阅读:1062| 2022-08-18
joaomh/curso-de-matlab
阅读:1149| 2022-08-17
在美元的英文“dollar”里面明明没有字母“s”,为什么美元的符号($)是一条竖线穿过字
阅读:1063| 2022-11-06
问题来源:http://www.cnblogs.com/del/archive/2009/03/09/1284244.html#1472084{函数
阅读:1317| 2022-07-18
rugk/mastodon-simplified-federation: Simplifies following and interacting with r
阅读:1081| 2022-08-17
Zulip is an open-source team collaboration tool. Zulip Server versions 2.1.0 abo
阅读:647| 2022-07-29
Gabriella439/Haskell-Optparse-Generic-Library: Auto-generate a command-line pars
阅读:958| 2022-08-15
Tangshitao/Dense-Scene-Matching: Learning Camera Localization via Dense Scene Ma
阅读:763| 2022-08-16
长沙城南,有一所以“环保”为名的学校,从1979年创立以来,四易归属、五更其名。 这
阅读:757| 2022-11-06
//校验手机号 function IsMobileNumber( num:string ):boolean; begin
阅读:480| 2022-07-18
请发表评论