mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #54 from RaspAP/workaround-nonASCII-ssid-names
Fix handling of non ASCII ssid names
This commit is contained in:
commit
b90777b550
@ -14,6 +14,7 @@ knownWifiStations($networks);
|
|||||||
nearbyWifiStations($networks, !isset($_REQUEST["refresh"]));
|
nearbyWifiStations($networks, !isset($_REQUEST["refresh"]));
|
||||||
connectedWifiStations($networks);
|
connectedWifiStations($networks);
|
||||||
sortNetworksByRSSI($networks);
|
sortNetworksByRSSI($networks);
|
||||||
|
foreach ($networks as $ssid => $network) $networks[$ssid]["ssidutf8"] = ssid2utf8( $ssid );
|
||||||
|
|
||||||
$connected = array_filter($networks, function($n) { return $n['connected']; } );
|
$connected = array_filter($networks, function($n) { return $n['connected']; } );
|
||||||
$known = array_filter($networks, function($n) { return !$n['connected'] && $n['configured']; } );
|
$known = array_filter($networks, function($n) { return !$n['connected'] && $n['configured']; } );
|
||||||
|
@ -61,7 +61,7 @@ function DisplayWPAConfig()
|
|||||||
if (strlen($network['passphrase']) >=8 && strlen($network['passphrase']) <= 63) {
|
if (strlen($network['passphrase']) >=8 && strlen($network['passphrase']) <= 63) {
|
||||||
unset($wpa_passphrase);
|
unset($wpa_passphrase);
|
||||||
unset($line);
|
unset($line);
|
||||||
exec('wpa_passphrase '.escapeshellarg($ssid). ' ' . escapeshellarg($network['passphrase']), $wpa_passphrase);
|
exec('wpa_passphrase '. ssid2utf8( escapeshellarg($ssid) ) . ' ' . escapeshellarg($network['passphrase']), $wpa_passphrase);
|
||||||
foreach ($wpa_passphrase as $line) {
|
foreach ($wpa_passphrase as $line) {
|
||||||
if (preg_match('/^\s*}\s*$/', $line)) {
|
if (preg_match('/^\s*}\s*$/', $line)) {
|
||||||
if (array_key_exists('priority', $network)) {
|
if (array_key_exists('priority', $network)) {
|
||||||
@ -69,7 +69,11 @@ function DisplayWPAConfig()
|
|||||||
}
|
}
|
||||||
fwrite($wpa_file, $line.PHP_EOL);
|
fwrite($wpa_file, $line.PHP_EOL);
|
||||||
} else {
|
} else {
|
||||||
fwrite($wpa_file, $line.PHP_EOL);
|
if ( preg_match('/\\\\x[0-9A-Fa-f]{2}/',$ssid) && strpos($line, "ssid=\"") !== false ) {
|
||||||
|
fwrite($wpa_file, "\tssid=P\"".$ssid."\"".PHP_EOL);
|
||||||
|
} else {
|
||||||
|
fwrite($wpa_file, $line.PHP_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -765,6 +765,10 @@ function evalHexSequence($string)
|
|||||||
return preg_replace_callback('/\\\x(..)/', $evaluator, $string);
|
return preg_replace_callback('/\\\x(..)/', $evaluator, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hexSequence2lower($string) {
|
||||||
|
return preg_replace_callback('/\\\\x([0-9A-F]{2})/', function($b){ return '\x'.strtolower($b[1]); }, $string);
|
||||||
|
}
|
||||||
|
|
||||||
/* File upload callback object
|
/* File upload callback object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/functions.php';
|
require_once 'includes/functions.php';
|
||||||
|
require_once 'includes/wifi_functions.php';
|
||||||
|
|
||||||
function getClients($simple=true)
|
function getClients($simple=true)
|
||||||
{
|
{
|
||||||
@ -70,9 +71,10 @@ function getClients($simple=true)
|
|||||||
$cl["device"][$i]["isAP"] = !empty($retiw);
|
$cl["device"][$i]["isAP"] = !empty($retiw);
|
||||||
unset($retiw);
|
unset($retiw);
|
||||||
exec("iw dev $dev link 2> /dev/null", $retiw);
|
exec("iw dev $dev link 2> /dev/null", $retiw);
|
||||||
if (!$simple && !empty($ssid=preg_only_match("/.*SSID: ([\w ]*).*/", $retiw)) ) {
|
if (!$simple && !empty($ssid=preg_only_match("/.*SSID:\s*([^\"]*).*/", $retiw)) ) {
|
||||||
$cl["device"][$i]["connected"] = "y";
|
$cl["device"][$i]["connected"] = "y";
|
||||||
$cl["device"][$i]["ssid"] = $ssid;
|
$cl["device"][$i]["ssid"] = $ssid;
|
||||||
|
$cl["device"][$i]["ssidutf8"] = ssid2utf8($ssid);
|
||||||
$cl["device"][$i]["ap-mac"] = preg_only_match("/^Connected to ([0-9a-f\:]*).*$/", $retiw);
|
$cl["device"][$i]["ap-mac"] = preg_only_match("/^Connected to ([0-9a-f\:]*).*$/", $retiw);
|
||||||
$sig = preg_only_match("/.*signal: (.*)$/", $retiw);
|
$sig = preg_only_match("/.*signal: (.*)$/", $retiw);
|
||||||
$val = preg_only_match("/^([0-9\.-]*).*$/", $sig);
|
$val = preg_only_match("/^([0-9\.-]*).*$/", $sig);
|
||||||
|
@ -20,6 +20,7 @@ function knownWifiStations(&$networks)
|
|||||||
switch (strtolower($lineArr[0])) {
|
switch (strtolower($lineArr[0])) {
|
||||||
case 'ssid':
|
case 'ssid':
|
||||||
$ssid = trim($lineArr[1], '"');
|
$ssid = trim($lineArr[1], '"');
|
||||||
|
$ssid = str_replace('P"','',$ssid);
|
||||||
$network['ssid'] = $ssid;
|
$network['ssid'] = $ssid;
|
||||||
break;
|
break;
|
||||||
case 'psk':
|
case 'psk':
|
||||||
@ -80,7 +81,6 @@ function nearbyWifiStations(&$networks, $cached = true)
|
|||||||
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
||||||
|
|
||||||
$ssid = trim($arrNetwork[4]);
|
$ssid = trim($arrNetwork[4]);
|
||||||
$ssid = evalHexSequence($ssid);
|
|
||||||
|
|
||||||
// exclude raspap ssid
|
// exclude raspap ssid
|
||||||
if (empty($ssid) || $ssid == $ap_ssid) {
|
if (empty($ssid) || $ssid == $ap_ssid) {
|
||||||
@ -125,7 +125,7 @@ function connectedWifiStations(&$networks)
|
|||||||
exec('iwconfig ' .$_SESSION['wifi_client_interface'], $iwconfig_return);
|
exec('iwconfig ' .$_SESSION['wifi_client_interface'], $iwconfig_return);
|
||||||
foreach ($iwconfig_return as $line) {
|
foreach ($iwconfig_return as $line) {
|
||||||
if (preg_match('/ESSID:\"([^"]+)\"/i', $line, $iwconfig_ssid)) {
|
if (preg_match('/ESSID:\"([^"]+)\"/i', $line, $iwconfig_ssid)) {
|
||||||
$networks[$iwconfig_ssid[1]]['connected'] = true;
|
$networks[hexSequence2lower($iwconfig_ssid[1])]['connected'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,3 +189,12 @@ function reinitializeWPA($force)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Replace escaped bytes (hex) by binary - assume UTF8 encoding
|
||||||
|
*
|
||||||
|
* @param string $ssid
|
||||||
|
*/
|
||||||
|
function ssid2utf8($ssid) {
|
||||||
|
return evalHexSequence($ssid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<?php $valEcho=function($cl,$id) {$val = isset($cl[$id])&& !empty($cl[$id]) ? $cl[$id] : "-"; echo htmlspecialchars($val,ENT_QUOTES);} ?>
|
<?php $valEcho=function($cl,$id) {$val = isset($cl[$id])&& !empty($cl[$id]) ? $cl[$id] : "-"; echo htmlspecialchars($val,ENT_QUOTES);} ?>
|
||||||
<?php if ($clientinfo["type"] == "wlan") : // WIRELESS ?>
|
<?php if ($clientinfo["type"] == "wlan") : // WIRELESS ?>
|
||||||
<div class="row mb-1">
|
<div class="row mb-1">
|
||||||
<div class="info-item col-xs-3"><?php echo _("Connected To"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ssid"); ?></div>
|
<div class="info-item col-xs-3"><?php echo _("Connected To"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ssidutf8"); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-1">
|
<div class="row mb-1">
|
||||||
<div class="info-item col-xs-3"><?php echo _("AP Mac Address"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ap-mac"); ?></div>
|
<div class="info-item col-xs-3"><?php echo _("AP Mac Address"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ap-mac"); ?></div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<?php if (strlen($network['ssid']) == 0) {
|
<?php if (strlen($network['ssid']) == 0) {
|
||||||
$network['ssid'] = "(unknown)";
|
$network['ssid'] = "(unknown)";
|
||||||
} ?>
|
} ?>
|
||||||
<h5 class="card-title"><?php echo htmlspecialchars($network['ssid'], ENT_QUOTES); ?></h5>
|
<h5 class="card-title"><?php echo htmlspecialchars($network['ssidutf8'], ENT_QUOTES); ?></h5>
|
||||||
|
|
||||||
<div class="info-item-wifi"><?php echo _("Status"); ?></div>
|
<div class="info-item-wifi"><?php echo _("Status"); ?></div>
|
||||||
<div>
|
<div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user