From 8aabf022b6b303d9b11ce2e029f238da9c5f303d Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 15 Jun 2009 16:58:29 -0400 Subject: Handle case of no ipsec tunnels (clear foreach() error) --- config/lcdproc/lcdproc_client.php | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'config') diff --git a/config/lcdproc/lcdproc_client.php b/config/lcdproc/lcdproc_client.php index e391f2ce..b39f6e01 100644 --- a/config/lcdproc/lcdproc_client.php +++ b/config/lcdproc/lcdproc_client.php @@ -258,29 +258,31 @@ $activecounter = 0; $inactivecounter = 0; - - foreach ($config['ipsec']['tunnel'] as $tunnel){ - $ipsecstatus = false; - $tun_disabled = "false"; - $foundsrc = false; - $founddst = false; + if($config['ipsec']['tunnel']) { + foreach ($config['ipsec']['tunnel'] as $tunnel){ + $ipsecstatus = false; + + $tun_disabled = "false"; + $foundsrc = false; + $founddst = false; - if (isset($tunnel['disabled'])) { - $tun_disabled = "true"; - continue; - } + if (isset($tunnel['disabled'])) { + $tun_disabled = "true"; + continue; + } - if(output_ipsec_tunnel_status($tunnel)) { - /* tunnel is up */ - $iconfn = "true"; - $activecounter++; - } else { - /* tunnel is down */ - $iconfn = "false"; - $inactivecounter++; - } + if(output_ipsec_tunnel_status($tunnel)) { + /* tunnel is up */ + $iconfn = "true"; + $activecounter++; + } else { + /* tunnel is down */ + $iconfn = "false"; + $inactivecounter++; + } + } } if (is_array($config['ipsec']['tunnel'])) { -- cgit v1.2.3