1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Properly use for attribute for label tags on hostapd page.

Added support for id attribute for SelectorOptions function.

Signed-off-by: D9ping <D9ping@users.noreply.github.com>
This commit is contained in:
D9ping 2018-10-03 22:20:06 +02:00
parent b10b538896
commit 73f5e4f2da
2 changed files with 28 additions and 23 deletions

View File

@ -89,8 +89,13 @@ function isAssoc($arr) {
* If $options is an associative array this should be the key * If $options is an associative array this should be the key
* *
*/ */
function SelectorOptions($name, $options, $selected = null) { function SelectorOptions($name, $options, $selected = null, $id = null) {
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'">' , PHP_EOL; echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"';
if (isset($id)) {
echo ' id="' . htmlspecialchars($id, ENT_QUOTES) .'"';
}
echo '>' , PHP_EOL;
foreach ( $options as $opt => $label) { foreach ( $options as $opt => $label) {
$select = ''; $select = '';
$key = isAssoc($options) ? $opt : $label; $key = isAssoc($options) ? $opt : $label;

View File

@ -91,21 +91,21 @@ function DisplayHostAPDConfig()
<?php CSRFToken() ?> <?php CSRFToken() ?>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("Interface") ;?></label> <label for="cbxinterface"><?php echo _("Interface") ;?></label>
<?php <?php
SelectorOptions('interface', $interfaces, $arrConfig['interface']); SelectorOptions('interface', $interfaces, $arrConfig['interface'], 'cbxinterface');
?> ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("SSID"); ?></label> <label for="txtssid"><?php echo _("SSID"); ?></label>
<input type="text" class="form-control" name="ssid" value="<?php echo htmlspecialchars($arrConfig['ssid'], ENT_QUOTES); ?>" /> <input type="text" id="txtssid" class="form-control" name="ssid" value="<?php echo htmlspecialchars($arrConfig['ssid'], ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("Wireless Mode") ;?></label> <label for="cbxhwmode"><?php echo _("Wireless Mode") ;?></label>
<?php <?php
$selectedHwMode = $arrConfig['hw_mode']; $selectedHwMode = $arrConfig['hw_mode'];
if (isset($arrConfig['ieee80211n'])) { if (isset($arrConfig['ieee80211n'])) {
@ -114,12 +114,12 @@ if (isset($arrConfig['ieee80211n'])) {
} }
} }
SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode); ?> SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode, 'cbxhwmode'); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("Channel"); ?></label> <label for="cbxchannel"><?php echo _("Channel"); ?></label>
<?php <?php
$selectablechannels = range(1, 13); $selectablechannels = range(1, 13);
$countries_2_4Ghz_max11ch = array('AG', 'BS', 'BB', 'BZ', 'CR', 'CU', 'DM', 'DO', 'SV', 'GD', 'GT', $countries_2_4Ghz_max11ch = array('AG', 'BS', 'BB', 'BZ', 'CR', 'CU', 'DM', 'DO', 'SV', 'GD', 'GT',
@ -139,7 +139,7 @@ if (in_array($arrConfig['country_code'], $countries_max11channels)) {
$selectablechannels = range(1, 14); $selectablechannels = range(1, 14);
} }
} }
SelectorOptions('channel', $selectablechannels, intval($arrConfig['channel'])) ?> SelectorOptions('channel', $selectablechannels, intval($arrConfig['channel']), 'cbxchannel') ?>
</div> </div>
</div> </div>
</div> </div>
@ -147,20 +147,20 @@ if (in_array($arrConfig['country_code'], $countries_max11channels)) {
<h4><?php echo _("Security settings"); ?></h4> <h4><?php echo _("Security settings"); ?></h4>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("Security type"); ?></label> <label for="cbxwpa"><?php echo _("Security type"); ?></label>
<?php SelectorOptions('wpa', $arrSecurity, $arrConfig['wpa']); ?> <?php SelectorOptions('wpa', $arrSecurity, $arrConfig['wpa'], 'cbxwpa'); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("Encryption Type"); ?></label> <label for="cbxwpapairwise"><?php echo _("Encryption Type"); ?></label>
<?php SelectorOptions('wpa_pairwise', $arrEncType, $arrConfig['wpa_pairwise']); ?> <?php SelectorOptions('wpa_pairwise', $arrEncType, $arrConfig['wpa_pairwise'], 'cbxwpapairwise'); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("PSK"); ?></label> <label for="txtwpapassphrase"><?php echo _("PSK"); ?></label>
<input type="text" class="form-control" name="wpa_passphrase" value="<?php echo htmlspecialchars($arrConfig['wpa_passphrase'], ENT_QUOTES); ?>" /> <input type="text" class="form-control" id="txtwpapassphrase" name="wpa_passphrase" value="<?php echo htmlspecialchars($arrConfig['wpa_passphrase'], ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
</div> </div>
@ -184,24 +184,24 @@ if (in_array($arrConfig['country_code'], $countries_max11channels)) {
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<div class="form-check"> <div class="form-check">
<label class="form-check-label"> <label class="form-check-label" for="chxlogenable">
<?php echo _("Enable logging"); <?php echo _("Enable logging");
$checked = ''; $checkedLogEnabled = '';
if ($arrHostapdConf['LogEnable'] == 1) { if ($arrHostapdConf['LogEnable'] == 1) {
$checked = ' checked="checked"'; $checkedLogEnabled = ' checked="checked"';
} }
?> ?>
<input id="logEnable" name ="logEnable" type="checkbox" class="form-check-input" value="1"<?php echo $checked; ?> />
</label> </label>
<input id="chxlogenable" name="logEnable" type="checkbox" class="form-check-input" value="1"<?php echo $checkedLogEnabled; ?> />
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="code"><?php echo _("Country Code"); ?></label> <label for="cbxcountries"><?php echo _("Country Code"); ?></label>
<input type="hidden" id="selected_country" value="<?php echo htmlspecialchars($arrConfig['country_code'], ENT_QUOTES); ?>"> <input type="hidden" id="selected_country" value="<?php echo htmlspecialchars($arrConfig['country_code'], ENT_QUOTES); ?>">
<select class="form-control" id="countries" name="country_code"> <select class="form-control" id="cbxcountries" name="country_code">
<option value="AF">Afghanistan</option> <option value="AF">Afghanistan</option>
<option value="AX">Åland Islands</option> <option value="AX">Åland Islands</option>
<option value="AL">Albania</option> <option value="AL">Albania</option>
@ -454,7 +454,7 @@ if ($arrHostapdConf['LogEnable'] == 1) {
</select> </select>
<script type="text/javascript"> <script type="text/javascript">
var country = document.getElementById("selected_country").value; var country = document.getElementById("selected_country").value;
var countries = document.getElementById("countries"); var countries = document.getElementById("cbxcountries");
var ops = countries.getElementsByTagName("option"); var ops = countries.getElementsByTagName("option");
for (var i = 0; i < ops.length; ++i) { for (var i = 0; i < ops.length; ++i) {
if(ops[i].value == country){ if(ops[i].value == country){