本文整理汇总了PHP中convert_delay函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_delay函数的具体用法?PHP convert_delay怎么用?PHP convert_delay使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了convert_delay函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mres
$alert_id = $_POST['alert_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$interval = mres($_POST['interval']);
$mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
if (empty($rule)) {
$update_message = "ERROR: No rule was generated - did you forget to click and / or?";
} elseif (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' || $_POST['device_id'][0] == ':') {
$device_id = $_POST['device_id'];
if (!is_numeric($count)) {
$count = '-1';
}
$delay_sec = convert_delay($delay);
$interval_sec = convert_delay($interval);
if ($mute == 'on') {
$mute = true;
} else {
$mute = false;
}
if ($invert == 'on') {
$invert = true;
} else {
$invert = false;
}
$extra = array('mute' => $mute, 'count' => $count, 'delay' => $delay_sec, 'invert' => $invert, 'interval' => $interval_sec);
$extra_json = json_encode($extra);
if (is_numeric($alert_id) && $alert_id > 0) {
if (dbUpdate(array('rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules', 'id=?', array($alert_id)) >= 0) {
$update_message = "Edited Rule: <i>{$name}: {$rule}</i>";
示例2: add_edit_rule
function add_edit_rule()
{
global $config;
$app = \Slim\Slim::getInstance();
$data = json_decode(file_get_contents('php://input'), true);
$status = 'error';
$message = '';
$code = 500;
$rule_id = mres($data['rule_id']);
$device_id = mres($data['device_id']);
if (empty($device_id) && !isset($rule_id)) {
$message = 'Missing the device id or global device id (-1)';
} elseif ($device_id == 0) {
$device_id = '-1';
}
$rule = $data['rule'];
if (empty($rule)) {
$message = 'Missing the alert rule';
}
$name = mres($data['name']);
if (empty($name)) {
$message = 'Missing the alert rule name';
}
$severity = mres($data['severity']);
$sevs = array('ok', 'warning', 'critical');
if (!in_array($severity, $sevs)) {
$message = 'Missing the severity';
}
$disabled = mres($data['disabled']);
if ($disabled != '0' && $disabled != '1') {
$disabled = 0;
}
$count = mres($data['count']);
$mute = mres($data['mute']);
$delay = mres($data['delay']);
$delay_sec = convert_delay($delay);
if ($mute == 1) {
$mute = true;
} else {
$mute = false;
}
$extra = array('mute' => $mute, 'count' => $count, 'delay' => $delay_sec);
$extra_json = json_encode($extra);
if (dbFetchCell('SELECT `name` FROM `alert_rules` WHERE `name`=?', array($name)) == $name) {
$message = 'Name has already been used';
}
if (empty($message)) {
if (is_numeric($rule_id)) {
if (dbUpdate(array('name' => $name, 'rule' => $rule, 'severity' => $severity, 'disabled' => $disabled, 'extra' => $extra_json), 'alert_rules', 'id=?', array($rule_id)) >= 0) {
$status = 'ok';
$code = 200;
} else {
$message = 'Failed to update existing alert rule';
}
} elseif (dbInsert(array('name' => $name, 'device_id' => $device_id, 'rule' => $rule, 'severity' => $severity, 'disabled' => $disabled, 'extra' => $extra_json), 'alert_rules')) {
$status = 'ok';
$code = 200;
} else {
$message = 'Failed to create new alert rule';
}
}
$output = array('status' => $status, 'err-msg' => $message);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例3: implode
$rule = implode(" ", $_POST['rules']);
$rule = rtrim($rule, '&&');
$rule = rtrim($rule, '||');
$alert_id = $_POST['alert_id'];
$count = mres($_POST['count']);
$delay = mres($_POST['delay']);
$mute = mres($_POST['mute']);
$name = mres($_POST['name']);
if (empty($rule)) {
$update_message = "ERROR: No rule was generated";
} elseif (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1') {
$device_id = $_POST['device_id'];
if (!is_numeric($count)) {
$count = '-1';
}
$delay_sec = convert_delay($delay);
if ($mute == 'on') {
$mute = true;
} else {
$mute = false;
}
$extra = array('mute' => $mute, 'count' => $count, 'delay' => $delay_sec);
$extra_json = json_encode($extra);
if (is_numeric($alert_id) && $alert_id > 0) {
if (dbUpdate(array('rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules', 'id=?', array($alert_id)) >= 0) {
$update_message = "Edited Rule: <i>{$name}: {$rule}</i>";
} else {
$update_message = "ERROR: Failed to edit Rule: <i>" . $rule . "</i>";
}
} else {
if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules')) {