Merge pull request #1662 from dibdot/travelmate

luci-app-travelmate: fixes for new QR code template
This commit is contained in:
Dirk Brenken 2018-03-05 12:26:19 +01:00 committed by GitHub
commit 41b7a90e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,19 +18,18 @@ This is free software, licensed under the Apache License, Version 2.0
local mode = s.mode or "" local mode = s.mode or ""
local ssid = s.ssid or "" local ssid = s.ssid or ""
local enc = s.encryption or "" local enc = s.encryption or ""
local key = s.key or "nokey" local key = s.key or ""
local hidden = s.hidden or "false" local hidden = s.hidden or "false"
local disabled = s.disabled or "" local disabled = s.disabled or ""
if device ~= "" and mode == "ap" and disabled ~= "1" then local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""}
if string.match(enc, '^psk2') then
enc = "wpa2" if device and mode == "ap" and disabled ~= "1" then
elseif string.match(enc, '^psk') then if string.match(enc, '^psk') then
enc = "wpa" enc = "WPA"
elseif string.match(enc, '^wep') then elseif string.match(enc, '^wep') then
enc = "WEP"
if tonumber(key) then if tonumber(key) then
enc = "" key = wep_slots[tonumber(key)]
else
enc = "wep"
end end
elseif enc == "none" then elseif enc == "none" then
enc = "nopass" enc = "nopass"
@ -41,9 +40,9 @@ This is free software, licensed under the Apache License, Version 2.0
if hidden == "1" then if hidden == "1" then
hidden = "true" hidden = "true"
end end
if ssid ~= "" and enc ~= "" then if ssid and enc and key then
local e_ssid = string.gsub(ssid,"[\";\\:, ]","\\%1") local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]])
local e_key = string.gsub(key,"[\";\\:, ]","\\%1") local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]])
local qrcode = "" local qrcode = ""
if nixio.fs.access("/usr/bin/qrencode") then if nixio.fs.access("/usr/bin/qrencode") then
qrcode = luci.sys.exec("/usr/bin/qrencode -I -t SVG -8 -o - 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'") qrcode = luci.sys.exec("/usr/bin/qrencode -I -t SVG -8 -o - 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'")