diff --git a/.gitignore b/.gitignore index eff3ba3..ad44dd1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ *.swp .DS_Store locales/po/*.mo +.omc/ diff --git a/includes/arrays.php b/includes/arrays.php index 46bc50a..32c4681 100644 --- a/includes/arrays.php +++ b/includes/arrays.php @@ -1,4 +1,6 @@ __('MQTT plaintext, default port 1883', 'servcheck'), ); -$service_types_ports = array( +$service_types_ports = [ 'web_http' => 80, 'web_https' => 443, @@ -106,7 +108,7 @@ // 'telnet_telnet' => 23, 'mqtt_mqtt' => 1883, -); +]; $graph_interval = array ( @@ -186,10 +188,10 @@ 10 => __('%d Seconds', 10, 'servcheck'), ); -$servcheck_notify_formats = array( +$servcheck_notify_formats = [ SERVCHECK_FORMAT_HTML => 'html', SERVCHECK_FORMAT_PLAIN => 'plain', -); +]; if (db_table_exists('plugin_servcheck_contacts')) { $servcheck_contact_users = db_fetch_assoc("SELECT pwc.id, pwc.data, pwc.type, ua.full_name @@ -198,10 +200,10 @@ ON ua.id=pwc.user_id WHERE pwc.data != ''"); } else { - $servcheck_contact_users = array(); + $servcheck_contact_users = []; } -$servcheck_notify_accounts = array(); +$servcheck_notify_accounts = []; if (!empty($servcheck_contact_users)) { foreach ($servcheck_contact_users as $servcheck_contact_user) { $servcheck_notify_accounts[$servcheck_contact_user['id']] = $servcheck_contact_user['full_name'] . ' - ' . ucfirst($servcheck_contact_user['type']); @@ -298,14 +300,14 @@ 'size' => '40', 'default' => '' ), - 'id' => array( + 'id' => [ 'method' => 'hidden_zero', 'value' => '|arg1:id|' - ), - 'save_component_proxy' => array( + ], + 'save_component_proxy' => [ 'method' => 'hidden', 'value' => '1' - ) + ] ); $servcheck_test_fields = array( @@ -542,10 +544,10 @@ 'max_length' => '20', 'value' => '|arg1:external_id|', ), - 'id' => array( + 'id' => [ 'method' => 'hidden_zero', 'value' => '|arg1:id|' - ), + ], ); $curl_error = array( diff --git a/includes/constants.php b/includes/constants.php index 8fb7c04..32a5772 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -1,4 +1,6 @@ DATE_SUB(NOW(), INTERVAL ? HOUR) - ORDER BY id", array($id, $interval)); + ORDER BY id", [$id, $interval]); if (cacti_sizeof($result) < 5) { print __('No data', 'servcheck'); @@ -144,44 +146,44 @@ function plugin_servcheck_graph ($id, $interval) { // Start chart attributes $chart = array( 'bindto' => "#line_$xid", - 'size' => array( + 'size' => [ 'height' => 300, 'width'=> 600 - ), - 'point' => array ( + ], + 'point' => [ 'r' => 1.5 - ), - 'data' => array( + ], + 'data' => [ 'type' => 'area', 'x' => 'x', 'xFormat' => '%Y-%m-%d %H:%M:%S' // rikam mu, jaky je format te timeserie - ) + ] ); - $columns = array(); - $axis = array(); - $axes = array(); + $columns = []; + $axis = []; + $axes = []; // Add the X Axis first - $columns[] = array_merge(array('x'), $lastcheck); - $columns[] = array_merge(array('Total'), $total_time); - $columns[] = array_merge(array('Connect'), $connect_time); - $columns[] = array_merge(array('DNS '), $namelookup_time); + $columns[] = array_merge(['x'], $lastcheck); + $columns[] = array_merge(['Total'], $total_time); + $columns[] = array_merge(['Connect'], $connect_time); + $columns[] = array_merge(['DNS '], $namelookup_time); // Setup the Axis $axis['x'] = array( 'type' => 'timeseries', 'tick' => array( 'format'=> '%m-%d %H:%M', - 'culling' => array('max' => 6), + 'culling' => ['max' => 6], ) ); $axis['y'] = array( 'tick' => array( - 'label' => array( + 'label' => [ 'text' => 'Response in ms', - ), + ], 'show' => true ) ); diff --git a/includes/index.php b/includes/index.php index 41ba701..a9d6c1e 100644 --- a/includes/index.php +++ b/includes/index.php @@ -1,4 +1,6 @@ gdi($this->cIx)); //$this->parse_data($curmx); - //$this->arrMX[] = array('MX_Pref' => $mxPref, 'MX' => $curmx); + //$this->arrMX[] = ['MX_Pref' => $mxPref, 'MX' => $curmx]; //$this->cIx += 3; } } @@ -78,7 +80,7 @@ function __destruct() { } function parse_data(&$retval) { - $arName = array(); + $arName = []; $byte = ord($this->gdi($this->cIx)); while($byte !== 0) { diff --git a/includes/tests.php b/includes/tests.php index 6ebff6d..0d9b1fa 100644 --- a/includes/tests.php +++ b/includes/tests.php @@ -1,4 +1,6 @@ true, CURLOPT_USERAGENT => $user_agent, CURLOPT_RETURNTRANSFER => true, @@ -44,7 +46,7 @@ function curl_try ($test) { CURLOPT_MAXREDIRS => 4, CURLOPT_TIMEOUT => $test['timeout_trigger'], CURLOPT_CAINFO => $ca_info, - ); + ]; if (($test['type'] == 'web_http' || $test['type'] == 'web_https') && empty($test['path'])) { cacti_log('Empty path, nothing to test'); @@ -116,7 +118,7 @@ function curl_try ($test) { plugin_servcheck_debug('Preparing own CA chain file ' . $ca_info , $test); $cert = db_fetch_cell_prepared('SELECT cert FROM plugin_servcheck_ca WHERE id = ?', - array($test['ca'])); + [$test['ca']]); $cert_file = fopen($ca_info, 'a'); if ($cert_file) { @@ -139,7 +141,7 @@ function curl_try ($test) { $proxy = db_fetch_row_prepared('SELECT * FROM plugin_servcheck_proxies WHERE id = ?', - array($test['proxy_server'])); + [$test['proxy_server']]); if (cacti_sizeof($proxy)) { $options[CURLOPT_PROXY] = $proxy['hostname']; @@ -190,12 +192,12 @@ function curl_try ($test) { plugin_servcheck_debug('cURL options: ' . clean_up_lines(var_export($options, true))); - curl_setopt_array($process,$options); + curl_setopt_array($process, $options); plugin_servcheck_debug('Executing curl request', $test); $data = curl_exec($process); - $data = str_replace(array("'", "\\"), array(''), $data); + $data = str_replace(["'", "\\"], [''], $data); $results['data'] = $data; // Get information regarding a specific transfer, cert info too @@ -208,7 +210,7 @@ function curl_try ($test) { plugin_servcheck_debug('Data: ' . clean_up_lines(var_export($data, true))); if ($results['curl_return'] > 0) { - $results['error'] = str_replace(array('"', "'"), '', (curl_error($process))); + $results['error'] = str_replace(['"', "'"], '', (curl_error($process))); } if ($test['ca'] > 0) { @@ -419,14 +421,14 @@ function mqtt_try ($test) { plugin_servcheck_debug('cURL options: ' . clean_up_lines(var_export($options, true))); - curl_setopt_array($process,$options); + curl_setopt_array($process, $options); plugin_servcheck_debug('Executing curl request', $test); curl_exec($process); $x = fclose($file); - $data = str_replace(array("'", "\\"), array(''), file_get_contents($filename)); + $data = str_replace(["'", "\\"], [''], file_get_contents($filename)); $results['data'] = $data; // Get information regarding a specific transfer @@ -442,7 +444,7 @@ function mqtt_try ($test) { if ($results['curl_return'] == 42) { $results['curl_return'] = 0; } elseif ($results['curl_return'] > 0) { - $results['error'] = str_replace(array('"', "'"), '', (curl_error($process))); + $results['error'] = str_replace(['"', "'"], '', (curl_error($process))); } curl_close($process); @@ -506,7 +508,7 @@ function mqtt_try ($test) { function doh_try ($test) { global $user_agent, $config, $ca_info, $service_types_ports; - $cert_info = array(); + $cert_info = []; // default result $results['result'] = 'ok'; @@ -514,7 +516,7 @@ function doh_try ($test) { $results['error'] = ''; $results['result_search'] = 'not tested'; - $options = array( + $options = [ CURLOPT_HEADER => true, CURLOPT_USERAGENT => $user_agent, CURLOPT_RETURNTRANSFER => true, @@ -522,7 +524,7 @@ function doh_try ($test) { CURLOPT_MAXREDIRS => 4, CURLOPT_TIMEOUT => $test['timeout_trigger'], CURLOPT_CAINFO => $ca_info, - ); + ]; if (empty($test['hostname']) || empty($test['dns_query'])) { cacti_log('Empty hsotname or dns_query, nothing to test'); @@ -548,7 +550,7 @@ function doh_try ($test) { plugin_servcheck_debug('Preparing own CA chain file ' . $ca_info , $test); $cert = db_fetch_cell_prepared('SELECT cert FROM plugin_servcheck_ca WHERE id = ?', - array($test['ca'])); + [$test['ca']]); $cert_file = fopen($ca_info, 'a'); if ($cert_file) { @@ -577,12 +579,12 @@ function doh_try ($test) { plugin_servcheck_debug('cURL options: ' . clean_up_lines(var_export($options, true))); - curl_setopt_array($process,$options); + curl_setopt_array($process, $options); plugin_servcheck_debug('Executing curl request', $test); $data = curl_exec($process); - $data = str_replace(array("'", "\\"), array(''), $data); + $data = str_replace(["'", "\\"], [''], $data); $results['data'] = $data; // Get information regarding a specific transfer, cert info too @@ -595,7 +597,7 @@ function doh_try ($test) { plugin_servcheck_debug('Data: ' . clean_up_lines(var_export($data, true))); if ($results['curl_return'] > 0) { - $results['error'] = str_replace(array('"', "'"), '', (curl_error($process))); + $results['error'] = str_replace(['"', "'"], '', (curl_error($process))); } if ($test['ca'] > 0) { diff --git a/index.php b/index.php index 41ba701..a9d6c1e 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,6 @@ 0) { plugin_servcheck_debug('Launching Service Check ' . $test['display_name'], $test); @@ -155,7 +157,7 @@ $running = db_fetch_cell_prepared('SELECT COUNT(*) FROM plugin_servcheck_processes WHERE poller_id = ?', - array($poller_id)); + [$poller_id]); if ($running == 0) { break; @@ -175,7 +177,7 @@ FROM plugin_servcheck_log WHERE test_id = ? ORDER BY id DESC LIMIT 1', - array($test['id'])); + [$test['id']]); if ($test_last['result'] == 'ok' || $test_last['result'] == 'not yet') { $stat_ok++; diff --git a/servcheck_ca.php b/servcheck_ca.php index 65b119a..a7c6ddf 100644 --- a/servcheck_ca.php +++ b/servcheck_ca.php @@ -1,4 +1,6 @@ $val) { @@ -86,7 +88,7 @@ function ca_form_actions() { input_validate_input_number($matches[1]); /* ==================================================== */ - $ca_list .= '
  • ' . db_fetch_cell_prepared('SELECT name FROM plugin_servcheck_ca WHERE id = ?', array($matches[1])) . '
  • '; + $ca_list .= '
  • ' . db_fetch_cell_prepared('SELECT name FROM plugin_servcheck_ca WHERE id = ?', [$matches[1]]) . '
  • '; $ca_array[] = $matches[1]; } } @@ -176,8 +178,8 @@ function ca_edit() { draw_edit_form( array( - 'config' => array('no_form_tag' => true), - 'fields' => inject_form_variables($servcheck_ca_fields, (isset($ca) ? $ca : array())) + 'config' => ['no_form_tag' => true], + 'fields' => inject_form_variables($servcheck_ca_fields, (isset($ca) ? $ca : [])) ) ); @@ -193,29 +195,29 @@ function ca_edit() { function request_validation() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'refresh' => array( + ], + 'refresh' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '20', - ), + ], 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -243,7 +245,7 @@ function ca() { $sql_where = ''; if (get_request_var('filter') != '') { - $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter'); + $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . 'name LIKE ' . db_qstr('%' . get_request_var('filter') . '%'); } $sql_order = get_order_string(); @@ -389,4 +391,3 @@ function clearFilter() { 0 && $test['next_run'] < time() && !$force) { plugin_servcheck_debug('INFO: Test ' . $test['display_name'] . ' skipped. The test is not run every poller cycle.', $test); @@ -152,7 +154,7 @@ /* attempt to get results 3 times before exiting */ $x = 0; -$results = array(); +$results = []; while ($x < 3) { plugin_servcheck_debug('Service Check Number ' . $x, $test); @@ -215,7 +217,7 @@ $last_log = db_fetch_row_prepared('SELECT * FROM plugin_servcheck_log WHERE test_id = ? ORDER BY id DESC LIMIT 1', - array ($test['id'])); + [$test['id']]); if (!$last_log) { $last_log['result'] = 'not yet'; @@ -266,7 +268,7 @@ $new_notify = db_fetch_cell_prepared('SELECT UNIX_TIMESTAMP(DATE_ADD(last_exp_notify, INTERVAL 1 DAY)) FROM plugin_servcheck_test WHERE id = ?', - array($test['id'])); + [$test['id']]); if ($new_notify < time()) { plugin_servcheck_debug('Certificate expired soon, will notify about expiration', $test); @@ -301,7 +303,7 @@ putenv('SERVCHECK_CERTIFICATE_EXPIRATION=' . (isset($test['expiry_date']) ? $test['expiry_date'] : 'Not tested')); if (file_exists($command) && is_executable($command)) { - $output = array(); + $output = []; $return = 0; exec($command, $output, $return); @@ -429,7 +431,7 @@ function plugin_servcheck_send_notification($results, $test, $type, $last_log) { $emails = db_fetch_cell_prepared('SELECT emails FROM plugin_notification_lists WHERE id = ?', - array($test['notify_list'])); + [$test['notify_list']]); if ($emails != '') { $to .= ($to != '' ? ', ':'') . $emails; diff --git a/servcheck_proxies.php b/servcheck_proxies.php index 98d33dd..226b9ff 100644 --- a/servcheck_proxies.php +++ b/servcheck_proxies.php @@ -1,4 +1,6 @@ $val) { @@ -85,7 +87,7 @@ function proxy_form_actions() { input_validate_input_number($matches[1]); /* ==================================================== */ - $proxy_list .= '
  • ' . db_fetch_cell_prepared('SELECT name FROM plugin_servcheck_proxies WHERE id = ?', array($matches[1])) . '
  • '; + $proxy_list .= '
  • ' . db_fetch_cell_prepared('SELECT name FROM plugin_servcheck_proxies WHERE id = ?', [$matches[1]]) . '
  • '; $proxy_array[] = $matches[1]; } } @@ -179,8 +181,8 @@ function proxy_edit() { draw_edit_form( array( - 'config' => array('no_form_tag' => true), - 'fields' => inject_form_variables($servcheck_proxy_fields, (isset($proxy) ? $proxy : array())) + 'config' => ['no_form_tag' => true], + 'fields' => inject_form_variables($servcheck_proxy_fields, (isset($proxy) ? $proxy : [])) ) ); @@ -202,29 +204,29 @@ function proxy_edit() { function request_validation() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), - 'refresh' => array( + ], + 'refresh' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '20', - ), + ], 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -252,7 +254,7 @@ function proxies() { $sql_where = ''; if (get_request_var('filter') != '') { - $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . ' name LIKE "%' . get_request_var('filter') . '%" OR hostname LIKE "%' . get_request_var('filter') . '%"'; + $sql_where .= ($sql_where == '' ? 'WHERE ' : ' AND ') . '(name LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ' OR hostname LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ')'; } $sql_order = get_order_string(); @@ -404,4 +406,3 @@ function clearFilter() { 0) { - db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "on" WHERE id = ?', array($id)); + db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "on" WHERE id = ?', [$id]); } header('Location: servcheck_test.php?header=false'); @@ -55,7 +57,7 @@ $id = get_filter_request_var('id'); if ($id > 0) { - db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "" WHERE id = ?', array($id)); + db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "" WHERE id = ?', [$id]); } header('Location: servcheck_test.php?header=false'); @@ -118,23 +120,23 @@ function form_actions() { if (cacti_sizeof($tests)) { if ($action == SERVCHECK_ACTION_TEST_DELETE) { // delete foreach ($tests as $id) { - db_execute_prepared('DELETE FROM plugin_servcheck_test WHERE id = ?', array($id)); - db_execute_prepared('DELETE FROM plugin_servcheck_log WHERE test_id = ?', array($id)); + db_execute_prepared('DELETE FROM plugin_servcheck_test WHERE id = ?', [$id]); + db_execute_prepared('DELETE FROM plugin_servcheck_log WHERE test_id = ?', [$id]); } } elseif ($action == SERVCHECK_ACTION_TEST_DISABLE) { // disable foreach ($tests as $id) { - db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "" WHERE id = ?', array($id)); + db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "" WHERE id = ?', [$id]); } } elseif ($action == SERVCHECK_ACTION_TEST_ENABLE) { // enable foreach ($tests as $id) { - db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "on" WHERE id = ?', array($id)); + db_execute_prepared('UPDATE plugin_servcheck_test SET enabled = "on" WHERE id = ?', [$id]); } } elseif ($action == SERVCHECK_ACTION_TEST_DUPLICATE) { // duplicate foreach($tests as $test) { $newid = 1; foreach ($tests as $id) { - $save = db_fetch_row_prepared('SELECT * FROM plugin_servcheck_test WHERE id = ?', array($id)); + $save = db_fetch_row_prepared('SELECT * FROM plugin_servcheck_test WHERE id = ?', [$id]); $save['id'] = 0; $save['display_name'] = 'New Service Check (' . $newid . ')'; $save['path'] = '/'; @@ -163,7 +165,7 @@ function form_actions() { /* setup some variables */ $test_list = ''; - $test_array = array(); + $test_array = []; /* loop through each of the tests selected on the previous page and get more info about them */ foreach ($_POST as $var => $val) { @@ -172,7 +174,7 @@ function form_actions() { input_validate_input_number($matches[1]); /* ==================================================== */ - $test_list .= '
  • ' . __esc(db_fetch_cell_prepared('SELECT display_name FROM plugin_servcheck_test WHERE id = ?', array($matches[1]))) . '
  • '; + $test_list .= '
  • ' . __esc(db_fetch_cell_prepared('SELECT display_name FROM plugin_servcheck_test WHERE id = ?', [$matches[1]])) . '
  • '; $test_array[] = $matches[1]; } } @@ -322,7 +324,7 @@ function form_save() { } if ($category == 'ldap') { - if (get_filter_request_var('ldapsearch', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-zA-Z0-9\.\- \*\=,]+$/')))) { + if (get_filter_request_var('ldapsearch', FILTER_VALIDATE_REGEXP, array('options' => ['regexp' => '/^[a-zA-Z0-9\.\- \*\=,]+$/']))) { $save['ldapsearch'] = get_nfilter_request_var('ldapsearch'); } else { raise_message(3); @@ -362,13 +364,13 @@ function form_save() { $save['certexpirenotify'] = ''; } - if (isset_request_var('username') && get_nfilter_request_var('username') != '' && get_filter_request_var('username', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-z0-9A-Z_\/@.\- \=,]{1,}$/')))) { + if (isset_request_var('username') && get_nfilter_request_var('username') != '' && get_filter_request_var('username', FILTER_VALIDATE_REGEXP, array('options' => ['regexp' => '/^[a-z0-9A-Z_\/@.\- \=,]{1,}$/']))) { $save['username'] = servcheck_hide_text(get_nfilter_request_var('username')); $save['password'] = servcheck_hide_text(get_nfilter_request_var('password')); } if ($category == 'web' || $category == 'ftp' || $category == 'smb') { - if (isset_request_var('path') && get_filter_request_var('path', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-zA-Z0-9_;\-\/\.\?=]+$/')))) { + if (isset_request_var('path') && get_filter_request_var('path', FILTER_VALIDATE_REGEXP, array('options' => ['regexp' => '/^[a-zA-Z0-9_;\-\/\.\?=]+$/']))) { $save['path'] = get_nfilter_request_var('path'); } else { raise_message(3); @@ -412,9 +414,9 @@ function purge_log_events($id) { $name = db_fetch_cell_prepared('SELECT display_name FROM plugin_servcheck_test WHERE id = ?', - array($id)); + [$id]); - db_execute_prepared('DELETE FROM plugin_servcheck_log WHERE test_id = ?', array($id)); + db_execute_prepared('DELETE FROM plugin_servcheck_log WHERE test_id = ?', [$id]); raise_message('test_log_purged', __('The Service Check history was purged for %s', $name, 'servcheck'), MESSAGE_LEVEL_INFO); } @@ -427,7 +429,7 @@ function servcheck_edit_test() { get_filter_request_var('id'); /* ==================================================== */ - $test = array(); + $test = []; if (!isempty_request_var('id')) { $test = db_fetch_row_prepared('SELECT * FROM plugin_servcheck_test WHERE id = ?', array(get_request_var('id')), false); @@ -453,7 +455,7 @@ function servcheck_edit_test() { draw_edit_form( array( - 'config' => array('form_name' => 'chk'), + 'config' => ['form_name' => 'chk'], 'fields' => inject_form_variables($servcheck_test_fields, $test) ) ); @@ -686,15 +688,15 @@ function setTest() { function servcheck_request_validation() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), + ], 'refresh' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, @@ -704,23 +706,23 @@ function servcheck_request_validation() { 'filter' => FILTER_VALIDATE_IS_REGEX, 'default' => '', 'pageset' => true, - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'display_name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), - 'state' => array( + 'state' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ) + ] ); validate_store_request_vars($filters, 'sess_servchecktest'); @@ -732,33 +734,33 @@ function servcheck_log_request_validation() { /* ================= input validation and session storage ================= */ $filters = array( - 'id' => array( + 'id' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '-1' - ), - 'rows' => array( + ], + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'page' => array( + ], + 'page' => [ 'filter' => FILTER_VALIDATE_INT, 'default' => '1' - ), + ], 'filter' => array( 'filter' => FILTER_CALLBACK, 'default' => '', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'lastcheck', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'DESC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), ); @@ -926,7 +928,7 @@ function servcheck_show_graph() { $result = db_fetch_row_prepared('SELECT display_name FROM plugin_servcheck_test WHERE id = ?', - array($id)); + [$id]); print '

    ' . html_escape($result['display_name']) . ':
    '; @@ -952,7 +954,7 @@ function servcheck_show_last_data() { $result = db_fetch_row_prepared('SELECT display_name, last_returned_data FROM plugin_servcheck_test WHERE id = ?', - array($id)); + [$id]); print '

    ' . __('Last returned data of test', 'servcheck') . ' ' . html_escape($result['display_name']) . ':
    '; @@ -964,16 +966,16 @@ function list_tests() { /* ================= input validation and session storage ================= */ $filters = array( - 'rows' => array( + 'rows' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), - 'state' => array( + ], + 'state' => [ 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' - ), + ], 'refresh' => array( 'filter' => FILTER_VALIDATE_INT, 'default' => read_config_option('log_refresh_interval') @@ -981,12 +983,12 @@ function list_tests() { 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'display_name', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', - 'options' => array('options' => 'sanitize_search_string') + 'options' => ['options' => 'sanitize_search_string'] ) ); @@ -1114,7 +1116,7 @@ function list_tests() { (SELECT count(id) FROM plugin_servcheck_log WHERE test_id = ? ) as `count` FROM plugin_servcheck_log WHERE test_id = ? ORDER BY id DESC LIMIT 1", - array ($row['id'], $row['id'])); + [$row['id'], $row['id']]); if (!$last_log) { $last_log['result'] = 'not yet'; @@ -1297,7 +1299,7 @@ function clearFilter() {