scripts/contacts.ml
scripts/create.ml
scripts/create_form.ml
+scripts/create_user.ml
+scripts/create_user_form.ml
scripts/delete_file.ml
scripts/delete_file_form.ml
scripts/delete_image.ml
scripts/delete_image_form.ml
+scripts/delete_user.ml
+scripts/delete_user_form.ml
scripts/diff.ml
scripts/edit.ml
scripts/edit_page_css.ml
scripts/search.ml
scripts/send_feedback.ml
scripts/send_feedback_form.ml
+scripts/set_password.ml
+scripts/set_password_form.ml
scripts/signup.ml
scripts/sitemap.ml
scripts/undelete_file.ml
templates/contact_show.html
templates/contacts.html
templates/create_form.html
+templates/create_user_form.html
templates/delete_file_form.html
templates/delete_image_form.html
+templates/delete_user_form.html
templates/diff.html
templates/edit.html
templates/edit_conflict.html
templates/rss.xml
templates/send_feedback.txt
templates/send_feedback_form.html
+templates/set_password_form.html
templates/sitemap.html
templates/undelete_file_form.html
templates/undelete_image_form.html
wikilib.cmi
create_form.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx \
wikilib.cmx
+create_user.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
+create_user.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
+create_user_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
+create_user_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
delete_file.cmo: cocanwiki.cmo cocanwiki_emailnotify.cmo cocanwiki_ok.cmo
delete_file.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx
delete_file_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
delete_image.cmx: cocanwiki.cmx cocanwiki_emailnotify.cmx cocanwiki_ok.cmx
delete_image_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
delete_image_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+delete_user.cmo: cocanwiki.cmo cocanwiki_ok.cmo
+delete_user.cmx: cocanwiki.cmx cocanwiki_ok.cmx
+delete_user_form.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_template.cmi
+delete_user_form.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
diff.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_template.cmi
diff.cmx: cocanwiki.cmx cocanwiki_diff.cmx cocanwiki_template.cmx
edit.cmo: cocanwiki.cmo cocanwiki_diff.cmo cocanwiki_emailnotify.cmo \
send_feedback.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_template.cmx
send_feedback_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
send_feedback_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
+set_password.cmo: cocanwiki.cmo cocanwiki_ok.cmo
+set_password.cmx: cocanwiki.cmx cocanwiki_ok.cmx
+set_password_form.cmo: cocanwiki.cmo cocanwiki_template.cmi
+set_password_form.cmx: cocanwiki.cmx cocanwiki_template.cmx
signup.cmo: cocanwiki.cmo cocanwiki_ok.cmo cocanwiki_strings.cmo
signup.cmx: cocanwiki.cmx cocanwiki_ok.cmx cocanwiki_strings.cmx
sitemap.cmo: cocanwiki.cmo cocanwiki_date.cmo cocanwiki_strings.cmo \
# Makefile for COCANWIKI.
-# $Id: Makefile,v 1.14 2004/09/20 17:18:26 rich Exp $
+# $Id: Makefile,v 1.15 2004/09/21 13:01:15 rich Exp $
include ../Makefile.config
contacts.cmo \
create.cmo \
create_form.cmo \
+ create_user.cmo \
+ create_user_form.cmo \
delete_file.cmo \
delete_file_form.cmo \
delete_image.cmo \
delete_image_form.cmo \
+ delete_user.cmo \
+ delete_user_form.cmo \
diff.cmo \
edit.cmo \
edit_page_css.cmo \
search.cmo \
send_feedback.cmo \
send_feedback_form.cmo \
+ set_password.cmo \
+ set_password_form.cmo \
signup.cmo \
sitemap.cmo \
undelete_file.cmo \
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: create.ml,v 1.6 2004/09/20 10:56:47 rich Exp $
+ * $Id: create.ml,v 1.7 2004/09/21 13:01:15 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
open Cocanwiki_emailnotify
open Cocanwiki_ok
-let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user =
(* Get the page title. *)
let title = q#param "title" in
try `String (Connection.remote_ip (Request.connection r))
with Not_found -> `Null in
+ let logged_user =
+ match user with
+ | User (id, _, _) -> `Int id
+ | _ -> `Null in
+
(* Create the page. *)
let sth = dbh#prepare_cached "insert into pages (hostid, url, title,
- description, logged_ip)
- values (?, ?, ?, ?, ?)" in
+ description, logged_ip, logged_user)
+ values (?, ?, ?, ?, ?, ?)" in
sth#execute [`Int hostid; `String url; `String title; `String description;
- logged_ip];
+ logged_ip; logged_user];
let pageid = sth#serial "pages_id_seq" in
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: create_user.ml,v 1.1 2004/09/21 13:01:15 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_ok
+open Cocanwiki_strings
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+ let username = trim (q#param "username") in
+ let password1 = trim (q#param "password1") in
+ let password2 = trim (q#param "password2") in
+
+ if username = "" || password1 = "" || password2 = "" then (
+ error ~back_button:true ~title:"Bad username or password"
+ q "The username or password you gave is empty.";
+ raise CgiExit
+ );
+
+ if password1 <> password2 then (
+ error ~back_button:true ~title:"Passwords don't match"
+ q "The two passwords you gave aren't identical.";
+ raise CgiExit
+ );
+
+ let password = password1 in
+
+ (*
+ Uh oh ... Not making UNICODE assumptions ... XXX
+ if String.length username > 32 || String.length password > 32 then
+ *)
+
+ let email = trim (q#param "email") in
+ let email = if string_is_whitespace email then `Null else `String email in
+
+ (* Not a duplicate? *)
+ let sth = dbh#prepare_cached "select id from users
+ where hostid = ? and name = ?" in
+ sth#execute [`Int hostid; `String username];
+
+ (try
+ sth#fetch1 ();
+ error ~back_button:true ~title:"Username already taken"
+ q "Someone has already taken that username.";
+ raise CgiExit
+ with
+ Not_found -> ());
+
+ let can_edit = q#param_true "can_edit" in
+ let can_manage_users = q#param_true "can_manage_users" in
+ let can_manage_contacts = q#param_true "can_manage_contacts" in
+
+ (* Create the user account. *)
+ let sth = dbh#prepare_cached "insert into users (name, password, email,
+ hostid, can_edit, can_manage_users,
+ can_manage_contacts)
+ values (?, ?, ?, ?, ?, ?, ?)" in
+ sth#execute [`String username; `String password; email; `Int hostid;
+ `Bool can_edit; `Bool can_manage_users;
+ `Bool can_manage_contacts];
+
+ dbh#commit ();
+
+ let buttons = [ ok_button "/_users" ] in
+
+ ok ~title:"Account created" ~buttons
+ q ("An account was created for " ^ username ^ ".")
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: create_user_form.ml,v 1.1 2004/09/21 13:01:15 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+ let template = get_template dbh hostid "create_user_form.html" in
+
+ q#template template
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: delete_user.ml,v 1.1 2004/09/21 13:01:15 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_ok
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} self =
+ if q#param_true "cancel" then (
+ (* Request cancelled. *)
+ q#redirect ("http://" ^ hostname ^ "/_users");
+ raise CgiExit
+ );
+
+ let userid = int_of_string (q#param "userid") in
+
+ (* Check userid belongs to host. The statements below wouldn't
+ * enforce this correctly ...
+ *)
+ let sth =
+ dbh#prepare_cached "select 1 from users where id = ? and hostid = ?" in
+ sth#execute [`Int userid; `Int hostid];
+
+ assert (sth#fetch1int () = 1);
+
+ (* Can't delete self! *)
+ let () =
+ match self with
+ | User (id, _, _) when id = userid ->
+ error ~back_button:true ~title:"Delete own account"
+ q "You cannot delete your own user account.";
+ raise CgiExit
+ | _ -> () in
+
+ (* Delete the user. *)
+ let sth = dbh#prepare_cached "delete from usercookies where userid = ?" in
+ sth#execute [`Int userid];
+
+ let sth = dbh#prepare_cached "update pages set logged_user = null
+ where logged_user = ? and hostid = ?" in
+ sth#execute [`Int userid; `Int hostid];
+
+ let sth =
+ dbh#prepare_cached "delete from users where id = ? and hostid = ?" in
+ sth#execute [`Int userid; `Int hostid];
+
+ dbh#commit ();
+
+ ok ~title:"Account deleted" ~buttons:[ok_button "/_users"]
+ q "That user account was deleted."
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: delete_user_form.ml,v 1.1 2004/09/21 13:01:15 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+open Cocanwiki_ok
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ self =
+ let template = get_template dbh hostid "delete_user_form.html" in
+
+ let userid = int_of_string (q#param "userid") in
+ template#set "userid" (string_of_int userid);
+
+ (* Can't delete self! *)
+ let () =
+ match self with
+ | User (id, _, _) when id = userid ->
+ error ~back_button:true ~title:"Delete own account"
+ q "You cannot delete your own user account.";
+ raise CgiExit
+ | _ -> () in
+
+ (* Get this user from the database. *)
+ let sth = dbh#prepare_cached "select name, email from users
+ where id = ? and hostid = ?" in
+ sth#execute [`Int userid; `Int hostid];
+
+ let username, email =
+ match sth#fetch1 () with
+ [ `String username; `String email ] ->
+ username, email
+ | [ `String username; `Null ] ->
+ username, ""
+ | _ -> assert false in
+
+ template#set "username" username;
+ template#set "email" email;
+
+ q#template template
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit.ml,v 1.9 2004/09/20 10:56:47 rich Exp $
+ * $Id: edit.ml,v 1.10 2004/09/21 13:01:15 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* for each section. *)
}
-let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user =
let template = get_template dbh hostid "edit.html" in
let template_conflict = get_template dbh hostid "edit_conflict.html" in
try `String (Connection.remote_ip (Request.connection r))
with Not_found -> `Null in
+ let logged_user =
+ match user with
+ | User (id, _, _) -> `Int id
+ | _ -> `Null in
+
(* Get redirect. *)
let redirect = if model.redirect = "" then `Null
else `String model.redirect in
(* Create the new page. *)
let sth = dbh#prepare_cached "insert into pages (hostid, url, title,
description, creation_date, logged_ip,
- redirect, css)
- values (?, ?, ?, ?, ?, ?, ?, ?)" in
+ logged_user, redirect, css)
+ values (?, ?, ?, ?, ?, ?, ?, ?, ?)" in
sth#execute [`Int hostid; `String url; `String title;
`String model.description; creation_date; logged_ip;
- redirect; css];
+ logged_user; redirect; css];
(* New page ID <> old page ID model.id. *)
let pageid = sth#serial "pages_id_seq" in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: edit_page_css.ml,v 1.7 2004/09/09 12:21:22 rich Exp $
+ * $Id: edit_page_css.ml,v 1.8 2004/09/21 13:01:15 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
open Cocanwiki_emailnotify
open Cocanwiki_strings
-let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user =
let page = q#param "page" in
let css = q#param "css" in
try `String (Connection.remote_ip (Request.connection r))
with Not_found -> `Null in
+ let logged_user =
+ match user with
+ | User (id, _, _) -> `Int id
+ | _ -> `Null in
+
(* Changing the CSS creates a new version of the page. This enables
* us to revert changes to the CSS easily.
*)
let sth = dbh#prepare_cached "insert into pages (hostid, url, title,
description, creation_date, logged_ip,
- redirect, css)
- values (?, ?, ?, ?, ?, ?, ?, ?)" in
+ logged_user, redirect, css)
+ values (?, ?, ?, ?, ?, ?, ?, ?, ?)" in
sth#execute [`Int hostid; `String page; title; description;
- creation_date; logged_ip; redirect; css ];
+ creation_date; logged_ip; logged_user; redirect; css ];
let pageid = sth#serial "pages_id_seq" in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: history.ml,v 1.7 2004/09/09 12:21:22 rich Exp $
+ * $Id: history.ml,v 1.8 2004/09/21 13:01:16 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
let sth =
dbh#prepare_cached
- "select id, url, url_deleted, title, last_modified_date, logged_ip
- from pages
- where hostid = ? and (url = ? or url_deleted = ?)
- order by last_modified_date desc" in
+ "select p.id, p.url, p.url_deleted, p.title, p.last_modified_date,
+ p.logged_ip, u.name
+ from pages p left outer join users u on p.logged_user = u.id
+ where p.hostid = ? and (p.url = ? or p.url_deleted = ?)
+ order by p.last_modified_date desc" in
sth#execute [`Int hostid; `String page; `String page];
let table =
sth#map
(function
| [`Int version; `String url; _; `String title;
- `Timestamp last_modified_date; logged_ip ] ->
+ `Timestamp last_modified_date; logged_ip; logged_user ] ->
let date = printable_date_time last_modified_date in
let has_logged_ip, logged_ip =
match logged_ip with
`Null -> false, ""
| `String ip -> true, ip
| _ -> assert false in
+ let has_logged_user, logged_user =
+ match logged_user with
+ `Null -> false, ""
+ | `String name -> true, name
+ | _ -> assert false in
[ "version", Template.VarString (string_of_int version);
"url", Template.VarString url;
"title", Template.VarString title;
"last_modified_date", Template.VarString date;
"has_logged_ip", Template.VarConditional has_logged_ip;
"logged_ip", Template.VarString logged_ip;
+ "has_logged_user", Template.VarConditional has_logged_user;
+ "logged_user", Template.VarString logged_user;
"is_live", Template.VarConditional true ]
| [`Int version; `Null; `String url; `String title;
- `Timestamp last_modified_date; logged_ip ] ->
+ `Timestamp last_modified_date; logged_ip; logged_user ] ->
let date = printable_date_time last_modified_date in
let has_logged_ip, logged_ip =
match logged_ip with
`Null -> false, ""
| `String ip -> true, ip
| _ -> assert false in
+ let has_logged_user, logged_user =
+ match logged_user with
+ `Null -> false, ""
+ | `String name -> true, name
+ | _ -> assert false in
[ "version", Template.VarString (string_of_int version);
"url", Template.VarString url;
"title", Template.VarString title;
"last_modified_date", Template.VarString date;
"has_logged_ip", Template.VarConditional has_logged_ip;
"logged_ip", Template.VarString logged_ip;
+ "has_logged_user", Template.VarConditional has_logged_user;
+ "logged_user", Template.VarString logged_user;
"is_live", Template.VarConditional false ]
| _ -> assert false) in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: recent.ml,v 1.7 2004/09/09 12:21:22 rich Exp $
+ * $Id: recent.ml,v 1.8 2004/09/21 13:01:16 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
let sth =
dbh#prepare_cached
- "select id, url, url_deleted, title, last_modified_date, logged_ip
- from pages
- where hostid = ?
- and last_modified_date >= current_timestamp - interval ?
- order by last_modified_date desc" in
+ "select p.id, p.url, p.url_deleted, p.title, p.last_modified_date,
+ p.logged_ip, u.name
+ from pages p left outer join users u on p.logged_user = u.id
+ where p.hostid = ?
+ and p.last_modified_date >= current_timestamp - interval ?
+ order by p.last_modified_date desc" in
sth#execute [`Int hostid; `String max_age];
let table =
sth#map
(function
| [`Int version; `String url; _; `String title;
- `Timestamp last_modified_date; logged_ip] ->
+ `Timestamp last_modified_date; logged_ip; logged_user] ->
let date = printable_date_time last_modified_date in
let has_logged_ip, logged_ip =
match logged_ip with
`Null -> false, ""
| `String ip -> true, ip
| _ -> assert false in
+ let has_logged_user, logged_user =
+ match logged_user with
+ `Null -> false, ""
+ | `String name -> true, name
+ | _ -> assert false in
[ "version", Template.VarString (string_of_int version);
"url", Template.VarString url;
"title", Template.VarString title;
"last_modified_date", Template.VarString date;
"has_logged_ip", Template.VarConditional has_logged_ip;
"logged_ip", Template.VarString logged_ip;
+ "has_logged_user", Template.VarConditional has_logged_user;
+ "logged_user", Template.VarString logged_user;
"is_live", Template.VarConditional true ]
| [`Int version; `Null; `String url; `String title;
- `Timestamp last_modified_date; logged_ip] ->
+ `Timestamp last_modified_date; logged_ip; logged_user] ->
let date = printable_date_time last_modified_date in
let has_logged_ip, logged_ip =
match logged_ip with
`Null -> false, ""
| `String ip -> true, ip
| _ -> assert false in
+ let has_logged_user, logged_user =
+ match logged_user with
+ `Null -> false, ""
+ | `String name -> true, name
+ | _ -> assert false in
[ "version", Template.VarString (string_of_int version);
"url", Template.VarString url;
"title", Template.VarString title;
"last_modified_date", Template.VarString date;
"has_logged_ip", Template.VarConditional has_logged_ip;
"logged_ip", Template.VarString logged_ip;
+ "has_logged_user", Template.VarConditional has_logged_user;
+ "logged_user", Template.VarString logged_user;
"is_live", Template.VarConditional false ]
| _ -> assert false) in
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: restore.ml,v 1.7 2004/09/09 12:21:22 rich Exp $
+ * $Id: restore.ml,v 1.8 2004/09/21 13:01:16 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
open Cocanwiki_diff
open Cocanwiki_emailnotify
-let run r (q : cgi) (dbh : Dbi.connection) hostid { hostname = hostname } _ =
+let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} user =
let version = int_of_string (q#param "version") in
let page = q#param "page" in
try `String (Connection.remote_ip (Request.connection r))
with Not_found -> `Null in
+ let logged_user =
+ match user with
+ | User (id, _, _) -> `Int id
+ | _ -> `Null in
+
(* Copy the old version of the page to be live. *)
let sth = dbh#prepare_cached "select title, description, creation_date,
redirect, css
let sth = dbh#prepare_cached "insert into pages (hostid, url, title,
description, creation_date, logged_ip,
- redirect, css)
- values (?, ?, ?, ?, ?, ?, ?, ?)" in
+ logged_user, redirect, css)
+ values (?, ?, ?, ?, ?, ?, ?, ?, ?)" in
sth#execute [`Int hostid; `String page; title; description;
- creation_date; logged_ip; redirect; css ];
+ creation_date; logged_ip; logged_user; redirect; css ];
let pageid = sth#serial "pages_id_seq" in
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: set_password.ml,v 1.1 2004/09/21 13:01:16 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_ok
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+ let userid = int_of_string (q#param "userid") in
+ let password1 = q#param "password1" in
+ let password2 = q#param "password2" in
+
+ if password1 <> password2 then (
+ error ~back_button:true ~title:"Passwords don't match"
+ q "The two passwords you gave aren't identical.";
+ raise CgiExit
+ );
+
+ let password = password1 in
+
+ let sth = dbh#prepare_cached "update users set password = ?
+ where id = ? and hostid = ?" in
+ sth#execute [`String password; `Int userid; `Int hostid];
+
+ dbh#commit ();
+
+ ok ~title:"Password updated" ~buttons:[ok_button "/_users"]
+ q "The password on that user account was updated."
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
--- /dev/null
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * Copyright (C) 2004 Merjis Ltd.
+ * $Id: set_password_form.ml,v 1.1 2004/09/21 13:01:16 rich Exp $
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *)
+
+open Apache
+open Registry
+open Cgi
+open Printf
+
+open Cocanwiki
+open Cocanwiki_template
+
+let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
+ let template = get_template dbh hostid "set_password_form.html" in
+
+ let userid = int_of_string (q#param "userid") in
+
+ let sth = dbh#prepare_cached "select name from users
+ where id = ? and hostid = ?" in
+ sth#execute [`Int userid; `Int hostid];
+
+ let username = sth#fetch1string () in
+
+ template#set "userid" (string_of_int userid);
+ template#set "username" username;
+
+ q#template template
+
+let () =
+ register_script ~restrict:[CanManageUsers] run
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Create a user account</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+<link rel="stylesheet" href="/_css/users.css" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Create a user account</h1>
+
+<form method="post" action="/_bin/create_user.cmo">
+<table id="edit_user">
+<tr>
+<th> Username: </th>
+
+<td> <input name="username" value="" size="32" maxlength="32"/> </td>
+</tr>
+
+<tr>
+<th> Password: </th>
+<td> <input type="password" name="password1" value="" size="32"/> </td>
+</tr>
+
+<tr>
+<th> Password again: </th>
+<td> <input type="password" name="password2" value="" size="32"/> </td>
+</tr>
+
+<tr>
+<th> Email: </th>
+<td> <input name="email" value="" size="40"/> </td>
+</tr>
+<tr>
+<th> Permissions: </th>
+<td>
+
+<input id="can_edit" type="checkbox" name="can_edit" value="1" checked="checked"/><label for="can_edit">Edit</label>
+<br/>
+<input id="can_manage_users" type="checkbox" name="can_manage_users" value="1"/><label for="can_manage_users">Manage users</label>
+<br/>
+<input id="can_manage_contacts" type="checkbox" name="can_manage_contacts" value="1"/><label for="can_manage_contacts">Manage contacts</label>
+</td>
+</tr>
+<tr>
+<td></td>
+<td> <input type="submit" value=" Create user " /> </td>
+</tr>
+
+</table>
+</form>
+
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<div id="menu_div">
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+</div>
+
+<div id="footer_div">
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright © ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+</div>
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Delete user: ::username_html::</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+<link rel="stylesheet" href="/_css/users.css" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Delete user: ::username_html::</h1>
+
+<p>
+Are you sure you want to delete this user?
+</p>
+
+<table id="edit_user">
+<tr>
+<th> Username: </th>
+<td> ::username_html:: </td>
+</tr>
+<tr>
+<th> Email: </th>
+<td> ::email_html:: </td>
+</tr>
+</table>
+
+<form method="post" action="/_bin/delete_user.cmo">
+<input type="hidden" name="userid" value="::userid::"/>
+<input type="submit" name="delete" value=" Delete this user "/>
+<input type="submit" name="cancel" value=" Cancel "/>
+</form>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<div id="menu_div">
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+</div>
+
+<div id="footer_div">
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright © ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+</div>
+
+</body>
+</html>
\ No newline at end of file
<span class="date">::last_modified_date_html::</span>
(<a href="/::url_html_tag::/diff?version=::version::">diff</a>)
::if(is_live)::<a href="/::url_html_tag::">::title_html::</a> (live)::else::<a href="/::url_html_tag::?version=::version::">::title_html::</a>::end::
+::if(has_logged_user)::(by ::logged_user_html::)::else::
::if(has_logged_ip)::(from ::logged_ip_html::)::end::
+::end::
</li>
::end::
</ul>
(<a href="/::url_html_tag::/diff?version=::version::">diff</a>)
(<a href="/::url_html_tag::/history">history</a>)
::if(is_live)::<a href="/::url_html_tag::">::title_html::</a> (live)::else::<a href="/::url_html_tag::?version=::version::">::title_html::</a>::end::
+::if(has_logged_user)::(by ::logged_user_html::)::else::
::if(has_logged_ip)::(from ::logged_ip_html::)::end::
+::end::
</li>
::end::
</ul>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<title>Set password for this user</title>
+<meta name="robots" content="noindex,nofollow"/>
+<meta name="author" content="http://www.merjis.com/" />
+<link rel="stylesheet" href="::theme_css_html_tag::" type="text/css" title="Standard"/>
+<link rel="stylesheet" href="/_css/users.css" type="text/css" title="Standard"/>
+</head><body>
+
+<h1>Set password for this user</h1>
+
+<form method="post" action="/_bin/set_password.cmo">
+<input type="hidden" name="userid" value="::userid::"/>
+<table id="edit_user">
+<tr>
+<th> Username: </th>
+
+<td> ::username_html:: </td>
+</tr>
+
+<tr>
+<th> Password: </th>
+<td> <input type="password" name="password1" value="" size="32"/> </td>
+</tr>
+
+<tr>
+<th> Password again: </th>
+<td> <input type="password" name="password2" value="" size="32"/> </td>
+</tr>
+
+<tr>
+<td></td>
+<td> <input type="submit" value=" Set password " /> </td>
+</tr>
+
+</table>
+</form>
+
+<ul id="topmenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+<li> <a href="/_sitemap">Sitemap</a> </li>
+<li> <a href="/_recent">Recent changes</a> </li>
+</ul>
+
+<div id="menu_div">
+<ul id="bottommenu" class="menu">
+<li class="first"> <a href="/">Home page</a> </li>
+::table(sitemenu)::<li> <a href="/::url_html_tag::">::label_html::</a> </li>
+::end::
+<li> <a href="/_sitemap">Sitemap</a> </li>
+</ul>
+</div>
+
+<div id="footer_div">
+<hr/>
+
+<ul id="footer" class="menu">
+<li class="first"> <a href="/copyright">Copyright © ::year::</a> </li>
+<li> Powered by <a href="http://sandbox.merjis.com/">::cocanwiki_package_html:: ::cocanwiki_version_html::</a> </li>
+</ul>
+</div>
+
+</body>
+</html>
\ No newline at end of file