4 * This script will import all users of the nel db and add a matching ticket_user an ams_user entry for them.
5 * @author Daan Janssens, mentored by Matthew Lagoe
8 //require the pages that are being needed.
9 require( '../../config.php' );
10 require( '../../../ams_lib/libinclude.php' );
11 ini_set( "display_errors", true );
12 error_reporting( E_ALL
);
14 //var used to access the DB;
20 $dbs = new DBLayer("shard");
21 $sql = "SELECT * FROM user";
22 $statement = $dbs->executeWithoutParams($sql);
23 $users = $statement->fetchAll();
24 foreach($users as $user){
26 $dbw = new DBLayer("web");
27 if (! $dbw->execute("SELECT * FROM ams_user WHERE Login = :name",array('name' => $user['Login']))->rowCount()){
28 $query = "INSERT INTO ams_user (Login, Password, Email, Language) VALUES (:name, :pass, :mail, :lang)";
29 global $DEFAULT_LANGUAGE;
30 $vars = array('name' => $user['Login'], 'pass' => $user['Password'], 'mail' => $user['Email'], 'lang' => $DEFAULT_LANGUAGE);
31 $id = $dbw->executeReturnId($query,$vars);
32 $dbl = new DBLayer("lib");
33 $query = "INSERT INTO `ticket_user` (Permission, ExternId) VALUES (1, :id)";
34 $vars = array('id' => $id);
35 $dbl->execute($query,$vars);
38 print "The users were imported! ";
39 }catch (PDOException
$e){
40 print "There was an error while creating the admin account! ";