POS default selection for encounter (#1088)
[openemr.git] / setup.php
blobfa5aa4e7f5e006ea63da74a3847fae6c9f5f4a82
1 <?php
2 /**
3 * Installation script.
5 * Copyright (C) 2016 Roberto Vasquez <robertogagliotta@gmail.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be usefull,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OF FITNESS FOR A PARTICULAR PURPOSE, See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the CNU General Public License
16 * along with this program. If not, see <http://opensource.org/Licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Roberto Vasquez <robertogagliotta@gmail.com>
20 * @author Scott Wakefield <scott@npclinics.com.au>
21 * @link http://www.open-emr.org
23 **/
25 // Checks if the server's PHP version is compatible with OpenEMR:
26 require_once(dirname(__FILE__) . "/common/compatibility/Checker.php");
28 use OpenEMR\Common\Checker;
30 $response = Checker::checkPhpVersion();
31 if ($response !== true) {
32 die($response);
35 $COMMAND_LINE = php_sapi_name() == 'cli';
36 require_once(dirname(__FILE__) . '/library/authentication/password_hashing.php');
37 require_once dirname(__FILE__) . '/library/classes/Installer.class.php';
39 //turn off PHP compatibility warnings
40 ini_set("session.bug_compat_warn", "off");
42 $state = isset($_POST["state"]) ? ($_POST["state"]) : '';
44 // Make this true for IPPF.
45 $ippf_specific = false;
47 // If this script was invoked with no site ID, then ask for one.
48 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
49 echo "<html>\n";
50 echo "<head>\n";
51 echo "<title>OpenEMR Setup Tool</title>\n";
52 echo "<link rel='stylesheet' href='interface/themes/style_blue.css'>\n";
53 echo "</head>\n";
54 echo "<body>\n";
55 echo "<p><b>Optional Site ID Selection</b></p>\n";
56 echo "<p>Most OpenEMR installations support only one site. If that is " .
57 "true for you then ignore the rest of this text and just click Continue.</p>\n";
58 echo "<p>Otherwise please enter a unique Site ID here.</p>\n";
59 echo "<p>A Site ID is a short identifier with no spaces or special " .
60 "characters other than periods or dashes. It is case-sensitive and we " .
61 "suggest sticking to lower case letters for ease of use.</p>\n";
62 echo "<p>If each site will have its own host/domain name, then use that " .
63 "name as the Site ID (e.g. www.example.com).</p>\n";
64 echo "<p>The site ID is used to identify which site you will log in to. " .
65 "If it is a hostname then it is taken from the hostname in the URL. " .
66 "Otherwise you must append \"?site=<i>siteid</i>\" to the URL used for " .
67 "logging in.</p>\n";
68 echo "<p>It is OK for one of the sites to have \"default\" as its ID. This " .
69 "is the ID that will be used if it cannot otherwise be determined.</p>\n";
70 echo "<form method='post'><input type='hidden' name='state' value='0'>" .
71 "Site ID: <input type='text' name='site' value='default'>&nbsp;" .
72 "<input type='submit' value='Continue'><br></form><br>\n";
73 echo "</body></html>\n";
74 exit();
77 // Support "?site=siteid" in the URL, otherwise assume "default".
78 $site_id = 'default';
79 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
80 $site_id = trim($_REQUEST['site']);
83 // Die if site ID is empty or has invalid characters.
84 if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) {
85 die("Site ID '".htmlspecialchars($site_id, ENT_NOQUOTES)."' contains invalid characters.");
88 //If having problems with file and directory permission
89 // checking, then can be manually disabled here.
90 $checkPermissions = true;
92 $installer = new Installer($_REQUEST);
93 global $OE_SITE_DIR; // The Installer sets this
95 $docsDirectory = "$OE_SITE_DIR/documents";
96 $billingDirectory = "$OE_SITE_DIR/edi";
97 $billingDirectory2 = "$OE_SITE_DIR/era";
98 $lettersDirectory = "$OE_SITE_DIR/letter_templates";
99 $gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c";
100 $requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
101 $requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
103 $zendModuleConfigFile = dirname(__FILE__)."/interface/modules/zend_modules/config/application.config.php";
105 //These are files and dir checked before install for
106 // correct permissions.
107 if (is_dir($OE_SITE_DIR)) {
108 $writableFileList = array($installer->conffile,$zendModuleConfigFile);
109 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
110 } else {
111 $writableFileList = array();
112 $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
115 // Include the sqlconf file if it exists yet.
116 $config = 0;
117 if (file_exists($OE_SITE_DIR)) {
118 include_once($installer->conffile);
119 } else if ($state > 3) {
120 // State 3 should have created the site directory if it is missing.
121 die("Internal error, site directory is missing.");
125 <HTML>
126 <HEAD>
127 <TITLE>OpenEMR Setup Tool</TITLE>
128 <LINK REL=STYLESHEET HREF="interface/themes/style_sky_blue.css">
129 <link rel="shortcut icon" href="public/images/favicon.ico" />
131 <style>
132 .noclone { }
133 table.phpset { border-collapse:collapse; }
134 table.phpset td, table.phpset th { font-size:9pt; border:1px solid gray; padding:2px; }
135 </style>
137 <script type="text/javascript" src="public/assets/jquery-min-1-2-2/index.js"></script>
139 <script language="javascript">
140 // onclick handler for "clone database" checkbox
141 function cloneClicked() {
142 var cb = document.forms[0].clone_database;
143 $('.noclone').css('display', cb.checked ? 'none' : 'block');
145 </script>
147 </HEAD>
148 <BODY>
150 <span class="title">OpenEMR Setup</span>
151 <br><br>
152 <span class="text">
153 <?php
154 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
155 echo "It appears that you have register_globals enabled in your php.ini\n" .
156 "configuration file. This causes unacceptable security risks. You must\n" .
157 "turn it off before continuing with installation.\n";
158 exit(1);
161 if (!extension_loaded("xml")) {
162 echo "Error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
163 exit(1);
166 if (!(extension_loaded("mysql") || extension_loaded("mysqlnd") || extension_loaded("mysqli"))) {
167 echo "Error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
168 exit(1);
171 if (!(extension_loaded("mbstring") )) {
172 echo "Error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
173 exit(1);
177 <?php
178 if ($state == 7) {
181 <p>Congratulations! OpenEMR is now installed.</p>
183 <ul>
184 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
185 OpenEMR's admin->acl menu.</li>
186 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
187 contains some settings that you may want to change.</li>
188 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
189 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
190 <li>To ensure a consistent look and feel throughout the application,
191 <a href='http://www.mozilla.org/products/firefox/'>Firefox</a> and <a href="https://www.google.com/chrome/browser/desktop/index.html">Chrome</a> are recommended. The OpenEMR development team exclusively tests with modern versions of these browsers.</li>
192 <li>The OpenEMR project home page, documentation, and forums can be found at <a href = "http://www.open-emr.org" target="_blank">http://www.open-emr.org</a></li>
193 <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:president@oemr.org">president@oemr.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>
194 </ul>
196 We recommend you print these instructions for future reference.
197 </p>
198 <?php if (empty($installer->clone_database)) {
199 echo "<p><b>The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."'</b></p>";
200 echo "<p>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.</p>";
201 } ?>
203 <a href='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR. </a>
204 </p>
206 <?php
207 exit();
211 <?php
213 $inst = isset($_POST["inst"]) ? ($_POST["inst"]) : '';
216 if (($config == 1) && ($state < 4)) {
217 echo "OpenEMR has already been installed. If you wish to force re-installation, then edit $installer->conffile (change the 'config' variable to 0), and re-run this script.<br>\n";
218 } else {
219 switch ($state) {
220 case 1:
221 echo "<b>Step $state</b><br><br>\n";
222 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
223 <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>
224 <br><br>\n
225 <FORM METHOD='POST'>\n
226 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
227 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
228 <LABEL FOR='inst1'><INPUT TYPE='RADIO' ID='inst1' NAME='inst' VALUE='1' checked>Have setup create the database</label><br>\n
229 <LABEL FOR='inst2'><INPUT TYPE='RADIO' ID='inst2' NAME='inst' VALUE='2'>I have already created the database</label><br>\n
230 <br>\n
231 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
232 break;
234 case 2:
235 echo "<b>Step $state</b><br><br>\n";
236 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='Documentation/INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.
237 <br><br>\n
238 <FORM METHOD='POST'>
239 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
240 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
241 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
242 <TABLE>\n
243 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
244 <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>
245 <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>
246 <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>
247 <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>
248 <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";
249 if ($inst != 2) {
250 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>
251 <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";
252 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>";
253 echo "<TR VALIGN='TOP'><TD><span class='text'>UTF-8 Collation: </span></TD><TD colspan='2'>" .
254 "<select name='collate'>" .
255 "<option value='utf8_bin' >Bin</option>" .
256 "<option value='utf8_czech_ci' >Czech</option>" .
257 "<option value='utf8_danish_ci' >Danish</option>" .
258 "<option value='utf8_esperanto_ci' >Esperanto</option>" .
259 "<option value='utf8_estonian_ci' >Estonian</option>" .
260 "<option value='utf8_general_ci' selected>General</option>" .
261 "<option value='utf8_hungarian_ci' >Hungarian</option>" .
262 "<option value='utf8_icelandic_ci' >Icelandic</option>" .
263 "<option value='utf8_latvian_ci' >Latvian</option>" .
264 "<option value='utf8_lithuanian_ci'>Lithuanian</option>" .
265 "<option value='utf8_persian_ci' >Persian</option>" .
266 "<option value='utf8_polish_ci' >Polish</option>" .
267 "<option value='utf8_roman_ci' >Roman</option>" .
268 "<option value='utf8_romanian_ci' >Romanian</option>" .
269 "<option value='utf8_slovak_ci' >Slovak</option>" .
270 "<option value='utf8_slovenian_ci' >Slovenian</option>" .
271 "<option value='utf8_spanish2_ci' >Spanish2 (Traditional)</option>" .
272 "<option value='utf8_spanish_ci' >Spanish (Modern)</option>" .
273 "<option value='utf8_swedish_ci' >Swedish</option>" .
274 "<option value='utf8_turkish_ci' >Turkish</option>" .
275 "<option value='utf8_unicode_ci' >Unicode (German, French, Russian, Armenian, Greek)</option>" .
276 "<option value='' >None (Do not force UTF-8)</option>" .
277 "</select>" .
278 "</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>";
281 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
283 // Include a "source" site ID drop-list and a checkbox to indicate
284 // if cloning its database. When checked, do not display initial user
285 // and group stuff below.
286 $dh = opendir($OE_SITES_BASE);
287 if (!$dh) {
288 die("Cannot read directory '$OE_SITES_BASE'.");
291 $siteslist = array();
292 while (false !== ($sfname = readdir($dh))) {
293 if (substr($sfname, 0, 1) == '.') {
294 continue;
297 if ($sfname == 'CVS') {
298 continue;
301 if ($sfname == $site_id) {
302 continue;
305 $sitedir = "$OE_SITES_BASE/$sfname";
306 if (!is_dir($sitedir)) {
307 continue;
310 if (!is_file("$sitedir/sqlconf.php")) {
311 continue;
314 $siteslist[$sfname] = $sfname;
317 closedir($dh);
318 // If this is not the first site...
319 if (!empty($siteslist)) {
320 ksort($siteslist);
321 echo "<tr valign='top'>\n";
322 echo " <td class='text'>Source Site: </td>\n";
323 echo " <td class='text'><select name='source_site_id'>";
324 foreach ($siteslist as $sfname) {
325 echo "<option value='$sfname'";
326 if ($sfname == 'default') {
327 echo " selected";
330 echo ">$sfname</option>";
333 echo "</select></td>\n";
334 echo " <td class='text'>(The site directory that will be a model for the new site.)</td>\n";
335 echo "</tr>\n";
336 echo "<tr valign='top'>\n";
337 echo " <td class='text'>Clone Source Database: </td>\n";
338 echo " <td class='text'><input type='checkbox' name='clone_database' onclick='cloneClicked()' /></td>\n";
339 echo " <td class='text'>(Clone the source site's database instead of creating a fresh one.)</td>\n";
340 echo "</tr>\n";
343 echo "<TR VALIGN='TOP' class='noclone'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
344 echo "<TR VALIGN='TOP' class='noclone'><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>
345 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User Password:</span></TD><TD><INPUT SIZE='30' TYPE='PASSWORD' NAME='iuserpass' VALUE=''></TD><TD><span class='text'>(This is the password for the initial user account above.)</span></TD></TR>
346 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User's First Name:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iufname' VALUE='Administrator'></TD><TD><span class='text'>(This is the First name of the 'initial user'.)</span></TD></TR>
347 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User's Last Name:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuname' VALUE='Administrator'></TD><TD><span class='text'>(This is the Last name of the 'initial user'.)</span></TD></TR>
348 <TR VALIGN='TOP' class='noclone'><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>
350 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
352 echo "</TABLE>
353 <br>
354 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
355 break;
357 case 3:
358 // Form Validation
359 // (applicable if not cloning from another database)
361 $pass_step2_validation = true;
362 $error_step2_message = "ERROR at ";
364 if (! $installer->char_is_valid($_REQUEST['server'])) {
365 $pass_step2_validation = false;
366 $error_step2_message .= "Database Server Host, ";
369 if (! $installer->char_is_valid($_REQUEST['port'])) {
370 $pass_step2_validation = false;
371 $error_step2_message .= "Database Server Port, ";
374 if (! $installer->char_is_valid($_REQUEST['dbname'])) {
375 $pass_step2_validation = false;
376 $error_step2_message .= "Database Name, ";
379 if (! $installer->char_is_valid($_REQUEST['login'])) {
380 $pass_step2_validation = false;
381 $error_step2_message .= "Database Login Name, ";
384 if (! $installer->char_is_valid($_REQUEST['pass'])) {
385 $pass_step2_validation = false;
386 $error_step2_message .= "Database Login Password, ";
389 if (!$pass_step2_validation) {
390 die($error_step2_message);
394 if (empty($installer->clone_database)) {
395 if (! $installer->login_is_valid()) {
396 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
397 echo "Click Back in browser to re-enter.<br>\n";
398 break;
401 if (! $installer->iuser_is_valid()) {
402 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
403 echo "Click Back in browser to re-enter.<br>\n";
404 break;
407 if (! $installer->user_password_is_valid()) {
408 echo "ERROR. Please pick a proper 'Initial User Password'.<br>\n";
409 echo "Click Back in browser to re-enter.<br>\n";
410 break;
414 if (! $installer->password_is_valid()) {
415 echo "ERROR. Please pick a proper 'Password'.<br>\n";
416 echo "Click Back in browser to re-enter.<br>\n";
417 break;
420 echo "<b>Step $state</b><br><br>\n";
421 echo "Configuring OpenEMR...<br><br>\n";
423 // Skip below if database shell has already been created.
424 if ($inst != 2) {
425 echo "Connecting to MySQL Server...\n";
426 flush();
427 if (! $installer->root_database_connection()) {
428 echo "ERROR. Check your login credentials.\n";
429 echo $installer->error_message;
430 break;
431 } else {
432 echo "OK.<br>\n";
433 flush();
437 // Only pertinent if cloning another installation database
438 if (! empty($installer->clone_database)) {
439 echo "Dumping source database...";
440 flush();
441 if (! $installer->create_dumpfiles()) {
442 echo $installer->error_message;
443 break;
444 } else {
445 echo " OK.<br>\n";
446 flush();
450 // Only pertinent if mirroring another installation directory
451 if (! empty($installer->source_site_id)) {
452 echo "Creating site directory...";
453 if (! $installer->create_site_directory()) {
454 echo $installer->error_message;
455 break;
456 } else {
457 echo "OK.<BR>";
458 flush();
462 // Skip below if database shell has already been created.
463 if ($inst != 2) {
464 echo "Creating database...\n";
465 flush();
466 if (! $installer->create_database()) {
467 echo "ERROR. Check your login credentials.\n";
468 echo $installer->error_message;
469 break;
470 } else {
471 echo "OK.<br>\n";
472 flush();
475 echo "Creating user with permissions for database...\n";
476 flush();
477 if (! $installer->grant_privileges()) {
478 echo "ERROR when granting privileges to the specified user.\n";
479 echo $installer->error_message;
480 break;
481 } else {
482 echo "OK.<br>\n";
483 flush();
486 echo "Reconnecting as new user...\n";
487 flush();
488 $installer->disconnect();
489 } else {
490 echo "Connecting to MySQL Server...\n";
493 if (! $installer->user_database_connection()) {
494 echo "ERROR. Check your login credentials.\n";
495 echo $installer->error_message;
496 break;
497 } else {
498 echo "OK.<br>\n";
499 flush();
502 // Load the database files
503 $dump_results = $installer->load_dumpfiles();
504 if (! $dump_results) {
505 echo $installer->error_message;
506 break;
507 } else {
508 echo $dump_results;
509 flush();
512 echo "Writing SQL configuration...\n";
513 flush();
514 if (! $installer->write_configuration_file()) {
515 echo $installer->error_message;
516 break;
517 } else {
518 echo "OK.<br>\n";
519 flush();
522 // Only pertinent if not cloning another installation database
523 if (empty($installer->clone_database)) {
524 echo "Setting version indicators...\n";
525 flush();
526 if (! $installer->add_version_info()) {
527 echo "ERROR.\n";
528 echo $installer->error_message;
530 break;
531 } else {
532 echo "OK<br>\n";
533 flush();
536 echo "Writing global configuration defaults...\n";
537 flush();
538 if (! $installer->insert_globals()) {
539 echo "ERROR.\n";
540 echo $installer->error_message;
542 break;
543 } else {
544 echo "OK<br>\n";
545 flush();
548 echo "Adding Initial User...\n";
549 flush();
550 if (! $installer->add_initial_user()) {
551 echo $installer->error_message;
552 break;
555 echo "OK<br>\n";
556 flush();
559 if (! empty($installer->clone_database)) {
560 // Database was cloned, skip ACL setup.
561 echo "Click 'continue' for further instructions.";
562 $next_state = 7;
563 } else {
564 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
565 $next_state = 4;
568 echo "
569 <FORM METHOD='POST'>\n
570 <INPUT TYPE='HIDDEN' NAME='state' VALUE='$next_state'>
571 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
572 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>
573 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>
574 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$installer->iuname'>
575 <INPUT TYPE='HIDDEN' NAME='iufname' VALUE='$installer->iufname'>
576 <INPUT TYPE='HIDDEN' NAME='clone_database' VALUE='$installer->clone_database'>
577 <br>\n
578 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
580 break;
581 case 4:
582 echo "<b>Step $state</b><br><br>\n";
583 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
585 if (! $installer->install_gacl()) {
586 echo $installer->error_message;
587 break;
588 } else {
589 // display the status information for gacl setup
590 echo $installer->debug_message;
593 echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.<br><br>";
595 echo "Done installing and configuring access controls (php-GACL).<br>";
596 echo "Next step will configure PHP.";
598 echo "<br><FORM METHOD='POST'>\n
599 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
600 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
601 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
602 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
603 <br>\n
604 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
606 break;
608 case 5:
609 echo "<b>Step $state</b><br><br>\n";
610 echo "Configuration of PHP...<br><br>\n";
611 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
612 echo "<ul>";
613 $gotFileFlag = 0;
614 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
615 $phpINIfile = php_ini_loaded_file();
616 if ($phpINIfile) {
617 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
618 $gotFileFlag = 1;
622 echo "<li>","To ensure proper functioning of OpenEMR you must make sure that PHP settings include:";
623 echo "<table class='phpset'><tr><th>Setting</th><th>Required value</th><th>Current value</th></tr>";
624 echo "<tr><td>short_open_tag </td><td>Off</td><td>", ini_get('short_open_tag')?'On':'Off', "</td></tr>\n";
625 echo "<tr><td>display_errors </td><td>Off</td><td>", ini_get('display_errors')?'On':'Off', "</td></tr>\n";
626 echo "<tr><td>register_globals </td><td>Off</td><td>", ini_get('register_globals')?'On':'Off', "</td></tr>\n";
627 echo "<tr><td>max_input_vars </td><td>at least 3000</td><td>", ini_get('max_input_vars'), "</td></tr>\n";
628 echo "<tr><td>max_execution_time </td><td>at least 60</td><td>", ini_get('max_execution_time'), "</td></tr>\n";
629 echo "<tr><td>max_input_time </td><td>at least 90</td><td>", ini_get('max_input_time'), "</td></tr>\n";
630 echo "<tr><td>post_max_size </td><td>at least 30M</td><td>", ini_get('post_max_size'), "</td></tr>\n";
631 echo "<tr><td>memory_limit </td><td>at least 128M</td><td>", ini_get('memory_limit'), "</td></tr>\n";
632 echo "</table>";
633 echo "</li>";
635 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";
636 if (!$gotFileFlag) {
637 echo "<li>If you are having difficulty finding your php.ini file, then refer to the <a href='Documentation/INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.</li>\n";
640 echo "</ul>";
642 echo "<br>We recommend you print these instructions for future reference.<br><br>";
643 echo "Next step will configure Apache web server.";
645 echo "<br><FORM METHOD='POST'>\n
646 <INPUT TYPE='HIDDEN' NAME='state' VALUE='6'>\n
647 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
648 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
649 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
650 <br>\n
651 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
653 break;
655 case 6:
656 echo "<b>Step $state</b><br><br>\n";
657 echo "Configuration of Apache web server...<br><br>\n";
658 echo "The \"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\", \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory))."\" and \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory2))."\" directories contain patient information, and
659 it is important to secure these directories. Additionally, some settings are required for the Zend Framework to work in OpenEMR. This can be done by pasting the below to end of your apache configuration file:<br>
660 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."\"&gt;<br>
661 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride FileInfo<br>
662 &nbsp;&nbsp;&lt;/Directory&gt;<br>
663 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."/sites\"&gt;<br>
664 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride None<br>
665 &nbsp;&nbsp;&lt;/Directory&gt;<br>
666 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\"&gt;<br>
667 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
668 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
669 &nbsp;&nbsp;&lt;/Directory&gt;<br>
670 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory))."\"&gt;<br>
671 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
672 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
673 &nbsp;&nbsp;&lt;/Directory&gt;<br>
674 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory2))."\"&gt;<br>
675 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
676 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
677 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
679 echo "If you are having difficulty finding your apache configuration file, then refer to the <a href='Documentation/INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.<br><br>\n";
680 echo "<br>We recommend you print these instructions for future reference.<br><br>";
681 echo "Click 'continue' for further instructions.";
683 echo "<br><FORM METHOD='POST'>\n
684 <INPUT TYPE='HIDDEN' NAME='state' VALUE='7'>\n
685 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
686 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
687 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
688 <br>\n
689 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
691 break;
693 case 0:
694 default:
695 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
696 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";
698 echo "<li>Detailed installation instructions can be found in the <a href='Documentation/INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li>\n";
700 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='Documentation/INSTALL' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li></ul>";
702 if ($checkPermissions) {
703 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
704 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
705 $errorWritable = 0;
706 foreach ($writableFileList as $tempFile) {
707 if (is_writable($tempFile)) {
708 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
709 } else {
710 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
711 echo "(configure file permissions; see below for further instructions)</p>\n";
712 $errorWritable = 1;
716 if ($errorWritable) {
717 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
718 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
719 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
720 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
721 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
722 break;
725 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
726 $errorWritable = 0;
727 foreach ($writableDirList as $tempDir) {
728 if (is_writable($tempDir)) {
729 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
730 } else {
731 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
732 echo "(configure directory permissions; see below for further instructions)</p>\n";
733 $errorWritable = 1;
737 if ($errorWritable) {
738 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
739 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";
740 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
741 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
742 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
743 break;
746 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
747 } else {
748 echo "<br>Click to continue installation.<br>\n";
751 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'>" .
752 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>" .
753 "<INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
758 </span>
760 </BODY>
761 </HTML>