diff options
author | Phil Davis <phil.davis@inf.org> | 2015-05-31 10:55:20 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-05-31 10:55:20 +0545 |
commit | 086cf944580b3a62a7c0e5dcbd2b92115cfb1334 (patch) | |
tree | 5043b938bdfd715daf231bfa3825d0b51c8c16f3 | |
parent | 5be3060472b257e0f171669b91d4e407960463e6 (diff) | |
download | pfsense-086cf944580b3a62a7c0e5dcbd2b92115cfb1334.zip pfsense-086cf944580b3a62a7c0e5dcbd2b92115cfb1334.tar.gz |
Code style bits and pieces from etc
47 files changed, 378 insertions, 364 deletions
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index ee32c2b..0a2cbfa 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -293,7 +293,7 @@ function get_user_privileges(& $user) { foreach ($names as $name) { $group = getGroupEntry($name); if (is_array($group['priv'])) { - $privs = array_merge( $privs, $group['priv']); + $privs = array_merge($privs, $group['priv']); } } @@ -353,7 +353,7 @@ function local_sync_accounts() { $fd = popen("/usr/sbin/pw usershow -a", "r"); if ($fd) { while (!feof($fd)) { - $line = explode(":",fgets($fd)); + $line = explode(":", fgets($fd)); if (((!strncmp($line[0], "_", 1)) || ($line[2] < 2000) || ($line[2] > 65000)) && ($line[0] != "admin")) { continue; } @@ -376,7 +376,7 @@ function local_sync_accounts() { $fd = popen("/usr/sbin/pw groupshow -a", "r"); if ($fd) { while (!feof($fd)) { - $line = explode(":",fgets($fd)); + $line = explode(":", fgets($fd)); if (!strncmp($line[0], "_", 1)) { continue; } @@ -572,7 +572,7 @@ function local_user_set_password(& $user, $password) { $ustr = ''; for ($i = 0; $i < strlen($astr); $i++) { $a = ord($astr{$i}) << 8; - $ustr.= sprintf("%X", $a); + $ustr .= sprintf("%X", $a); } // Generate the NT-HASH from the unicode string @@ -588,7 +588,7 @@ function local_user_get_groups($user, $all = false) { } foreach ($config['system']['group'] as $group) { - if ( $all || ( !$all && ($group['name'] != "all"))) { + if ($all || (!$all && ($group['name'] != "all"))) { if (is_array($group['member'])) { if (in_array($user['uid'], $group['member'])) { $groups[] = $group['name']; @@ -607,7 +607,7 @@ function local_user_get_groups($user, $all = false) { } -function local_user_set_groups($user, $new_groups = NULL ) { +function local_user_set_groups($user, $new_groups = NULL) { global $debug, $config, $groupindex; if (!is_array($config['system']['group'])) { @@ -627,7 +627,7 @@ function local_user_set_groups($user, $new_groups = NULL ) { /* determine which memberships to add */ foreach ($new_groups as $groupname) { - if ($groupname == '' || in_array($groupname,$cur_groups)) { + if ($groupname == '' || in_array($groupname, $cur_groups)) { continue; } $group = & $config['system']['group'][$groupindex[$groupname]]; @@ -638,7 +638,7 @@ function local_user_set_groups($user, $new_groups = NULL ) { /* determine which memberships to remove */ foreach ($cur_groups as $groupname) { - if (in_array($groupname,$new_groups)) { + if (in_array($groupname, $new_groups)) { continue; } if (!isset($config['system']['group'][$groupindex[$groupname]])) { @@ -684,7 +684,7 @@ function local_group_set($group, $reset = false) { $group_gid = $group['gid']; $group_members = ''; if (!$reset && !empty($group['member']) && count($group['member']) > 0) { - $group_members = implode(",",$group['member']); + $group_members = implode(",", $group['member']); } if (empty($group_name)) { @@ -747,7 +747,7 @@ function ldap_test_connection($authcfg) { } /* first check if there is even an LDAP server populated */ - if ( !$ldapserver) { + if (!$ldapserver) { return false; } @@ -956,8 +956,8 @@ function ldap_get_user_ous($show_complete_ou=true, $authcfg) { if (!$show_complete_ou) { $inf_split = explode(",", $inf['dn']); $ou = $inf_split[0]; - $ou = str_replace("OU=","", $ou); - $ou = str_replace("CN=","", $ou); + $ou = str_replace("OU=", "", $ou); + $ou = str_replace("CN=", "", $ou); } else { if ($inf['dn']) { $ou = $inf['dn']; @@ -1095,7 +1095,7 @@ function ldap_get_groups($username, $authcfg) { /* Time to close LDAP connection */ @ldap_unbind($ldap); - $groups = print_r($memberof,true); + $groups = print_r($memberof, true); //log_error("Returning groups ".$groups." for user $username"); @@ -1214,7 +1214,7 @@ function ldap_backed($username, $passwd, $authcfg) { /* Get LDAP Authcontainers and split em up. */ $ldac_splits = explode(";", $ldapauthcont); - /* setup the usercount so we think we havn't found anyone yet */ + /* setup the usercount so we think we haven't found anyone yet */ $usercount = 0; /*****************************************************************/ @@ -1251,7 +1251,7 @@ function ldap_backed($username, $passwd, $authcfg) { log_error(sprintf(gettext("Search resulted in error: %s"), ldap_error($ldap))); continue; } - $info = ldap_get_entries($ldap,$search); + $info = ldap_get_entries($ldap, $search); $matches = $info['count']; if ($matches == 1) { $userdn = $_SESSION['ldapdn'] = $info[0]['dn']; @@ -1360,7 +1360,7 @@ function get_user_expiration_date($username) { function is_account_expired($username) { $expirydate = get_user_expiration_date($username); if ($expirydate) { - if (strtotime("-1 day") > strtotime(date("m/d/Y",strtotime($expirydate)))) { + if (strtotime("-1 day") > strtotime(date("m/d/Y", strtotime($expirydate)))) { return true; } } @@ -1404,7 +1404,7 @@ function auth_get_authserver_list() { } } - $list["Local Database"] = array( "name" => gettext("Local Database"), "type" => "Local Auth", "host" => $config['system']['hostname']); + $list["Local Database"] = array("name" => gettext("Local Database"), "type" => "Local Auth", "host" => $config['system']['hostname']); return $list; } diff --git a/etc/inc/authgui.inc b/etc/inc/authgui.inc index 7a35800..2c4aea0 100644 --- a/etc/inc/authgui.inc +++ b/etc/inc/authgui.inc @@ -319,8 +319,9 @@ if ($local_ip == false) { "cookie_test=1" + "<?php echo $config['system']['webgui']['protocol'] == 'https' ? '; secure' : '';?>"; - if (document.cookie.indexOf("cookie_test") == -1) + if (document.cookie.indexOf("cookie_test") == -1) { document.getElementById("no_cookies").style.display=""; + } // Delete it document.cookie = "cookie_test=1; expires=Thu, 01-Jan-1970 00:00:01 GMT"; diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 62cfb97..0d46fec 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -733,7 +733,7 @@ function captiveportal_prune_old() { } if ($timedout) { - captiveportal_disconnect($cpentry, $radiusservers,$term_cause,$stop_time); + captiveportal_disconnect($cpentry, $radiusservers, $term_cause, $stop_time); captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "TIMEOUT"); $unsetindexes[] = $cpentry[5]; } @@ -884,7 +884,7 @@ function captiveportal_prune_old_automac() { } /* remove a single client according to the DB entry */ -function captiveportal_disconnect($dbent, $radiusservers,$term_cause = 1,$stop_time = null) { +function captiveportal_disconnect($dbent, $radiusservers, $term_cause = 1, $stop_time = null) { global $g, $config, $cpzone, $cpzoneid; $stop_time = (empty($stop_time)) ? time() : $stop_time; @@ -1223,7 +1223,7 @@ function captiveportal_get_last_activity($ip, $mac = NULL, $table = 1) { /* Reading only from one of the tables is enough of approximation. */ if (is_array($ipfwoutput)) { /* Workaround for #46652 */ - if ($ipfwoutput['packets'] > 0) { + if ($ipfwoutput['packets'] > 0) { return $ipfwoutput['timestamp']; } else { return 0; @@ -1283,16 +1283,16 @@ function captiveportal_init_radius_servers() { return 1; } if (isset($radiusip)) { - fwrite($fd,$radiusip . "," . $radiusport . "," . $radiusacctport . "," . $radiuskey . ",first"); + fwrite($fd, $radiusip . "," . $radiusport . "," . $radiusacctport . "," . $radiuskey . ",first"); } if (isset($radiusip2)) { - fwrite($fd,"\n" . $radiusip2 . "," . $radiusport2 . "," . $radiusacctport . "," . $radiuskey2 . ",first"); + fwrite($fd, "\n" . $radiusip2 . "," . $radiusport2 . "," . $radiusacctport . "," . $radiuskey2 . ",first"); } if (isset($radiusip3)) { - fwrite($fd,"\n" . $radiusip3 . "," . $radiusport3 . "," . $radiusacctport . "," . $radiuskey3 . ",second"); + fwrite($fd, "\n" . $radiusip3 . "," . $radiusport3 . "," . $radiusacctport . "," . $radiuskey3 . ",second"); } if (isset($radiusip4)) { - fwrite($fd,"\n" . $radiusip4 . "," . $radiusport4 . "," . $radiusacctport . "," . $radiuskey4 . ",second"); + fwrite($fd, "\n" . $radiusip4 . "," . $radiusport4 . "," . $radiusacctport . "," . $radiuskey4 . ",second"); } fclose($fd); @@ -1314,7 +1314,7 @@ function captiveportal_get_radius_servers() { $line = trim($cpradiusentry); if ($line) { $radsrv = array(); - list($radsrv['ipaddr'],$radsrv['port'],$radsrv['acctport'],$radsrv['key'], $context) = explode(",",$line); + list($radsrv['ipaddr'], $radsrv['port'], $radsrv['acctport'], $radsrv['key'], $context) = explode(",", $line); } if (empty($context)) { if (!is_array($radiusservers['first'])) { @@ -1339,7 +1339,7 @@ function captiveportal_get_radius_servers() { /* log successful captive portal authentication to syslog */ /* part of this code from php.net */ -function captiveportal_logportalauth($user,$mac,$ip,$status, $message = null) { +function captiveportal_logportalauth($user, $mac, $ip, $status, $message = null) { // Log it if (!$message) { $message = "{$status}: {$user}, {$mac}, {$ip}"; @@ -1362,7 +1362,7 @@ function captiveportal_syslog($message) { closelog(); } -function radius($username,$password,$clientip,$clientmac,$type, $radiusctx = null) { +function radius($username, $password, $clientip, $clientmac, $type, $radiusctx = null) { global $g, $config, $cpzoneid; $pipeno = captiveportal_get_next_dn_ruleno(); @@ -1389,7 +1389,7 @@ function radius($username,$password,$clientip,$clientmac,$type, $radiusctx = nul $pipeno); if ($auth_list['auth_val'] == 2) { - captiveportal_logportalauth($username,$clientmac,$clientip,$type); + captiveportal_logportalauth($username, $clientmac, $clientip, $type); $sessionid = portal_allow($clientip, $clientmac, $username, @@ -1750,8 +1750,7 @@ function getVolume($ip, $mac = NULL) { * */ -function getNasIP() -{ +function getNasIP() { global $config, $cpzone; if (empty($config['captiveportal'][$cpzone]['radiussrcip_attribute'])) { @@ -1891,14 +1890,14 @@ function portal_reply_page($redirurl, $type = null, $message = null, $clientmac echo $htmltext; } -function portal_mac_radius($clientmac,$clientip) { +function portal_mac_radius($clientmac, $clientip) { global $config, $cpzone; $radmac_secret = $config['captiveportal'][$cpzone]['radmac_secret']; /* authentication against the radius server */ $username = mac_format($clientmac); - $auth_list = radius($username,$radmac_secret,$clientip,$clientmac,"MACHINE LOGIN"); + $auth_list = radius($username, $radmac_secret, $clientip, $clientmac, "MACHINE LOGIN"); if ($auth_list['auth_val'] == 2) { return TRUE; } @@ -1931,7 +1930,7 @@ function captiveportal_reapply_attributes($cpentry, $attributes) { unset($bw_up_pipeno, $bw_down_pipeno, $bw_up, $bw_down); } -function portal_allow($clientip,$clientmac,$username,$password = null, $attributes = null, $pipeno = null, $radiusctx = null) { +function portal_allow($clientip, $clientmac, $username, $password = null, $attributes = null, $pipeno = null, $radiusctx = null) { global $redirurl, $g, $config, $type, $passthrumac, $_POST, $cpzone, $cpzoneid; // Ensure we create an array if we are missing attributes @@ -2017,9 +2016,9 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut /* on the same ip */ if ($cpentry[2] == $clientip) { if (isset($config['captiveportal'][$cpzone]['nomacfilter']) || $cpentry[3] == $clientmac) { - captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - REUSING OLD SESSION"); + captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "CONCURRENT LOGIN - REUSING OLD SESSION"); } else { - captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - REUSING IP {$cpentry[2]} WITH DIFFERENT MAC ADDRESS {$cpentry[3]}"); + captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "CONCURRENT LOGIN - REUSING IP {$cpentry[2]} WITH DIFFERENT MAC ADDRESS {$cpentry[3]}"); } $sessionid = $cpentry[5]; break; @@ -2032,16 +2031,16 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut } /* This user was already logged in so we disconnect the old one */ - captiveportal_disconnect($cpentry,$radiusservers[$cpentry[11]],13); - captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - TERMINATING OLD SESSION"); + captiveportal_disconnect($cpentry, $radiusservers[$cpentry[11]], 13); + captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "CONCURRENT LOGIN - TERMINATING OLD SESSION"); $unsetindexes[] = $cpentry[5]; break; } elseif ((isset($config['captiveportal'][$cpzone]['noconcurrentlogins'])) && ($username != 'unauthenticated')) { /* on the same username */ if (strcasecmp($cpentry[4], $username) == 0) { /* This user was already logged in so we disconnect the old one */ - captiveportal_disconnect($cpentry,$radiusservers[$cpentry[11]],13); - captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"CONCURRENT LOGIN - TERMINATING OLD SESSION"); + captiveportal_disconnect($cpentry, $radiusservers[$cpentry[11]], 13); + captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "CONCURRENT LOGIN - TERMINATING OLD SESSION"); $unsetindexes[] = $cpentry[5]; break; } @@ -2162,7 +2161,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut if (isset($config['captiveportal'][$cpzone]['radacct_enable']) && !empty($radiusservers[$radiusctx])) { $acct_val = RADIUS_ACCOUNTING_START($pipeno, $username, $sessionid, $radiusservers[$radiusctx], $clientip, $clientmac); if ($acct_val == 1) { - captiveportal_logportalauth($username,$clientmac,$clientip,$type,"RADIUS ACCOUNTING FAILED"); + captiveportal_logportalauth($username, $clientmac, $clientip, $type, "RADIUS ACCOUNTING FAILED"); } } } diff --git a/etc/inc/certs.inc b/etc/inc/certs.inc index 0bdc1fc..75f9fd9 100644 --- a/etc/inc/certs.inc +++ b/etc/inc/certs.inc @@ -178,7 +178,7 @@ function ca_import(& $ca, $str, $key="", $serial=0) { if (is_array($config['ca'])) { foreach ($config['ca'] as & $oca) { $issuer = cert_get_issuer($oca['crt']); - if ($ca['refid']<>$oca['refid'] && $issuer==$subject) { + if ($ca['refid'] <> $oca['refid'] && $issuer == $subject) { $oca['caref'] = $ca['refid']; } } @@ -186,7 +186,7 @@ function ca_import(& $ca, $str, $key="", $serial=0) { if (is_array($config['cert'])) { foreach ($config['cert'] as & $cert) { $issuer = cert_get_issuer($cert['crt']); - if ($issuer==$subject) { + if ($issuer == $subject) { $cert['caref'] = $ca['refid']; } } @@ -554,8 +554,8 @@ function cert_get_modulus($str_crt, $decode = true, $type = "crt") { } $modulus = ""; - if ( in_array($type, array("crt", "prv", "csr")) ) { - $type = str_replace( array("crt","prv","csr"), array("x509","rsa","req"), $type); + if (in_array($type, array("crt", "prv", "csr"))) { + $type = str_replace(array("crt", "prv", "csr"), array("x509", "rsa", "req"), $type); $modulus = exec("echo \"{$str_crt}\" | openssl {$type} -noout -modulus"); } return $modulus; diff --git a/etc/inc/config.inc b/etc/inc/config.inc index 5f95f06..4792ac3 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -59,9 +59,9 @@ if (!$ARCH) { // Set memory limit to 256M on amd64. if ($ARCH == "amd64") { - ini_set("memory_limit","256M"); + ini_set("memory_limit", "256M"); } else { - ini_set("memory_limit","128M"); + ini_set("memory_limit", "128M"); } /* include globals from notices.inc /utility/XML parser files */ @@ -98,7 +98,7 @@ if (platform_booting(true)) { echo "."; /* user has just upgraded from m0n0wall, replace root xml tags */ log_error(gettext("Upgrading m0n0wall configuration to pfSense... ")); - $config_contents = str_replace("m0n0wall","pfsense", $config_contents); + $config_contents = str_replace("m0n0wall", "pfsense", $config_contents); if (!config_validate("{$g['conf_path']}/config.xml")) { log_error(gettext("ERROR! Could not convert m0n0wall -> pfsense in config.xml")); } @@ -109,7 +109,7 @@ if (platform_booting(true)) { unset($config_contents); } /* if our config file exists bail out, we're already set. */ - else if (!file_exists($g['cf_conf_path'] . "/config.xml") ) { + else if (!file_exists($g['cf_conf_path'] . "/config.xml")) { echo "."; /* find the device where config.xml resides and write out an fstab */ unset($cfgdevice); diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index 81cced6..ff0430e 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -114,8 +114,9 @@ function parse_config($parse = false) { } } - if (platform_booting(true)) + if (platform_booting(true)) { echo "."; + } // Check for encrypted config.xml encrypted_configxml(); @@ -216,7 +217,7 @@ function restore_backup($file) { if (file_exists($file)) { conf_mount_rw(); unlink_if_exists("{$g['tmp_path']}/config.cache"); - copy("$file","/cf/conf/config.xml"); + copy("$file", "/cf/conf/config.xml"); disable_security_checks(); log_error(sprintf(gettext('%1$s is restoring the configuration %2$s'), $g['product_name'], $file)); file_notice("config.xml", sprintf(gettext('%1$s is restoring the configuration %2$s'), $g['product_name'], $file), "pfSenseConfigurator", ""); @@ -407,9 +408,9 @@ function convert_config() { /* fix every minute crontab bogons entry */ if (is_array($config['cron'])) { $cron_item_count = count($config['cron']['item']); - for($x=0; $x<$cron_item_count; $x++) { + for ($x = 0; $x < $cron_item_count; $x++) { if (stristr($config['cron']['item'][$x]['command'], "rc.update_bogons.sh")) { - if ($config['cron']['item'][$x]['hour'] == "*" ) { + if ($config['cron']['item'][$x]['hour'] == "*") { $config['cron']['item'][$x]['hour'] = "3"; write_config(gettext("Updated bogon update frequency to 3am")); log_error(gettext("Updated bogon update frequency to 3am")); diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class index 5656708..b23f6e2 100644 --- a/etc/inc/dyndns.class +++ b/etc/inc/dyndns.class @@ -555,7 +555,7 @@ log_error("HE.net ({$this->_dnsHost}): DNS update() starting."); } $server = "https://dyn.dns.he.net/nic/update?"; - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_URL, $server . 'hostname=' . $this->_dnsHost . '&password=' . $this->_dnsPass . '&myip=' . $this->_dnsIP); break; @@ -653,7 +653,7 @@ if (strstr($this->dnsUpdateURL, "%IP%")) {$needsIP = TRUE;} else {$needsIP = FALSE;} if ($this->_dnsUser != '') { if ($this->_curlIpresolveV4) { - curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); } if ($this->_curlSslVerifypeer) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); @@ -672,7 +672,7 @@ case 'cloudflare': $needsIP = TRUE; $dnsServer ='www.cloudflare.com'; - $dnsHost = str_replace(' ','', $this->_dnsHost); + $dnsHost = str_replace(' ', '', $this->_dnsHost); $URL = "https://{$dnsServer}/api.html?a=DIUP&email={$this->_dnsUser}&tkn={$this->_dnsPass}&ip={$this->_dnsIP}&hosts={$dnsHost}"; curl_setopt($ch, CURLOPT_URL, $URL); break; @@ -742,7 +742,7 @@ $jsondata = '{"record":{"content":"' . $this->_dnsIP . '","ttl":"' . $this->_dnsTTL . '"}}'; curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json','X-DNSimple-Token: ' . $token)); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json', 'X-DNSimple-Token: ' . $token)); curl_setopt($ch, CURLOPT_URL, $server . $this->_dnsHost . '/records/' . $this->_dnsZoneID); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata); break; @@ -798,7 +798,7 @@ switch ($this->_dnsService) { case 'glesys': if (preg_match('/Record updated/i', $data)) { - $status = "GleSYS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "GleSYS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else { $status = "GleSYS ({$this->_dnsHost}): (Unknown Response)"; @@ -818,7 +818,7 @@ } else if (preg_match('/abuse/i', $data)) { $status = "DNS-O-Matic ({$this->_dnsHost}): The hostname is blocked for update abuse."; } else if (preg_match('/good/i', $data)) { - $status = "DNS-O-Matic ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "DNS-O-Matic ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/dnserr/i', $data)) { $status = "DNS-O-Matic ({$this->_dnsHost}): DNS error encountered. Stop updating for 30 minutes."; @@ -837,7 +837,7 @@ $status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address"; $successful_update = true; } else if (preg_match('/good/i', $data)) { - $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/badauth/i', $data)) { $status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed"; @@ -855,7 +855,7 @@ $status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address"; $successful_update = true; } else if (preg_match('/good/i', $data)) { - $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/noauth/i', $data)) { $status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed"; @@ -903,7 +903,7 @@ break; case 'noip': case 'noip-free': - list($ip,$code) = explode(":",$data); + list($ip, $code) = explode(":", $data); switch ($code) { case 0: $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP address is current, no update performed."; @@ -1080,7 +1080,7 @@ $status = "phpDynDNS ({$this->_dnsHost}): (Error) Hostname you are trying to update does not exist."; $successful_update = true; } else if (preg_match('/good/i', $data)) { - $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/yours/i', $data)) { $status = "phpDynDNS ({$this->_dnsHost}): (Error) hostname specified exists, but not under the username specified."; @@ -1190,7 +1190,7 @@ $status = "phpDynDNS: (Success) No Change In IP Address"; $successful_update = true; } else if (preg_match('/good/i', $data)) { - $status = "phpDynDNS: (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS: (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/noauth/i', $data)) { $status = "phpDynDNS: (Error) User Authorization Failed"; @@ -1227,7 +1227,7 @@ break; case 'cloudflare': // receive multiple results - $data = explode("\n",$data); + $data = explode("\n", $data); $lines = count($data)-1; // loop over the lines @@ -1244,10 +1244,10 @@ } else if (preg_match('/DUPHST/i', $resp)) { $status = "DynDNS: Duplicate values exist for a record. Only single values for records are supported currently."; } else if (preg_match('/NOUPDATE/i', $resp)) { - $status = "DynDNS: No changes made to the hostname (".strtok($resp,' ')."). Continual updates with no changes lead to blocked clients."; + $status = "DynDNS: No changes made to the hostname (" . strtok($resp, ' ') . "). Continual updates with no changes lead to blocked clients."; $successful_update = true; //success if it is the same so that it saves } else if (preg_match('/OK/i', $resp)) { - $status = "DynDNS: (Success) (".strtok($resp,' ').") IP Address for Changed Successfully!"; + $status = "DynDNS: (Success) (" . strtok($resp, ' ') . ") IP Address for Changed Successfully!"; $successful_update = true; } else { $status = "DynDNS: (Unknown Response)"; @@ -1264,7 +1264,7 @@ $status = "phpDynDNS: (Success) No Change In IP Address"; $successful_update = true; } else if (preg_match('/good/i', $data)) { - $status = "phpDynDNS: (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS: (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/badauth/i', $data)) { $status = "phpDynDNS: (Error) User Authorization Failed"; @@ -1324,7 +1324,7 @@ $status = "phpDynDNS ({$this->_dnsHost}): (Success) No Change In IP Address"; $successful_update = true; } else if (preg_match('/good/i', $data)) { - $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS ({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; } else if (preg_match('/badauth/i', $data)) { $status = "phpDynDNS ({$this->_dnsHost}): (Error) User Authorization Failed"; @@ -1345,7 +1345,7 @@ case 'dnsmadeeasy': switch ($data) { case 'success': - $status = "phpDynDNS({$this->_dnsHost}): (Success) IP Address Changed Successfully! (".$this->_dnsIP.")"; + $status = "phpDynDNS({$this->_dnsHost}): (Success) IP Address Changed Successfully! (" . $this->_dnsIP . ")"; $successful_update = true; break; case 'error-auth': @@ -1478,7 +1478,7 @@ if ($this->_useIPv6 == true) { if (file_exists($this->_cacheFile_v6)) { $contents = file_get_contents($this->_cacheFile_v6); - list($cacheIP,$cacheTime) = explode('|', $contents); + list($cacheIP, $cacheTime) = explode('|', $contents); $this->_debug($cacheIP.'/'.$cacheTime); $initial = false; $log_error .= "Cached IPv6: {$cacheIP} "; @@ -1494,7 +1494,7 @@ } else { if (file_exists($this->_cacheFile)) { $contents = file_get_contents($this->_cacheFile); - list($cacheIP,$cacheTime) = explode(':', $contents); + list($cacheIP, $cacheTime) = explode(':', $contents); $this->_debug($cacheIP.'/'.$cacheTime); $initial = false; $log_error .= "Cached IP: {$cacheIP} "; @@ -1537,8 +1537,9 @@ * new cache value and return true */ if ($needs_updating == true) { - if ($this->_dnsVerboseLog) + if ($this->_dnsVerboseLog) { log_error("DynDns ({$this->_dnsHost}): {$update_reason}"); + } return true; } diff --git a/etc/inc/easyrule.inc b/etc/inc/easyrule.inc index e849aae..c46e84d 100644 --- a/etc/inc/easyrule.inc +++ b/etc/inc/easyrule.inc @@ -56,7 +56,7 @@ function easyrule_find_rule_interface($int) { } /* add ipsec interfaces */ - if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])){ + if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { $iflist["enc0"] = "IPSEC"; } @@ -407,7 +407,7 @@ function easyrule_parse_unblock($int, $host, $ipproto = "inet") { $a_address = explode(" ", $config['aliases']['alias'][$id]['address']); $a_detail = explode("||", $config['aliases']['alias'][$id]['detail']); - if(($key = array_search($unblock, $a_address)) !== false) { + if (($key = array_search($unblock, $a_address)) !== false) { unset($a_address[$key]); unset($a_detail[$key]); // Write back the result to the config array diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index c4f7cd5..b4407d5 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -131,7 +131,7 @@ function filter_rule_tracker($tracker) { function filter_negaterule_tracker() { global $tracker; - + ++$negate_tracker; return "tracker {$negate_tracker} "; } @@ -669,8 +669,7 @@ function filter_generate_nested_alias($name, $alias, &$aliasnesting, &$aliasaddr return $finallist; } -function filter_expand_alias($alias_name) -{ +function filter_expand_alias($alias_name) { global $config; if (isset($config['aliases']['alias'])) { @@ -1599,7 +1598,7 @@ function filter_nat_rules_automatic_tonathosts($with_descr = false) { } /* PPTP subnet */ - if (($config['pptpd']['mode'] == "server" ) && is_private_ip($config['pptpd']['remoteip'])) { + if (($config['pptpd']['mode'] == "server") && is_private_ip($config['pptpd']['remoteip'])) { if (isset($config['pptpd']['n_pptp_units']) && is_numeric($config['pptpd']['n_pptp_units'])) { $pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip'])+($config['pptpd']['n_pptp_units']-1))); @@ -1961,7 +1960,7 @@ function filter_nat_rules_generate() { if ($remote_subnet == "0.0.0.0/0") { $remote_subnet = "any"; } - if (is_ipaddr($natlocal_subnet) && !is_ipaddr($local_subnet) ) { + if (is_ipaddr($natlocal_subnet) && !is_ipaddr($local_subnet)) { $nattype = "nat"; } else { list($natnet, $natmask) = explode('/', $natlocal_subnet); @@ -2095,7 +2094,7 @@ function filter_nat_rules_generate() { @unlink("/var/etc/inetd.conf"); } // Open inetd.conf write handle - $inetd_fd = fopen("/var/etc/inetd.conf","w"); + $inetd_fd = fopen("/var/etc/inetd.conf", "w"); /* add tftp protocol helper */ fwrite($inetd_fd, "tftp-proxy\tdgram\tudp\twait\t\troot\t/usr/libexec/tftp-proxy\ttftp-proxy -v\n"); @@ -2211,14 +2210,14 @@ function filter_nat_rules_generate() { if (isset($rule['destination']['any'])) { /* With reflection enabled, destination of 'any' has side effects * that most people would not expect, so change it on reflection rules. */ - + if (!empty($FilterIflist[$natif]['ip'])) { $dstaddr_reflect = $FilterIflist[$natif]['ip']; } else { // no IP, bail continue; } - + if (!empty($FilterIflist[$natif]['sn'])) { $dstaddr_reflect = gen_subnet($dstaddr_reflect, $FilterIflist[$natif]['sn']) . '/' . $FilterIflist[$natif]['sn']; } @@ -2358,7 +2357,7 @@ function filter_generate_port(& $rule, $target = "source", $isnat = false) { $src = ""; $rule['protocol'] = strtolower($rule['protocol']); - if (in_array($rule['protocol'], array("tcp","udp","tcp/udp"))) { + if (in_array($rule['protocol'], array("tcp", "udp", "tcp/udp"))) { if ($rule[$target]['port']) { $srcport = explode("-", $rule[$target]['port']); $srcporta = alias_expand($srcport[0]); @@ -2599,8 +2598,9 @@ function filter_generate_address(& $rule, $target = "source", $isnat = false) { $src = " {$not} {$expsrc}"; } - if (empty($src)) + if (empty($src)) { return ''; + } $src .= filter_generate_port($rule, $target, $isnat); @@ -2639,8 +2639,9 @@ function filter_generate_user_rule($rule) { } else { $aline['interface'] = ""; } - } else + } else { $aline['interface'] = ""; + } } else if (!array_key_exists($rule['interface'], $FilterIflist)) { foreach ($FilterIflist as $oc) { $items .= $oc['descr'] . " "; @@ -2932,7 +2933,7 @@ function filter_generate_user_rule($rule) { (isset($rule['max']) and $rule['max'] <> "") or (isset($rule['max-src-nodes']) and $rule['max-src-nodes'] <> "") or (isset($rule['max-src-states']) and $rule['max-src-states'] <> "") or - ((in_array($rule['protocol'], array("tcp","tcp/udp"))) and + ((in_array($rule['protocol'], array("tcp", "tcp/udp"))) and ((isset($rule['statetimeout']) and $rule['statetimeout'] <> "") or (isset($rule['max-src-conn']) and $rule['max-src-conn'] <> "") or (isset($rule['max-src-conn-rate']) and $rule['max-src-conn-rate'] <> "") or @@ -2956,7 +2957,7 @@ function filter_generate_user_rule($rule) { if (isset($rule['max-src-nodes']) and $rule['max-src-nodes'] <> "") { $aline['flags'] .= "max-src-nodes " . $rule['max-src-nodes'] . " "; } - if ((in_array($rule['protocol'], array("tcp","tcp/udp"))) and + if ((in_array($rule['protocol'], array("tcp", "tcp/udp"))) and (isset($rule['max-src-conn'])) and ($rule['max-src-conn'] <> "")) { $aline['flags'] .= "max-src-conn " . $rule['max-src-conn'] . " "; @@ -2964,12 +2965,12 @@ function filter_generate_user_rule($rule) { if (isset($rule['max-src-states']) and $rule['max-src-states'] <> "") { $aline['flags'] .= "max-src-states " . $rule['max-src-states'] . " "; } - if ((in_array($rule['protocol'], array("tcp","tcp/udp"))) and + if ((in_array($rule['protocol'], array("tcp", "tcp/udp"))) and (isset($rule['statetimeout'])) and ($rule['statetimeout'] <> "")) { $aline['flags'] .= "tcp.established " . $rule['statetimeout'] . " "; } - if ((in_array($rule['protocol'], array("tcp","tcp/udp"))) and + if ((in_array($rule['protocol'], array("tcp", "tcp/udp"))) and (isset($rule['max-src-conn-rate'])) and ($rule['max-src-conn-rate'] <> "") and (isset($rule['max-src-conn-rates'])) and @@ -2989,7 +2990,7 @@ function filter_generate_user_rule($rule) { if ($rule['defaultqueue'] <> "") { $aline['queue'] = " queue (".$rule['defaultqueue']; if ($rule['ackqueue'] <> "") { - $aline['queue'] .= ",".$rule['ackqueue']; + $aline['queue'] .= "," . $rule['ackqueue']; } $aline['queue'] .= ") "; } @@ -2997,9 +2998,9 @@ function filter_generate_user_rule($rule) { if (!empty($dummynet_name_list[$rule['dnpipe']])) { if ($dummynet_name_list[$rule['dnpipe']][0] == "?") { $aline['dnpipe'] = " dnqueue( "; - $aline['dnpipe'] .= substr($dummynet_name_list[$rule['dnpipe']],1); + $aline['dnpipe'] .= substr($dummynet_name_list[$rule['dnpipe']], 1); if ($rule['pdnpipe'] <> "") { - $aline['dnpipe'] .= ",".substr($dummynet_name_list[$rule['pdnpipe']], 1); + $aline['dnpipe'] .= "," . substr($dummynet_name_list[$rule['pdnpipe']], 1); } } else { $aline['dnpipe'] = " dnpipe ( " . $dummynet_name_list[$rule['dnpipe']]; @@ -3106,7 +3107,7 @@ function filter_rules_generate() { $saved_tracker += 100; $tracker = $saved_tracker; - + if (!isset($config['system']['no_apipa_block'])) { $ipfrules .= <<<EOD # block IPv4 link-local. Per RFC 3927, link local "MUST NOT" be forwarded by a routing device, @@ -3790,7 +3791,7 @@ function tdr_install_cron($should_install) { function filter_tdr_install_cron($should_install) { global $config, $g; - if (platform_booting()==true) { + if (platform_booting() == true) { return; } @@ -4132,7 +4133,7 @@ pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to EOD; /* If NAT-T is enabled, add additional rules */ - if ($ph1ent['nat_traversal'] != "off" ) { + if ($ph1ent['nat_traversal'] != "off") { $ipfrules .= <<<EOD pass out {$log['pass']} $route_to proto udp from any to {$rgip} port = 4500 tracker {$increment_tracker($tracker)} keep state label "IPsec: {$shorttunneldescr} - outbound nat-t" pass in {$log['pass']} on \${$FilterIflist[$parentinterface]['descr']} $reply_to proto udp from {$rgip} to any port = 4500 tracker {$increment_tracker($tracker)} keep state label "IPsec: {$shorttunneldescr} - inbound nat-t" diff --git a/etc/inc/filter_log.inc b/etc/inc/filter_log.inc index f4d9841..2276a1b 100644 --- a/etc/inc/filter_log.inc +++ b/etc/inc/filter_log.inc @@ -74,7 +74,7 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil $flent = parse_filter_line($logent); if (!$filterinterface || ($filterinterface == $flent['interface'])) { if ((($flent != "") && (!is_array($filtertext)) && (match_filter_line ($flent, $filtertext))) || - (($flent != "") && ( is_array($filtertext)) && (match_filter_field($flent, $filtertext)))) { + (($flent != "") && (is_array($filtertext)) && (match_filter_field($flent, $filtertext)))) { $counter++; $filterlog[] = $flent; } @@ -198,7 +198,7 @@ function parse_filter_line($line) { $flent['ack'] = $rule_data[$field++]; $flent['window'] = $rule_data[$field++]; $flent['urg'] = $rule_data[$field++]; - $flent['options'] = explode(";",$rule_data[$field++]); + $flent['options'] = explode(";", $rule_data[$field++]); } } else if ($flent['protoid'] == '1') { // ICMP $flent['src'] = $flent['srcip']; @@ -382,11 +382,11 @@ function find_rule_by_number_buffer($rulenum, $trackernum, $type) { if ($type == "rdr") { $ruleString = $buffer_rules_rdr[$lookup_key]; //TODO: get the correct 'description' part of a RDR log line. currently just first 30 characters.. - $rulename = substr($ruleString,0,30); + $rulename = substr($ruleString, 0, 30); } else { $ruleString = $buffer_rules_normal[$lookup_key]; - list(,$rulename,) = explode("\"",$ruleString); - $rulename = str_replace("USER_RULE: ",'<img src="/themes/'.$g['theme'].'/images/icons/icon_frmfld_user.png" width="11" height="12" title="USER_RULE" alt="USER_RULE"/> ',$rulename); + list(,$rulename,) = explode("\"", $ruleString); + $rulename = str_replace("USER_RULE: ", '<img src="/themes/' . $g['theme'] . '/images/icons/icon_frmfld_user.png" width="11" height="12" title="USER_RULE" alt="USER_RULE"/> ', $rulename); } return "{$rulename} ({$lookup_key})"; } @@ -406,7 +406,7 @@ function find_action_image($action) { function handle_ajax($nentries, $tail = 50) { global $config; if ($_GET['lastsawtime'] or $_POST['lastsawtime']) { - global $filter_logfile,$filterent; + global $filter_logfile, $filterent; if ($_GET['lastsawtime']) { $lastsawtime = $_GET['lastsawtime']; } diff --git a/etc/inc/functions.inc b/etc/inc/functions.inc index ab9b73d..0ccd845 100644 --- a/etc/inc/functions.inc +++ b/etc/inc/functions.inc @@ -78,7 +78,7 @@ if (!function_exists("pfSenseHeader")) { /*fetch menu notices function*/ if (!function_exists("get_menu_messages")) { function get_menu_messages() { - global $g,$config; + global $g, $config; if (are_notices_pending()) { $notices = get_notices(); $requests=array(); @@ -102,7 +102,7 @@ if (!function_exists("get_menu_messages")) { foreach ($notices as $key => $value) { $date = date("m-d-y H:i:s", $key); $noticemsg = ($value['notice'] != "" ? $value['notice'] : $value['id']); - $noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i","",$noticemsg); + $noticemsg = preg_replace("/(\"|\'|\n|<.?\w+>)/i", "", $noticemsg); if ((strlen($noticemsg)* 8) > $domtt_width) { $domtt_width=(strlen($noticemsg) *8); } @@ -116,32 +116,32 @@ if (!function_exists("get_menu_messages")) { $domtt= "onclick=\"domTT_activate(this, event, 'caption', '{$notice}','content', '<br />{$notice_msgs}', 'trail', false, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle','width','{$domtt_width}','y',5,'type', 'sticky');\""; $menu_messages="<div id='alerts'>\n"; - if (count($notices)==1) { - $msg= sprintf("%1$02d",count($notices))." ".gettext("unread notice"); + if (count($notices) == 1) { + $msg= sprintf("%1$02d", count($notices)) . " " . gettext("unread notice"); } else { - $msg= sprintf("%1$02d",count($notices))." ".gettext("unread notices"); + $msg= sprintf("%1$02d", count($notices)) . " " . gettext("unread notices"); } - $menu_messages.="<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n"; - $menu_messages.="</div>\n"; + $menu_messages .= "<div id='marquee-text' style='z-index:1001;'><a href='#' {$domtt}><b> .:. {$msg} .:. </b></a></div>\n"; + $menu_messages .= "</div>\n"; } } else { - $menu_messages='<div id="hostname">'; - $menu_messages.=$config['system']['hostname'] . "." . $config['system']['domain']; - $menu_messages.='</div>'; + $menu_messages = '<div id="hostname">'; + $menu_messages .= $config['system']['hostname'] . "." . $config['system']['domain']; + $menu_messages .= '</div>'; } return ($menu_messages); } } if (!function_exists("dom_title")) { - function dom_title($title_msg,$width=NULL) { - $width=preg_replace("/\D+/","",$width); + function dom_title($title_msg, $width=NULL) { + $width=preg_replace("/\D+/", "", $width); if (!empty($width)) { $width=",'width',$width"; } if (!empty($title_msg)) { - $title_msg=preg_replace("/\s+/"," ",$title_msg); - $title_msg=preg_replace("/'/","\'",$title_msg); + $title_msg=preg_replace("/\s+/", " ", $title_msg); + $title_msg=preg_replace("/'/", "\'", $title_msg); return "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 250, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle' $width);\""; } } diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index f65605f..724a714 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -597,8 +597,8 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive } /* Process/add dynamic v4 gateways. */ - foreach ($iflist as $ifname => $friendly ) { - if (! interface_has_gateway($ifname)) { + foreach ($iflist as $ifname => $friendly) { + if (!interface_has_gateway($ifname)) { continue; } @@ -688,13 +688,13 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive unset($gateway); /* Process/add dynamic v6 gateways. */ - foreach ($iflist as $ifname => $friendly ) { + foreach ($iflist as $ifname => $friendly) { /* If the user has disabled IPv6, they probably don't want any IPv6 gateways. */ if (!isset($config['system']['ipv6allow'])) { break; } - if (! interface_has_gatewayv6($ifname)) { + if (!interface_has_gatewayv6($ifname)) { continue; } diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 9880f6b..120d868 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -49,7 +49,7 @@ require_once("gwlb.inc"); function interfaces_bring_up($interface) { if (!$interface) { log_error(gettext("interfaces_bring_up() was called but no variable defined.")); - log_error( "Backtrace: " . debug_backtrace() ); + log_error("Backtrace: " . debug_backtrace()); return; } pfSense_interface_flags($interface, IFF_UP); @@ -156,7 +156,7 @@ function interface_netgraph_needed($interface = "wan") { $realif = get_real_interface($interface); if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { foreach ($config['ppps']['ppp'] as $pppid => $ppp) { - $ports = explode(',',$ppp['ports']); + $ports = explode(',', $ppp['ports']); foreach ($ports as $pid => $port) { $port = get_real_interface($port); if ($realif == $port) { @@ -360,7 +360,7 @@ function interfaces_qinq_configure() { } } if (platform_booting()) { - echo gettext( "done.") . "\n"; + echo gettext("done.") . "\n"; } } @@ -1054,7 +1054,7 @@ function interfaces_configure() { } interface_configure($if, $reload); if (platform_booting()) { - echo gettext( "done.") . "\n"; + echo gettext("done.") . "\n"; } } } @@ -1327,8 +1327,9 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg = } else { /* get_interface_ipv6() returns empty value if interface is being disabled */ $ip6 = get_interface_ipv6($interface); - if (is_ipaddrv6($ip6)) + if (is_ipaddrv6($ip6)) { mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " inet6 {$ip6} delete", true); + } } interface_ipalias_cleanup($interface, "inet6"); if ($destroy == true) { @@ -1608,7 +1609,7 @@ function interface_ppps_configure($interface) { } */ - $ports = explode(',',$ppp['ports']); + $ports = explode(',', $ppp['ports']); if ($type != "modem") { foreach ($ports as $pid => $port) { $ports[$pid] = get_real_interface($port); @@ -1617,9 +1618,9 @@ function interface_ppps_configure($interface) { } } } - $localips = explode(',',$ppp['localip']); - $gateways = explode(',',$ppp['gateway']); - $subnets = explode(',',$ppp['subnet']); + $localips = explode(',', $ppp['localip']); + $gateways = explode(',', $ppp['gateway']); + $subnets = explode(',', $ppp['subnet']); /* We bring up the parent interface first because if DHCP is configured on the parent we need * to obtain an address first so we can write it in the mpd .conf file for PPTP and L2TP configs @@ -1712,16 +1713,16 @@ function interface_ppps_configure($interface) { $passwd = base64_decode($ppp['password']); } - $bandwidths = explode(',',$ppp['bandwidth']); + $bandwidths = explode(',', $ppp['bandwidth']); $defaultmtu = "1492"; if (!empty($ifcfg['mtu'])) { $defaultmtu = intval($ifcfg['mtu']); } - $mtus = explode(',',$ppp['mtu']); - $mrus = explode(',',$ppp['mru']); + $mtus = explode(',', $ppp['mtu']); + $mrus = explode(',', $ppp['mru']); if (isset($ppp['mrru'])) { - $mrrus = explode(',',$ppp['mrru']); + $mrrus = explode(',', $ppp['mrru']); } // Construct the mpd.conf file @@ -2368,7 +2369,7 @@ function interface_wireless_clone($realif, $wlcfg) { } else { $wlcfg_mode = $wlcfg['mode']; } - switch($wlcfg_mode) { + switch ($wlcfg_mode) { case "hostap": $mode = "wlanmode hostap"; break; @@ -2383,11 +2384,11 @@ function interface_wireless_clone($realif, $wlcfg) { if (does_interface_exist($realif)) { exec("/sbin/ifconfig " . escapeshellarg($realif), $output, $ret); $ifconfig_str = implode($output); - if (($wlcfg_mode == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) { + if (($wlcfg_mode == "hostap") && (!preg_match("/hostap/si", $ifconfig_str))) { log_error(sprintf(gettext("Interface %s changed to hostap mode"), $realif)); $needs_clone = true; } - if (($wlcfg_mode == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) { + if (($wlcfg_mode == "adhoc") && (!preg_match("/adhoc/si", $ifconfig_str))) { log_error(sprintf(gettext("Interface %s changed to adhoc mode"), $realif)); $needs_clone = true; } @@ -2515,11 +2516,11 @@ function interface_wireless_configure($if, &$wl, &$wlcfg) { // Reject inadvertent changes to shared settings in case the interface hasn't been configured. interface_sync_wireless_clones($wl, false); - $fd_set = fopen("{$g['tmp_path']}/{$if}_setup.sh","w"); + $fd_set = fopen("{$g['tmp_path']}/{$if}_setup.sh", "w"); fwrite($fd_set, "#!/bin/sh\n"); fwrite($fd_set, "# {$g['product_name']} wireless configuration script.\n\n"); - - $wlan_setup_log = fopen("{$g['tmp_path']}/{$if}_setup.log","w"); + + $wlan_setup_log = fopen("{$g['tmp_path']}/{$if}_setup.log", "w"); /* set values for /path/program */ $hostapd = "/usr/sbin/hostapd"; @@ -2638,10 +2639,10 @@ function interface_wireless_configure($if, &$wl, &$wlcfg) { /* handle txpower setting */ // or don't. this has issues at the moment. /* - if($wlcfg['txpower'] <> "" && is_numeric($wlcfg['txpower'])) { + if ($wlcfg['txpower'] <> "" && is_numeric($wlcfg['txpower'])) { $wlcmd[] = "txpower " . escapeshellarg($wlcfg['txpower']); }*/ - + /* handle wme option */ if (isset($wlcfg['wme']['enable'])) { $wlcmd[] = "wme"; @@ -2652,7 +2653,7 @@ function interface_wireless_configure($if, &$wl, &$wlcfg) { /* set up wep if enabled */ $wepset = ""; if (isset($wlcfg['wep']['enable']) && is_array($wlcfg['wep']['key'])) { - switch($wlcfg['wpa']['auth_algs']) { + switch ($wlcfg['wpa']['auth_algs']) { case "1": $wepset .= "authmode open wepmode on "; break; @@ -2926,9 +2927,9 @@ EOD; } } - /* 20150318 cmb - Note: the below no longer appears to be true on FreeBSD 10.x, so don't set + /* 20150318 cmb - Note: the below no longer appears to be true on FreeBSD 10.x, so don't set * mode twice (for now at least). This can be removed entirely in the future if no problems are found - + * The mode must be specified in a separate command before ifconfig * will allow the mode and channel at the same time in the next. */ //mwexec("/sbin/ifconfig " . escapeshellarg($if) . " mode " . escapeshellarg($standard)); @@ -2939,7 +2940,7 @@ EOD; mwexec("/sbin/ifconfig " . escapeshellarg($if) . " " . $wlcmd_args, false); fwrite($wlan_setup_log, "/sbin/ifconfig " . escapeshellarg($if) . " " . "$wlcmd_args \n"); fclose($wlan_setup_log); - + unset($wlcmd_args, $wlcmd); @@ -3399,7 +3400,7 @@ function interface_track6_configure($interface = "lan", $wancfg, $linkupevent = return; } - switch($trackcfg['ipaddrv6']) { + switch ($trackcfg['ipaddrv6']) { case "6to4": if ($g['debug']) { log_error("Interface {$interface} configured via {$wancfg['track6-interface']} type {$type}"); @@ -3976,7 +3977,7 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif) { if (($wancfg['adv_dhcp6_id_assoc_statement_prefix'] != '') && (is_numeric($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']) || - ($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] == 'infinity')) ) { + ($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] == 'infinity'))) { $id_assoc_statement_prefix .= "\n\tprefix"; $id_assoc_statement_prefix .= " {$wancfg['adv_dhcp6_id_assoc_statement_prefix']}"; $id_assoc_statement_prefix .= " {$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']}"; @@ -4000,7 +4001,7 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif) { } if (($wancfg['adv_dhcp6_id_assoc_statement_prefix'] != '') || - (is_numeric($wancfg['adv_dhcp6_prefix_interface_statement_sla_id'])) ) { + (is_numeric($wancfg['adv_dhcp6_prefix_interface_statement_sla_id']))) { $id_assoc_statement_prefix .= "\n"; } @@ -4641,7 +4642,7 @@ function get_real_interface($interface = "wan", $family = "all", $realv6iface = case 'ppp': case 'l2tp': case 'pptp': - if ( is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { + if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { $wanif = interface_get_wireless_clone($cfg['if']); } else { $wanif = $cfg['if']; @@ -4678,7 +4679,7 @@ function get_real_interface($interface = "wan", $family = "all", $realv6iface = // Wireless cloned NIC support (FreeBSD 8+) // interface name format: $parentnic_wlanparentnic# // example: ath0_wlan0 - if ( is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { + if (is_array($cfg['wireless']) || preg_match($g['wireless_regex'], $cfg['if'])) { $wanif = interface_get_wireless_clone($cfg['if']); } else { $wanif = $cfg['if']; @@ -5764,7 +5765,7 @@ function interfaces_staticarp_configure($if) { /* Enable staticarp, if enabled */ if (isset($config['dhcpd'][$if]['staticarp'])) { - mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " staticarp " ); + mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " staticarp "); mwexec("/usr/sbin/arp -d -i " . escapeshellarg($ifcfg['if']) . " -a > /dev/null 2>&1 "); if (is_array($config['dhcpd'][$if]['staticmap'])) { foreach ($config['dhcpd'][$if]['staticmap'] as $arpent) { @@ -5772,7 +5773,7 @@ function interfaces_staticarp_configure($if) { } } } else { - mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " -staticarp " ); + mwexec("/sbin/ifconfig " . escapeshellarg($ifcfg['if']) . " -staticarp "); mwexec("/usr/sbin/arp -d -i " . escapeshellarg($ifcfg['if']) . " -a > /dev/null 2>&1 "); if (is_array($config['dhcpd'][$if]) && is_array($config['dhcpd'][$if]['staticmap'])) { foreach ($config['dhcpd'][$if]['staticmap'] as $arpent) { diff --git a/etc/inc/ipsec.auth-user.php b/etc/inc/ipsec.auth-user.php index 571f237..8e8386d 100755 --- a/etc/inc/ipsec.auth-user.php +++ b/etc/inc/ipsec.auth-user.php @@ -52,8 +52,7 @@ require_once("interfaces.inc"); * We will use our local hostname to make up the nas_id */ if (!function_exists("getNasID")) { -function getNasID() -{ +function getNasID() { global $g; $nasId = gethostname(); @@ -71,8 +70,7 @@ function getNasID() * */ if (!function_exists("getNasIP")) { -function getNasIP() -{ +function getNasIP() { $nasIp = get_interface_ip(); if (!$nasIp) { $nasIp = "0.0.0.0"; diff --git a/etc/inc/ipsec.inc b/etc/inc/ipsec.inc index d766ade..d8fa843 100644 --- a/etc/inc/ipsec.inc +++ b/etc/inc/ipsec.inc @@ -44,22 +44,22 @@ $ipsec_loglevels = array("dmn" => "Daemon", "mgr" => "SA Manager", "ike" => "IKE global $my_identifier_list; $my_identifier_list = array( - 'myaddress' => array( 'desc' => gettext('My IP address'), 'mobile' => true ), - 'address' => array( 'desc' => gettext('IP address'), 'mobile' => true ), - 'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ), - 'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ), - 'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ), - 'keyid tag' => array( 'desc' => gettext('KeyID tag'), 'mobile' => true ), - 'dyn_dns' => array( 'desc' => gettext('Dynamic DNS'), 'mobile' => true )); + 'myaddress' => array('desc' => gettext('My IP address'), 'mobile' => true), + 'address' => array('desc' => gettext('IP address'), 'mobile' => true), + 'fqdn' => array('desc' => gettext('Distinguished name'), 'mobile' => true), + 'user_fqdn' => array('desc' => gettext('User distinguished name'), 'mobile' => true), + 'asn1dn' => array('desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true), + 'keyid tag' => array('desc' => gettext('KeyID tag'), 'mobile' => true), + 'dyn_dns' => array('desc' => gettext('Dynamic DNS'), 'mobile' => true)); global $peer_identifier_list; $peer_identifier_list = array( - 'peeraddress' => array( 'desc' => gettext('Peer IP address'), 'mobile' => false ), - 'address' => array( 'desc' => gettext('IP address'), 'mobile' => false ), - 'fqdn' => array( 'desc' => gettext('Distinguished name'), 'mobile' => true ), - 'user_fqdn' => array( 'desc' => gettext('User distinguished name'), 'mobile' => true ), - 'asn1dn' => array( 'desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true ), - 'keyid tag' => array( 'desc' =>gettext('KeyID tag'), 'mobile' => true )); + 'peeraddress' => array('desc' => gettext('Peer IP address'), 'mobile' => false), + 'address' => array('desc' => gettext('IP address'), 'mobile' => false), + 'fqdn' => array('desc' => gettext('Distinguished name'), 'mobile' => true), + 'user_fqdn' => array('desc' => gettext('User distinguished name'), 'mobile' => true), + 'asn1dn' => array('desc' => gettext('ASN.1 distinguished Name'), 'mobile' => true), + 'keyid tag' => array('desc' =>gettext('KeyID tag'), 'mobile' => true)); global $ipsec_idhandling; $ipsec_idhandling = array( @@ -68,25 +68,25 @@ $ipsec_idhandling = array( global $p1_ealgos; $p1_ealgos = array( - 'aes' => array( 'name' => 'AES', 'keysel' => array( 'lo' => 128, 'hi' => 256, 'step' => 64 ) ), - 'aes128gcm' => array( 'name' => 'AES128-GCM', 'keysel' => array( 'lo' => 64, 'hi' => 128, 'step' => 32 ) ), - 'aes192gcm' => array( 'name' => 'AES192-GCM', 'keysel' => array( 'lo' => 64, 'hi' => 128, 'step' => 32 ) ), - 'aes256gcm' => array( 'name' => 'AES256-GCM', 'keysel' => array( 'lo' => 64, 'hi' => 128, 'step' => 32 ) ), - 'blowfish' => array( 'name' => 'Blowfish', 'keysel' => array( 'lo' => 128, 'hi' => 256, 'step' => 64 ) ), - '3des' => array( 'name' => '3DES' ), - 'cast128' => array( 'name' => 'CAST128' ), - 'des' => array( 'name' => 'DES' )); + 'aes' => array('name' => 'AES', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), + 'aes128gcm' => array('name' => 'AES128-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), + 'aes192gcm' => array('name' => 'AES192-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), + 'aes256gcm' => array('name' => 'AES256-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), + 'blowfish' => array('name' => 'Blowfish', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), + '3des' => array('name' => '3DES'), + 'cast128' => array('name' => 'CAST128'), + 'des' => array('name' => 'DES')); global $p2_ealgos; $p2_ealgos = array( - 'aes' => array( 'name' => 'AES', 'keysel' => array( 'lo' => 128, 'hi' => 256, 'step' => 64 ) ), - 'aes128gcm' => array( 'name' => 'AES128-GCM', 'keysel' => array( 'lo' => 64, 'hi' => 128, 'step' => 32 ) ), - 'aes192gcm' => array( 'name' => 'AES192-GCM', 'keysel' => array( 'lo' => 64, 'hi' => 128, 'step' => 32 ) ), - 'aes256gcm' => array( 'name' => 'AES256-GCM', 'keysel' => array( 'lo' => 64, 'hi' => 128, 'step' => 32 ) ), - 'blowfish' => array( 'name' => 'Blowfish', 'keysel' => array( 'lo' => 128, 'hi' => 256, 'step' => 64 ) ), - '3des' => array( 'name' => '3DES' ), - 'cast128' => array( 'name' => 'CAST128' ), - 'des' => array( 'name' => 'DES' )); + 'aes' => array('name' => 'AES', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), + 'aes128gcm' => array('name' => 'AES128-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), + 'aes192gcm' => array('name' => 'AES192-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), + 'aes256gcm' => array('name' => 'AES256-GCM', 'keysel' => array('lo' => 64, 'hi' => 128, 'step' => 32)), + 'blowfish' => array('name' => 'Blowfish', 'keysel' => array('lo' => 128, 'hi' => 256, 'step' => 64)), + '3des' => array('name' => '3DES'), + 'cast128' => array('name' => 'CAST128'), + 'des' => array('name' => 'DES')); global $p1_halgos; $p1_halgos = array( @@ -131,14 +131,14 @@ $p2_halgos = array( global $p1_authentication_methods; $p1_authentication_methods = array( - 'hybrid_rsa_server' => array( 'name' => 'Hybrid RSA + Xauth', 'mobile' => true ), - 'xauth_rsa_server' => array( 'name' => 'Mutual RSA + Xauth', 'mobile' => true ), - 'xauth_psk_server' => array( 'name' => 'Mutual PSK + Xauth', 'mobile' => true ), - 'eap-tls' => array( 'name' => 'EAP-TLS', 'mobile' => true), - 'eap-radius' => array( 'name' => 'EAP-RADIUS', 'mobile' => true), - 'eap-mschapv2' => array( 'name' => 'EAP-MSChapv2', 'mobile' => true), - 'rsasig' => array( 'name' => 'Mutual RSA', 'mobile' => false ), - 'pre_shared_key' => array( 'name' => 'Mutual PSK', 'mobile' => false ) ); + 'hybrid_rsa_server' => array('name' => 'Hybrid RSA + Xauth', 'mobile' => true), + 'xauth_rsa_server' => array('name' => 'Mutual RSA + Xauth', 'mobile' => true), + 'xauth_psk_server' => array('name' => 'Mutual PSK + Xauth', 'mobile' => true), + 'eap-tls' => array('name' => 'EAP-TLS', 'mobile' => true), + 'eap-radius' => array('name' => 'EAP-RADIUS', 'mobile' => true), + 'eap-mschapv2' => array('name' => 'EAP-MSChapv2', 'mobile' => true), + 'rsasig' => array('name' => 'Mutual RSA', 'mobile' => false), + 'pre_shared_key' => array('name' => 'Mutual PSK', 'mobile' => false)); global $ipsec_preshared_key_type; $ipsec_preshared_key_type = array( @@ -184,7 +184,7 @@ function ipsec_ikeid_used($ikeid) { global $config; foreach ($config['ipsec']['phase1'] as $ph1ent) { - if ( $ikeid == $ph1ent['ikeid'] ) { + if ($ikeid == $ph1ent['ikeid']) { return true; } } @@ -245,7 +245,7 @@ function ipsec_get_phase1_dst(& $ph1ent) { } $rg = $ph1ent['remote-gateway']; if (!is_ipaddr($rg)) { - if (! platform_booting()) { + if (!platform_booting()) { return resolve_retry($rg); } } @@ -270,8 +270,9 @@ function ipsec_idinfo_to_cidr(& $idinfo, $addrbits = false, $mode = "") { } else { return $idinfo['address']."/32"; } - } else + } else { return $idinfo['address']; + } break; /* NOTREACHED */ case "network": return "{$idinfo['address']}/{$idinfo['netbits']}"; @@ -288,12 +289,12 @@ function ipsec_idinfo_to_cidr(& $idinfo, $addrbits = false, $mode = "") { if ($mode == "tunnel6") { $address = get_interface_ipv6($idinfo['type']); $netbits = get_interface_subnetv6($idinfo['type']); - $address = gen_subnetv6($address,$netbits); + $address = gen_subnetv6($address, $netbits); return "{$address}/{$netbits}"; } else { $address = get_interface_ip($idinfo['type']); $netbits = get_interface_subnet($idinfo['type']); - $address = gen_subnet($address,$netbits); + $address = gen_subnet($address, $netbits); return "{$address}/{$netbits}"; } break; /* NOTREACHED */ @@ -303,7 +304,7 @@ function ipsec_idinfo_to_cidr(& $idinfo, $addrbits = false, $mode = "") { /* * Return phase2 idinfo in address/netmask format */ -function ipsec_idinfo_to_subnet(& $idinfo,$addrbits = false) { +function ipsec_idinfo_to_subnet(& $idinfo, $addrbits = false) { global $config; switch ($idinfo['type']) { @@ -314,8 +315,9 @@ function ipsec_idinfo_to_subnet(& $idinfo,$addrbits = false) { } else { return $idinfo['address']."/255.255.255.255"; } - } else + } else { return $idinfo['address']; + } break; /* NOTREACHED */ case "none": case "network": @@ -328,12 +330,12 @@ function ipsec_idinfo_to_subnet(& $idinfo,$addrbits = false) { if ($idinfo['mode'] == "tunnel6") { $address = get_interface_ipv6($idinfo['type']); $netbits = get_interface_subnetv6($idinfo['type']); - $address = gen_subnetv6($address,$netbits); + $address = gen_subnetv6($address, $netbits); return $address."/".$netbits; } else { $address = get_interface_ip($idinfo['type']); $netbits = get_interface_subnet($idinfo['type']); - $address = gen_subnet($address,$netbits); + $address = gen_subnet($address, $netbits); return $address."/".$netbits; } break; /* NOTREACHED */ @@ -372,7 +374,7 @@ function ipsec_idinfo_to_text(& $idinfo) { /* * Return phase1 association for phase2 */ -function ipsec_lookup_phase1(& $ph2ent,& $ph1ent) { +function ipsec_lookup_phase1(& $ph2ent, & $ph1ent) { global $config; if (!is_array($config['ipsec'])) { @@ -416,7 +418,7 @@ function ipsec_phase1_status(&$ipsec_status, $ikeid) { */ function ipsec_phase2_status(&$ipsec_status, &$phase2) { - if (ipsec_lookup_phase1($ph2ent,$ph1ent)) { + if (ipsec_lookup_phase1($ph2ent, $ph1ent)) { return ipsec_phase1_status($ipsec_status, $ph1ent['ikeid']); } @@ -473,8 +475,7 @@ function ipsec_smp_dump_status() { /* * Return dump of SPD table */ -function ipsec_dump_spd() -{ +function ipsec_dump_spd() { $fd = @popen("/sbin/setkey -DP", "r"); $spd = array(); if ($fd) { @@ -528,8 +529,7 @@ function ipsec_dump_spd() /* * Return dump of SAD table */ -function ipsec_dump_sad() -{ +function ipsec_dump_sad() { $fd = @popen("/sbin/setkey -D", "r"); $sad = array(); if ($fd) { @@ -546,7 +546,7 @@ function ipsec_dump_sad() $sad[] = $cursa; } $cursa = array(); - list($cursa['src'],$cursa['dst']) = explode(" ", $line); + list($cursa['src'], $cursa['dst']) = explode(" ", $line); } else { $line = trim($line, "\t\n\r "); $linea = explode(" ", $line); diff --git a/etc/inc/itemid.inc b/etc/inc/itemid.inc index dff4a8b..c698cfa 100644 --- a/etc/inc/itemid.inc +++ b/etc/inc/itemid.inc @@ -51,14 +51,14 @@ function delete_id($id, &$array) { // Search for the item in the array foreach ($array as $key => $item) { // If this item is the one we want to delete - if (isset($item['associated-rule-id']) && $item['associated-rule-id']==$id ) { + if (isset($item['associated-rule-id']) && $item['associated-rule-id'] == $id) { $delete_index = $key; break; } } // If we found the item, unset it - if ($delete_index!==NULL) { + if ($delete_index !== NULL) { unset($array[$delete_index]); return true; } else { @@ -86,7 +86,7 @@ function get_id($id, &$array) { // Search for the item in the array foreach ($array as $key => $item) { // If this item is the one we want to delete - if (isset($item['associated-rule-id']) && $item['associated-rule-id']==$id) { + if (isset($item['associated-rule-id']) && $item['associated-rule-id'] == $id) { return $key; } } diff --git a/etc/inc/notices.inc b/etc/inc/notices.inc index 4b9655b..b006740 100644 --- a/etc/inc/notices.inc +++ b/etc/inc/notices.inc @@ -368,7 +368,7 @@ function send_smtp_message($message, $subject = "(no subject)", $force = false) "From: {$from}", "To: {$to}", "Subject: {$subject}", - "Date: ".date("r") + "Date: " . date("r") ); if ($smtp->SendMessage($from, preg_split('/\s*,\s*/', trim($to)), $headers, $message)) { @@ -390,7 +390,7 @@ function send_smtp_message($message, $subject = "(no subject)", $force = false) ******/ function notify_via_growl($message, $force=false) { require_once("growl.class"); - global $config,$g; + global $config, $g; if (isset($config['notifications']['growl']['disable']) && !$force) { return; diff --git a/etc/inc/openvpn.auth-user.php b/etc/inc/openvpn.auth-user.php index 043848d..d017c61 100644 --- a/etc/inc/openvpn.auth-user.php +++ b/etc/inc/openvpn.auth-user.php @@ -53,8 +53,7 @@ require_once("interfaces.inc"); * We will use our local hostname to make up the nas_id */ if (!function_exists("getNasID")) { -function getNasID() -{ +function getNasID() { global $g; $nasId = gethostname(); @@ -72,8 +71,7 @@ function getNasID() * */ if (!function_exists("getNasIP")) { -function getNasIP() -{ +function getNasIP() { $nasIp = get_interface_ip(); if (!$nasIp) { $nasIp = "0.0.0.0"; diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 23ae85c..00eaf15 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -1354,7 +1354,7 @@ function openvpn_get_client_status($client, $socket) { } /* Get the client state */ - if (strstr($line,"CONNECTED")) { + if (strstr($line, "CONNECTED")) { $client['status']="up"; $list = explode(",", $line); @@ -1362,17 +1362,17 @@ function openvpn_get_client_status($client, $socket) { $client['virtual_addr'] = $list[3]; $client['remote_host'] = $list[4]; } - if (strstr($line,"CONNECTING")) { + if (strstr($line, "CONNECTING")) { $client['status']="connecting"; } - if (strstr($line,"ASSIGN_IP")) { + if (strstr($line, "ASSIGN_IP")) { $client['status']="waiting"; $list = explode(",", $line); $client['connect_time'] = date("D M j G:i:s Y", $list[0]); $client['virtual_addr'] = $list[3]; } - if (strstr($line,"RECONNECTING")) { + if (strstr($line, "RECONNECTING")) { $client['status']="reconnecting"; $list = explode(",", $line); @@ -1398,12 +1398,12 @@ function openvpn_get_client_status($client, $socket) { break; } - if (strstr($line,"TCP/UDP read bytes")) { + if (strstr($line, "TCP/UDP read bytes")) { $list = explode(",", $line); $client['bytes_recv'] = $list[1]; } - if (strstr($line,"TCP/UDP write bytes")) { + if (strstr($line, "TCP/UDP write bytes")) { $list = explode(",", $line); $client['bytes_sent'] = $list[1]; } diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 600e50e..b58fb5e 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -79,7 +79,7 @@ function have_ruleint_access($if) { * returns true if a url is available ******/ function does_url_exist($url) { - $fd = fopen("$url","r"); + $fd = fopen("$url", "r"); if ($fd) { fclose($fd); return true; @@ -105,7 +105,7 @@ function is_private_ip($iptocheck) { "192.168.0.0/16", ); foreach ($ip_private_list as $private) { - if (ip_in_subnet($iptocheck,$private)==true) { + if (ip_in_subnet($iptocheck, $private) == true) { $isprivate = true; } } @@ -494,8 +494,7 @@ function get_dir($dir) { * RESULT * true/false - true if the operation was successful ******/ -function WakeOnLan($addr, $mac) -{ +function WakeOnLan($addr, $mac) { $addr_byte = explode(':', $mac); $hw_addr = ''; @@ -561,7 +560,7 @@ function backup_config_section($section_name) { function restore_config_section($section_name, $new_contents) { global $config, $g; conf_mount_rw(); - $fout = fopen("{$g['tmp_path']}/tmpxml","w"); + $fout = fopen("{$g['tmp_path']}/tmpxml", "w"); fwrite($fout, $new_contents); fclose($fout); @@ -622,10 +621,10 @@ function merge_config_section($section_name, $new_contents) { function http_post($server, $port, $url, $vars) { $user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"; $urlencoded = ""; - while (list($key,$value) = each($vars)) { - $urlencoded.= urlencode($key) . "=" . urlencode($value) . "&"; + while (list($key, $value) = each($vars)) { + $urlencoded .= urlencode($key) . "=" . urlencode($value) . "&"; } - $urlencoded = substr($urlencoded,0,-1); + $urlencoded = substr($urlencoded, 0, -1); $content_length = strlen($urlencoded); $headers = "POST $url HTTP/1.1 Accept: */* @@ -651,7 +650,7 @@ Content-Length: $content_length $ret = ""; while (!feof($fp)) { - $ret.= fgets($fp, 1024); + $ret .= fgets($fp, 1024); } fclose($fp); @@ -665,7 +664,7 @@ if (!function_exists('php_check_syntax')) { global $g; function php_check_syntax($code_to_check, &$errormessage) { return false; - $fout = fopen("{$g['tmp_path']}/codetocheck.php","w"); + $fout = fopen("{$g['tmp_path']}/codetocheck.php", "w"); $code = $_POST['content']; $code = str_replace("<?php", "", $code); $code = str_replace("?>", "", $code); @@ -706,11 +705,11 @@ if (!function_exists('php_check_syntax')) { } /* - * rmdir_recursive($path,$follow_links=false) + * rmdir_recursive($path, $follow_links=false) * Recursively remove a directory tree (rm -rf path) * This is for directories _only_ */ -function rmdir_recursive($path,$follow_links=false) { +function rmdir_recursive($path, $follow_links=false) { $to_do = glob($path); if (!is_array($to_do)) { $to_do = array($to_do); @@ -722,7 +721,7 @@ function rmdir_recursive($path,$follow_links=false) { while ($entry = readdir($dir)) { if (is_file("$workingdir/$entry") || ((!$follow_links) && is_link("$workingdir/$entry"))) { unlink("$workingdir/$entry"); - } elseif (is_dir("$workingdir/$entry") && $entry!='.' && $entry!='..') { + } elseif (is_dir("$workingdir/$entry") && $entry != '.' && $entry != '..') { rmdir_recursive("$workingdir/$entry"); } } @@ -1009,7 +1008,7 @@ function setup_serial_port($when="save", $path="") { } $boot_config_split = explode("\n", $boot_config); - $fd = fopen($boot_config_file,"w"); + $fd = fopen($boot_config_file, "w"); if ($fd) { foreach ($boot_config_split as $bcs) { if (stristr($bcs, "-D") || stristr($bcs, "-h")) { @@ -1277,7 +1276,7 @@ function convert_seconds_to_hms($sec) { function get_ppp_uptime($port) { if (file_exists("/conf/{$port}.log")) { $saved_time = file_get_contents("/conf/{$port}.log"); - $uptime_data = explode("\n",$saved_time); + $uptime_data = explode("\n", $saved_time); $sec=0; foreach ($uptime_data as $upt) { $sec += substr($upt, 1 + strpos($upt, " ")); @@ -2466,8 +2465,7 @@ function get_include_contents($filename) { * The reason we do not use it for pfSense is that it does not know about array fields * which causes it to fail on array fields with single items. Possible Todo? */ -function xml2array($contents, $get_attributes = 1, $priority = 'tag') -{ +function xml2array($contents, $get_attributes = 1, $priority = 'tag') { if (!function_exists('xml_parser_create')) { return array (); } @@ -2644,7 +2642,7 @@ function generate_ipv6_from_mac($mac) { $hexadecimal = substr($byte, 1, 2); $bitmap = base_convert($hexadecimal, 16, 2); $bitmap = str_pad($bitmap, 4, "0", STR_PAD_LEFT); - $bitmap = substr($bitmap, 0, 2) ."1". substr($bitmap, 3,4); + $bitmap = substr($bitmap, 0, 2) ."1". substr($bitmap, 3, 4); $byte = substr($byte, 0, 1) . base_convert($bitmap, 2, 16); } $ipv6 .= $byte; @@ -2700,7 +2698,7 @@ function load_mac_manufacturer_table() { * check_localip - if true then also check for matches with PPTP and LT2P addresses * check_subnets - if true then check if the given ipaddr is contained anywhere in the subnet of any other configured IP address * cidrprefix - the CIDR prefix (16, 20, 24, 64...) of ipaddr. - * If check_subnets is true and cidrprefix is specified, + * If check_subnets is true and cidrprefix is specified, * then check if the ipaddr/cidrprefix subnet overlaps the subnet of any other configured IP address * RESULT * returns true if the IP Address is configured and present on this device or overlaps a configured subnet. @@ -2721,7 +2719,7 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false, * check_localip - if true then also check for matches with PPTP and LT2P addresses * check_subnets - if true then check if the given ipaddr is contained anywhere in the subnet of any other configured IP address * cidrprefix - the CIDR prefix (16, 20, 24, 64...) of ipaddr. - * If check_subnets is true and cidrprefix is specified, + * If check_subnets is true and cidrprefix is specified, * then check if the ipaddr/cidrprefix subnet overlaps the subnet of any other configured IP address * RESULT * Returns an array of the interfaces 'if' plus IP address or subnet 'ip_or_subnet' that match or overlap the IP address to check. @@ -2859,8 +2857,8 @@ function set_language($lang = 'en_US', $encoding = "UTF-8") { putenv("LANG={$lang}.{$encoding}"); setlocale(LC_ALL, "{$lang}.{$encoding}"); textdomain("pfSense"); - bindtextdomain("pfSense","/usr/local/share/locale"); - bind_textdomain_codeset("pfSense","{$lang}.{$encoding}"); + bindtextdomain("pfSense", "/usr/local/share/locale"); + bind_textdomain_codeset("pfSense", "{$lang}.{$encoding}"); } function get_locale_list() { @@ -3155,7 +3153,7 @@ function pkg_call_plugins($plugin_type, $plugin_params) { continue; } $pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], 'packagegui'); - $pkgname = substr(reverse_strrchr($package['configurationfile'], "."),0,-1); + $pkgname = substr(reverse_strrchr($package['configurationfile'], "."), 0, -1); if (is_array($pkg_config['plugins']['item'])) { foreach ($pkg_config['plugins']['item'] as $plugin) { if ($plugin['type'] == $plugin_type) { diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index 952583e..ab6c8d4 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -391,7 +391,7 @@ function install_package_xml($package_name) { update_output_window($static_output); if ($pkgid == -1) { $config['installedpackages']['package'][] = $pkg_info; - $changedesc = sprintf(gettext("Installed %s package."),$pkg_info['name']); + $changedesc = sprintf(gettext("Installed %s package."), $pkg_info['name']); $to_output = gettext("done.") . "\n"; } else { $config['installedpackages']['package'][$pkgid] = $pkg_info; @@ -565,7 +565,7 @@ function delete_package($package_name) { return; } - $static_output .= sprintf(gettext("Starting package deletion for %s..."),$package_name); + $static_output .= sprintf(gettext("Starting package deletion for %s..."), $package_name); update_output_window($static_output); pkg_delete($package_name); @@ -593,8 +593,8 @@ function delete_package_xml($package_name, $when = "post-deinstall") { conf_mount_ro(); return; } - pkg_debug(sprintf(gettext("Removing %s package... "),$package_name)); - $static_output .= sprintf(gettext("Removing %s components..."),$package_name) . "\n"; + pkg_debug(sprintf(gettext("Removing %s package... "), $package_name)); + $static_output .= sprintf(gettext("Removing %s components..."), $package_name) . "\n"; update_output_window($static_output); /* parse package configuration */ $packages = &$config['installedpackages']['package']; diff --git a/etc/inc/priv.inc b/etc/inc/priv.inc index a15254d..45dcc3b 100644 --- a/etc/inc/priv.inc +++ b/etc/inc/priv.inc @@ -76,14 +76,14 @@ function get_priv_files($directory) { // Load and sort privs $dir_array = get_priv_files("/etc/inc/priv"); foreach ($dir_array as $file) { - if (!is_dir("/etc/inc/priv/{$file}") && stristr($file,".inc")) { + if (!is_dir("/etc/inc/priv/{$file}") && stristr($file, ".inc")) { include("/etc/inc/priv/{$file}"); } } if (is_dir("/usr/local/pkg/priv")) { $dir_array = get_priv_files("/usr/local/pkg/priv"); foreach ($dir_array as $file) { - if (!is_dir("/usr/local/pkg/priv/{$file}") && stristr($file,".inc")) { + if (!is_dir("/usr/local/pkg/priv/{$file}") && stristr($file, ".inc")) { include("/usr/local/pkg/priv/{$file}"); } } @@ -128,12 +128,12 @@ function cmp_page_matches($page, & $matches, $fullwc = true) { foreach ($matches as $match) { /* possibly ignore full wildcard match */ - if (!$fullwc && !strcmp($match ,"*")) { + if (!$fullwc && !strcmp($match , "*")) { continue; } /* compare exact or wildcard match */ - $match = str_replace(array(".", "*","?"), array("\.", ".*","\?"), $match); + $match = str_replace(array(".", "*", "?"), array("\.", ".*", "\?"), $match); $result = preg_match("@^/{$match}$@", "/{$page}"); if ($result) { @@ -152,7 +152,7 @@ function map_page_privname($page) { continue; } $fullwc = false; - if (!strcasecmp($page,"any")||!strcmp($page,"*")) { + if (!strcasecmp($page, "any")||!strcmp($page, "*")) { $fullwc = true; } if (cmp_page_matches($page, $pdata['match'], $fullwc)) { @@ -182,7 +182,7 @@ function get_user_privdesc(& $user) { continue; } foreach ($group_privs as $pname) { - if (in_array($pname,$user_privs)) { + if (in_array($pname, $user_privs)) { continue; } if (!$priv_list[$pname]) { @@ -214,7 +214,7 @@ function isAllowed($username, $page) { $user = getUserEntry($username); if (isset($user)) { if (isset($user['uid'])) { - if ($user['uid']==0) { + if ($user['uid'] == 0) { return true; } } @@ -243,7 +243,7 @@ function isAllowedPage($page) { $user = getUserEntry($username); if (isset($user)) { if (isset($user['uid'])) { - if ($user['uid']==0) { + if ($user['uid'] == 0) { return true; } } diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc index 716dd98..d0f14ec 100644 --- a/etc/inc/rrd.inc +++ b/etc/inc/rrd.inc @@ -116,7 +116,7 @@ function migrate_rrd_format($rrdoldxml, $rrdnewxml) { $numrranew = count($rrdnewxml['rra']); $numdsold = count($rrdoldxml['ds']); $numdsnew = count($rrdnewxml['ds']); - log_error(sprintf(gettext('Import RRD has %1$s DS values and %2$s RRA databases, new format RRD has %3$s DS values and %4$s RRA databases'), $numdsold, $numrraold, $numdsnew ,$numrranew)); + log_error(sprintf(gettext('Import RRD has %1$s DS values and %2$s RRA databases, new format RRD has %3$s DS values and %4$s RRA databases'), $numdsold, $numrraold, $numdsnew , $numrranew)); /* add data sources not found in the old array from the new array */ $i = 0; diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 32334b3..77a7914 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -471,7 +471,7 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false) $output = ""; if (get_service_status($service)) { $statustext = gettext("Running"); - $output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/"; + $output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"), $service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/"; $output .= ($smallicon) ? "icon_pass.gif" : "icon_service_running.gif"; $output .= "\" alt=\"status\" /> "; if ($withtext) { @@ -480,7 +480,7 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false) } else { $service_enabled = is_service_enabled($service['name']); $statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled"); - $output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/"; + $output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"), $service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/"; $output .= ($smallicon) ? "icon_block.gif" : "icon_service_stopped.gif"; $output .= "\" alt=\"status\" /> "; if ($withtext) { @@ -505,7 +505,7 @@ function get_service_control_links($service, $addname = false) { default: $output .= "<a href='status_services.php?mode=restartservice&service={$service['name']}'>"; } - $output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Restart %sService"),$stitle) . "' border='0' src='/themes/".$g['theme']."/images/icons/icon_service_restart.gif' alt='restart' /></a>\n"; + $output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Restart %sService"), $stitle) . "' border='0' src='/themes/".$g['theme']."/images/icons/icon_service_restart.gif' alt='restart' /></a>\n"; switch ($service['name']) { case "openvpn": $output .= "<a href='status_services.php?mode=stopservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['vpnid']}'>"; @@ -516,7 +516,7 @@ function get_service_control_links($service, $addname = false) { default: $output .= "<a href='status_services.php?mode=stopservice&service={$service['name']}'>"; } - $output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Stop %sService"),$stitle) . "' border='0' src='/themes/".$g['theme']."/images/icons/icon_service_stop.gif' alt='stop' />"; + $output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Stop %sService"), $stitle) . "' border='0' src='/themes/".$g['theme']."/images/icons/icon_service_stop.gif' alt='stop' />"; $output .= "</a>"; } else { $service_enabled = is_service_enabled($service['name']); @@ -533,7 +533,7 @@ function get_service_control_links($service, $addname = false) { } } if ($service_enabled) { - $output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' border='0' src='/themes/".$g['theme']."/images/icons/icon_service_start.gif' alt='start' /></a>\n"; + $output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Start %sService"), $stitle) . "' border='0' src='/themes/".$g['theme']."/images/icons/icon_service_start.gif' alt='start' /></a>\n"; } } return $output; @@ -603,7 +603,7 @@ function service_control_start($name, $extras) { start_service($name); break; } - return sprintf(gettext("%s has been started."),htmlspecialchars($name)); + return sprintf(gettext("%s has been started."), htmlspecialchars($name)); } function service_control_stop($name, $extras) { global $g; @@ -743,7 +743,7 @@ function service_control_restart($name, $extras) { restart_service($name); break; } - return sprintf(gettext("%s has been restarted."),htmlspecialchars($name)); + return sprintf(gettext("%s has been restarted."), htmlspecialchars($name)); } ?> diff --git a/etc/inc/services.inc b/etc/inc/services.inc index 9a1b280..aaba9d7 100644 --- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -224,7 +224,7 @@ function services_radvd_configure($blacklist = array()) { $radvdconf .= "\t\tAdvOnLink on;\n"; $radvdconf .= "\t\tAdvAutonomous on;\n"; $radvdconf .= "\t\tAdvRouterAddr on;\n"; - break; + break; } $radvdconf .= "\t};\n"; } @@ -395,7 +395,7 @@ function services_dhcpd_configure($family = "all", $blacklist = array()) { global $config, $g; /* configure DHCPD chroot once */ - $fd = fopen("{$g['tmp_path']}/dhcpd.sh","w"); + $fd = fopen("{$g['tmp_path']}/dhcpd.sh", "w"); fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}\n"); fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/dev\n"); fwrite($fd, "/bin/mkdir -p {$g['dhcpd_chroot_path']}/etc\n"); @@ -1069,8 +1069,7 @@ EOD; return 0; } -function dhcpdkey($dhcpifconf) -{ +function dhcpdkey($dhcpifconf) { $dhcpdconf = ""; if ($dhcpifconf['ddnsdomainkeyname'] <> "" && $dhcpifconf['ddnsdomainkey'] <> "") { $dhcpdconf .= "key {$dhcpifconf['ddnsdomainkeyname']} {\n"; @@ -1082,8 +1081,7 @@ function dhcpdkey($dhcpifconf) return $dhcpdconf; } -function dhcpdzones($ddns_zones, $dhcpifconf) -{ +function dhcpdzones($ddns_zones, $dhcpifconf) { $dhcpdconf = ""; if (is_array($ddns_zones)) { @@ -1734,8 +1732,9 @@ function services_dhcrelay6_configure() { $dhcifaces = explode(",", $dhcrelaycfg['interface']); foreach ($dhcifaces as $dhcrelayif) { if (!isset($iflist[$dhcrelayif]) || - link_interface_to_bridge($dhcrelayif)) + link_interface_to_bridge($dhcrelayif)) { continue; + } if (is_ipaddrv6(get_interface_ipv6($dhcrelayif))) { $dhcrelayifs[] = get_real_interface($dhcrelayif); @@ -1949,7 +1948,7 @@ function services_dnsmasq_configure() { } /* generate hosts file */ - if (system_hosts_generate()!=0) { + if (system_hosts_generate() != 0) { $return = 1; } @@ -2105,7 +2104,7 @@ function services_dnsmasq_configure() { } if (!platform_booting()) { - if (services_dhcpd_configure()!=0) { + if (services_dhcpd_configure() != 0) { $return = 1; } } @@ -2135,7 +2134,7 @@ function services_unbound_configure() { } /* generate hosts file */ - if (system_hosts_generate()!=0) { + if (system_hosts_generate() != 0) { $return = 1; } @@ -2149,7 +2148,7 @@ function services_unbound_configure() { } if (!platform_booting()) { - if (services_dhcpd_configure()!=0) { + if (services_dhcpd_configure() != 0) { $return = 1; } } @@ -2180,7 +2179,7 @@ function services_snmpd_configure() { /* generate snmpd.conf */ $fd = fopen("{$g['varetc_path']}/snmpd.conf", "w"); if (!$fd) { - printf(gettext("Error: cannot open snmpd.conf in services_snmpd_configure().%s"),"\n"); + printf(gettext("Error: cannot open snmpd.conf in services_snmpd_configure().%s"), "\n"); return 1; } diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc index b474599..416f920 100644 --- a/etc/inc/shaper.inc +++ b/etc/inc/shaper.inc @@ -4483,7 +4483,7 @@ function read_layer7_config() { continue; /* XXX: grrrrrr at php */ } $root =& new layer7(); - $root->ReadConfig($conf['name'],$conf); + $root->ReadConfig($conf['name'], $conf); $layer7_rules_list[$root->GetRName()] = &$root; } } @@ -4524,8 +4524,8 @@ function generate_layer7_files() { $rules = $l7rules->build_l7_rules(); - $fp = fopen($path,'w'); - fwrite($fp,$rules); + $fp = fopen($path, 'w'); + fwrite($fp, $rules); fclose($fp); } } diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 945e284..362af97 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -832,14 +832,15 @@ function system_syslogd_start() { $syslogd_extra = ""; if (isset($syslogcfg)) { - $separatelogfacilities = array('ntp','ntpd','ntpdate','charon','ipsec_starter','openvpn','pptps','poes','l2tps','relayd','hostapd','dnsmasq','filterdns','unbound','dhcpd','dhcrelay','dhclient','dhcp6c','apinger','radvd','routed','olsrd','zebra','ospfd','bgpd','miniupnpd','filterlog'); + $separatelogfacilities = array('ntp', 'ntpd', 'ntpdate', 'charon', 'ipsec_starter', 'openvpn', 'pptps', 'poes', 'l2tps', 'relayd', 'hostapd', 'dnsmasq', 'filterdns', 'unbound', 'dhcpd', 'dhcrelay', 'dhclient', 'dhcp6c', 'apinger', 'radvd', 'routed', 'olsrd', 'zebra', 'ospfd', 'bgpd', 'miniupnpd', 'filterlog'); $syslogconf = ""; if ($config['installedpackages']['package']) { foreach ($config['installedpackages']['package'] as $package) { if ($package['logging']) { array_push($separatelogfacilities, $package['logging']['facilityname']); - if (!is_file($g['varlog_path'].'/'.$package['logging']['logfilename'])) + if (!is_file($g['varlog_path'].'/'.$package['logging']['logfilename'])) { mwexec("{$log_create_directive} {$log_size} {$g['varlog_path']}/{$package['logging']['logfilename']}"); + } $syslogconf .= "!{$package['logging']['facilityname']}\n*.*\t\t\t\t\t\t {$log_directive}{$g['varlog_path']}/{$package['logging']['logfilename']}\n"; } } diff --git a/etc/inc/unbound.inc b/etc/inc/unbound.inc index e644bdc..9141e3f 100644 --- a/etc/inc/unbound.inc +++ b/etc/inc/unbound.inc @@ -62,7 +62,7 @@ function unbound_optimization() { $numprocs = intval(get_single_sysctl('kern.smp.cpus')); if ($numprocs > 1) { $optimization['number_threads'] = "num-threads: {$numprocs}"; - $optimize_num = pow(2,floor(log($numprocs,2))); + $optimize_num = pow(2, floor(log($numprocs, 2))); } else { $optimization['number_threads'] = "num-threads: 1"; $optimize_num = 4; @@ -500,7 +500,7 @@ function unbound_add_domain_overrides($pvt_rev="") { $domain_entries .= "private-domain: \"$domain\"\n"; $domain_entries .= "domain-insecure: \"$domain\"\n"; } else if ($pvt_rev == "reverse") { - if ((substr($domain,-14) == ".in-addr.arpa.") || (substr($domain,-13) == ".in-addr.arpa")) { + if ((substr($domain, -14) == ".in-addr.arpa.") || (substr($domain, -13) == ".in-addr.arpa")) { $domain_entries .= "local-zone: \"$domain\" typetransparent\n"; } } else { diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index f2a1712..c66eb3f 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -743,7 +743,7 @@ function upgrade_042_to_043() { $gateways = array(); $i = 0; foreach ($iflist as $ifname => $interface) { - if (! interface_has_gateway($ifname)) { + if (!interface_has_gateway($ifname)) { continue; } $config['gateways']['gateway_item'][$i] = array(); @@ -1087,7 +1087,7 @@ function upgrade_046_to_047() { $type = $tunnel['local-subnet']['network']; } if ($tunnel['local-subnet']['address']) { - list($address,$netbits) = explode("/",$tunnel['local-subnet']['address']); + list($address, $netbits) = explode("/", $tunnel['local-subnet']['address']); if (is_null($netbits)) { $type = "address"; } else { @@ -1097,18 +1097,18 @@ function upgrade_046_to_047() { switch ($type) { case "address": - $ph2ent['localid'] = array('type' => $type,'address' => $address); + $ph2ent['localid'] = array('type' => $type, 'address' => $address); break; case "network": - $ph2ent['localid'] = array('type' => $type,'address' => $address,'netbits' => $netbits); + $ph2ent['localid'] = array('type' => $type, 'address' => $address, 'netbits' => $netbits); break; default: $ph2ent['localid'] = array('type' => $type); break; } - list($address,$netbits) = explode("/",$tunnel['remote-subnet']); - $ph2ent['remoteid'] = array('type' => 'network','address' => $address,'netbits' => $netbits); + list($address, $netbits) = explode("/", $tunnel['remote-subnet']); + $ph2ent['remoteid'] = array('type' => 'network', 'address' => $address, 'netbits' => $netbits); $ph2ent['protocol'] = $tunnel['p2']['protocol']; @@ -1407,7 +1407,7 @@ function upgrade_048_to_049() { $group['member'] = array(); foreach ($config['system']['user'] as & $user) { $groupnames = explode(",", $user['groupname']); - if (in_array($group['name'],$groupnames)) { + if (in_array($group['name'], $groupnames)) { $group['member'][] = $user['uid']; } } @@ -1429,7 +1429,7 @@ function upgrade_048_to_049() { /* insert new all group */ $groups = Array(); $groups[] = $all; - $groups = array_merge($config['system']['group'],$groups); + $groups = array_merge($config['system']['group'], $groups); $config['system']['group'] = $groups; } @@ -1682,7 +1682,7 @@ function upgrade_051_to_052() { $tmpstr = ""; foreach ($tmpcstmopts as $tmpcstmopt) { $tmpstr = str_replace(" ", "", $tmpcstmopt); - if (substr($tmpstr,0 ,6) == "devtun") { + if (substr($tmpstr, 0, 6) == "devtun") { $assigned_if = substr($tmpstr, 3); continue; } else if (substr($tmpstr, 0, 5) == "local") { @@ -1787,7 +1787,7 @@ function upgrade_051_to_052() { $tmpstr = ""; foreach ($tmpcstmopts as $tmpcstmopt) { $tmpstr = str_replace(" ", "", $tmpcstmopt); - if (substr($tmpstr,0 ,6) == "devtun") { + if (substr($tmpstr, 0, 6) == "devtun") { $assigned_if = substr($tmpstr, 3); continue; } else if (substr($tmpstr, 0, 5) == "local") { @@ -1965,7 +1965,7 @@ function upgrade_053_to_054() { $gateway_group_arr = array(); $gateways = return_gateways_array(); $group_name_changes = array(); - if (! is_array($config['gateways']['gateway_item'])) { + if (!is_array($config['gateways']['gateway_item'])) { $config['gateways']['gateway_item'] = array(); } diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 3fafdfb..fa06658 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -434,7 +434,7 @@ function ip_range_size_v4($startip, $endip) { function find_smallest_cidr_v4($number) { $smallest = 1; for ($b=32; $b > 0; $b--) { - $smallest = ($number <= pow(2,$b)) ? $b : $smallest; + $smallest = ($number <= pow(2, $b)) ? $b : $smallest; } return (32-$smallest); } @@ -813,7 +813,7 @@ function check_subnetsv6_overlap($subnet1, $bits1, $subnet2, $bits2) { } /* return true if $addr is in $subnet, false if not */ -function ip_in_subnet($addr,$subnet) { +function ip_in_subnet($addr, $subnet) { if (is_ipaddrv6($addr) && is_subnetv6($subnet)) { return (Net_IPv6::isInNetmask($addr, $subnet)); } else if (is_ipaddrv4($addr) && is_subnetv4($subnet)) { @@ -1077,7 +1077,7 @@ function get_configured_ip_aliases_list($returnfullentry = false) { if (is_array($config['virtualip']['vip'])) { $viparr = &$config['virtualip']['vip']; foreach ($viparr as $vip) { - if ($vip['mode']=="ipalias") { + if ($vip['mode'] == "ipalias") { if ($returnfullentry) { $alias_list[$vip['subnet']] = $vip; } else { @@ -1269,7 +1269,7 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") $upints = array(); /* get a list of virtual interface types */ if (!$vfaces) { - $vfaces = array ( + $vfaces = array( 'bridge', 'ppp', 'pppoe', @@ -1704,7 +1704,7 @@ function run_plugins($directory) { foreach ($files as $file) { if (stristr($file, ".sh") == true) { mwexec($directory . $file . " start"); - } else if (!is_dir($directory . "/" . $file) && stristr($file,".inc")) { + } else if (!is_dir($directory . "/" . $file) && stristr($file, ".inc")) { require_once($directory . "/" . $file); } } @@ -1839,7 +1839,7 @@ function get_memory() { $physmem = get_single_sysctl("hw.physmem"); $realmem = get_single_sysctl("hw.realmem"); /* convert from bytes to megabytes */ - return array(($physmem/1048576),($realmem/1048576)); + return array(($physmem/1048576), ($realmem/1048576)); } function mute_kernel_msgs() { @@ -1958,7 +1958,7 @@ function isAjax() { function timeout($timer = 9) { while (!isset($key)) { if ($timer >= 9) { - echo chr(8) . chr(8) . ($timer==9 ? chr(32) : null) . "{$timer}"; + echo chr(8) . chr(8) . ($timer == 9 ? chr(32) : null) . "{$timer}"; } else { echo chr(8). "{$timer}"; } @@ -2000,7 +2000,7 @@ function msort($array, $id="id", $sort_ascending=true) { $index++; } $temp_array[] = $array[$lowest_id]; - $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1)); + $array = array_merge(array_slice($array, 0, $lowest_id), array_slice($array, $lowest_id + 1)); } if ($sort_ascending) { return $temp_array; diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index a927ebc..54df10b 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -292,11 +292,12 @@ function voucher_expire($voucher_received) { /* Check if this voucher has any active sessions */ $cpentry = captiveportal_read_db("WHERE username = '{$voucher}'"); if (!empty($cpentry) && !empty($cpentry[0])) { - if (empty($cpzoneid) && !empty($config['captiveportal'][$cpzone])) + if (empty($cpzoneid) && !empty($config['captiveportal'][$cpzone])) { $cpzoneid = $config['captiveportal'][$cpzone]['zoneid']; + } $cpentry = $cpentry[0]; - captiveportal_disconnect($cpentry,null,13); - captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"FORCLY TERMINATING VOUCHER {$voucher} SESSION"); + captiveportal_disconnect($cpentry, null, 13); + captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], "FORCLY TERMINATING VOUCHER {$voucher} SESSION"); $unsetindexes[] = $cpentry[5]; } } else { @@ -410,7 +411,7 @@ function voucher_auth($voucher_received, $test = 0) { } // valid voucher. Store roll# and ticket# if (!empty($active_vouchers[$roll][$voucher])) { - list($timestamp,$minutes) = explode(",", $active_vouchers[$roll][$voucher]); + list($timestamp, $minutes) = explode(",", $active_vouchers[$roll][$voucher]); // we have an already active voucher here. $remaining = intval((($timestamp + (60*$minutes)) - time())/60); $test_result[] = sprintf(gettext('%1$s (%2$s/%3$s) active and good for %4$d Minutes'), $voucher, $roll, $nr, $remaining); @@ -453,7 +454,7 @@ function voucher_auth($voucher_received, $test = 0) { if ($error) { $test_result[] = gettext("Access denied!"); } else { - $test_result[] = sprintf(gettext("Access granted for %d Minutes in total."),$total_minutes); + $test_result[] = sprintf(gettext("Access granted for %d Minutes in total."), $total_minutes); } unlock($voucherlck); @@ -635,7 +636,7 @@ function voucher_read_active_db($roll) { while (!feof($fd)) { $line = trim(fgets($fd)); if ($line) { - list($voucher,$timestamp,$minutes) = explode(",", $line); // voucher,timestamp + list($voucher, $timestamp, $minutes) = explode(",", $line); // voucher,timestamp if ((($timestamp + (60*$minutes)) - time()) > 0) { $active[$voucher] = "$timestamp,$minutes"; } else { @@ -719,7 +720,7 @@ function voucher_log($priority, $message) { $message = trim($message); openlog("logportalauth", LOG_PID, LOG_LOCAL4); - syslog($priority, sprintf(gettext("Voucher: %s"),$message)); + syslog($priority, sprintf(gettext("Voucher: %s"), $message)); closelog(); } @@ -761,7 +762,7 @@ function voucher_save_db_to_config_zone() { $db = array(); $dbi = 1; foreach ($active_vouchers as $voucher => $line) { - list($timestamp,$minutes) = explode(",", $line); + list($timestamp, $minutes) = explode(",", $line); $activent['voucher'] = $voucher; $activent['timestamp'] = $timestamp; $activent['minutes'] = $minutes; diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc index 23e636a..068ca00 100644 --- a/etc/inc/vpn.inc +++ b/etc/inc/vpn.inc @@ -42,8 +42,7 @@ require_once("ipsec.inc"); -function vpn_ipsec_configure_loglevels($forconfig = false) -{ +function vpn_ipsec_configure_loglevels($forconfig = false) { global $config, $ipsec_loglevels; $cfgtext = array(); @@ -62,8 +61,7 @@ function vpn_ipsec_configure_loglevels($forconfig = false) } /* include all configuration functions */ -function vpn_ipsec_convert_to_modp($index) -{ +function vpn_ipsec_convert_to_modp($index) { $convertion = ""; switch ($index) { @@ -114,8 +112,7 @@ function vpn_ipsec_convert_to_modp($index) return $convertion; } -function vpn_ipsec_configure($restart = false) -{ +function vpn_ipsec_configure($restart = false) { global $config, $g, $sa, $sn, $p1_ealgos, $p2_ealgos, $ipsec_idhandling; if ($g['platform'] == 'jail') { @@ -125,7 +122,7 @@ function vpn_ipsec_configure($restart = false) /* get the automatic ping_hosts.sh ready */ unlink_if_exists("{$g['vardb_path']}/ipsecpinghosts"); touch("{$g['vardb_path']}/ipsecpinghosts"); - + /* service may have been enabled, disabled, or otherwise changed in a way requiring rule updates */ filter_configure(); @@ -240,7 +237,7 @@ function vpn_ipsec_configure($restart = false) continue; } - if (!in_array($ep,$ipmap)) { + if (!in_array($ep, $ipmap)) { $ipmap[] = $ep; } @@ -675,8 +672,9 @@ EOD; $uniqueids = 'yes'; if (!empty($config['ipsec']['uniqueids'])) { - if (array_key_exists($config['ipsec']['uniqueids'], $ipsec_idhandling)) + if (array_key_exists($config['ipsec']['uniqueids'], $ipsec_idhandling)) { $uniqueids = $config['ipsec']['uniqueids']; + } } $natfilterrules = false; /* begin ipsec.conf */ @@ -898,8 +896,9 @@ EOD; if (isset($ph1ent['mobile'])) { $authentication = "eap_identity=%identity\n\t"; $authentication .= "leftauth=pubkey\n\trightauth=eap-radius"; - if (!empty($ph1ent['certref'])) + if (!empty($ph1ent['certref'])) { $authentication .= "\n\tleftcert={$certpath}/cert-{$ph1ent['ikeid']}.crt"; + } } else { $authentication = "leftauth=eap-radius\n\trightauth=eap-radius"; if (!empty($ph1ent['certref'])) { @@ -991,7 +990,7 @@ EOD; /* Do not print localid in some cases, such as a pure-psk or psk/xauth single phase2 mobile tunnel */ if (($localid_type == "none" || $localid_type == "mobile") && - isset($ph1ent['mobile']) && (ipsec_get_number_of_phase2($ikeid)==1)) { + isset($ph1ent['mobile']) && (ipsec_get_number_of_phase2($ikeid) == 1)) { $left_spec = '%any'; } else { if ($localid_type != "address") { diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc index e7af433..08d9b19 100644 --- a/etc/inc/xmlparse.inc +++ b/etc/inc/xmlparse.inc @@ -180,7 +180,7 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") { xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "cdata"); - xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 1); if (!($fp = fopen($cffile, "r"))) { log_error(gettext("Error: could not open XML input") . "\n"); @@ -285,9 +285,9 @@ function dump_xml_config_sub($arr, $indent) { (substr($ent, 0, 9) == "ldap_bind") || (substr($ent, 0, 11) == "ldap_basedn") || (substr($ent, 0, 18) == "ldap_authcn") || - (substr($ent, 0, 19) == "ldap_extended_query")) + (substr($ent, 0, 19) == "ldap_extended_query")) { $xmlconfig .= "<$ent><![CDATA[" . htmlentities($val) . "]]></$ent>\n"; - else { + } else { $xmlconfig .= "<$ent>" . htmlentities($val) . "</$ent>\n"; } } diff --git a/etc/inc/xmlparse_attr.inc b/etc/inc/xmlparse_attr.inc index a024c20..ab90e98 100644 --- a/etc/inc/xmlparse_attr.inc +++ b/etc/inc/xmlparse_attr.inc @@ -190,7 +190,7 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst xml_set_element_handler($xml_parser, "startElement_attr", "endElement_attr"); xml_set_character_data_handler($xml_parser, "cData_attr"); - xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 1); if (!($fp = fopen($cffile, "r"))) { log_error(gettext("Error: could not open XML input") . "\n"); diff --git a/etc/inc/zeromq.inc b/etc/inc/zeromq.inc index eb1d432..6b513d3 100644 --- a/etc/inc/zeromq.inc +++ b/etc/inc/zeromq.inc @@ -240,7 +240,7 @@ function restore_config_section_zeromq($raw_params) { } $config = array_merge($config, $params[3]); $mergedkeys = implode(",", array_keys($params[3])); - write_config(sprintf(gettext("Merged in config (%s sections) from ZeroMQ client."),$mergedkeys)); + write_config(sprintf(gettext("Merged in config (%s sections) from ZeroMQ client."), $mergedkeys)); return ZEROMQ_FASLE; } @@ -252,7 +252,7 @@ function merge_installedpackages_section_zeromq($raw_params) { } $config['installedpackages'] = array_merge($config['installedpackages'], $params[0]); $mergedkeys = implode(",", array_keys($params[3])); - write_config(sprintf(gettext("Merged in config (%s sections) from ZeroMQ client."),$mergedkeys)); + write_config(sprintf(gettext("Merged in config (%s sections) from ZeroMQ client."), $mergedkeys)); return ZEROMQ_FASLE; } diff --git a/etc/rc.bootup b/etc/rc.bootup index a8f6b3f..7eca7f6 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -48,7 +48,7 @@ function rescue_detect_keypress() { echo "Timeout before auto boot continues (seconds): {$timeout}"; $key = null; exec("/bin/stty erase " . chr(8)); - while (!in_array($key, array("c", "C", "r","R", "i", "I", "~", "!"))) { + while (!in_array($key, array("c", "C", "r", "R", "i", "I", "~", "!"))) { echo chr(8) . "{$timeout}"; `/bin/stty -icanon min 0 time 25`; $key = trim(`KEY=\`dd count=1 2>/dev/null\`; echo \$KEY`); diff --git a/etc/rc.dhclient_cron b/etc/rc.dhclient_cron index 7020748..f091a50 100755 --- a/etc/rc.dhclient_cron +++ b/etc/rc.dhclient_cron @@ -38,7 +38,7 @@ vc_invalidate(); unlink_if_exists("/tmp/config.cache"); $iflist = get_configured_interface_with_descr(); -foreach($iflist as $ifname => $interface) { +foreach ($iflist as $ifname => $interface) { $real_interface = get_real_interface($ifname); if ($config['interfaces'][$ifname]['ipaddr'] == "dhcp") { $pid = find_dhclient_process($real_interface); diff --git a/etc/rc.expireaccounts b/etc/rc.expireaccounts index 0bf578e..7aa897d 100755 --- a/etc/rc.expireaccounts +++ b/etc/rc.expireaccounts @@ -34,19 +34,22 @@ require_once("functions.inc"); $removed = 0; - if (!is_array($config['system']['user'])) + if (!is_array($config['system']['user'])) { return; + } $count = count($config['system']['user']); $index = 0; for (; $index < $count; $index++) { $user =& $config['system']['user'][$index]; - if ($user['scope'] == "system") + if ($user['scope'] == "system") { continue; + } echo "1\n"; echo "User {$user['name']} expires {$user['expires']}\n"; - if (!$user['expires'] || isset($user['disabled'])) + if (!$user['expires'] || isset($user['disabled'])) { continue; + } echo "1\n"; if (strtotime("-1 day") > strtotime($user['expires'])) { echo "Disabling user {$user['name']} at index #{$index}\n"; diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index fc65b75..f8aaea2 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -50,15 +50,17 @@ require_once("interfaces.inc"); function backup_vip_config_section() { global $config; - if (!is_array($config['virtualip']['vip'])) + if (!is_array($config['virtualip']['vip'])) { return; + } $temp = array(); $temp['vip'] = array(); foreach ($config['virtualip']['vip'] as $section) { if (($section['mode'] == 'proxyarp' || $section['mode'] == 'ipalias') && (strpos($section['interface'], '_vip') === FALSE) && - (strpos($section['interface'], 'lo0') === FALSE)) + (strpos($section['interface'], 'lo0') === FALSE)) { continue; + } if ($section['advskew'] <> "") { $section_val = intval($section['advskew']); $section_val=$section_val+100; @@ -81,7 +83,7 @@ function backup_vip_config_section() { function remove_special_characters($string) { $match_array = ""; - preg_match_all("/[a-zA-Z0-9\_\-]+/",$string,$match_array); + preg_match_all("/[a-zA-Z0-9\_\-]+/", $string, $match_array); $string = ""; foreach ($match_array[0] as $ma) { if ($string <> "") { @@ -95,8 +97,9 @@ function remove_special_characters($string) { function carp_check_version($url, $username, $password, $port = 80, $method = 'pfsense.host_firmware_version') { global $config, $g; - if (file_exists("{$g['varrun_path']}/booting") || platform_booting()) + if (file_exists("{$g['varrun_path']}/booting") || platform_booting()) { return; + } $params = array( XML_RPC_encode($password) @@ -147,8 +150,9 @@ function carp_check_version($url, $username, $password, $port = 80, $method = 'p function carp_sync_xml($url, $username, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') { global $config, $g; - if (file_exists("{$g['varrun_path']}/booting") || platform_booting()) + if (file_exists("{$g['varrun_path']}/booting") || platform_booting()) { return; + } update_filter_reload_status("Syncing CARP data to {$url}"); @@ -285,8 +289,9 @@ function carp_sync_xml($url, $username, $password, $sections, $port = 80, $metho } } -if (platform_booting()) +if (platform_booting()) { return; +} if (is_array($config['hasync'])) { update_filter_reload_status("Building high availability sync information"); @@ -448,12 +453,14 @@ if (is_array($config['hasync'])) { $username = $hasync['username']; } - if (!carp_check_version($synchronizetoip, $username, $hasync['password'], $port)) + if (!carp_check_version($synchronizetoip, $username, $hasync['password'], $port)) { return; + } update_filter_reload_status("Signaling CARP reload signal..."); - if (carp_sync_xml($synchronizetoip, $username, $hasync['password'], $sections, $port) == -1) + if (carp_sync_xml($synchronizetoip, $username, $hasync['password'], $sections, $port) == -1) { return; + } $cli = new XML_RPC_Client('/xmlrpc.php', $synchronizetoip, $port); $params = array( XML_RPC_encode($hasync['password']) diff --git a/etc/rc.initial.firmware_update b/etc/rc.initial.firmware_update index 3c6a4ee..bd1d16f 100755 --- a/etc/rc.initial.firmware_update +++ b/etc/rc.initial.firmware_update @@ -11,7 +11,7 @@ echo "Starting the {$g['product_name']} console firmware update system"; require("functions.inc"); echo "."; -if(isset($config['system']['firmware']['alturl']['enable'])) { +if (isset($config['system']['firmware']['alturl']['enable'])) { $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}"; } else { $updater_url = $g['update_url']; @@ -95,8 +95,8 @@ switch ($command) { } } if (file_exists("/root/firmware.tgz.sha256")) { - $source_sha256 = trim(`cat /root/firmware.tgz.sha256 | awk '{ print \$4 }'`,"\r"); - $file_sha256 = trim(`sha256 /root/firmware.tgz | awk '{ print \$4 }'`,"\r"); + $source_sha256 = trim(`cat /root/firmware.tgz.sha256 | awk '{ print \$4 }'`, "\r"); + $file_sha256 = trim(`sha256 /root/firmware.tgz | awk '{ print \$4 }'`, "\r"); echo "URL sha256: $source_sha256\n"; echo "Downloaded file sha256: $file_sha256\n"; if ($source_sha256 <> $file_sha256) { @@ -109,10 +109,10 @@ switch ($command) { echo "\nsha256 checksum matches.\n"; unlink_if_exists("/root/firmware.tgz.sha256"); } - if (strstr($url,"bdiff")) { + if (strstr($url, "bdiff")) { echo "Binary DIFF upgrade file detected...\n"; $type = "bdiff"; - } elseif (strstr($url,"nanobsd")) { + } elseif (strstr($url, "nanobsd")) { echo "NanoBSD upgrade file detected...\n"; $type = "nanobsd"; } else { @@ -129,10 +129,10 @@ switch ($command) { fclose($fp); die; } - if (stristr($path,"bdiff")) { + if (stristr($path, "bdiff")) { $type = "bdiff"; } - if (stristr($path,"nanobsd")) { + if (stristr($path, "nanobsd")) { $type = "nanobsd"; } if (file_exists($path)) { diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip index 62ca93b..b64dec8 100755 --- a/etc/rc.initial.setlanip +++ b/etc/rc.initial.setlanip @@ -113,8 +113,8 @@ function prompt_for_enable_dhcp_server($version = 4) { function get_interface_config_description($iface) { global $config; $c = $config['interfaces'][$iface]; - if (!$c) { - return null; + if (!$c) { + return null; } $if = $c['if']; $result = $if; @@ -158,10 +158,12 @@ if ($count > 1) { $intnum = $count; } -if ($intnum < 1) +if ($intnum < 1) { return; -if ($intnum > $count) +} +if ($intnum > $count) { return; +} $index = 1; foreach ($ifdescrs as $ifname => $ifdesc) { @@ -422,10 +424,12 @@ function console_configure_dhcpd($version = 4) { return 1; } -if (console_configure_dhcpd(4) == 0) +if (console_configure_dhcpd(4) == 0) { return 0; -if (console_configure_dhcpd(6) == 0) +} +if (console_configure_dhcpd(6) == 0) { return 0; +} //***************************************************************************** diff --git a/etc/rc.initial.store_config_to_removable_device b/etc/rc.initial.store_config_to_removable_device index bd92446..ee1dda4 100755 --- a/etc/rc.initial.store_config_to_removable_device +++ b/etc/rc.initial.store_config_to_removable_device @@ -47,7 +47,7 @@ } echo "\nDevices capable of config.xml storage:\n"; foreach ($dirs as $dir) { - preg_match_all("/capable\_(.*)/",$dir,$match_array); + preg_match_all("/capable\_(.*)/", $dir, $match_array); echo $match_array[1][0] . " "; } echo "\n\n"; diff --git a/etc/rc.kill_states b/etc/rc.kill_states index fe5a296..ca70729 100755 --- a/etc/rc.kill_states +++ b/etc/rc.kill_states @@ -34,8 +34,9 @@ require_once("interfaces.inc"); require_once("util.inc"); // Do not process while booting -if (platform_booting()) +if (platform_booting()) { return; +} /* Interface address to cleanup states */ $interface = str_replace("\n", "", $argv[1]); diff --git a/etc/rc.linkup b/etc/rc.linkup index f5d4034..ed7ea23 100755 --- a/etc/rc.linkup +++ b/etc/rc.linkup @@ -117,7 +117,7 @@ if (isset($_GET['interface'])) { $realiface = $argv[2]; } -switch($action) { +switch ($action) { case "start": case "stop": break; diff --git a/etc/rc.newwanip b/etc/rc.newwanip index 79d07a4..6c6d617 100755 --- a/etc/rc.newwanip +++ b/etc/rc.newwanip @@ -82,7 +82,7 @@ if (empty($argument)) { $curwanip = get_interface_ip(); } else { $curwanip = find_interface_ip($interface_real, true); - if($curwanip == "") { + if ($curwanip == "") { $curwanip = get_interface_ip($interface); } } @@ -189,7 +189,7 @@ if (!empty($gif)) { } } if (!empty($gre)) { - foreach($gre as $gretun) { + foreach ($gre as $gretun) { $confif = convert_real_interface_to_friendly_interface_name($gretun['greif']); if (!empty($confif)) { interface_configure($confif); diff --git a/etc/rc.openvpn b/etc/rc.openvpn index ce5ea96..e54d6d5 100755 --- a/etc/rc.openvpn +++ b/etc/rc.openvpn @@ -95,7 +95,7 @@ if (!$openvpnlck) { $openvpnlck = lock('openvpn', LOCK_EX); } -$arg_array = explode(",",$argument); +$arg_array = explode(",", $argument); foreach ($arg_array as $arg_element) { $gwgroups = array(); if ($arg_element == "all") { diff --git a/etc/rc.restore_config_backup b/etc/rc.restore_config_backup index a1a3022..295f427 100755 --- a/etc/rc.restore_config_backup +++ b/etc/rc.restore_config_backup @@ -9,7 +9,7 @@ unset($confvers['versions']); $fp = fopen('php://stdin', 'r'); function print_backup_info($backup_info, $number) { - if($backup_info['time'] != 0) { + if ($backup_info['time'] != 0) { $date = date(gettext("n/j/y H:i:s"), $backup_info['time']); } else { $date = gettext("Unknown"); @@ -101,8 +101,9 @@ while (true) { $command = strtolower(chop(fgets($fp))); // Make sure we can detect a foreign language "quit" command. - if (strtolower($command) == gettext("quit")) + if (strtolower($command) == gettext("quit")) { $command = "quit"; + } switch ($command) { case "q": |