mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #164 from rmarshall31/priority
preserve priority in wpa_supplicant.conf
This commit is contained in:
commit
659e21f00b
@ -41,6 +41,9 @@ function DisplayWPAConfig(){
|
|||||||
$network['protocol'] = 'Open';
|
$network['protocol'] = 'Open';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'priority':
|
||||||
|
$network['priority'] = trim($lineArr[1], '"');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,6 +66,9 @@ function DisplayWPAConfig(){
|
|||||||
'passphrase' => $_POST['passphrase' . $post_match[1]],
|
'passphrase' => $_POST['passphrase' . $post_match[1]],
|
||||||
'configured' => true
|
'configured' => true
|
||||||
);
|
);
|
||||||
|
if (array_key_exists('priority' . $post_match[1], $_POST)) {
|
||||||
|
$tmp_networks[$_POST['ssid' . $post_match[1]]]['priority'] = $_POST['priority' . $post_match[1]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +78,9 @@ function DisplayWPAConfig(){
|
|||||||
fwrite($wpa_file, "network={".PHP_EOL);
|
fwrite($wpa_file, "network={".PHP_EOL);
|
||||||
fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL);
|
fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL);
|
||||||
fwrite($wpa_file, "\tkey_mgmt=NONE".PHP_EOL);
|
fwrite($wpa_file, "\tkey_mgmt=NONE".PHP_EOL);
|
||||||
|
if (array_key_exists('priority', $network)) {
|
||||||
|
fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL);
|
||||||
|
}
|
||||||
fwrite($wpa_file, "}".PHP_EOL);
|
fwrite($wpa_file, "}".PHP_EOL);
|
||||||
} else {
|
} else {
|
||||||
if (strlen($network['passphrase']) >=8 && strlen($network['passphrase']) <= 63) {
|
if (strlen($network['passphrase']) >=8 && strlen($network['passphrase']) <= 63) {
|
||||||
@ -79,15 +88,20 @@ function DisplayWPAConfig(){
|
|||||||
unset($line);
|
unset($line);
|
||||||
exec( 'wpa_passphrase '.escapeshellarg($ssid). ' ' . escapeshellarg($network['passphrase']),$wpa_passphrase );
|
exec( 'wpa_passphrase '.escapeshellarg($ssid). ' ' . escapeshellarg($network['passphrase']),$wpa_passphrase );
|
||||||
foreach($wpa_passphrase as $line) {
|
foreach($wpa_passphrase as $line) {
|
||||||
|
if (preg_match('/^\s*}\s*$/', $line)) {
|
||||||
|
if (array_key_exists('priority', $network)) {
|
||||||
|
fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL);
|
||||||
|
}
|
||||||
fwrite($wpa_file, $line.PHP_EOL);
|
fwrite($wpa_file, $line.PHP_EOL);
|
||||||
|
} else {
|
||||||
|
fwrite($wpa_file, $line.PHP_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
||||||
$ok = false;
|
$ok = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
@ -118,7 +132,7 @@ function DisplayWPAConfig(){
|
|||||||
// display output
|
// display output
|
||||||
foreach( $scan_return as $network ) {
|
foreach( $scan_return as $network ) {
|
||||||
$arrNetwork = preg_split("/[\t]+/",$network);
|
$arrNetwork = preg_split("/[\t]+/",$network);
|
||||||
if (array_key_exists($arrNetwork[4], $networks)) {
|
if (array_key_exists(4, $arrNetwork) && array_key_exists($arrNetwork[4], $networks)) {
|
||||||
$networks[$arrNetwork[4]]['visible'] = true;
|
$networks[$arrNetwork[4]]['visible'] = true;
|
||||||
$networks[$arrNetwork[4]]['channel'] = ConvertToChannel($arrNetwork[1]);
|
$networks[$arrNetwork[4]]['channel'] = ConvertToChannel($arrNetwork[1]);
|
||||||
// TODO What if the security has changed?
|
// TODO What if the security has changed?
|
||||||
@ -172,7 +186,7 @@ function DisplayWPAConfig(){
|
|||||||
<?php if ($network['configured']) { ?>
|
<?php if ($network['configured']) { ?>
|
||||||
<i class="fa fa-check-circle fa-fw"></i>
|
<i class="fa fa-check-circle fa-fw"></i>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($network['connected']) { ?>
|
<?php if (array_key_exists('connected', $network) && $network['connected']) { ?>
|
||||||
<i class="fa fa-exchange fa-fw"></i>
|
<i class="fa fa-exchange fa-fw"></i>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
@ -180,12 +194,17 @@ function DisplayWPAConfig(){
|
|||||||
<input type="hidden" name="ssid<?php echo $index ?>" value="<?php echo htmlentities($ssid) ?>" />
|
<input type="hidden" name="ssid<?php echo $index ?>" value="<?php echo htmlentities($ssid) ?>" />
|
||||||
<?php echo $ssid ?>
|
<?php echo $ssid ?>
|
||||||
</td>
|
</td>
|
||||||
<?php if ($network['visible']) { ?>
|
<?php if (array_key_exists('visible', $network) && $network['visible']) { ?>
|
||||||
<td><?php echo $network['channel'] ?></td>
|
<td><?php echo $network['channel'] ?></td>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<td><span class="label label-warning">X</span></td>
|
<td><span class="label label-warning">X</span></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td><input type="hidden" name="protocol<?php echo $index ?>" value="<?php echo $network['protocol'] ?>" /><?php echo $network['protocol'] ?></td>
|
<td>
|
||||||
|
<?php if (array_key_exists('priority', $network)) { ?>
|
||||||
|
<input type="hidden" name="priority<?php echo $index ?>" value="<?php echo $network['priority'] ?>" />
|
||||||
|
<?php } ?>
|
||||||
|
<input type="hidden" name="protocol<?php echo $index ?>" value="<?php echo $network['protocol'] ?>" /><?php echo $network['protocol'] ?>
|
||||||
|
</td>
|
||||||
<?php if ($network['protocol'] === 'Open') { ?>
|
<?php if ($network['protocol'] === 'Open') { ?>
|
||||||
<td><input type="hidden" name="passphrase<?php echo $index ?>" value="" />---</td>
|
<td><input type="hidden" name="passphrase<?php echo $index ?>" value="" />---</td>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user