Replaced an old icon with a new one, format changed from ICO to PNG to make it even...
[project/luci.git] / applications / luci-app-noddos / htdocs / cgi-bin / clientdetails
1 #!/usr/bin/lua
2
3 -- clientdetails.lua : Provides details about client devices discovered by Noddos
4 -- Copyright (C) 2017 Steven Hessing (steven.hessing@gmail.com)
5 -- This is free software, licensed under the GNU General Public License v3.
6
7 require "nixio.fs"
8
9 print ("Content-type: Text/html\n")
10 local info = os.getenv("QUERY_STRING")
11
12 local params = {}
13 local echo = {}
14
15 function print_row(key)
16 print ("<tr><th>")
17 print (key)
18 print ("</th><td>")
19 print (device[key])
20 print ("</td></tr>")
21 end
22
23 for name, value in string.gmatch(info .. '&', '(.-)%=(.-)%&') do
24 value = string.gsub(value , '%+', ' ')
25 value = string.gsub(value , '%%(%x%x)', function(dpc)
26 return string.char(tonumber(dpc,16))
27 end )
28 params[name] = value
29
30 value = string.gsub(value, "%&", "&amp;")
31 value = string.gsub(value, "%<", "&lt;")
32 value = string.gsub(value, '%"', "&quot;")
33 echo[name] = value
34 end
35
36 device = {}
37 profile = {}
38
39 if nixio.fs.access("/var/lib/noddos/DeviceDump.json") then
40 io.input("/var/lib/noddos/DeviceDump.json")
41 local t = io.read("*all")
42 local json = require "luci.jsonc"
43 local devdump = json.parse(t)
44 for i, v in ipairs(devdump) do
45 if v.MacAddress == params["mac"] then
46 device = v
47 end
48 end
49 io.input("/var/lib/noddos/DeviceProfiles.json")
50 t = io.read("*all")
51 local temp = json.parse(t)
52 for i, v in ipairs(temp) do
53 if device.DeviceProfileUuid == v.DeviceProfileUuid then
54 profile = v
55 end
56 end
57 end
58 pagetop = [[
59 <html>
60 <head>
61 <title>Client Details by Noddos</title>
62 <meta charset="utf-8">
63 <!--[if lt IE 9]><script src="/luci-static/bootstrap/html5.js?v=git-17.100.70571-29fabe2"></script><![endif]-->
64 <meta name="viewport" content="initial-scale=1.0">
65 <link rel="stylesheet" href="/luci-static/bootstrap/cascade.css?v=git-17.100.70571-29fabe2">
66 <link rel="stylesheet" media="only screen and (max-device-width: 854px)" href="/luci-static/bootstrap/mobile.css?v=git-17.100.70571-29fabe2" type="text/css" />
67 <link rel="shortcut icon" href="/luci-static/bootstrap/favicon.png">
68 <script src="/luci-static/resources/xhr.js?v=git-17.100.70571-29fabe2"></script>
69 </head>
70 <body text=blue>
71 <h1>Client Details</h1>
72 ]]
73 print (pagetop)
74
75 if params["mac"] ~= nil then
76 print ("<table>")
77 for i, key in ipairs{"MacAddress", "Ipv4Address", "Ipv6Address", "DeviceProfileUuid", "DhcpHostname", "DhcpVendor", "SsdpFriendlyName", "SsdpLocation", "SsdpManufacturer", "SsdpModelName", "SsdpModelUrl", "SsdpSerialNumber", "SsdpServer","SsdpUserAgent", "MdnsDeviceUrl", "MdnsHw", "MdnsManufacturer", "MdnsModelName", "MdnsOs", "WsDiscoveryTypes", "WsDiscoveryXaddrs", "DnsQueries"} do
78 print_row(key)
79 end
80 print ("</table>")
81 else
82 print ("no mac address specified")
83 end
84
85 pagebase = [[<br><br>
86 Client Details by
87 <a href=http://www.noddos.io>Noddos</a>
88 </body></html>
89 ]]
90
91 print (pagebase)