libs/web: add "any" option to firewall_zonelist widget
[project/luci.git] / libs / web / luasrc / view / cbi / filebrowser.htm
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5     <title>Filebrowser - LuCI</title>
6         <style type="text/css">
7                 #path, #listing {
8                         font-size: 85%;
9                 }
10
11                 ul {
12                         padding-left: 0;
13                         list-style-type: none;
14                 }
15
16                 li img {
17                         vertical-align: bottom;
18                         margin-right: 0.2em;
19                 }
20         </style>
21
22         <script type="text/javascript">
23                 function callback(path) {
24                         if( window.opener ) {
25                                 var input = window.opener.document.getElementById('<%=luci.http.formvalue('field')%>');
26                                 if( input ) {
27                                         input.value = path;
28                                         window.close();
29                                 }
30                         }
31                 }
32         </script>
33 </head>
34 <body>
35         <%
36                 require("nixio.fs")
37                 require("nixio.util")
38                 require("luci.http")
39                 require("luci.dispatcher")
40
41                 local field   = luci.http.formvalue('field')
42                 local request = luci.dispatcher.context.args
43                 local path    = { '' }
44
45                 for i = 1, #request do
46                         if request[i] ~= '..' and #request[i] > 0 then
47                                 path[#path+1] = request[i]
48                         end
49                 end
50
51                 local filepath = table.concat( path, '/' )
52                 local filestat = nixio.fs.stat( filepath )
53                 local baseurl  = luci.dispatcher.build_url('admin', 'filebrowser')
54
55                 if filestat and filestat.type == "reg" then
56                         table.remove( path, #path )
57                         filepath = table.concat( path, '/' ) .. '/'
58                 elseif not ( filestat and filestat.type == "dir" ) then
59                         path     = { '' }
60                         filepath = '/'
61                 else
62                         filepath = filepath .. '/'
63                 end
64
65                 local entries = nixio.util.consume((nixio.fs.dir(filepath)))
66         -%>
67     <div id="path">
68                 Location:
69                 <% for i, dir in ipairs(path) do %>
70                         <% if i == 1 then %>
71                                 <a href="<%=baseurl%>?field=<%=field%>">(root)</a>
72                         <% elseif next(path, i) then %>
73                                 <% baseurl = baseurl .. '/' .. dir %>
74                                 / <a href="<%=baseurl%>?field=<%=field%>"><%=dir%></a>
75                         <% else %>
76                                 <% baseurl = baseurl .. '/' .. dir %>
77                                 / <%=dir%>
78                         <% end %>
79                 <% end %>
80         </div>
81
82         <hr />
83
84         <div id="listing">
85                 <ul>
86                         <% for _, e in luci.util.vspairs(entries) do
87                             local stat = nixio.fs.stat(filepath..e)
88                                 if stat and stat.type == 'dir' then
89                         -%>
90                                 <li class="dir">
91                                         <img src="<%=resource%>/cbi/folder.gif" alt="<%:Directory%>" />
92                                         <a href="<%=baseurl%>/<%=e%>?field=<%=field%>"><%=e%>/</a>
93                                 </li>
94                         <% end end -%>
95
96                         <% for _, e in luci.util.vspairs(entries) do
97                             local stat = nixio.fs.stat(filepath..e)
98                                 if stat and stat.type ~= 'dir' then
99                         -%>
100                                 <li class="file">
101                                         <img src="<%=resource%>/cbi/file.gif" alt="<%:File%>" />
102                                         <a href="#" onclick="callback('<%=filepath..e%>')"><%=e%></a>
103                                 </li>
104                         <% end end -%>
105                 </ul>
106         </div>
107 </body>
108 </html>