2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: files.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
16 let template = get_template "files.html"
18 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _) _ =
19 let deleted = q#param_true "deleted" in
20 template#conditional "deleted" deleted;
23 "select id, name, name_deleted, octet_length (content)
25 where hostid = ? and " ^
26 (if not deleted then "name is not null"
27 else "name_deleted is not null") ^
29 let sth = dbh#prepare_cached sql in
30 sth#execute [`Int hostid];
35 let id, name, size, is_deleted =
37 | [`Int id; `String name; `Null; `Int size] ->
39 | [`Int id; `Null; `String name; `Int size] ->
41 | _ -> assert false in
42 [ "id", Template.VarString (string_of_int id);
43 "name", Template.VarString name;
44 "ksize", Template.VarString (string_of_int (size / 1024));
45 "is_deleted", Template.VarConditional is_deleted ]) in
47 template#table "files" table;