Split is removed in PHP7, replace with explode as none were using it as a regex.

Also fix two array keys without quotes in include/syslog.php
Fixes #2205
This commit is contained in:
Tony Murray
2016-02-25 14:30:40 -06:00
parent d9dcebb878
commit 9f22b18dc8
25 changed files with 26 additions and 26 deletions

View File

@@ -34,7 +34,7 @@ foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.devi
$cmd = $config['nagios_plugins'] . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']); $cmd = $config['nagios_plugins'] . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']);
$cmd .= " ".$service['service_param']; $cmd .= " ".$service['service_param'];
$check = shell_exec($cmd); $check = shell_exec($cmd);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(stristr($check, "ok -")) { if(stristr($check, "ok -")) {
$status = 1; $status = 1;
} }

View File

@@ -37,7 +37,7 @@ if ($handle = opendir($rrddir)) {
foreach ($files as $id => $file) { foreach ($files as $id => $file) {
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = eregi_replace('.rrd', '', $hostname); $hostname = eregi_replace('.rrd', '', $hostname);
list($host, $port) = split('_', $hostname, 2); list($host, $port) = explode('_', $hostname, 2);
$rrd_filenames[] = $rrddir.'/'.$file; $rrd_filenames[] = $rrddir.'/'.$file;
$rrd_list[$i]['filename'] = $rrddir.'/'.$file; $rrd_list[$i]['filename'] = $rrddir.'/'.$file;
$rrd_list[$i]['descr'] = $host.':'.$port; $rrd_list[$i]['descr'] = $host.':'.$port;

View File

@@ -25,7 +25,7 @@ if ($handle = opendir($rrddir)) {
foreach ($files as $id => $file) { foreach ($files as $id => $file) {
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = eregi_replace('.rrd', '', $hostname); $hostname = eregi_replace('.rrd', '', $hostname);
list($host, $port) = split('_', $hostname, 2); list($host, $port) = explode('_', $hostname, 2);
$rrd_filenames[] = $rrddir.'/'.$file; $rrd_filenames[] = $rrddir.'/'.$file;
$rrd_list[$i]['filename'] = $rrddir.'/'.$file; $rrd_list[$i]['filename'] = $rrddir.'/'.$file;
$rrd_list[$i]['descr'] = $host.':'.$port; $rrd_list[$i]['descr'] = $host.':'.$port;

View File

@@ -42,7 +42,7 @@ if (isset($total) && $total === true) {
foreach ($files as $id => $file) { foreach ($files as $id => $file) {
$hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file);
$hostname = eregi_replace('.rrd', '', $hostname); $hostname = eregi_replace('.rrd', '', $hostname);
list($host, $port) = split('_', $hostname, 2); list($host, $port) = explode('_', $hostname, 2);
$graphs = array( $graphs = array(
'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')', 'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')',
'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')', 'shoutcast_stats' => 'Shoutcast Statistics - '.$host.' (Port: '.$port.')',

View File

@@ -307,7 +307,7 @@ echo '
</div>'; </div>';
$api_urls = get_config_like_name('alert.transports.api.%.'); $api_urls = get_config_like_name('alert.transports.api.%.');
foreach ($api_urls as $api_url) { foreach ($api_urls as $api_url) {
$api_split = split('\.', $api_url['config_name']); $api_split = explode('.', $api_url['config_name']);
$api_method = $api_split[3]; $api_method = $api_split[3];
echo '<div class="form-group has-feedback" id="'.$api_url['config_id'].'"> echo '<div class="form-group has-feedback" id="'.$api_url['config_id'].'">
<label for="api_url" class="col-sm-4 control-label">API URL ('.$api_method.') </label> <label for="api_url" class="col-sm-4 control-label">API URL ('.$api_method.') </label>

View File

@@ -15,7 +15,7 @@ foreach ($servers as $item => $server) {
if (!empty($server)) { if (!empty($server)) {
$data = explode(';', $server); $data = explode(';', $server);
list($host, $port) = split(':', $data['0'], 2); list($host, $port) = explode(':', $data['0'], 2);
$bitrate = $data['1']; $bitrate = $data['1'];
$traf_in = $data['2']; $traf_in = $data['2'];
$traf_out = $data['3']; $traf_out = $data['3'];

View File

@@ -2,5 +2,5 @@
$serial = snmp_get($device, 'productSerialNum.0', '-Ovq', 'NETAPP-MIB'); $serial = snmp_get($device, 'productSerialNum.0', '-Ovq', 'NETAPP-MIB');
$hardware = snmp_get($device, 'productModel.0', '-Ovq', 'NETAPP-MIB'); $hardware = snmp_get($device, 'productModel.0', '-Ovq', 'NETAPP-MIB');
list($version,) = split(':', snmp_get($device, 'productVersion.0', '-Ovq', 'NETAPP-MIB')); list($version,) = explode(':', snmp_get($device, 'productVersion.0', '-Ovq', 'NETAPP-MIB'));
$version = str_replace('NetApp Release ', '', $version); $version = str_replace('NetApp Release ', '', $version);

View File

@@ -2,5 +2,5 @@
$sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', ''))); $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', '')));
preg_match_all('/([0-9]+C)+/', $sensor_value, $temps); preg_match_all('/([0-9]+C)+/', $sensor_value, $temps);
list(,$index) = split('\.', $sensor['sensor_index']); list(,$index) = explode('.', $sensor['sensor_index']);
$sensor_value = $temps[0][$index]; $sensor_value = $temps[0][$index];

View File

@@ -6,7 +6,7 @@ if ($service['service_ip']) { $resolver = $service['service_ip']; } else {
$check = shell_exec($config['nagios_plugins'] . "/check_dns -H ".$nsquery." -s ".$resolver); $check = shell_exec($config['nagios_plugins'] . "/check_dns -H ".$nsquery." -s ".$resolver);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "DNS OK: ")) { if(strstr($check, "DNS OK: ")) {
$status = '1'; $status = '1';

View File

@@ -10,7 +10,7 @@ if( $service['service_ip'] ) {
$cmd .= " ".$service['service_param']; $cmd .= " ".$service['service_param'];
$check = shell_exec($cmd); $check = shell_exec($cmd);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "OK - Domain")) { if(strstr($check, "OK - Domain")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_ftp -H ".$service['hostname']); $check = shell_exec($config['nagios_plugins'] . "/check_ftp -H ".$service['hostname']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "FTP OK - ")) { if(strstr($check, "FTP OK - ")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_http -H ".$service['hostname']." ".$service['service_param']); $check = shell_exec($config['nagios_plugins'] . "/check_http -H ".$service['hostname']." ".$service['service_param']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "HTTP OK")) { if(strstr($check, "HTTP OK")) {
$status = '1'; $status = '1';

View File

@@ -1,7 +1,7 @@
<?php <?php
$check = shell_exec($config['nagios_plugins'] . "/check_icmp ".($service['service_ip'] ? $service['service_ip'] : $service['hostname'])); $check = shell_exec($config['nagios_plugins'] . "/check_icmp ".($service['service_ip'] ? $service['service_ip'] : $service['hostname']));
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "OK - ")) { if(strstr($check, "OK - ")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_imap -H ".$service['hostname']); $check = shell_exec($config['nagios_plugins'] . "/check_imap -H ".$service['hostname']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "IMAP OK - ")) { if(strstr($check, "IMAP OK - ")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_ircd -H ".$service['hostname']." ".$service['service_param']); $check = shell_exec($config['nagios_plugins'] . "/check_ircd -H ".$service['hostname']." ".$service['service_param']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if (strstr($check, "IRCD ok")) { if (strstr($check, "IRCD ok")) {
$status = '1'; $status = '1';

View File

@@ -5,7 +5,7 @@ if ($service['service_param']) { $dbname = $service['service_param']; } else { $
$check = shell_exec($config['nagios_plugins'] . "/check_mysql -H ".$service['hostname']." ".$dbname); $check = shell_exec($config['nagios_plugins'] . "/check_mysql -H ".$service['hostname']." ".$dbname);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "Uptime:") || strstr($check, "MySQL OK")) { if(strstr($check, "Uptime:") || strstr($check, "MySQL OK")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_ntp -H ".$service['hostname']." ".$service['service_param']); $check = shell_exec($config['nagios_plugins'] . "/check_ntp -H ".$service['hostname']." ".$service['service_param']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "NTP OK")) { if(strstr($check, "NTP OK")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_pop -H ".$service['hostname']); $check = shell_exec($config['nagios_plugins'] . "/check_pop -H ".$service['hostname']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "POP OK - ")) { if(strstr($check, "POP OK - ")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_simap -H ".$service['hostname']); $check = shell_exec($config['nagios_plugins'] . "/check_simap -H ".$service['hostname']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "SIMAP OK")) { if(strstr($check, "SIMAP OK")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_smtp -H ".$service['hostname']); $check = shell_exec($config['nagios_plugins'] . "/check_smtp -H ".$service['hostname']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "SMTP OK")) { if(strstr($check, "SMTP OK")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_spop -H ".$service['hostname']); $check = shell_exec($config['nagios_plugins'] . "/check_spop -H ".$service['hostname']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "SPOP OK")) { if(strstr($check, "SPOP OK")) {
$status = '1'; $status = '1';

View File

@@ -2,7 +2,7 @@
$check = shell_exec($config['nagios_plugins'] . "/check_ssh -H ".$service['hostname']." ".$service['service_param']); $check = shell_exec($config['nagios_plugins'] . "/check_ssh -H ".$service['hostname']." ".$service['service_param']);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "SSH OK")) { if(strstr($check, "SSH OK")) {
$status = '1'; $status = '1';

View File

@@ -4,7 +4,7 @@ if($service['service_port']) { $port = $service['service_port']; } else { $port
$check = shell_exec($config['nagios_plugins'] . "/check_telnet -H ".$service['hostname']." -p ".$port); $check = shell_exec($config['nagios_plugins'] . "/check_telnet -H ".$service['hostname']." -p ".$port);
list($check, $time) = split("\|", $check); list($check, $time) = explode("|", $check);
if(strstr($check, "TCP OK - ")) { if(strstr($check, "TCP OK - ")) {
$status = '1'; $status = '1';

View File

@@ -58,9 +58,9 @@ function process_syslog($entry, $update) {
// $entry['program'] = $matches['program']; // $entry['program'] = $matches['program'];
// } // }
// unset($matches); // unset($matches);
if (strstr($entry[msg], '%')) { if (strstr($entry['msg'], '%')) {
$entry['msg'] = preg_replace('/^%(.+?):\ /', '\\1||', $entry['msg']); $entry['msg'] = preg_replace('/^%(.+?):\ /', '\\1||', $entry['msg']);
list(,$entry[msg]) = split(': %', $entry['msg']); list(,$entry['msg']) = explode(': %', $entry['msg']);
$entry['msg'] = '%'.$entry['msg']; $entry['msg'] = '%'.$entry['msg'];
$entry['msg'] = preg_replace('/^%(.+?):\ /', '\\1||', $entry['msg']); $entry['msg'] = preg_replace('/^%(.+?):\ /', '\\1||', $entry['msg']);
} }

View File

@@ -63,7 +63,7 @@
$servers = file($config); $servers = file($config);
$data = array(); $data = array();
foreach ($servers as $item=>$server) { foreach ($servers as $item=>$server) {
list($host, $port) = split(":", $server, 2); list($host, $port) = explode(":", $server, 2);
array_push($data, get_data(trim($host), trim($port))); array_push($data, get_data(trim($host), trim($port)));
} }
return $data; return $data;