<%# LuCI - Lua Configuration Interface Copyright 2008 Steven Barth Copyright 2008 Jo-Philipp Wich Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ -%> Filebrowser - LuCI <% require("nixio.fs") require("nixio.util") require("luci.http") require("luci.dispatcher") local field = luci.http.formvalue('field') local request = luci.dispatcher.context.path local path = { '' } for i = 3, #request do if request[i] ~= '..' and #request[i] > 0 then path[#path+1] = request[i] end end local filepath = table.concat( path, '/' ) local filestat = nixio.fs.stat( filepath ) local baseurl = luci.dispatcher.build_url('admin', 'filebrowser') if filestat and filestat.type == "reg" then table.remove( path, #path ) filepath = table.concat( path, '/' ) .. '/' elseif not ( filestat and filestat.type == "dir" ) then path = { '' } filepath = '/' else filepath = filepath .. '/' end local entries = nixio.util.consume((nixio.fs.dir(filepath))) -%>
Location: <% for i, dir in ipairs(path) do %> <% if i == 1 then %> (root) <% elseif next(path, i) then %> <% baseurl = baseurl .. '/' .. dir %> / <%=dir%> <% else %> <% baseurl = baseurl .. '/' .. dir %> / <%=dir%> <% end %> <% end %>

    <% for _, e in luci.util.vspairs(entries) do local stat = nixio.fs.stat(filepath..e) if stat and stat.type == 'dir' then -%>
  • Directory <%=e%>/
  • <% end end -%> <% for _, e in luci.util.vspairs(entries) do local stat = nixio.fs.stat(filepath..e) if stat and stat.type ~= 'dir' then -%>
  • File <%=e%>
  • <% end end -%>