--- /dev/null
+<% @header[("title", ["Generated passwords"])];
+
+Group.requireGroupNum 0;
+
+if $"id" <> "" then
+ val id = Web.stoi ($"id");
+ switch PassGen.lookup id of
+ NONE => %>ID not found!<%
+ | SOME pass => %><table class="blanks">
+ <tr> <td>ID:</td> <td><% id %></td> </tr>
+ <tr> <td>Password:</td> <td><% pass %></td> </tr>
+ </table><%
+ end
+end %>
+
+<p><form method="post"><table class="blanks">
+ <tr> <td>ID:</td> <td><input name="id" size="5"></td> </tr>
+ <tr> <td><input type="submit" value="Lookup"></td> </tr>
+</table></form></p>
+
+<% @footer[] %>
\ No newline at end of file
--- /dev/null
+structure PassGen :> PASSGEN = struct
+
+open Sql Init
+
+fun lookup id =
+ let
+ val db = C.conn Config.passgenDbstring
+ in
+ (case C.oneOrNoRows db ($`SELECT pass FROM Pass WHERE id = ^(C.intToSql id)`) of
+ NONE => NONE
+ | SOME [pass] => SOME (C.stringFromSql pass)
+ | _ => raise Fail "Bad \"SELECT pass\" row")
+ before C.close db
+ end
+
+end