sysauth.htm 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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(FULL_REQUEST_URI)%>">
  8. <%- if fuser then %>
  9. <div class="alert-message warning">
  10. <p><%:Invalid username and/or password! Please try again.%></p>
  11. </div>
  12. <% end -%>
  13. <div class="cbi-map">
  14. <h2 name="content"><%:Authorization Required%></h2>
  15. <div class="cbi-map-descr">
  16. <%:Please enter your username and password.%>
  17. </div>
  18. <div class="cbi-section"><div class="cbi-section-node">
  19. <div class="cbi-value">
  20. <label class="cbi-value-title"><%:Username%></label>
  21. <div class="cbi-value-field">
  22. <input class="cbi-input-text" type="text" name="luci_username" value="<%=duser%>" />
  23. </div>
  24. </div>
  25. <div class="cbi-value cbi-value-last">
  26. <label class="cbi-value-title"><%:Password%></label>
  27. <div class="cbi-value-field">
  28. <input class="cbi-input-text" type="password" name="luci_password" />
  29. </div>
  30. </div>
  31. </div></div>
  32. </div>
  33. <div class="cbi-page-actions">
  34. <input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
  35. <input type="reset" value="<%:Reset%>" class="cbi-button cbi-button-reset" />
  36. </div>
  37. </form>
  38. <script type="text/javascript">//<![CDATA[
  39. var input = document.getElementsByName('luci_password')[0];
  40. if (input)
  41. input.focus();
  42. //]]></script>
  43. <%
  44. local uci = require "luci.model.uci".cursor()
  45. local fs = require "nixio.fs"
  46. local https_key = uci:get("uhttpd", "main", "key")
  47. local https_port = uci:get("uhttpd", "main", "listen_https")
  48. if type(https_port) == "table" then
  49. https_port = https_port[1]
  50. end
  51. if https_port and fs.access(https_key) then
  52. https_port = https_port:match("(%d+)$")
  53. %>
  54. <script type="text/javascript">//<![CDATA[
  55. if (document.location.protocol != 'https:') {
  56. var url = 'https://' + window.location.hostname + ':' + '<%=https_port%>' + window.location.pathname;
  57. var img=new Image;
  58. img.onload=function(){window.location = url};
  59. img.src='https://' + window.location.hostname + ':' + '<%=https_port%>' + '<%=resource%>/cbi/up.gif?' + Math.random();;
  60. setTimeout(function(){
  61. img.src=''
  62. }, 5000);
  63. }
  64. //]]></script>
  65. <% end %>
  66. <%+footer%>