2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
10 http://www.apache.org/licenses/LICENSE-2.0
16 <?xml version="1.0" encoding="UTF-8"?>
17 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
18 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
20 <title>Filebrowser - LuCI</title>
21 <style type="text/css">
28 list-style-type: none;
32 vertical-align: bottom;
37 <script type="text/javascript">
38 function callback(path) {
40 var input = window.opener.document.getElementById('<%=luci.http.formvalue('field')%>');
53 require("luci.dispatcher")
55 local field = luci.http.formvalue('field')
56 local request = luci.dispatcher.context.path
59 for i = 3, #request do
60 if request[i] ~= '..' and #request[i] > 0 then
61 path[#path+1] = request[i]
65 local filepath = table.concat( path, '/' )
66 local filestat = luci.fs.stat( filepath )
67 local baseurl = luci.dispatcher.build_url('admin', 'filebrowser')
69 if filestat and filestat.type == "regular" then
70 table.remove( path, #path )
71 filepath = table.concat( path, '/' ) .. '/'
72 elseif not ( filestat and filestat.type == "directory" ) then
76 filepath = filepath .. '/'
79 local entries = luci.fs.dir(filepath)
83 <% for i, dir in ipairs(path) do %>
85 <a href="<%=baseurl%>?field=<%=field%>">(root)</a>
86 <% elseif next(path, i) then %>
87 <% baseurl = baseurl .. '/' .. dir %>
88 / <a href="<%=baseurl%>?field=<%=field%>"><%=dir%></a>
90 <% baseurl = baseurl .. '/' .. dir %>
100 <% for _, e in luci.util.vspairs(entries) do
101 local stat = luci.fs.stat(filepath..e)
102 if e ~= '.' and e ~= '..' and stat and stat.type == 'directory' then
105 <img src="/luci-static/resources/cbi/folder.png" alt="Directory" />
106 <a href="<%=baseurl%>/<%=e%>?field=<%=field%>"><%=e%>/</a>
110 <% for _, e in luci.util.vspairs(entries) do
111 local stat = luci.fs.stat(filepath..e)
112 if stat and stat.type ~= 'directory' then
115 <img src="/luci-static/resources/cbi/file.png" alt="File" />
116 <a href="#" onclick="callback('<%=filepath..e%>')"><%=e%></a>