themes: only check password for uid=0 pages, nobody cannot read shadow (#426)
[project/luci.git] / themes / freifunk-generic / luasrc / view / themes / freifunk-generic / header.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11 -%>
12
13 <%
14 local fs = require "luci.fs"
15 local sys = require "luci.sys"
16 local http = require "luci.http"
17 local disp = require "luci.dispatcher"
18
19 local hostname = sys.hostname()
20 local load1, load5, load15 = sys.loadavg()
21
22 local request = disp.context.path
23 local category = request[1]
24 local cattree = category and disp.node(category)
25
26 local tree = disp.node()
27 local node = disp.context.dispatched
28
29 local categories = disp.node_childs(tree)
30
31 local c = tree
32 local i, r
33
34 -- tag all nodes leading to this page
35 for i, r in ipairs(request) do
36 if c.nodes and c.nodes[r] then
37 c = c.nodes[r]
38 c._menu_selected = true
39 end
40 end
41
42 local uci = require "luci.model.uci".cursor()
43 local ff = uci:get("freifunk", "community", "name") or ""
44 local co = "profile_" .. ff
45 local community = uci:get_first(co, "community", "name") or "Freifunk"
46 local hp = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net"
47 local logo = "/luci-static/freifunk-generic/logo.jpg"
48 local banner = false
49 local show_comm = true
50
51 local lo = fs.glob("/www/luci-static/resources/custom_logo.*")
52 if lo[1] then
53 logo = string.gsub(lo[1], "/www", "")
54 end
55
56 local lon = fs.glob("/www/luci-static/resources/custom_logo_only.*")
57 if lon[1] then
58 logo = string.gsub(lon[1], "/www", "")
59 show_comm = false
60 end
61
62 local hea = fs.glob("/www/luci-static/resources/custom_header.*")
63 if hea[1] then
64 logo = string.gsub(hea[1], "/www", "")
65 show_comm = false
66 banner = true
67 end
68 -%>
69
70 <?xml version="1.0" encoding="utf-8"?>
71 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
72 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
73 <head>
74 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
75 <meta http-equiv="Content-Script-Type" content="text/javascript" />
76 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
77 <link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="<%=media%>/mobile.css" type="text/css" />
78 <link rel="stylesheet" media="handheld" href="<%=media%>/mobile.css" type="text/css" />
79 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
80 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
81 <% end -%>
82 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
83
84 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
85 </head>
86
87 <body class="lang_<%=luci.i18n.context.lang%>">
88
89 <div class="wrapper">
90
91 <!--[if lt IE 7]>
92 <div class="warning"><div style="background-color: #cccccc;padding: 2px 10px 2px 10px">
93 <%: Your Internet Explorer is too old to display this page correctly. Please upgrade it to at least version 7 or use another browser like Firefox, Opera or Safari.%>
94 </div></div>
95 <![endif]-->
96
97 <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
98 <div class="warning">
99 <strong><%:No password set!%></strong><br />
100 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
101 </div>
102 <%- end -%>
103
104 <p class="skiplink">
105 <span id="skiplink1"><a href="#navigation"><%:skiplink1 Skip to navigation%></a></span>
106 <span id="skiplink2"><a href="#content"><%:skiplink2 Skip to content%></a></span>
107 </p>
108
109 <div id="header">
110 <%if banner then%>
111 <div class="header_banner">
112 <a href="<%=hp%>"><img src="<%=logo%>" alt="Header" /></a>
113 </div>
114 <%else%>
115 <div class="header_left">
116 <a href="<%=hp%>"><img src="<%=logo%>" alt="Logo" /></a>
117 <%if show_comm then%>
118 <a href="<%=hp%>"><%=community%></a>
119 <br/>
120 <%end%>
121 <div class = "spacer"></div>
122 </div>
123 <div class="header_right">
124 <%=luci.version.distversion%><br />
125 <%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%><br />
126 <%:Hostname%>: <%=hostname%><br />
127 <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
128 <%:Auto Refresh%>:
129 <span id="xhr_poll_status_on"><%:on%></span>
130 <span id="xhr_poll_status_off" style="display:none"><%:off%></span>
131 </span>
132 </div>
133 <%end%>
134 </div>
135
136 <%-
137 local function submenu(prefix, node)
138 local childs = disp.node_childs(node)
139 if #childs > 0 then
140 %>
141 <ul id="submenu_<%=string.gsub(string.gsub(prefix, "/", "_"), "^_(.-)_$", "%1")%>">
142 <%-
143 for i, r in ipairs(childs) do
144 local nnode = node.nodes[r]
145 local href = controller .. prefix .. r .. "/" ..
146 (nnode.query and http.build_querystring(nnode.query) or "")
147 %>
148 <li>
149 <a<%=ifattr(nnode._menu_selected, "class", "active")%> href="<%=luci.util.pcdata(href)%>"><%=translate(nnode.title)%></a>
150 <%- submenu(prefix .. r .. "/", nnode) %>
151 </li>
152 <%-
153 end
154 %>
155 </ul>
156 <%
157 end
158 end
159 %>
160
161 <div id="menubar">
162 <h2 class="navigation"><a id="navigation" name="navigation"><%:navigation Navigation%></a></h2>
163 <ul id="mainmenu" class="dropdowns">
164 <%
165 local childs = disp.node_childs(cattree)
166 if #childs > 0 then
167 for i, r in ipairs(childs) do
168 local nnode = cattree.nodes[r]
169 local href = controller .. "/" .. category .. "/" .. r ..
170 (nnode.query and http.build_querystring(k.query) or "")
171 %>
172 <li>
173 <a<%=ifattr(nnode._menu_selected, "class", "preactive")%> href="<%=href%>"><%=translate(nnode.title)%></a>
174 <%- submenu("/" .. category .. "/" .. r .. "/", nnode) %>
175 </li>
176 <%
177 end
178 end
179 %>
180 <li></li>
181 </ul>
182
183 <% if #categories > 1 then %>
184 <ul id="modemenu">
185 <% for i, r in ipairs(categories) do %>
186 <li><a<%=ifattr(request[1] == r, "class", "active")%> href="<%=controller%>/<%=r%>/"><%=striptags(translate(tree.nodes[r].title))%></a></li>
187 <% end %>
188 </ul>
189 <% end %>
190
191 <%
192 if tree.nodes[category] and tree.nodes[category].ucidata then
193 local ucic = 0
194 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
195 for k, l in pairs(j) do
196 for m, n in pairs(l) do
197 ucic = ucic + 1;
198 end
199 end
200 end
201 -%>
202 <div id="savemenu">
203 <% if ucic > 0 then %>
204 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes/?redir=<%=http.urlencode(http.formvalue("redir") or REQUEST_URI)%>"><%:Unsaved Changes%>: <%=ucic%></a>
205 <% end -%>
206 </div>
207 <% end %>
208
209 <div class="clear"></div>
210 </div>
211 <div id="maincontent">
212 <% if category ~= "freifunk" and category ~= "splash" then %>
213 <noscript>
214 <div class="errorbox">
215 <strong><%:Java Script required!%></strong><br />
216 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
217 </div>
218 </noscript>
219 <% end %>