Commit 7a846b49 authored by Franco Fichtner's avatar Franco Fichtner

src: first of many whitspace cleanups

parent 11f56521
......@@ -17,7 +17,7 @@ if [ -f /var/log/dmesg.boot ]; then
fi
fi
# Check for different HZ
# Check for different HZ
if [ -f /boot/loader.conf ]; then
HZ=`/usr/bin/grep -c kern.hz /boot/loader.conf`
if [ "$HZ" = "1" ]; then
......@@ -25,7 +25,7 @@ if [ -f /boot/loader.conf ]; then
fi
fi
if [ -c "/dev/speaker" ]; then
if [ -c "/dev/speaker" ]; then
if [ "$1" = "start" ]; then
/usr/local/bin/beep -p 500 $NOTELENGTH
/usr/local/bin/beep -p 400 $NOTELENGTH
......
......@@ -120,4 +120,4 @@ if (($argc > 1) && !empty($argv[1])) {
echo " " . basename($argv[0]) . " pass wan icmp 1.2.3.4 192.168.0.4\n";
echo "\n";
}
?>
\ No newline at end of file
?>
......@@ -30,8 +30,8 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
A quick CLI log parser.
Examples:
A quick CLI log parser.
Examples:
clog /var/log/filter.log | tail -50 | /usr/local/www/filterparser.php
clog -f /var/log/filter.log | /usr/local/www/filterparser.php
*/
......@@ -44,7 +44,7 @@ include_once("filter_log.inc");
$log = fopen("php://stdin", "r");
$lastline = "";
while(!feof($log)) {
while(!feof($log)) {
$line = fgets($log);
$line = rtrim($line);
$flent = parse_filter_line(trim($line));
......
......@@ -21,4 +21,4 @@ if (!empty($subject))
send_smtp_message($message, $subject);
else
send_smtp_message($message);
?>
\ No newline at end of file
?>
......@@ -131,4 +131,3 @@ for TOPING in $PINGHOSTS ; do
done
exit 0
#!/bin/sh
vi /cf/conf/config.xml
rm /tmp/config.cache
\ No newline at end of file
rm /tmp/config.cache
......@@ -206,7 +206,7 @@ EOD;
$user = $_POST['auth_user'];
else if (!empty($_POST['auth_user2']))
$user = $_POST['auth_user2'];
else
else
$user = 'unknown';
captiveportal_logportalauth($user ,$clientmac,$clientip,"ERROR");
portal_reply_page($redirurl, "error", $errormsg);
......
......@@ -7,30 +7,30 @@
Copyright (c) 2006, Jonathan De Graeve <jonathan.de.graeve@imelda.be>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
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
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
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.
3. The names of the authors may not be used to endorse or promote products
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN 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.
This code cannot simply be copied and put under the GNU Public License or
This code cannot simply be copied and put under the GNU Public License or
any other GPL-like (LGPL, GPL2) License.
This code is made possible thx to samples made by Michael Bretterklieber <michael@bretterklieber.com>
......@@ -45,7 +45,7 @@
define('GIGAWORDS_RIGHT_OPERAND', '4294967296'); // 2^32
/*
RADIUS ACCOUNTING START
RADIUS ACCOUNTING START
-----------------------
*/
......@@ -202,9 +202,9 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
$racct = new Auth_RADIUS_Acct_Stop;
/*
Add support for more then one radiusserver.
At most 10 servers may be specified.
When multiple servers are given, they are tried in round-robin fashion until a valid response is received
Add support for more then one radiusserver.
At most 10 servers may be specified.
When multiple servers are given, they are tried in round-robin fashion until a valid response is received
*/
foreach ($radiusservers as $radsrv) {
// Add a new server to our instance
......
......@@ -6,30 +6,30 @@
Copyright (c) 2006, Jonathan De Graeve <jonathan.de.graeve@imelda.be>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
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
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
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.
3. The names of the authors may not be used to endorse or promote products
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN 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.
This code cannot simply be copied and put under the GNU Public License or
This code cannot simply be copied and put under the GNU Public License or
any other GPL-like (LGPL, GPL2) License.
This code is made possible thx to samples made by Michael Bretterklieber <michael@bretterklieber.com>
......@@ -64,14 +64,14 @@ function RADIUS_AUTHENTICATION($username,$password,$radiusservers,$clientip,$cli
switch($radiusvendor) {
case 'cisco':
$calledstationid = $clientmac;
$callingstationid = $clientip;
break;
$calledstationid = $clientmac;
$callingstationid = $clientip;
break;
default:
if (!function_exists('getNasIP'))
require_once("captiveportal.inc");
$calledstationid = getNasIP();
$callingstationid = $clientmac;
$calledstationid = getNasIP();
$callingstationid = $clientmac;
break;
}
......@@ -80,9 +80,9 @@ function RADIUS_AUTHENTICATION($username,$password,$radiusservers,$clientip,$cli
$rauth = new $classname($username, $password);
/*
* Add support for more then one radiusserver.
* At most 10 servers may be specified.
* When multiple servers are given, they are tried in round-robin fashion until a valid response is received
* Add support for more then one radiusserver.
* At most 10 servers may be specified.
* When multiple servers are given, they are tried in round-robin fashion until a valid response is received
*/
foreach ($radiusservers as $radsrv) {
// Add a new server to our instance
......@@ -126,7 +126,7 @@ function RADIUS_AUTHENTICATION($username,$password,$radiusservers,$clientip,$cli
if (PEAR::isError($rauth->start())) {
$retvalue['auth_val'] = 1;
$retvalue['error'] = $rauth->getError();
$retvalue['error'] = $rauth->getError();
// If we encounter an error immediately stop this function and go back
$rauth->close();
......
......@@ -234,4 +234,4 @@ WS Samoa
YE Yemen
YT Mayotte
ZA South Africa
ZM Zambia
\ No newline at end of file
ZM Zambia
......@@ -76,4 +76,4 @@ if ($password == $confpassword) {
} else {
echo gettext("New and Confirm passwords did not match.") . "\n";
exit(-1);
}
\ No newline at end of file
}
......@@ -10,4 +10,4 @@ write_config("pfSsh.php disabled dhcp on all interfaces");
services_dhcpd_configure();
echo "done.\n";
\ No newline at end of file
echo "done.\n";
......@@ -31,4 +31,4 @@ unset($config['interfaces']['wan']['blockbogons']);
$config = parse_config(true);
echo "Reloading the filter configuration...";
filter_configure_sync();
echo "\n\n";
\ No newline at end of file
echo "\n\n";
......@@ -10,7 +10,7 @@ require_once("filter.inc");
require_once("shaper.inc");
require_once("rrd.inc");
require_once("pfsense-utils.inc");
$GIT_PKG = "git"; // Either "git" or the full package URL
$GIT_BIN= "/usr/pbi/bin/git";
$GIT_REPO = "git://github.com/pfsense/pfsense.git";
......@@ -106,15 +106,15 @@ if(!file_exists($GIT_BIN)) {
}
# Remove mainline if exists (older)
if(is_dir("/root/pfsense/mainline"))
if(is_dir("/root/pfsense/mainline"))
exec("rm -rf /root/pfsense/mainline");
# Remove RELENG_1_2 if exists (older)
if(is_dir("/root/pfsense/RELENG_1_2"))
if(is_dir("/root/pfsense/RELENG_1_2"))
exec("rm -rf /root/pfsense/RELENG_1_2");
# Remove HEAD if exists (older)
if(is_dir("/root/pfsense/HEAD"))
if(is_dir("/root/pfsense/HEAD"))
exec("rm -rf /root/pfsense/HEAD");
if(file_exists("/root/cvssync_backup.tgz")) {
......@@ -143,9 +143,9 @@ if(!$args[0] && !$upgrading) {
$branch = $args[0];
}
if($args[1] == "NOBACKUP")
if($args[1] == "NOBACKUP")
$nobackup = true;
else
else
$nobackup = false;
// If the repository has been fetched before, build a list of its branches.
......@@ -162,7 +162,7 @@ if(is_dir("$CODIR/pfSenseGITREPO/pfSenseGITREPO")) {
$found = false;
foreach($branches as $branchname => $branchdesc) {
if($branchname == $branch)
if($branchname == $branch)
$found = true;
}
if(!$found) {
......@@ -181,7 +181,7 @@ if(!$found) {
$command = readline("Checkout which branch [${DEFAULT_BRANCH}]? ");
if($command == "")
$branch = $DEFAULT_BRANCH;
if($command)
if($command)
$branch = $command;
$found = true;
}
......@@ -283,9 +283,9 @@ if(is_dir("$CODIR/pfSenseGITREPO/pfSenseGITREPO")) {
exec("mkdir -p $CODIR/pfSenseGITREPO");
echo "Executing cd $CODIR/pfSenseGITREPO && {$GIT_BIN} clone $GIT_REPO pfSenseGITREPO\n";
exec("cd $CODIR/pfSenseGITREPO && {$GIT_BIN} clone " . escapeshellarg($GIT_REPO) . " pfSenseGITREPO");
if(is_dir("$CODIR/pfSenseGITREPO/pfSense"))
if(is_dir("$CODIR/pfSenseGITREPO/pfSense"))
exec("mv $CODIR/pfSenseGITREPO/pfSense $CODIR/pfSenseGITREPO/pfSenseGITREPO");
if(is_dir("$CODIR/pfSenseGITREPO/mainline"))
if(is_dir("$CODIR/pfSenseGITREPO/mainline"))
exec("mv $CODIR/pfSenseGITREPO/mainline $CODIR/pfSenseGITREPO/pfSenseGITREPO");
run_cmds($git_cmd);
}
......@@ -320,7 +320,7 @@ exec("mkdir -p /tmp/lighttpd/cache/compress/");
exec("cd ${CODIR}/pfSenseGITREPO/pfSenseGITREPO && find . -name CVS -exec rm -rf {} \; 2>/dev/null");
exec("cd ${CODIR}/pfSenseGITREPO/pfSenseGITREPO && find . -name pfSense.tgz -exec rm {} \; 2>/dev/null");
// Remove files that we do not want to overwrite the system with
// Remove files that we do not want to overwrite the system with
exec("rm ${CODIR}/pfSenseGITREPO/pfSenseGITREPO/etc/crontab 2>/dev/null");
exec("rm ${CODIR}/pfSenseGITREPO/pfSenseGITREPO/etc/master.passwd 2>/dev/null");
exec("rm ${CODIR}/pfSenseGITREPO/pfSenseGITREPO/etc/passwd 2>/dev/null");
......@@ -340,9 +340,9 @@ exec("rm -f ${CODIR}/pfSenseGITREPO/pfSenseGITREPO/etc/syslog.conf 2>/dev/null")
echo "===> Installing new files...\n";
if($g['platform'] == "pfSense")
if($g['platform'] == "pfSense")
$command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - {$files_to_copy} | (cd / ; tar -Uxpf -)";
else
else
$command = "cd $CODIR/pfSenseGITREPO/pfSenseGITREPO ; tar -cpf - {$files_to_copy} | (cd / ; tar -xpf -) 2>/dev/null";
if(!empty($files_to_copy))
exec($command);
......@@ -388,7 +388,7 @@ function post_cvssync_commands() {
/* lock down console if necessary */
echo "===> Locking down the console if needed...\n";
reload_ttys();
echo "===> Signaling PHP and Lighty restart...";
$fd = fopen("/tmp/restart_lighty", "w");
fwrite($fd, "#!/bin/sh\n");
......@@ -403,9 +403,9 @@ function post_cvssync_commands() {
}
function isUrl($url = "") {
if($url)
if(strstr($url, "rcs.pfsense.org") or
strstr($url, "mainline") or
if($url)
if(strstr($url, "rcs.pfsense.org") or
strstr($url, "mainline") or
strstr($url, ".git") or strstr($url, "git://"))
return true;
return false;
......
......@@ -21,4 +21,4 @@ if (write_config()) {
} else {
echo gettext("Unable to write config.xml (Access Denied?)\n");
}
filter_configure();
\ No newline at end of file
filter_configure();
......@@ -32,4 +32,4 @@ elseif ($remove_type == "xmlonly")
else
echo "Invalid removal type. Valid values are: normal, xmlonly.\n";
echo "\nDone.\n";
\ No newline at end of file
echo "\nDone.\n";
......@@ -45,7 +45,7 @@
}
function upnp_validate_ip($ip, $check_cdir) {
/* validate cidr */
/* validate cidr */
$ip_array = array();
if($check_cdir) {
$ip_array = explode('/', $ip);
......@@ -68,7 +68,7 @@
foreach(explode('-', $port) as $sub)
if($sub < 0 || $sub > 65535)
return false;
return true;
return true;
}
function before_form_miniupnpd(&$pkg) {
......@@ -117,7 +117,7 @@
$input_errors[] = "You must specify a valid ip address in the 'User specified permissions {$i}' field";
}
}
}
}
}
function sync_package_miniupnpd() {
......@@ -184,11 +184,11 @@
$config_text .= "bitrate_down={$download}\n";
$config_text .= "bitrate_up={$upload}\n";
}
/* enable logging of packets handled by miniupnpd rules */
if($upnp_config['logpackets'])
$config_text .= "packet_log=yes\n";
/* enable system uptime instead of miniupnpd uptime */
if($upnp_config['sysuptime'])
$config_text .= "system_uptime=yes\n";
......@@ -207,7 +207,7 @@
/* set model number */
$config_text .= "model_number=".file_get_contents("/usr/local/etc/version")."\n";
/* upnp access restrictions */
for($i=1; $i<=4; $i++) {
if($upnp_config["permuser{$i}"])
......@@ -231,11 +231,11 @@
/* write out the configuration */
upnp_write_config($config_file, $config_text);
/* if miniupnpd not running start it */
if(!upnp_running()) {
upnp_notice("Starting service on interface: {$ifaces_active}");
upnp_action('start');
upnp_action('start');
}
/* or restart miniupnpd if settings were changed */
else {
......@@ -251,7 +251,7 @@
if(!$upnp_config['enable'])
upnp_notice('Stopping service: miniupnpd disabled');
else
upnp_notice('Stopping service: no interfaces selected');
upnp_notice('Stopping service: no interfaces selected');
upnp_action('stop');
@unlink($config_file);
......
......@@ -42,7 +42,7 @@
<fieldname>enable</fieldname>
<type>checkbox</type>
<enablefields>enable_upnp,enable_natpmp,iface_array,overridewanip,upnpqueue,logpackets,sysuptime,permdefault,permuser1,permuser2,permuser3,permuser4</enablefields>
</field>
</field>
<field>
<fielddescr>Allow UPnP Port Mapping</fielddescr>
<fieldname>enable_upnp</fieldname>
......@@ -143,7 +143,7 @@
<description>Format: [allow or deny] [ext port or range] [int ipaddr or ipaddr/cdir] [int port or range]</description>
<type>input</type>
<size>60</size>
</field>
</field>
</fields>
<custom_php_command_before_form>
before_form_miniupnpd($pkg);
......
......@@ -48,7 +48,7 @@ if(strtoupper($command) == "Y" || strtoupper($command) == "YES") {
echo "\n\nStarting package wipe... One moment please... ";
exec("cd /var/db/pkg/ && find . -exec 'pkg_delete {}' \; ");
exec("rm -rf /var/db/pkg/*");
if(strtoupper($rmconfig) == "Y" || strtoupper($rmconfig) == "YES") {
echo "\nRemoving pfSense package configuration information...";
if($config['installedpackages']['package']) {
......@@ -57,8 +57,8 @@ if(strtoupper($command) == "Y" || strtoupper($command) == "YES") {
}
echo "\n";
}
echo "\npfSense package wipe procedure has completed.\n\n";
}
?>
\ No newline at end of file
?>
......@@ -233,7 +233,7 @@ add_new_routes() {
else
$ROUTE add default $router
echo $ROUTE add default $router | $LOGGER
echo $router > /tmp/${interface}_router
echo $router > /tmp/${interface}_router
fi
ADDED_ROUTE=yes
# 2nd and subsequent default routers error out, so explicitly
......@@ -248,7 +248,7 @@ add_new_routes() {
while [ $# -gt 1 ]; do
$ROUTE add $1 $2
if [ "$ADDED_ROUTE" = "no" ]; then
echo $2 > /tmp/${interface}_router
echo $2 > /tmp/${interface}_router
fi
shift; shift
done
......@@ -263,7 +263,7 @@ add_new_resolv_conf() {
$ROUTE delete $nameserver >/dev/null 2>&1
done
fi
if [ -n "$new_domain_name_servers" ]; then
if [ -n "$new_domain_name_servers" ]; then
/bin/rm -f /var/etc/nameserver_$interface
ALLOWOVERRIDE=`/usr/bin/grep dnsallowoverride /conf/config.xml | /usr/bin/wc -l`
for nameserver in $new_domain_name_servers; do
......
......@@ -89,4 +89,4 @@ if (count($notices)) {
if ($mirror_status != $previous_mirror_status)
file_put_contents($status_file, serialize($mirror_status));
?>
\ No newline at end of file
?>
......@@ -116,7 +116,7 @@ DialPeerSetAPN:
log $modemCmd
call ModemCmd2
return
# Null-modem connection
DialNullModem:
log "Connected via null modem connection."
......@@ -1396,7 +1396,7 @@ SetBaudrate2:
goto ModemCmd2
##
## ModemCheckValue
## ModemCheckValue
##
## Check the value in an S-register (or equivalent). If it is
## not what we want, then change it and set $valueChanged to "yes",
......@@ -1639,4 +1639,3 @@ AutoLoginTimeout:
log "Auto-login timeout."
cancel all
return
......@@ -12,6 +12,6 @@ if [ "${dev_type}" = "tun" ]; then
fi
/usr/bin/touch /tmp/$1up
# reload filter
# reload filter
/usr/local/sbin/pfSctl -c "interface newip $1"
exit 0
#!/usr/local/bin/php -f
<?php
require_once("globals.inc");
......@@ -13,7 +12,7 @@ require_once("util.inc");
echo ".";
$g['booting'] = false;
$shell_cmds = array("alias", "alloc", "bg", "bind", "bindkey", "break",
$shell_cmds = array("alias", "alloc", "bg", "bind", "bindkey", "break",
"breaksw", "builtins", "case", "cd", "chdir", "command", "complete", "continue", "default",
"dirs", "do", "done", "echo", "echotc", "elif", "else", "end", "endif", "endsw", "esac", "eval",
"exec", "exit", "export", "false", "fc", "fg", "filetest", "fi", "for", "foreach", "getopts",
......@@ -30,7 +29,7 @@ function pipe_cmd($command, $text_to_pipe) {
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w")); // stderr ?? instead of a file
$fd = proc_open("$command", $descriptorspec, $pipes);
if (is_resource($fd)) {
fwrite($pipes[0], "{$text_to_pipe}");
......@@ -62,8 +61,8 @@ function more($text, $count=24) {
echo "Press RETURN to continue ...";
$fp = fopen('php://stdin', 'r');
$pressreturn = chop(fgets($fp));
if($pressreturn == "q" || $pressreturn == "quit")
return;
if($pressreturn == "q" || $pressreturn == "quit")
return;
fclose($fp);
$counter = 0;
}
......@@ -77,7 +76,7 @@ function show_help() {
$show_help_text = <<<EOF
Enter a series of commands and then execute the set with "exec".
For example:
echo "foo"; // php command
echo "foo2"; // php command
......@@ -97,54 +96,54 @@ $show_help_text = <<<EOF
/* to output a configuration array */
print_r(\$config);
/* to output the interfaces configuration portion of config.xml */
print_r(\$config['interfaces']);
/* to output the dhcp server configuration */
print_r(\$config['dhcpd']);
/* to exit the php {$g['product_name']} shell */
exit
/* to output supported wireless modes for an interface */
print_r(get_wireless_modes(\"ath0\"));
/* to enable SSH */
\$config['system']['enablesshd'] = true;
/* change OPTX to the OPT interface name such as BACKHAUL */
\$config['interfaces']['optx']['wireless']['standard'] = "11a";
\$config['interfaces']['optx']['wireless']['mode'] = "hostap";
\$config['interfaces']['optx']['wireless']['channel'] = "6";
/* to enable dhcp server for an optx interface */
\$config['dhcpd']['optx']['enable'] = true;
\$config['dhcpd']['optx']['range']['from'] = "192.168.31.100";
\$config['dhcpd']['optx']['range']['to'] = "192.168.31.150";
/* to disable the firewall filter */
\$config['system']['disablefilter'] = true;
/* to enable an interface and set it for dhcp */
\$config['interfaces']['optx']['disabled'] = false;
\$config['interfaces']['optx']['ipaddr'] = "dhcp";
/* to enable an interface and set a static ip address */
\$config['interfaces']['wan']['disabled'] = false;
\$config['interfaces']['wan']['ipaddr'] = "192.168.100.1";
\$config['interfaces']['wan']['subnet'] = "24";
/* to save out the new configuration (config.xml) */
write_config();
/* to reboot the system after saving */
system_reboot_sync();
EOF;
more($show_help_text);
}
$fp = fopen('php://stdin', 'r');
......@@ -186,7 +185,7 @@ $recording = false;
$playback_file_split = array();
$playbackbuffer = "";
if($argv[1]=="playback" or $argv[1]=="run") {
if($argv[1]=="playback" or $argv[1]=="run") {
if(!file_exists("/usr/local/etc/phpshellsessions/{$argv[2]}")) {
echo "Could not locate playback file.";
exit;
......@@ -212,7 +211,7 @@ while($shell_active == true) {
$command = readline("{$g['product_name']} shell: ");
readline_add_history($command);
$command_split = explode(" ", $command);
$first_command = $command_split[0];
$first_command = $command_split[0];
if($first_command == "playback" || $first_command == "run") {
$playback_file = $command_split[1];
if(!$playback_file || !file_exists("/usr/local/etc/phpshellsessions/{$playback_file}")) {
......@@ -225,7 +224,7 @@ while($shell_active == true) {
continue;
}
}
if($first_command == "exit" or $first_command == "quit")
if($first_command == "exit" or $first_command == "quit")
die;
if($first_command == "help" or $first_command == "?") {
show_help();
......@@ -244,7 +243,7 @@ while($shell_active == true) {
$command = "";
conf_mount_ro();
echo "Recording stopped.\n";
$recording = false;
$recording = false;
} else {
echo "No recording session in progress.\n";
$command = "";
......@@ -252,7 +251,7 @@ while($shell_active == true) {
}
if($first_command == "showrecordings") {
show_recordings();
$command = "";
$command = "";
}
if($first_command == "reset") {
$playbackbuffer = "";
......@@ -271,7 +270,7 @@ while($shell_active == true) {
if(!$recording_fd) {
echo "Could not start recording session.\n";
$command = "";
} else {
} else {
$recording = true;
echo "Recording of {$command_split[1]} started.\n";
$command = "";
......@@ -284,27 +283,27 @@ while($shell_active == true) {
function show_recordings() {
conf_mount_rw();
safe_mkdir("/usr/local/etc/phpshellsessions");
if($recording)
if($recording)
conf_mount_ro();
echo "==> Sessions available for playback are:\n";
system("cd /usr/local/etc/phpshellsessions && ls /usr/local/etc/phpshellsessions");
echo "==> end of list.\n";
echo "==> end of list.\n";
}
function returnlastchar($command) {
$commandlen = strlen($command);
$endofstring = substr($command, ($commandlen-1));
return $endofstring;
return $endofstring;
}
function returnfirstchar($command) {
$commandlen = strlen($command);
$endofstring = substr($command, 0, 1);
return $endofstring;
return $endofstring;
}
function str_replace_all($search,$replace,$subject) {
while(strpos($subject,$search)!==false)
while(strpos($subject,$search)!==false)
$subject = str_replace($search,$replace,$subject);
return $subject;
}
......@@ -315,7 +314,7 @@ function playback_text($playback_file_contents) {
$playback_text .= "require_once('globals.inc');\n";
$playback_text .= "require_once('config.inc');\n";
$toquote = '"';
$toquotereplace = '\\"';
$toquotereplace = '\\"';
foreach($playback_file_split as $pfs) {
$firstchar = returnfirstchar($pfs);
$currentline = $pfs;
......@@ -339,5 +338,3 @@ function playback_file($playback_file) {
$playback_file_contents = file_get_contents("/usr/local/etc/phpshellsessions/{$playback_file}");
playback_text($playback_file_contents);
}
?>
#!/bin/sh
#get ppp uptime from age of /tmp/{interface}up file
[ -f /tmp/$1up ] && /bin/echo $((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`))
\ No newline at end of file
[ -f /tmp/$1up ] && /bin/echo $((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`))
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