当前位置: 首页>>代码示例>>PHP>>正文


PHP zbx_is_int函数代码示例

本文整理汇总了PHP中zbx_is_int函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_is_int函数的具体用法?PHP zbx_is_int怎么用?PHP zbx_is_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zbx_is_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeCol

 /**
  * Returns a column object for the given row and field. Add additional service tree related formatting.
  *
  * @param $rowId
  * @param $colName
  *
  * @return CCol
  */
 protected function makeCol($rowId, $colName)
 {
     $class = null;
     if ($colName == 'status' && zbx_is_int($this->tree[$rowId][$colName]) && $this->tree[$rowId]['id'] > 0) {
         $status = $this->tree[$rowId][$colName];
         // do not show the severity for information and unclassified triggers
         if (in_array($status, array(TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_NOT_CLASSIFIED))) {
             $this->tree[$rowId][$colName] = new CSpan(_('OK'), 'green');
         } else {
             $this->tree[$rowId][$colName] = getSeverityCaption($status);
             $class = getSeverityStyle($status);
         }
     }
     $col = parent::makeCol($rowId, $colName);
     $col->addClass($class);
     return $col;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:25,代码来源:CServiceTree.php

示例2: 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 (isset($tableSchema['fields'][$field]['ref_table'])) {
             if ($tableSchema['fields'][$field]['null']) {
                 $values[$field] = $values[$field] == '0' ? NULL : $values[$field];
             }
         }
         if (is_null($values[$field])) {
             if ($tableSchema['fields'][$field]['null']) {
                 $values[$field] = 'NULL';
             } elseif (isset($tableSchema['fields'][$field]['default'])) {
                 $values[$field] = zbx_dbstr($tableSchema['fields'][$field]['default']);
             } else {
                 self::exception(self::DBEXECUTE_ERROR, _s('Field "%1$s" cannot be set to NULL.', $field));
             }
         } else {
             switch ($tableSchema['fields'][$field]['type']) {
                 case self::FIELD_TYPE_CHAR:
                     $length = mb_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 = mb_strlen($values[$field]);
                     $values[$field] = zbx_dbstr($values[$field]);
                     if ($DB['TYPE'] == ZBX_DB_DB2 || $DB['TYPE'] == ZBX_DB_ORACLE) {
                         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:omidmt,项目名称:zabbix-greenplum,代码行数:63,代码来源:DB.php

示例3: checkSpans

 /**
  * Checks that the row and column spans are valid.
  *
  * @throws APIException if the any of the spans is not an integer or missing
  *
  * @param array $screenItem
  * @param array $screen
  */
 protected function checkSpans(array $screenItem, array $screen)
 {
     if (isset($screenItem['rowspan'])) {
         if (!zbx_is_int($screenItem['rowspan']) || $screenItem['rowspan'] < 0) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Screen "%1$s" row span in cell X - %2$s Y - %3$s is incorrect.', $screen['name'], $screenItem['x'], $screenItem['y']));
         }
     }
     if (isset($screenItem['colspan'])) {
         if (!zbx_is_int($screenItem['colspan']) || $screenItem['colspan'] < 0) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Screen "%1$s" column span in cell X - %2$s Y - %3$s is incorrect.', $screen['name'], $screenItem['x'], $screenItem['y']));
         }
     }
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:21,代码来源:CScreenItem.php

示例4: checkServiceTime

/**
 * Validate the new service time. Validation is implemented as a separate function to be available directly from the
 * frontend.
 *
 * @throws APIException if the given service time is invalid
 *
 * @param array $serviceTime
 *
 * @return void
 */
function checkServiceTime(array $serviceTime)
{
    // type validation
    $serviceTypes = array(SERVICE_TIME_TYPE_DOWNTIME, SERVICE_TIME_TYPE_ONETIME_DOWNTIME, SERVICE_TIME_TYPE_UPTIME);
    if (!isset($serviceTime['type']) || !in_array($serviceTime['type'], $serviceTypes)) {
        throw new APIException(ZBX_API_ERROR_PARAMETERS, _('Incorrect service time type.'));
    }
    // one-time downtime validation
    if ($serviceTime['type'] == SERVICE_TIME_TYPE_ONETIME_DOWNTIME) {
        if (!isset($serviceTime['ts_from']) || !validateUnixTime($serviceTime['ts_from'])) {
            throw new APIException(ZBX_API_ERROR_PARAMETERS, _('Incorrect service start time.'));
        }
        if (!isset($serviceTime['ts_to']) || !validateUnixTime($serviceTime['ts_to'])) {
            throw new APIException(ZBX_API_ERROR_PARAMETERS, _('Incorrect service end time.'));
        }
    } else {
        if (!isset($serviceTime['ts_from']) || !zbx_is_int($serviceTime['ts_from']) || $serviceTime['ts_from'] < 0 || $serviceTime['ts_from'] > SEC_PER_WEEK) {
            throw new APIException(ZBX_API_ERROR_PARAMETERS, _('Incorrect service start time.'));
        }
        if (!isset($serviceTime['ts_to']) || !zbx_is_int($serviceTime['ts_to']) || $serviceTime['ts_to'] < 0 || $serviceTime['ts_to'] > SEC_PER_WEEK) {
            throw new APIException(ZBX_API_ERROR_PARAMETERS, _('Incorrect service end time.'));
        }
    }
    if ($serviceTime['ts_from'] >= $serviceTime['ts_to']) {
        throw new APIException(ZBX_API_ERROR_PARAMETERS, _('Service start time must be less than end time.'));
    }
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:37,代码来源:services.inc.php

示例5: checkValueType

 private static function checkValueType($value, $type)
 {
     switch ($type) {
         case PROFILE_TYPE_ID:
             return zbx_ctype_digit($value);
         case PROFILE_TYPE_INT:
             return zbx_is_int($value);
         case PROFILE_TYPE_STR:
             return zbx_strlen($value) <= self::$stringProfileMaxLength;
         default:
             return true;
     }
 }
开发者ID:hujingguang,项目名称:work,代码行数:13,代码来源:profiles.inc.php

示例6: validateNumber

function validateNumber($value, $min = null, $max = null)
{
    if (!zbx_is_int($value)) {
        return false;
    }
    if ($min !== null && $value < $min) {
        return false;
    }
    if ($max !== null && $value > $max) {
        return false;
    }
    return true;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:13,代码来源:validate.inc.php

示例7: checkStatus

 /**
  * Validates the "status" field. Assumes the "name" field is valid.
  *
  * @throws APIException if the value is incorrect
  *
  * @param array $service
  *
  * @return void
  */
 protected function checkStatus(array $service)
 {
     if (!empty($service['status']) && !zbx_is_int($service['status'])) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect status for service "%1$s".', $service['name']));
     }
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:15,代码来源:CService.php

示例8: checkValueMapMappings

/**
 * Check value map mappings.
 * 1. check if at least one is defined
 * 2. check if value is numeric
 * 3. check if mappend value is not empty string
 * 4. check for duplicate values
 *
 * @param array $mappings
 *
 * @throws Exception
 */
function checkValueMapMappings(array $mappings)
{
    if (empty($mappings)) {
        throw new Exception(_('Value mapping must have at least one mapping.'));
    }
    foreach ($mappings as $mapping) {
        if (!zbx_is_int($mapping['value'])) {
            throw new Exception(_('Value maps are used to create a mapping between numeric values and string representations.'));
        }
        if (zbx_empty($mapping['newvalue'])) {
            throw new Exception(_('Value cannot be mapped to empty string.'));
        }
    }
    $valueCount = array_count_values(zbx_objectValues($mappings, 'value'));
    foreach ($valueCount as $value => $count) {
        if ($count > 1) {
            throw new Exception(_s('Mapping value "%1$s" is not unique.', $value));
        }
    }
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:valuemap.inc.php

示例9: convertGraphs

 /**
  * Convert graph elements.
  *
  * @param array $graphs
  *
  * @return array
  */
 protected function convertGraphs(array $graphs)
 {
     foreach ($graphs as &$graph) {
         $graph['graph_items'] = $this->convertGraphItems($graph['graph_items']);
         if (zbx_is_int($graph['ymin_type_1'])) {
             if ($graph['ymin_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                 $graph['ymin_item_1']['key'] = $this->itemKeyConverter->convert($graph['ymin_item_1']['key']);
             }
         }
         if (zbx_is_int($graph['ymax_type_1'])) {
             if ($graph['ymax_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
                 $graph['ymax_item_1']['key'] = $this->itemKeyConverter->convert($graph['ymax_item_1']['key']);
             }
         }
     }
     unset($graph);
     return $graphs;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:25,代码来源:C20ImportConverter.php

示例10: checkSpans

 /**
  * Checks that the row and column spans are valid.
  *
  * @throws APIException if the any of the spans is not an integer or missing
  *
  * @param array $screenItem
  *
  * @return void
  */
 protected function checkSpans(array $screenItem)
 {
     if (zbx_empty($screenItem['rowspan']) || !zbx_is_int($screenItem['rowspan'])) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect row span provided for screen element located at X - %1$s and Y - %2$s.', $screenItem['x'], $screenItem['y']));
     }
     if (zbx_empty($screenItem['colspan']) || !zbx_is_int($screenItem['colspan'])) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect column span provided for screen element located at X - %1$s and Y - %2$s.', $screenItem['x'], $screenItem['y']));
     }
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:18,代码来源:CScreenItem.php

示例11: checkValueType

 private static function checkValueType($value, $type)
 {
     switch ($type) {
         case PROFILE_TYPE_ID:
             $result = zbx_ctype_digit($value);
             break;
         case PROFILE_TYPE_INT:
             $result = zbx_is_int($value);
             break;
         default:
             $result = true;
     }
     return $result;
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:14,代码来源:profiles.inc.php

示例12: check_type

function check_type(&$field, $flags, &$var, $type)
{
    if (is_array($var) && $type != T_ZBX_IP) {
        $err = ZBX_VALID_OK;
        foreach ($var as $el) {
            $err |= check_type($field, $flags, $el, $type);
        }
        return $err;
    }
    if ($type == T_ZBX_IP) {
        if (!validate_ip($var, $arr)) {
            if ($flags & P_SYS) {
                info('Critical error. Field [' . $field . '] is not IP');
                return ZBX_VALID_ERROR;
            } else {
                info('Warning. Field [' . $field . '] is not IP');
                return ZBX_VALID_WARNING;
            }
        }
        return ZBX_VALID_OK;
    }
    if ($type == T_ZBX_IP_RANGE) {
        if (!validate_ip_range($var)) {
            if ($flags & P_SYS) {
                info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_IP_RANGE_SMALL);
                return ZBX_VALID_ERROR;
            } else {
                info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_IP_RANGE_SMALL);
                return ZBX_VALID_WARNING;
            }
        }
        return ZBX_VALID_OK;
    }
    if ($type == T_ZBX_PORTS) {
        $err = ZBX_VALID_OK;
        $type = $flags & P_SYS ? ZBX_VALID_ERROR : ZBX_VALID_WARNING;
        foreach (explode(',', $var) as $el) {
            foreach (explode('-', $el) as $p) {
                $err |= check_type($field, $flags, $p, T_ZBX_INT);
                if ($p > 65535 || $p < 0) {
                    $err |= $type;
                }
            }
        }
        if ($err == ZBX_VALID_ERROR) {
            info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_PORT_RANGE_SMALL);
        } else {
            if ($err == ZBX_VALID_WARNING) {
                info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_PORT_RANGE_SMALL);
            }
        }
        return $err;
    }
    if ($type == T_ZBX_INT_RANGE) {
        if (!is_int_range($var)) {
            if ($flags & P_SYS) {
                info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_INTEGER_RANGE_SMALL);
                return ZBX_VALID_ERROR;
            } else {
                info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_INTEGER_RANGE_SMALL);
                return ZBX_VALID_WARNING;
            }
        }
        return ZBX_VALID_OK;
    }
    if ($type == T_ZBX_INT && !zbx_is_int($var)) {
        if ($flags & P_SYS) {
            info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_INTEGER_SMALL);
            return ZBX_VALID_ERROR;
        } else {
            info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_INTEGER_SMALL);
            return ZBX_VALID_WARNING;
        }
    }
    if ($type == T_ZBX_DBL && !is_numeric($var)) {
        if ($flags & P_SYS) {
            info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_DOUBLE_SMALL);
            return ZBX_VALID_ERROR;
        } else {
            info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_DOUBLE_SMALL);
            return ZBX_VALID_WARNING;
        }
    }
    if ($type == T_ZBX_STR && !is_string($var)) {
        if ($flags & P_SYS) {
            info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_STRING_SMALL);
            return ZBX_VALID_ERROR;
        } else {
            info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_IS_NOT_STRING_SMALL);
            return ZBX_VALID_WARNING;
        }
    }
    //*
    if ($type == T_ZBX_STR && !defined('ZBX_ALLOW_UNICODE') && zbx_strlen($var) != zbx_strlen($var)) {
        if ($flags & P_SYS) {
            info(S_CRITICAL_ERROR . '.' . SPACE . S_FIELD . SPACE . '[' . $field . ']' . SPACE . S_CONTAINS_MULTIBYTE_CHARS_SMALL);
            return ZBX_VALID_ERROR;
        } else {
            info(S_WARNING . '.' . SPACE . S_FIELD . SPACE . '[' . $field . '] - ' . S_MULTIBYTE_CHARS_ARE_RESTRICTED_SMALL);
            return ZBX_VALID_ERROR;
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:validate.inc.php

示例13: validateMapElement

 /**
  * Validate map element.
  *
  * @param string $data			import data
  * @param array  $parent_data	data's parent array
  * @param string $path			XML path
  *
  * @throws Exception			if the map element is invalid
  */
 public function validateMapElement($data, array $parent_data = null, $path)
 {
     if (zbx_is_int($parent_data['elementtype'])) {
         switch ($parent_data['elementtype']) {
             case SYSMAP_ELEMENT_TYPE_HOST:
                 $rules = ['type' => XML_ARRAY, 'rules' => ['host' => ['type' => XML_STRING | XML_REQUIRED]]];
                 break;
             case SYSMAP_ELEMENT_TYPE_MAP:
                 $rules = ['type' => XML_ARRAY, 'rules' => ['name' => ['type' => XML_STRING | XML_REQUIRED]]];
                 break;
             case SYSMAP_ELEMENT_TYPE_TRIGGER:
                 $rules = ['type' => XML_ARRAY, 'rules' => ['host' => ['type' => XML_STRING], 'description' => ['type' => XML_STRING | XML_REQUIRED], 'expression' => ['type' => XML_STRING | XML_REQUIRED]]];
                 break;
             case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
                 $rules = ['type' => XML_ARRAY, 'rules' => ['name' => ['type' => XML_STRING | XML_REQUIRED]]];
                 break;
             default:
                 return $data;
         }
         $data = (new CXmlValidatorGeneral($rules, $this->format))->validate($data, $path);
     }
     return $data;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:32,代码来源:C10XmlValidator.php

示例14: validateYMaxItem

 /**
  * Validate "ymax_item_1" tag.
  *
  * @param string $data			import data
  * @param array  $parent_data	data's parent array
  * @param string $path			XML path
  *
  * @throws Exception			if the element is invalid
  */
 public function validateYMaxItem($data, array $parent_data = null, $path)
 {
     if (zbx_is_int($parent_data['ymax_type_1']) && $parent_data['ymax_type_1'] == GRAPH_YAXIS_TYPE_ITEM_VALUE) {
         $rules = ['type' => XML_ARRAY, 'rules' => ['host' => ['type' => XML_STRING | XML_REQUIRED], 'key' => ['type' => XML_STRING | XML_REQUIRED]]];
     } else {
         $rules = ['type' => XML_ARRAY, 'rules' => []];
     }
     return (new CXmlValidatorGeneral($rules, $this->format))->validate($data, $path);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:18,代码来源:C30XmlValidator.php

示例15: validateScreenSize

 /**
  * Validate vsize and hsize parameters.
  *
  * @param array $screen
  *
  * @throws APIException if the input is invalid.
  */
 protected function validateScreenSize(array $screen)
 {
     foreach (['vsize', 'hsize'] as $field_name) {
         if (!array_key_exists($field_name, $screen)) {
             continue;
         }
         if (!zbx_is_int($screen[$field_name])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect value for field "%1$s": %2$s.', $field_name, _('a numeric value is expected')));
         }
         if ($screen[$field_name] < SCREEN_MIN_SIZE || $screen[$field_name] > SCREEN_MAX_SIZE) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect value for field "%1$s": %2$s.', $field_name, _s('must be between "%1$s" and "%2$s"', SCREEN_MIN_SIZE, SCREEN_MAX_SIZE)));
         }
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:21,代码来源:CScreen.php


注:本文中的zbx_is_int函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。