added some php configuration instructions
[openemr.git] / setup.php
blob1ad01cc8f81123e838c4d04286bef75f8c6821e5
1 <?php
2 //required for normal operation because of recent changes in PHP:
3 extract($_GET);
4 extract($_POST);
5 //turn off PHP compatibility warnings
6 ini_set("session.bug_compat_warn","off");
8 $url = "";
9 $upgrade = 0;
10 $defhost = 'localhost';
11 $state = $_POST["state"];
13 //Below section is only for variables that require a path.
14 // The $manualPath variable can be edited by 3rd party
15 // installation scripts to manually set path. (this will
16 // allow straightforward use of this script by 3rd party
17 // installers)
18 $manualPath = "";
19 $dumpfile = $manualPath."sql/database.sql";
20 $icd9 = $manualPath."sql/icd9.sql";
21 $conffile = $manualPath."library/sqlconf.php";
22 $conffile2 = $manualPath."interface/globals.php";
23 $gaclConfigFile1 = $manualPath."gacl/gacl.ini.php";
24 $gaclConfigFile2 = $manualPath."gacl/gacl.class.php";
25 $docsDirectory = $manualPath."documents";
26 $billingDirectory = $manualPath."edi";
27 $gaclWritableDirectory = $manualPath."gacl/admin/templates_c";
28 $requiredDirectory1 = $manualPath."interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
29 $requiredDirectory2 = $manualPath."interface/main/calendar/modules/PostCalendar/pntemplates/cache";
30 $gaclSetupScript1 = $manualPath."gacl/setup.php";
31 $gaclSetupScript2 = $manualPath."acl_setup.php";
33 //These are files and dir checked before install for
34 // existence and correct permissions.
35 $writableFileList = array($conffile, $conffile2, $gaclConfigFile1, $gaclConfigFile2);
36 $writableDirList = array($docsDirectory, $billingDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
39 include_once($conffile);
41 <HTML>
42 <HEAD>
43 <TITLE>OpenEMR Setup Tool</TITLE>
44 <LINK REL=STYLESHEET HREF="interface/themes/style_blue.css">
45 </HEAD>
46 <BODY>
48 <span class="title">OpenEMR Setup</span>
49 <br><br>
50 <span class="text">
52 <?php
53 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
54 echo "It appears that you have register_globals enabled in your php.ini\n" .
55 "configuration file. This causes unacceptable security risks. You must\n" .
56 "turn it off before continuing with installation.\n";
57 exit();
61 <?php
62 if ($state == 5) {
65 <p>Congratulations! OpenEMR is now successfully installed.
67 <ul>
68 <li>Please restore secure permissions on the four configuration files: /openemr/interface/globals.php,
69 /openemr/library/sqlconf.php, /openemr/gacl/gacl.ini.php, and /openemr/gacl/gacl.class.php files.
70 In linux, recommend changing file permissions with the 'chmod 644 filename' command.</li>
71 <li>In order to take full advantage of the patient documents capability you must make sure
72 your PHP installation (normally set in your php.ini file) has
73 "file_uploads enabled", that "upload_max_filesize" is appropriate for your
74 use and that "upload_tmp_dir" is set to a correct value if the default of "/tmp"
75 won't work on your system.</li>
76 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
77 OpenEMR's admin->acl menu.</li>
78 <li>Reading openemr/includes/config.php and openemr/interface/globals.php is a good idea. These files
79 contain many options to choose from including themes.</li>
80 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
81 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
82 <li>To ensure a consistent look and feel through out the application using
83 <a href='http://www.mozilla.org/products/firefox/'>Firefox</a> is recommended.</li>
84 </ul>
85 <p>The "openemrwebroot/documents" and "openemrwebroot/edi" contain patient information, and
86 it is important to secure these directories. This can be done by placing pertinent .htaccess
87 files in these directories or by pasting the below in your apache configuration file:<br>
88 &lt;Directory "<?php echo realpath($docsDirectory);?>"&gt;<br>
89 order deny,allow<br>
90 Deny from all<br>
91 &lt;/Directory&gt;<br>
92 &lt;Directory "<?php echo realpath($billingDirectory);?>"&gt;<br>
93 order deny,allow<br>
94 Deny from all<br>
95 &lt;/Directory&gt;<br>
96 <p>
97 <b>The initial OpenEMR user is "<?php echo $iuser; ?>" and the password is "pass".</b>
98 You should change this password!
99 </p>
101 <a href='./'>Click here to start using OpenEMR. </a>
102 </p>
105 exit();
109 <?php
111 $server = $_POST["server"];
112 $port = $_POST["port"];
113 $dbname = $_POST["dbname"];
114 $root = $_POST["root"];
115 $login = $_POST["login"];
116 $pass = $_POST["pass"];
117 $loginhost = $_POST["loginhost"];
118 $rootpass = $_POST["rootpass"];
119 $iuser = $_POST["iuser"];
120 $iuname = $_POST["iuname"];
121 $igroup = $_POST["igroup"];
122 $openemrBasePath = $_POST["openemrBasePath"];
123 $openemrWebPath = $_POST["openemrWebPath"];
124 //END POST VARIABLES
127 if (($config == 1) && ($state != 4)) {
128 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";
130 else {
131 switch ($state) {
133 case 1:
134 echo "<b>Step $state</b><br><br>\n";
135 echo "Now I need to know whether you want me to create the database on my own or if you have already created the database for me to use. For me to create the database, you will need to supply the MySQL root password.\n
136 <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>
137 <br><br>\n
138 <FORM METHOD='POST'>\n
139 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
140 <INPUT TYPE='RADIO' NAME='inst' VALUE='1' checked>Have setup create the database<br>\n
141 <INPUT TYPE='RADIO' NAME='inst' VALUE='2'>I have already created the database<br>\n
142 <br>\n
143 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
144 break;
146 case 2:
147 echo "<b>Step $state</b><br><br>\n";
148 echo "Now you need to supply the MySQL server information and path information.
149 <br><br>
150 <FORM METHOD='POST'>
151 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
152 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
153 <TABLE>\n
154 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
155 <TR VALIGN='TOP'><TD><span class='text'>Server Host: </span></TD><TD><INPUT TYPE='TEXT' VALUE='$defhost' NAME='server' SIZE='30'></TD><TD><span class='text'>(This is the IP address of the machine running MySQL. If this is on the same machine as the webserver, leave this as 'localhost'.)</span><br></TD></TR>
156 <TR VALIGN='TOP'><TD><span class='text'>Server Port: </span></TD><TD><INPUT TYPE='TEXT' VALUE='3306' NAME='port' SIZE='30'></TD><TD><span class='text'>(The default port for MySQL is 3306.)</span><br></TD></TR>
157 <TR VALIGN='TOP'><TD><span class='text'>Database Name: </span></TD><TD><INPUT TYPE='TEXT' VALUE='openemr' NAME='dbname' SIZE='30'></TD><TD><span class='text'>(This is the name of the OpenEMR database in MySQL - 'openemr' is the recommended)</span><br></TD></TR>
158 <TR VALIGN='TOP'><TD><span class='text'>Login Name: </span></TD><TD><INPUT TYPE='TEXT' VALUE='openemr' NAME='login' SIZE='30'></TD><TD><span class='text'>(This is the name of the OpenEMR login name in MySQL - 'openemr' is the recommended)</span><br></TD></TR>
159 <TR VALIGN='TOP'><TD><span class='text'>Password: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='pass' SIZE='30'></TD><TD><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";
160 if ($inst != 2) {
161 echo "<TR VALIGN='TOP'><TD><span class='text'>Name for Root Account: </span></TD><TD><INPUT TYPE='TEXT' VALUE='root' NAME='root' SIZE='30'></TD><TD><span class='text'>(This is name for MySQL root account. For localhost, it is usually ok to leave it 'root'.)</span><br></TD></TR>
162 <TR VALIGN='TOP'><TD><span class='text'>Root Pass: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='rootpass' SIZE='30'></TD><TD><span class='text'>(This is your MySQL root password. For localhost, it is usually ok to leave it blank.)</span><br></TD></TR>\n";
163 echo "<TR VALIGN='TOP'><TD><span class='text'>User Hostname: </span></TD><TD><INPUT TYPE='TEXT' VALUE='$defhost' NAME='loginhost' SIZE='30'></TD><TD><span class='text'>(If you run Apache/PHP and MySQL on the same computer, then leave this as 'localhost'. If they are on separate computers, then enter the IP address of the computer running Apache/PHP.)</span><br></TD></TR>";
165 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
166 echo "<TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
167 echo "<TR VALIGN='TOP'><TD><span class='text'>Initial User:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuser' VALUE='admin'></TD><TD><span class='text'>(This is the login name of user that will be created for you. Limit this to one word.)</span></TD></TR>
168 <TR VALIGN='TOP'><TD><span class='text'>Initial User's Name:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuname' VALUE='Administrator'></TD><TD><span class='text'>(This is the real name of the 'initial user'.)</span></TD></TR>
169 <TR VALIGN='TOP'><TD><span class='text'>Initial Group:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='igroup' VALUE='Default'></TD><TD><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>
171 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
172 echo "<TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>OPENEMR PATHS:</font></TD></TR>";
173 echo "<TR VALIGN='TOP'><TD COLSPAN=3></TD></TR>
174 <TR VALIGN='TOP'><TD><span class='text'>Absolute Path:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='openemrBasePath' VALUE='".realpath('./')."'></TD><TD><span class='text'>(This is the full absolute directory path to openemr. The value here is automatically created, and should not need to be modified. Do not worry about direction of slashes; they will be automatically corrected.)</span></TD></TR>
175 <TR VALIGN='TOP'><TD><span class='text'>Relative HTML Path:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='openemrWebPath' VALUE='/openemr'></TD><TD><span class='text'>(Set this to the relative html path, ie. what you would type into the web browser after the server address to get to OpenEMR. For example, if you type 'http://127.0.0.1/clinic/openemr/ to load OpenEMR, set this to '/clinic/openemr' without the trailing slash. Do not worry about direction of slashes; they will be automatically corrected.)</span></TD></TR>
177 echo "</TABLE>
178 <br>
179 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
181 break;
184 case 3:
186 if ($login == "" || !isset($login)) {
187 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
188 echo "Click Back in browser to re-enter.<br>\n";
189 break;
191 if (strpbrk($iuser,' ')) {
192 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
193 echo "Click Back in browser to re-enter.<br>\n";
194 break;
196 if ($pass == "" || !isset($pass)) {
197 echo "ERROR. Please pick a proper 'Password'.<br>\n";
198 echo "Click Back in browser to re-enter.<br>\n";
199 break;
202 echo "<b>Step $state</b><br><br>\n";
203 echo "Configuring OpenEMR...<br><br>\n";
206 if ($inst != 2) {
207 echo "Connecting to MySQL Server...\n";
208 flush();
209 if ($server == "localhost")
210 $dbh = mysql_connect("$server","$root","$rootpass");
211 else
212 $dbh = mysql_connect("$server:$port","$root","$rootpass");
213 if ($dbh == FALSE) {
214 echo "ERROR. Check your login credentials.\n";
215 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
216 break;
218 else
219 echo "OK.<br>\n";
220 echo "Creating database...\n";
221 flush();
222 if (mysql_query("create database $dbname",$dbh) == FALSE) {
223 echo "ERROR. Check your login credentials.\n";
224 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
225 break;
227 else
228 echo "OK.<br>\n";
229 echo "Creating user with permissions for database...\n";
230 flush();
231 if (mysql_query("GRANT ALL PRIVILEGES ON $dbname.* TO '$login'@'$loginhost' IDENTIFIED BY '$pass'",$dbh) == FALSE) {
232 echo "ERROR when granting privileges to the specified user.\n";
233 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
234 echo "ERROR.\n";
235 break;
237 else
238 echo "OK.<br>\n";
239 echo "Reconnecting as new user...\n";
240 mysql_close($dbh);
242 else
243 echo "Connecting to MySQL Server...\n";
245 if ($server == "localhost")
246 $dbh = mysql_connect("$server","$login","$pass");
247 else
248 $dbh = mysql_connect("$server:$port","$login","$pass");
250 if ($dbh == FALSE) {
251 echo "ERROR. Check your login credentials.\n";
252 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
253 break;
255 else
256 echo "OK.<br>\n";
257 echo "Opening database...";
258 flush();
259 if (mysql_select_db("$dbname",$dbh) == FALSE) {
260 echo "ERROR. Check your login credentials.\n";
261 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
262 break;
264 else
265 echo "OK.<br>\n";
266 flush();
267 if ($upgrade != 1) {
268 echo "Creating initial tables...\n";
269 mysql_query("USE $dbname",$dbh);
270 flush();
271 $fd = fopen($dumpfile, 'r');
272 if ($fd == FALSE) {
273 echo "ERROR. Could not open dumpfile '$dumpfile'.\n";
274 flush();
275 break;
277 $query = "";
278 $line = "";
279 while (!feof ($fd)){
280 $line = fgets($fd,1024);
281 $line = rtrim($line);
282 if (substr($line,0,2) == "--") // Kill comments
283 continue;
284 if (substr($line,0,1) == "#") // Kill comments
285 continue;
286 if ($line == "")
287 continue;
288 $query = $query.$line; // Check for full query
289 $chr = substr($query,strlen($query)-1,1);
290 if ($chr == ";") { // valid query, execute
291 $query = rtrim($query,";");
292 mysql_query("$query",$dbh);
293 $query = "";
296 echo "OK<br>\n";
297 fclose($fd);
298 flush();
299 echo "Adding Initial User...\n";
300 flush();
301 //echo "INSERT INTO groups VALUES (1,'$igroup','$iuser')<br>\n";
302 if (mysql_query("INSERT INTO groups (id, name, user) VALUES (1,'$igroup','$iuser')") == FALSE) {
303 echo "ERROR. Could not run queries.\n";
304 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
305 flush();
306 break;
308 if (mysql_query("INSERT INTO users (id, username, password, authorized, lname,fname) VALUES (1,'$iuser','1a1dc91c907325c69271ddf0c944bc72',1,'$iuname','')") == FALSE) {
309 echo "ERROR. Could not run queries.\n";
310 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
311 flush();
312 break;
314 echo "OK<br>\n";
315 flush();
316 /* echo "Inserting ICD-9-CM Codes into Database...\n";
317 flush();
318 $fd = fopen($icd9, 'r');
319 if ($fd == FALSE) {
320 echo "ERROR. Could not open dumpfile.\n";
321 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
322 flush();
323 break;
325 $query = "";
326 $line = "";
327 while (!feof ($fd)){
328 $line = fgets($fd,1024);
329 $line = rtrim($line);
330 if (substr($line,0,2) == "--") // Kill comments
331 continue;
332 if (substr($line,0,1) == "#") // Kill comments
333 continue;
334 if ($line == "")
335 continue;
336 $query = $query.$line; // Check for full query
337 $chr = substr($query,strlen($query)-1,1);
338 if ($chr == ";") { // valid query, execute
339 $query = rtrim($query,";");
340 mysql_query("$query",$dbh);
341 $query = "";
344 echo "OK\n";
345 fclose($fd);*/
346 flush();
349 echo "<br>Writing SQL Configuration...<br>";
350 @touch($conffile); // php bug
351 $fd = @fopen($conffile, 'w');
352 $string = "<?
353 // OpenEMR
354 // MySQL Config
355 // Referenced from sql.inc
359 $it_died = 0; //fmg: variable keeps running track of any errors
361 fwrite($fd,$string) or $it_died++;
362 fwrite($fd,"\$host\t= '$server';\n") or $it_died++;
363 fwrite($fd,"\$port\t= '$port';\n") or $it_died++;
364 fwrite($fd,"\$login\t= '$login';\n") or $it_died++;
365 fwrite($fd,"\$pass\t= '$pass';\n") or $it_died++;
366 fwrite($fd,"\$dbase\t= '$dbname';\n") or $it_died++;
369 $string = '
371 $sqlconf = array();
372 $sqlconf["host"]= $host;
373 $sqlconf["port"] = $port;
374 $sqlconf["login"] = $login;
375 $sqlconf["pass"] = $pass;
376 $sqlconf["dbase"] = $dbase;
377 //////////////////////////
378 //////////////////////////
379 //////////////////////////
380 //////DO NOT TOUCH THIS///
381 $config = 1; /////////////
382 //////////////////////////
383 //////////////////////////
384 //////////////////////////
387 ?><? // done just for coloring
389 fwrite($fd,$string) or $it_died++;
391 //it's rather irresponsible to not report errors when writing this file.
392 if ($it_died != 0) {
393 echo "ERROR. Couldn't write $it_died lines to config file '$conffile'.\n";
394 flush();
395 break;
397 fclose($fd);
399 echo "Successfully wrote SQL configuration.<BR><br>";
401 echo "Writing OpenEMR webserver paths to config file...<br>";
402 //edit interface/globals.php
403 //first, ensure slashes are in correct direction (windows specific fix)
404 $openemrBasePath = str_replace('\\\\', '/', $openemrBasePath);
405 $openemrBasePath = str_replace('\\', '/', $openemrBasePath);
406 $openemrWebPath = str_replace('\\\\', '/', $openemrWebPath);
407 $openemrWebPath = str_replace('\\', '/', $openemrWebPath);
408 //second, edit file
409 $data = file($conffile2) or die("Could not read ".$conffile2." file.");
410 $finalData = "";
411 $isCount = 0;
412 foreach ($data as $line) {
413 $isHit = 0;
414 if ((strpos($line,"\$webserver_root = \"")) === false) {
416 else {
417 $isHit = 1;
418 $isCount += 1;
419 $finalData .= "\$webserver_root = \"$openemrBasePath\";\n";
421 if ((strpos($line,"\$web_root = \"")) === false) {
423 else {
424 $isHit = 1;
425 $isCount += 1;
426 $finalData .= "\$web_root = \"$openemrWebPath\";\n";
428 if (!$isHit) {
429 $finalData .= $line;
432 $fd = @fopen($conffile2, 'w') or die("Could not open ".$conffile2." file.");
433 fwrite($fd, $finalData);
434 fclose($fd);
435 if ($isCount == 2) {
436 echo "Successfully wrote OpenEMR webserver paths to config file<br><br>";
438 else {
439 echo "<FONT COLOR='red'>ERROR</FONT> writing openemr webserver root paths to config file ($conffile2). ($isCount)<br><br>\n";
442 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
444 echo "
445 <FORM METHOD='POST'>\n
446 <INPUT TYPE='HIDDEN' NAME='state' VALUE='4'>
447 <INPUT TYPE='HIDDEN' NAME='host' VALUE='$server'>
448 <INPUT TYPE='HIDDEN' NAME='dbname' VALUE='$dbname'>
449 <INPUT TYPE='HIDDEN' NAME='port' VALUE='$port'>
450 <INPUT TYPE='HIDDEN' NAME='login' VALUE='$login'>
451 <INPUT TYPE='HIDDEN' NAME='pass' VALUE='$pass'>
452 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>
453 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$iuname'>
454 <br>\n
455 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
458 break;
460 case 4:
461 echo "<b>Step $state</b><br><br>\n";
462 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
464 //first, edit two gacl config files
465 echo "Writing php-GACL configuration settings to config files...<br>";
466 // edit gacl.ini.php
467 $data = file($gaclConfigFile1) or die("Could not read ".$gaclConfigFile1." file.");
468 $finalData = "";
469 foreach ($data as $line) {
470 $isHit = 0;
471 if ((strpos($line,"db_host")) === false) {
473 else {
474 $isHit = 1;
475 $finalData .= "db_host = \"${host}\"\n";
477 if ((strpos($line,"db_user")) === false) {
479 else {
480 $isHit = 1;
481 $finalData .= "db_user = \"${login}\"\n";
483 if ((strpos($line,"db_password")) === false) {
485 else {
486 $isHit = 1;
487 $finalData .= "db_password = \"${pass}\"\n";
489 if ((strpos($line,"db_name")) === false) {
491 else {
492 $isHit = 1;
493 $finalData .= "db_name = \"${dbname}\"\n";
495 if (!$isHit) {
496 $finalData .= $line;
499 $fd = @fopen($gaclConfigFile1, 'w') or die("Could not open ".$gaclConfigFile1." file.");
500 fwrite($fd, $finalData);
501 fclose($fd);
503 // edit gacl.class.php
504 $data = file($gaclConfigFile2) or die("Could not read ".$gaclConfigFile2." file.");
505 $finalData = "";
506 foreach ($data as $line) {
507 $isHit = 0;
508 if ((strpos($line,"var \$_db_host = ")) === false) {
510 else {
511 $isHit = 1;
512 $finalData .= "var \$_db_host = '$host';\n";
514 if ((strpos($line,"var \$_db_user = ")) === false) {
516 else {
517 $isHit = 1;
518 $finalData .= "var \$_db_user = '$login';\n";
520 if ((strpos($line,"var \$_db_password = ")) === false) {
522 else {
523 $isHit = 1;
524 $finalData .= "var \$_db_password = '$pass';\n";
526 if ((strpos($line,"var \$_db_name = ")) === false) {
528 else {
529 $isHit = 1;
530 $finalData .= "var \$_db_name = '$dbname';\n";
532 if (!$isHit) {
533 $finalData .= $line;
536 $fd = @fopen($gaclConfigFile2, 'w') or die("Could not open ".$gaclConfigFile2." file.");
537 fwrite($fd, $finalData);
538 fclose($fd);
539 echo "Finished writing php-GACL configuration settings to config files.<br><br>";
541 //second, run gacl config scripts
542 require $gaclSetupScript1;
543 require $gaclSetupScript2;
544 echo "<br>";
546 //third, give the administrator user admin priviledges
547 $groupArray = array("Administrators");
548 set_user_aro($groupArray,$iuser,$iuname,"","");
549 echo "Gave the '$iuser' user (password is 'pass') administrator access.<br><br>";
551 echo "Done installing and configuring access controls (php-GACL). Click 'continue' to see further instructions.";
553 echo "<br><FORM METHOD='POST'>\n
554 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
555 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>\n
556 <br>\n
557 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
559 break;
561 case 0:
562 default:
563 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";
565 echo "Detailed installation instructions can be found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.<br><br>";
567 Echo "If you are upgrading from a previous version, do NOT use this script. Please read the 'Upgrading' section found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.<br><br>";
569 echo "We will now ensure correct file permissions and directories before starting installation:<br><br>\n";
570 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
571 $errorWritable = 0;
572 foreach ($writableFileList as $tempFile) {
573 if (is_writable($tempFile)) {
574 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>";
576 else {
577 echo "<br><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>";
578 echo "(configure file permissions; see below for further instructions)<br>";
579 $errorWritable = 1;
582 if ($errorWritable) {
583 echo "<br><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>";
584 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>";
585 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>";
586 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'><br></FORM><br>\n";
587 break;
590 echo "<br><FONT COLOR='green'>Ensuring following directories exist...</FONT><br>\n";
591 $errorWritable = 0;
592 foreach ($writableDirList as $tempDir) {
593 if (file_exists($tempDir)) {
594 echo "'".realpath($tempDir)."' directory <FONT COLOR='green'><b>exists</b></FONT>.<br>";
596 else {
597 $tempPath = realpath($tempDir);
598 if ($tempPath == "") {
599 //this is a fix specific to microsoft windows
600 $tempPath = realpath('./').DIRECTORY_SEPARATOR.$tempDir;
601 $tempPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $tempPath);
603 echo "<br><FONT COLOR='red'>UNABLE</FONT> to find directory '".$tempPath."'.<br>";
604 echo "(please create directory; see below for further instructions)<br>";
605 $errorWritable = 1;
608 if ($errorWritable) {
609 echo "<br><FONT COLOR='red'>You can't proceed until all above directories exist.</FONT><br>";
610 echo "In linux, recommend using the 'mkdir directory_name' command<br>\n";
611 echo "Add above marked directories and then click the 'Check Again' button to re-check for directories.<br>";
612 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'><br></FORM><br>\n";
613 break;
616 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
617 $errorWritable = 0;
618 foreach ($writableDirList as $tempDir) {
619 if (is_writable($tempDir)) {
620 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>";
622 else {
623 echo "<br><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>";
624 echo "(configure directory permissions; see below for further instructions)<br>";
625 $errorWritable = 1;
628 if ($errorWritable) {
629 echo "<br><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>";
630 echo "In linux, recommend changing owners of these directories to the web server. For example, in many linux OS's the web server user is 'apache', 'nobody', or 'www-data'. So if 'apache' were the web server user name, could use the command 'chown -R apache:apache directory_name' command.<br>\n";
631 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>";
632 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'><br></FORM><br>\n";
633 break;
636 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
637 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'><INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
644 </span>
646 </BODY>
647 </HTML>