Merge pull request #1818 from dibdot/lxc_fix
[project/luci.git] / applications / luci-app-tinyproxy / luasrc / view / tinyproxy_status.htm
1 <%
2
3 if luci.http.formvalue("frame") == "1" then
4         local uci = require "luci.model.uci".cursor()
5         local addr = "127.0.0.1"
6         local port = "8888"
7
8         uci:foreach("tinyproxy", "tinyproxy",
9                 function(s)
10                         addr = s.StatHost or addr
11                         port = s.Port     or port
12                         return false
13                 end)
14
15         local data = false
16         local wget = io.popen("wget -qO- http://%s:%s" %{
17                 luci.util.shellquote(addr),
18                 luci.util.shellquote(port)
19         })
20
21         if wget then
22                 while true do
23                         local l = wget:read("*l")
24                         if not l then
25                                 break
26                         end
27
28                         luci.http.write(l)
29                         data = true
30                 end
31
32                 wget:close()
33         end
34
35         if not data then
36                 luci.http.write(translate("Failed to retrieve statistics from url:"))
37                 luci.http.write(" http://%s:%s" %{
38                         luci.util.pcdata(addr),
39                         luci.util.pcdata(port)
40                 })
41         end
42
43         return
44 end
45
46 -%>
47
48 <%+header%>
49
50 <div class="cbi-map">
51         <h2 name="content"><%:Tinyproxy Status%></h2>
52         <div class="cbi-section">
53                 <iframe src="<%=REQUEST_URI%>?frame=1" style="width:100%; height:350px; border:none"></iframe>
54         </div>
55 </div>
56
57 <%+footer%>