Scripts updated to use new PG interface.
[cocanwiki.git] / scripts / admin / create_host.ml
index 370b501..0d4f6e6 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * Copyright (C) 2004 Merjis Ltd.
- * $Id: create_host.ml,v 1.11 2006/03/27 18:09:47 rich Exp $
+ * $Id: create_host.ml,v 1.12 2006/03/28 16:24:08 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
@@ -35,7 +35,8 @@ let split_re = Pcre.regexp "[\\s,;]+"
 
 let run r =
   let q = new cgi r in
-  let dbh = Cocanwiki._get_dbh r in
+  let dbh = PGOCaml.connect ~database:"cocanwiki" () in
+  PGOCaml.begin_work dbh;
 
   let canonical_hostname = q#param "canonical_hostname" in
   let hostnames = try q#param "hostnames" with Not_found -> "" in
@@ -45,7 +46,7 @@ let run r =
   let title = trim title in
   if title = "" then (
     Cocanwiki_ok.error ~back_button:true ~title:"Bad title"
-      dbh (-1) q "You must give a title for this Wiki.";
+      dbh (-1l) q "You must give a title for this Wiki.";
   ) else (
     (* In theory we could verify characters in hostnames.  However
      * it's probably best to assume the sysadmin knows what they're up to
@@ -64,8 +65,8 @@ let run r =
     let hostnames = List.filter ((<>) "") hostnames in
 
     let template =
-      if q#param_true "template" then int_of_string (q#param "template")
-      else 0 in
+      if q#param_true "template" then Int32.of_string (q#param "template")
+      else 0l in
 
     let hostid = create_host dbh canonical_hostname hostnames template title
                   "Administrator" "123456" true None in
@@ -78,11 +79,11 @@ let run r =
       { Template.StdPages.label = "OK";
        Template.StdPages.link = "/_bin/admin/host.cmo";
        Template.StdPages.method_ = None;
-       Template.StdPages.params = [ "hostid", string_of_int hostid ] }
+       Template.StdPages.params = [ "hostid", Int32.to_string hostid ] }
     ] in
 
     Cocanwiki_ok.ok ~title:"Wiki created" ~buttons
-      dbh (-1) q "A new Wiki was created."
+      dbh (-1l) q "A new Wiki was created."
   )
 
 let () =