luci-proto-pppossh: move pppossh to own package
[project/luci.git] / applications / luci-app-travelmate / luasrc / view / travelmate / ap_qr.htm
1 <%#
2 Copyright 2018 Dirk Brenken (dev@brenken.org)
3 This is free software, licensed under the Apache License, Version 2.0
4 -%>
5
6 <%+header%>
7
8 <div class="cbi-map">
9 <div class="cbi-map-descr">
10 <%=translate("Here you'll find the QR codes from all of your configured Access Points. It allows you to connect your Android or iOS devices to your router's WiFi using the QR code shown below.")%>
11 </div>
12 <%- local uci = require("luci.model.uci").cursor()
13
14 uci:foreach("wireless", "wifi-iface", function(s)
15 local device = s.device or ""
16 local mode = s.mode or ""
17 local ssid = s.ssid or ""
18 local enc = s.encryption or ""
19 local key = s.key or ""
20 local hidden = s.hidden or "false"
21 local disabled = s.disabled or ""
22 local wep_slots = {s.key1 or "", s.key2 or "", s.key3 or "", s.key4 or ""}
23
24 if device and mode == "ap" and disabled ~= "1" then
25 if string.match(enc, '^psk') then
26 enc = "WPA"
27 elseif string.match(enc, '^wep') then
28 enc = "WEP"
29 if tonumber(key) then
30 key = wep_slots[tonumber(key)]
31 end
32 elseif enc == "none" then
33 enc = "nopass"
34 key = "nokey"
35 else
36 enc = ""
37 end
38
39 if hidden == "1" then
40 hidden = "true"
41 end
42
43 if ssid and enc and key then
44 local e_ssid = string.gsub(ssid,"[\"\\';:, ]",[[\\\%1]])
45 local e_key = string.gsub(key,"[\"\\';:, ]",[[\\\%1]])
46 local qrcode = ""
47
48 qrcode = luci.sys.exec("/usr/bin/qrencode --inline --8bit --type=SVG --output=- 'WIFI:S:\"'" .. e_ssid .. "'\";T:'" .. enc .. "';P:\"'" .. e_key .. "'\";H:'" .. hidden .. "';'")
49 -%>
50 <div class="cbi-section">
51 <h3>AP on <%=device%> with SSID "<%=ssid%>"</h3>
52 <h3><%=qrcode%></h3>
53 </div>
54 <%-
55 end
56 end
57 end)
58 -%>
59 </div>
60 <div class="cbi-page-actions right">
61 <form class="inline" action="<%=luci.dispatcher.build_url('admin/services/travelmate/tab_from_cbi')%>" method="post">
62 <input class="cbi-button cbi-button-reset" type="submit" value="<%:Back to overview%>" />
63 </form>
64 </div>
65
66 <%+footer%>