7 * @link https://www.open-emr.org
8 * @author Roberto Vasquez <robertogagliotta@gmail.com>
9 * @author Scott Wakefield <scott@npclinics.com.au>
10 * @author Ranganath Pathak <pathak@scrs1.org>
11 * @copyright Copyright (c) 2016 Roberto Vasquez <robertogagliotta@gmail.com>
12 * @copyright Copyright (c) 2016 Scott Wakefield <scott@npclinics.com.au>
13 * @copyright Copyright (c) 2019 Ranganath Pathak <pathak@scrs1.org>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 // Checks if the server's PHP version is compatible with OpenEMR:
18 require_once(dirname(__FILE__
) . "/src/Common/Compatibility/Checker.php");
19 $response = OpenEMR\Common\Compatibility\Checker
::checkPhpVersion();
20 if ($response !== true) {
21 die(htmlspecialchars($response));
24 // Set the maximum excution time and time limit to unlimited.
25 ini_set('max_execution_time', 0);
26 ini_set('display_errors', 0);
29 // Warning. If you set $allow_multisite_setup to true, this is a potential security vulnerability.
30 // Recommend setting it back to false (or removing this setup.php script entirely) after you
31 // are done with the multisite procedure.
32 $allow_multisite_setup = false;
34 // Warning. If you set $allow_cloning_setup to true, this is a potential security vulnerability.
35 // Recommend setting it back to false (or removing this setup.php script entirely) after you
36 // are done with the cloning setup procedure.
37 $allow_cloning_setup = false;
38 if (!$allow_cloning_setup && !empty($_REQUEST['clone_database'])) {
39 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");
42 function recursive_writable_directory_test($dir)
44 // first, collect the directory and subdirectories
45 $ri = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
47 foreach ($ri as $file) {
49 if (!preg_match("/\.\.$/", $file->getPathname())) {
50 $dirName = realpath($file->getPathname());
51 if (!in_array($dirName, $dirNames)) {
52 $dirNames[] = $dirName;
58 // second, flag the directories that are not writable
59 $resultsNegative = array();
60 foreach ($dirNames as $value) {
61 if (!is_writable($value)) {
62 $resultsNegative[] = $value;
66 // third, send the output and return if didn't pass the test
67 if (!empty($resultsNegative)) {
71 foreach ($resultsNegative as $failedDir) {
72 if (basename($failedDir) == basename($dir)) {
73 // need to reorder output so the main directory is at the top of the list
74 $mainDirTest = "<FONT COLOR='red'>UNABLE</FONT> to open directory '" . realpath($failedDir) . "' for writing by web server.<br>\r\n";
76 $outputs[] = "<FONT COLOR='red'>UNABLE</FONT> to open subdirectory '" . realpath($failedDir) . "' for writing by web server.<br>\r\n";
80 // need to reorder output so the main directory is at the top of the list
81 array_unshift($outputs, $mainDirTest);
83 foreach ($outputs as $output) {
86 echo "(configure directory permissions; see below for further instructions)</p>\r\n";
89 echo "'" . realpath($dir) . "' directory and its subdirectories are <FONT COLOR='green'><b>ready</b></FONT>.<br>\r\n";
94 // Bring in standard libraries/classes
95 require_once dirname(__FILE__
) ."/vendor/autoload.php";
97 require_once(dirname(__FILE__
) . '/library/authentication/password_hashing.php');
98 require_once dirname(__FILE__
) . '/library/classes/Installer.class.php';
100 use OpenEMR\Common\Utils\RandomGenUtils
;
102 $COMMAND_LINE = php_sapi_name() == 'cli';
104 $state = isset($_POST["state"]) ?
($_POST["state"]) : '';
105 $installer = new Installer($_REQUEST);
106 // Make this true for IPPF.
107 $ippf_specific = false;
109 $error_page_end = <<<EPE
112 </div><!--end of container div-->
117 // If this script was invoked with no site ID, then ask for one.
118 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
123 <title>OpenEMR Setup Tool</title>
124 <!--<link rel=stylesheet href="interface/themes/style_blue.css">-->
125 <link rel="stylesheet" href="public/assets/bootstrap/dist/css/bootstrap.min.css" type="text/css">
126 <link rel="stylesheet" href="public/assets/jquery-ui/jquery-ui.css" type="text/css">
127 <script type="text/javascript" src="public/assets/jquery/dist/jquery.min.js"></script>
128 <script type="text/javascript" src="public/assets/bootstrap/dist/js/bootstrap.min.js"></script>
129 <link rel="stylesheet" href="public/assets/font-awesome/css/font-awesome.min.css" type="text/css">
130 <link rel="shortcut icon" href="public/images/favicon.ico" />
131 <script type="text/javascript" src="public/assets/jquery-ui/jquery-ui.js"></script>
139 <div class = 'container'>
142 <div class="col-sm-12">
143 <div class="page-header">
144 <h2>OpenEMR Setup <a class="oe-pull-away oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#676666" title="Click to view Help"><i class="fa fa-question-circle" aria-hidden="true"></i></a></h2>
150 <div class="col-sm-12">
152 <legend>Optional Site ID Selection</legend>
153 <p>Most OpenEMR installations support only one site. If that is
154 true for you then ignore the rest of this text and just click Continue.</p>
155 <p class='bg-warning'>If you are using the multisite setup module for the first time please read the
156 'Multi Site Installation' section of the help file before proceeding.</p>
157 <p>Otherwise please enter a unique Site ID here.</p>
158 <p>A Site ID is a short identifier with no spaces or special
159 characters other than periods or dashes. It is case-sensitive and we
160 suggest sticking to lower case letters for ease of use.</p>
161 <p>If each site will have its own host/domain name, then use that
162 name as the Site ID (e.g. www.example.com).</p>
163 <p>The site ID is used to identify which site you will log in to.
164 If it is a hostname then it is taken from the hostname in the URL.
165 Otherwise you must append "?site=<i>siteid</i>" to the URL used for
167 <p>It is OK for one of the sites to have "default" as its ID. This
168 is the ID that will be used if it cannot otherwise be determined.</p>
171 <input type='hidden' name='state' value='0'>
172 Site ID: <input type='text' name='site' value='default'>
173 <button type='submit' value='Continue'>Continue</button>
178 </div><!--end of container div-->
180 echo $site_id . "\r\n";
181 $installer->setupHelpModal();
182 echo "</body>". "\r\n";
183 echo "</html>". "\r\n";
188 // Support "?site=siteid" in the URL, otherwise assume "default".
189 $site_id = 'default';
190 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
191 $site_id = trim($_REQUEST['site']);
194 // Die if site ID is empty or has invalid characters.
195 if (empty($site_id) ||
preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) {
196 die("Site ID '".htmlspecialchars($site_id, ENT_NOQUOTES
)."' contains invalid characters.");
199 // If multisite is turned off, then only allow default for site.
200 if (!$allow_multisite_setup && $site_id != 'default') {
201 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");
204 //If having problems with file and directory permission
205 // checking, then can be manually disabled here.
206 $checkPermissions = true;
208 global $OE_SITE_DIR; // The Installer sets this
210 $docsDirectory = "$OE_SITE_DIR/documents";
212 //These are files and dir checked before install for
213 // correct permissions.
214 if (is_dir($OE_SITE_DIR)) {
215 $writableFileList = array($installer->conffile
);
216 $writableDirList = array($docsDirectory);
218 $writableFileList = array();
219 $writableDirList = array($OE_SITES_BASE);
222 // Include the sqlconf file if it exists yet.
224 if (file_exists($OE_SITE_DIR)) {
225 include_once($installer->conffile
);
226 } elseif ($state > 3) {
227 // State 3 should have created the site directory if it is missing.
228 die("Internal error, site directory is missing.");
233 <title
>OpenEMR Setup Tool
</title
>
234 <!--<link rel
=stylesheet href
="interface/themes/style_blue.css">-->
235 <link rel
="stylesheet" href
="public/assets/bootstrap/dist/css/bootstrap.min.css" type
="text/css">
236 <link rel
="stylesheet" href
="public/assets/jquery-ui/jquery-ui.css" type
="text/css">
237 <script type
="text/javascript" src
="public/assets/jquery/dist/jquery.min.js"></script
>
238 <script type
="text/javascript" src
="public/assets/bootstrap/dist/js/bootstrap.min.js"></script
>
239 <script type
="text/javascript" src
="public/assets/jquery-ui/jquery-ui.js"></script
>
240 <link rel
="stylesheet" href
="public/assets/font-awesome/css/font-awesome.min.css" type
="text/css">
241 <link rel
="shortcut icon" href
="public/images/favicon.ico" />
246 border
-collapse
:collapse
;
248 table
.phpset td
, table
.phpset th
{
250 border
:1px solid gray
;
253 .table
.no
-border tr td
, .table
.no
-border tr th
{
265 font
-family
:sans
-serif
;
273 .label
-div
:hover
> a
{
274 display
:inline
-block
;
279 margin
: 10px
15px
0px
15px
;
281 div
[id$
="_info"] > a
{
285 display
: inline
-block
;
288 .checkboxgroup label
{
301 font
-size
: 70%
!important
;
304 background
-color
: WHITESMOKE
;
320 fieldset
> [class*="col-"] {
322 text
-align
:left
!Important
;
326 <script language
="javascript">
327 // onclick handler for "clone database" checkbox
328 function cloneClicked() {
329 var cb
= document
.forms
[0].clone_database
;
330 $
('.noclone').css('display', cb
.checked ?
'none' : 'block');
336 <div
class = 'container'>
338 <div
class="col-sm-12">
339 <div
class="page-header">
340 <h2
>OpenEMR Setup
<a
class="oe-pull-away oe-help-redirect" data
-target
="#myModal" data
-toggle
="modal" href
="#" id
="help-href" name
="help-href" style
="color:#676666" title
="Click to view Help"><i
class="fa fa-question-circle" aria
-hidden
="true"></i
></a
></h2
>
345 <div
class="col-sm-12">
347 $error = "<span class='text-danger'><b>ERROR</b></span>";
348 $caution = "<span class='text-danger'><b>CAUTION</b></span>";
349 $ok = "<span class='text-success'><b>OK</b></span>";
350 $note = "<span class='text-primary'><b>NOTE</b></span>";
352 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
353 echo "$caution: It appears that you have register_globals enabled in your php.ini\n" .
354 "configuration file. This causes unacceptable security risks. You must\n" .
355 "turn it off before continuing with installation.\n";
359 if (!extension_loaded("xml")) {
360 echo "$error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
364 if (!(extension_loaded("mysql") ||
extension_loaded("mysqlnd") ||
extension_loaded("mysqli"))) {
365 echo "$error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
369 if (!(extension_loaded("mbstring") )) {
370 echo "$error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
374 if (!(extension_loaded("openssl") )) {
375 echo "$error: PHP openssl extension missing. To continue, install PHP openssl extension, then restart web server.";
385 <legend
>Final step
- Success
</legend
>
386 <p
>Congratulations
! OpenEMR is now installed
.</p
>
389 <li
>Access
controls (php
-GACL
) are installed
for fine
-grained security
, and can be administered in
390 OpenEMR
's admin->acl menu.</li>
391 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
392 contains some settings that you may want to change.</li>
393 <li>There's much information
and many extra tools bundled within the OpenEMR installation directory
.
394 Please refer to openemr
/Documentation
. Many forms
and other useful scripts can be found at openemr
/contrib
.</li
>
395 <li
>To ensure a consistent look
and feel throughout the application
,
396 <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
>
397 <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>
398 <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
>
400 <p
>We recommend you
print these instructions
for future reference
.</p
>
402 echo "<p> The selected theme is :</p>";
403 $installer->displayNewThemeDiv();
404 if (empty($installer->clone_database
)) {
405 echo "<p><b>The initial OpenEMR user is <span class='text-primary'>'".$installer->iuser
."'</span> and the password is <span class='text-primary'>'".$installer->iuserpass
."'</span></b></p>";
407 echo "<p>The initial OpenEMR user name and password is the same as that of source site <b>'". $installer->source_site_id
."'</span></b></p>";
409 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>";
410 echo "<p>In Linux use the following command:</p>";
411 echo "<p><code>sudo apachectl -k restart</code></p>";
415 <a href
='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR
. </a
>
419 $installer->setCurrentTheme();
424 </div><!--end of container div-->
426 echo $end_div . "\r\n";
427 $installer->setupHelpModal();
428 echo "</body>". "\r\n";
429 echo "</html>". "\r\n";
437 $inst = isset($_POST["inst"]) ?
($_POST["inst"]) : '';
439 if (($config == 1) && ($state < 4)) {
440 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";
446 <legend>Step $state - Select Database Setup</legend>
447 <p>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.
449 <p class='bg-danger'>$caution: clicking on <b>Proceed to Step 2</b> may delete or cause damage to existing data on your system. Before you continue <b>please backup your data</b>.
452 <input name='state' type='hidden' value='2'>
453 <input name='site' type='hidden' value='$site_id'>
455 <input checked id='inst1' name='inst' type='radio' value='1'>Have setup create the database
458 <input id='inst2' name='inst' type='radio' value='2'>I have already created the database
461 <button type='submit' value='Continue'><b>Proceed to Step 2</b></button>
469 $step2top = <<<STP2TOP
471 <legend>Step $state - Database and OpenEMR Initial User Setup Details</legend>
472 <p>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.
474 <form method='post' id='myform'>
475 <input name='state' type='hidden' value='3'>
476 <input name='site' type='hidden' value='$site_id'>
477 <input name='inst' type='hidden' value='$inst'>
479 echo $step2top ."\r\n";
482 $step2tabletop1 = <<<STP2TBLTOP1
484 <legend name="form_legend" id="form_legend" class='oe-setup-legend'>MySQL Server Details<i id="enter-details-tooltip" class="fa fa-info-circle oe-text-black oe-superscript enter-details-tooltip" aria-hidden="true"></i></legend>
486 <div class="col-xs-12 ">
487 <div class="col-sm-4">
488 <div class="clearfix form-group">
489 <div class="label-div">
490 <label class="control-label" for="server">Server Host:</label> <a href="#server_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
493 <input name='server' id='server' type='text' class='form-control' value='localhost'>
497 <div id="server_info" class="collapse">
498 <a href="#server_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
499 <p>If you run MySQL and Apache/PHP on the same computer, then leave this as 'localhost'.
500 <p>If they are on separate computers, then enter the IP address of the computer running MySQL.
504 <div class="col-sm-4">
505 <div class="clearfix form-group">
506 <div class="label-div">
507 <label class="control-label" for="port">Server Port:</label> <a href="#port_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
510 <input name='port' id='port' type='text' class='form-control' value='3306'>
513 <div id="port_info" class="collapse">
514 <a href="#port_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
515 <p>This is the MySQL port.
516 <p>The default port for MySQL is 3306.
519 <div class="col-sm-4">
520 <div class="clearfix form-group">
521 <div class="col-sm-12 label-div">
522 <label class="control-label" for="dbname">Database Name:</label> <a href="#dbname_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
524 <div class="col-sm-12">
525 <input name='dbname' id='dbname' type='text' class='form-control' value='openemr'>
528 <div id="dbname_info" class="collapse">
529 <a href="#dbname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
530 <p>This will be the name of the OpenEMR database in MySQL.
531 <p>'openemr' is the recommended name.
532 <p>This database will contain patient data as well as data pertaining to the OpenEMR installation.
538 <div class="col-xs-12 ">
539 <div class="col-sm-4">
540 <div class="clearfix form-group">
541 <div class="label-div">
542 <label class="control-label" for="login">Login Name:</label> <a href="#login_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
545 <input name='login' ID='login' type='text' class='form-control' value='openemr'>
549 <div id="login_info" class="collapse">
550 <a href="#login_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
551 <p>This is the name that OpenEMR will use to login to the MySQL database.
552 <p>'openemr' is the recommended name.
555 <div class="col-sm-4">
556 <div class="clearfix form-group">
557 <div class="label-div">
558 <label class="control-label" for="pass">Password:</label> <a href="#pass_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
561 <input name='pass' id='pass' class='form-control' type='password' value='' required>
564 <div id="pass_info" class="collapse">
565 <a href="#pass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
566 <p>This is the Login Password that OpenEMR will use to accesses the MySQL database.
567 <p>It should be at least 12 characters long and composed of both numbers and letters.
571 echo $step2tabletop1 ."\r\n";
573 $step2tabletop2 = <<<STP2TBLTOP2
574 <div class="col-sm-4">
575 <div class="clearfix form-group">
576 <div class="col-sm-12 label-div">
577 <label class="control-label" for="root">Name for Root Account:</label> <a href="#root_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
579 <div class="col-sm-12">
580 <input name='root' id='root'type='text' class='form-control' value='root'>
583 <div id="root_info" class="collapse">
584 <a href="#root_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
585 <p>This is name for the MySQL root account.
586 <p>For localhost, it is usually ok to leave it as 'root'.
592 <div class="col-xs-12 ">
593 <div class="col-sm-4">
594 <div class="clearfix form-group">
595 <div class="label-div">
596 <label class="control-label" for="rootpass">Root Password:</label> <a href="#rootpass_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
599 <input name='rootpass' id='rootpass' type='password' class='form-control' value=''>
603 <div id="rootpass_info" class="collapse">
604 <a href="#rootpass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
605 <p>This is your MySQL server root password.
608 <div class="col-sm-4">
609 <div class="clearfix form-group">
610 <div class="label-div">
611 <label class="control-label" for="loginhost">User Hostname:</label> <a href="#loginhost_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
614 <input name='loginhost' id='loginhost' type='text' class='form-control' value='localhost'>
617 <div id="loginhost_info" class="collapse">
618 <a href="#loginhost_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
619 <p>If you run Apache/PHP and MySQL on the same computer, then leave this as 'localhost'.
620 <p>If they are on separate computers, then enter the IP address of the computer running Apache/PHP.
623 <div class="col-sm-4">
624 <div class="clearfix form-group">
625 <div class="col-sm-12 label-div">
626 <label class="control-label" for="collate">UTF-8 Collation:</label> <a href="#collate_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
628 <div class="col-sm-12">
629 <select name='collate' id=='collate' class='form-control'>
630 <option value='utf8_bin'>
633 <option value='utf8_czech_ci'>
636 <option value='utf8_danish_ci'>
639 <option value='utf8_esperanto_ci'>
642 <option value='utf8_estonian_ci'>
645 <option selected value='utf8_general_ci'>
648 <option value='utf8_hungarian_ci'>
651 <option value='utf8_icelandic_ci'>
654 <option value='utf8_latvian_ci'>
657 <option value='utf8_lithuanian_ci'>
660 <option value='utf8_persian_ci'>
663 <option value='utf8_polish_ci'>
666 <option value='utf8_roman_ci'>
669 <option value='utf8_romanian_ci'>
672 <option value='utf8_slovak_ci'>
675 <option value='utf8_slovenian_ci'>
678 <option value='utf8_spanish2_ci'>
679 Spanish2 (Traditional)
681 <option value='utf8_spanish_ci'>
684 <option value='utf8_swedish_ci'>
687 <option value='utf8_turkish_ci'>
690 <option value='utf8_unicode_ci'>
691 Unicode (German, French, Russian, Armenian, Greek)
694 None (Do not force UTF-8)
699 <div id="collate_info" class="collapse">
700 <a href="#collate_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
701 <p>This is the collation setting for MySQL.
702 <p>Collation refers to a set of rules that determine how data is sorted and compared in a database.
703 <p>Leave as 'General' if you are not sure.
704 <p>If the language you are planning to use in OpenEMR is in the menu, then you can select it.
705 <p>Otherwise, just select 'General'.
711 echo $step2tabletop2 ."\r\n";
713 // Include a "source" site ID drop-list and a checkbox to indicate
714 // if cloning its database. When checked, do not display initial user
715 // and group stuff below.
716 $dh = opendir($OE_SITES_BASE);
718 die("Cannot read directory '$OE_SITES_BASE'.");
721 $siteslist = array();
722 while (false !== ($sfname = readdir($dh))) {
723 if (substr($sfname, 0, 1) == '.') {
727 if ($sfname == 'CVS') {
731 if ($sfname == $site_id) {
735 $sitedir = "$OE_SITES_BASE/$sfname";
736 if (!is_dir($sitedir)) {
740 if (!is_file("$sitedir/sqlconf.php")) {
744 $siteslist[$sfname] = $sfname;
748 // If this is not the first site...
749 if (!empty($siteslist)) {
751 $source_site_top = <<<SOURCESITETOP
753 <div class="col-xs-12 ">
754 <div class="col-sm-4">
755 <div class="clearfix form-group">
756 <div class="label-div">
757 <label class="control-label" for="source_site_id">Source Site:</label> <a href="#source_site_id_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
760 <select name='source_site_id'id='source_site_id' class='form-control'>
762 echo $source_site_top . "\r\n";
763 foreach ($siteslist as $sfname) {
764 echo "<option value='$sfname'";
765 if ($sfname == 'default') {
769 echo ">$sfname</option>";
771 $source_site_bot = <<<SOURCESITEBOT
776 <div id="source_site_id_info" class="collapse">
777 <a href="#source_site_id_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
778 <p>The site directory that will be a model for the new site.
781 <div class="col-sm-4">
782 <div class="clearfix form-group">
783 <div class="label-div">
784 <label class="control-label" for="clone_database">Clone Source Database:</label> <a href="#clone_database_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
787 <input type='checkbox' name='clone_database' id='clone_database' onclick='cloneClicked()' />
790 <div id="clone_database_info" class="collapse">
791 <a href="#clone_database_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
792 <p>Clone the source site's database instead of creating a fresh one.
798 echo $source_site_bot ."\r\n";
801 $randomusernamepre = RandomGenUtils::produceRandomString(3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
802 $randomusernamepost = RandomGenUtils::produceRandomString(2, "0123456789");
803 $randomusername = $randomusernamepre . "-admin-" . $randomusernamepost;
805 // App Based TOTP secret
806 // Shared key (per rfc6238 and rfc4226) should be 20 bytes (160 bits) and encoded in base32, which should
807 // be 32 characters in base32
808 // Would be nice to use the OpenEMR\Common\Utils\RandomGenUtils\produceRandomBytes() function and then encode to base32,
809 // but does not appear to be a standard way to encode binary to base32 in php.
810 $randomsecret = RandomGenUtils::produceRandomString(32, "234567ABCDEFGHIJKLMNOPQRSTUVWXYZ");
811 if (empty($randomsecret) || empty($randomusernamepre) || empty($randomusernamepost)) {
812 error_log('OpenEMR Error : Random String error - exiting');
815 $disableCheckbox = "";
816 if (empty($randomsecret)) {
818 $disableCheckbox = "disabled";
821 $step2tablebot = <<<STP2TBLBOT
824 <fieldset class='noclone'>
825 <legend name="form_legend" id="form_legend" class='oe-setup-legend'>OpenEMR Initial User Details<i id="enter-details-tooltip" class="fa fa-info-circle oe-text-black oe-superscript enter-details-tooltip" aria-hidden="true"></i></legend>
827 <div class="col-xs-12 ">
828 <div class="col-sm-4">
829 <div class="clearfix form-group">
830 <div class="label-div">
831 <label class="control-label" for="iuser">Initial User Login Name:</label> <a href="#iuser_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
834 <input name='iuser' id='iuser' type='text' class='form-control' value='$randomusername' minlength='12'>
838 <div id="iuser_info" class="collapse">
839 <a href="#iuser_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
840 <p>This is the login name of the first user that will be created for you.
841 <p>Limit this to one word with at least 12 characters and composed of both numbers and letters.
845 <div class="col-sm-4">
846 <div class="clearfix form-group">
847 <div class="label-div">
848 <label class="control-label" for="iuserpass">Initial User Password:</label> <a href="#iuserpass_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
851 <input name='iuserpass' id='iuserpass' type='password' class='form-control' value='' minlength='12'>
854 <div id="iuserpass_info" class="collapse">
855 <a href="#iuserpass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
856 <p>This is the password for the initial user.
859 <div class="col-sm-4">
860 <div class="clearfix form-group">
861 <div class="col-sm-12 label-div">
862 <label class="control-label" for="iufname">Initial User's First Name:</label> <a href="#iufname_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
864 <div class="col-sm-12">
865 <input name='iufname' id='iufname 'type='text' class='form-control' value='Administrator'>
868 <div id="iufname_info" class="collapse">
869 <a href="#iufname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
870 <p>This is the First name of the 'initial user'.
876 <div class="col-xs-12 ">
877 <div class="col-sm-4">
878 <div class="clearfix form-group">
879 <div class="label-div">
880 <label class="control-label" for="iuname">Initial User's Last Name:</label> <a href="#iuname_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
883 <input name='iuname' id='iuname' type='text' class='form-control' value='Administrator'>
887 <div id="iuname_info" class="collapse">
888 <a href="#iuname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
889 <p>This is the Last name of the 'initial user'.
892 <div class="col-sm-4">
893 <div class="clearfix form-group">
894 <div class="label-div">
895 <label class="control-label" for="igroup">Initial Group:</label> <a href="#igroup_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
898 <input name='igroup' id='igroup' class='form-control' type='text' value='Default'>
901 <div id="igroup_info" class="collapse">
902 <a href="#igroup_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
903 <p>This is the group that will be created for your users.
904 <p>This should be the name of your practice.
911 <fieldset class='noclone bg-danger oe-margin-b-5'>
912 <legend name="form_legend" id="form_legend" class='oe-setup-legend text-danger'>Enable 2 Factor Authentication for Initial User (more secure - optional) <i id="2fa-section" class="fa fa-info-circle oe-text-black oe-superscript 2fa-section-tooltip" aria-hidden="true"></i></legend>
915 <div class="col-xs-12 ">
916 <div class="col-sm-3">
917 <div class="clearfix form-group">
918 <div class="label-div">
919 <label class="control-label" for="i2fa">Configure 2FA:</label> <a href="#i2fa_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
922 <input name='i2faenable' id='i2faenable' type='checkbox' $disableCheckbox/> Enable 2FA
923 <input type='hidden' name='i2fasecret' id='i2fasecret' value='$randomsecret' />
926 <div id="i2fa_info" class="collapse">
927 <a href="#i2fa_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
928 <p>If selected will allow TOTP 2 factor authentication for the initial user.</p>
929 <p>Click on the help file for more information.</p>
932 <div class="col-sm-5">
933 <div class="clearfix form-group">
934 <p class="text-danger"><b>IMPORTANT IF ENABLED</b></p>
935 <p>If enabled, you must have an authenticator app on your phone ready to scan the QR code displayed next.</p>
938 <div class="col-sm-4">
939 <div class="clearfix form-group">
940 <p>Example authenticator apps include:</p>
943 (<a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8" target="_blank">ios</a>, <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en">android</a>)</li>
945 (<a href="https://itunes.apple.com/us/app/authy/id494168017?mt=8">ios</a>, <a href="https://play.google.com/store/apps/details?id=com.authy.authy&hl=en">android</a>)</li>
952 <p class='bg-warning'>Click the <b>Create DB and User</b> button below to create the database and first user <a href='#create_db_button' title='Click me'><i class="fa fa-arrow-circle-down" aria-hidden="true"></i></a>. $note: This process will take a few minutes.</p>
953 <!--<p class='bg-success'>Upon successful completion will automatically take you to the next step.</p>-->
954 <p class='bg-success oe-spinner' style = 'visibility:hidden;'>Upon successful completion will automatically take you to the next step.<i class='fa fa-spinner fa-pulse fa-fw'></i></p>
955 <button type='submit' id='create_db_button' value='Continue' class='wait'><b>Create DB and User</b></button>
959 echo $step2tablebot ."\r\n";
964 // (applicable if not cloning from another database)
966 $pass_step2_validation = true;
967 $error_step2_message = "$error - ";
969 if (! $installer->char_is_valid($_REQUEST['server'])) {
970 $pass_step2_validation = false;
971 $error_step2_message .= "A database server host is required <br>\n";
974 if (! $installer->char_is_valid($_REQUEST['port'])) {
975 $pass_step2_validation = false;
976 $error_step2_message .= "A database server port value is required <br>\n";
979 if (! $installer->databaseNameIsValid($_REQUEST['dbname'])) {
980 $pass_step2_validation = false;
981 $error_step2_message .= "A database name is required <br>\n";
984 if (! $installer->collateNameIsValid($_REQUEST['collate'])) {
985 $pass_step2_validation = false;
986 $error_step2_message .= "A collation name is required <br>\n";
989 if (! $installer->char_is_valid($_REQUEST['login'])) {
990 $pass_step2_validation = false;
991 $error_step2_message .= "A database login name is required <br>\n";
994 if (! $installer->char_is_valid($_REQUEST['pass'])) {
995 $pass_step2_validation = false;
996 $error_step2_message .= "A database login password is required <br>\n";
999 if (!$pass_step2_validation) {
1000 $error_step2_message .= $error_page_end . "\r\n";
1001 die($error_step2_message);
1005 if (empty($installer->clone_database)) {
1006 if (! $installer->login_is_valid()) {
1007 echo "$error. Please pick a proper 'Login Name'.<br>\n";
1008 echo "Click Back in browser to re-enter.<br>\n";
1012 if (! $installer->iuser_is_valid()) {
1013 echo "$error. The 'Initial User' field can only contain one word and no spaces.<br>\n";
1014 echo "Click Back in browser to re-enter.<br>\n";
1018 if (! $installer->user_password_is_valid()) {
1019 echo "$error. Please pick a proper 'Initial User Password'.<br>\n";
1020 echo "Click Back in browser to re-enter.<br>\n";
1025 if (! $installer->password_is_valid()) {
1026 echo "$error. Please pick a proper 'Password'.<br>\n";
1027 echo "Click Back in browser to re-enter.<br>\n";
1032 echo "<legend>Step $state - Creating Database and First User</legend>";
1034 // Skip below if database shell has already been created.
1036 echo "Connecting to MySQL Server...\n";
1038 if (! $installer->root_database_connection()) {
1039 echo "$error. Check your login credentials.\n";
1040 echo $installer->error_message;
1048 // Only pertinent if cloning another installation database
1049 if ($allow_cloning_setup && !empty($installer->clone_database)) {
1050 echo "Dumping source database...";
1052 if (! $installer->create_dumpfiles()) {
1053 echo $installer->error_message;
1061 // Only pertinent if mirroring another installation directory
1062 if (! empty($installer->source_site_id)) {
1063 echo "Creating site directory...";
1064 if (! $installer->create_site_directory()) {
1065 echo $installer->error_message;
1073 // Skip below if database shell has already been created.
1075 echo "Creating database...\n";
1077 if (! $installer->create_database()) {
1078 echo "$error. Check your login credentials.\n";
1079 echo $installer->error_message;
1086 echo "Creating user with permissions for database...\n";
1088 $user_mysql_error = true;
1089 if (! $installer->create_database_user()) {
1090 echo "$error when creating specified user.\n";
1091 echo $installer->error_message;
1094 $user_mysql_error = false;
1096 if (! $installer->grant_privileges()) {
1097 echo "$error when granting privileges to the specified user.\n";
1098 echo $installer->error_message;
1101 $user_mysql_error = false;
1103 if (!$user_mysql_error) {
1108 echo "Reconnecting as new user...\n";
1110 $installer->disconnect();
1112 echo "Connecting to MySQL Server...\n";
1115 if (! $installer->user_database_connection()) {
1116 echo "$error. Check your login credentials.\n";
1117 echo $installer->error_message;
1124 // Load the database files
1125 $dump_results = $installer->load_dumpfiles();
1126 if (! $dump_results) {
1128 echo $installer->error_message;
1135 echo "Writing SQL configuration...\n";
1137 if (! $installer->write_configuration_file()) {
1139 echo $installer->error_message;
1146 // Only pertinent if not cloning another installation database
1147 if (empty($installer->clone_database)) {
1148 echo "Setting version indicators...\n";
1150 if (! $installer->add_version_info()) {
1152 echo $installer->error_message;
1160 echo "Writing global configuration defaults...\n";
1162 if (! $installer->insert_globals()) {
1164 echo $installer->error_message;
1172 echo "Adding Initial User...\n";
1174 if (! $installer->add_initial_user()) {
1176 echo $installer->error_message;
1185 // If user has selected to set MFA App Based 2FA, display QR code to scan
1186 $qr = $installer->get_initial_user_2fa_qr();
1188 $qrDisplay = <<<TOTP
1193 <strong><font color='RED'>IMPORTANT!!</font></strong>
1194 <p><strong>You must scan the following QR code with your preferred authenticator app.</strong></p>
1195 <img src='$qr' width="150" />
1200 Example authenticator apps include:
1203 (<a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8">ios</a>, <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en">android</a>)</li>
1205 (<a href="https://itunes.apple.com/us/app/authy/id494168017?mt=8">ios</a>, <a href="https://play.google.com/store/apps/details?id=com.authy.authy&hl=en">android</a>)</li>
1214 if ($allow_cloning_setup && !empty($installer->clone_database)) {
1215 // Database was cloned, skip ACL setup.
1216 $btn_text = 'Proceed to Select a Theme';
1218 echo "<p>The database was cloned, access control list exists therefore skipping ACL setup</p>";
1219 echo "<p class='bg-warning'>Click <b>$btn_text</b> for further instructions.</p>";
1222 $btn_text = 'Proceed to Step 4';
1224 echo "<p class='bg-warning'>Click <b>$btn_text</b> to install and configure access controls (php-GACL). $note: This process will take a few minutes.</p>";
1225 echo "<p class='bg-success oe-spinner' style = 'visibility:hidden;'>Upon successful completion will automatically take you to the next step.<i class='fa fa-spinner fa-pulse fa-fw'></i></p>";
1229 $form_top = <<<FRMTOP
1230 <form method='post'>
1231 <input name='state' type='hidden' value='$next_state'>
1232 <input name='site' type='hidden' value='$site_id'>
1233 <input name='iuser' type='hidden' value='{$installer->iuser}'>
1234 <input name='iuserpass' type='hidden' value='{$installer->iuserpass}'>
1235 <input name='iuname' type='hidden' value='{$installer->iuname}'>
1236 <input name='iufname' type='hidden' value='{$installer->iufname}'>
1237 <input name='login' type='hidden' value='{$installer->login}'>
1238 <input name='pass' type='hidden' value='{$installer->pass}'>
1239 <input name='server' type='hidden' value='{$installer->server}'>
1240 <input name='port' type='hidden' value='{$installer->port}'>
1241 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1242 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1244 echo $form_top . "\r\n";
1245 if ($allow_cloning_setup) {
1246 echo "<input type='hidden' name='clone_database' value='$installer->clone_database'>";
1247 echo "<input name='source_site_id' type='hidden' value='$installer->source_site_id'>";
1249 $form_bottom = <<<FRMBOT
1250 <button type='submit' id='step-4-btn' value='Continue' class='wait'><b>$btn_text</b></button>
1255 echo $form_bottom . "\r\n";
1258 $step4_top = <<<STP4TOP
1260 <legend>Step $state - Creating and Configuring Access Control List</legend>
1261 <p>Installing and Configuring Access Controls (php-GACL)...</p><br>
1263 echo $step4_top . "\r\n";
1264 if (! $installer->install_gacl()) {
1266 echo $installer->error_message;
1269 // display the status information for gacl setup
1270 echo $installer->debug_message;
1272 $btn_text = 'Proceed to Step 5';
1273 $step4_bottom = <<<STP4BOT
1274 <p>Gave the '{$installer->iuser}' user (password is '{$installer->iuserpass}') administrator access.</p>
1275 <p>Done installing and configuring access controls (php-gacl).</p>
1276 <p>The next step will configure php.</p>
1277 <p class='bg-warning'>Click <strong>$btn_text</strong> to continue.</p>
1279 <form method='post'>
1280 <input name='state' type='hidden' value='5'>
1281 <input name='site' type='hidden' value='$site_id'>
1282 <input name='iuser' type='hidden' value='{$installer->iuser}'>
1283 <input name='iuserpass' type='hidden' value='{$installer->iuserpass}'>
1284 <input name='login' type='hidden' value='{$installer->login}'>
1285 <input name='pass' type='hidden' value='{$installer->pass}'>
1286 <input name='server' type='hidden' value='{$installer->server}'>
1287 <input name='port' type='hidden' value='{$installer->port}'>
1288 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1289 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1290 <button type='submit' value='Continue'><b>$btn_text</b></button>
1294 echo $step4_bottom . "\r\n";
1298 $step5_top = <<<STP5TOP
1300 <legend>Step $state - Configure PHP</legend>
1301 <p>Configuration of PHP...</p><br>
1302 <p>We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:</p>
1305 echo $step5_top . "\r\n";
1308 $phpINIfile = php_ini_loaded_file();
1310 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
1314 $short_tag = ini_get('short_open_tag')?'On':'Off';
1315 $display_errors = ini_get('display_errors')?'On':'Off';
1316 $register_globals = ini_get('register_globals')?'On':'Off';
1317 $max_input_vars = ini_get('max_input_vars');
1318 $max_execution_time = ini_get('max_execution_time');
1319 $max_input_time = ini_get('max_input_time');
1320 $post_max_size = ini_get('post_max_size');
1321 $memory_limit = ini_get('memory_limit');
1323 $step5_table = <<<STP5TAB
1324 <li>To ensure proper functioning of OpenEMR you must make sure that PHP settings include:
1325 <table class='phpset'>
1328 <th>Required value</th>
1329 <th>Current value</th>
1332 <td>short_open_tag</td>
1337 <td>display_errors</td>
1339 <td>$display_errors</td>
1342 <td>register_globals</td>
1344 <td>$register_globals</td>
1347 <td>max_input_vars</td>
1348 <td>at least 3000</td>
1349 <td>$max_input_vars</td>
1352 <td>max_execution_time</td>
1353 <td>at least 60</td>
1354 <td>$max_execution_time</td>
1357 <td>max_input_time</td>
1359 <td>$max_input_time</td>
1362 <td>post_max_size</td>
1363 <td>at least 30M</td>
1364 <td>$post_max_size</td>
1367 <td>memory_limit</td>
1368 <td>at least 256M</td>
1369 <td>$memory_limit</td>
1373 <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.
1376 echo $step5_table . "\r\n";
1378 if (!$gotFileFlag) {
1379 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";
1382 $btn_text = 'Proceed to Step 6';
1383 $step5_bottom = <<<STP5BOT
1386 <p>We recommend you print these instructions for future reference.</p>
1387 <p>The next step will configure the Apache web server.</p>
1388 <p class='bg-warning'>Click <strong>$btn_text</strong> to continue.</p>
1390 <form method='post'>
1391 <input type='hidden' name='state' value='6'>
1392 <input type='hidden' name='site' value='$site_id'>
1393 <input type='hidden' name='iuser' value='{$installer->iuser}'>
1394 <input type='hidden' name='iuserpass' value='{$installer->iuserpass}'>
1395 <input name='login' type='hidden' value='{$installer->login}'>
1396 <input name='pass' type='hidden' value='{$installer->pass}'>
1397 <input name='server' type='hidden' value='{$installer->server}'>
1398 <input name='port' type='hidden' value='{$installer->port}'>
1399 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1400 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1401 <button type='submit' value='Continue'><b>$btn_text</b></button>
1405 echo $step5_bottom . "\r\n";
1410 echo "<legend>Step $state - Configure Apache Web Server</legend>";
1411 echo "<p>Configuration of Apache web server...</p><br>\n";
1412 echo "The <strong>\"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\"</strong> directory contain patient information, and
1413 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><br>
1414 <Directory \"".realpath(dirname(__FILE__))."\"><br>
1415 AllowOverride FileInfo<br>
1416 Require all granted<br>
1417 </Directory><br>
1418 <Directory \"".realpath(dirname(__FILE__))."/sites\"><br>
1419 AllowOverride None<br>
1420 </Directory><br>
1421 <Directory \"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\"><br>
1422 Require all denied<br>
1423 </Directory><br><br>";
1425 $btn_text = 'Proceed to Select a Theme';
1426 $step6_bottom = <<<STP6BOT
1427 <p>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.</p>
1428 <p>We recommend you print these instructions for future reference.</p>
1429 <p class='bg-warning'>Click <strong>'$btn_text'</strong> to select a theme.</p>
1431 <form method='post'>
1432 <input type='hidden' name='state' value='7'>
1433 <input type='hidden' name='site' value='$site_id'>
1434 <input type='hidden' name='iuser' value='{$installer->iuser}'>
1435 <input type='hidden' name='iuserpass' value='{$installer->iuserpass}'>
1436 <input name='login' type='hidden' value='{$installer->login}'>
1437 <input name='pass' type='hidden' value='{$installer->pass}'>
1438 <input name='server' type='hidden' value='{$installer->server}'>
1439 <input name='port' type='hidden' value='{$installer->port}'>
1440 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1441 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1442 <button type='submit' value='Continue'><b>$btn_text</b></button>
1446 echo $step6_bottom . "\r\n";
1451 echo "<legend>Step $state - Select a Theme</legend>";
1452 echo "<p>Select a theme for OpenEMR...</p><br>\n";
1453 $btn_text = "Proceed to Final Step";
1454 $installer->displaySelectedThemeDiv();
1455 $theme_form = <<<TMF
1457 <div class="col-sm-4 col-sm-offset-4">
1458 <form method='post'>
1459 <input type='hidden' name='state' value='8'>
1460 <input type='hidden' name='site' value='$site_id'>
1461 <input type='hidden' name='iuser' value='{$installer->iuser}'>
1462 <input type='hidden' name='iuserpass' value='{$installer->iuserpass}'>
1463 <input name='login' type='hidden' value='{$installer->login}'>
1464 <input name='pass' type='hidden' value='{$installer->pass}'>
1465 <input name='server' type='hidden' value='{$installer->server}'>
1466 <input name='port' type='hidden' value='{$installer->port}'>
1467 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1468 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1469 <input type='hidden' name='new_theme' id = 'new_theme' value='{$installer->getCurrentTheme()}'>
1470 <input name='clone_database' type='hidden' value='{$installer->clone_database}'>
1471 <input name='source_site_id' type='hidden' value='{$installer->source_site_id}'>
1472 <h4>Select One:</h4>
1473 <div class="checkbox">
1474 <label><input type="checkbox" class="check" value="show_theme">Show More Themes</label>
1476 <div class="checkbox">
1477 <label><input type="checkbox" class="check" value="keep_current">Keep Current</label>
1479 <div class='hide_button' style="display:none;">
1480 <button type='submit' value='Continue' id='continue'>{$btn_text}</button>
1487 echo $theme_form ."\r\n";
1488 echo '<div class="row hideaway" style="display:none;">'."\r\n";
1489 echo '<div class="col-sm-12">'."\r\n";
1490 echo ' <h4>Select New Theme: <h5>(scroll down to view all)</h5></h4>'."\r\n";
1491 echo ' <br>'."\r\n";
1492 $installer->displayThemesDivs();
1499 <legend>Pre Install - Checking File and Directory Permissions</legend>
1500 <p><span class="text">Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</span></p>
1502 <li><span class="text">Before proceeding, be sure that you have a properly installed and configured MySQL server available, and a PHP configured webserver.</span></li>
1503 <li><span class="text mark">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.</span></li>
1504 <li>If you are upgrading from a previous version, <strong>DO NOT</strong> use this script. Please read the <strong>'Upgrading'</strong> section found in the <a href='Documentation/INSTALL' rel='noopener' target='_blank'><span style='text-decoration: underline;'>'INSTALL'</span></a> manual file.
1509 if ($checkPermissions) {
1510 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
1511 echo "<FONT COLOR='green'>Ensuring following file is world-writable...</FONT><br>\n";
1513 foreach ($writableFileList as $tempFile) {
1514 if (is_writable($tempFile)) {
1515 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
1517 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
1518 echo "(configure file permissions; see below for further instructions)</p>\n";
1523 if ($errorWritable) {
1524 $check_file = <<<CHKFILE
1525 <p style="font-color:red;">You can't proceed until all above files are ready (world-writable).</p>
1526 <p>In linux, recommend changing file permissions with the <strong>'chmod 666 filename'</strong> command.</p>
1527 <p class='bg-danger'>Fix above file permissions and then click the <strong>'Check Again'</strong> button to re-check files.</p>
1529 <form method='post'>
1530 <input type='hidden' name='site' value='$site_id'>
1531 <button type='submit' value='check again'><b>Check Again</b></button>
1534 echo $check_file . "\r\n";
1539 foreach ($writableDirList as $tempDir) {
1540 echo "<br><FONT COLOR='green'>Ensuring the '" . realpath($tempDir) . "' directory and its subdirectories have proper permissions...</FONT><br>\n";
1541 $errorWritable = recursive_writable_directory_test($tempDir);
1544 if ($errorWritable) {
1545 $check_directory = <<<CHKDIR
1546 <p style="font-color:red;">You can't proceed until all directories and subdirectories are ready.</p>
1547 <p>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 <strong>'chown -R apache:apache directory_name'</strong> command.</p>
1548 <p class='bg-warning'>Fix above directory permissions and then click the <strong>'Check Again'</strong> button to re-check directories.</p>
1550 <form method='post'>
1551 <input type='hidden' name='site' value='$site_id'>
1552 <button type='submit' value='check again'><b>Check Again</b></button>
1555 echo $check_directory . "\r\n";
1562 <p>All required files and directories have been verified.</p>
1563 <p class='bg-warning'>Click <b>Proceed to Step 1</b> to continue with a new installation.</p>
1564 <p class='bg-danger'>$caution: If you are upgrading from a previous version, <strong>DO NOT</strong> use this script. Please read the <strong>'Upgrading'</strong> section found in the <a href='Documentation/INSTALL' rel='noopener' target='_blank'><span style='text-decoration: underline;'>'INSTALL'</span></a> manual file.</p>
1566 <form method='post'>
1567 <input name='state' type='hidden' value='1'>
1568 <input name='site' type='hidden' value='$site_id'>
1569 <button type='submit' value='Continue'><b>Proceed to Step 1</b></button>
1574 echo "<br>Click to continue installation.<br>\n";
1586 </div><!--end of container div -->
1587 <?php $installer->setupHelpModal();?>
1591 $('.icon-tooltip').prop( "title", "Click to see more information").tooltip({
1597 $('.enter-details-tooltip').prop( "title", "Additional help to fill out this form is available by hovering over labels of each box and clicking on the dark blue help ? icon that is revealed. On mobile devices tap once on the label to reveal the help icon and tap on the icon to show the help section").tooltip();
1598 $('.2fa-section-tooltip').prop( "title", "Two factor authentication prevents unauthorized access to openEMR thus improves security. It is optional. More information is available in the help file under Step 2 Database and OpenEMR Initial User Setup Details.").tooltip();
1603 <script type = "text/javascript" >
1605 $("input[type='radio']").click(function() {
1606 var radioValue = $("input[name='stylesheet']:checked").val();
1607 var imgPath = "public/images/stylesheets/";
1608 var currStyle = $("#current_theme_title").text();
1609 var currStyleTitle = currStyle;
1610 currStyle = currStyle.replace(/\b\w/g, l => l.toLowerCase());
1611 currStyle = currStyle.split(" ");
1612 currStyle = currStyle.join("_");
1613 currStyle = "style_" + currStyle + ".png";
1615 var currThemeText = radioValue.split("_");
1616 currThemeText = currThemeText.join(" ");
1617 currThemeText = currThemeText.replace(/\b\w/g, l => l.toUpperCase());
1618 var styleSelected = confirm("You have selected style - " + currThemeText + "\n" + "Click OK to apply selection");
1619 if (styleSelected) {
1620 $("#current_theme").attr("src", imgPath + "style_" + radioValue + ".png");
1621 $("#current_theme_title").text(currThemeText);
1622 $("#new_theme").val("style_" + radioValue + ".css");
1624 $("#current_theme").attr("src", imgPath + currStyle);
1625 $("#current_theme_title").text(currStyleTitle);
1626 $(this).prop("checked", false);
1630 $('.check').click(function() {
1631 $('.check').not(this).prop('checked', false);
1632 if($('.check:checked').val() == 'show_theme'){
1633 $(".hideaway").show();
1634 } else if($('.check:checked').val() == 'keep_current'){
1635 $(".hideaway").hide();
1638 if($('.check').filter(':checked').length > 0) {
1639 $(".hide_button").show();
1641 $(".hide_button").hide();
1642 $(".hideaway").hide();
1645 $('.wait').removeClass('button-wait');
1647 $( "#create_db_button" ).hover(
1649 if (($('#iuserpass' ).val().length > 11 && $('#iuser' ).val().length > 11 ) || ($('#clone_database').prop('checked'))){
1651 $("button").click(function(){
1652 $(".oe-spinner").css("visibility", "visible");
1655 $('.wait').click(function(){
1656 $('.wait').addClass('button-wait');
1662 $("#step-4-btn").click(function(){
1663 $(".oe-spinner").css("visibility", "visible");
1664 $(this).addClass('button-wait');