1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<% local view, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"><\/script>');
}
</script>
<script type="text/javascript">
if (typeof $.tablesorter == 'undefined') {
document.write('<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery.tablesorter.js"><\/script>');
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$(".deletepasswdentry").click(function(){ return confirm("Are you sure you want to delete this entry?")});
$("#list").tablesorter({headers: {0:{sorter: false}}, widgets: ['zebra']});
});
</script>
<% htmlviewfunctions.displaycommandresults({"editpasswdentry", "deletepasswdentry", "editpasswd", "editfile"}, session) %>
<% htmlviewfunctions.displaycommandresults({"createpasswdentry"}, session, true) %>
<% -- This is a hack to redirect back to viewing the same file
local redir = page_info.orig_action.."?filename="..html.url_encode(view.value.filename.value)
%>
<%
local editable = false
if view.value.mode and string.match(view.value.mode.value, "^.w") then
editable = true
end
%>
<h1><%= html.html_escape(view.label) %></h1>
<% htmlviewfunctions.displayitem(view.value.filename) %>
<% if view.value.mode then htmlviewfunctions.displayitem(view.value.mode) end %>
<% if view.value.data then %>
<% local containspasswd = 0 %>
<dl><table id="list" class="tablesorter"><thead>
<tr>
<th>Action</th>
<% for i,f in ipairs(view.value.fields.value) do %>
<% if f == "Crypt-Password" then containspasswd = i end %>
<th><%= html.html_escape(f) %></th>
<% end %>
</tr>
</thead><tbody>
<% for i,r in ipairs( view.value.data.value ) do %>
<tr>
<td>
<% if editable then %>
<% if viewlibrary.check_permission("editpasswdentry") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editpasswdentry?filename="..html.url_encode(view.value.filename.value).."&entry="..i.."&redir="..html.url_encode(redir), label="Edit "} %>
<% end %>
<% if viewlibrary.check_permission("deletepasswdentry") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/deletepasswdentry?submit=true&filename="..html.url_encode(view.value.filename.value).."&entry="..i, label="Delete "} %>
<% end %>
<% if 0 < containspasswd and r[containspasswd] ~= "" and viewlibrary.check_permission("editpasswd") then %>
<%= html.link{value=page_info.script..page_info.prefix..page_info.controller.."/editpasswd?filename="..html.url_encode(view.value.filename.value).."&entry="..i.."&redir="..html.url_encode(redir), label="ChangePass "} %>
<% end %>
<% end %>
</td>
<% for j,f in ipairs(r) do %>
<td><% if (j == containspasswd) and (f ~= "") then io.write("********") else io.write(html.html_escape(f)) end %></td>
<% end %>
</tr>
<% end %>
</tbody></table></dl>
<% end %>
<% if editable and view.value.data and viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("editfile") then %>
<h2>Expert</h2>
<dl>
<dt></dt>
<dd><form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. '/editfile') %>" method="post">
<input type='hidden' name='filename' value='<%= html.html_escape(view.value.filename.value) %>'>
<input type='hidden' name='redir' value='<%= html.html_escape(redir) %>'>
<input class='submit' type='submit' value='Edit'></form></dd>
</dl>
<% end %>
<% if editable and view.value.data and viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("createpasswdentry") then
local createform = viewlibrary.dispatch_component("createpasswdentry", {filename=view.value.filename.value, redir=redir}, true) %>
<H2><%= html.html_escape(createform.label) %></H2>
<% createform.action = page_info.script .. page_info.prefix .. page_info.controller .. "/createpasswdentry"
htmlviewfunctions.displayform(createform)
end %>
|