2 //required for normal operation because of recent changes in PHP:
5 //turn off PHP compatibility warnings
6 ini_set("session.bug_compat_warn","off");
9 $dumpfile = "sql/database.sql";
10 $icd9 = "sql/icd9.sql";
11 $conffile = "library/sqlconf.php";
13 $defhost = 'localhost';
14 $state = $_POST["state"];
16 include_once($conffile);
20 <TITLE
>OpenEMR Setup Tool
</TITLE
>
21 <LINK REL
=STYLESHEET HREF
="interface/themes/style_blue.css">
25 <span
class="title">OpenEMR Setup
</span
>
30 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
31 echo "It appears that you have register_globals enabled in your php.ini\n" .
32 "configuration file. This causes unacceptable security risks. You must\n" .
33 "turn it off before continuing with installation.\n";
42 <p
>Congratulations
! OpenEMR is now successfully installed
.
45 <li
>Please Edit the
'interface/globals.php' file now to specify the correct
46 URL paths
, and to select a theme
.</li
>
47 <li
>Please make sure that the two folders underneath
48 'openemrwebroot/interface/main/calendar/modules/PostCalendar/pntemplates/'
49 exist
and are writable by the web server
. The two subdirectories are
50 'compiled' and 'cache'.<br
>
51 Try "chown apache:apache -R openemrwebroot/interface/main/calendar/modules/PostCalendar/pntemplates/compiled"
53 "chown apache:apache -R openemrwebroot/interface/main/calendar/modules/PostCalendar/pntemplates/cache".
54 (If either subdirectory doesn
't exist, create it first then do the chown above).<br>
55 The user name and group of apache may differ depending on your OS, i.e.
56 for Debian they are www-data and www-data.</li>
59 In order to take full advantage of the documents capability you
60 must give your web server permissions on the document storage
61 directory. Try "chown apache:apache -R openemrwebroot/documents"
62 and then "chmod g+w openemrwebroot/documents".
63 You must also make sure your PHP installation (normally set in
64 your php.ini file) has "file_uploads enabled", that
65 "upload_max_filesize" is appropriate for your use and that
66 "upload_tmp_dir" is set to a correct value if the default of
67 "/tmp" won't work on your system
.
70 There
's much information and many extra tools bundled within the OpenEMR
71 installation directory. Please refer to openemr/Documentation.
72 <br>Many forms and other useful scripts can be found at openemr/contrib.
73 <br>OpenEMR now comes with optional GACL support, a fine grained access control
74 system. Please refer to openemr/Documentation/README.phpgacl for -easy-
78 Reading openemr/includes/config.php and openemr/interface/globals.php is a good
82 To ensure a consistent look and feel through out the application
83 using <a href='http
://www.mozilla.org/products/firefox/'>Firefox</a>
87 <b
>The initial OpenEMR user is
"admin" and the password is
"pass".</b
>
88 You should change this password
!
91 <a href
='./'>Click here to start using OpenEMR
. </a
>
101 $server = $_POST["server"];
102 $port = $_POST["port"];
103 $dbname = $_POST["dbname"];
104 $root = $_POST["root"];
105 $login = $_POST["login"];
106 $pass = $_POST["pass"];
107 $loginhost = $_POST["loginhost"];
108 $rootpass = $_POST["rootpass"];
112 echo "OpenEMR is already configured. If you wish to re-configure the SQL server, edit $conffile, or change the 'config' variable to 0, and re-run this script.<br>\n";
118 echo "<b>Step $state</b><br><br>\n";
119 echo "Now I need to know whether you want me to create the databases on my own or if you have already created the database for me to use. If you are upgrading, you will want to select the latter function. For me to create the databases, you will need to supply the MySQL root password.\n
120 <span class='title'> <br />NOTE: clicking on \"Continue\" may delete or cause damage to data on your system. Before you continue please backup your data.</span>
122 <FORM METHOD='POST'>\n
123 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
124 <INPUT TYPE='RADIO' NAME='inst' VALUE='1' checked>Have setup create the databases<br>\n
125 <INPUT TYPE='RADIO' NAME='inst' VALUE='2'>I have already created the databases<br>\n
127 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
131 echo "<b>Step $state</b><br><br>\n";
132 echo "Now you need to supply the MySQL server information.
135 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
136 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
138 <TR><TD><font color='red'>SERVER:</font></TD></TR>
139 <TR><TD><span class='text'>Server Host: </span></TD><TD><INPUT TYPE='TEXT' VALUE='$defhost' NAME='server' SIZE='30'><span class='text'>(This is the IP address of the machine running MySQL)</span><br></TD></TR>
140 <TR><TD><span class='text'>Server Port: </span></TD><TD><INPUT TYPE='TEXT' VALUE='3306' NAME='port' SIZE='30'><span class='text'>(The default port for MySQL is 3306)</span><br></TD></TR>
141 <TR><TD><span class='text'>Database Name: </span></TD><TD><INPUT TYPE='TEXT' VALUE='openemr' NAME='dbname' SIZE='30'><span class='text'>(This is the name of the OpenEMR database - 'openemr' is the recommended)</span><br></TD></TR>
142 <TR><TD><span class='text'>Login Name: </span></TD><TD><INPUT TYPE='TEXT' VALUE='openemr' NAME='login' SIZE='30'><span class='text'>(This is the name of the OpenEMR login name - 'openemr' is the recommended)</span><br></TD></TR>
143 <TR><TD><span class='text'>Password: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='pass' SIZE='30'><span class='text'>(This is the Login Password for when PHP accesses MySQL - it should be at least 8 characters long and composed of both numbers and letters)</span><br></TD></TR>\n";
145 echo "<TR><TD><font color='red'>CLIENT:</font></TD></TR>";
146 echo "<TR><TD><span class='text'>User Hostname: </span></TD><TD><INPUT TYPE='TEXT' VALUE='$defhost' NAME='loginhost' SIZE='30'><span class='text'>(This is the IP address of the server machine running Apache and PHP - if you are setting up one computer, this is the same as the Server Host above)</span><br></TD></TR>
147 <TR><TD><span class='text'>Name for Root Account: </span></TD><TD><INPUT TYPE='TEXT' VALUE='root' NAME='root' SIZE='30'><span class='text'>(This is name for MySQL root account. For localhost, it is usually ok to leave it 'root'.)</span><br></TD></TR>
148 <TR><TD><span class='text'>Root Pass: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='rootpass' SIZE='30'><span class='text'>(This is your MySQL root password. For localhost, it is usually ok to leave it blank.)</span><br></TD></TR>\n";
150 echo "<TR><TD><font color='red'>USER:</font></TD></TR>";
151 echo "<TR><TD COLSPAN=2></TD></TR>
152 <TR><TD><span class='text'>Initial User:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuser' VALUE='admin'><span class='text'>(This is the user that will be created for you. It will be an authorized user, so it should be for a Doctor or other Practitioner)</span></TD></TR>
153 <TR><TD><span class='text'>Initial User's Name:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuname' VALUE='Administrator'><span class='text'>(This is the real name of the initial user.)</span></TD></TR>
154 <TR><TD><span class='text'>Initial Group:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='igroup' VALUE='Default'><span class='text'>(This is the group that will be created for your users. This should be the name of your practice.)</span></TD></TR>
158 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
166 echo "<b>Step $state</b><br><br>\n";
167 if ($pass == "" ||
$login == "" ||
!isset($login) ||
!isset($pass)) {
168 echo "ERROR. Please pick a proper username and/or password.<br>\n";
173 echo "Connecting to MySQL Server...\n";
175 if ($server == "localhost")
176 $dbh = mysql_connect("$server","$root","$rootpass");
178 $dbh = mysql_connect("$server:$port","$root","$rootpass");
180 echo "ERROR. Check your login credentials.\n";
181 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
186 echo "Creating database...\n";
188 if (mysql_query("create database $dbname",$dbh) == FALSE) {
189 echo "ERROR. Check your login credentials.\n";
190 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
195 echo "Creating user with permissions for database...\n";
197 if (mysql_query("GRANT ALL PRIVILEGES ON $dbname.* TO '$login'@'$loginhost' IDENTIFIED BY '$pass'",$dbh) == FALSE) {
198 echo "ERROR when granting privileges to the specified user.\n";
199 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
205 echo "Reconnecting as new user...\n";
209 echo "Connecting to MySQL Server...\n";
211 if ($server == "localhost")
212 $dbh = mysql_connect("$server","$login","$pass");
214 $dbh = mysql_connect("$server:$port","$login","$pass");
217 echo "ERROR. Check your login credentials.\n";
218 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
223 echo "Opening database...";
225 if (mysql_select_db("$dbname",$dbh) == FALSE) {
226 echo "ERROR. Check your login credentials.\n";
227 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
234 echo "Creating initial tables...\n";
235 mysql_query("USE $dbname",$dbh);
237 $fd = fopen($dumpfile, 'r');
239 echo "ERROR. Could not open dumpfile '$dumpfile'.\n";
246 $line = fgets($fd,1024);
247 $line = rtrim($line);
248 if (substr($line,0,2) == "--") // Kill comments
250 if (substr($line,0,1) == "#") // Kill comments
254 $query = $query.$line; // Check for full query
255 $chr = substr($query,strlen($query)-1,1);
256 if ($chr == ";") { // valid query, execute
257 $query = rtrim($query,";");
258 mysql_query("$query",$dbh);
265 echo "Adding Initial User...\n";
267 $iuser = $_POST["iuser"];
268 $iuname = $_POST["iuname"];
269 $igroup = $_POST["igroup"];
270 //echo "INSERT INTO groups VALUES (1,'$igroup','$iuser')<br>\n";
271 if (mysql_query("INSERT INTO groups (id, name, user) VALUES (1,'$igroup','$iuser')") == FALSE) {
272 echo "ERROR. Could not run queries.\n";
273 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
277 if (mysql_query("INSERT INTO users (id, username, password, authorized, lname,fname) VALUES (1,'$iuser','1a1dc91c907325c69271ddf0c944bc72',1,'$iuname','')") == FALSE) {
278 echo "ERROR. Could not run queries.\n";
279 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
285 /* echo "Inserting ICD-9-CM Codes into Database...\n";
287 $fd = fopen($icd9, 'r');
289 echo "ERROR. Could not open dumpfile.\n";
290 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
297 $line = fgets($fd,1024);
298 $line = rtrim($line);
299 if (substr($line,0,2) == "--") // Kill comments
301 if (substr($line,0,1) == "#") // Kill comments
305 $query = $query.$line; // Check for full query
306 $chr = substr($query,strlen($query)-1,1);
307 if ($chr == ";") { // valid query, execute
308 $query = rtrim($query,";");
309 mysql_query("$query",$dbh);
317 echo "\n<br>Please make sure 'library/sqlconf.php' is world-writeable for the next step.<br>\n";
321 <FORM METHOD='POST'>\n
322 <INPUT TYPE='HIDDEN' NAME='state' VALUE='4'>
323 <INPUT TYPE='HIDDEN' NAME='host' VALUE='$server'>
324 <INPUT TYPE='HIDDEN' NAME='dbname' VALUE='$dbname'>
325 <INPUT TYPE='HIDDEN' NAME='port' VALUE='$port'>
326 <INPUT TYPE='HIDDEN' NAME='login' VALUE='$login'>
327 <INPUT TYPE='HIDDEN' NAME='pass' VALUE='$pass'>
329 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
335 echo "<b>Step $state</b><br><br>\n";
336 echo "Writing SQL Configuration to disk...\n";
337 @touch
($conffile); // php bug
338 $fd = @fopen
($conffile, 'w');
340 echo "ERROR. Could not open config file '$conffile' for writing.\n";
347 // Referenced from sql.inc
351 $it_died = 0; //fmg: variable keeps running track of any errors
353 fwrite($fd,$string) or $it_died++
;
354 fwrite($fd,"\$host\t= '$host';\n") or $it_died++
;
355 fwrite($fd,"\$port\t= '$port';\n") or $it_died++
;
356 fwrite($fd,"\$login\t= '$login';\n") or $it_died++
;
357 fwrite($fd,"\$pass\t= '$pass';\n") or $it_died++
;
358 fwrite($fd,"\$dbase\t= '$dbname';\n") or $it_died++
;
364 $sqlconf["host"]= $host;
365 $sqlconf["port"] = $port;
366 $sqlconf["login"] = $login;
367 $sqlconf["pass"] = $pass;
368 $sqlconf["dbase"] = $dbase;
369 //////////////////////////
370 //////////////////////////
371 //////////////////////////
372 //////DO NOT TOUCH THIS///
373 $config = 1; /////////////
374 //////////////////////////
375 //////////////////////////
376 //////////////////////////
379 ?
><?
// done just for coloring
381 fwrite($fd,$string) or $it_died++
;
383 //it's rather irresponsible to not report errors when writing this file.
385 echo "ERROR. Couldn't write $it_died lines to config file '$conffile'.\n";
391 echo "OK<BR>\nPlease restore secure permissions on the 'library/sqlconf.php' file now.\n<br><FORM METHOD='POST'>\n
392 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
394 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
400 echo "Welcome to OpenEMR. This utility will step you through the configuration of OpenEMR for your practice. Before proceeding, be sure that you have a properly installed and configured MySQL server available, and a PHP configured webserver.<br><br>\n";
402 Echo "<p>If you are upgrading from a previous version, please read the README file.<br><br>";
404 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'><INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";