--- a
+++ b/fixPasswords/MySQLConnectionFactory.class.php
@@ -0,0 +1,60 @@
+<?php
+## Copyright 2006 Kyle Hall
+
+## This file is part of koha-tools.
+
+## koha-tools 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.
+
+## koha-tools 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 koha-tools; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+class MySQLConnectionFactory {
+  public static function create() {   
+    $db_data = parse_ini_file('/etc/koha-tools/koha-tools.ini');
+    $host = $db_data['host']; 
+    $username = $db_data['username'];
+    $password = $db_data['password'];
+    $database = $db_data['database'];
+    
+    $link = mysql_connect($localhost, $username, $password);
+
+    if (!$link) {
+      throw new Exception('Unable to connect to any database servers - last error: ' . mysql_error());
+    }
+    
+    $db_selected = mysql_select_db($database, $link);
+    if (!$db_selected) {
+       throw new Exception('Can\'t use ' . $database . ' : ' . mysql_error());
+    }
+    
+    return $link;
+  }
+
+  public static function createi() {   
+    $db_data = parse_ini_file('/etc/koha-tools/koha-tools.ini');
+    $host = $db_data['host']; 
+    $username = $db_data['username'];
+    $password = $db_data['password'];
+    $database = $db_data['database'];
+    
+    $dbc = new mysqli($localhost, $username, $password, $database);
+
+    /* check connection */
+    if ( mysqli_connect_errno() ) {
+      throw new Exception("Connect failed: %s\n", mysqli_connect_error());
+    }
+    
+    return $dbc;
+  }
+
+}
+ ?>