Processed with phpcbf for PSR-2 coding standard

This commit is contained in:
billz 2019-09-07 16:42:31 +01:00
parent ef406edc61
commit 8be24381a8
20 changed files with 106 additions and 87 deletions

View file

@ -7,5 +7,5 @@
*/
function DisplayAbout()
{
echo renderTemplate("about");
echo renderTemplate("about");
}

View file

@ -46,7 +46,7 @@ function DisplayWPAConfig()
fwrite($wpa_file, "network={".PHP_EOL);
fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL);
fwrite($wpa_file, "\tkey_mgmt=NONE".PHP_EOL);
fwrite($wpa_file, "\tscan_ssid=1".PHP_EOL);
fwrite($wpa_file, "\tscan_ssid=1".PHP_EOL);
if (array_key_exists('priority', $network)) {
fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL);
}
@ -96,5 +96,4 @@ function DisplayWPAConfig()
connectedWifiStations($networks);
echo renderTemplate("configure_client", compact("status"));
}

View file

@ -4,5 +4,5 @@ include_once('functions.php');
include_once('session.php');
if (csrfValidateRequest() && !CSRFValidate()) {
handleInvalidCSRFToken();
handleInvalidCSRFToken();
}

View file

@ -33,12 +33,12 @@ function DisplayDashboard()
$ipv4Addrs = _('No IPv4 Address Found');
} else {
foreach ($matchesIpv4AddrAndSubnet as $inet) {
$address = $inet[1];
$suffix = (int) $inet[2];
$netmask = long2ip(-1 << (32 - $suffix));
$address = $inet[1];
$suffix = (int) $inet[2];
$netmask = long2ip(-1 << (32 - $suffix));
$ipv4Addrs .= " $address";
$ipv4Netmasks .= " $netmask";
$ipv4Addrs .= " $address";
$ipv4Netmasks .= " $netmask";
}
$ipv4Addrs = trim($ipv4Addrs);
$ipv4Netmasks = trim($ipv4Netmasks);
@ -173,12 +173,21 @@ function DisplayDashboard()
echo renderTemplate("dashboard", compact(
"status",
"ipv4Addrs", "ipv4Netmasks",
"ipv6Addrs", "macAddr",
"strRxPackets", "strRxBytes",
"strTxPackets", "strTxBytes",
"connectedSSID", "connectedBSSID",
"bitrate", "signalLevel", "txPower", "frequency", "strLinkQuality",
"ipv4Addrs",
"ipv4Netmasks",
"ipv6Addrs",
"macAddr",
"strRxPackets",
"strRxBytes",
"strTxPackets",
"strTxBytes",
"connectedSSID",
"connectedBSSID",
"bitrate",
"signalLevel",
"txPower",
"frequency",
"strLinkQuality",
"wlan0up"
));
}
@ -213,4 +222,3 @@ function getHumanReadableDatasize($numbytes, $precision = 2)
return $humanDatasize;
}

View file

@ -138,10 +138,17 @@ function DisplayDHCPConfig()
echo renderTemplate("dhcp", compact(
"status",
"serviceStatus",
"RangeStart", "RangeEnd",
"RangeStart",
"RangeEnd",
"arrRangeLeaseTime",
"mselected", "hselected", "dselected", "infiniteselected",
"dnsmasq_state", "conf", "dhcpHost",
"interfaces", "leases"
"mselected",
"hselected",
"dselected",
"infiniteselected",
"dnsmasq_state",
"conf",
"dhcpHost",
"interfaces",
"leases"
));
}

View file

@ -116,8 +116,8 @@ function CSRFValidate()
*/
function csrfValidateRequest()
{
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
return in_array($request_method, [ "post", "put", "patch", "delete" ]);
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
return in_array($request_method, [ "post", "put", "patch", "delete" ]);
}
/**
@ -194,7 +194,9 @@ function ParseConfig($arrConfig)
$config = array();
foreach ($arrConfig as $line) {
$line = trim($line);
if ($line == "" || $line[0] == "#") { continue; }
if ($line == "" || $line[0] == "#") {
continue;
}
list($option, $value) = array_map("trim", explode("=", $line, 2));
@ -384,14 +386,14 @@ function DisplayOpenVPNConfig()
} else {
echo '<input type="submit" class="btn btn-warning" name="StopOpenVPN" value="Stop OpenVPN" />' , PHP_EOL;
}
?>
?>
</form>
</div><!-- /.panel-body -->
</div><!-- /.panel-primary -->
<div class="panel-footer"> Information provided by openvpn</div>
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
<?php
<?php
}
/**
@ -420,7 +422,7 @@ function DisplayTorProxyConfig()
}
}
?>
?>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-primary">
@ -535,7 +537,7 @@ function DisplayTorProxyConfig()
</div><!-- /.panel-primary -->
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
<?php
<?php
}
/**
@ -585,7 +587,7 @@ function renderTemplate($name, $data = [])
return "template $name ($file) not found";
}
if (is_array($data)){
if (is_array($data)) {
extract($data);
}

View file

@ -59,10 +59,15 @@ function DisplayHostAPDConfig()
echo renderTemplate("hostapd", compact(
"status",
"serviceStatus", "hostapdstatus",
"interfaces", "arrConfig",
"arr80211Standard", "selectedHwMode",
"arrSecurity", "arrEncType", "arrHostapdConf"
"serviceStatus",
"hostapdstatus",
"interfaces",
"arrConfig",
"arr80211Standard",
"selectedHwMode",
"arrSecurity",
"arrEncType",
"arrHostapdConf"
));
}
@ -260,4 +265,3 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
return true;
}

View file

@ -62,8 +62,8 @@ if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2)
$_SESSION['locale'] = $locale;
}
// Note: the associated locale must be installed on the RPi
// Use: 'sudo raspi-configure' and select 'Localisation Options'
// Note: the associated locale must be installed on the RPi
// Use: 'sudo raspi-configure' and select 'Localisation Options'
// activate the locale setting
putenv("LANG=" . $_SESSION['locale']);

View file

@ -1,5 +1,5 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
session_start();
}

View file

@ -102,4 +102,3 @@ function DisplaySystem()
echo renderTemplate("system", compact("arrLocales", "status", "system"));
}

View file

@ -51,7 +51,7 @@ function nearbyWifiStations(&$networks, $cached = true)
deleteCache($cacheKey);
}
$scan_results = cache($cacheKey, function() {
$scan_results = cache($cacheKey, function () {
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
sleep(3);

View file

@ -5,7 +5,7 @@
<div class="panel-body">
<?php $status->showMessages(); ?>
<form role="form" action="?page=auth_conf" method="POST">
<?php echo CSRFTokenFieldTag() ?>
<?php echo CSRFTokenFieldTag() ?>
<div class="row">
<div class="form-group col-md-4">
<label for="username"><?php echo _("Username"); ?></label>

View file

@ -12,7 +12,7 @@
</div>
<form method="POST" action="?page=wpa_conf" name="wpa_conf_form" class="row">
<?php echo CSRFTokenFieldTag() ?>
<?php echo CSRFTokenFieldTag() ?>
<input type="hidden" name="client_settings" ?>
<div class="js-wifi-stations loading-spinner"></div>
</form>

View file

@ -1,9 +1,9 @@
<?php
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
if ($arrHostapdConf['WifiAPEnable'] == 1) {
$client_iface = 'uap0';
$client_iface = 'uap0';
} else {
$client_iface = RASPI_WIFI_CLIENT_INTERFACE;
$client_iface = RASPI_WIFI_CLIENT_INTERFACE;
}
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.$client_iface.' -n | grep -oE "(([0-9]|[a-f]|[A-F]){2}:){5}([0-9]|[a-f]|[A-F]){2}" | tr "\n" "\|" | sed "s/.$//")', $clients);
?>
@ -64,14 +64,14 @@ exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.$client_iface.' -n | grep
</tr>
</thead>
<tbody>
<?php foreach ($clients as $client): ?>
<?php $props = explode(' ', $client) ?>
<?php foreach ($clients as $client) : ?>
<?php $props = explode(' ', $client) ?>
<tr>
<td><?php echo htmlspecialchars($props[3], ENT_QUOTES) ?></td>
<td><?php echo htmlspecialchars($props[2], ENT_QUOTES) ?></td>
<td><?php echo htmlspecialchars($props[1], ENT_QUOTES) ?></td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
</tbody>
</table>
</div><!-- /.table-responsive -->
@ -83,14 +83,14 @@ exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.$client_iface.' -n | grep
<div class="col-lg-12">
<div class="row">
<form action="?page=wlan0_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>
<?php if (!RASPI_MONITOR_ENABLED): ?>
<?php if (!$wlan0up): ?>
<?php echo CSRFTokenFieldTag() ?>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<?php if (!$wlan0up) : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start ").RASPI_WIFI_CLIENT_INTERFACE ?>" name="ifup_wlan0" />
<?php else: ?>
<?php else : ?>
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop ").RASPI_WIFI_CLIENT_INTERFACE ?>" name="ifdown_wlan0" />
<?php endif ?>
<?php endif ?>
<?php endif ?>
<?php endif ?>
<a href="?page=<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fa fa-refresh"></i> <?php echo _("Refresh") ?></a>
</form>
</div>

View file

@ -17,13 +17,13 @@
<h4><?php echo _('Hourly traffic amount'); ?></h4>
<label for="cbxInterfacehourly"><?php echo _('interface'); ?></label>
<select id="cbxInterfacehourly" class="form-control" name="interfacehourly">
<?php foreach ($interfaces as $if): ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<?php foreach ($interfaces as $if) : ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<option value="<?php echo $if_quoted ?>"><?php echo $if_quoted ?></option>
<?php endforeach ?>
</select>
<div class="hidden alert alert-info" id="divLoaderBandwidthhourly">
<?php echo sprintf(_("Loading %s bandwidth chart"), _('hourly')); ?>
<?php echo sprintf(_("Loading %s bandwidth chart"), _('hourly')); ?>
</div>
<div id="divChartBandwidthhourly"></div>
<div id="divTableBandwidthhourly"></div>
@ -36,13 +36,13 @@
<h4><?php echo _('Daily traffic amount'); ?></h4>
<label for="cbxInterfacedaily"><?php echo _('interface'); ?></label>
<select id="cbxInterfacedaily" class="form-control" name="interfacedaily">
<?php foreach ($interfaces as $if): ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<?php foreach ($interfaces as $if) : ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<option value="<?php echo $if_quoted ?>"><?php echo $if_quoted ?></option>
<?php endforeach ?>
</select>
<div class="hidden alert alert-info" id="divLoaderBandwidthdaily">
<?php echo sprintf(_("Loading %s bandwidth chart"), _('daily')); ?>
<?php echo sprintf(_("Loading %s bandwidth chart"), _('daily')); ?>
</div>
<div id="divChartBandwidthdaily"></div>
<div id="divTableBandwidthdaily"></div>
@ -55,13 +55,13 @@
<h4><?php echo _("Monthly traffic amount"); ?></h4>
<label for="cbxInterfacemonthly"><?php echo _('interface'); ?></label>
<select id="cbxInterfacemonthly" class="form-control" name="interfacemonthly">
<?php foreach ($interfaces as $if): ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<?php foreach ($interfaces as $if) : ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<option value="<?php echo $if_quoted ?>"><?php echo $if_quoted ?></option>
<?php endforeach ?>
</select>
<div class="hidden alert alert-info" id="divLoaderBandwidthmonthly">
<?php echo sprintf(_("Loading %s bandwidth chart"), _('monthly')); ?>
<?php echo sprintf(_("Loading %s bandwidth chart"), _('monthly')); ?>
</div>
<div id="divChartBandwidthmonthly"></div>
<div id="divTableBandwidthmonthly"></div>

View file

@ -26,9 +26,9 @@
<div class="form-group col-md-4">
<label for="code">Interface</label>
<select class="form-control" name="interface">
<?php foreach ($interfaces as $if): ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<?php $selected = $if === $conf['interface'] ? ' selected="selected"' : '' ?>
<?php foreach ($interfaces as $if) : ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<?php $selected = $if === $conf['interface'] ? ' selected="selected"' : '' ?>
<option value="<?php echo $if_quoted ?>"<?php echo $selected ?>><?php echo $if_quoted ?></option>
<?php endforeach ?>
</select>
@ -63,11 +63,11 @@
</select>
</div>
</div>
<?php if (!RASPI_MONITOR_ENABLED): ?>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
<?php if ($dnsmasq_state): ?>
<?php if ($dnsmasq_state) : ?>
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop dnsmasq") ?>" name="stopdhcpd" />
<?php else: ?>
<?php else : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start dnsmasq") ?>" name="startdhcpd" />
<?php endif ?>
<?php endif ?>
@ -93,12 +93,12 @@
</tr>
</thead>
<tbody>
<?php foreach ($leases as $lease): ?>
<?php foreach (explode(' ', $lease) as $prop): ?>
<?php foreach ($leases as $lease) : ?>
<?php foreach (explode(' ', $lease) as $prop) : ?>
<tr>
<td><?php echo htmlspecialchars($prop, ENT_QUOTES) ?></td>
</tr>
<?php endforeach ?>
<?php endforeach ?>
<?php endforeach ?>
</tbody>
</table>
@ -111,8 +111,8 @@
<div class="tab-pane fade in" id="static-leases">
<div class="dhcp-static-leases js-dhcp-static-lease-container">
<?php foreach ($dhcpHost as $host): ?>
<?php list($mac, $ip) = array_map("trim", explode(",", $host)); ?>
<?php foreach ($dhcpHost as $host) : ?>
<?php list($mac, $ip) = array_map("trim", explode(",", $host)); ?>
<div class="row dhcp-static-lease-row js-dhcp-static-lease-row">
<div class="col-md-5 col-xs-5">
<input type="text" name="static_leases[mac][]" value="<?php echo htmlspecialchars($mac, ENT_QUOTES) ?>" placeholder="<?php echo _("MAC address") ?>" class="form-control">
@ -153,7 +153,7 @@
</div>
</div>
</template>
<?php if (!RASPI_MONITOR_ENABLED): ?>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
<?php
if ($dnsmasq_state) {

View file

@ -121,7 +121,7 @@
<?php
$checkedWifiAPEnabled = '';
if ($arrHostapdConf['WifiAPEnable'] == 1) {
$checkedWifiAPEnabled = ' checked="checked"';
$checkedWifiAPEnabled = ' checked="checked"';
}
?>
<input id="chxwificlientap" name="wifiAPEnable" type="checkbox" class="form-check-input" data-toggle="toggle" data-on="Enabled" data-off="Disabled" data-width="100" value="1"<?php echo $checkedWifiAPEnabled; ?> />
@ -135,7 +135,7 @@ $checkedWifiAPEnabled = ' checked="checked"';
<?php
$checkedLogEnabled = '';
if ($arrHostapdConf['LogEnable'] == 1) {
$checkedLogEnabled = ' checked="checked"';
$checkedLogEnabled = ' checked="checked"';
}
?>
<input id="chxlogenable" name="logEnable" type="checkbox" class="form-check-input" data-toggle="toggle" data-on="Enabled" data-off="Disabled" data-width="100" value="1"<?php echo $checkedLogEnabled; ?> />
@ -149,7 +149,7 @@ $checkedLogEnabled = ' checked="checked"';
<?php
$checkedHiddenSSID = '';
if ($arrConfig['ignore_broadcast_ssid'] == 1 || $arrConfig['ignore_broadcast_ssid'] == 2) {
$checkedHiddenSSID = ' checked="checked"';
$checkedHiddenSSID = ' checked="checked"';
}
?>
<input id="chxhiddenssid" name="hiddenSSID" type="checkbox" class="form-check-input" data-toggle="toggle" data-on="Enabled" data-off="Disabled" data-width="100" value="1"<?php echo $checkedHiddenSSID; ?> />
@ -433,8 +433,8 @@ if(ops[i].value == country){
</script>
</div>
</div><!-- /.panel-body -->
</div><!-- /.panel-primary -->
<?php if (!RASPI_MONITOR_ENABLED): ?>
</div><!-- /.panel-primary -->
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<input type="submit" class="btn btn-outline btn-primary" name="SaveHostAPDSettings" value="<?php echo _("Save settings"); ?>" />
<?php
if ($hostapdstatus[0] == 0) {
@ -442,7 +442,7 @@ if(ops[i].value == country){
} else {
echo '<input type="submit" class="btn btn-warning" name="StopHotspot" value="' . _("Stop hotspot") . '"/>' , PHP_EOL;
};
endif ?>
endif ?>
</form>
</div></div><!-- /.panel-primary -->
<div class="panel-footer"> <?php echo _("Information provided by hostapd"); ?></div>

View file

@ -66,12 +66,12 @@ if ($cpuload > 90) {
</div>
<form action="?page=system_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>
<?php if (!RASPI_MONITOR_ENABLED): ?>
<?php echo CSRFTokenFieldTag() ?>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<input type="submit" class="btn btn-warning" name="system_reboot" value="<?php echo _("Reboot"); ?>" />
<input type="submit" class="btn btn-warning" name="system_shutdown" value="<?php echo _("Shutdown"); ?>" />
<input type="submit" class="btn btn-warning" name="system_shutdown" value="<?php echo _("Shutdown"); ?>" />
<?php endif ?>
<a href="?page=<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fa fa-refresh"></i> <?php echo _("Refresh") ?></a>
<a href="?page=<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fa fa-refresh"></i> <?php echo _("Refresh") ?></a>
</form>
</div>
</div>
@ -82,7 +82,7 @@ if ($cpuload > 90) {
<div class="row">
<div class="form-group col-md-4">
<label for="code"><?php echo _("Select a language"); ?></label>
<?php SelectorOptions('locale', $arrLocales, $_SESSION['locale']); ?>
<?php SelectorOptions('locale', $arrLocales, $_SESSION['locale']); ?>
</div>
</div>
<input type="submit" class="btn btn-outline btn-primary" name="SaveLanguage" value="<?php echo _("Save settings"); ?>" />

View file

@ -14,7 +14,7 @@
</div>
<form action="?page=system_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>
<?php echo CSRFTokenFieldTag() ?>
<a href="?page=<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fa fa-refresh"></i> <?php echo _("Refresh"); ?></a>
</form>

View file

@ -1,9 +1,9 @@
<?php if (empty($networks)): ?>
<?php if (empty($networks)) : ?>
<p class="lead text-center"><?php echo _('No Wifi stations found') ?></p>
<p class="text-center"><?php echo _('Click "Rescan" to search for nearby Wifi stations.') ?></p>
<?php endif ?>
<?php $index = 0; ?>
<?php foreach ($networks as $ssid => $network): ?>
<?php foreach ($networks as $ssid => $network) : ?>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-body">
@ -89,5 +89,5 @@
</div><!-- /.panel-default -->
</div><!-- /.col-md-6 -->
<?php $index += 1; ?>
<?php $index += 1; ?>
<?php endforeach ?>