';
@@ -602,24 +592,24 @@ function graph_host_detail() {
return $panel;
}
-//------------------------------------ graph host_template -----------------------------------------------------
+// ------------------------------------ graph host_template -----------------------------------------------------
function graph_host_template_detail() {
global $config;
- $panel = array(
- 'name' => __('Device Templates', 'intropage'),
- 'alarm' => 'green',
+ $panel = [
+ 'name' => __('Device Templates', 'intropage'),
+ 'alarm' => 'green',
'detail' => '',
- );
+ ];
$simple_perms = get_simple_device_perms($_SESSION['sess_user_id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -639,22 +629,23 @@ function graph_host_template_detail() {
if (cacti_sizeof($rows)) {
$panel['detail'] .= '
';
$i = 0;
+
foreach ($rows as $item) {
- $class = ($i % 2 == 0 ? 'odd':'even');
+ $class = ($i % 2 == 0 ? 'odd' : 'even');
$panel['detail'] .= '| ' . html_escape($item['name']) . ' | ';
- $panel['detail'] .= '' . number_format_i18n($item['total'], -1) . ' | ';
+ $panel['detail'] .= '' . number_format_i18n($item['total'], -1) . ' | ';
$total += $item['total'];
$i++;
}
- $class = ($i % 2 == 0 ? 'odd':'even');
+ $class = ($i % 2 == 0 ? 'odd' : 'even');
$panel['detail'] .= '
- | ' . __('Total', 'intropage') . ' |
+ ' . __('Total', 'intropage') . ' |
' . number_format_i18n($total, -1) . ' |
';
@@ -666,8 +657,7 @@ function graph_host_template_detail() {
return $panel;
}
-
-//------------------------------------ host collect -----------------------------------------------------
+// ------------------------------------ host collect -----------------------------------------------------
function host_collect() {
global $config;
@@ -675,15 +665,14 @@ function host_collect() {
$users = get_user_list();
foreach ($users as $user) {
-
$simple_perms = get_simple_device_perms($user['id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user['id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -691,7 +680,6 @@ function host_collect() {
}
if ($allowed_devices !== false || $simple_perms) {
-
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
SELECT 'host_down', COUNT(*),?
@@ -699,7 +687,7 @@ function host_collect() {
WHERE status='1'
$q_host_cond
AND disabled=''",
- array($user['id']));
+ [$user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
@@ -708,7 +696,7 @@ function host_collect() {
WHERE status='2'
$q_host_cond
AND disabled=''",
- array($user['id']));
+ [$user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
@@ -716,22 +704,22 @@ function host_collect() {
FROM host
WHERE disabled='on'
$q_host_cond",
- array($user['id']));
+ [$user['id']]);
} else {
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('host_down', 0, ?)",
- array($user['id']));
+ [$user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('host_reco', 0, ?)",
- array($user['id']));
+ [$user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('host_disa', 0, ?)",
- array($user['id']));
+ [$user['id']]);
}
}
}
diff --git a/panellib/index.php b/panellib/index.php
index 4f8fcac..4298bd5 100644
--- a/panellib/index.php
+++ b/panellib/index.php
@@ -23,4 +23,3 @@
*/
header('Location:../index.php');
-
diff --git a/panellib/mactrack.php b/panellib/mactrack.php
index 47a52b1..8e3369e 100644
--- a/panellib/mactrack.php
+++ b/panellib/mactrack.php
@@ -27,13 +27,13 @@
function register_mactrack() {
global $registry;
- $registry['mactrack'] = array(
+ $registry['mactrack'] = [
'name' => __('MacTrack Panels', 'intropage'),
'description' => __('Panels that provide information about Cacti\'s MacTrack plugins.', 'intropage')
- );
+ ];
- $panels = array(
- 'mactrack' => array(
+ $panels = [
+ 'mactrack' => [
'name' => __('MacTrack Plugin', 'intropage'),
'description' => __('Various MacTrack collection and site statistics.', 'intropage'),
'class' => 'mactrack',
@@ -50,8 +50,8 @@ function register_mactrack() {
'update_func' => 'mactrack',
'details_func' => false,
'trends_func' => false
- ),
- 'mactrack_sites' => array(
+ ],
+ 'mactrack_sites' => [
'name' => __('MacTrack Sites', 'intropage'),
'description' => __('Various MacTrack Site statistics.', 'intropage'),
'class' => 'mactrack',
@@ -68,13 +68,13 @@ function register_mactrack() {
'update_func' => 'mactrack_sites',
'details_func' => 'mactrack_sites_detail',
'trends_func' => false
- ),
- );
+ ],
+ ];
return $panels;
}
-//------------------------------------ mactrack -----------------------------------------------------
+// ------------------------------------ mactrack -----------------------------------------------------
function mactrack($panel, $user_id) {
global $config;
@@ -98,24 +98,24 @@ function mactrack($panel, $user_id) {
$panel['alarm'] = 'yellow';
}
- $panel['data'] = __('All: %s', $m_all, 'intropage') . ' | ';
- $panel['data'] .= __('Up: %s', $m_up, 'intropage') . ' | ';
- $panel['data'] .= __('Down: %s', $m_down, 'intropage') . ' | ';
- $panel['data'] .= __('Error: %s', $m_err, 'intropage') . ' | ';
- $panel['data'] .= __('Unknown: %s', $m_unkn, 'intropage') . ' | ';
+ $panel['data'] = __('All: %s', $m_all, 'intropage') . ' | ';
+ $panel['data'] .= __('Up: %s', $m_up, 'intropage') . ' | ';
+ $panel['data'] .= __('Down: %s', $m_down, 'intropage') . ' | ';
+ $panel['data'] .= __('Error: %s', $m_err, 'intropage') . ' | ';
+ $panel['data'] .= __('Unknown: %s', $m_unkn, 'intropage') . ' | ';
$panel['data'] .= __('Disabled: %s', $m_disa, 'intropage') . ' | ';
- $graph = array ('pie' => array(
+ $graph = ['pie' => [
'title' => __('MacTrack', 'intropage'),
- 'label' => array(
+ 'label' => [
__('Up', 'intropage'),
__('Down', 'intropage'),
__('Error', 'intropage'),
__('Unknown', 'intropage'),
__('Disabled', 'intropage'),
- ),
- 'data' => array($m_up, $m_down, $m_err, $m_unkn, $m_disa))
- );
+ ],
+ 'data' => [$m_up, $m_down, $m_err, $m_unkn, $m_disa]]
+ ];
$panel['data'] = intropage_prepare_graph($graph, $user_id);
} else {
@@ -125,7 +125,7 @@ function mactrack($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ mactrack sites -----------------------------------------------------
+// ------------------------------------ mactrack sites -----------------------------------------------------
function mactrack_sites($panel, $user_id) {
global $config;
@@ -139,12 +139,12 @@ function mactrack_sites($panel, $user_id) {
} elseif (api_plugin_user_realm_auth('mactrack_view_sites.php') || api_plugin_user_realm_auth('mactrack_devices.php')) {
$panel['data'] = '' .
'';
@@ -157,13 +157,13 @@ function mactrack_sites($panel, $user_id) {
if (cacti_sizeof($data)) {
foreach ($data as $site) {
$row = '' .
- '| ' . html_escape($site['site_name']) . ' | ' .
- '' . $site['total_devices'] . ' | ' .
- '' . $site['total_ips'] . ' | ' .
- '' . $site['total_user_ports'] . ' | ' .
- '' . $site['total_oper_ports'] . ' | ' .
- '' . $site['total_macs'] . ' | ' .
- '' . $site['total_device_errors'] . ' | ' .
+ '' . html_escape($site['site_name']) . ' | ' .
+ '' . $site['total_devices'] . ' | ' .
+ '' . $site['total_ips'] . ' | ' .
+ '' . $site['total_user_ports'] . ' | ' .
+ '' . $site['total_oper_ports'] . ' | ' .
+ '' . $site['total_macs'] . ' | ' .
+ '' . $site['total_device_errors'] . ' | ' .
' ';
$panel['data'] .= $row;
@@ -180,24 +180,24 @@ function mactrack_sites($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ mactrack sites -----------------------------------------------------
+// ------------------------------------ mactrack sites -----------------------------------------------------
function mactrack_sites_detail() {
global $config, $console_access;
- $panel = array(
+ $panel = [
'name' => __('MacTrack Sites', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
$panel['detail'] = '' .
'';
@@ -208,13 +208,13 @@ function mactrack_sites_detail() {
if (cacti_sizeof($data)) {
foreach ($data as $site) {
$row = '' .
- '| ' . html_escape($site['site_name']) . ' | ' .
- '' . $site['total_devices'] . ' | ' .
- '' . $site['total_ips'] . ' | ' .
- '' . $site['total_user_ports'] . ' | ' .
- '' . $site['total_oper_ports'] . ' | ' .
- '' . $site['total_macs'] . ' | ' .
- '' . $site['total_device_errors'] . ' | ' .
+ '' . html_escape($site['site_name']) . ' | ' .
+ '' . $site['total_devices'] . ' | ' .
+ '' . $site['total_ips'] . ' | ' .
+ '' . $site['total_user_ports'] . ' | ' .
+ '' . $site['total_oper_ports'] . ' | ' .
+ '' . $site['total_macs'] . ' | ' .
+ '' . $site['total_device_errors'] . ' | ' .
' ';
if ($site['total_device_errors'] > 0) {
@@ -226,7 +226,7 @@ function mactrack_sites_detail() {
$panel['detail'] .= ' ';
} else {
- $panel['detail'] = __('No mactrack sites found', 'intropage');
+ $panel['detail'] = __('No mactrack sites found', 'intropage');
}
return $panel;
diff --git a/panellib/misc.php b/panellib/misc.php
index 64f7ba5..2e337af 100644
--- a/panellib/misc.php
+++ b/panellib/misc.php
@@ -27,13 +27,13 @@
function register_misc() {
global $registry;
- $registry['misc'] = array(
+ $registry['misc'] = [
'name' => __('Miscellaneous Panels', 'intropage'),
'description' => __('Panels that general non-categorized data about Cacti\'s.', 'intropage')
- );
+ ];
- $panels = array(
- 'ntp_dns' => array(
+ $panels = [
+ 'ntp_dns' => [
'name' => __('NTP/DNS Status', 'intropage'),
'description' => __('Checking your Cacti system clock for drift from a known baseline and DNS resolving check', 'intropage'),
'class' => 'misc',
@@ -50,8 +50,8 @@ function register_misc() {
'update_func' => 'ntp_dns',
'details_func' => false,
'trends_func' => false
- ),
- 'maint' => array(
+ ],
+ 'maint' => [
'name' => __('Maint Plugin Details', 'intropage'),
'description' => __('Maint Plugin details on upcoming schedules', 'intropage'),
'class' => 'misc',
@@ -68,8 +68,8 @@ function register_misc() {
'update_func' => 'maint',
'details_func' => false,
'trends_func' => false
- ),
- 'webseer' => array(
+ ],
+ 'webseer' => [
'name' => __('Webseer Details', 'intropage'),
'description' => __('Plugin webseer URL Service Check Details', 'intropage'),
'class' => 'misc',
@@ -86,8 +86,8 @@ function register_misc() {
'update_func' => 'webseer',
'details_func' => 'webseer_detail',
'trends_func' => false
- ),
- 'servcheck' => array(
+ ],
+ 'servcheck' => [
'name' => __('Servcheck plugin Details', 'intropage'),
'description' => __('Plugin ServCheck Details', 'intropage'),
'class' => 'misc',
@@ -104,8 +104,8 @@ function register_misc() {
'update_func' => 'servcheck',
'details_func' => 'servcheck_detail',
'trends_func' => false
- ),
- );
+ ],
+ ];
return $panels;
}
@@ -122,15 +122,16 @@ function ntp_dns($panel, $user_id) {
if (empty($ntp_server)) {
$panel['alarm'] = 'grey';
- $panel['data'] .= '| ' . __('No NTP server configured', 'intropage') . ' | ';
+ $panel['data'] .= '| ' . __('No NTP server configured', 'intropage') . ' | ';
} elseif (!filter_var(trim($ntp_server), FILTER_VALIDATE_IP) && !filter_var(trim($ntp_server), FILTER_VALIDATE_DOMAIN)) {
$panel['alarm'] = 'red';
- $panel['data'] .= '' . __('Wrong NTP server configured - %s Please fix it in settings', $ntp_server, 'intropage') . ' | ';
+ $panel['data'] .= '' . __('Wrong NTP server configured - %s Please fix it in settings', $ntp_server, 'intropage') . ' | ';
} else {
$i = 0;
while (true) {
$timestamp = ntp_time($ntp_server);
+
if (is_numeric($timestamp)) {
break;
} else {
@@ -139,6 +140,7 @@ function ntp_dns($panel, $user_id) {
if ($i > 2) {
$timestamp = 'error';
+
break;
}
}
@@ -165,36 +167,36 @@ function ntp_dns($panel, $user_id) {
}
} else {
$panel['alarm'] = 'red';
- $panel['data'] .= '| ' . __('Unable to contact the NTP server indicated.', 'intropage') . ' | ';
- $panel['data'] .= '| ' . 'Server: ' . $ntp_server . ' | ';
+ $panel['data'] .= '| ' . __('Unable to contact the NTP server indicated.', 'intropage') . ' | ';
+ $panel['data'] .= '| ' . 'Server: ' . $ntp_server . ' | ';
- $panel['data'] .= '| ' . 'Timestamp: ' . $timestamp . ' | ';
- $panel['data'] .= '| ' . __('Please check your configuration.', 'intropage') . ' | ';
+ $panel['data'] .= '| ' . 'Timestamp: ' . $timestamp . ' | ';
+ $panel['data'] .= '| ' . __('Please check your configuration.', 'intropage') . ' | ';
}
}
- $panel['data'] .= '
| ';
+ $panel['data'] .= '
| ';
if (empty($dns_host)) {
$panel['alarm'] = 'grey';
- $panel['data'] .= '| ' . __('No DNS hostname configured', 'intropage') . ' | ';
+ $panel['data'] .= '| ' . __('No DNS hostname configured', 'intropage') . ' | ';
} elseif (!filter_var(trim($dns_host), FILTER_VALIDATE_DOMAIN)) {
$panel['alarm'] = 'red';
- $panel['data'] .= '' . __('Wrong DNS hostname configured - %s Please fix it in settings', $dns_host, 'intropage') . ' | ';
+ $panel['data'] .= '' . __('Wrong DNS hostname configured - %s Please fix it in settings', $dns_host, 'intropage') . ' | ';
} else {
$start = microtime(true);
$dns_response = cacti_gethostinfo($dns_host, DNS_A | DNS_CNAME | DNS_AAAA);
- $total_time = 1000*(microtime(true) - $start);
+ $total_time = 1000 * (microtime(true) - $start);
if ($dns_response) {
$panel['data'] .= '| ' . __('DNS hostname (%s) resolving ok.', $dns_host, 'intropage') . ' | ';
$panel['data'] .= '| ' . __('DNS resolv time: %s ms', round($total_time,2), 'intropage') . ' | ';
} else {
$panel['alarm'] = 'red';
- $panel['data'] .= '| ' . __('DNS hostname (%s) resolving failed.', $dns_host, 'intropage') . ' | ';
- $panel['data'] .= '| ' . __('Please check your configuration.', 'intropage') . ' | ';
+ $panel['data'] .= '| ' . __('DNS hostname (%s) resolving failed.', $dns_host, 'intropage') . ' | ';
+ $panel['data'] .= '| ' . __('Please check your configuration.', 'intropage') . ' | ';
}
}
@@ -203,25 +205,24 @@ function ntp_dns($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//---------------------------maint plugin--------------------
+// ---------------------------maint plugin--------------------
function maint($panel, $user_id) {
global $config;
$panel['alarm'] = 'green';
- $panel['data'] = '';
+ $panel['data'] = '';
$maint_days_before = read_config_option('intropage_maint_plugin_days_before');
if (api_plugin_is_enabled('maint') && $maint_days_before >= 0) {
-
$simple_perms = get_simple_device_perms($user_id);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -238,67 +239,66 @@ function maint($panel, $user_id) {
$t = time();
switch ($sc['mtype']) {
- case 1:
- if ($t > ($sc['stime'] - $maint_days_before) && $t < $sc['etime']) {
- $hosts = db_fetch_assoc_prepared("SELECT description FROM host
+ case 1:
+ if ($t > ($sc['stime'] - $maint_days_before) && $t < $sc['etime']) {
+ $hosts = db_fetch_assoc_prepared("SELECT description FROM host
INNER JOIN plugin_maint_hosts
ON host.id=plugin_maint_hosts.host
WHERE schedule = ?
$q_host_cond",
- array($sc['id']));
-
- if (cacti_sizeof($hosts)) {
- $panel['data'] .= '' . date('d. m . Y H:i', $sc['stime']) .
- ' - ' . date('d. m . Y H:i', $sc['etime']) .
- ' - ' . $sc['name'] . ' (One time) ';
+ [$sc['id']]);
- $text = 'Affected hosts: ' . implode (', ', array_column($hosts,'description'));
+ if (cacti_sizeof($hosts)) {
+ $panel['data'] .= '' . date('d. m . Y H:i', $sc['stime']) .
+ ' - ' . date('d. m . Y H:i', $sc['etime']) .
+ ' - ' . $sc['name'] . ' (One time) ';
- $panel['data'] .= '' . $text . '
';
+ $text = 'Affected hosts: ' . implode(', ', array_column($hosts,'description'));
- }
- }
-
- break;
- case 2:
- /* past, calculate next */
- if ($sc['etime'] < $t) {
- /* convert start and end to local so that hour stays same for add days across daylight saving time change */
- $starttimelocal = (new DateTime('@' . strval($sc['stime'])))->setTimezone( new DateTimeZone( date_default_timezone_get()));
- $endtimelocal = (new DateTime('@' . strval($sc['etime'])))->setTimezone( new DateTimeZone( date_default_timezone_get()));
- $nowtime = new DateTime();
- /* add interval days */
- $addday = new DateInterval( 'P' . strval($sc['minterval'] / 86400) . 'D');
- while ($endtimelocal < $nowtime) {
- $starttimelocal = $starttimelocal->add( $addday );
- $endtimelocal = $endtimelocal->add( $addday );
+ $panel['data'] .= '' . $text . '
';
+ }
}
- $sc['stime'] = $starttimelocal->getTimestamp();
- $sc['etime'] = $endtimelocal->getTimestamp();
- }
+ break;
+ case 2:
+ // past, calculate next
+ if ($sc['etime'] < $t) {
+ // convert start and end to local so that hour stays same for add days across daylight saving time change
+ $starttimelocal = (new DateTime('@' . strval($sc['stime'])))->setTimezone(new DateTimeZone(date_default_timezone_get()));
+ $endtimelocal = (new DateTime('@' . strval($sc['etime'])))->setTimezone(new DateTimeZone(date_default_timezone_get()));
+ $nowtime = new DateTime();
+ // add interval days
+ $addday = new DateInterval('P' . strval($sc['minterval'] / 86400) . 'D');
+
+ while ($endtimelocal < $nowtime) {
+ $starttimelocal = $starttimelocal->add($addday);
+ $endtimelocal = $endtimelocal->add($addday);
+ }
+
+ $sc['stime'] = $starttimelocal->getTimestamp();
+ $sc['etime'] = $endtimelocal->getTimestamp();
+ }
- if ($t > ($sc['stime'] - $maint_days_before) && $t < $sc['etime']) {
- $hosts = db_fetch_assoc_prepared("SELECT description FROM host
+ if ($t > ($sc['stime'] - $maint_days_before) && $t < $sc['etime']) {
+ $hosts = db_fetch_assoc_prepared("SELECT description FROM host
INNER JOIN plugin_maint_hosts
ON host.id=plugin_maint_hosts.host
WHERE schedule = ?
$q_host_cond",
- array($sc['id']));
+ [$sc['id']]);
- if (cacti_sizeof($hosts)) {
- $panel['data'] .= '' . date('d. m . Y H:i', $sc['stime']) .
- ' - ' . date('d. m . Y H:i', $sc['etime']) .
- ' - ' . $sc['name'] . ' (Reoccurring) ';
+ if (cacti_sizeof($hosts)) {
+ $panel['data'] .= '' . date('d. m . Y H:i', $sc['stime']) .
+ ' - ' . date('d. m . Y H:i', $sc['etime']) .
+ ' - ' . $sc['name'] . ' (Reoccurring) ';
- $text = 'Affected hosts: ' . implode (', ', array_column($hosts,'description'));
+ $text = 'Affected hosts: ' . implode(', ', array_column($hosts,'description'));
- $panel['data'] .= '' . $text . '
';
+ $panel['data'] .= '' . $text . '
';
+ }
}
- }
-
- break;
+ break;
}
}
}
@@ -316,8 +316,9 @@ function webseer($panel, $user_id) {
$panel['alarm'] = 'green';
- $lines = get_panel_lines_count($panel['height'], $user_id);
+ $lines = get_panel_lines_count($panel['height'], $user_id);
$important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $user_id);
+
if ($important_period == -1) {
$important_period = time();
}
@@ -325,7 +326,7 @@ function webseer($panel, $user_id) {
if (!api_plugin_is_enabled('webseer')) {
$panel['alarm'] = 'yellow';
$panel['data'] = __('Plugin Webseer isn\'t installed or started', 'intropage');
- $panel['detail'] = FALSE;
+ $panel['detail'] = false;
} else {
$all = db_fetch_cell('SELECT COUNT(*) FROM plugin_webseer_urls');
$disa = db_fetch_cell("SELECT COUNT(*) FROM plugin_webseer_urls WHERE enabled != 'on'");
@@ -340,7 +341,7 @@ function webseer($panel, $user_id) {
$panel['data'] .= __('Number of checks (all/disabled): ', 'intropage') . $all . ' / ' . $disa . ' ';
$panel['data'] .= __('Status (up/down): ', 'intropage') . $ok . ' / ' . $ko . '
';
- $logs = db_fetch_assoc ('SELECT pwul.lastcheck, pwul.result, pwul.http_code, pwul.error, pwu.url,
+ $logs = db_fetch_assoc('SELECT pwul.lastcheck, pwul.result, pwul.http_code, pwul.error, pwu.url,
UNIX_TIMESTAMP(pwul.lastcheck) AS secs
FROM plugin_webseer_urls_log AS pwul
INNER JOIN plugin_webseer_urls AS pwu
@@ -350,7 +351,6 @@ function webseer($panel, $user_id) {
LIMIT ' . ($lines - 4));
if (cacti_sizeof($logs) > 0) {
-
$panel['data'] .= '';
$panel['data'] .= '| ' . __('Last log messages', 'intropage') . ' | ';
$panel['data'] .= '| ' . __('Date', 'intropage') . ' | ' .
@@ -359,15 +359,15 @@ function webseer($panel, $user_id) {
foreach ($logs as $row) {
$color = 'grey';
- $text = '';
+ $text = '';
if ($row['http_code'] == 200) {
- if ($row['secs'] > (time()-($important_period))) {
+ if ($row['secs'] > (time() - ($important_period))) {
$color = 'green';
}
$text = __('OK');
} else {
- if ($row['secs'] > (time()-($important_period))) {
+ if ($row['secs'] > (time() - ($important_period))) {
$color = 'red';
}
$text = __('Failed');
@@ -397,22 +397,23 @@ function webseer($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ webseer_plugin -----------------------------------------------------
+// ------------------------------------ webseer_plugin -----------------------------------------------------
function webseer_detail() {
global $config, $log;
- $important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $_SESSION['sess_user_id']);
- if ($important_period == -1) {
- $important_period = time();
- }
+ $important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $_SESSION['sess_user_id']);
- $panel = array(
+ if ($important_period == -1) {
+ $important_period = time();
+ }
+
+ $panel = [
'name' => __('Webseer Plugin - Details', 'intropage'),
'alarm' => 'grey',
'detail' => '',
- );
+ ];
- $logs = db_fetch_assoc ('SELECT pwul.lastcheck, pwul.result, pwul.http_code, pwul.error, pwu.url,
+ $logs = db_fetch_assoc('SELECT pwul.lastcheck, pwul.result, pwul.http_code, pwul.error, pwu.url,
UNIX_TIMESTAMP(pwul.lastcheck) AS secs
FROM plugin_webseer_urls_log AS pwul
INNER JOIN plugin_webseer_urls AS pwu
@@ -424,14 +425,14 @@ function webseer_detail() {
$panel['detail'] = '';
- foreach ($logs as $log) {
+ foreach ($logs as $log) {
$color = 'grey';
$panel['detail'] .= '';
@@ -439,12 +440,12 @@ function webseer_detail() {
$panel['detail'] .= '| ' . $log['url'] . ' | ';
if ($log['result'] == 1) {
- if ($log['secs'] > (time()-($important_period))) {
+ if ($log['secs'] > (time() - ($important_period))) {
$color = 'green';
}
$panel['detail'] .= '' . __('OK') . ' | ';
} else {
- if ($log['secs'] > (time()-($important_period))) {
+ if ($log['secs'] > (time() - ($important_period))) {
$color = 'red';
}
$panel['detail'] .= '' . __('Failed') . ' | ';
@@ -453,7 +454,7 @@ function webseer_detail() {
$panel['detail'] .= '' . $log['http_code'] . ' | ';
$panel['detail'] .= '' . $log['error'] . ' | ';
- if ($color == 'red') {
+ if ($color == 'red') {
$panel['alarm'] = 'red';
}
}
@@ -463,7 +464,6 @@ function webseer_detail() {
return $panel;
}
-
// -------------------------------------plugin servcheck-------------------------------------------
function servcheck($panel, $user_id) {
global $config;
@@ -473,6 +473,7 @@ function servcheck($panel, $user_id) {
$lines = get_panel_lines_count($panel['height'], $user_id);
$important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $user_id);
+
if ($important_period == -1) {
$important_period = time();
}
@@ -480,9 +481,10 @@ function servcheck($panel, $user_id) {
if (!api_plugin_is_enabled('servcheck')) {
$panel['alarm'] = 'yellow';
$panel['data'] = __('Plugin Servcheck isn\'t installed or started', 'intropage');
- $panel['detail'] = FALSE;
+ $panel['detail'] = false;
} else {
- $ok = 0; $ko = 0;
+ $ok = 0;
+ $ko = 0;
$all = db_fetch_cell('SELECT COUNT(*) FROM plugin_servcheck_test');
$disa = db_fetch_cell("SELECT COUNT(*) FROM plugin_servcheck_test WHERE enabled != 'on'");
@@ -498,8 +500,8 @@ function servcheck($panel, $user_id) {
foreach ($tests as $test) {
$state = db_fetch_cell_prepared('SELECT result FROM plugin_servcheck_log
WHERE test_id = ? ORDER BY lastcheck DESC LIMIT 1',
- array($test['id']));
-
+ [$test['id']]);
+
if ($state == 'ok') {
$ok++;
} else {
@@ -514,7 +516,7 @@ function servcheck($panel, $user_id) {
$panel['data'] .= __('Number of checks (all/disabled): ', 'intropage') . $all . ' / ' . $disa . ' ';
$panel['data'] .= __('Status (ok/error): ', 'intropage') . $ok . ' / ' . $ko . '
';
- $logs = db_fetch_assoc ('SELECT psl.lastcheck as `lastcheck`, result, error, '. $dncolumn . ' as name, type,
+ $logs = db_fetch_assoc('SELECT psl.lastcheck as `lastcheck`, result, error, ' . $dncolumn . ' as name, type,
UNIX_TIMESTAMP(psl.lastcheck) AS secs
FROM plugin_servcheck_log AS psl
LEFT JOIN plugin_servcheck_test AS pst
@@ -522,7 +524,6 @@ function servcheck($panel, $user_id) {
LIMIT ' . ($lines - 4));
if (cacti_sizeof($logs) > 0) {
-
$panel['data'] .= '';
$panel['data'] .= '| ' . __('Last log records', 'intropage') . ' | ';
$panel['data'] .= '| ' . __('Date', 'intropage') . ' | ' .
@@ -532,15 +533,15 @@ function servcheck($panel, $user_id) {
foreach ($logs as $row) {
$color = 'grey';
- $text = '';
+ $text = '';
if ($row['result'] == 'ok') {
- if ($row['secs'] > (time()-($important_period))) {
+ if ($row['secs'] > (time() - ($important_period))) {
$color = 'green';
}
$text = __('OK');
} else {
- if ($row['secs'] > (time()-($important_period))) {
+ if ($row['secs'] > (time() - ($important_period))) {
$color = 'red';
}
$text = __('Failed');
@@ -561,7 +562,7 @@ function servcheck($panel, $user_id) {
$panel['data'] .= '' . $row['lastcheck'] . ' | ' .
'' . $row['name'] . ' | ' .
'' . $row['type'] . ' | ' .
- '' . $row['result'] .' | ';
+ '' . $row['result'] . ' | ';
}
$panel['data'] .= ' ';
@@ -571,29 +572,31 @@ function servcheck($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ servcheck_plugin_detail-------------------------------------------------
+// ------------------------------------ servcheck_plugin_detail-------------------------------------------------
function servcheck_detail() {
global $config, $log;
- $important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $_SESSION['sess_user_id']);
- if ($important_period == -1) {
- $important_period = time();
- }
+ $important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $_SESSION['sess_user_id']);
- $panel = array(
+ if ($important_period == -1) {
+ $important_period = time();
+ }
+
+ $panel = [
'name' => __('Servcheck Plugin - Details', 'intropage'),
'alarm' => 'grey',
'detail' => '',
- );
+ ];
$dncolumn = db_fetch_cell("SELECT COLUMN_NAME FROM information_schema.columns
WHERE TABLE_NAME = 'plugin_servcheck_test' AND COLUMN_NAME = 'display_name'");
+
// servcheck < 0.3 uses another name
if (!$dncolumn) {
$dncolumn = 'name';
}
- $logs = db_fetch_assoc ('SELECT psl.lastcheck as `lastcheck`, result, error, ' . $dncolumn . ', type,
+ $logs = db_fetch_assoc('SELECT psl.lastcheck as `lastcheck`, result, error, ' . $dncolumn . ', type,
UNIX_TIMESTAMP(psl.lastcheck) AS secs
FROM plugin_servcheck_log AS psl
LEFT JOIN plugin_servcheck_test AS pst
@@ -604,14 +607,14 @@ function servcheck_detail() {
$panel['detail'] = '';
- foreach ($logs as $log) {
+ foreach ($logs as $log) {
$color = 'grey';
$panel['detail'] .= '';
@@ -620,13 +623,13 @@ function servcheck_detail() {
$panel['detail'] .= '| ' . $log['type'] . ' | ';
if ($log['result'] == 'ok') {
- if ($log['secs'] > (time()-($important_period))) {
+ if ($log['secs'] > (time() - ($important_period))) {
$color = 'green';
}
$panel['detail'] .= '' . __('OK') . ' | ';
} else {
- if ($log['secs'] > (time()-($important_period))) {
+ if ($log['secs'] > (time() - ($important_period))) {
$color = 'red';
}
$panel['detail'] .= '' . __('Failed') . ' | ';
@@ -635,7 +638,7 @@ function servcheck_detail() {
$panel['detail'] .= '' . $log['result'] . ' | ';
$panel['detail'] .= '' . $log['error'] . ' | ';
- if ($color == 'red') {
+ if ($color == 'red') {
$panel['alarm'] = 'red';
}
}
@@ -644,4 +647,3 @@ function servcheck_detail() {
return $panel;
}
-
diff --git a/panellib/poller.php b/panellib/poller.php
index bc3e202..72e94ff 100644
--- a/panellib/poller.php
+++ b/panellib/poller.php
@@ -27,13 +27,13 @@
function register_poller() {
global $registry;
- $registry['poller'] = array(
+ $registry['poller'] = [
'name' => __('Poller Panels', 'intropage'),
'description' => __('Panels that provide information about Cacti\'s polling process.', 'intropage')
- );
+ ];
- $panels = array(
- 'poller_info' => array(
+ $panels = [
+ 'poller_info' => [
'name' => __('Poller Information', 'intropage'),
'description' => __('Various information about your Cacti poller.', 'intropage'),
'class' => 'poller',
@@ -50,8 +50,8 @@ function register_poller() {
'update_func' => 'poller_info',
'details_func' => 'poller_info_detail',
'trends_func' => 'poller_info_trend'
- ),
- 'poller_stat' => array(
+ ],
+ 'poller_stat' => [
'name' => __('Poller Statistics', 'intropage'),
'description' => __('Various Cacti poller statistics.', 'intropage'),
'class' => 'poller',
@@ -68,8 +68,8 @@ function register_poller() {
'update_func' => 'poller_stat',
'details_func' => false,
'trends_func' => 'poller_stat_trend'
- ),
- 'poller_output_items' => array(
+ ],
+ 'poller_output_items' => [
'name' => __('Poller Output Items', 'intropage'),
'description' => __('Various Cacti poller statistics.', 'intropage'),
'class' => 'poller',
@@ -86,8 +86,8 @@ function register_poller() {
'update_func' => 'poller_output_items',
'details_func' => false,
'trends_func' => 'poller_output_items_trend'
- ),
- );
+ ],
+ ];
return $panels;
}
@@ -96,7 +96,7 @@ function poller_info_trend() {
// Not yet implemented
}
-//------------------------------------ poller info -----------------------------------------------------
+// ------------------------------------ poller info -----------------------------------------------------
function poller_info($panel, $user_id) {
global $config;
@@ -122,14 +122,13 @@ function poller_info($panel, $user_id) {
if (cacti_sizeof($sql_pollers)) {
$details = '' .
'';
foreach ($sql_pollers as $poller) {
-
$color = 'green';
if ($poller['status'] == 0 || $poller['status'] == 1 || $poller['status'] == 2 || $poller['status'] == 5) {
@@ -144,24 +143,24 @@ function poller_info($panel, $user_id) {
$status = __('Idle', 'intropage');
} elseif ($poller['status'] == 3) {
$status = __('Unkn/down', 'intropage');
- $color = 'red';
+ $color = 'red';
} elseif ($poller['status'] == 4) {
$status = __('Disabled', 'intropage');
} elseif ($poller['status'] == 5) {
$status = __('Recovering', 'intropage');
- $color = 'yellow';
+ $color = 'yellow';
}
$details .= '' .
- '| ' . $poller['id'] . ' | ' .
- '' . html_escape($poller['name']) . ' | ' .
- '' . $status . ' | ';
+ '' . $poller['id'] . ' | ' .
+ '' . html_escape($poller['name']) . ' | ' .
+ '' . $status . ' | ';
$color = 'green';
- if (($poller['total_time']/$poller_interval) > 0.9) {
+ if (($poller['total_time'] / $poller_interval) > 0.9) {
$color = 'red';
- } elseif (($poller['total_time']/$poller_interval) > 0.7) {
+ } elseif (($poller['total_time'] / $poller_interval) > 0.7) {
$color = 'yellow';
}
@@ -194,11 +193,11 @@ function poller_stat_trend() {
db_execute_prepared("REPLACE INTO plugin_intropage_trends
(name, cur_timestamp, value, user_id) VALUES
('poller', ?, ?, ?)",
- array($stat['start'], $stat['id'] . ':' . round($stat['total_time']),4));
+ [$stat['start'], $stat['id'] . ':' . round($stat['total_time']), 4]);
}
}
-//------------------------------------ poller stat -----------------------------------------------------
+// ------------------------------------ poller stat -----------------------------------------------------
function poller_stat($panel, $user_id, $timespan = 0) {
global $config, $run_from_poller;
@@ -208,25 +207,25 @@ function poller_stat($panel, $user_id, $timespan = 0) {
$panel['alarm'] = 'green';
- $graph = array (
- 'line' => array(
+ $graph = [
+ 'line' => [
'title1' => '',
- 'label1' => array(),
- 'data1' => array(),
+ 'label1' => [],
+ 'data1' => [],
'title2' => '',
- 'label2' => array(),
- 'data2' => array(),
+ 'label2' => [],
+ 'data2' => [],
'title3' => '',
- 'label3' => array(),
- 'data3' => array(),
+ 'label3' => [],
+ 'data3' => [],
'title4' => '',
- 'label4' => array(),
- 'data4' => array(),
+ 'label4' => [],
+ 'data4' => [],
'title5' => '',
- 'label5' => array(),
- 'data5' => array(),
- ),
- );
+ 'label5' => [],
+ 'data5' => [],
+ ],
+ ];
if ($timespan == 0) {
if (isset($_SESSION['sess_user_id'])) {
@@ -240,7 +239,7 @@ function poller_stat($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh_interval'];
}
@@ -258,6 +257,7 @@ function poller_stat($panel, $user_id, $timespan = 0) {
if ($pcount > 0) {
$new_index = 1;
+
foreach ($pollers as $xpoller) {
$seconds = floor($timespan / 60);
@@ -268,7 +268,7 @@ function poller_stat($panel, $user_id, $timespan = 0) {
AND value LIKE ?
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
ORDER BY cur_timestamp ASC",
- array($timespan, $xpoller['id'] . ':%'));
+ [$timespan, $xpoller['id'] . ':%']);
if ($pcount < 3) {
$avg = db_fetch_cell_prepared("SELECT (SUBSTRING_INDEX(value, ':', -1)) AS value
@@ -276,7 +276,7 @@ function poller_stat($panel, $user_id, $timespan = 0) {
WHERE cur_timestamp > date_sub(NOW(), INTERVAL 24 HOUR) AND
name = 'poller' AND
value LIKE ?",
- array($xpoller['id'] . ':%'));
+ [$xpoller['id'] . ':%']);
$avg_label = [];
$avg_data = [];
}
@@ -288,7 +288,7 @@ function poller_stat($panel, $user_id, $timespan = 0) {
// graph data
$graph['line']['label' . $new_index][] = $row['date'];
- $graph['line']['data' . $new_index][] = round($row['value'], 2);
+ $graph['line']['data' . $new_index][] = round($row['value'], 2);
$graph['line']['title' . $new_index] = __('ID: ', 'intropage') . $xpoller['id'];
$graph['line']['unit1']['title'] = __('Seconds', 'intropage');
@@ -302,9 +302,8 @@ function poller_stat($panel, $user_id, $timespan = 0) {
// add 24 hours avg if we have enough lines
if ($pcount < 3) {
-
$graph['line']['label' . $new_index] = $avg_label;
- $graph['line']['data' . $new_index] = $avg_data;
+ $graph['line']['data' . $new_index] = $avg_data;
$graph['line']['title' . $new_index] = __('24h avg ID: ', 'intropage') . $xpoller['id'];
$graph['line']['unit1']['title'] = __('Seconds', 'intropage');
@@ -320,26 +319,26 @@ function poller_stat($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ poller_info -----------------------------------------------------
+// ------------------------------------ poller_info -----------------------------------------------------
function poller_info_detail() {
global $config;
$poller_interval = read_config_option('poller_interval');
- $panel = array(
+ $panel = [
'name' => __('Poller Details', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
$row = '' .
'';
$pollers = db_fetch_assoc('SELECT p.*
@@ -369,28 +368,28 @@ function poller_info_detail() {
$row .= '| ' . html_escape($poller['name']) . ' | ';
if ($poller['status'] == 0) {
- $row .= '' . __('New/Idle', 'intropage') . ' | ';
+ $row .= '' . __('New/Idle', 'intropage') . ' | ';
} elseif ($poller['status'] == 1) {
- $row .= '' . __('Running', 'intropage') . ' | ';
+ $row .= '' . __('Running', 'intropage') . ' | ';
} elseif ($poller['status'] == 2) {
- $row .= '' . __('Idle', 'intropage') . ' | ';
+ $row .= '' . __('Idle', 'intropage') . ' | ';
} elseif ($poller['status'] == 3) {
- $row .= '' . __('Unkn/down', 'intropage') . ' | ';
+ $row .= '' . __('Unkn/down', 'intropage') . ' | ';
} elseif ($poller['status'] == 4) {
- $row .= '' . __('Disabled', 'intropage') . ' | ';
+ $row .= '' . __('Disabled', 'intropage') . ' | ';
} elseif ($poller['status'] == 5) {
$row .= '' . __('Recovering', 'intropage') . ' | ';
}
- if (($poller['total_time']/$poller_interval) > 0.9) {
+ if (($poller['total_time'] / $poller_interval) > 0.9) {
$color = 'red';
- } elseif (($poller['total_time']/$poller_interval) > 0.7) {
+ } elseif (($poller['total_time'] / $poller_interval) > 0.7) {
$color = 'yellow';
}
$row .= '' . round($poller['total_time'], 2) . 's | ';
- $row .= '' . round($poller['avg_time'], 2) . 's | ';
- $row .= '' . round($poller['max_time'], 2) . 's | ';
+ $row .= '' . round($poller['avg_time'], 2) . 's | ';
+ $row .= '' . round($poller['max_time'], 2) . 's | ';
$row .= '';
}
@@ -409,33 +408,32 @@ function poller_info_detail() {
return $panel;
}
-//------------------------------------ poller_output_items -----------------------------------------------------
+// ------------------------------------ poller_output_items -----------------------------------------------------
function poller_output_items_trend() {
-
- $count = db_fetch_cell("SELECT COUNT(local_data_id) FROM poller_output");
+ $count = db_fetch_cell('SELECT COUNT(local_data_id) FROM poller_output');
db_execute_prepared('REPLACE INTO plugin_intropage_trends
(name, value, user_id)
VALUES (?, ?, 0)',
- array('poller_output', $count));
+ ['poller_output', $count]);
}
function poller_output_items($panel, $user_id, $timespan = 0) {
global $config, $run_from_poller;
$poller_interval = read_config_option('poller_interval');
- $color = read_config_option('intropage_alert_poller_output');
+ $color = read_config_option('intropage_alert_poller_output');
$panel['alarm'] = 'green';
- $graph = array (
- 'line' => array(
+ $graph = [
+ 'line' => [
'title1' => '',
- 'label1' => array(),
- 'data1' => array(),
- ),
- );
+ 'label1' => [],
+ 'data1' => [],
+ ],
+ ];
if ($timespan == 0) {
if (isset($_SESSION['sess_user_id'])) {
@@ -449,7 +447,7 @@ function poller_output_items($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh_interval'];
}
@@ -462,22 +460,22 @@ function poller_output_items($panel, $user_id, $timespan = 0) {
AND name = 'poller_output'
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
foreach ($rows as $row) {
if ($row['value'] > 0) {
if ($color == 'red') {
$panel['alarm'] = 'red';
- } elseif ($panel['alarm'] == 'green' && $color == "yellow") {
+ } elseif ($panel['alarm'] == 'green' && $color == 'yellow') {
$panel['alarm'] = 'yellow';
}
}
// graph data
- $graph['line']['label1'][] = $row['date'];
- $graph['line']['data1'][] = $row['value'];
- $graph['line']['title1'] = __('Poller output items ', 'intropage');
+ $graph['line']['label1'][] = $row['date'];
+ $graph['line']['data1'][] = $row['value'];
+ $graph['line']['title1'] = __('Poller output items ', 'intropage');
$graph['line']['unit1']['title'] = __('Items', 'intropage');
}
@@ -488,4 +486,3 @@ function poller_output_items($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-
diff --git a/panellib/syslog.php b/panellib/syslog.php
index 744da6b..6dd7c5d 100644
--- a/panellib/syslog.php
+++ b/panellib/syslog.php
@@ -27,13 +27,13 @@
function register_syslog() {
global $registry;
- $registry['syslog'] = array(
+ $registry['syslog'] = [
'name' => __('Syslog Panels', 'intropage'),
'description' => __('Panels that provide information about Cacti\'s Syslog message processing.', 'intropage')
- );
+ ];
- $panels = array(
- 'plugin_syslog' => array(
+ $panels = [
+ 'plugin_syslog' => [
'name' => __('Syslog Details', 'intropage'),
'description' => __('Various Syslog Plugin statistics.', 'intropage'),
'class' => 'syslog',
@@ -50,8 +50,8 @@ function register_syslog() {
'update_func' => 'plugin_syslog',
'details_func' => false,
'trends_func' => 'plugin_syslog_trend'
- ),
- 'plugin_syslog_devices' => array(
+ ],
+ 'plugin_syslog_devices' => [
'name' => __('Syslog Top Devices', 'intropage'),
'description' => __('Devices with the most messages', 'intropage'),
'class' => 'syslog',
@@ -68,8 +68,8 @@ function register_syslog() {
'update_func' => 'plugin_syslog_devices',
'details_func' => 'plugin_syslog_devices_detail',
'trends_func' => false
- ),
- 'plugin_syslog_levels' => array(
+ ],
+ 'plugin_syslog_levels' => [
'name' => __('Syslog Message levels', 'intropage'),
'description' => __('Messages by level.', 'intropage'),
'class' => 'syslog',
@@ -86,8 +86,8 @@ function register_syslog() {
'update_func' => 'plugin_syslog_levels',
'details_func' => false,
'trends_func' => 'plugin_syslog_levels_trend'
- ),
- );
+ ],
+ ];
return $panels;
}
@@ -96,7 +96,6 @@ function plugin_syslog_trend() {
global $config;
if (api_plugin_is_enabled('syslog')) {
-
include_once($config['base_path'] . '/plugins/syslog/database.php');
// Grab row counts from the information schema, it's faster
@@ -111,22 +110,22 @@ function plugin_syslog_trend() {
$alert_rows = syslog_db_fetch_cell_prepared('SELECT IFNULL(SUM(count),0)
FROM syslog_logs WHERE
logtime > DATE_SUB(NOW(), INTERVAL ? SECOND)',
- array(read_config_option('poller_interval')));
+ [read_config_option('poller_interval')]);
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES ("syslog_incoming", ?, 0)',
- array($i_rows));
+ [$i_rows]);
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES ("syslog_total", ?, 0)',
- array ($total_rows));
+ [$total_rows]);
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES ("syslog_alert", ?, 0)',
- array ($alert_rows));
+ [$alert_rows]);
}
}
@@ -134,10 +133,9 @@ function plugin_syslog_levels_trend() {
global $config;
if (api_plugin_is_enabled('syslog')) {
-
include_once($config['base_path'] . '/plugins/syslog/database.php');
- $data = array(
+ $data = [
0 => 0,
1 => 0,
2 => 0,
@@ -146,7 +144,7 @@ function plugin_syslog_levels_trend() {
5 => 0,
6 => 0,
7 => 0,
- );
+ ];
$pi = read_config_option('poller_interval');
@@ -155,10 +153,10 @@ function plugin_syslog_levels_trend() {
FROM syslog
WHERE logtime BETWEEN (DATE_SUB(NOW(),INTERVAL ? SECOND)) AND (DATE_SUB(NOW(),INTERVAL ? SECOND))
GROUP BY priority_id',
- array(2*$pi, $pi));
+ [2 * $pi, $pi]);
foreach ($levels as $level) {
- $l = (int) $level['priority_id'];
+ $l = (int) $level['priority_id'];
$data[$l] = $level['mcount'];
}
@@ -167,27 +165,27 @@ function plugin_syslog_levels_trend() {
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES ("syslog_levels", ?, 0)',
- array($insert));
+ [$insert]);
}
}
function plugin_syslog($panel, $user_id, $timespan = 0) {
$panel['alarm'] = 'green';
- $graph = array (
- 'line' => array(
+ $graph = [
+ 'line' => [
'title' => $panel['name'],
'title1' => '',
- 'label1' => array(),
- 'data1' => array(),
+ 'label1' => [],
+ 'data1' => [],
'title2' => '',
- 'label2' => array(),
- 'data2' => array(),
+ 'label2' => [],
+ 'data2' => [],
'title3' => '',
- 'label3' => array(),
- 'data3' => array(),
- ),
- );
+ 'label3' => [],
+ 'data3' => [],
+ ],
+ ];
if ($timespan == 0) {
if (isset($_SESSION['sess_user_id'])) {
@@ -201,7 +199,7 @@ function plugin_syslog($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh'];
}
@@ -219,14 +217,14 @@ function plugin_syslog($panel, $user_id, $timespan = 0) {
AND name IN ('syslog_total', 'syslog_incoming', 'syslog_alert')
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
// Converted syslog_total to total new rows;
- $nrows = array();
+ $nrows = [];
$last_total = 0;
- foreach($rows as $index => $row) {
+ foreach ($rows as $index => $row) {
$total = $row['syslog_total'];
$totali = $row['syslog_incoming'];
@@ -254,9 +252,9 @@ function plugin_syslog($panel, $user_id, $timespan = 0) {
$graph['line']['title3'] = __('Stored', 'intropage');
$graph['line']['unit1']['title'] = __('Messages', 'intropage');
- $graph['line']['unit1']['series'] = array('data1', 'data2', 'data3');
+ $graph['line']['unit1']['series'] = ['data1', 'data2', 'data3'];
- foreach($nrows as $row) {
+ foreach ($nrows as $row) {
$graph['line']['label1'][] = $row['date'];
$graph['line']['data1'][] = $row['syslog_incoming'];
$graph['line']['data2'][] = $row['syslog_alert'];
@@ -282,35 +280,35 @@ function plugin_syslog($panel, $user_id, $timespan = 0) {
function plugin_syslog_levels($panel, $user_id, $timespan = 0) {
$panel['alarm'] = 'green';
- $graph = array (
- 'bar' => array(
+ $graph = [
+ 'bar' => [
'title' => $panel['name'],
'title1' => 'Emergency',
- 'label1' => array(),
- 'data1' => array(),
+ 'label1' => [],
+ 'data1' => [],
'title2' => 'Alert',
- 'label2' => array(),
- 'data2' => array(),
+ 'label2' => [],
+ 'data2' => [],
'title3' => 'Critical',
- 'label3' => array(),
- 'data3' => array(),
+ 'label3' => [],
+ 'data3' => [],
'title4' => 'Error',
- 'label4' => array(),
- 'data4' => array(),
+ 'label4' => [],
+ 'data4' => [],
'title5' => 'Warning',
- 'label5' => array(),
- 'data5' => array(),
+ 'label5' => [],
+ 'data5' => [],
'title6' => 'Notice',
- 'label6' => array(),
- 'data6' => array(),
+ 'label6' => [],
+ 'data6' => [],
'title7' => 'Info',
- 'label7' => array(),
- 'data7' => array(),
+ 'label7' => [],
+ 'data7' => [],
'title8' => 'Debug',
- 'label8' => array(),
- 'data8' => array(),
- ),
- );
+ 'label8' => [],
+ 'data8' => [],
+ ],
+ ];
if ($timespan == 0) {
if (isset($_SESSION['sess_user_id'])) {
@@ -324,7 +322,7 @@ function plugin_syslog_levels($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh'];
}
@@ -338,24 +336,23 @@ function plugin_syslog_levels($panel, $user_id, $timespan = 0) {
AND name = 'syslog_levels'
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV ?
ORDER BY cur_timestamp ASC",
- array($timespan, $seconds));
+ [$timespan, $seconds]);
if (cacti_sizeof($rows)) {
-
- foreach($rows as $row) {
+ foreach ($rows as $row) {
$all = explode('&', $row['value']);
$graph['bar']['label1'][] = $row['cur_timestamp'];
foreach ($all as $item) {
- list($lev, $count) = explode('=', $item);
+ [$lev, $count] = explode('=', $item);
$lev++;
$graph['bar']["data$lev"][] = $count;
}
}
$graph['bar']['unit1']['title'] = __('Messages', 'intropage');
- $graph['bar']['unit1']['series'] = array('data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data8');
+ $graph['bar']['unit1']['series'] = ['data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data8'];
$panel['data'] = intropage_prepare_graph($graph, $user_id);
} else {
@@ -369,7 +366,6 @@ function plugin_syslog_levels($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-
function plugin_syslog_devices($panel, $user_id, $timespan = 0) {
global $config;
@@ -384,7 +380,6 @@ function plugin_syslog_devices($panel, $user_id, $timespan = 0) {
}
if (api_plugin_is_enabled('syslog')) {
-
include_once($config['base_path'] . '/plugins/syslog/database.php');
$lines = get_panel_lines_count($panel['height'], $user_id);
@@ -397,20 +392,19 @@ function plugin_syslog_devices($panel, $user_id, $timespan = 0) {
GROUP BY s.host_id
ORDER BY hcount DESC
LIMIT ' . $lines,
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($devices)) {
-
$panel['data'] = '' .
'';
$i = 0;
- foreach ($devices as $device) {
- $row = '| ' . html_escape(substr($device['ip'],0,37)) . ' | ';
+ foreach ($devices as $device) {
+ $row = ' | ' . html_escape(substr($device['ip'],0,37)) . ' | ';
$row .= "" . $device['hcount'] . ' | ';
$panel['data'] .= $row;
@@ -427,15 +421,14 @@ function plugin_syslog_devices($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-
function plugin_syslog_devices_detail() {
global $config, $console_access;
- $panel = array(
+ $panel = [
'name' => __('Top 20 Hosts with the most messages', 'intropage'),
'alarm' => 'grey',
'detail' => '',
- );
+ ];
if (isset($_SESSION['sess_user_id'])) {
$timespan = read_user_setting('intropage_timespan', read_config_option('intropage_timespan'), $_SESSION['sess_user_id']);
@@ -444,7 +437,6 @@ function plugin_syslog_devices_detail() {
}
if (api_plugin_is_enabled('syslog')) {
-
include_once($config['base_path'] . '/plugins/syslog/database.php');
$devices = syslog_db_fetch_assoc_prepared('SELECT sh.host AS ip ,count(*) AS hcount
@@ -455,21 +447,20 @@ function plugin_syslog_devices_detail() {
GROUP BY s.host_id
ORDER BY hcount desc
LIMIT 20',
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($devices)) {
-
$panel['detail'] = '' .
'';
$i = 0;
- foreach ($devices as $device) {
- $row = '| ' . html_escape($device['ip']) . ' | ';
- $row .= '' . $device['hcount']. ' | ';
+ foreach ($devices as $device) {
+ $row = '| ' . html_escape($device['ip']) . ' | ';
+ $row .= '' . $device['hcount'] . ' | ';
$panel['detail'] .= $row;
$i++;
@@ -480,8 +471,8 @@ function plugin_syslog_devices_detail() {
$panel['detail'] = __('No messages', 'intropage');
}
} else {
- $panel['detail'] = __('Syslog plugin is not enabled', 'intropage');
+ $panel['detail'] = __('Syslog plugin is not enabled', 'intropage');
}
+
return $panel;
}
-
diff --git a/panellib/system.php b/panellib/system.php
index 31f3157..5cde971 100644
--- a/panellib/system.php
+++ b/panellib/system.php
@@ -27,13 +27,13 @@
function register_system() {
global $registry;
- $registry['system'] = array(
+ $registry['system'] = [
'name' => __('System Panels', 'intropage'),
'description' => __('Panels that provide information about Cacti system performance.', 'intropage')
- );
+ ];
- $panels = array(
- 'info' => array(
+ $panels = [
+ 'info' => [
'name' => __('Information', 'intropage'),
'description' => __('Various system information about the Cacti system itself.', 'intropage'),
'class' => 'system',
@@ -50,8 +50,8 @@ function register_system() {
'update_func' => 'info',
'details_func' => false,
'trends_func' => false
- ),
- 'admin_alert' => array(
+ ],
+ 'admin_alert' => [
'name' => __('Administrative Alerts', 'intropage'),
'description' => __('Extra admin notify panel for all users', 'intropage'),
'class' => 'system',
@@ -68,8 +68,8 @@ function register_system() {
'update_func' => 'admin_alert',
'details_func' => false,
'trends_func' => false
- ),
- 'boost' => array(
+ ],
+ 'boost' => [
'name' => __('Boost Statistics', 'intropage'),
'description' => __('Information about Cacti\'s performance boost process.', 'intropage'),
'class' => 'system',
@@ -86,8 +86,8 @@ function register_system() {
'update_func' => 'boost',
'details_func' => false,
'trends_func' => false
- ),
- 'boost_history' => array(
+ ],
+ 'boost_history' => [
'name' => __('Boost History', 'intropage'),
'description' => __('Information about boost process history.', 'intropage'),
'class' => 'system',
@@ -104,8 +104,8 @@ function register_system() {
'update_func' => 'boost_history',
'details_func' => false,
'trends_func' => 'boost_history_trend'
- ),
- 'extrem' => array(
+ ],
+ 'extrem' => [
'name' => __('24 Hour Extremes', 'intropage'),
'description' => __('Table with 24 hours of Polling Extremes (longest poller run, down hosts)', 'intropage'),
'class' => 'system',
@@ -122,8 +122,8 @@ function register_system() {
'update_func' => 'extrem',
'details_func' => 'extrem_detail',
'trends_func' => 'extrem_trend'
- ),
- 'cpuload' => array(
+ ],
+ 'cpuload' => [
'name' => __('CPU Utilization', 'intropage'),
'description' => __('CPU utilization Graph (only Linux).', 'intropage'),
'class' => 'system',
@@ -140,8 +140,8 @@ function register_system() {
'update_func' => 'cpuload',
'details_func' => false,
'trends_func' => 'cpuload_trend'
- )
- );
+ ]
+ ];
return $panels;
}
@@ -154,24 +154,23 @@ function cpuload_trend() {
db_execute_prepared("REPLACE INTO plugin_intropage_trends
(name, value, user_id)
VALUES ('cpuload', ?, 0)",
- array($load[0]));
+ [$load[0]]);
}
}
-
-//------------------------------------ cpuload -----------------------------------------------------
+// ------------------------------------ cpuload -----------------------------------------------------
function cpuload($panel, $user_id, $timespan = 0) {
global $config;
$panel['alarm'] = 'green';
- $graph = array (
- 'line' => array(
+ $graph = [
+ 'line' => [
'title' => __('CPU Load: ', 'intropage'),
- 'label1' => array(),
- 'data1' => array(),
- ),
- );
+ 'label1' => [],
+ 'data1' => [],
+ ],
+ ];
if ($timespan == 0) {
if (isset($_SESSION['sess_user_id'])) {
@@ -185,7 +184,7 @@ function cpuload($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh'];
}
@@ -202,7 +201,7 @@ function cpuload($panel, $user_id, $timespan = 0) {
AND name = 'cpuload'
GROUP BY UNIX_TIMESTAMP(cur_timestamp) DIV $seconds
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
$graph['line']['title1'] = __('Avg CPU', 'intropage');
@@ -238,7 +237,7 @@ function cpuload($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-//------------------------- info-------------------------
+// ------------------------- info-------------------------
function info($panel, $user_id) {
global $config, $poller_options;
@@ -259,7 +258,7 @@ function info($panel, $user_id) {
$spine_version = $out_array[0];
}
- $panel['data'] .= '| ' . __('Poller Type:', 'intropage') .' ' . __('Spine', 'intropage') . ' | ';
+ $panel['data'] .= '| ' . __('Poller Type:', 'intropage') . ' ' . __('Spine', 'intropage') . ' | ';
$panel['data'] .= '' . __('Spine version: ', 'intropage') . $spine_version . '
| ';
@@ -267,9 +266,8 @@ function info($panel, $user_id) {
$panel['data'] .= '| ' . __('You are using incorrect spine version!', 'intropage') . ' | ';
$panel['alarm'] = 'red';
}
-
} else {
- $panel['data'] .= '' . __('Poller Type: ', 'intropage') . ' ' . $poller_options[read_config_option('poller_type')] . '
| ';
+ $panel['data'] .= '' . __('Poller Type: ', 'intropage') . ' ' . $poller_options[read_config_option('poller_type')] . '
| ';
}
if (function_exists('php_uname')) {
@@ -285,7 +283,7 @@ function info($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//---------------------------admin alert--------------------
+// ---------------------------admin alert--------------------
function admin_alert($panel, $user_id) {
global $config;
@@ -294,9 +292,7 @@ function admin_alert($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-
function boost_history_trend() {
-
$data_length = db_fetch_cell("SELECT data_length
FROM INFORMATION_SCHEMA.TABLES WHERE table_schema=SCHEMA()
AND (table_name LIKE 'poller_output_boost_arch_%' OR table_name LIKE 'poller_output_boost')");
@@ -304,7 +300,7 @@ function boost_history_trend() {
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES ("boost_mem_size", ?, 0)',
- array($data_length));
+ [$data_length]);
$boost_table_status = db_fetch_assoc("SELECT *
FROM INFORMATION_SCHEMA.TABLES WHERE table_schema=SCHEMA()
@@ -326,24 +322,23 @@ function boost_history_trend() {
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES ("boost_pending", ?, 0)',
- array($pending_records));
+ [$pending_records]);
}
-
function boost_history($panel, $user_id, $timespan = 0) {
global $config;
$panel['alarm'] = 'green';
- $graph = array (
- 'line' => array(
+ $graph = [
+ 'line' => [
'title' => __('Boost history: ', 'intropage'),
- 'label1' => array(),
- 'data1' => array(),
- 'label2' => array(),
- 'data2' => array(),
- ),
- );
+ 'label1' => [],
+ 'data1' => [],
+ 'label2' => [],
+ 'data2' => [],
+ ],
+ ];
if ($timespan == 0) {
if (isset($_SESSION['sess_user_id'])) {
@@ -357,7 +352,7 @@ function boost_history($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh'];
}
@@ -367,15 +362,15 @@ function boost_history($panel, $user_id, $timespan = 0) {
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
AND name = 'boost_mem_size'
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
- $graph['line']['title1'] = __('Mem ', 'intropage');
+ $graph['line']['title1'] = __('Mem ', 'intropage');
$graph['line']['unit1']['title'] = 'Used mem [KB]';
foreach ($rows as $row) {
$graph['line']['label1'][] = $row['date'];
- $graph['line']['data1'][] = $row['value']/1024;
+ $graph['line']['data1'][] = $row['value'] / 1024;
}
$rows = db_fetch_assoc_prepared("SELECT cur_timestamp AS `date`, value
@@ -383,10 +378,10 @@ function boost_history($panel, $user_id, $timespan = 0) {
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
AND name = 'boost_pending'
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
- $graph['line']['title2'] = __('Pending records ', 'intropage');
+ $graph['line']['title2'] = __('Pending records ', 'intropage');
$graph['line']['unit2']['title'] = 'Records';
foreach ($rows as $row) {
@@ -409,8 +404,7 @@ function boost_history($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-
-//--------------------------------boost--------------------------------
+// --------------------------------boost--------------------------------
function boost($panel, $user_id) {
global $config, $boost_refresh_interval, $boost_max_runtime;
@@ -427,7 +421,7 @@ function boost($panel, $user_id) {
$parallel = read_config_option('boost_parallel', true);
$detail_stats = read_config_option('stats_detail_boost', true);
- /* get the boost table status */
+ // get the boost table status
$boost_table_status = db_fetch_assoc("SELECT *
FROM INFORMATION_SCHEMA.TABLES WHERE table_schema=SCHEMA()
AND (table_name LIKE 'poller_output_boost_arch_%' OR table_name LIKE 'poller_output_boost')");
@@ -437,7 +431,7 @@ function boost($panel, $user_id) {
$data_length = 0;
$engine = '';
$max_data_length = 0;
- $total_records = 0;
+ $total_records = 0;
if (cacti_sizeof($boost_table_status)) {
foreach ($boost_table_status as $table) {
@@ -474,10 +468,10 @@ function boost($panel, $user_id) {
$boost_status_text = __('Running', 'intropage');
} elseif (substr_count($boost_status_array[0], 'overrun')) {
$boost_status_text = __('Overrun Warning', 'intropage');
- $panel['alarm'] = 'red';
+ $panel['alarm'] = 'red';
} elseif (substr_count($boost_status_array[0], 'timeout')) {
$boost_status_text = __('Timed Out', 'intropage');
- $panel['alarm'] = 'red';
+ $panel['alarm'] = 'red';
} else {
$boost_status_text = __('Other');
}
@@ -531,10 +525,10 @@ function boost($panel, $user_id) {
$panel['data'] .= '
| ';
- /* tell the user how big the table is */
+ // tell the user how big the table is
$panel['data'] .= '| ' . __('Current Boost Table(s) Size: %s', human_filesize($data_length), 'intropage') . ' | ';
- /* tell the user about the average size/record */
+ // tell the user about the average size/record
$panel['data'] .= '| ' . __('Avg Bytes/Record: %s', human_filesize($avg_row_length), 'intropage') . ' | ';
if (is_numeric($boost_last_run_duration)) {
@@ -558,15 +552,14 @@ function extrem_trend() {
foreach ($users as $user) {
if (is_panel_allowed('extrem', $user['id'])) {
-
$simple_perms = get_simple_device_perms($user['id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user['id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -581,7 +574,7 @@ function extrem_trend() {
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES (?, ?, ?)',
- array('failed_polls', $count, $user['id']));
+ ['failed_polls', $count, $user['id']]);
}
if (db_table_exists('host_errors')) {
@@ -592,13 +585,13 @@ function extrem_trend() {
db_execute_prepared('INSERT INTO plugin_intropage_trends
(name, value, user_id)
VALUES (?, ?, ?)',
- array('host_errors', $count, $user['id']));
+ ['host_errors', $count, $user['id']]);
}
}
}
}
-//------------------------------------ extrem -----------------------------------------------------
+// ------------------------------------ extrem -----------------------------------------------------
function extrem($panel, $user_id) {
global $config;
@@ -608,9 +601,9 @@ function extrem($panel, $user_id) {
$panel['alarm'] = 'grey';
- $columns = array();
- $data = array();
- $fin_data = array();
+ $columns = [];
+ $data = [];
+ $fin_data = [];
$console_access = get_console_access($user_id);
@@ -627,9 +620,9 @@ function extrem($panel, $user_id) {
if (cacti_sizeof($data)) {
foreach ($data as $key => $row) {
- if (($row['xvalue']/$poller_interval) > 0.9) {
+ if (($row['xvalue'] / $poller_interval) > 0.9) {
$color = 'red';
- } elseif (($row['xvalue']/$poller_interval) > 0.7) {
+ } elseif (($row['xvalue'] / $poller_interval) > 0.7) {
$color = 'yellow';
} else {
$color = 'green';
@@ -650,11 +643,10 @@ function extrem($panel, $user_id) {
AND cur_timestamp > date_sub(now(),interval 1 day)
ORDER BY value desc,cur_timestamp
LIMIT $lines",
- array($user_id));
+ [$user_id]);
if (cacti_sizeof($data)) {
foreach ($data as $key => $row) {
-
if ($row['value'] > 0) {
$color = 'red';
} else {
@@ -676,7 +668,7 @@ function extrem($panel, $user_id) {
AND cur_timestamp > date_sub(now(),interval 1 day)
ORDER BY value desc,cur_timestamp
LIMIT $lines",
- array($user_id));
+ [$user_id]);
if (cacti_sizeof($data)) {
foreach ($data as $key => $row) {
@@ -711,7 +703,6 @@ function extrem($panel, $user_id) {
}
$fin_data[$key]['pout'] = $row['date'] . ' ' . $row['value'] . ' ';
-
}
}
}
@@ -764,18 +755,19 @@ function extrem($panel, $user_id) {
// Create table from data
$panel['data'] = '';
$i = 0;
- foreach($fin_data as $key => $rdata) {
- $panel['data'] .= '';
- foreach($columns as $index => $col) {
- $panel['data'] .= '| ' . (isset($rdata[$index]) ? $rdata[$index]:'-') . ' | ';
+ foreach ($fin_data as $key => $rdata) {
+ $panel['data'] .= ' ';
+
+ foreach ($columns as $index => $col) {
+ $panel['data'] .= '| ' . (isset($rdata[$index]) ? $rdata[$index] : '-') . ' | ';
}
$panel['data'] .= ' ';
@@ -785,26 +777,26 @@ function extrem($panel, $user_id) {
$panel['data'] .= ' ';
} else {
- $panel['data'] .= __('Waiting for data', 'intropage');
+ $panel['data'] .= __('Waiting for data', 'intropage');
}
save_panel_result($panel, $user_id);
}
-//------------------------------------ extrem -----------------------------------------------------
+// ------------------------------------ extrem -----------------------------------------------------
function extrem_detail() {
global $config, $console_access;
$poller_interval = read_config_option('poller_interval');
- $panel = array(
+ $panel = [
'name' => __('48 Hour Extreme Polling', 'intropage'),
'alarm' => 'grey',
'detail' => '',
- );
+ ];
- $trows = array();
- $header = array();
+ $trows = [];
+ $header = [];
$panel['detail'] .= '' .
'';
- for($k = 0; $k < $i; $k++) {
+ for ($k = 0; $k < $i; $k++) {
$panel['detail'] .= '';
- for($l = 0; $l <= $j; $l++) {
- $panel['detail'] .= '| ' . (isset($trows[$k][$l]) ? $trows[$k][$l]:__('N/A', 'intropage')) . ' | ';
+
+ for ($l = 0; $l <= $j; $l++) {
+ $panel['detail'] .= '' . (isset($trows[$k][$l]) ? $trows[$k][$l] : __('N/A', 'intropage')) . ' | ';
}
$panel['detail'] .= ' ';
@@ -997,4 +994,3 @@ function extrem_detail() {
return $panel;
}
-
diff --git a/panellib/thold.php b/panellib/thold.php
index 7b3680b..b736d9f 100644
--- a/panellib/thold.php
+++ b/panellib/thold.php
@@ -27,13 +27,13 @@
function register_thold() {
global $registry;
- $registry['thold'] = array(
+ $registry['thold'] = [
'name' => __('Threshold Panels', 'intropage'),
'description' => __('Panels that provide information about Cacti Thresholding Plugin.', 'intropage')
- );
+ ];
- $panels = array(
- 'thold_event' => array(
+ $panels = [
+ 'thold_event' => [
'name' => __('Last Threshold Events', 'intropage'),
'description' => __('Threshold Plugin Latest Events', 'intropage'),
'class' => 'thold',
@@ -50,8 +50,8 @@ function register_thold() {
'update_func' => 'thold_event',
'details_func' => 'thold_event_detail',
'trends_func' => false
- ),
- 'graph_thold' => array(
+ ],
+ 'graph_thold' => [
'name' => __('Threshold', 'intropage'),
'description' => __('Threshold Plugin Graph (all, triggered, ...)', 'intropage'),
'class' => 'thold',
@@ -68,19 +68,20 @@ function register_thold() {
'update_func' => 'graph_thold',
'details_func' => 'graph_thold_detail',
'trends_func' => 'thold_collect'
- ),
- );
+ ],
+ ];
return $panels;
}
-//------------------------------------ thold event -----------------------------------------------------
+// ------------------------------------ thold event -----------------------------------------------------
function thold_event($panel, $user_id) {
global $config;
$lines = get_panel_lines_count($panel['height'], $user_id);
$important_period = read_user_setting('intropage_important_period', read_config_option('intropage_important_period'), false, $user_id);
+
if ($important_period == -1) {
$important_period = time();
}
@@ -88,18 +89,18 @@ function thold_event($panel, $user_id) {
$panel['alarm'] = 'green';
if (!api_plugin_is_enabled('thold')) {
- $panel['alarm'] = 'yellow';
- $panel['data'] = __('Plugin Thold isn\'t installed or started', 'intropage');
- $panel['detail'] = FALSE;
+ $panel['alarm'] = 'yellow';
+ $panel['data'] = __('Plugin Thold isn\'t installed or started', 'intropage');
+ $panel['detail'] = false;
} else {
$simple_perms = get_simple_device_perms($user_id);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user_id);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -131,11 +132,10 @@ function thold_event($panel, $user_id) {
ORDER BY `time` DESC
LIMIT " . $lines);
} else {
- $data = array();
+ $data = [];
}
if (cacti_sizeof($data)) {
-
$panel['data'] .= '';
foreach ($data as $row) {
@@ -143,7 +143,7 @@ function thold_event($panel, $user_id) {
$color = 'grey';
- if ($row['time'] > (time()-($important_period))) {
+ if ($row['time'] > (time() - ($important_period))) {
if (preg_match('/(NORMAL)/i', $row['description'])) {
$color = 'green';
} elseif (preg_match('/(ALERT|ERROR)/i', $row['description'])) {
@@ -178,7 +178,7 @@ function thold_event($panel, $user_id) {
$panel['alarm'] == 'yellow';
}
}
-
+
$panel['data'] .= ' ';
} else {
$panel['data'] = __('Without events yet', 'intropage');
@@ -188,7 +188,7 @@ function thold_event($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ graph_thold -----------------------------------------------------
+// ------------------------------------ graph_thold -----------------------------------------------------
function graph_thold($panel, $user_id, $timespan = 0) {
global $config;
@@ -196,26 +196,24 @@ function graph_thold($panel, $user_id, $timespan = 0) {
include_once($config['base_path'] . '/plugins/thold/thold_functions.php');
- $graph = array (
- 'line' => array(
+ $graph = [
+ 'line' => [
'title' => __('Thresholds: ', 'intropage'),
- 'label1' => array(),
- 'data1' => array(),
- 'label2' => array(),
- 'data2' => array(),
- 'label3' => array(),
- 'data3' => array(),
- ),
- );
+ 'label1' => [],
+ 'data1' => [],
+ 'label2' => [],
+ 'data2' => [],
+ 'label3' => [],
+ 'data3' => [],
+ ],
+ ];
if (!api_plugin_is_enabled('thold')) {
$panel['alarm'] = 'grey';
$panel['data'] = __('Thold plugin not installed/running', 'intropage');
} elseif (api_plugin_user_realm_auth('thold_graph.php')) {
-
-
if ($timespan == 0) {
- if (isset($_SESSION['sess_user_id'])) {
+ if (isset($_SESSION['sess_user_id'])) {
$timespan = read_user_setting('intropage_timespan', read_config_option('intropage_timespan'), $_SESSION['sess_user_id']);
} else {
$timespan = $panel['refresh'];
@@ -226,7 +224,7 @@ function graph_thold($panel, $user_id, $timespan = 0) {
$refresh = db_fetch_cell_prepared('SELECT refresh_interval
FROM plugin_intropage_panel_data
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
} else {
$refresh = $panel['refresh'];
}
@@ -236,24 +234,21 @@ function graph_thold($panel, $user_id, $timespan = 0) {
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
AND name = 'thold_trig'
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
-
- $graph['line']['title1'] = __('Triggered', 'intropage');
+ $graph['line']['title1'] = __('Triggered', 'intropage');
$graph['line']['unit1']['title'] = 'Triggered';
foreach ($rows as $row) {
-
$graph['line']['label1'][] = $row['date'];
$graph['line']['data1'][] = $row['value'];
- $last = $row['value'];
+ $last = $row['value'];
}
if ($last > 0) {
$panel['alarm'] = 'red';
}
-
} else {
unset($graph['line']['label1']);
unset($graph['line']['data1']);
@@ -264,23 +259,21 @@ function graph_thold($panel, $user_id, $timespan = 0) {
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
AND name = 'thold_brea'
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
-
- $graph['line']['title2'] = __('Breached', 'intropage');
+ $graph['line']['title2'] = __('Breached', 'intropage');
$graph['line']['unit2']['title'] = 'Breached';
foreach ($rows as $row) {
$graph['line']['label2'][] = $row['date'];
$graph['line']['data2'][] = $row['value'];
- $last = $row['value'];
+ $last = $row['value'];
}
if ($last > 0 && $panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
}
-
} else {
unset($graph['line']['label2']);
unset($graph['line']['data2']);
@@ -291,17 +284,16 @@ function graph_thold($panel, $user_id, $timespan = 0) {
WHERE cur_timestamp > date_sub(NOW(), INTERVAL ? SECOND)
AND name = 'thold_disa'
ORDER BY cur_timestamp ASC",
- array($timespan));
+ [$timespan]);
if (cacti_sizeof($rows)) {
-
- $graph['line']['title3'] = __('Disabled', 'intropage');
+ $graph['line']['title3'] = __('Disabled', 'intropage');
$graph['line']['unit3']['title'] = 'Disabled';
foreach ($rows as $row) {
$graph['line']['label3'][] = $row['date'];
$graph['line']['data3'][] = $row['value'];
- }
+ }
} else {
unset($graph['line']['label3']);
unset($graph['line']['data3']);
@@ -320,20 +312,20 @@ function graph_thold($panel, $user_id, $timespan = 0) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ graph_thold -----------------------------------------------------
+// ------------------------------------ graph_thold -----------------------------------------------------
function graph_thold_detail() {
global $config, $sql_where;
include_once($config['base_path'] . '/plugins/thold/thold_functions.php');
- $panel = array(
+ $panel = [
'name' => __('Threshold Details', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
if (!api_plugin_is_enabled('thold')) {
- $panel['alarm'] = 'grey';
+ $panel['alarm'] = 'grey';
$panel['detail'] = __('Thold plugin not installed/running', 'intropage');
unset($panel['pie']);
} elseif (api_plugin_user_realm_auth('thold_graph.php')) {
@@ -343,25 +335,25 @@ function graph_thold_detail() {
$t_disa = 0;
$sql_where = '';
- $x = get_allowed_thresholds($sql_where, 'null', 1, $t_all, $_SESSION['sess_user_id']);
+ $x = get_allowed_thresholds($sql_where, 'null', 1, $t_all, $_SESSION['sess_user_id']);
if (db_column_exists('thold_data', 'thold_per_enabled')) {
- $cond_ena = "(td.thold_enabled = 'on' AND td.thold_per_enabled = 'on')";
+ $cond_ena = "(td.thold_enabled = 'on' AND td.thold_per_enabled = 'on')";
$cond_disa = "(td.thold_per_enabled = '' OR td.thold_enabled = '')";
} else {
- $cond_ena = "td.thold_enabled = 'on'";
+ $cond_ena = "td.thold_enabled = 'on'";
$cond_disa = "td.thold_enabled = ''";
}
- $sql_where = "( h.status = 3 AND ( " . $cond_ena . " AND (td.thold_alert != 0 OR td.bl_alert > 0)))";
+ $sql_where = '( h.status = 3 AND ( ' . $cond_ena . ' AND (td.thold_alert != 0 OR td.bl_alert > 0)))';
$t_brea_result = get_allowed_thresholds($sql_where, 'null', '', $t_brea, $_SESSION['sess_user_id']);
- $sql_where = " h.status = 3 AND " . $cond_ena . " AND ((td.thold_alert != 0 AND td.thold_fail_count >= td.thold_fail_trigger)
- OR (td.bl_alert > 0 AND td.bl_fail_count >= td.bl_fail_trigger))";
+ $sql_where = ' h.status = 3 AND ' . $cond_ena . ' AND ((td.thold_alert != 0 AND td.thold_fail_count >= td.thold_fail_trigger)
+ OR (td.bl_alert > 0 AND td.bl_fail_count >= td.bl_fail_trigger))';
$t_trig_result = get_allowed_thresholds($sql_where, 'null', '', $t_trig, $_SESSION['sess_user_id']);
- $sql_where = " h.status = 3 AND " . $cond_disa;
- $x = get_allowed_thresholds($sql_where, 'null', 1, $t_disa, $_SESSION['sess_user_id']);
+ $sql_where = ' h.status = 3 AND ' . $cond_disa;
+ $x = get_allowed_thresholds($sql_where, 'null', 1, $t_disa, $_SESSION['sess_user_id']);
$count = $t_all + $t_brea + $t_trig + $t_disa;
@@ -374,35 +366,35 @@ function graph_thold_detail() {
$url_prefix = '';
$panel['detail'] .= '
- | ' . sprintf($url_prefix, '-1') . __('All', 'intropage') . ' |
+ ' . sprintf($url_prefix, '-1') . __('All', 'intropage') . ' |
' . number_format_i18n($t_all, -1) . ' | ';
$panel['detail'] .= '
- | ' . sprintf($url_prefix, '1') . __('Breached', 'intropage') . ' |
+ ' . sprintf($url_prefix, '1') . __('Breached', 'intropage') . ' |
' . number_format_i18n($t_brea, -1) . ' | ';
$panel['detail'] .= '
- | ' . sprintf($url_prefix, '3') . __('Triggered', 'intropage') . ' |
+ ' . sprintf($url_prefix, '3') . __('Triggered', 'intropage') . ' |
' . number_format_i18n($t_trig, -1) . ' | ';
$panel['detail'] .= '
- | ' . sprintf($url_prefix, '0') . __('Disabled', 'intropage') . ' |
+ ' . sprintf($url_prefix, '0') . __('Disabled', 'intropage') . ' |
' . number_format_i18n($t_disa, -1) . ' | ';
} else {
$panel['detail'] .= '
- | ' . __('All', 'intropage') . ' |
+ ' . __('All', 'intropage') . ' |
' . number_format_i18n($t_all, -1) . ' | ';
$panel['detail'] .= '
- | ' . __('Breached', 'intropage') . ' |
+ ' . __('Breached', 'intropage') . ' |
' . number_format_i18n($t_brea, -1) . ' | ';
$panel['detail'] .= '
- | ' . __('Triggered', 'intropage') . ' |
+ ' . __('Triggered', 'intropage') . ' |
' . number_format_i18n($t_trig, -1) . ' | ';
$panel['detail'] .= '
- | ' . __('Disabled', 'intropage') . ' |
+ ' . __('Disabled', 'intropage') . ' |
' . number_format_i18n($t_disa, -1) . ' | ';
}
@@ -422,7 +414,7 @@ function graph_thold_detail() {
if ($t_trig > 0) {
$panel['alarm'] = 'red';
- $panel['detail'] .= '' . __('Triggered: ', 'intropage') .' ';
+ $panel['detail'] .= '' . __('Triggered: ', 'intropage') . ' ';
foreach ($t_trig_result as $host) {
$panel['detail'] .= html_escape($host['name_cache']) . ' ';
@@ -436,33 +428,32 @@ function graph_thold_detail() {
return $panel;
}
-//------------------------------------ thold_events -----------------------------------------------------
+// ------------------------------------ thold_events -----------------------------------------------------
function thold_event_detail() {
global $config;
include_once($config['base_path'] . '/plugins/thold/thold_functions.php');
- $panel = array(
+ $panel = [
'name' => __('Last Threshold Events', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
if (!api_plugin_is_enabled('thold')) {
$panel['alarm'] = 'yellow';
$panel['detail'] = __('Plugin Thold isn\'t installed or started', 'intropage');
} else {
-
$simple_perms = get_simple_device_perms($_SESSION['sess_user_id']);
if (!$simple_perms) {
- $allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
- $q_host_cond = 'WHERE td.host_id ' . $host_cond;
- } else {
- $allowed_devices = false;
- $q_host_cond = '';
- }
+ $allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
+ $host_cond = 'IN (' . $allowed_devices . ')';
+ $q_host_cond = 'WHERE td.host_id ' . $host_cond;
+ } else {
+ $allowed_devices = false;
+ $q_host_cond = '';
+ }
$data = db_fetch_assoc("SELECT tl.description as description,tl.time as time,
tl.status as status, uap0.user_id AS user0, uap1.user_id AS user1, uap2.user_id AS user2
@@ -494,10 +485,11 @@ function thold_event_detail() {
' . __('Date', 'intropage') . ' | ';
$i = 0;
+
foreach ($data as $row) {
- $class = ($i % 2 == 0 ? 'odd':'even');
+ $class = ($i % 2 == 0 ? 'odd' : 'even');
$panel['detail'] .= '
- | ' . html_escape($row['description']) . ' |
+ ' . html_escape($row['description']) . ' |
' . date('Y-m-d H:i:s', $row['time']) . ' |
';
@@ -536,10 +528,10 @@ function thold_collect() {
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user['id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -547,58 +539,56 @@ function thold_collect() {
}
if ($allowed_devices !== false || $simple_perms) {
-
- $x = '';
+ $x = '';
$sql_where = '';
if (db_column_exists('thold_data', 'thold_per_enabled')) {
- $cond_ena = "(td.thold_enabled = 'on' AND td.thold_per_enabled = 'on')";
+ $cond_ena = "(td.thold_enabled = 'on' AND td.thold_per_enabled = 'on')";
$cond_disa = "(td.thold_per_enabled = '' OR td.thold_enabled = '')";
} else {
- $cond_ena = "td.thold_enabled = 'on'";
+ $cond_ena = "td.thold_enabled = 'on'";
$cond_disa = "td.thold_enabled = ''";
}
- $sql_where = "( h.status = 3 AND ( " . $cond_ena . " AND (td.thold_alert != 0 OR td.bl_alert > 0)))";
+ $sql_where = '( h.status = 3 AND ( ' . $cond_ena . ' AND (td.thold_alert != 0 OR td.bl_alert > 0)))';
$t_brea_result = get_allowed_thresholds($sql_where, 'null', 1, $t_brea, $user['id']);
- $sql_where = " h.status = 3 AND " . $cond_ena . " AND ((td.thold_alert != 0 AND td.thold_fail_count >= td.thold_fail_trigger)
- OR (td.bl_alert > 0 AND td.bl_fail_count >= td.bl_fail_trigger))";
+ $sql_where = ' h.status = 3 AND ' . $cond_ena . ' AND ((td.thold_alert != 0 AND td.thold_fail_count >= td.thold_fail_trigger)
+ OR (td.bl_alert > 0 AND td.bl_fail_count >= td.bl_fail_trigger))';
$t_trig_result = get_allowed_thresholds($sql_where, 'null', 1, $t_trig, $user['id']);
- $sql_where = " h.status = 3 AND " . $cond_disa;
- $x = get_allowed_thresholds($sql_where, 'null', 1, $t_disa, $user['id']);
+ $sql_where = ' h.status = 3 AND ' . $cond_disa;
+ $x = get_allowed_thresholds($sql_where, 'null', 1, $t_disa, $user['id']);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('thold_brea', ?, ?)",
- array($t_brea, $user['id']));
+ [$t_brea, $user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('thold_disa', ?, ?)",
- array($t_disa, $user['id']));
+ [$t_disa, $user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('thold_trig', ?, ?)",
- array($t_trig, $user['id']));
+ [$t_trig, $user['id']]);
} else {
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('thold_brea', 0, ?)",
- array($user['id']));
+ [$user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('thold_disa', 0, ?)",
- array($user['id']));
+ [$user['id']]);
db_execute_prepared("INSERT INTO plugin_intropage_trends
(name,value,user_id)
VALUES ('thold_trig', 0, ?)",
- array($user['id']));
+ [$user['id']]);
}
}
}
-
diff --git a/panellib/top5.php b/panellib/top5.php
index 8ac156c..29e2411 100644
--- a/panellib/top5.php
+++ b/panellib/top5.php
@@ -27,13 +27,13 @@
function register_top5() {
global $registry;
- $registry['top5'] = array(
+ $registry['top5'] = [
'name' => __('Top/Bottom 5 Panels', 'intropage'),
'description' => __('Panels that provide information trending information about Cacti data collection.', 'intropage')
- );
+ ];
- $panels = array(
- 'top5_ping' => array(
+ $panels = [
+ 'top5_ping' => [
'name' => __('Bottom Ping', 'intropage'),
'description' => __('Devices with the worst ping response', 'intropage'),
'class' => 'top5',
@@ -50,8 +50,8 @@ function register_top5() {
'update_func' => 'top5_ping',
'details_func' => 'top5_ping_detail',
'trends_func' => false
- ),
- 'top5_availability' => array(
+ ],
+ 'top5_availability' => [
'name' => __('Bottom Availability', 'intropage'),
'description' => __('Devices with the worst availability/reachability', 'intropage'),
'class' => 'top5',
@@ -68,8 +68,8 @@ function register_top5() {
'update_func' => 'top5_availability',
'details_func' => 'top5_availability_detail',
'trends_func' => false
- ),
- 'top5_polltime' => array(
+ ],
+ 'top5_polltime' => [
'name' => __('Bottom Polling Time', 'intropage'),
'description' => __('Devices with the worst polling time', 'intropage'),
'class' => 'top5',
@@ -86,8 +86,8 @@ function register_top5() {
'update_func' => 'top5_polltime',
'details_func' => 'top5_polltime_detail',
'trends_func' => false
- ),
- 'top5_pollratio' => array(
+ ],
+ 'top5_pollratio' => [
'name' => __('Bottom Polling Ratio', 'intropage'),
'description' => __('Devices with the worst polling ratio', 'intropage'),
'class' => 'top5',
@@ -104,13 +104,13 @@ function register_top5() {
'update_func' => 'top5_pollratio',
'details_func' => 'top5_pollratio_detail',
'trends_func' => false
- ),
- );
+ ],
+ ];
return $panels;
}
-//------------------------------------ top5_worst_ping -----------------------------------------------------
+// ------------------------------------ top5_worst_ping -----------------------------------------------------
function top5_ping($panel, $user_id) {
global $config;
@@ -122,10 +122,10 @@ function top5_ping($panel, $user_id) {
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user_id);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -143,21 +143,22 @@ function top5_ping($panel, $user_id) {
LIMIT " . $lines);
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_ping');
- list($red, $yellow) = explode ('/', $color);
+ $color = read_config_option('intropage_alert_worst_ping');
+ [$red, $yellow] = explode('/', $color);
$panel['data'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['cur_time'] > $red) {
$panel['alarm'] = 'red';
- $color = 'red';
+ $color = 'red';
} elseif ($host['cur_time'] > $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
@@ -168,9 +169,9 @@ function top5_ping($panel, $user_id) {
}
if ($console_access) {
- $row = '| ' . html_escape(substr($host['description'],0,37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'],0,37)) . ' | ';
} else {
- $row = ' | ' . html_escape(substr($host['description'],0,37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'],0,37)) . ' | ';
}
$row .= "" . round($host['avg_time'], 2) . ' ms | ';
@@ -192,7 +193,7 @@ function top5_ping($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ top5_availability -----------------------------------------------------
+// ------------------------------------ top5_availability -----------------------------------------------------
function top5_availability($panel, $user_id) {
global $config;
@@ -204,10 +205,10 @@ function top5_availability($panel, $user_id) {
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user_id);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -225,20 +226,21 @@ function top5_availability($panel, $user_id) {
LIMIT " . $lines);
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_availability');
- list($red, $yellow) = explode ('/', $color);
+ $color = read_config_option('intropage_alert_worst_availability');
+ [$red, $yellow] = explode('/', $color);
$panel['data'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['availability'] < $red) {
$panel['alarm'] = 'red';
- $color = 'red';
+ $color = 'red';
} elseif ($host['availability'] < $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
@@ -249,9 +251,9 @@ function top5_availability($panel, $user_id) {
}
if ($console_access) {
- $row = '| ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
} else {
- $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
}
$row .= "" . round($host['availability'],2) . " % | ";
@@ -272,7 +274,7 @@ function top5_availability($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ top5_worst_polltime -----------------------------------------------------
+// ------------------------------------ top5_worst_polltime -----------------------------------------------------
function top5_polltime($panel, $user_id) {
global $config;
@@ -284,10 +286,10 @@ function top5_polltime($panel, $user_id) {
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user_id);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -305,20 +307,21 @@ function top5_polltime($panel, $user_id) {
LIMIT " . $lines);
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_polling_time');
- list($red, $yellow) = explode ('/', $color);
+ $color = read_config_option('intropage_alert_worst_polling_time');
+ [$red, $yellow] = explode('/', $color);
$panel['data'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['polling_time'] > $red) {
$panel['alarm'] = 'red';
- $color = 'red';
+ $color = 'red';
} elseif ($host['polling_time'] > $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
@@ -329,9 +332,9 @@ function top5_polltime($panel, $user_id) {
}
if ($console_access) {
- $row = '| ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
} else {
- $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
}
$row .= "" . __('%s Secs', round($host['polling_time'], 2), 'intropage') . " | ";
@@ -352,7 +355,7 @@ function top5_polltime($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ top5_worst_pollratio -----------------------------------------------------
+// ------------------------------------ top5_worst_pollratio -----------------------------------------------------
function top5_pollratio($panel, $user_id) {
global $config;
@@ -364,10 +367,10 @@ function top5_pollratio($panel, $user_id) {
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($user_id);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -386,23 +389,24 @@ function top5_pollratio($panel, $user_id) {
LIMIT " . $lines);
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_polling_ratio');
- list($red, $yellow) = explode ('/', $color);
+ $color = read_config_option('intropage_alert_worst_polling_ratio');
+ [$red, $yellow] = explode('/', $color);
$panel['data'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['ratio'] > $red) {
$panel['alarm'] = 'red';
- $color = 'red';
- } elseif ( $host['ratio'] > $yellow) {
+ $color = 'red';
+ } elseif ($host['ratio'] > $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
}
@@ -412,14 +416,14 @@ function top5_pollratio($panel, $user_id) {
}
if ($console_access) {
- $row = '| ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
} else {
- $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
+ $row = ' | ' . html_escape(substr($host['description'], 0, 37)) . ' | ';
}
$row .= "" . number_format_i18n($host['failed_polls'], 0) . ' | ';
- $row .= "" . number_format_i18n($host['total_polls'], 0) . ' | ';
- $row .= "" . round($host['ratio'] * 100, 3) . " % | ";
+ $row .= "" . number_format_i18n($host['total_polls'], 0) . ' | ';
+ $row .= "" . round($host['ratio'] * 100, 3) . " % | ";
$panel['data'] .= $row;
@@ -437,24 +441,24 @@ function top5_pollratio($panel, $user_id) {
save_panel_result($panel, $user_id);
}
-//------------------------------------ top5_worst_ping -----------------------------------------------------
+// ------------------------------------ top5_worst_ping -----------------------------------------------------
function top5_ping_detail() {
global $config, $console_access;
- $panel = array(
+ $panel = [
'name' => __('Top 20 Hosts with Worst Ping', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
$simple_perms = get_simple_device_perms($_SESSION['sess_user_id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -469,26 +473,27 @@ function top5_ping_detail() {
ORDER BY cur_time desc
LIMIT 40");
} else {
- $sql_worst_host = array();
+ $sql_worst_host = [];
}
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_ping');
- list($red, $yellow) = explode ('/', $color);
+ $color = read_config_option('intropage_alert_worst_ping');
+ [$red, $yellow] = explode('/', $color);
$panel['detail'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['cur_time'] > $red) {
$panel['alarm'] = 'red';
- $color = 'red';
- } elseif ($host['cur_time'] > $yellow) {
+ $color = 'red';
+ } elseif ($host['cur_time'] > $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
}
@@ -498,9 +503,9 @@ function top5_ping_detail() {
}
if ($console_access) {
- $row = '| ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
} else {
- $row = ' | ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
}
$row .= '' . round($host['avg_time'], 2) . ' ms | ';
@@ -519,24 +524,24 @@ function top5_ping_detail() {
return $panel;
}
-//------------------------------------ top5_availability -----------------------------------------------------
+// ------------------------------------ top5_availability -----------------------------------------------------
function top5_availability_detail() {
global $config, $console_access;
- $panel = array(
+ $panel = [
'name' => __('Top 20 Hosts with the Worst Availability', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
$simple_perms = get_simple_device_perms($_SESSION['sess_user_id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -544,7 +549,6 @@ function top5_availability_detail() {
}
if ($allowed_devices !== false || $simple_perms) {
-
$sql_worst_host = db_fetch_assoc("SELECT description, id, availability
FROM host
WHERE disabled != 'on'
@@ -552,24 +556,25 @@ function top5_availability_detail() {
ORDER BY availability
LIMIT 40");
} else {
- $sql_worst_host = array();
+ $sql_worst_host = [];
}
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_availability');
- list($red, $yellow) = explode ('/', $color);
+ $color = read_config_option('intropage_alert_worst_availability');
+ [$red, $yellow] = explode('/', $color);
$panel['detail'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['availability'] < $red) {
$panel['alarm'] = 'red';
- $color = 'red';
+ $color = 'red';
} elseif ($host['availability'] < $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
@@ -580,9 +585,9 @@ function top5_availability_detail() {
}
if ($console_access) {
- $row = '| ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
} else {
- $row = ' | ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
}
$row .= "" . round($host['availability'], 2) . " % | ";
@@ -600,24 +605,24 @@ function top5_availability_detail() {
return $panel;
}
-//------------------------------------ top5_polltime -----------------------------------------------------
+// ------------------------------------ top5_polltime -----------------------------------------------------
function top5_polltime_detail() {
global $config, $console_access;
- $panel = array(
+ $panel = [
'name' => __('Top 20 Hosts Worst Polling Time', 'intropage'),
'alarm' => 'green',
'detail' => '',
- );
+ ];
$simple_perms = get_simple_device_perms($_SESSION['sess_user_id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -632,24 +637,25 @@ function top5_polltime_detail() {
ORDER BY polling_time DESC
LIMIT 40");
} else {
- $sql_worst_host = array();
+ $sql_worst_host = [];
}
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_polling_time');
- list($red,$yellow) = explode ('/',$color);
+ $color = read_config_option('intropage_alert_worst_polling_time');
+ [$red,$yellow] = explode('/',$color);
$panel['detail'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['polling_time'] > $red) {
$panel['alarm'] = 'red';
- $color = 'red';
+ $color = 'red';
} elseif ($host['polling_time'] > $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
@@ -660,9 +666,9 @@ function top5_polltime_detail() {
}
if ($console_access) {
- $row = '| ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
} else {
- $row = ' | ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
}
$row .= "" . __('%s Secs', round($host['polling_time'], 2), 'intropage') . " | ";
@@ -680,24 +686,24 @@ function top5_polltime_detail() {
return $panel;
}
-//------------------------------------ top5_pollratio -----------------------------------------------------
+// ------------------------------------ top5_pollratio -----------------------------------------------------
function top5_pollratio_detail() {
global $config, $console_access;
- $panel = array(
+ $panel = [
'name' => __('Top 20 Hosts with the Worst Polling Ratio', 'intropage'),
'alarm' => 'grey',
'detail' => '',
- );
+ ];
$simple_perms = get_simple_device_perms($_SESSION['sess_user_id']);
if (!$simple_perms) {
$allowed_devices = intropage_get_allowed_devices($_SESSION['sess_user_id']);
- $host_cond = 'IN (' . $allowed_devices . ')';
+ $host_cond = 'IN (' . $allowed_devices . ')';
} else {
$allowed_devices = false;
- $q_host_cond = '';
+ $q_host_cond = '';
}
if (!$simple_perms) {
@@ -705,7 +711,6 @@ function top5_pollratio_detail() {
}
if ($allowed_devices !== false || $simple_perms) {
-
$sql_worst_host = db_fetch_assoc("SELECT id, description, failed_polls,
total_polls, CAST(failed_polls/total_polls AS DECIMAL(5,4)) AS ratio
FROM host
@@ -714,27 +719,28 @@ function top5_pollratio_detail() {
ORDER BY ratio DESC
LIMIT 40");
} else {
- $sql_worst_host = array();
+ $sql_worst_host = [];
}
if (cacti_sizeof($sql_worst_host)) {
- $color = read_config_option('intropage_alert_worst_polling_ratio');
- list($red,$yellow) = explode ('/',$color);
+ $color = read_config_option('intropage_alert_worst_polling_ratio');
+ [$red,$yellow] = explode('/',$color);
$panel['detail'] = '' .
'';
$i = 0;
+
foreach ($sql_worst_host as $host) {
if ($host['ratio'] > $red) {
$panel['alarm'] = 'red';
- $color = 'red';
- } elseif ($host['ratio'] > $yellow) {
+ $color = 'red';
+ } elseif ($host['ratio'] > $yellow) {
if ($panel['alarm'] == 'green') {
$panel['alarm'] = 'yellow';
}
@@ -744,14 +750,14 @@ function top5_pollratio_detail() {
}
if ($console_access) {
- $row = '| ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
} else {
- $row = ' | ' . html_escape($host['description']) . ' | ';
+ $row = ' | ' . html_escape($host['description']) . ' | ';
}
$row .= "" . number_format_i18n($host['failed_polls'], 0) . ' | ';
- $row .= "" . number_format_i18n($host['total_polls'], 0) . ' | ';
- $row .= "" . round($host['ratio']* 100, 3) . " % | ";
+ $row .= "" . number_format_i18n($host['total_polls'], 0) . ' | ';
+ $row .= "" . round($host['ratio'] * 100, 3) . " % | ";
$panel['detail'] .= $row;
diff --git a/poller_intropage.php b/poller_intropage.php
index 3b7d893..f9de4df 100644
--- a/poller_intropage.php
+++ b/poller_intropage.php
@@ -24,19 +24,19 @@
+-------------------------------------------------------------------------+
*/
-$dir = dirname(__FILE__);
+$dir = __DIR__;
chdir($dir);
include('../../include/cli_check.php');
include_once($config['base_path'] . '/lib/reports.php');
include_once($config['base_path'] . '/plugins/intropage/include/functions.php');
-/* let PHP run just as long as it has to */
+// let PHP run just as long as it has to
ini_set('max_execution_time', '0');
error_reporting(E_ALL);
-/* record the start time */
+// record the start time
$poller_start = microtime(true);
$start_date = date('Y-m-d H:i:s');
$force = false;
@@ -47,53 +47,53 @@
$run_from_poller = true;
-/* process calling arguments */
+// process calling arguments
$parms = $_SERVER['argv'];
array_shift($parms);
if (cacti_sizeof($parms)) {
$shortopts = 'VvHh';
- $longopts = array(
+ $longopts = [
'force',
'debug',
'version',
'help'
- );
+ ];
$options = getopt($shortopts, $longopts);
- foreach($options as $arg => $value) {
+ foreach ($options as $arg => $value) {
switch($arg) {
- case 'force':
- $force = true;
-
- break;
- case 'debug':
- $debug = true;
-
- break;
- case 'version':
- case 'V':
- case 'v':
- display_version();
- exit(0);
- case 'help':
- case 'H':
- case 'h':
- display_help();
- exit(0);
- default:
- print "ERROR: Invalid Argument: ($arg)" . PHP_EOL . PHP_EOL;
- display_help();
- exit(1);
+ case 'force':
+ $force = true;
+
+ break;
+ case 'debug':
+ $debug = true;
+
+ break;
+ case 'version':
+ case 'V':
+ case 'v':
+ display_version();
+ exit(0);
+ case 'help':
+ case 'H':
+ case 'h':
+ display_help();
+ exit(0);
+ default:
+ print "ERROR: Invalid Argument: ($arg)" . PHP_EOL . PHP_EOL;
+ display_help();
+ exit(1);
}
}
}
intropage_debug('Intropage Starting Checks');
-/* silently end if the registered process is still running, or process table missing */
+// silently end if the registered process is still running, or process table missing
if (function_exists('register_process_start')) {
if (!register_process_start('intropage', 'master', $config['poller_id'], read_config_option('intropage_timeout'))) {
intropage_debug('Another Intropage Process Still Running');
@@ -108,7 +108,7 @@
$poller_end = microtime(true);
-$pstats = 'Time:' . round($poller_end-$poller_start, 2) . ', Checks:' . $stats['checks'] . ', Panels:' . $stats['panels'] . ', Trends:' . $stats['trends'];
+$pstats = 'Time:' . round($poller_end - $poller_start, 2) . ', Checks:' . $stats['checks'] . ', Panels:' . $stats['panels'] . ', Trends:' . $stats['trends'];
cacti_log('INTROPAGE STATS: ' . $pstats, false, 'SYSTEM');
set_config_option('stats_intropage', $pstats);
@@ -136,7 +136,7 @@ function intropage_gather_stats() {
$logging = read_config_option('log_verbosity', true);
$trends = 0;
- $pdata = 0;
+ $pdata = 0;
$checks = 0;
$panels = initialize_panel_library();
@@ -159,13 +159,12 @@ function intropage_gather_stats() {
OR (last_update IS NULL AND level = 0)');
if (cacti_sizeof($tpanels)) {
+ $done_trends = [];
- $done_trends = array();
+ foreach ($tpanels as $panel) {
+ $start = microtime(true);
- foreach($tpanels as $panel) {
- $start = microtime(true);
-
- /* Get trends next */
+ // Get trends next
if (isset($panel['trends_func']) && $panel['trends_func'] != '' && is_panel_enabled($panel['panel_id'])) {
$function = $panel['trends_func'];
@@ -173,9 +172,9 @@ function intropage_gather_stats() {
db_execute_prepared('UPDATE plugin_intropage_panel_data
SET last_trend_update = NOW()
WHERE id = ?',
- array($panel['id']));
+ [$panel['id']]);
- /* we need run it only once. Example - graph host panel gathers data for all users */
+ // we need run it only once. Example - graph host panel gathers data for all users
if (!array_key_exists($panel['panel_id'], $done_trends)) {
$function();
$trends++;
@@ -188,7 +187,6 @@ function intropage_gather_stats() {
}
intropage_debug(sprintf('gathering trend function:%s, duration:%4.3f', $function, microtime(true) - $start));
-
} else {
cacti_log('WARNING: Unable to find update function ' . $function . ' for panel ' . $panel['name'], false, 'INTROPAGE');
}
@@ -215,7 +213,7 @@ function intropage_gather_stats() {
db_execute_prepared('UPDATE plugin_intropage_panel_data
SET refresh_interval = ?
WHERE id = ?',
- array($panel['refresh'], $upanel['id']));
+ [$panel['refresh'], $upanel['id']]);
$upanel['refresh_interval'] = $panel['refresh'];
}
@@ -272,7 +270,7 @@ function intropage_gather_stats() {
SET cur_timestamp = now()
WHERE name = 'ar_poller_finish'");
- return array('checks' => $checks, 'panels' => $pdata, 'trends' => $trends);
+ return ['checks' => $checks, 'panels' => $pdata, 'trends' => $trends];
}
function intropage_debug($message) {
@@ -306,4 +304,3 @@ function display_help() {
print ' --force - force execution, e.g. for testing' . PHP_EOL;
print ' --debug - debug execution, e.g. for testing' . PHP_EOL . PHP_EOL;
}
-
diff --git a/setup.php b/setup.php
index 24eea05..a7a24ff 100644
--- a/setup.php
+++ b/setup.php
@@ -59,10 +59,10 @@ function plugin_intropage_install() {
api_plugin_register_realm('intropage', 'intropage.php', 'Intropage Viewer', 1);
api_plugin_register_realm('intropage', 'intropage_admin.php', 'Intropage Administration', 1);
- $realms = array(
+ $realms = [
__('Intropage Viewer', 'intropage'),
__('Intropage Administration', 'intropage')
- );
+ ];
intropage_setup_database();
}
@@ -78,10 +78,10 @@ function plugin_intropage_uninstall() {
function intropage_config_arrays() {
global $intropage_intervals, $trend_timespans, $panel_lines;
- auth_augment_roles(__('Normal User'), array('intropage.php'));
- auth_augment_roles(__('System Administration'), array('intropage_admin.php'));
+ auth_augment_roles(__('Normal User'), ['intropage.php']);
+ auth_augment_roles(__('System Administration'), ['intropage_admin.php']);
- $trend_timespans = array(
+ $trend_timespans = [
3600 => __('Timespan Last 1 Hour', 'intropage'),
7200 => __('Timespan Last %d Hours', 2, 'intropage'),
10800 => __('Timespan Last %d Hours', 3, 'intropage'),
@@ -90,11 +90,11 @@ function intropage_config_arrays() {
43200 => __('Timespan Last %d Hours', 12, 'intropage'),
86400 => __('Timespan Last 1 Day', 'intropage'),
172800 => __('Timespan Last 2 Days', 'intropage')
- );
+ ];
$poller_interval = read_config_option('poller_interval');
- $intropage_intervals = array(
+ $intropage_intervals = [
'10' => __('%d Seconds', 10, 'intropage'),
'15' => __('%d Seconds', 15, 'intropage'),
'20' => __('%d Seconds', 20, 'intropage'),
@@ -114,9 +114,9 @@ function intropage_config_arrays() {
'28800' => __('%d Hours', 8, 'intropage'),
'43200' => __('%d Hours', 12, 'intropage'),
'86400' => __('%d Day', 1, 'intropage')
- );
+ ];
- foreach($intropage_intervals as $key => $name) {
+ foreach ($intropage_intervals as $key => $name) {
if ($key < $poller_interval) {
unset($intropage_intervals[$key]);
}
@@ -199,12 +199,12 @@ function intropage_poller_bottom() {
// refresh_interval - in second, min is 60
// priority - for displaying
// description - small description, it is visible in user auth settings
-function intropage_add_panel($panel_id, $file, $has_detail, $refresh_interval, $priority=20, $description='') {
+function intropage_add_panel($panel_id, $file, $has_detail, $refresh_interval, $priority = 20, $description = '') {
if (db_execute_prepared('REPLACE INTO plugin_intropage_panel_definition
(panel_id,file,has_detail,refresh_interval, priority, description)
- VALUES (?,?,?,?,?,?)', array($panel_id,$file,$has_detail,$refresh_interval,$priority,$description)) == 1) {
+ VALUES (?,?,?,?,?,?)', [$panel_id, $file, $has_detail, $refresh_interval, $priority, $description]) == 1) {
+ api_plugin_db_add_column('intropage', 'plugin_intropage_user_auth', ['name' => $panel_id, 'type' => 'char(2)', 'NULL' => false, 'default' => 'on']);
- api_plugin_db_add_column('intropage', 'plugin_intropage_user_auth', array('name' => $panel_id, 'type' => 'char(2)', 'NULL' => false, 'default' => 'on'));
return ('1');
} else {
return db_error();
@@ -213,21 +213,20 @@ function intropage_add_panel($panel_id, $file, $has_detail, $refresh_interval, $
// remove third party panel
function intropage_remove_panel($panel_id) {
- db_execute_prepared('DELETE FROM plugin_intropage_panel_data WHERE panel_id = ?', array($panel_id));
- db_execute_prepared('DELETE FROM plugin_intropage_panel_definition WHERE panel_id = ?', array($panel_id));
- db_execute_prepared('ALTER TABLE plugin_intropage_user_auth DROP ?',array($panel_id));
+ db_execute_prepared('DELETE FROM plugin_intropage_panel_data WHERE panel_id = ?', [$panel_id]);
+ db_execute_prepared('DELETE FROM plugin_intropage_panel_definition WHERE panel_id = ?', [$panel_id]);
+ db_execute_prepared('ALTER TABLE plugin_intropage_user_auth DROP ?',[$panel_id]);
return ('1');
}
function intropage_user_remove($user_id) {
- db_execute_prepared('DELETE FROM plugin_intropage_panel_data WHERE user_id = ?', array($user_id));
- db_execute_prepared('DELETE FROM plugin_intropage_panel_dashboard WHERE user_id = ?', array($user_id));
- db_execute_prepared('DELETE FROM settings_user WHERE user_id = ?', array($user_id));
- db_execute_prepared('DELETE FROM plugin_intropage_user_auth WHERE user_id = ?', array($user_id));
+ db_execute_prepared('DELETE FROM plugin_intropage_panel_data WHERE user_id = ?', [$user_id]);
+ db_execute_prepared('DELETE FROM plugin_intropage_panel_dashboard WHERE user_id = ?', [$user_id]);
+ db_execute_prepared('DELETE FROM settings_user WHERE user_id = ?', [$user_id]);
+ db_execute_prepared('DELETE FROM plugin_intropage_user_auth WHERE user_id = ?', [$user_id]);
}
function intropage_user_group_remove($group_id) {
- db_execute_prepared('DELETE FROM plugin_intropage_user_group_auth WHERE id = ?', array($group_id));
+ db_execute_prepared('DELETE FROM plugin_intropage_user_group_auth WHERE id = ?', [$group_id]);
}
-
|