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>;.
19 * @author Roberto Vasquez <robertogagliotta@gmail.com>
20 * @author Scott Wakefield <scott@npclinics.com.au>
21 * @link http://www.open-emr.org
26 // Set the maximum excution time and time limit to unlimited.
27 ini_set('max_execution_time', 0);
30 // Warning. If you set $allow_multisite_setup to true, this is a potential security vulnerability.
31 // Recommend setting it back to false (or removing this setup.php script entirely) after you
32 // are done with the multisite procedure.
33 $allow_multisite_setup = false;
35 // Warning. If you set $allow_cloning_setup to true, this is a potential security vulnerability.
36 // Recommend setting it back to false (or removing this setup.php script entirely) after you
37 // are done with the cloning setup procedure.
38 $allow_cloning_setup = false;
39 if (!$allow_cloning_setup && !empty($_REQUEST['clone_database'])) {
40 die("To turn on support for cloning setup, need to edit this script and change \$allow_cloning_setup to true. After you are done setting up the cloning, ensure you change \$allow_cloning_setup back to false or remove this script altogether");
43 // Checks if the server's PHP version is compatible with OpenEMR:
44 require_once(dirname(__FILE__
) . "/common/compatibility/Checker.php");
46 use OpenEMR\Common\Checker
;
48 $response = Checker
::checkPhpVersion();
49 if ($response !== true) {
53 $COMMAND_LINE = php_sapi_name() == 'cli';
54 require_once(dirname(__FILE__
) . '/library/authentication/password_hashing.php');
55 require_once dirname(__FILE__
) . '/library/classes/Installer.class.php';
57 $state = isset($_POST["state"]) ?
($_POST["state"]) : '';
59 // Make this true for IPPF.
60 $ippf_specific = false;
62 // If this script was invoked with no site ID, then ask for one.
63 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
66 echo "<title>OpenEMR Setup Tool</title>\n";
67 echo "<link rel='stylesheet' href='interface/themes/style_blue.css'>\n";
70 echo "<p><b>Optional Site ID Selection</b></p>\n";
71 echo "<p>Most OpenEMR installations support only one site. If that is " .
72 "true for you then ignore the rest of this text and just click Continue.</p>\n";
73 echo "<p>Otherwise please enter a unique Site ID here.</p>\n";
74 echo "<p>A Site ID is a short identifier with no spaces or special " .
75 "characters other than periods or dashes. It is case-sensitive and we " .
76 "suggest sticking to lower case letters for ease of use.</p>\n";
77 echo "<p>If each site will have its own host/domain name, then use that " .
78 "name as the Site ID (e.g. www.example.com).</p>\n";
79 echo "<p>The site ID is used to identify which site you will log in to. " .
80 "If it is a hostname then it is taken from the hostname in the URL. " .
81 "Otherwise you must append \"?site=<i>siteid</i>\" to the URL used for " .
83 echo "<p>It is OK for one of the sites to have \"default\" as its ID. This " .
84 "is the ID that will be used if it cannot otherwise be determined.</p>\n";
85 echo "<form method='post'><input type='hidden' name='state' value='0'>" .
86 "Site ID: <input type='text' name='site' value='default'> " .
87 "<input type='submit' value='Continue'><br></form><br>\n";
88 echo "</body></html>\n";
92 // Support "?site=siteid" in the URL, otherwise assume "default".
94 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
95 $site_id = trim($_REQUEST['site']);
98 // Die if site ID is empty or has invalid characters.
99 if (empty($site_id) ||
preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) {
100 die("Site ID '".htmlspecialchars($site_id, ENT_NOQUOTES
)."' contains invalid characters.");
103 // If multisite is turned off, then only allow default for site.
104 if (!$allow_multisite_setup && $site_id != 'default') {
105 die("To turn on support for multisite setup, need to edit this script and change \$allow_multisite_setup to true. After you are done setting up the cloning, ensure you change \$allow_multisite_setup back to false or remove this script altogether");
108 //If having problems with file and directory permission
109 // checking, then can be manually disabled here.
110 $checkPermissions = true;
112 $installer = new Installer($_REQUEST);
113 global $OE_SITE_DIR; // The Installer sets this
115 $docsDirectory = "$OE_SITE_DIR/documents";
116 $billingDirectory = "$OE_SITE_DIR/edi";
117 $billingDirectory2 = "$OE_SITE_DIR/era";
118 $lettersDirectory = "$OE_SITE_DIR/letter_templates";
119 $gaclWritableDirectory = dirname(__FILE__
)."/gacl/admin/templates_c";
120 $requiredDirectory1 = dirname(__FILE__
)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
121 $requiredDirectory2 = dirname(__FILE__
)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
123 $zendModuleConfigFile = dirname(__FILE__
)."/interface/modules/zend_modules/config/application.config.php";
125 //These are files and dir checked before install for
126 // correct permissions.
127 if (is_dir($OE_SITE_DIR)) {
128 $writableFileList = array($installer->conffile
,$zendModuleConfigFile);
129 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
131 $writableFileList = array();
132 $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
135 // Include the sqlconf file if it exists yet.
137 if (file_exists($OE_SITE_DIR)) {
138 include_once($installer->conffile
);
139 } else if ($state > 3) {
140 // State 3 should have created the site directory if it is missing.
141 die("Internal error, site directory is missing.");
147 <TITLE
>OpenEMR Setup Tool
</TITLE
>
148 <LINK REL
=STYLESHEET HREF
="interface/themes/style_blue.css">
149 <link rel
="shortcut icon" href
="public/images/favicon.ico" />
153 table
.phpset
{ border
-collapse
:collapse
; }
154 table
.phpset td
, table
.phpset th
{ font
-size
:9pt
; border
:1px solid gray
; padding
:2px
; }
157 <script type
="text/javascript" src
="public/assets/jquery/dist/jquery.min.js"></script
>
158 <script language
="javascript">
159 // onclick handler for "clone database" checkbox
160 function cloneClicked() {
161 var cb
= document
.forms
[0].clone_database
;
162 $
('.noclone').css('display', cb
.checked ?
'none' : 'block');
169 <span
class="title">OpenEMR Setup
</span
>
173 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
174 echo "It appears that you have register_globals enabled in your php.ini\n" .
175 "configuration file. This causes unacceptable security risks. You must\n" .
176 "turn it off before continuing with installation.\n";
180 if (!extension_loaded("xml")) {
181 echo "Error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
185 if (!(extension_loaded("mysql") ||
extension_loaded("mysqlnd") ||
extension_loaded("mysqli"))) {
186 echo "Error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
190 if (!(extension_loaded("mbstring") )) {
191 echo "Error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
200 <p
>Congratulations
! OpenEMR is now installed
.</p
>
203 <li
>Access
controls (php
-GACL
) are installed
for fine
-grained security
, and can be administered in
204 OpenEMR
's admin->acl menu.</li>
205 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
206 contains some settings that you may want to change.</li>
207 <li>There's much information
and many extra tools bundled within the OpenEMR installation directory
.
208 Please refer to openemr
/Documentation
. Many forms
and other useful scripts can be found at openemr
/contrib
.</li
>
209 <li
>To ensure a consistent look
and feel throughout the application
,
210 <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
>
211 <li
>The OpenEMR project home page
, documentation
, and forums can be found at
<a href
= "https://www.open-emr.org" rel
='noopener' target
="_blank">https
://www.open-emr.org</a></li>
212 <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
>
215 We recommend you
print these instructions
for future reference
.
217 <?php
if (empty($installer->clone_database
)) {
218 echo "<p><b>The initial OpenEMR user is '".$installer->iuser
."' and the password is '".$installer->iuserpass
."'</b></p>";
219 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>";
222 <a href
='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR
. </a
>
232 $inst = isset($_POST["inst"]) ?
($_POST["inst"]) : '';
235 if (($config == 1) && ($state < 4)) {
236 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";
240 echo "<b>Step $state</b><br><br>\n";
241 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
242 <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>
244 <FORM METHOD='POST'>\n
245 <INPUT TYPE='HIDDEN' NAME='state' VALUE='2'>\n
246 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
247 <LABEL FOR='inst1'><INPUT TYPE='RADIO' ID='inst1' NAME='inst' VALUE='1' checked>Have setup create the database</label><br>\n
248 <LABEL FOR='inst2'><INPUT TYPE='RADIO' ID='inst2' NAME='inst' VALUE='2'>I have already created the database</label><br>\n
250 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
254 echo "<b>Step $state</b><br><br>\n";
255 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' rel='noopener' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.
258 <INPUT TYPE='HIDDEN' NAME='state' VALUE='3'>
259 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
260 <INPUT TYPE='HIDDEN' NAME='inst' VALUE='$inst'>
262 <TR VALIGN='TOP'><TD COLSPAN=2><font color='red'>MYSQL SERVER:</font></TD></TR>
263 <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>
264 <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>
265 <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>
266 <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>
267 <TR VALIGN='TOP'><TD><span class='text'>Password: </span></TD><TD><INPUT TYPE='PASSWORD' VALUE='' NAME='pass' SIZE='30' minlength='12' required></TD><TD><span class='text'>(This is the Login Password for when PHP accesses MySQL - it should be at least 12 characters long and composed of both numbers and letters)</span><br></TD></TR>\n";
269 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>
270 <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";
271 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>";
272 echo "<TR VALIGN='TOP'><TD><span class='text'>UTF-8 Collation: </span></TD><TD colspan='2'>" .
273 "<select name='collate'>" .
274 "<option value='utf8_bin' >Bin</option>" .
275 "<option value='utf8_czech_ci' >Czech</option>" .
276 "<option value='utf8_danish_ci' >Danish</option>" .
277 "<option value='utf8_esperanto_ci' >Esperanto</option>" .
278 "<option value='utf8_estonian_ci' >Estonian</option>" .
279 "<option value='utf8_general_ci' selected>General</option>" .
280 "<option value='utf8_hungarian_ci' >Hungarian</option>" .
281 "<option value='utf8_icelandic_ci' >Icelandic</option>" .
282 "<option value='utf8_latvian_ci' >Latvian</option>" .
283 "<option value='utf8_lithuanian_ci'>Lithuanian</option>" .
284 "<option value='utf8_persian_ci' >Persian</option>" .
285 "<option value='utf8_polish_ci' >Polish</option>" .
286 "<option value='utf8_roman_ci' >Roman</option>" .
287 "<option value='utf8_romanian_ci' >Romanian</option>" .
288 "<option value='utf8_slovak_ci' >Slovak</option>" .
289 "<option value='utf8_slovenian_ci' >Slovenian</option>" .
290 "<option value='utf8_spanish2_ci' >Spanish2 (Traditional)</option>" .
291 "<option value='utf8_spanish_ci' >Spanish (Modern)</option>" .
292 "<option value='utf8_swedish_ci' >Swedish</option>" .
293 "<option value='utf8_turkish_ci' >Turkish</option>" .
294 "<option value='utf8_unicode_ci' >Unicode (German, French, Russian, Armenian, Greek)</option>" .
295 "<option value='' >None (Do not force UTF-8)</option>" .
297 "</TD></TR><TR VALIGN='TOP'><TD> </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>";
300 echo "<TR VALIGN='TOP'><TD> </TD></TR>";
302 // Include a "source" site ID drop-list and a checkbox to indicate
303 // if cloning its database. When checked, do not display initial user
304 // and group stuff below.
305 $dh = opendir($OE_SITES_BASE);
307 die("Cannot read directory '$OE_SITES_BASE'.");
310 $siteslist = array();
311 while (false !== ($sfname = readdir($dh))) {
312 if (substr($sfname, 0, 1) == '.') {
316 if ($sfname == 'CVS') {
320 if ($sfname == $site_id) {
324 $sitedir = "$OE_SITES_BASE/$sfname";
325 if (!is_dir($sitedir)) {
329 if (!is_file("$sitedir/sqlconf.php")) {
333 $siteslist[$sfname] = $sfname;
337 // If this is not the first site...
338 if (!empty($siteslist)) {
340 echo "<tr valign='top'>\n";
341 echo " <td class='text'>Source Site: </td>\n";
342 echo " <td class='text'><select name='source_site_id'>";
343 foreach ($siteslist as $sfname) {
344 echo "<option value='$sfname'";
345 if ($sfname == 'default') {
349 echo ">$sfname</option>";
352 echo "</select></td>\n";
353 echo " <td class='text'>(The site directory that will be a model for the new site.)</td>\n";
355 echo "<tr valign='top'>\n";
356 echo " <td class='text'>Clone Source Database: </td>\n";
357 echo " <td class='text'><input type='checkbox' name='clone_database' onclick='cloneClicked()' /></td>\n";
358 echo " <td class='text'>(Clone the source site's database instead of creating a fresh one.)</td>\n";
361 $randomusername = chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . "-admin-" . rand(0, 9) . rand(0, 9);
363 echo "<TR VALIGN='TOP' class='noclone'><TD COLSPAN=2><font color='red'>OPENEMR USER:</font></TD></TR>";
364 echo "<TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User:</span></TD><TD><INPUT SIZE='30' TYPE='TEXT' NAME='iuser' VALUE='".$randomusername."' minlength='12' required></TD><TD><span class='text'>(This is the login name of user that will be created for you. Limit this to one word with at least 12 characters.)</span></TD></TR>
365 <TR VALIGN='TOP' class='noclone'><TD><span class='text'>Initial User Password:</span></TD><TD><INPUT SIZE='30' TYPE='PASSWORD' NAME='iuserpass' VALUE='' minlength='12' required></TD><TD><span class='text'>(This is the password for the initial user account above - it should be at least 12 characters long and composed of both numbers and letters.)</span></TD></TR>
366 <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>
367 <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>
368 <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>
370 echo "<TR VALIGN='TOP'><TD> </TD></TR>";
374 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";
379 // (applicable if not cloning from another database)
381 $pass_step2_validation = true;
382 $error_step2_message = "ERROR at ";
384 if (! $installer->char_is_valid($_REQUEST['server'])) {
385 $pass_step2_validation = false;
386 $error_step2_message .= "Database Server Host, ";
389 if (! $installer->char_is_valid($_REQUEST['port'])) {
390 $pass_step2_validation = false;
391 $error_step2_message .= "Database Server Port, ";
394 if (! $installer->databaseNameIsValid($_REQUEST['dbname'])) {
395 $pass_step2_validation = false;
396 $error_step2_message .= "Database Name, ";
399 if (! $installer->collateNameIsValid($_REQUEST['collate'])) {
400 $pass_step2_validation = false;
401 $error_step2_message .= "Collation Name, ";
404 if (! $installer->char_is_valid($_REQUEST['login'])) {
405 $pass_step2_validation = false;
406 $error_step2_message .= "Database Login Name, ";
409 if (! $installer->char_is_valid($_REQUEST['pass'])) {
410 $pass_step2_validation = false;
411 $error_step2_message .= "Database Login Password, ";
414 if (!$pass_step2_validation) {
415 die($error_step2_message);
419 if (empty($installer->clone_database
)) {
420 if (! $installer->login_is_valid()) {
421 echo "ERROR. Please pick a proper 'Login Name'.<br>\n";
422 echo "Click Back in browser to re-enter.<br>\n";
426 if (! $installer->iuser_is_valid()) {
427 echo "ERROR. The 'Initial User' field can only contain one word and no spaces.<br>\n";
428 echo "Click Back in browser to re-enter.<br>\n";
432 if (! $installer->user_password_is_valid()) {
433 echo "ERROR. Please pick a proper 'Initial User Password'.<br>\n";
434 echo "Click Back in browser to re-enter.<br>\n";
439 if (! $installer->password_is_valid()) {
440 echo "ERROR. Please pick a proper 'Password'.<br>\n";
441 echo "Click Back in browser to re-enter.<br>\n";
445 echo "<b>Step $state</b><br><br>\n";
446 echo "Configuring OpenEMR...<br><br>\n";
448 // Skip below if database shell has already been created.
450 echo "Connecting to MySQL Server...\n";
452 if (! $installer->root_database_connection()) {
453 echo "ERROR. Check your login credentials.\n";
454 echo $installer->error_message
;
462 // Only pertinent if cloning another installation database
463 if ($allow_cloning_setup && !empty($installer->clone_database
)) {
464 echo "Dumping source database...";
466 if (! $installer->create_dumpfiles()) {
467 echo $installer->error_message
;
475 // Only pertinent if mirroring another installation directory
476 if (! empty($installer->source_site_id
)) {
477 echo "Creating site directory...";
478 if (! $installer->create_site_directory()) {
479 echo $installer->error_message
;
487 // Skip below if database shell has already been created.
489 echo "Creating database...\n";
491 if (! $installer->create_database()) {
492 echo "ERROR. Check your login credentials.\n";
493 echo $installer->error_message
;
500 echo "Creating user with permissions for database...\n";
502 $user_mysql_error = true;
503 if (! $installer->create_database_user()) {
504 echo "ERROR when creating specified user.\n";
505 echo $installer->error_message
;
508 $user_mysql_error = false;
510 if (! $installer->grant_privileges()) {
511 echo "ERROR when granting privileges to the specified user.\n";
512 echo $installer->error_message
;
515 $user_mysql_error = false;
517 if (!$user_mysql_error) {
522 echo "Reconnecting as new user...\n";
524 $installer->disconnect();
526 echo "Connecting to MySQL Server...\n";
529 if (! $installer->user_database_connection()) {
530 echo "ERROR. Check your login credentials.\n";
531 echo $installer->error_message
;
538 // Load the database files
539 $dump_results = $installer->load_dumpfiles();
540 if (! $dump_results) {
541 echo $installer->error_message
;
548 echo "Writing SQL configuration...\n";
550 if (! $installer->write_configuration_file()) {
551 echo $installer->error_message
;
558 // Only pertinent if not cloning another installation database
559 if (empty($installer->clone_database
)) {
560 echo "Setting version indicators...\n";
562 if (! $installer->add_version_info()) {
564 echo $installer->error_message
;
572 echo "Writing global configuration defaults...\n";
574 if (! $installer->insert_globals()) {
576 echo $installer->error_message
;
584 echo "Adding Initial User...\n";
586 if (! $installer->add_initial_user()) {
587 echo $installer->error_message
;
595 if ($allow_cloning_setup && !empty($installer->clone_database
)) {
596 // Database was cloned, skip ACL setup.
597 echo "Click 'continue' for further instructions.";
600 echo "\n<br>Next step will install and configure access controls (php-GACL).<br>\n";
605 <FORM METHOD='POST'>\n
606 <INPUT TYPE='HIDDEN' NAME='state' VALUE='$next_state'>
607 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
608 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>
609 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>
610 <INPUT TYPE='HIDDEN' NAME='iuname' VALUE='$installer->iuname'>
611 <INPUT TYPE='HIDDEN' NAME='iufname' VALUE='$installer->iufname'>";
612 if ($allow_cloning_setup) {
613 echo "<INPUT TYPE='HIDDEN' NAME='clone_database' VALUE='$installer->clone_database'>";
617 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
621 echo "<b>Step $state</b><br><br>\n";
622 echo "Installing and Configuring Access Controls (php-GACL)...<br><br>";
624 if (! $installer->install_gacl()) {
625 echo $installer->error_message
;
628 // display the status information for gacl setup
629 echo $installer->debug_message
;
632 echo "Gave the '$installer->iuser' user (password is '$installer->iuserpass') administrator access.<br><br>";
634 echo "Done installing and configuring access controls (php-GACL).<br>";
635 echo "Next step will configure PHP.";
637 echo "<br><FORM METHOD='POST'>\n
638 <INPUT TYPE='HIDDEN' NAME='state' VALUE='5'>\n
639 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
640 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
641 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
643 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
648 echo "<b>Step $state</b><br><br>\n";
649 echo "Configuration of PHP...<br><br>\n";
650 echo "We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:\n";
653 if (version_compare(PHP_VERSION
, '5.2.4', '>=')) {
654 $phpINIfile = php_ini_loaded_file();
656 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
661 echo "<li>","To ensure proper functioning of OpenEMR you must make sure that PHP settings include:";
662 echo "<table class='phpset'><tr><th>Setting</th><th>Required value</th><th>Current value</th></tr>";
663 echo "<tr><td>short_open_tag </td><td>Off</td><td>", ini_get('short_open_tag')?
'On':'Off', "</td></tr>\n";
664 echo "<tr><td>display_errors </td><td>Off</td><td>", ini_get('display_errors')?
'On':'Off', "</td></tr>\n";
665 echo "<tr><td>register_globals </td><td>Off</td><td>", ini_get('register_globals')?
'On':'Off', "</td></tr>\n";
666 echo "<tr><td>max_input_vars </td><td>at least 3000</td><td>", ini_get('max_input_vars'), "</td></tr>\n";
667 echo "<tr><td>max_execution_time </td><td>at least 60</td><td>", ini_get('max_execution_time'), "</td></tr>\n";
668 echo "<tr><td>max_input_time </td><td>-1</td><td>", ini_get('max_input_time'), "</td></tr>\n";
669 echo "<tr><td>post_max_size </td><td>at least 30M</td><td>", ini_get('post_max_size'), "</td></tr>\n";
670 echo "<tr><td>memory_limit </td><td>at least 256M</td><td>", ini_get('memory_limit'), "</td></tr>\n";
674 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";
676 echo "<li>If you are having difficulty finding your php.ini file, then refer to the <a href='Documentation/INSTALL' rel='noopener' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.</li>\n";
681 echo "<br>We recommend you print these instructions for future reference.<br><br>";
682 echo "Next step will configure Apache web server.";
684 echo "<br><FORM METHOD='POST'>\n
685 <INPUT TYPE='HIDDEN' NAME='state' VALUE='6'>\n
686 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
687 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
688 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
690 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
695 echo "<b>Step $state</b><br><br>\n";
696 echo "Configuration of Apache web server...<br><br>\n";
697 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
698 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>
699 <Directory \"".realpath(dirname(__FILE__
))."\"><br>
700 AllowOverride FileInfo<br>
701 </Directory><br>
702 <Directory \"".realpath(dirname(__FILE__
))."/sites\"><br>
703 AllowOverride None<br>
704 </Directory><br>
705 <Directory \"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\"><br>
706 order deny,allow<br>
707 Deny from all<br>
708 </Directory><br>
709 <Directory \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory))."\"><br>
710 order deny,allow<br>
711 Deny from all<br>
712 </Directory><br>
713 <Directory \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory2))."\"><br>
714 order deny,allow<br>
715 Deny from all<br>
716 </Directory><br><br>";
718 echo "If you are having difficulty finding your apache configuration file, then refer to the <a href='Documentation/INSTALL' rel='noopener' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual for suggestions.<br><br>\n";
719 echo "<br>We recommend you print these instructions for future reference.<br><br>";
720 echo "Click 'continue' for further instructions.";
722 echo "<br><FORM METHOD='POST'>\n
723 <INPUT TYPE='HIDDEN' NAME='state' VALUE='7'>\n
724 <INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>\n
725 <INPUT TYPE='HIDDEN' NAME='iuser' VALUE='$installer->iuser'>\n
726 <INPUT TYPE='HIDDEN' NAME='iuserpass' VALUE='$installer->iuserpass'>\n
728 <INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>\n";
734 echo "<p>Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</p>\n";
735 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";
737 echo "<li>Detailed installation instructions can be found in the <a href='Documentation/INSTALL' rel='noopener' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li>\n";
739 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' rel='noopener' target='_blank'><span STYLE='text-decoration: underline;'>'INSTALL'</span></a> manual file.</li></ul>";
741 if ($checkPermissions) {
742 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
743 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
745 foreach ($writableFileList as $tempFile) {
746 if (is_writable($tempFile)) {
747 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
749 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
750 echo "(configure file permissions; see below for further instructions)</p>\n";
755 if ($errorWritable) {
756 echo "<p><FONT COLOR='red'>You can't proceed until all above files are ready (world-writable).</FONT><br>\n";
757 echo "In linux, recommend changing file permissions with the 'chmod 666 filename' command.<br>\n";
758 echo "Fix above file permissions and then click the 'Check Again' button to re-check files.<br>\n";
759 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
760 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
764 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
766 foreach ($writableDirList as $tempDir) {
767 if (is_writable($tempDir)) {
768 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
770 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\n";
771 echo "(configure directory permissions; see below for further instructions)</p>\n";
776 if ($errorWritable) {
777 echo "<p><FONT COLOR='red'>You can't proceed until all directories are ready.</FONT><br>\n";
778 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";
779 echo "Fix above directory permissions and then click the 'Check Again' button to re-check directories.<br>\n";
780 echo "<FORM METHOD='POST'><INPUT TYPE='SUBMIT' VALUE='Check Again'></p>" .
781 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'></FORM><br>\n";
785 echo "<br>All required files and directories have been verified. Click to continue installation.<br>\n";
787 echo "<br>Click to continue installation.<br>\n";
790 echo "<FORM METHOD='POST'><INPUT TYPE='HIDDEN' NAME='state' VALUE='1'>" .
791 "<INPUT TYPE='HIDDEN' NAME='site' VALUE='$site_id'>" .
792 "<INPUT TYPE='SUBMIT' VALUE='Continue'><br></FORM><br>";