Email change of a developer (#503)
[openemr.git] / setup.php
blob78a774b67d1adcd77c44b43dd1c2c4ec9bacb7dc
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 $response = Checker::checkPhpVersion();
29 if ($response !== true) {
30 die($response);
33 $COMMAND_LINE = php_sapi_name() == 'cli';
34 require_once (dirname(__FILE__) . '/library/authentication/password_hashing.php');
35 require_once dirname(__FILE__) . '/library/classes/Installer.class.php';
37 //turn off PHP compatibility warnings
38 ini_set("session.bug_compat_warn","off");
40 $state = isset($_POST["state"]) ? ($_POST["state"]) : '';
42 // Make this true for IPPF.
43 $ippf_specific = false;
45 // If this script was invoked with no site ID, then ask for one.
46 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
47 echo "<html>\n";
48 echo "<head>\n";
49 echo "<title>OpenEMR Setup Tool</title>\n";
50 echo "<link rel='stylesheet' href='interface/themes/style_blue.css'>\n";
51 echo "</head>\n";
52 echo "<body>\n";
53 echo "<p><b>Optional Site ID Selection</b></p>\n";
54 echo "<p>Most OpenEMR installations support only one site. If that is " .
55 "true for you then ignore the rest of this text and just click Continue.</p>\n";
56 echo "<p>Otherwise please enter a unique Site ID here.</p>\n";
57 echo "<p>A Site ID is a short identifier with no spaces or special " .
58 "characters other than periods or dashes. It is case-sensitive and we " .
59 "suggest sticking to lower case letters for ease of use.</p>\n";
60 echo "<p>If each site will have its own host/domain name, then use that " .
61 "name as the Site ID (e.g. www.example.com).</p>\n";
62 echo "<p>The site ID is used to identify which site you will log in to. " .
63 "If it is a hostname then it is taken from the hostname in the URL. " .
64 "Otherwise you must append \"?site=<i>siteid</i>\" to the URL used for " .
65 "logging in.</p>\n";
66 echo "<p>It is OK for one of the sites to have \"default\" as its ID. This " .
67 "is the ID that will be used if it cannot otherwise be determined.</p>\n";
68 echo "<form method='post'><input type='hidden' name='state' value='0'>" .
69 "Site ID: <input type='text' name='site' value='default'>&nbsp;" .
70 "<input type='submit' value='Continue'><br></form><br>\n";
71 echo "</body></html>\n";
72 exit();
75 // Support "?site=siteid" in the URL, otherwise assume "default".
76 $site_id = 'default';
77 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
78 $site_id = trim($_REQUEST['site']);
81 // Die if site ID is empty or has invalid characters.
82 if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id))
83 die("Site ID '".htmlspecialchars($site_id,ENT_NOQUOTES)."' contains invalid characters.");
85 //If having problems with file and directory permission
86 // checking, then can be manually disabled here.
87 $checkPermissions = True;
89 $installer = new Installer( $_REQUEST );
90 global $OE_SITE_DIR; // The Installer sets this
92 $docsDirectory = "$OE_SITE_DIR/documents";
93 $billingDirectory = "$OE_SITE_DIR/edi";
94 $billingDirectory2 = "$OE_SITE_DIR/era";
95 $lettersDirectory = "$OE_SITE_DIR/letter_templates";
96 $gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c";
97 $requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
98 $requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
100 $zendModuleConfigFile = dirname(__FILE__)."/interface/modules/zend_modules/config/application.config.php";
102 //These are files and dir checked before install for
103 // correct permissions.
104 if (is_dir($OE_SITE_DIR)) {
105 $writableFileList = array($installer->conffile,$zendModuleConfigFile);
106 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
108 else {
109 $writableFileList = array();
110 $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
113 // Include the sqlconf file if it exists yet.
114 $config = 0;
115 if (file_exists($OE_SITE_DIR)) {
116 include_once($installer->conffile);
118 else if ($state > 3) {
119 // State 3 should have created the site directory if it is missing.
120 die("Internal error, site directory is missing.");
124 <HTML>
125 <HEAD>
126 <TITLE>OpenEMR Setup Tool</TITLE>
127 <LINK REL=STYLESHEET HREF="interface/themes/style_sky_blue.css">
128 <link rel="shortcut icon" href="public/images/favicon.ico" />
130 <style>
131 .noclone { }
132 table.phpset { border-collapse:collapse; }
133 table.phpset td, table.phpset th { font-size:9pt; border:1px solid gray; padding:2px; }
134 </style>
136 <script type="text/javascript" src="public/assets/jquery-min-1-2-1/index.js"></script>
138 <script language="javascript">
139 // onclick handler for "clone database" checkbox
140 function cloneClicked() {
141 var cb = document.forms[0].clone_database;
142 $('.noclone').css('display', cb.checked ? 'none' : 'block');
144 </script>
146 </HEAD>
147 <BODY>
149 <span class="title">OpenEMR Setup</span>
150 <br><br>
151 <span class="text">
152 <?php
153 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
154 echo "It appears that you have register_globals enabled in your php.ini\n" .
155 "configuration file. This causes unacceptable security risks. You must\n" .
156 "turn it off before continuing with installation.\n";
157 exit(1);
160 if(!extension_loaded("xml")) {
161 echo "Error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
162 exit(1);
164 if( !(extension_loaded("mysql") || extension_loaded("mysqlnd") || extension_loaded("mysqli")) ) {
165 echo "Error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
166 exit(1);
168 if( !(extension_loaded("mbstring") ) ) {
169 echo "Error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
170 exit(1);
174 <?php
175 if ($state == 7) {
178 <p>Congratulations! OpenEMR is now installed.</p>
180 <ul>
181 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
182 OpenEMR's admin->acl menu.</li>
183 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
184 contains some settings that you may want to change.</li>
185 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
186 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
187 <li>To ensure a consistent look and feel throughout the application,
188 <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>
189 <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>
190 <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>
191 </ul>
193 We recommend you print these instructions for future reference.
194 </p>
195 <?php if (empty($installer->clone_database)) {
196 echo "<p><b>The initial OpenEMR user is '".$installer->iuser."' and the password is '".$installer->iuserpass."'</b></p>";
197 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>";
198 } ?>
200 <a href='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR. </a>
201 </p>
203 <?php
204 exit();
208 <?php
210 $inst = isset($_POST["inst"]) ? ($_POST["inst"]) : '';
213 if (($config == 1) && ($state < 4)) {
214 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";
216 else {
217 switch ($state) {
219 case 1:
220 echo "<b>Step $state</b><br><br>\n";
221 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
222 <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>
223 <br><br>\n
224 <FORM METHOD='POST'>\n
225 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
226 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
227 <LABEL FOR='inst1'><INPUT TYPE='RADIO' ID='inst1' NAME='inst' VALUE='1' checked>Have setup create the database</label><br>\n
228 <LABEL FOR='inst2'><INPUT TYPE='RADIO' ID='inst2' NAME='inst' VALUE='2'>I have already created the database</label><br>\n
229 <br>\n
230 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
231 break;
233 case 2:
234 echo "<b>Step $state</b><br><br>\n";
235 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.
236 <br><br>\n
237 <FORM METHOD='POST'>
238 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
239 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
240 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
241 <TABLE>\n
242 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
243 <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>
244 <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>
245 <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>
246 <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>
247 <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";
248 if ($inst != 2) {
249 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>
250 <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";
251 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>";
252 echo "<TR VALIGN='TOP'><TD><span class='text'>UTF-8 Collation: </span></TD><TD colspan='2'>" .
253 "<select name='collate'>" .
254 "<option value='utf8_bin' >Bin</option>" .
255 "<option value='utf8_czech_ci' >Czech</option>" .
256 "<option value='utf8_danish_ci' >Danish</option>" .
257 "<option value='utf8_esperanto_ci' >Esperanto</option>" .
258 "<option value='utf8_estonian_ci' >Estonian</option>" .
259 "<option value='utf8_general_ci' selected>General</option>" .
260 "<option value='utf8_hungarian_ci' >Hungarian</option>" .
261 "<option value='utf8_icelandic_ci' >Icelandic</option>" .
262 "<option value='utf8_latvian_ci' >Latvian</option>" .
263 "<option value='utf8_lithuanian_ci'>Lithuanian</option>" .
264 "<option value='utf8_persian_ci' >Persian</option>" .
265 "<option value='utf8_polish_ci' >Polish</option>" .
266 "<option value='utf8_roman_ci' >Roman</option>" .
267 "<option value='utf8_romanian_ci' >Romanian</option>" .
268 "<option value='utf8_slovak_ci' >Slovak</option>" .
269 "<option value='utf8_slovenian_ci' >Slovenian</option>" .
270 "<option value='utf8_spanish2_ci' >Spanish2 (Traditional)</option>" .
271 "<option value='utf8_spanish_ci' >Spanish (Modern)</option>" .
272 "<option value='utf8_swedish_ci' >Swedish</option>" .
273 "<option value='utf8_turkish_ci' >Turkish</option>" .
274 "<option value='utf8_unicode_ci' >Unicode (German, French, Russian, Armenian, Greek)</option>" .
275 "<option value='' >None (Do not force UTF-8)</option>" .
276 "</select>" .
277 "</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>";
279 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
281 // Include a "source" site ID drop-list and a checkbox to indicate
282 // if cloning its database. When checked, do not display initial user
283 // and group stuff below.
284 $dh = opendir($OE_SITES_BASE);
285 if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
286 $siteslist = array();
287 while (false !== ($sfname = readdir($dh))) {
288 if (substr($sfname, 0, 1) == '.') continue;
289 if ($sfname == 'CVS' ) continue;
290 if ($sfname == $site_id ) continue;
291 $sitedir = "$OE_SITES_BASE/$sfname";
292 if (!is_dir($sitedir) ) continue;
293 if (!is_file("$sitedir/sqlconf.php")) continue;
294 $siteslist[$sfname] = $sfname;
296 closedir($dh);
297 // If this is not the first site...
298 if (!empty($siteslist)) {
299 ksort($siteslist);
300 echo "<tr valign='top'>\n";
301 echo " <td class='text'>Source Site: </td>\n";
302 echo " <td class='text'><select name='source_site_id'>";
303 foreach ($siteslist as $sfname) {
304 echo "<option value='$sfname'";
305 if ($sfname == 'default') echo " selected";
306 echo ">$sfname</option>";
308 echo "</select></td>\n";
309 echo " <td class='text'>(The site directory that will be a model for the new site.)</td>\n";
310 echo "</tr>\n";
311 echo "<tr valign='top'>\n";
312 echo " <td class='text'>Clone Source Database: </td>\n";
313 echo " <td class='text'><input type='checkbox' name='clone_database' onclick='cloneClicked()' /></td>\n";
314 echo " <td class='text'>(Clone the source site's database instead of creating a fresh one.)</td>\n";
315 echo "</tr>\n";
318 echo "<TR VALIGN='TOP' class='noclone'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
319 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>
320 <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>
321 <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>
322 <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>
323 <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>
325 echo "<TR VALIGN='TOP'><TD>&nbsp;</TD></TR>";
327 echo "</TABLE>
328 <br>
329 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
330 break;
332 case 3:
334 // Form Validation
335 // (applicable if not cloning from another database)
337 $pass_step2_validation = TRUE;
338 $error_step2_message = "ERROR at ";
340 if ( ! $installer->char_is_valid($_REQUEST['server'])) {
341 $pass_step2_validation = FALSE;
342 $error_step2_message .= "Database Server Host, ";
345 if ( ! $installer->char_is_valid($_REQUEST['port'])) {
346 $pass_step2_validation = FALSE;
347 $error_step2_message .= "Database Server Port, ";
349 if ( ! $installer->char_is_valid($_REQUEST['dbname'])) {
350 $pass_step2_validation = FALSE;
351 $error_step2_message .= "Database Name, ";
353 if ( ! $installer->char_is_valid($_REQUEST['login'])) {
354 $pass_step2_validation = FALSE;
355 $error_step2_message .= "Database Login Name, ";
357 if ( ! $installer->char_is_valid($_REQUEST['pass'])) {
358 $pass_step2_validation = FALSE;
359 $error_step2_message .= "Database Login Password, ";
361 if (!$pass_step2_validation) {
362 die($error_step2_message);
366 if (empty($installer->clone_database)) {
367 if ( ! $installer->login_is_valid() ) {
368 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
369 echo "Click Back in browser to re-enter.<br>\n";
370 break;
372 if ( ! $installer->iuser_is_valid() ) {
373 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
374 echo "Click Back in browser to re-enter.<br>\n";
375 break;
377 if ( ! $installer->user_password_is_valid() ) {
378 echo "ERROR. Please pick a proper 'Initial User Password'.<br>\n";
379 echo "Click Back in browser to re-enter.<br>\n";
380 break;
383 if ( ! $installer->password_is_valid() ) {
384 echo "ERROR. Please pick a proper 'Password'.<br>\n";
385 echo "Click Back in browser to re-enter.<br>\n";
386 break;
389 echo "<b>Step $state</b><br><br>\n";
390 echo "Configuring OpenEMR...<br><br>\n";
392 // Skip below if database shell has already been created.
393 if ($inst != 2) {
395 echo "Connecting to MySQL Server...\n";
396 flush();
397 if ( ! $installer->root_database_connection() ) {
398 echo "ERROR. Check your login credentials.\n";
399 echo $installer->error_message;
400 break;
402 else {
403 echo "OK.<br>\n";
404 flush();
408 // Only pertinent if cloning another installation database
409 if ( ! empty($installer->clone_database)) {
411 echo "Dumping source database...";
412 flush();
413 if ( ! $installer->create_dumpfiles() ) {
414 echo $installer->error_message;
415 break;
417 else {
418 echo " OK.<br>\n";
419 flush();
423 // Only pertinent if mirroring another installation directory
424 if ( ! empty($installer->source_site_id)) {
426 echo "Creating site directory...";
427 if ( ! $installer->create_site_directory() ) {
428 echo $installer->error_message;
429 break;
431 else {
432 echo "OK.<BR>";
433 flush();
437 // Skip below if database shell has already been created.
438 if ($inst != 2) {
439 echo "Creating database...\n";
440 flush();
441 if ( ! $installer->create_database() ) {
442 echo "ERROR. Check your login credentials.\n";
443 echo $installer->error_message;
444 break;
445 } else {
446 echo "OK.<br>\n";
447 flush();
450 echo "Creating user with permissions for database...\n";
451 flush();
452 if ( ! $installer->grant_privileges() ) {
453 echo "ERROR when granting privileges to the specified user.\n";
454 echo $installer->error_message;
455 break;
456 } else {
457 echo "OK.<br>\n";
458 flush();
461 echo "Reconnecting as new user...\n";
462 flush();
463 $installer->disconnect();
464 } else {
466 echo "Connecting to MySQL Server...\n";
468 if ( ! $installer->user_database_connection() ) {
469 echo "ERROR. Check your login credentials.\n";
470 echo $installer->error_message;
471 break;
473 else {
474 echo "OK.<br>\n";
475 flush();
478 // Load the database files
479 $dump_results = $installer->load_dumpfiles();
480 if ( ! $dump_results ) {
481 echo $installer->error_message;
482 break;
483 } else {
484 echo $dump_results;
485 flush();
488 echo "Writing SQL configuration...\n";
489 flush();
490 if ( ! $installer->write_configuration_file() ) {
491 echo $installer->error_message;
492 break;
494 else {
495 echo "OK.<br>\n";
496 flush();
499 // Only pertinent if not cloning another installation database
500 if (empty($installer->clone_database)) {
502 echo "Setting version indicators...\n";
503 flush();
504 if ( ! $installer->add_version_info() ) {
505 echo "ERROR.\n";
506 echo $installer->error_message;;
507 break;
509 else {
510 echo "OK<br>\n";
511 flush();
514 echo "Writing global configuration defaults...\n";
515 flush();
516 if ( ! $installer->insert_globals() ) {
517 echo "ERROR.\n";
518 echo $installer->error_message;;
519 break;
521 else {
522 echo "OK<br>\n";
523 flush();
526 echo "Adding Initial User...\n";
527 flush();
528 if ( ! $installer->add_initial_user() ) {
529 echo $installer->error_message;
530 break;
532 echo "OK<br>\n";
533 flush();
536 if ( ! empty($installer->clone_database) ) {
537 // Database was cloned, skip ACL setup.
538 echo "Click 'continue' for further instructions.";
539 $next_state = 7;
541 else {
542 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
543 $next_state = 4;
546 echo "
547 <FORM METHOD='POST'>\n
548 <INPUT TYPE='HIDDEN' NAME='state' VALUE='$next_state'>
549 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
550 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>
551 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>
552 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$installer->iuname'>
553 <INPUT TYPE='HIDDEN' NAME='iufname' VALUE='$installer->iufname'>
554 <INPUT TYPE='HIDDEN' NAME='clone_database' VALUE='$installer->clone_database'>
555 <br>\n
556 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
558 break;
559 case 4:
560 echo "<b>Step $state</b><br><br>\n";
561 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
563 if ( ! $installer->install_gacl() ) {
564 echo $installer->error_message;
565 break;
567 else {
568 // display the status information for gacl setup
569 echo $installer->debug_message;
572 echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.<br><br>";
574 echo "Done installing and configuring access controls (php-GACL).<br>";
575 echo "Next step will configure PHP.";
577 echo "<br><FORM METHOD='POST'>\n
578 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
579 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
580 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
581 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
582 <br>\n
583 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
585 break;
587 case 5:
588 echo "<b>Step $state</b><br><br>\n";
589 echo "Configuration of PHP...<br><br>\n";
590 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
591 echo "<ul>";
592 $gotFileFlag = 0;
593 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
594 $phpINIfile = php_ini_loaded_file();
595 if ($phpINIfile) {
596 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
597 $gotFileFlag = 1;
600 echo "<li>","To ensure proper functioning of OpenEMR you must make sure that PHP settings include:";
601 echo "<table class='phpset'><tr><th>Setting</th><th>Required value</th><th>Current value</th></tr>";
602 echo "<tr><td>short_open_tag </td><td>Off</td><td>", ini_get('short_open_tag')?'On':'Off', "</td></tr>\n";
603 echo "<tr><td>display_errors </td><td>Off</td><td>", ini_get('display_errors')?'On':'Off', "</td></tr>\n";
604 echo "<tr><td>register_globals </td><td>Off</td><td>", ini_get('register_globals')?'On':'Off', "</td></tr>\n";
605 echo "<tr><td>max_input_vars </td><td>at least 3000</td><td>", ini_get('max_input_vars'), "</td></tr>\n";
606 echo "<tr><td>max_execution_time </td><td>at least 60</td><td>", ini_get('max_execution_time'), "</td></tr>\n";
607 echo "<tr><td>max_input_time </td><td>at least 90</td><td>", ini_get('max_input_time'), "</td></tr>\n";
608 echo "<tr><td>post_max_size </td><td>at least 30M</td><td>", ini_get('post_max_size'), "</td></tr>\n";
609 echo "<tr><td>memory_limit </td><td>at least 128M</td><td>", ini_get('memory_limit'), "</td></tr>\n";
610 echo "</table>";
611 echo "</li>";
613 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";
614 if (!$gotFileFlag) {
615 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";
617 echo "</ul>";
619 echo "<br>We recommend you print these instructions for future reference.<br><br>";
620 echo "Next step will configure Apache web server.";
622 echo "<br><FORM METHOD='POST'>\n
623 <INPUT TYPE='HIDDEN' NAME='state' VALUE='6'>\n
624 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
625 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
626 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
627 <br>\n
628 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
630 break;
632 case 6:
633 echo "<b>Step $state</b><br><br>\n";
634 echo "Configuration of Apache web server...<br><br>\n";
635 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
636 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>
637 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."\"&gt;<br>
638 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride FileInfo<br>
639 &nbsp;&nbsp;&lt;/Directory&gt;<br>
640 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."/sites\"&gt;<br>
641 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride None<br>
642 &nbsp;&nbsp;&lt;/Directory&gt;<br>
643 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/","*",realpath($docsDirectory))."\"&gt;<br>
644 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
645 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
646 &nbsp;&nbsp;&lt;/Directory&gt;<br>
647 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory))."\"&gt;<br>
648 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
649 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
650 &nbsp;&nbsp;&lt;/Directory&gt;<br>
651 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/","*",realpath($billingDirectory2))."\"&gt;<br>
652 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
653 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
654 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
656 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";
657 echo "<br>We recommend you print these instructions for future reference.<br><br>";
658 echo "Click 'continue' for further instructions.";
660 echo "<br><FORM METHOD='POST'>\n
661 <INPUT TYPE='HIDDEN' NAME='state' VALUE='7'>\n
662 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
663 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
664 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
665 <br>\n
666 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
668 break;
670 case 0:
671 default:
672 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
673 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";
675 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";
677 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>";
679 if ($checkPermissions) {
680 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
681 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
682 $errorWritable = 0;
683 foreach ($writableFileList as $tempFile) {
684 if (is_writable($tempFile)) {
685 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
687 else {
688 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
689 echo "(configure file permissions; see below for further instructions)</p>\n";
690 $errorWritable = 1;
693 if ($errorWritable) {
694 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
695 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
696 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
697 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
698 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
699 break;
702 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
703 $errorWritable = 0;
704 foreach ($writableDirList as $tempDir) {
705 if (is_writable($tempDir)) {
706 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
708 else {
709 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
710 echo "(configure directory permissions; see below for further instructions)</p>\n";
711 $errorWritable = 1;
714 if ($errorWritable) {
715 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
716 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";
717 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
718 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
719 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
720 break;
723 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
725 else {
726 echo "<br>Click to continue installation.<br>\n";
729 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'>" .
730 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>" .
731 "<INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
737 </span>
739 </BODY>
740 </HTML>