sample template here, and ensure directory not pruned
[openemr.git] / setup.php
bloba7c8872d1aa5814842c802ac616fa71881b875ee
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 //If having problems with file and directory permission
14 // checking, then can be manually disabled here.
15 $checkPermissions = "TRUE";
17 //Below section is only for variables that require a path.
18 // The $manualPath variable can be edited by 3rd party
19 // installation scripts to manually set path. (this will
20 // allow straightforward use of this script by 3rd party
21 // installers)
22 $manualPath = "";
23 $dumpfile = $manualPath."sql/database.sql";
24 $icd9 = $manualPath."sql/icd9.sql";
25 $conffile = $manualPath."library/sqlconf.php";
26 $conffile2 = $manualPath."interface/globals.php";
27 $gaclConfigFile1 = $manualPath."gacl/gacl.ini.php";
28 $gaclConfigFile2 = $manualPath."gacl/gacl.class.php";
29 $docsDirectory = $manualPath."documents";
30 $billingDirectory = $manualPath."edi";
31 $gaclWritableDirectory = $manualPath."gacl/admin/templates_c";
32 $requiredDirectory1 = $manualPath."interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
33 $requiredDirectory2 = $manualPath."interface/main/calendar/modules/PostCalendar/pntemplates/cache";
34 $gaclSetupScript1 = $manualPath."gacl/setup.php";
35 $gaclSetupScript2 = $manualPath."acl_setup.php";
37 //These are files and dir checked before install for
38 // correct permissions.
39 $writableFileList = array($conffile, $conffile2, $gaclConfigFile1, $gaclConfigFile2);
40 $writableDirList = array($docsDirectory, $billingDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
43 include_once($conffile);
45 <HTML>
46 <HEAD>
47 <TITLE>OpenEMR Setup Tool</TITLE>
48 <LINK REL=STYLESHEET HREF="interface/themes/style_blue.css">
49 </HEAD>
50 <BODY>
52 <span class="title">OpenEMR Setup</span>
53 <br><br>
54 <span class="text">
56 <?php
57 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
58 echo "It appears that you have register_globals enabled in your php.ini\n" .
59 "configuration file. This causes unacceptable security risks. You must\n" .
60 "turn it off before continuing with installation.\n";
61 exit();
63 ?>
65 <?php
66 if ($state == 6) {
69 <p>Congratulations! OpenEMR is now installed.</p>
71 <ul>
72 <li>If applicable, please restore secure permissions on the four configuration files: /openemr/interface/globals.php,
73 /openemr/library/sqlconf.php, /openemr/gacl/gacl.ini.php, and /openemr/gacl/gacl.class.php files.
74 In linux, recommend changing file permissions with the 'chmod 644 filename' command.</li>
75 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
76 OpenEMR's admin->acl menu.</li>
77 <li>Reading openemr/includes/config.php and openemr/interface/globals.php is a good idea. These files
78 contain many options to choose from including themes.</li>
79 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
80 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
81 <li>To ensure a consistent look and feel through out the application using
82 <a href='http://www.mozilla.org/products/firefox/'>Firefox</a> is recommended.</li>
83 <li>The OpenEMR project home page and wiki can be found at <a href = "http://www.oemr.org" target="_blank">http://www.oemr.org</a></li>
84 <li>The OpenEMR forums can be found at <a href = "http://sourceforge.net/projects/openemr" target="_blank">http://sourceforge.net/projects/openemr</a></li>
85 <li>We pursue grants to help fund the future development of OpenEMR. To apply for these grants, we need to estimate how many times this program is installed and how many practices are evaluating or using this software. It would be awesome if you would email us at <a href="mailto:drbowen@charter.net">drbowen@charter.net</a> if you have installed this software. The more details about your plans with this software, the better, but even just sending us an email stating you just installed it is very helpful.</li>
86 </ul>
87 <p>
88 We recommend you print these instructions for future reference.
89 </p>
90 <p>
91 <b>The initial OpenEMR user is "<?php echo $iuser; ?>" and the password is "pass".</b>
92 You should change this password!
93 </p>
94 <p>
95 <a href='./'>Click here to start using OpenEMR. </a>
96 </p>
99 exit();
103 <?php
105 $server = $_POST["server"];
106 $port = $_POST["port"];
107 $dbname = $_POST["dbname"];
108 $root = $_POST["root"];
109 $login = $_POST["login"];
110 $pass = $_POST["pass"];
111 $loginhost = $_POST["loginhost"];
112 $rootpass = $_POST["rootpass"];
113 $iuser = $_POST["iuser"];
114 $iuname = $_POST["iuname"];
115 $igroup = $_POST["igroup"];
116 $openemrBasePath = $_POST["openemrBasePath"];
117 $openemrWebPath = $_POST["openemrWebPath"];
118 //END POST VARIABLES
121 if (($config == 1) && ($state < 4)) {
122 echo "OpenEMR has already been installed. If you wish to force re-installation, then edit $conffile(change the 'config' variable to 0), and re-run this script.<br>\n";
124 else {
125 switch ($state) {
127 case 1:
128 echo "<b>Step $state</b><br><br>\n";
129 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
130 <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>
131 <br><br>\n
132 <FORM METHOD='POST'>\n
133 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
134 <INPUT TYPE='RADIO' NAME='inst' VALUE='1' checked>Have setup create the database<br>\n
135 <INPUT TYPE='RADIO' NAME='inst' VALUE='2'>I have already created the database<br>\n
136 <br>\n
137 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
138 break;
140 case 2:
141 echo "<b>Step $state</b><br><br>\n";
142 echo "Now you need to supply the MySQL server information and path information.
143 <br><br>
144 <FORM METHOD='POST'>
145 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
146 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
147 <TABLE>\n
148 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
149 <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>
150 <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>
151 <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>
152 <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>
153 <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";
154 if ($inst != 2) {
155 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>
156 <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";
157 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>";
159 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
160 echo "<TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
161 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>
162 <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>
163 <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>
165 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
166 echo "<TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>OPENEMR PATHS:</font></TD></TR>";
167 echo "<TR VALIGN='TOP'><TD COLSPAN=3></TD></TR>
168 <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>
169 <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>
171 echo "</TABLE>
172 <br>
173 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
175 break;
178 case 3:
180 if ($login == "" || !isset($login)) {
181 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
182 echo "Click Back in browser to re-enter.<br>\n";
183 break;
185 if (strpos($iuser, " ")) {
186 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
187 echo "Click Back in browser to re-enter.<br>\n";
188 break;
190 if ($pass == "" || !isset($pass)) {
191 echo "ERROR. Please pick a proper 'Password'.<br>\n";
192 echo "Click Back in browser to re-enter.<br>\n";
193 break;
196 echo "<b>Step $state</b><br><br>\n";
197 echo "Configuring OpenEMR...<br><br>\n";
200 if ($inst != 2) {
201 echo "Connecting to MySQL Server...\n";
202 flush();
203 if ($server == "localhost")
204 $dbh = mysql_connect("$server","$root","$rootpass");
205 else
206 $dbh = mysql_connect("$server:$port","$root","$rootpass");
207 if ($dbh == FALSE) {
208 echo "ERROR. Check your login credentials.\n";
209 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
210 break;
212 else
213 echo "OK.<br>\n";
214 echo "Creating database...\n";
215 flush();
216 if (mysql_query("create database $dbname",$dbh) == FALSE) {
217 echo "ERROR. Check your login credentials.\n";
218 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
219 break;
221 else
222 echo "OK.<br>\n";
223 echo "Creating user with permissions for database...\n";
224 flush();
225 if (mysql_query("GRANT ALL PRIVILEGES ON $dbname.* TO '$login'@'$loginhost' IDENTIFIED BY '$pass'",$dbh) == FALSE) {
226 echo "ERROR when granting privileges to the specified user.\n";
227 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
228 echo "ERROR.\n";
229 break;
231 else
232 echo "OK.<br>\n";
233 echo "Reconnecting as new user...\n";
234 mysql_close($dbh);
236 else
237 echo "Connecting to MySQL Server...\n";
239 if ($server == "localhost")
240 $dbh = mysql_connect("$server","$login","$pass");
241 else
242 $dbh = mysql_connect("$server:$port","$login","$pass");
244 if ($dbh == FALSE) {
245 echo "ERROR. Check your login credentials.\n";
246 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
247 break;
249 else
250 echo "OK.<br>\n";
251 echo "Opening database...";
252 flush();
253 if (mysql_select_db("$dbname",$dbh) == FALSE) {
254 echo "ERROR. Check your login credentials.\n";
255 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
256 break;
258 else
259 echo "OK.<br>\n";
260 flush();
261 if ($upgrade != 1) {
262 echo "Creating initial tables...\n";
263 mysql_query("USE $dbname",$dbh);
264 flush();
265 $fd = fopen($dumpfile, 'r');
266 if ($fd == FALSE) {
267 echo "ERROR. Could not open dumpfile '$dumpfile'.\n";
268 flush();
269 break;
271 $query = "";
272 $line = "";
273 while (!feof ($fd)){
274 $line = fgets($fd,1024);
275 $line = rtrim($line);
276 if (substr($line,0,2) == "--") // Kill comments
277 continue;
278 if (substr($line,0,1) == "#") // Kill comments
279 continue;
280 if ($line == "")
281 continue;
282 $query = $query.$line; // Check for full query
283 $chr = substr($query,strlen($query)-1,1);
284 if ($chr == ";") { // valid query, execute
285 $query = rtrim($query,";");
286 mysql_query("$query",$dbh);
287 $query = "";
290 echo "OK<br>\n";
291 fclose($fd);
292 flush();
293 echo "Adding Initial User...\n";
294 flush();
295 //echo "INSERT INTO groups VALUES (1,'$igroup','$iuser')<br>\n";
296 if (mysql_query("INSERT INTO groups (id, name, user) VALUES (1,'$igroup','$iuser')") == FALSE) {
297 echo "ERROR. Could not run queries.\n";
298 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
299 flush();
300 break;
302 if (mysql_query("INSERT INTO users (id, username, password, authorized, lname,fname) VALUES (1,'$iuser','1a1dc91c907325c69271ddf0c944bc72',1,'$iuname','')") == FALSE) {
303 echo "ERROR. Could not run queries.\n";
304 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
305 flush();
306 break;
308 echo "OK<br>\n";
309 flush();
310 /* echo "Inserting ICD-9-CM Codes into Database...\n";
311 flush();
312 $fd = fopen($icd9, 'r');
313 if ($fd == FALSE) {
314 echo "ERROR. Could not open dumpfile.\n";
315 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
316 flush();
317 break;
319 $query = "";
320 $line = "";
321 while (!feof ($fd)){
322 $line = fgets($fd,1024);
323 $line = rtrim($line);
324 if (substr($line,0,2) == "--") // Kill comments
325 continue;
326 if (substr($line,0,1) == "#") // Kill comments
327 continue;
328 if ($line == "")
329 continue;
330 $query = $query.$line; // Check for full query
331 $chr = substr($query,strlen($query)-1,1);
332 if ($chr == ";") { // valid query, execute
333 $query = rtrim($query,";");
334 mysql_query("$query",$dbh);
335 $query = "";
338 echo "OK\n";
339 fclose($fd);*/
340 flush();
343 echo "<br>Writing SQL Configuration...<br>";
344 @touch($conffile); // php bug
345 $fd = @fopen($conffile, 'w');
346 $string = "<?
347 // OpenEMR
348 // MySQL Config
349 // Referenced from sql.inc
353 $it_died = 0; //fmg: variable keeps running track of any errors
355 fwrite($fd,$string) or $it_died++;
356 fwrite($fd,"\$host\t= '$server';\n") or $it_died++;
357 fwrite($fd,"\$port\t= '$port';\n") or $it_died++;
358 fwrite($fd,"\$login\t= '$login';\n") or $it_died++;
359 fwrite($fd,"\$pass\t= '$pass';\n") or $it_died++;
360 fwrite($fd,"\$dbase\t= '$dbname';\n") or $it_died++;
363 $string = '
365 $sqlconf = array();
366 $sqlconf["host"]= $host;
367 $sqlconf["port"] = $port;
368 $sqlconf["login"] = $login;
369 $sqlconf["pass"] = $pass;
370 $sqlconf["dbase"] = $dbase;
371 //////////////////////////
372 //////////////////////////
373 //////////////////////////
374 //////DO NOT TOUCH THIS///
375 $config = 1; /////////////
376 //////////////////////////
377 //////////////////////////
378 //////////////////////////
381 ?><? // done just for coloring
383 fwrite($fd,$string) or $it_died++;
385 //it's rather irresponsible to not report errors when writing this file.
386 if ($it_died != 0) {
387 echo "ERROR. Couldn't write $it_died lines to config file '$conffile'.\n";
388 flush();
389 break;
391 fclose($fd);
393 echo "Successfully wrote SQL configuration.<BR><br>";
395 echo "Writing OpenEMR webserver paths to config file...<br>";
396 //edit interface/globals.php
397 //first, ensure slashes are in correct direction (windows specific fix)
398 $openemrBasePath = str_replace('\\\\', '/', $openemrBasePath);
399 $openemrBasePath = str_replace('\\', '/', $openemrBasePath);
400 $openemrWebPath = str_replace('\\\\', '/', $openemrWebPath);
401 $openemrWebPath = str_replace('\\', '/', $openemrWebPath);
402 //second, edit file
403 $data = file($conffile2) or die("Could not read ".$conffile2." file.");
404 $finalData = "";
405 $isCount = 0;
406 foreach ($data as $line) {
407 $isHit = 0;
408 if ((strpos($line,"\$webserver_root = \"")) === false) {
410 else {
411 $isHit = 1;
412 $isCount += 1;
413 $finalData .= "\$webserver_root = \"$openemrBasePath\";\n";
415 if ((strpos($line,"\$web_root = \"")) === false) {
417 else {
418 $isHit = 1;
419 $isCount += 1;
420 $finalData .= "\$web_root = \"$openemrWebPath\";\n";
422 if (!$isHit) {
423 $finalData .= $line;
426 $fd = @fopen($conffile2, 'w') or die("Could not open ".$conffile2." file.");
427 fwrite($fd, $finalData);
428 fclose($fd);
429 if ($isCount == 2) {
430 echo "Successfully wrote OpenEMR webserver paths to config file<br><br>";
432 else {
433 echo "<FONT COLOR='red'>ERROR</FONT> writing openemr webserver root paths to config file ($conffile2). ($isCount)<br><br>\n";
436 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
438 echo "
439 <FORM METHOD='POST'>\n
440 <INPUT TYPE='HIDDEN' NAME='state' VALUE='4'>
441 <INPUT TYPE='HIDDEN' NAME='host' VALUE='$server'>
442 <INPUT TYPE='HIDDEN' NAME='dbname' VALUE='$dbname'>
443 <INPUT TYPE='HIDDEN' NAME='port' VALUE='$port'>
444 <INPUT TYPE='HIDDEN' NAME='login' VALUE='$login'>
445 <INPUT TYPE='HIDDEN' NAME='pass' VALUE='$pass'>
446 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>
447 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$iuname'>
448 <br>\n
449 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
452 break;
454 case 4:
455 echo "<b>Step $state</b><br><br>\n";
456 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
458 //first, edit two gacl config files
459 echo "Writing php-GACL configuration settings to config files...<br>";
460 // edit gacl.ini.php
461 $data = file($gaclConfigFile1) or die("Could not read ".$gaclConfigFile1." file.");
462 $finalData = "";
463 foreach ($data as $line) {
464 $isHit = 0;
465 if ((strpos($line,"db_host")) === false) {
467 else {
468 $isHit = 1;
469 $finalData .= "db_host = \"${host}\"\n";
471 if ((strpos($line,"db_user")) === false) {
473 else {
474 $isHit = 1;
475 $finalData .= "db_user = \"${login}\"\n";
477 if ((strpos($line,"db_password")) === false) {
479 else {
480 $isHit = 1;
481 $finalData .= "db_password = \"${pass}\"\n";
483 if ((strpos($line,"db_name")) === false) {
485 else {
486 $isHit = 1;
487 $finalData .= "db_name = \"${dbname}\"\n";
489 if (!$isHit) {
490 $finalData .= $line;
493 $fd = @fopen($gaclConfigFile1, 'w') or die("Could not open ".$gaclConfigFile1." file.");
494 fwrite($fd, $finalData);
495 fclose($fd);
497 // edit gacl.class.php
498 $data = file($gaclConfigFile2) or die("Could not read ".$gaclConfigFile2." file.");
499 $finalData = "";
500 foreach ($data as $line) {
501 $isHit = 0;
502 if ((strpos($line,"var \$_db_host = ")) === false) {
504 else {
505 $isHit = 1;
506 $finalData .= "var \$_db_host = '$host';\n";
508 if ((strpos($line,"var \$_db_user = ")) === false) {
510 else {
511 $isHit = 1;
512 $finalData .= "var \$_db_user = '$login';\n";
514 if ((strpos($line,"var \$_db_password = ")) === false) {
516 else {
517 $isHit = 1;
518 $finalData .= "var \$_db_password = '$pass';\n";
520 if ((strpos($line,"var \$_db_name = ")) === false) {
522 else {
523 $isHit = 1;
524 $finalData .= "var \$_db_name = '$dbname';\n";
526 if (!$isHit) {
527 $finalData .= $line;
530 $fd = @fopen($gaclConfigFile2, 'w') or die("Could not open ".$gaclConfigFile2." file.");
531 fwrite($fd, $finalData);
532 fclose($fd);
533 echo "Finished writing php-GACL configuration settings to config files.<br><br>";
535 //second, run gacl config scripts
536 require $gaclSetupScript1;
537 require $gaclSetupScript2;
538 echo "<br>";
540 //third, give the administrator user admin priviledges
541 $groupArray = array("Administrators");
542 set_user_aro($groupArray,$iuser,$iuname,"","");
543 echo "Gave the '$iuser' user (password is 'pass') administrator access.<br><br>";
545 echo "Done installing and configuring access controls (php-GACL).<br>";
546 echo "Next step will configure PHP and Apache webserver.";
548 echo "<br><FORM METHOD='POST'>\n
549 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
550 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>\n
551 <br>\n
552 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
554 break;
556 case 5:
557 echo "<b>Step $state</b><br><br>\n";
558 echo "Configuration of PHP and Apache web server...<br><br>\n";
559 echo "<b>PHP configuration:</b><br>\n";
560 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
561 echo "<ul>";
562 $gotFileFlag = 0;
563 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
564 $phpINIfile = php_ini_loaded_file();
565 if ($phpINIfile) {
566 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
567 $gotFileFlag = 1;
570 echo "<li>To ensure proper functioning of OpenEMR you must make sure that settings in php.ini file include \"display_errors = Off\", \"register_globals = Off\", \"magic_quotes_gpc = Off\", and \"memory_limit\" set to at least \"128M\".</li>\n";
571 echo "<li>In order to take full advantage of the patient documents capability you must make sure that settings in php.ini file include \"file_uploads = On\", that \"upload_max_filesize\" is appropriate for your use and that \"upload_tmp_dir\" is set to a correct value that will work on your system.</li>\n";
572 if (!$gotFileFlag) {
573 echo "<li>If you are having difficulty finding your php.ini file, then refer to the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.</li>\n";
575 echo "</ul>";
577 echo "<br><b>APACHE configuration:</b><br>
578 The \"".realpath($docsDirectory)."\" and \"".realpath($billingDirectory)."\" directories contain patient information, and
579 it is important to secure these directories. This can be done by placing pertinent .htaccess
580 files in these directories or by pasting the below in your apache configuration file:<br>
581 &nbsp;&nbsp;&lt;Directory ".realpath($docsDirectory)."&gt;<br>
582 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
583 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
584 &nbsp;&nbsp;&lt;/Directory&gt;<br>
585 &nbsp;&nbsp;&lt;Directory ".realpath($billingDirectory)."&gt;<br>
586 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
587 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
588 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
589 echo "If you are having difficulty finding your apache configuration file, then refer to the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.<br><br>\n";
590 echo "<br>We recommend you print these instructions for future reference.<br><br>";
591 echo "Click 'continue' for further instructions.";
593 echo "<br><FORM METHOD='POST'>\n
594 <INPUT TYPE='HIDDEN' NAME='state' VALUE='6'>\n
595 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>\n
596 <br>\n
597 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
599 break;
601 case 0:
602 default:
603 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
604 echo "<ul><li>Before proceeding, be sure that you have a properly installed and configured MySQL server available, and a PHP configured webserver.</li>\n";
606 echo "<li>Detailed installation instructions can be found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li>\n";
608 Echo "<li>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.</li></ul>";
610 if ($checkPermissions == "TRUE") {
611 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
612 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
613 $errorWritable = 0;
614 foreach ($writableFileList as $tempFile) {
615 if (is_writable($tempFile)) {
616 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
618 else {
619 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
620 echo "(configure file permissions; see below for further instructions)</p>\n";
621 $errorWritable = 1;
624 if ($errorWritable) {
625 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
626 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
627 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
628 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p></FORM><br>\n";
629 break;
632 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
633 $errorWritable = 0;
634 foreach ($writableDirList as $tempDir) {
635 if (is_writable($tempDir)) {
636 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
638 else {
639 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
640 echo "(configure directory permissions; see below for further instructions)</p>\n";
641 $errorWritable = 1;
644 if ($errorWritable) {
645 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
646 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";
647 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
648 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p></FORM><br>\n";
649 break;
652 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
654 else {
655 echo "<br>Click to continue installation.<br>\n";
658 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'><INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
665 </span>
667 </BODY>
668 </HTML>