(* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: email_change.ml,v 1.1 2004/10/23 15:00:14 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 _ _ = (* Get the key in the pending_email_changes table. *) let key = q#param "key" in let sth = dbh#prepare_cached "select userid, email from pending_email_changes where key = ?" in sth#execute [`String key]; let userid, email = try (match sth#fetch1 () with [ `Int userid; `String email ] -> userid, email | _ -> assert false) with Not_found -> error ~title:"Already verified" q ("It looks like you have already verified this email address."); return () in (* Update the database. *) let sth = dbh#prepare_cached "delete from pending_email_changes where key = ?" in sth#execute [`String key]; let sth = dbh#prepare_cached "update users set email = ? where id = ?" in sth#execute [`String email; `Int userid]; dbh#commit (); ok ~title:"Email address verified" q "Thank you for verifying your new email address." let () = register_script run