From 262024a3c7f6c411ab4d204e13df96c3a3242d51 Mon Sep 17 00:00:00 2001 From: markleeds Date: Sat, 28 Jun 2008 10:22:33 +0000 Subject: [PATCH] A utility for fast setup of OpenEMR which works with XAMPP under Windows XP (No other OS tested). --- contrib/util/express.php | 227 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100755 contrib/util/express.php diff --git a/contrib/util/express.php b/contrib/util/express.php new file mode 100755 index 000000000..f478c4e16 --- /dev/null +++ b/contrib/util/express.php @@ -0,0 +1,227 @@ + + + + + + + +
+

+This script will take the name that you give and create an OpenEMR database with this as the database name, username, password, group name. It will also rename the directory this OpenEMR installation is under to the new name. THIS ONLY WORKS WITH XAMPP AND HAS VERY LIMITED TESTING. +

+

+Make sure that you close Text Editors, Windows Explorer, etc... as these things may stop directory rename that occurs in this script. +

+

+Enter the name you wish to use for this OpenEMR installation. +

+ + +
+".mysql_error()." (#".mysql_errno().")\n"; + break; + } + else + echo "OK.
\n"; + echo "Creating database...\n"; + flush(); + if (mysql_query("create database $dbname",$dbh) == FALSE) { + echo "ERROR. Check your login credentials.\n"; + echo "

".mysql_error()." (#".mysql_errno().")\n"; + break; + } + else + echo "OK.
\n"; + echo "Creating user with permissions for database...\n"; + flush(); + if (mysql_query("GRANT ALL PRIVILEGES ON $dbname.* TO '$login'@'$loginhost' IDENTIFIED BY '$pass'",$dbh) == FALSE) { + echo "ERROR when granting privileges to the specified user.\n"; + echo "

".mysql_error()." (#".mysql_errno().")\n"; + echo "ERROR.\n"; + break; + } + else + echo "OK.
\n"; + echo "Reconnecting as new user...\n"; + mysql_close($dbh); +} +else + echo "Connecting to MySQL Server...\n"; + +if ($server == "localhost") + $dbh = mysql_connect("$server","$login","$pass"); +else + $dbh = mysql_connect("$server:$port","$login","$pass"); + +if ($dbh == FALSE) { + echo "ERROR. Check your login credentials.\n"; + echo "

".mysql_error()." (#".mysql_errno().")\n"; + break; +} +else + echo "OK.
\n"; +echo "Opening database..."; +flush(); +if (mysql_select_db("$dbname",$dbh) == FALSE) { + echo "ERROR. Check your login credentials.\n"; + echo "

".mysql_error()." (#".mysql_errno().")\n"; + break; +} +else + echo "OK.
\n"; + flush(); +if ($upgrade != 1) { + echo "Creating initial tables...\n"; + mysql_query("USE $dbname",$dbh); + flush(); + $fd = fopen($dumpfile, 'r'); + if ($fd == FALSE) { + echo "ERROR. Could not open dumpfile '$dumpfile'.\n"; + flush(); + break; + } + $query = ""; + $line = ""; + while (!feof ($fd)){ + $line = fgets($fd,1024); + $line = rtrim($line); + if (substr($line,0,2) == "--") // Kill comments + continue; + if (substr($line,0,1) == "#") // Kill comments + continue; + if ($line == "") + continue; + $query = $query.$line; // Check for full query + $chr = substr($query,strlen($query)-1,1); + if ($chr == ";") { // valid query, execute + $query = rtrim($query,";"); + mysql_query("$query",$dbh); + $query = ""; + } + } + echo "OK
\n"; + fclose($fd); + flush(); + echo "Adding Initial User...\n"; + flush(); + $iuser = "admin"; + $iuname = "admin"; + $igroup = $newname; + //echo "INSERT INTO groups VALUES (1,'$igroup','$iuser')
\n"; + if (mysql_query("INSERT INTO groups (id, name, user) VALUES (1,'$igroup','$iuser')") == FALSE) { + echo "ERROR. Could not run queries.\n"; + echo "

".mysql_error()." (#".mysql_errno().")\n"; + flush(); + break; + } + if (mysql_query("INSERT INTO users (id, username, password, authorized, lname,fname) VALUES (1,'$iuser','1a1dc91c907325c69271ddf0c944bc72',1,'$iuname','')") == FALSE) { + echo "ERROR. Could not run queries.\n"; + echo "

".mysql_error()." (#".mysql_errno().")\n"; + flush(); + break; + } + echo "OK
\n"; + flush(); + + //Now write sqlconf file +echo "Writing SQL Configuration to disk...\n"; +@touch($conffile); // php bug +$fd = @fopen($conffile, 'w'); +if ($fd == FALSE) { + echo "ERROR. Could not open config file '$conffile' for writing.\n"; + flush(); + break; +} +$string = " +'; +?>click here"; + } +} +?> + + -- 2.11.4.GIT