Commit 15c0ce09 authored by Franco Fichtner's avatar Franco Fichtner

inc: apply last batch of whitespace cleanups

Also reapply a few after recent merge/rebase action in the CP.
parent 1a3cfae0
......@@ -264,9 +264,9 @@ function get_default_captive_portal_html() {
global $config, $g, $cpzone;
$htmltext = <<<EOD
<html>
<body>
<form method="post" action="\$PORTAL_ACTION\$">
<html>
<body>
<form method="post" action="\$PORTAL_ACTION\$">
<input name="redirurl" type="hidden" value="\$PORTAL_REDIRURL\$">
<input name="zone" type="hidden" value="\$PORTAL_ZONE\$">
<center>
......@@ -347,7 +347,7 @@ EOD;
</table>
</center>
</form>
</body>
</body>
</html>
EOD;
......@@ -658,7 +658,7 @@ function captiveportal_init_webgui_zone($cpcfg) {
}
/*
/*
* Remove clients that have been around for longer than the specified amount of time
* db file structure:
* timestamp,ipfw_rule_no,clientip,clientmac,username,sessionid,password,session_timeout,idle_timeout,session_terminate_time,interim_interval
......@@ -680,7 +680,7 @@ function captiveportal_prune_old() {
}else{
// cleanup sessions if radius accounting is enable
// TODO: this code needs a rewrite, probably the easiest thing todo is update the zone administration and run
// the normal cleanup (portal_cleanup_sessions) to detach both processes
// the normal cleanup (portal_cleanup_sessions) to detach both processes
//
$vcpcfg = $config['voucher'][$cpzone];
......
<?php
/****h* pfSense/config
* NAME
* config.inc - Functions to manipulate config.xml
* DESCRIPTION
* This include contains various config.xml specific functions.
* HISTORY
* $Id$
******
config.console.inc
Copyright (C) 2004-2010 Scott Ullrich
All rights reserved.
originally part of m0n0wall (http://m0n0.ch/wall)
/*
Copyright (C) 2004-2010 Scott Ullrich
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
......@@ -36,18 +25,17 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
pfSense_BUILDER_BINARIES: /sbin/mount /sbin/umount /sbin/halt /sbin/fsck
pfSense_MODULE: config
*/
function set_networking_interfaces_ports() {
function set_networking_interfaces_ports()
{
global $noreboot;
global $config;
global $g;
global $fp;
$yes_no_prompt = '[y|n]? ';
$fp = fopen('php://stdin', 'r');
$memory = get_memory();
......@@ -66,7 +54,7 @@ function set_networking_interfaces_ports() {
$iflist = get_interface_list();
/* Function flow is based on $key and $auto_assign or the lack thereof */
/* Function flow is based on $key and $auto_assign or the lack thereof */
$key = null;
/* Only present auto interface option if running from LiveCD and interface mismatch*/
......@@ -92,21 +80,21 @@ EOD;
if ($auto_assign) {
echo <<<EOD
!!! LiveCD Detected: Auto Interface Option !!!!
BEGIN MANUAL CONFIGURATION OR WE WILL PROCEED WITH AUTO CONFIGURATION.
EOD;
}
}
echo <<<EOD
Do you want to set up VLANs first?
Do you want to set up VLANs first?
If you are not going to use VLANs, or only for optional interfaces, you should
say no here and use the webConfigurator to configure VLANs later, if required.
Do you want to set up VLANs now [y|n]?
Do you want to set up VLANs now ${yes_no_prompt}
EOD;
if ($auto_assign) {
......@@ -132,16 +120,16 @@ now is the time to do so.
We'll keep trying until you do.
Searching for active interfaces...
EOD;
unset($wanif, $lanif);
$media_iflist = $plugged_in = array();
$media_iflist = get_interface_list("media");
foreach ($media_iflist as $iface => $ifa) {
if ($ifa['up'])
if ($ifa['up'])
$plugged_in[] = $iface;
}
$lanif = array_shift($plugged_in);
......@@ -158,11 +146,11 @@ EOD;
echo <<<EOD
Assigned WAN to : $wanif
Assigned LAN to : $lanif
Assigned WAN to : ${wanif}
Assigned LAN to : ${lanif}
If you don't like this assignment,
press any key to go back to manual configuration.
press any key to go back to manual configuration.
EOD;
$key = timeout(20);
......@@ -170,33 +158,33 @@ EOD;
return;
} while (!isset($wanif));
$config['system']['enablesshd'] = 'enabled';
$config['system']['enablesshd'] = 'enabled';
$key = 'y';
} else { //Manually assign interfaces
} else { //Manually assign interfaces
if (in_array($key, array('y', 'Y')))
vlan_setup();
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
echo "\n\n" . gettext("VLAN interfaces:") . "\n\n";
foreach ($config['vlans']['vlan'] as $vlan) {
echo sprintf("% -16s%s\n", "{$vlan['if']}_vlan{$vlan['tag']}",
"VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}");
$iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array();
}
}
echo <<<EOD
If you do not know the names of your interfaces, you may choose to use
auto-detection. In that case, disconnect all interfaces now before
hitting 'a' to initiate auto detection.
EOD;
do {
echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection:") . " ";
$wanif = chop(fgets($fp));
......@@ -211,22 +199,22 @@ EOD;
continue;
}
} while (!$wanif);
do {
printf(gettext("%sEnter the LAN interface name or 'a' for auto-detection %s" .
"NOTE: this enables full Firewalling/NAT mode.%s" .
"(or nothing if finished):%s"), "\n", "\n", "\n", " ");
$lanif = chop(fgets($fp));
if($lanif == "exit") {
exit;
}
if($lanif == "") {
break;
}
if ($lanif === "a")
$lanif = autodetect_interface("LAN", $fp);
else if (!array_key_exists($lanif, $iflist)) {
......@@ -235,11 +223,11 @@ EOD;
continue;
}
} while (!$lanif);
/* optional interfaces */
$i = 0;
$optif = array();
if($lanif <> "") {
while (1) {
if ($optif[$i])
......@@ -248,12 +236,12 @@ EOD;
if($config['interfaces']['opt' . $io]['descr'])
printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']);
printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" .
"(or nothing if finished):%s"), "\n", $io, "\n", " ");
$optif[$i] = chop(fgets($fp));
if ($optif[$i]) {
if ($optif[$i] === "a") {
$ad = autodetect_interface(gettext("Optional") . " " . $io, $fp);
......@@ -272,38 +260,38 @@ EOD;
}
}
}
/* check for double assignments */
$ifarr = array_merge(array($lanif, $wanif), $optif);
for ($i = 0; $i < (count($ifarr)-1); $i++) {
for ($j = ($i+1); $j < count($ifarr); $j++) {
if ($ifarr[$i] == $ifarr[$j]) {
echo <<<EOD
Error: you cannot assign the same interface name twice!
EOD;
fclose($fp);
return;
}
}
}
echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n";
echo "WAN -> " . $wanif . "\n";
if ($lanif != "")
echo "LAN -> " . $lanif . "\n";
for ($i = 0; $i < count($optif); $i++) {
echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n";
}
echo <<<EOD
Do you want to proceed [y|n]?
Do you want to proceed ${yes_no_prompt}
EOD;
$key = chop(fgets($fp));
$key = chop(fgets($fp));
}
if (in_array($key, array('y', 'Y'))) {
......@@ -319,7 +307,7 @@ echo <<<EODD
You have chosen to remove the LAN interface.
Would you like to remove the LAN IP address and
unload the interface now? [y|n]?
unload the interface now ${yes_no_prompt}
EODD;
if (strcasecmp(chop(fgets($fp)), "y") == 0) {
......@@ -339,7 +327,7 @@ EODD;
if(isset($config['ezshaper']))
unset($config['ezshaper']);
if(isset($config['nat']))
unset($config['nat']);
unset($config['nat']);
} else {
if(isset($config['interfaces']['lan']['if']))
mwexec("/sbin/ifconfig " . $config['interfaces']['lan']['if'] . " delete");
......@@ -356,7 +344,7 @@ EODD;
if(isset($config['ezshaper']))
unset($config['ezshaper']);
if(isset($config['nat']))
unset($config['nat']);
unset($config['nat']);
}
if (preg_match($g['wireless_regex'], $lanif)) {
if (is_array($config['interfaces']['lan']) &&
......@@ -424,8 +412,9 @@ EODD;
}
}
function autodetect_interface($ifname, $fp) {
$iflist_prev = get_interface_list("media");
function autodetect_interface($ifname, $fp)
{
$iflist_prev = get_interface_list('media');
echo <<<EOD
Connect the {$ifname} interface now and make sure that the link is up.
......@@ -447,16 +436,11 @@ EOD;
return null;
}
function interfaces_setup() {
function vlan_setup()
{
global $iflist, $config, $g, $fp;
$iflist = get_interface_list();
}
function vlan_setup() {
global $iflist, $config, $g, $fp;
$yes_no_prompt = '[y|n]? ';
$iflist = get_interface_list();
......@@ -466,7 +450,7 @@ function vlan_setup() {
WARNING: all existing VLANs will be cleared if you proceed!
Do you want to proceed [y|n]?
Do you want to proceed ${yes_no_prompt}
EOD;
if (strcasecmp(chop(fgets($fp)), "y") != 0)
......@@ -520,10 +504,8 @@ EOD;
printf(gettext("%sInvalid VLAN tag '%s'%s"), "\n", $vlan['tag'], "\n");
continue;
}
$config['vlans']['vlan'][] = $vlan;
$vlanif++;
}
}
?>
......@@ -4,17 +4,17 @@
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2007 Marcel Wiget <mwiget@mac.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
......@@ -243,7 +243,7 @@ function voucher_expire($voucher_received) {
}
// split into an array. Useful for multiple vouchers given
$a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received);
$a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received);
$active_dirty = false;
// go through all received vouchers, check their valid and extract
......@@ -257,9 +257,9 @@ function voucher_expire($voucher_received) {
$_gb = exec("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher_{$cpzone}.cfg -k {$g['varetc_path']}/voucher_{$cpzone}.public -- $v", $output);
list($status, $roll, $nr) = explode(" ", $output[0]);
if ($status == "OK") {
// check if we have this ticket on a registered roll for this ticket
// check if we have this ticket on a registered roll for this ticket
if ($tickets_per_roll[$roll] && ($nr <= $tickets_per_roll[$roll])) {
// voucher is from a registered roll.
// voucher is from a registered roll.
if (!isset($active_vouchers[$roll]))
$active_vouchers[$roll] = voucher_read_active_db($roll);
// valid voucher. Store roll# and ticket#
......@@ -321,7 +321,7 @@ function voucher_expire($voucher_received) {
return true;
}
/*
/*
* Authenticate a voucher and return the remaining time credit in minutes
* if $test is set, don't mark the voucher as used nor add it to the list
* of active vouchers
......@@ -356,7 +356,7 @@ function voucher_auth($voucher_received, $test = 0) {
}
// split into an array. Useful for multiple vouchers given
$a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received);
$a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received);
$error = 0;
$test_result = array(); // used to display for voucher test option in GUI
$total_minutes = 0;
......@@ -378,9 +378,9 @@ function voucher_auth($voucher_received, $test = 0) {
$first_voucher = $voucher;
$first_voucher_roll = $roll;
}
// check if we have this ticket on a registered roll for this ticket
// check if we have this ticket on a registered roll for this ticket
if ($tickets_per_roll[$roll] && ($nr <= $tickets_per_roll[$roll])) {
// voucher is from a registered roll.
// voucher is from a registered roll.
if (!isset($active_vouchers[$roll]))
$active_vouchers[$roll] = voucher_read_active_db($roll);
// valid voucher. Store roll# and ticket#
......@@ -448,7 +448,7 @@ function voucher_auth($voucher_received, $test = 0) {
if (!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) {
if (!is_null($remote_time_used))
$total_minutes = $remote_time_used;
else if ($remote_time_used < $total_minutes)
else if ($remote_time_used < $total_minutes)
$total_minutes -= $remote_time_used;
}
......@@ -572,7 +572,7 @@ function voucher_configure_zone($sync = false) {
return 0;
}
/* write bitstring of used vouchers to ramdisk.
/* write bitstring of used vouchers to ramdisk.
* Bitstring must already be base64_encoded!
*/
function voucher_write_used_db($roll, $vdb) {
......@@ -587,7 +587,7 @@ function voucher_write_used_db($roll, $vdb) {
}
/* return assoc array of active vouchers with activation timestamp
* voucher is index.
* voucher is index.
*/
function voucher_read_active_db($roll) {
global $g, $cpzone;
......@@ -642,7 +642,7 @@ function voucher_used_count($roll) {
$max = strlen($bitstring) * 8;
$used = 0;
for ($i = 1; $i <= $max; $i++) {
// check if ticket already used or not.
// check if ticket already used or not.
$pos = $i >> 3; // divide by 8 -> octet
$mask = 1 << ($i % 8); // mask to test bit in octet
if (ord($bitstring[$pos]) & $mask)
......@@ -701,7 +701,7 @@ function voucher_save_db_to_config() {
function voucher_save_db_to_config_zone() {
global $config, $g, $cpzone;
if (!isset($config['voucher'][$cpzone]['enable']))
return; // no vouchers or don't want to save DB's
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment