AMC changes for summary of care and CPOE, see note below:
[openemr.git] / setup.php
blob4a79a5452c2ae2d388ebe9b95563e82ff4fd6655
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 $COMMAND_LINE = php_sapi_name() == 'cli';
8 require_once (dirname(__FILE__) . '/library/authentication/password_hashing.php');
9 require_once dirname(__FILE__) . '/library/classes/Installer.class.php';
11 //turn off PHP compatibility warnings
12 ini_set("session.bug_compat_warn","off");
14 $state = $_POST["state"];
16 // Make this true for IPPF.
17 $ippf_specific = false;
19 // If this script was invoked with no site ID, then ask for one.
20 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
21 echo "<html>\n";
22 echo "<head>\n";
23 echo "<title>OpenEMR Setup Tool</title>\n";
24 echo "<link rel='stylesheet' href='interface/themes/style_blue.css'>\n";
25 echo "</head>\n";
26 echo "<body>\n";
27 echo "<p><b>Optional Site ID Selection</b></p>\n";
28 echo "<p>Most OpenEMR installations support only one site. If that is " .
29 "true for you then ignore the rest of this text and just click Continue.</p>\n";
30 echo "<p>Otherwise please enter a unique Site ID here.</p>\n";
31 echo "<p>A Site ID is a short identifier with no spaces or special " .
32 "characters other than periods or dashes. It is case-sensitive and we " .
33 "suggest sticking to lower case letters for ease of use.</p>\n";
34 echo "<p>If each site will have its own host/domain name, then use that " .
35 "name as the Site ID (e.g. www.example.com).</p>\n";
36 echo "<p>The site ID is used to identify which site you will log in to. " .
37 "If it is a hostname then it is taken from the hostname in the URL. " .
38 "Otherwise you must append \"?site=<i>siteid</i>\" to the URL used for " .
39 "logging in.</p>\n";
40 echo "<p>It is OK for one of the sites to have \"default\" as its ID. This " .
41 "is the ID that will be used if it cannot otherwise be determined.</p>\n";
42 echo "<form method='post'><input type='hidden' name='state' value='0'>" .
43 "Site ID: <input type='text' name='site' value='default'>&nbsp;" .
44 "<input type='submit' value='Continue'><br></form><br>\n";
45 echo "</body></html>\n";
46 exit();
49 // Support "?site=siteid" in the URL, otherwise assume "default".
50 $site_id = 'default';
51 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
52 $site_id = trim($_REQUEST['site']);
55 // Die if site ID is empty or has invalid characters.
56 if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id))
57 die("Site ID '".htmlspecialchars($site_id,ENT_NOQUOTES)."' contains invalid characters.");
59 //If having problems with file and directory permission
60 // checking, then can be manually disabled here.
61 $checkPermissions = True;
63 $installer = new Installer( $_REQUEST );
64 global $OE_SITE_DIR; // The Installer sets this
66 $docsDirectory = "$OE_SITE_DIR/documents";
67 $billingDirectory = "$OE_SITE_DIR/edi";
68 $billingDirectory2 = "$OE_SITE_DIR/era";
70 $billingLogDirectory = dirname(__FILE__)."/library/freeb";
71 $lettersDirectory = "$OE_SITE_DIR/letter_templates";
72 $gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c";
73 $requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
74 $requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
76 $zendModuleConfigFile = dirname(__FILE__)."/interface/modules/zend_modules/config/application.config.php";
78 //These are files and dir checked before install for
79 // correct permissions.
80 if (is_dir($OE_SITE_DIR)) {
81 $writableFileList = array($installer->conffile,$zendModuleConfigFile);
82 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
84 else {
85 $writableFileList = array();
86 $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
89 // Include the sqlconf file if it exists yet.
90 $config = 0;
91 if (file_exists($OE_SITE_DIR)) {
92 include_once($installer->conffile);
94 else if ($state > 3) {
95 // State 3 should have created the site directory if it is missing.
96 die("Internal error, site directory is missing.");
100 <HTML>
101 <HEAD>
102 <TITLE>OpenEMR Setup Tool</TITLE>
103 <LINK REL=STYLESHEET HREF="interface/themes/style_sky_blue.css">
105 <style>
106 .noclone { }
107 table.phpset { border-collapse:collapse; }
108 table.phpset td, table.phpset th { font-size:9pt; border:1px solid gray; padding:2px; }
109 </style>
111 <script type="text/javascript" src="library/js/jquery.js"></script>
113 <script language="javascript">
114 // onclick handler for "clone database" checkbox
115 function cloneClicked() {
116 var cb = document.forms[0].clone_database;
117 $('.noclone').css('display', cb.checked ? 'none' : 'block');
119 </script>
121 </HEAD>
122 <BODY>
124 <span class="title">OpenEMR Setup</span>
125 <br><br>
126 <span class="text">
128 <?php
129 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
130 echo "It appears that you have register_globals enabled in your php.ini\n" .
131 "configuration file. This causes unacceptable security risks. You must\n" .
132 "turn it off before continuing with installation.\n";
133 exit(1);
136 if(!extension_loaded("xml")) {
137 echo "Error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
138 exit(1);
140 if( !(extension_loaded("mysql") || extension_loaded("mysqlnd") || extension_loaded("mysqli")) ) {
141 echo "Error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
142 exit(1);
144 if( !(extension_loaded("mbstring") ) ) {
145 echo "Error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
146 exit(1);
150 <?php
151 if ($state == 7) {
154 <p>Congratulations! OpenEMR is now installed.</p>
156 <ul>
157 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
158 OpenEMR's admin->acl menu.</li>
159 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
160 contains some settings that you may want to change.</li>
161 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
162 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
163 <li>To ensure a consistent look and feel through out the application using
164 <a href='http://www.mozilla.org/products/firefox/'>Firefox</a> is recommended.</li>
165 <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>
166 <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>
167 </ul>
169 We recommend you print these instructions for future reference.
170 </p>
171 <?php if (empty($installer->clone_database)) {
172 echo "<p><b>The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."'</b></p>";
173 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>";
174 } ?>
176 <a href='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR. </a>
177 </p>
179 <?php
180 exit();
184 <?php
186 $inst = $_POST["inst"];
188 if (($config == 1) && ($state < 4)) {
189 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";
191 else {
192 switch ($state) {
194 case 1:
195 echo "<b>Step $state</b><br><br>\n";
196 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
197 <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>
198 <br><br>\n
199 <FORM METHOD='POST'>\n
200 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
201 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
202 <LABEL FOR='inst1'><INPUT TYPE='RADIO' ID='inst1' NAME='inst' VALUE='1' checked>Have setup create the database</label><br>\n
203 <LABEL FOR='inst2'><INPUT TYPE='RADIO' ID='inst2' NAME='inst' VALUE='2'>I have already created the database</label><br>\n
204 <br>\n
205 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
206 break;
208 case 2:
209 echo "<b>Step $state</b><br><br>\n";
210 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.
211 <br><br>\n
212 <FORM METHOD='POST'>
213 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
214 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
215 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
216 <TABLE>\n
217 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
218 <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>
219 <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>
220 <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>
221 <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>
222 <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";
223 if ($inst != 2) {
224 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>
225 <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";
226 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>";
227 echo "<TR VALIGN='TOP'><TD><span class='text'>UTF-8 Collation: </span></TD><TD colspan='2'>" .
228 "<select name='collate'>" .
229 "<option value='utf8_bin' >Bin</option>" .
230 "<option value='utf8_czech_ci' >Czech</option>" .
231 "<option value='utf8_danish_ci' >Danish</option>" .
232 "<option value='utf8_esperanto_ci' >Esperanto</option>" .
233 "<option value='utf8_estonian_ci' >Estonian</option>" .
234 "<option value='utf8_general_ci' selected>General</option>" .
235 "<option value='utf8_hungarian_ci' >Hungarian</option>" .
236 "<option value='utf8_icelandic_ci' >Icelandic</option>" .
237 "<option value='utf8_latvian_ci' >Latvian</option>" .
238 "<option value='utf8_lithuanian_ci'>Lithuanian</option>" .
239 "<option value='utf8_persian_ci' >Persian</option>" .
240 "<option value='utf8_polish_ci' >Polish</option>" .
241 "<option value='utf8_roman_ci' >Roman</option>" .
242 "<option value='utf8_romanian_ci' >Romanian</option>" .
243 "<option value='utf8_slovak_ci' >Slovak</option>" .
244 "<option value='utf8_slovenian_ci' >Slovenian</option>" .
245 "<option value='utf8_spanish2_ci' >Spanish2 (Traditional)</option>" .
246 "<option value='utf8_spanish_ci' >Spanish (Modern)</option>" .
247 "<option value='utf8_swedish_ci' >Swedish</option>" .
248 "<option value='utf8_turkish_ci' >Turkish</option>" .
249 "<option value='utf8_unicode_ci' >Unicode (German, French, Russian, Armenian, Greek)</option>" .
250 "<option value='' >None (Do not force UTF-8)</option>" .
251 "</select>" .
252 "</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>";
254 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
256 // Include a "source" site ID drop-list and a checkbox to indicate
257 // if cloning its database. When checked, do not display initial user
258 // and group stuff below.
259 $dh = opendir($OE_SITES_BASE);
260 if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
261 $siteslist = array();
262 while (false !== ($sfname = readdir($dh))) {
263 if (substr($sfname, 0, 1) == '.') continue;
264 if ($sfname == 'CVS' ) continue;
265 if ($sfname == $site_id ) continue;
266 $sitedir = "$OE_SITES_BASE/$sfname";
267 if (!is_dir($sitedir) ) continue;
268 if (!is_file("$sitedir/sqlconf.php")) continue;
269 $siteslist[$sfname] = $sfname;
271 closedir($dh);
272 // If this is not the first site...
273 if (!empty($siteslist)) {
274 ksort($siteslist);
275 echo "<tr valign='top'>\n";
276 echo " <td class='text'>Source Site: </td>\n";
277 echo " <td class='text'><select name='source_site_id'>";
278 foreach ($siteslist as $sfname) {
279 echo "<option value='$sfname'";
280 if ($sfname == 'default') echo " selected";
281 echo ">$sfname</option>";
283 echo "</select></td>\n";
284 echo " <td class='text'>(The site directory that will be a model for the new site.)</td>\n";
285 echo "</tr>\n";
286 echo "<tr valign='top'>\n";
287 echo " <td class='text'>Clone Source Database: </td>\n";
288 echo " <td class='text'><input type='checkbox' name='clone_database' onclick='cloneClicked()' /></td>\n";
289 echo " <td class='text'>(Clone the source site's database instead of creating a fresh one.)</td>\n";
290 echo "</tr>\n";
293 echo "<TR VALIGN='TOP' class='noclone'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
294 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>
295 <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>
296 <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>
297 <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>
298 <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>
300 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
302 echo "</TABLE>
303 <br>
304 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
305 break;
307 case 3:
309 // Form Validation
310 // (applicable if not cloning from another database)
311 if (empty($installer->clone_database)) {
312 if ( ! $installer->login_is_valid() ) {
313 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
314 echo "Click Back in browser to re-enter.<br>\n";
315 break;
317 if ( ! $installer->iuser_is_valid() ) {
318 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
319 echo "Click Back in browser to re-enter.<br>\n";
320 break;
322 if ( ! $installer->user_password_is_valid() ) {
323 echo "ERROR. Please pick a proper 'Initial User Password'.<br>\n";
324 echo "Click Back in browser to re-enter.<br>\n";
325 break;
328 if ( ! $installer->password_is_valid() ) {
329 echo "ERROR. Please pick a proper 'Password'.<br>\n";
330 echo "Click Back in browser to re-enter.<br>\n";
331 break;
334 echo "<b>Step $state</b><br><br>\n";
335 echo "Configuring OpenEMR...<br><br>\n";
337 // Skip below if database shell has already been created.
338 if ($inst != 2) {
340 echo "Connecting to MySQL Server...\n";
341 flush();
342 if ( ! $installer->root_database_connection() ) {
343 echo "ERROR. Check your login credentials.\n";
344 echo $installer->error_message;
345 break;
347 else {
348 echo "OK.<br>\n";
349 flush();
353 // Only pertinent if cloning another installation database
354 if ( ! empty($installer->clone_database)) {
356 echo "Dumping source database...";
357 flush();
358 if ( ! $installer->create_dumpfiles() ) {
359 echo $installer->error_message;
360 break;
362 else {
363 echo " OK.<br>\n";
364 flush();
368 // Only pertinent if mirroring another installation directory
369 if ( ! empty($installer->source_site_id)) {
371 echo "Creating site directory...";
372 if ( ! $installer->create_site_directory() ) {
373 echo $installer->error_message;
374 break;
376 else {
377 echo "OK.<BR>";
378 flush();
382 // Skip below if database shell has already been created.
383 if ($inst != 2) {
384 echo "Creating database...\n";
385 flush();
386 if ( ! $installer->create_database() ) {
387 echo "ERROR. Check your login credentials.\n";
388 echo $installer->error_message;
389 break;
390 } else {
391 echo "OK.<br>\n";
392 flush();
395 echo "Creating user with permissions for database...\n";
396 flush();
397 if ( ! $installer->grant_privileges() ) {
398 echo "ERROR when granting privileges to the specified user.\n";
399 echo $installer->error_message;
400 break;
401 } else {
402 echo "OK.<br>\n";
403 flush();
406 echo "Reconnecting as new user...\n";
407 flush();
408 $installer->disconnect();
409 } else {
411 echo "Connecting to MySQL Server...\n";
413 if ( ! $installer->user_database_connection() ) {
414 echo "ERROR. Check your login credentials.\n";
415 echo $installer->error_message;
416 break;
418 else {
419 echo "OK.<br>\n";
420 flush();
423 // Load the database files
424 $dump_results = $installer->load_dumpfiles();
425 if ( ! $dump_results ) {
426 echo $installer->error_message;
427 break;
428 } else {
429 echo $dump_results;
430 flush();
433 echo "Writing SQL configuration...\n";
434 flush();
435 if ( ! $installer->write_configuration_file() ) {
436 echo $installer->error_message;
437 break;
439 else {
440 echo "OK.<br>\n";
441 flush();
444 // Only pertinent if not cloning another installation database
445 if (empty($installer->clone_database)) {
447 echo "Setting version indicators...\n";
448 flush();
449 if ( ! $installer->add_version_info() ) {
450 echo "ERROR.\n";
451 echo $installer->error_message;;
452 break;
454 else {
455 echo "OK<br>\n";
456 flush();
459 echo "Writing global configuration defaults...\n";
460 flush();
461 if ( ! $installer->insert_globals() ) {
462 echo "ERROR.\n";
463 echo $installer->error_message;;
464 break;
466 else {
467 echo "OK<br>\n";
468 flush();
471 echo "Adding Initial User...\n";
472 flush();
473 if ( ! $installer->add_initial_user() ) {
474 echo $installer->error_message;
475 break;
477 echo "OK<br>\n";
478 flush();
481 if ( ! empty($installer->clone_database) ) {
482 // Database was cloned, skip ACL setup.
483 echo "Click 'continue' for further instructions.";
484 $next_state = 7;
486 else {
487 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
488 $next_state = 4;
491 echo "
492 <FORM METHOD='POST'>\n
493 <INPUT TYPE='HIDDEN' NAME='state' VALUE='$next_state'>
494 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
495 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>
496 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>
497 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$installer->iuname'>
498 <INPUT TYPE='HIDDEN' NAME='iufname' VALUE='$installer->iufname'>
499 <INPUT TYPE='HIDDEN' NAME='clone_database' VALUE='$installer->clone_database'>
500 <br>\n
501 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
503 break;
504 case 4:
505 echo "<b>Step $state</b><br><br>\n";
506 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
508 if ( ! $installer->install_gacl() ) {
509 echo $installer->error_message;
510 break;
512 else {
513 // display the status information for gacl setup
514 echo $installer->debug_message;
517 echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.<br><br>";
519 echo "Done installing and configuring access controls (php-GACL).<br>";
520 echo "Next step will configure PHP.";
522 echo "<br><FORM METHOD='POST'>\n
523 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
524 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
525 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
526 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
527 <br>\n
528 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
530 break;
532 case 5:
533 echo "<b>Step $state</b><br><br>\n";
534 echo "Configuration of PHP...<br><br>\n";
535 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
536 echo "<ul>";
537 $gotFileFlag = 0;
538 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
539 $phpINIfile = php_ini_loaded_file();
540 if ($phpINIfile) {
541 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
542 $gotFileFlag = 1;
545 echo "<li>","To ensure proper functioning of OpenEMR you must make sure that PHP settings include:";
546 echo "<table class='phpset'><tr><th>Setting</th><th>Required value</th><th>Current value</th></tr>";
547 echo "<tr><td>short_open_tag </td><td>Off</td><td>", ini_get('short_open_tag')?'On':'Off', "</td></tr>\n";
548 echo "<tr><td>display_errors </td><td>Off</td><td>", ini_get('display_errors')?'On':'Off', "</td></tr>\n";
549 echo "<tr><td>register_globals </td><td>Off</td><td>", ini_get('register_globals')?'On':'Off', "</td></tr>\n";
550 echo "<tr><td>max_input_vars </td><td>at least 3000</td><td>", ini_get('max_input_vars'), "</td></tr>\n";
551 echo "<tr><td>max_execution_time </td><td>at least 60</td><td>", ini_get('max_execution_time'), "</td></tr>\n";
552 echo "<tr><td>max_input_time </td><td>at least 90</td><td>", ini_get('max_input_time'), "</td></tr>\n";
553 echo "<tr><td>post_max_size </td><td>at least 30M</td><td>", ini_get('post_max_size'), "</td></tr>\n";
554 echo "<tr><td>memory_limit </td><td>at least 128M</td><td>", ini_get('memory_limit'), "</td></tr>\n";
555 echo "</table>";
556 echo "</li>";
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='Documentation/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='site' VALUE='$site_id'>\n
570 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
571 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
572 <br>\n
573 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
575 break;
577 case 6:
578 echo "<b>Step $state</b><br><br>\n";
579 echo "Configuration of Apache web server...<br><br>\n";
580 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
581 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>
582 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."\"&gt;<br>
583 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride FileInfo<br>
584 &nbsp;&nbsp;&lt;/Directory&gt;<br>
585 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."/sites\"&gt;<br>
586 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride None<br>
587 &nbsp;&nbsp;&lt;/Directory&gt;<br>
588 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/","*",realpath($docsDirectory))."\"&gt;<br>
589 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
590 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
591 &nbsp;&nbsp;&lt;/Directory&gt;<br>
592 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory))."\"&gt;<br>
593 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
594 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
595 &nbsp;&nbsp;&lt;/Directory&gt;<br>
596 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory2))."\"&gt;<br>
597 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
598 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
599 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
601 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";
602 echo "<br>We recommend you print these instructions for future reference.<br><br>";
603 echo "Click 'continue' for further instructions.";
605 echo "<br><FORM METHOD='POST'>\n
606 <INPUT TYPE='HIDDEN' NAME='state' VALUE='7'>\n
607 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
608 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
609 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
610 <br>\n
611 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
613 break;
615 case 0:
616 default:
617 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
618 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";
620 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";
622 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>";
624 if ($checkPermissions) {
625 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
626 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
627 $errorWritable = 0;
628 foreach ($writableFileList as $tempFile) {
629 if (is_writable($tempFile)) {
630 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
632 else {
633 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
634 echo "(configure file permissions; see below for further instructions)</p>\n";
635 $errorWritable = 1;
638 if ($errorWritable) {
639 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
640 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
641 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
642 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
643 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
644 break;
647 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
648 $errorWritable = 0;
649 foreach ($writableDirList as $tempDir) {
650 if (is_writable($tempDir)) {
651 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
653 else {
654 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
655 echo "(configure directory permissions; see below for further instructions)</p>\n";
656 $errorWritable = 1;
659 if ($errorWritable) {
660 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
661 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";
662 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
663 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
664 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
665 break;
668 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
670 else {
671 echo "<br>Click to continue installation.<br>\n";
674 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'>" .
675 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>" .
676 "<INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
682 </span>
684 </BODY>
685 </HTML>