summaryrefslogtreecommitdiffstats
path: root/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-31 10:55:20 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-31 10:55:20 +0545
commit086cf944580b3a62a7c0e5dcbd2b92115cfb1334 (patch)
tree5043b938bdfd715daf231bfa3825d0b51c8c16f3 /etc/inc/pfsense-utils.inc
parent5be3060472b257e0f171669b91d4e407960463e6 (diff)
downloadpfsense-086cf944580b3a62a7c0e5dcbd2b92115cfb1334.zip
pfsense-086cf944580b3a62a7c0e5dcbd2b92115cfb1334.tar.gz
Code style bits and pieces from etc
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r--etc/inc/pfsense-utils.inc44
1 files changed, 21 insertions, 23 deletions
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) {
OpenPOWER on IntegriCloud