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">
5 <title>Filebrowser - LuCI</title>
6 <style type="text/css">
13 list-style-type: none;
17 vertical-align: bottom;
22 <script type="text/javascript">
23 function callback(path) {
25 var input = window.opener.document.getElementById(decodeURIComponent('<%=luci.http.urlencode(luci.http.formvalue('field'))%>'));
27 input.value = decodeURIComponent(path);
39 require("luci.dispatcher")
41 local field = luci.http.formvalue('field')
42 local request = luci.dispatcher.context.args
45 for i = 1, #request do
46 if request[i] ~= '..' and #request[i] > 0 then
47 path[#path+1] = request[i]
51 local filestat = nixio.fs.stat(table.concat(path, '/'))
52 local baseurl = { 'admin', 'filebrowser' }
54 if filestat and filestat.type == "reg" then
56 elseif not (filestat and filestat.type == "dir") then
62 filepath = table.concat(path, '/')
66 for _, e in luci.util.vspairs(nixio.util.consume((nixio.fs.dir(filepath)))) do
67 local p = filepath .. e
68 local s = nixio.fs.stat(p)
70 entries[#entries+1] = {
80 <% for i, dir in ipairs(path) do %>
82 <a href="<%=url(unpack(baseurl))%>?field=<%=luci.http.urlencode(field)%>">(root)</a>
83 <% elseif next(path, i) then %>
84 <% baseurl[#baseurl+1] = luci.http.urlencode(dir) %>
85 / <a href="<%=url(unpack(baseurl))%>?field=<%=luci.http.urlencode(field)%>"><%=pcdata(dir)%></a>
87 <% baseurl[#baseurl+1] = luci.http.urlencode(dir) %>
97 <% for _, e in ipairs(entries) do if e.type == 'dir' then -%>
99 <img src="<%=resource%>/cbi/folder.gif" alt="<%:Directory%>" />
100 <a href="<%=url(unpack(baseurl))%>/<%=luci.http.urlencode(e.name)%>?field=<%=luci.http.urlencode(field)%>"><%=pcdata(e.name)%>/</a>
104 <% for _, e in ipairs(entries) do if e.type ~= 'dir' then -%>
106 <img src="<%=resource%>/cbi/file.gif" alt="<%:File%>" />
107 <a href="#" onclick="callback('<%=luci.http.urlencode(e.path)%>')"><%=pcdata(e.name)%></a>