tinyproxy_status.htm 942 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <%
  2. if luci.http.formvalue("frame") == "1" then
  3. local uci = require "luci.model.uci".cursor()
  4. local addr = "127.0.0.1"
  5. local port = "8888"
  6. uci:foreach("tinyproxy", "tinyproxy",
  7. function(s)
  8. addr = s.StatHost or addr
  9. port = s.Port or port
  10. return false
  11. end)
  12. local data = false
  13. local wget = io.popen("wget -qO- http://%s:%s" % { addr, port })
  14. if wget then
  15. while true do
  16. local l = wget:read("*l")
  17. if not l then
  18. break
  19. end
  20. luci.http.write(l)
  21. data = true
  22. end
  23. wget:close()
  24. end
  25. if not data then
  26. luci.http.write(translate("Failed to retrieve statistics from url:"))
  27. luci.http.write(" http://%s:%s" % { addr, port })
  28. end
  29. return
  30. end
  31. -%>
  32. <%+header%>
  33. <div class="cbi-map">
  34. <h2><a id="content" name="content"><%:Tinyproxy Status%></a></h2>
  35. <div class="cbi-section">
  36. <iframe src="<%=REQUESTURL%>?frame=1" style="width:100%; height:350px; border:none"></iframe>
  37. </div>
  38. </div>
  39. <%+footer%>