2
0

sysauth.htm 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <%#
  2. Copyright 2008 Steven Barth <steven@midlink.org>
  3. Copyright 2008-2012 Jo-Philipp Wich <jow@openwrt.org>
  4. Licensed to the public under the Apache License 2.0.
  5. -%>
  6. <%+header%>
  7. <form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
  8. <%- if fuser then %>
  9. <div class="errorbox"><%:Invalid username and/or password! Please try again.%></div>
  10. <% end -%>
  11. <div class="cbi-map">
  12. <h2 name="content"><%:Authorization Required%></h2>
  13. <div class="cbi-map-descr">
  14. <%:Please enter your username and password.%>
  15. </div>
  16. <fieldset class="cbi-section"><fieldset class="cbi-section-node">
  17. <div class="cbi-value">
  18. <label class="cbi-value-title"><%:Username%></label>
  19. <div class="cbi-value-field">
  20. <input class="cbi-input-user" type="text" name="luci_username" value="<%=duser%>" />
  21. </div>
  22. </div>
  23. <div class="cbi-value cbi-value-last">
  24. <label class="cbi-value-title"><%:Password%></label>
  25. <div class="cbi-value-field">
  26. <input class="cbi-input-password" type="password" name="luci_password" />
  27. </div>
  28. </div>
  29. </fieldset></fieldset>
  30. </div>
  31. <div>
  32. <input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
  33. <input type="reset" value="<%:Reset%>" class="cbi-button cbi-button-reset" />
  34. </div>
  35. </form>
  36. <script type="text/javascript">//<![CDATA[
  37. var input = document.getElementsByName('luci_password')[0];
  38. if (input)
  39. input.focus();
  40. //]]></script>
  41. <%
  42. local uci = require "luci.model.uci".cursor()
  43. local fs = require "nixio.fs"
  44. local https_key = uci:get("uhttpd", "main", "key")
  45. local https_port = uci:get("uhttpd", "main", "listen_https")
  46. if type(https_port) == "table" then
  47. https_port = https_port[1]
  48. end
  49. if https_port and fs.access(https_key) then
  50. https_port = https_port:match("(%d+)$")
  51. %>
  52. <script type="text/javascript">//<![CDATA[
  53. if (document.location.protocol != 'https:') {
  54. var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
  55. var img=new Image;
  56. img.onload=function(){window.location = url};
  57. img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
  58. setTimeout(function(){
  59. img.src=''
  60. }, 5000);
  61. }
  62. //]]></script>
  63. <% end %>
  64. <%+footer%>