translate column headers
[openemr.git] / setup.php
blob39f18954447b0c649201919c0c6a53a89069e836
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 $state = $_POST["state"];
12 // Make this true for IPPF.
13 $ippf_specific = false;
15 //If having problems with file and directory permission
16 // checking, then can be manually disabled here.
17 $checkPermissions = "TRUE";
19 //Below section is only for variables that require a path.
20 // The $manualPath variable can be edited by 3rd party
21 // installation scripts to manually set path. (this will
22 // allow straightforward use of this script by 3rd party
23 // installers)
24 $manualPath = "";
25 $dumpfile = $manualPath."sql/database.sql";
26 $translations_dumpfile_utf8 = $manualPath."contrib/util/language_translations/currentLanguage_utf8.sql";
27 $translations_dumpfile_latin1 = $manualPath."contrib/util/language_translations/currentLanguage_latin1.sql";
28 $icd9 = $manualPath."sql/icd9.sql";
29 $conffile = $manualPath."library/sqlconf.php";
30 $conffile2 = $manualPath."interface/globals.php";
31 $docsDirectory = $manualPath."documents";
32 $billingDirectory = $manualPath."edi";
33 $billingDirectory2 = $manualPath."era";
34 $billingLogDirectory = $manualPath."library/freeb";
35 $lettersDirectory = $manualPath."custom/letter_templates";
36 $gaclWritableDirectory = $manualPath."gacl/admin/templates_c";
37 $requiredDirectory1 = $manualPath."interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
38 $requiredDirectory2 = $manualPath."interface/main/calendar/modules/PostCalendar/pntemplates/cache";
39 $gaclSetupScript1 = $manualPath."gacl/setup.php";
40 $gaclSetupScript2 = $manualPath."acl_setup.php";
42 //These are files and dir checked before install for
43 // correct permissions.
44 $writableFileList = array($conffile, $conffile2);
45 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $billingLogDirectory, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
47 //These are the dumpfiles that are loaded into database
48 // The subsequent array holds the title of dumpfiles
49 $dumpfiles = array($dumpfile);
50 $dumpfilesTitles = array("Main");
52 include_once($conffile);
54 <HTML>
55 <HEAD>
56 <TITLE>OpenEMR Setup Tool</TITLE>
57 <LINK REL=STYLESHEET HREF="interface/themes/style_blue.css">
58 </HEAD>
59 <BODY>
61 <span class="title">OpenEMR Setup</span>
62 <br><br>
63 <span class="text">
65 <?php
66 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
67 echo "It appears that you have register_globals enabled in your php.ini\n" .
68 "configuration file. This causes unacceptable security risks. You must\n" .
69 "turn it off before continuing with installation.\n";
70 exit();
72 ?>
74 <?php
75 if ($state == 7) {
78 <p>Congratulations! OpenEMR is now installed.</p>
80 <ul>
81 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
82 OpenEMR's admin->acl menu.</li>
83 <li>Reading openemr/includes/config.php and openemr/interface/globals.php is a good idea. These files
84 contain many options to choose from including themes.</li>
85 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
86 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
87 <li>To ensure a consistent look and feel through out the application using
88 <a href='http://www.mozilla.org/products/firefox/'>Firefox</a> is recommended.</li>
89 <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>
90 <li>The OpenEMR forums can be found at <a href = "http://sourceforge.net/projects/openemr" target="_blank">http://sourceforge.net/projects/openemr</a></li>
91 <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@openmedsoftware.org">drbowen@openmedsoftware.org</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>
92 </ul>
93 <p>
94 We recommend you print these instructions for future reference.
95 </p>
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 If you edited the PHP or Apache configuration files during this installation process, then we recommend you restart your Apache server before following below OpenEMR link.
102 </p>
104 <a href='./'>Click here to start using OpenEMR. </a>
105 </p>
107 <?php
108 exit();
112 <?php
114 $server = $_POST["server"];
115 $port = $_POST["port"];
116 $dbname = $_POST["dbname"];
117 $root = $_POST["root"];
118 $login = $_POST["login"];
119 $pass = $_POST["pass"];
120 $loginhost = $_POST["loginhost"];
121 $collate = $_POST["collate"];
122 $rootpass = $_POST["rootpass"];
123 $iuser = $_POST["iuser"];
124 $iuname = $_POST["iuname"];
125 $igroup = $_POST["igroup"];
126 $openemrBasePath = $_POST["openemrBasePath"];
127 $openemrWebPath = $_POST["openemrWebPath"];
128 //END POST VARIABLES
131 if (($config == 1) && ($state < 4)) {
132 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";
134 else {
135 switch ($state) {
137 case 1:
138 echo "<b>Step $state</b><br><br>\n";
139 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
140 <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>
141 <br><br>\n
142 <FORM METHOD='POST'>\n
143 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
144 <INPUT TYPE='RADIO' NAME='inst' VALUE='1' checked>Have setup create the database<br>\n
145 <INPUT TYPE='RADIO' NAME='inst' VALUE='2'>I have already created the database<br>\n
146 <br>\n
147 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
148 break;
150 case 2:
151 echo "<b>Step $state</b><br><br>\n";
152 echo "Now you need to supply the MySQL server information and path information. Detailed instructions on each item can be found in the <a href='INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.
153 <br><br>\n
154 <FORM METHOD='POST'>
155 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
156 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
157 <TABLE>\n
158 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
159 <TR VALIGN='TOP'><TD><span class='text'>Server Host: </span></TD><TD><INPUT TYPE='TEXT' VALUE='localhost' NAME='server' SIZE='30'></TD><TD><span class='text'>(If you run MySQL and Apache/PHP on the same computer, then leave this as 'localhost'. If they are on separate computers, then enter the IP address of the computer running MySQL.)</span><br></TD></TR>
160 <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'>(This is the MySQL port. The default port for MySQL is 3306.)</span><br></TD></TR>
161 <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>
162 <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>
163 <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";
164 if ($inst != 2) {
165 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>
166 <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";
167 echo "<TR VALIGN='TOP'><TD><span class='text'>User Hostname: </span></TD><TD><INPUT TYPE='TEXT' VALUE='localhost' 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>";
168 echo "<TR VALIGN='TOP'><TD><span class='text'>UTF-8 Collation: </span></TD><TD colspan='2'>" .
169 "<select name='collate'>" .
170 "<option value='utf8_bin' >Bin</option>" .
171 "<option value='utf8_czech_ci' >Czech</option>" .
172 "<option value='utf8_danish_ci' >Danish</option>" .
173 "<option value='utf8_esperanto_ci' >Esperanto</option>" .
174 "<option value='utf8_estonian_ci' >Estonian</option>" .
175 "<option value='utf8_general_ci' selected>General</option>" .
176 "<option value='utf8_hungarian_ci' >Hungarian</option>" .
177 "<option value='utf8_icelandic_ci' >Icelandic</option>" .
178 "<option value='utf8_latvian_ci' >Latvian</option>" .
179 "<option value='utf8_lithuanian_ci'>Lithuanian</option>" .
180 "<option value='utf8_persian_ci' >Persian</option>" .
181 "<option value='utf8_polish_ci' >Polish</option>" .
182 "<option value='utf8_roman_ci' >Roman</option>" .
183 "<option value='utf8_romanian_ci' >Romanian</option>" .
184 "<option value='utf8_slovak_ci' >Slovak</option>" .
185 "<option value='utf8_slovenian_ci' >Slovenian</option>" .
186 "<option value='utf8_spanish2_ci' >Spanish2 (Traditional)</option>" .
187 "<option value='utf8_spanish_ci' >Spanish (Modern)</option>" .
188 "<option value='utf8_swedish_ci' >Swedish</option>" .
189 "<option value='utf8_turkish_ci' >Turkish</option>" .
190 "<option value='utf8_unicode_ci' >Unicode (German, French, Russian, Armenian, Greek)</option>" .
191 "<option value='' >None (Do not force UTF-8)</option>" .
192 "</select>" .
193 "</TD></TR><TR VALIGN='TOP'><TD>&nbsp;</TD><TD colspan='2'><span class='text'>(This is the collation setting for mysql. Leave as 'General' if you are not sure. If the language you are planning to use in OpenEMR is in the menu, then you can select it. Otherwise, just select 'General'.)</span><br></TD></TR>";
195 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
196 echo "<TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
197 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>
198 <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>
199 <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>
201 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
202 echo "<TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>OPENEMR PATHS:</font></TD></TR>";
203 echo "<TR VALIGN='TOP'><TD COLSPAN=3></TD></TR>
204 <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>
205 <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>
207 echo "</TABLE>
208 <br>
209 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
211 break;
214 case 3:
216 if ($login == "" || !isset($login)) {
217 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
218 echo "Click Back in browser to re-enter.<br>\n";
219 break;
221 if (strpos($iuser, " ")) {
222 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
223 echo "Click Back in browser to re-enter.<br>\n";
224 break;
226 if ($pass == "" || !isset($pass)) {
227 echo "ERROR. Please pick a proper 'Password'.<br>\n";
228 echo "Click Back in browser to re-enter.<br>\n";
229 break;
232 echo "<b>Step $state</b><br><br>\n";
233 echo "Configuring OpenEMR...<br><br>\n";
236 if ($inst != 2) {
237 echo "Connecting to MySQL Server...\n";
238 flush();
239 if ($server == "localhost")
240 $dbh = mysql_connect("$server","$root","$rootpass");
241 else
242 $dbh = mysql_connect("$server:$port","$root","$rootpass");
243 if ($dbh == FALSE) {
244 echo "ERROR. Check your login credentials.\n";
245 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
246 break;
248 else
249 echo "OK.<br>\n";
250 echo "Creating database...\n";
251 flush();
252 $sql = "create database $dbname";
253 if ($collate) {
254 $sql .= " character set utf8 collate $collate";
255 mysql_query("SET NAMES 'utf8'", $dbh);
257 if (mysql_query($sql, $dbh) == FALSE) {
258 echo "ERROR. Check your login credentials.\n";
259 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
260 break;
262 else
263 echo "OK.<br>\n";
264 echo "Creating user with permissions for database...\n";
265 flush();
266 if (mysql_query("GRANT ALL PRIVILEGES ON $dbname.* TO '$login'@'$loginhost' IDENTIFIED BY '$pass'",$dbh) == FALSE) {
267 echo "ERROR when granting privileges to the specified user.\n";
268 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
269 echo "ERROR.\n";
270 break;
272 else
273 echo "OK.<br>\n";
274 echo "Reconnecting as new user...\n";
275 mysql_close($dbh);
277 else
278 echo "Connecting to MySQL Server...\n";
280 if ($server == "localhost")
281 $dbh = mysql_connect("$server","$login","$pass");
282 else
283 $dbh = mysql_connect("$server:$port","$login","$pass");
285 if ($dbh == FALSE) {
286 echo "ERROR. Check your login credentials.\n";
287 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
288 break;
290 else {
291 if ($collate) {
292 mysql_query("SET NAMES 'utf8'", $dbh);
294 echo "OK.<br>\n";
296 echo "Opening database...";
297 flush();
298 if (mysql_select_db("$dbname",$dbh) == FALSE) {
299 echo "ERROR. Check your login credentials.\n";
300 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
301 break;
303 else
304 echo "OK.<br>\n";
305 flush();
306 if ($upgrade != 1) {
308 //select the correct translation dumpfile
309 if ($collate) {
310 array_push($dumpfiles,$translations_dumpfile_utf8);
311 array_push($dumpfilesTitles,"Language Translation (utf8)");
313 else {
314 array_push($dumpfiles,$translations_dumpfile_latin1);
315 array_push($dumpfilesTitles,"Language Translation (latin1)");
318 // Deal with IPPF-specific SQL.
319 if ($ippf_specific) {
320 array_push($dumpfiles, $manualPath . "sql/ippf_layout.sql");
321 array_push($dumpfilesTitles, "IPPF Layout");
324 $dumpfileCounter = 0;
325 foreach ($dumpfiles as $var) {
326 echo "Creating ".$dumpfilesTitles[$dumpfileCounter]." tables...\n";
327 mysql_query("USE $dbname",$dbh);
328 flush();
329 $fd = fopen($var, 'r');
330 if ($fd == FALSE) {
331 echo "ERROR. Could not open dumpfile '$dumpfile'.\n";
332 flush();
333 break;
335 $query = "";
336 $line = "";
337 while (!feof ($fd)){
338 $line = fgets($fd,1024);
339 $line = rtrim($line);
340 if (substr($line,0,2) == "--") // Kill comments
341 continue;
342 if (substr($line,0,1) == "#") // Kill comments
343 continue;
344 if ($line == "")
345 continue;
346 $query = $query.$line; // Check for full query
347 $chr = substr($query,strlen($query)-1,1);
348 if ($chr == ";") { // valid query, execute
349 $query = rtrim($query,";");
350 if (!mysql_query($query, $dbh)) {
351 echo "<p>ERROR. Query failed: \"$query\"\n";
352 echo "<br />" . mysql_error() . " (#" . mysql_errno() . ")</p>\n";
354 $query = "";
357 echo "OK<br>\n";
358 fclose($fd);
359 flush();
360 $dumpfileCounter++;
362 echo "Adding Initial User...\n";
363 flush();
364 //echo "INSERT INTO groups VALUES (1,'$igroup','$iuser')<br>\n";
365 if (mysql_query("INSERT INTO groups (id, name, user) VALUES (1,'$igroup','$iuser')") == FALSE) {
366 echo "ERROR. Could not run queries.\n";
367 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
368 flush();
369 break;
371 if (mysql_query("INSERT INTO users (id, username, password, authorized, lname, fname, facility_id, calendar, cal_ui) VALUES (1,'$iuser','1a1dc91c907325c69271ddf0c944bc72',1,'$iuname','',3,1,3)") == FALSE) {
372 echo "ERROR. Could not run queries.\n";
373 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
374 flush();
375 break;
377 echo "OK<br>\n";
378 flush();
379 /* echo "Inserting ICD-9-CM Codes into Database...\n";
380 flush();
381 $fd = fopen($icd9, 'r');
382 if ($fd == FALSE) {
383 echo "ERROR. Could not open dumpfile.\n";
384 echo "<p>".mysql_error()." (#".mysql_errno().")\n";
385 flush();
386 break;
388 $query = "";
389 $line = "";
390 while (!feof ($fd)){
391 $line = fgets($fd,1024);
392 $line = rtrim($line);
393 if (substr($line,0,2) == "--") // Kill comments
394 continue;
395 if (substr($line,0,1) == "#") // Kill comments
396 continue;
397 if ($line == "")
398 continue;
399 $query = $query.$line; // Check for full query
400 $chr = substr($query,strlen($query)-1,1);
401 if ($chr == ";") { // valid query, execute
402 $query = rtrim($query,";");
403 mysql_query("$query",$dbh);
404 $query = "";
407 echo "OK\n";
408 fclose($fd);*/
409 flush();
412 echo "<br>Writing SQL Configuration...<br>";
413 @touch($conffile); // php bug
414 $fd = @fopen($conffile, 'w');
415 $string = "<?php
416 // OpenEMR
417 // MySQL Config
418 // Referenced from sql.inc
422 $it_died = 0; //fmg: variable keeps running track of any errors
424 fwrite($fd,$string) or $it_died++;
425 fwrite($fd,"\$host\t= '$server';\n") or $it_died++;
426 fwrite($fd,"\$port\t= '$port';\n") or $it_died++;
427 fwrite($fd,"\$login\t= '$login';\n") or $it_died++;
428 fwrite($fd,"\$pass\t= '$pass';\n") or $it_died++;
429 fwrite($fd,"\$dbase\t= '$dbname';\n\n") or $it_died++;
430 fwrite($fd,"//Added ability to disable\n") or $it_died++;
431 fwrite($fd,"//utf8 encoding - bm 05-2009\n") or $it_died++;
432 fwrite($fd,"\$disable_utf8_flag = false;\n") or $it_died++;
434 $string = '
435 $sqlconf = array();
436 $sqlconf["host"]= $host;
437 $sqlconf["port"] = $port;
438 $sqlconf["login"] = $login;
439 $sqlconf["pass"] = $pass;
440 $sqlconf["dbase"] = $dbase;
441 //////////////////////////
442 //////////////////////////
443 //////////////////////////
444 //////DO NOT TOUCH THIS///
445 $config = 1; /////////////
446 //////////////////////////
447 //////////////////////////
448 //////////////////////////
451 ?><?php // done just for coloring
453 fwrite($fd,$string) or $it_died++;
455 //it's rather irresponsible to not report errors when writing this file.
456 if ($it_died != 0) {
457 echo "ERROR. Couldn't write $it_died lines to config file '$conffile'.\n";
458 flush();
459 break;
461 fclose($fd);
463 echo "Successfully wrote SQL configuration.<BR><br>";
465 echo "Writing OpenEMR webserver paths to config file...<br>";
466 //edit interface/globals.php
467 //first, ensure slashes are in correct direction (windows specific fix)
468 $openemrBasePath = str_replace('\\\\', '/', $openemrBasePath);
469 $openemrBasePath = str_replace('\\', '/', $openemrBasePath);
470 $openemrWebPath = str_replace('\\\\', '/', $openemrWebPath);
471 $openemrWebPath = str_replace('\\', '/', $openemrWebPath);
472 //second, edit file (web paths and set UTF8 if pertinent)
473 $data = file($conffile2) or die("Could not read ".$conffile2." file.");
474 $finalData = "";
475 $isCount = 0;
476 foreach ($data as $line) {
477 $isHit = 0;
478 if ((strpos($line,"\$webserver_root = \"")) === false) {
480 else {
481 $isHit = 1;
482 $isCount += 1;
483 $finalData .= "\$webserver_root = \"$openemrBasePath\";\n";
485 if ((strpos($line,"\$web_root = \"")) === false) {
487 else {
488 $isHit = 1;
489 $isCount += 1;
490 $finalData .= "\$web_root = \"$openemrWebPath\";\n";
492 if (!$isHit) {
493 $finalData .= $line;
496 $fd = @fopen($conffile2, 'w') or die("Could not open ".$conffile2." file.");
497 fwrite($fd, $finalData);
498 fclose($fd);
499 if ($isCount == 2) {
500 echo "Successfully wrote OpenEMR webserver paths to config file<br><br>";
502 else {
503 echo "<FONT COLOR='red'>ERROR</FONT> writing openemr webserver root paths to config file ($conffile2). ($isCount)<br><br>\n";
506 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
508 echo "
509 <FORM METHOD='POST'>\n
510 <INPUT TYPE='HIDDEN' NAME='state' VALUE='4'>
511 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>
512 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$iuname'>
513 <br>\n
514 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
517 break;
519 case 4:
520 echo "<b>Step $state</b><br><br>\n";
521 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
523 //run gacl config scripts, all sql config data now in sqlconf.php file
524 require $gaclSetupScript1;
525 require $gaclSetupScript2;
526 echo "<br>";
528 //give the administrator user admin priviledges
529 $groupArray = array("Administrators");
530 set_user_aro($groupArray,$iuser,$iuname,"","");
531 echo "Gave the '$iuser' user (password is 'pass') administrator access.<br><br>";
533 echo "Done installing and configuring access controls (php-GACL).<br>";
534 echo "Next step will configure PHP.";
536 echo "<br><FORM METHOD='POST'>\n
537 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
538 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>\n
539 <br>\n
540 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
542 break;
544 case 5:
545 echo "<b>Step $state</b><br><br>\n";
546 echo "Configuration of PHP...<br><br>\n";
547 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
548 echo "<ul>";
549 $gotFileFlag = 0;
550 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
551 $phpINIfile = php_ini_loaded_file();
552 if ($phpINIfile) {
553 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
554 $gotFileFlag = 1;
557 echo "<li>To ensure proper functioning of OpenEMR you must make sure that settings in php.ini file include \"short_open_tag = On\", \"display_errors = Off\", \"register_globals = Off\", \"magic_quotes_gpc = On\", \"max_execution_time\" set to at least 60, \"max_input_time\" set to at least 90, and \"memory_limit\" set to at least \"128M\".</li>\n";
558 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";
559 if (!$gotFileFlag) {
560 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";
562 echo "</ul>";
564 echo "<br>We recommend you print these instructions for future reference.<br><br>";
565 echo "Next step will configure Apache web server.";
567 echo "<br><FORM METHOD='POST'>\n
568 <INPUT TYPE='HIDDEN' NAME='state' VALUE='6'>\n
569 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>\n
570 <br>\n
571 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
573 break;
575 case 6:
576 echo "<b>Step $state</b><br><br>\n";
577 echo "Configuration of Apache web server...<br><br>\n";
578 echo "The \"".realpath($docsDirectory)."\", \"".realpath($billingDirectory)."\" and \"".realpath($billingDirectory2)."\" 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 to end of 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>
589 &nbsp;&nbsp;&lt;Directory ".realpath($billingDirectory2)."&gt;<br>
590 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
591 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
592 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
594 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";
595 echo "<br>We recommend you print these instructions for future reference.<br><br>";
596 echo "Click 'continue' for further instructions.";
598 echo "<br><FORM METHOD='POST'>\n
599 <INPUT TYPE='HIDDEN' NAME='state' VALUE='7'>\n
600 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$iuser'>\n
601 <br>\n
602 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
604 break;
606 case 0:
607 default:
608 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
609 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";
611 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";
613 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>";
615 if ($checkPermissions == "TRUE") {
616 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
617 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
618 $errorWritable = 0;
619 foreach ($writableFileList as $tempFile) {
620 if (is_writable($tempFile)) {
621 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
623 else {
624 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
625 echo "(configure file permissions; see below for further instructions)</p>\n";
626 $errorWritable = 1;
629 if ($errorWritable) {
630 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
631 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
632 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
633 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p></FORM><br>\n";
634 break;
637 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
638 $errorWritable = 0;
639 foreach ($writableDirList as $tempDir) {
640 if (is_writable($tempDir)) {
641 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
643 else {
644 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
645 echo "(configure directory permissions; see below for further instructions)</p>\n";
646 $errorWritable = 1;
649 if ($errorWritable) {
650 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
651 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";
652 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
653 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p></FORM><br>\n";
654 break;
657 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
659 else {
660 echo "<br>Click to continue installation.<br>\n";
663 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'><INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
670 </span>
672 </BODY>
673 </HTML>