From 4bc15529d457732c75201516e9bc646b1864eb61 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Mon, 11 Apr 2011 09:22:12 +0000 Subject: [PATCH] eradicate split() in favour of explode() git-svn-id: http://www.observium.org/svn/observer/trunk@2054 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/device/graphs.inc.php | 2 +- html/pages/device/showconfig.inc.php | 2 +- html/pages/iftype.inc.php | 6 +++--- includes/billing.php | 3 ++- includes/discovery/bgp-peers.inc.php | 4 ++-- includes/discovery/cisco-pw.inc.php | 2 +- includes/discovery/ipv6-addresses.inc.php | 2 +- includes/discovery/q-bridge-mib.inc.php | 2 +- includes/functions.php | 2 +- includes/polling/bgp-peers.inc.php | 2 +- includes/polling/os/aos.inc.php | 2 +- includes/polling/os/cat1900.inc.php | 2 +- includes/polling/os/dell-laser.inc.php | 2 +- includes/polling/os/unix.inc.php | 2 +- includes/syslog.php | 2 +- 15 files changed, 19 insertions(+), 18 deletions(-) diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 83aac0fc0e..8ad6194d38 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -30,7 +30,7 @@ foreach ($config['graph_sections'] as $section) echo(''); } - echo(" " . $type .""); + echo(" " . ucfirst($type) .""); if ($_GET['opta'] == $type) { echo(""); diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 0402356c27..175aa66ee1 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -18,7 +18,7 @@ if ($_SESSION['userlevel'] >= "7") if ($config['rancid_ignorecomments']) { - $lines = split("\n",$text); + $lines = explode("\n",$text); for ($i = 0;$i < count($lines);$i++) { if ($lines[$i][0] == "#") { unset($lines[$i]); } diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index 47acb1fc4c..b4357f19f3 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -2,10 +2,10 @@ " . generate_port_link($interface,$interface['port_descr_descr']) . "
".generate_device_link($interface)." ".generate_port_link($interface)." "); diff --git a/includes/billing.php b/includes/billing.php index 45577031f3..00626fcfce 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -3,7 +3,8 @@ function getDates($dayofmonth) { $dayofmonth = zeropad($dayofmonth); - list($year, $month) = split('-', date('Y-m')); + $year = date('Y'); + $month = date('m'); if (date('d') > $dayofmonth) { diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index b461c94f96..2f2bfed442 100755 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -23,7 +23,7 @@ if ($config['enable_bgp']) foreach (explode("\n", $peers) as $peer) { - list($peer_ip, $peer_as) = split(" ", $peer); + list($peer_ip, $peer_as) = explode(" ", $peer); if ($peer && $peer_ip != "0.0.0.0") { @@ -43,7 +43,7 @@ if ($config['enable_bgp']) $peers = trim(str_replace(".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.","", $result)); foreach (explode("\n", $peers) as $peer) { - list($peer_ip_snmp, $peer_as) = split(" ", $peer); + list($peer_ip_snmp, $peer_as) = explode(" ", $peer); # Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs. $peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.',array_slice(explode('.',$peer_ip_snmp),count(explode('.',$peer_ip_snmp))-16)))); diff --git a/includes/discovery/cisco-pw.inc.php b/includes/discovery/cisco-pw.inc.php index 1ef0c16b18..1c5bac417f 100755 --- a/includes/discovery/cisco-pw.inc.php +++ b/includes/discovery/cisco-pw.inc.php @@ -21,7 +21,7 @@ if ($config['enable_pseudowires'] && $device['os_group'] == "ios") if ($cpwOid) { - list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid)); + list($cpw_remote_id) = explode(":", shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid)); $interface_descr = trim(shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid)); $cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0); $if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0); diff --git a/includes/discovery/ipv6-addresses.inc.php b/includes/discovery/ipv6-addresses.inc.php index d0248beccc..6e6e6a8a55 100644 --- a/includes/discovery/ipv6-addresses.inc.php +++ b/includes/discovery/ipv6-addresses.inc.php @@ -50,7 +50,7 @@ if (!$oids) { $data = trim($data); list($if_ipv6addr,$ipv6_prefixlen) = explode(" ", $data); - list($ifIndex,$ipv6addr) = split("\\.",$if_ipv6addr,2); + list($ifIndex,$ipv6addr) = explode("\\.",$if_ipv6addr,2); $ipv6_address = snmp2ipv6($ipv6addr); $ipv6_origin = snmp_get($device, "IPV6-MIB::ipv6AddrType.$if_ipv6addr", "-Ovq", "IPV6-MIB"); discover_process_ipv6($ifIndex,$ipv6_address,$ipv6_prefixlen,$ipv6_origin); diff --git a/includes/discovery/q-bridge-mib.inc.php b/includes/discovery/q-bridge-mib.inc.php index 0f966a2971..ac1181c525 100644 --- a/includes/discovery/q-bridge-mib.inc.php +++ b/includes/discovery/q-bridge-mib.inc.php @@ -12,7 +12,7 @@ if ($vlanversion == 'version1') foreach (explode("\n", $vlans) as $vlan_oid) { - list($oid,$vlan_index) = split(' ',$vlan_oid); + list($oid,$vlan_index) = explode(' ',$vlan_oid); $oid_ex = explode('.',$oid); $vlan = $oid_ex[count($oid_ex)-1]; diff --git a/includes/functions.php b/includes/functions.php index 99cc80e988..6a4c68a1a6 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -129,7 +129,7 @@ function getImage($host) if ($type == "linux") { $features = strtolower(trim($data['features'])); - list($distro) = split(" ", $features); + list($distro) = explode(" ", $features); if (file_exists($config['html_dir'] . "/images/os/$distro" . ".png")){ $image = ''; } elseif (file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")){ $image = ''; } } diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index ccad3e1d98..e81bf34bac 100755 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -40,7 +40,7 @@ else $peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6"; foreach (explode("\n",trim(`$peer_cmd`)) as $oid) { - list($peer_oid) = split(' ',$oid); + list($peer_oid) = explode(' ',$oid); $peer_id = explode('.',$peer_oid); $junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18)); } diff --git a/includes/polling/os/aos.inc.php b/includes/polling/os/aos.inc.php index 3d287ce6e2..2af525b0ea 100755 --- a/includes/polling/os/aos.inc.php +++ b/includes/polling/os/aos.inc.php @@ -1,5 +1,5 @@ diff --git a/includes/polling/os/cat1900.inc.php b/includes/polling/os/cat1900.inc.php index b78a7f71ae..7451c6a532 100755 --- a/includes/polling/os/cat1900.inc.php +++ b/includes/polling/os/cat1900.inc.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/includes/polling/os/dell-laser.inc.php b/includes/polling/os/dell-laser.inc.php index c2a4bc9b9d..94b0027b5c 100644 --- a/includes/polling/os/dell-laser.inc.php +++ b/includes/polling/os/dell-laser.inc.php @@ -13,7 +13,7 @@ foreach ($dellinfo as $dellinf) $hardware = $dell_laser['MDL']; -list(,$version) = split('Engine ',$sysDescr); +list(,$version) = explode('Engine ',$sysDescr); $version = "Engine " . trim($version,')'); diff --git a/includes/polling/os/unix.inc.php b/includes/polling/os/unix.inc.php index 07509b8c3d..9c0c738ebe 100755 --- a/includes/polling/os/unix.inc.php +++ b/includes/polling/os/unix.inc.php @@ -56,7 +56,7 @@ elseif ($device['os'] == "openbsd" || $device['os'] == "solaris" || $device['os' } elseif ($device['os'] == "monowall" || $device['os'] == "Voswall") { - list(,,$version,$hardware,$freebsda, $freebsdb, $arch) = split(" ", $sysDescr); + list(,,$version,$hardware,$freebsda, $freebsdb, $arch) = explode(" ", $sysDescr); $features = $freebsda . " " . $freebsdb; $hardware = "$hardware ($arch)"; $hardware = str_replace("\"", "", $hardware); diff --git a/includes/syslog.php b/includes/syslog.php index 1c8f05c554..34ba79c7e5 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -41,7 +41,7 @@ function process_syslog ($entry, $update) if (strstr($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'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']); }