mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
parent
33fbb910e5
commit
695ea7b969
49
app/img/wifi-qr-code.php
Normal file
49
app/img/wifi-qr-code.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/config.php';
|
||||
require_once '../../includes/defaults.php';
|
||||
|
||||
function qr_encode($str)
|
||||
{
|
||||
return preg_replace('/(?<!\\\)([\":;,])/', '\\\\\1', $str);
|
||||
}
|
||||
|
||||
$hostapd = parse_ini_file(RASPI_HOSTAPD_CONFIG, false, INI_SCANNER_RAW);
|
||||
|
||||
// assume wpa encryption and get the passphrase
|
||||
$type = "WPA";
|
||||
$password = isset($hostapd['wpa_psk']) ? $hostapd['wpa_psk'] : $hostapd['wpa_passphrase'];
|
||||
|
||||
// use wep if configured
|
||||
$wep_default_key = intval($hostapd['wep_default_key']);
|
||||
$wep_key = 'wep_key' . $wep_default_key;
|
||||
if (array_key_exists($wep_key, $hostapd)) {
|
||||
$type = "WEP";
|
||||
$password = $hostapd[$wep_key];
|
||||
}
|
||||
|
||||
// if password is still empty, assume nopass
|
||||
if (empty($password)) {
|
||||
$type = "nopass";
|
||||
}
|
||||
|
||||
$ssid = $hostapd['ssid'];
|
||||
$hidden = intval($hostapd['ignore_broadcast_ssid']) != 0 ? "H:true" : "";
|
||||
|
||||
$ssid = qr_encode($ssid);
|
||||
$password = qr_encode($password);
|
||||
|
||||
$data = "WIFI:S:$ssid;T:$type;P:$password;$hidden;";
|
||||
$command = "qrencode -t svg -m 0 -o - " . escapeshellarg($data);
|
||||
$svg = shell_exec($command);
|
||||
|
||||
$config_mtime = filemtime(RASPI_HOSTAPD_CONFIG);
|
||||
$last_modified = gmdate('D, d M Y H:i:s ', $config_mtime) . 'GMT';
|
||||
$content_length = strlen($svg);
|
||||
|
||||
header("Content-Type: image/svg+xml");
|
||||
header("Content-Length: $content_length");
|
||||
header("Last-Modified: $last_modified");
|
||||
header("X-QR-Code-Content: $data");
|
||||
echo shell_exec($command);
|
||||
|
@ -63,7 +63,7 @@ function config_installation() {
|
||||
# Runs a system software update to make sure we're using all fresh packages
|
||||
function install_dependencies() {
|
||||
install_log "Installing required packages"
|
||||
sudo apt-get install $apt_option lighttpd $php_package git hostapd dnsmasq vnstat || install_error "Unable to install dependencies"
|
||||
sudo apt-get install $apt_option lighttpd $php_package git hostapd dnsmasq vnstat qrencode || install_error "Unable to install dependencies"
|
||||
}
|
||||
|
||||
# Enables PHP for lighttpd and restarts service for settings to take effect
|
||||
|
@ -82,21 +82,25 @@
|
||||
<div class="tab-pane fade" id="security">
|
||||
<h4 class="mt-3"><?php echo _("Security settings"); ?></h4>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cbxwpa"><?php echo _("Security type"); ?></label>
|
||||
<?php SelectorOptions('wpa', $arrSecurity, $arrConfig['wpa'], 'cbxwpa'); ?>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="cbxwpa"><?php echo _("Security type"); ?></label>
|
||||
<?php SelectorOptions('wpa', $arrSecurity, $arrConfig['wpa'], 'cbxwpa'); ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="cbxwpapairwise"><?php echo _("Encryption Type"); ?></label>
|
||||
<?php SelectorOptions('wpa_pairwise', $arrEncType, $arrConfig['wpa_pairwise'], 'cbxwpapairwise'); ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="txtwpapassphrase"><?php echo _("PSK"); ?></label>
|
||||
<input type="text" class="form-control" id="txtwpapassphrase" name="wpa_passphrase" value="<?php echo htmlspecialchars($arrConfig['wpa_passphrase'], ENT_QUOTES); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cbxwpapairwise"><?php echo _("Encryption Type"); ?></label>
|
||||
<?php SelectorOptions('wpa_pairwise', $arrEncType, $arrConfig['wpa_pairwise'], 'cbxwpapairwise'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="txtwpapassphrase"><?php echo _("PSK"); ?></label>
|
||||
<input type="text" class="form-control" id="txtwpapassphrase" name="wpa_passphrase" value="<?php echo htmlspecialchars($arrConfig['wpa_passphrase'], ENT_QUOTES); ?>" />
|
||||
<div class="col-md-6">
|
||||
<figure class="figure">
|
||||
<img src="/app/img/wifi-qr-code.php" class="figure-img img-fluid" alt="RaspAP Wifi QR code" style="width:100%;">
|
||||
<figcaption class="figure-caption"><?php echo _("Scan this QR code with your phone to connect to this RaspAP."); ?></figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user