another minor fix
[openemr.git] / setup.php
blob6d504225cebcb100ad7ab05fbc9d98410658b932
1 <?php
2 /**
4 * Installation script.
6 * @package OpenEMR
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
16 // Set the maximum excution time and time limit to unlimited.
17 ini_set('max_execution_time', 0);
18 set_time_limit(0);
20 // Warning. If you set $allow_multisite_setup to true, this is a potential security vulnerability.
21 // Recommend setting it back to false (or removing this setup.php script entirely) after you
22 // are done with the multisite procedure.
23 $allow_multisite_setup = false;
25 // Warning. If you set $allow_cloning_setup to true, this is a potential security vulnerability.
26 // Recommend setting it back to false (or removing this setup.php script entirely) after you
27 // are done with the cloning setup procedure.
28 $allow_cloning_setup = false;
29 if (!$allow_cloning_setup && !empty($_REQUEST['clone_database'])) {
30 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");
33 // Checks if the server's PHP version is compatible with OpenEMR:
34 require_once(dirname(__FILE__) . "/common/compatibility/Checker.php");
36 use OpenEMR\Common\Checker;
38 $response = Checker::checkPhpVersion();
39 if ($response !== true) {
40 die($response);
43 $COMMAND_LINE = php_sapi_name() == 'cli';
44 require_once(dirname(__FILE__) . '/library/authentication/password_hashing.php');
45 require_once dirname(__FILE__) . '/library/classes/Installer.class.php';
47 $state = isset($_POST["state"]) ? ($_POST["state"]) : '';
48 $installer = new Installer($_REQUEST);
49 // Make this true for IPPF.
50 $ippf_specific = false;
52 $error_page_end = <<<EPE
53 </div>
54 </div>
55 </div><!--end of container div-->
56 </body>
57 </html>
58 EPE;
60 // If this script was invoked with no site ID, then ask for one.
61 if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
62 $site_id = <<<SITEID
63 <!DOCTYPE html>
64 <html>
65 <head>
66 <title>OpenEMR Setup Tool</title>
67 <!--<link rel=stylesheet href="interface/themes/style_blue.css">-->
68 <link rel="stylesheet" href="public/assets/bootstrap/dist/css/bootstrap.min.css" type="text/css">
69 <link rel="stylesheet" href="public/assets/jquery-ui/jquery-ui.css" type="text/css">
70 <script type="text/javascript" src="public/assets/jquery/dist/jquery.min.js"></script>
71 <script type="text/javascript" src="public/assets/bootstrap/dist/js/bootstrap.min.js"></script>
72 <link rel="stylesheet" href="public/assets/font-awesome/css/font-awesome.min.css" type="text/css">
73 <link rel="shortcut icon" href="public/images/favicon.ico" />
74 <script type="text/javascript" src="public/assets/jquery-ui/jquery-ui.js"></script>
75 <style>
76 .oe-pull-away {
77 float:right;
79 </style>
80 </head>
81 <body>
82 <div class = 'container'>
83 <div class="row">
84 <div class="row">
85 <div class="col-sm-12">
86 <div class="page-header">
87 <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>
88 </div>
89 </div>
90 </div>
91 </div>
92 <div class="row">
93 <div class="col-sm-12">
94 <fieldset>
95 <legend>Optional Site ID Selection</legend>
96 <p>Most OpenEMR installations support only one site. If that is
97 true for you then ignore the rest of this text and just click Continue.</p>
98 <p>Otherwise please enter a unique Site ID here.</p>
99 <p>A Site ID is a short identifier with no spaces or special
100 characters other than periods or dashes. It is case-sensitive and we
101 suggest sticking to lower case letters for ease of use.</p>
102 <p>If each site will have its own host/domain name, then use that
103 name as the Site ID (e.g. www.example.com).</p>
104 <p>The site ID is used to identify which site you will log in to.
105 If it is a hostname then it is taken from the hostname in the URL.
106 Otherwise you must append "?site=<i>siteid</i>" to the URL used for
107 logging in.</p>
108 <p>It is OK for one of the sites to have "default" as its ID. This
109 is the ID that will be used if it cannot otherwise be determined.</p>
110 <br>
111 <form method='post'>
112 <input type='hidden' name='state' value='0'>
113 Site ID: <input type='text' name='site' value='default'>
114 <button type='submit' value='Continue'>Continue</button>
115 </form>
116 </fieldset>
117 </div>
118 </div>
119 </div><!--end of container div-->
120 SITEID;
121 echo $site_id . "\r\n";
122 $installer->setupHelpModal();
123 echo "</body>". "\r\n";
124 echo "</html>". "\r\n";
126 exit();
129 // Support "?site=siteid" in the URL, otherwise assume "default".
130 $site_id = 'default';
131 if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
132 $site_id = trim($_REQUEST['site']);
135 // Die if site ID is empty or has invalid characters.
136 if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) {
137 die("Site ID '".htmlspecialchars($site_id, ENT_NOQUOTES)."' contains invalid characters.");
140 // If multisite is turned off, then only allow default for site.
141 if (!$allow_multisite_setup && $site_id != 'default') {
142 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");
145 //If having problems with file and directory permission
146 // checking, then can be manually disabled here.
147 $checkPermissions = true;
149 global $OE_SITE_DIR; // The Installer sets this
151 $docsDirectory = "$OE_SITE_DIR/documents";
152 $billingDirectory = "$OE_SITE_DIR/edi";
153 $billingDirectory2 = "$OE_SITE_DIR/era";
154 $lettersDirectory = "$OE_SITE_DIR/letter_templates";
155 $gaclWritableDirectory = dirname(__FILE__)."/gacl/admin/templates_c";
156 $requiredDirectory1 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/compiled";
157 $requiredDirectory2 = dirname(__FILE__)."/interface/main/calendar/modules/PostCalendar/pntemplates/cache";
159 $zendModuleConfigFile = dirname(__FILE__)."/interface/modules/zend_modules/config/application.config.php";
161 //These are files and dir checked before install for
162 // correct permissions.
163 if (is_dir($OE_SITE_DIR)) {
164 $writableFileList = array($installer->conffile,$zendModuleConfigFile);
165 $writableDirList = array($docsDirectory, $billingDirectory, $billingDirectory2, $lettersDirectory, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
166 } else {
167 $writableFileList = array();
168 $writableDirList = array($OE_SITES_BASE, $gaclWritableDirectory, $requiredDirectory1, $requiredDirectory2);
171 // Include the sqlconf file if it exists yet.
172 $config = 0;
173 if (file_exists($OE_SITE_DIR)) {
174 include_once($installer->conffile);
175 } elseif ($state > 3) {
176 // State 3 should have created the site directory if it is missing.
177 die("Internal error, site directory is missing.");
180 <html>
181 <head>
182 <title>OpenEMR Setup Tool</title>
183 <!--<link rel=stylesheet href="interface/themes/style_blue.css">-->
184 <link rel="stylesheet" href="public/assets/bootstrap/dist/css/bootstrap.min.css" type="text/css">
185 <link rel="stylesheet" href="public/assets/jquery-ui/jquery-ui.css" type="text/css">
186 <script type="text/javascript" src="public/assets/jquery/dist/jquery.min.js"></script>
187 <script type="text/javascript" src="public/assets/bootstrap/dist/js/bootstrap.min.js"></script>
188 <script type="text/javascript" src="public/assets/jquery-ui/jquery-ui.js"></script>
189 <link rel="stylesheet" href="public/assets/font-awesome/css/font-awesome.min.css" type="text/css">
190 <link rel="shortcut icon" href="public/images/favicon.ico" />
192 <style>
193 .noclone { }
194 table.phpset {
195 border-collapse:collapse;
197 table.phpset td, table.phpset th {
198 font-size:9pt;
199 border:1px solid gray;
200 padding:2px;
202 .table.no-border tr td, .table.no-border tr th {
203 border-width: 0;
205 td {
206 font-size:10pt;
208 .inputtext {
209 padding-left:2px;
210 padding-right:2px;
213 .button {
214 font-family:sans-serif;
215 font-size:9pt;
216 font-weight:bold;
219 .label-div > a {
220 display:none;
222 .label-div:hover > a {
223 display:inline-block;
225 div[id$="_info"] {
226 background: #F7FAB3;
227 padding: 20px;
228 margin: 10px 15px 0px 15px;
230 div[id$="_info"] > a {
231 margin-left:10px;
233 .checkboxgroup {
234 display: inline-block;
235 text-align: center;
237 .checkboxgroup label {
238 display: block;
240 .oe-pull-away{
241 float:right;
243 .oe-help-x {
244 color: grey;
245 padding: 0 5px;
247 .oe-superscript {
248 position: relative;
249 top: -.5em;
250 font-size: 70%!important;
252 .oe-setup-legend{
253 background-color: WHITESMOKE;
254 padding:0 10px;
256 button {
257 font-weight:bold;
259 .button-wait {
260 color: grey;
261 cursor: not-allowed;
262 opacity: 0.6;
264 @media only screen {
265 fieldset > [class*="col-"] {
266 width: 100%;
267 text-align:left!Important;
270 </style>
271 <script language="javascript">
272 // onclick handler for "clone database" checkbox
273 function cloneClicked() {
274 var cb = document.forms[0].clone_database;
275 $('.noclone').css('display', cb.checked ? 'none' : 'block');
277 </script>
279 </head>
280 <body>
281 <div class = 'container'>
282 <div class="row">
283 <div class="col-sm-12">
284 <div class="page-header">
285 <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>
286 </div>
287 </div>
288 </div>
289 <div class="row">
290 <div class="col-sm-12">
291 <?php
292 $error = "<span class='text-danger'><b>ERROR</b></span>";
293 $caution = "<span class='text-danger'><b>CAUTION</b></span>";
294 $ok = "<span class='text-success'><b>OK</b></span>";
295 $note = "<span class='text-primary'><b>NOTE</b></span>";
297 if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
298 echo "$caution: It appears that you have register_globals enabled in your php.ini\n" .
299 "configuration file. This causes unacceptable security risks. You must\n" .
300 "turn it off before continuing with installation.\n";
301 exit(1);
304 if (!extension_loaded("xml")) {
305 echo "$error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
306 exit(1);
309 if (!(extension_loaded("mysql") || extension_loaded("mysqlnd") || extension_loaded("mysqli"))) {
310 echo "$error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
311 exit(1);
314 if (!(extension_loaded("mbstring") )) {
315 echo "$error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
316 exit(1);
319 if (!(extension_loaded("openssl") )) {
320 echo "$error: PHP openssl extension missing. To continue, install PHP openssl extension, then restart web server.";
321 exit(1);
325 <?php
326 if ($state == 8) {
329 <fieldset>
330 <legend>Final step - Success</legend>
331 <p>Congratulations! OpenEMR is now installed.</p>
333 <ul>
334 <li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
335 OpenEMR's admin->acl menu.</li>
336 <li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
337 contains some settings that you may want to change.</li>
338 <li>There's much information and many extra tools bundled within the OpenEMR installation directory.
339 Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
340 <li>To ensure a consistent look and feel throughout the application,
341 <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>
342 <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>
343 <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>
344 </ul>
345 <p>We recommend you print these instructions for future reference.</p>
346 <?php
347 if (empty($installer->clone_database)) {
348 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>";
349 echo "<p> The selected theme is :</p>";
350 $installer->displayNewThemeDiv();
351 $installer->setCurrentTheme();
352 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>";
353 echo "<p>In Linux use the following command:</p>";
354 echo "<p><code>sudo apachectl -k restart</code></p>";
355 } ?>
357 <a href='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR. </a>
358 </p>
359 </fieldset>
360 <?php
361 $end_div = <<<ENDDIV
362 </div>
363 </div>
364 </div><!--end of container div-->
365 ENDDIV;
366 echo $end_div . "\r\n";
367 $installer->setupHelpModal();
368 echo "</body>". "\r\n";
369 echo "</html>". "\r\n";
371 exit();
375 <?php
377 $inst = isset($_POST["inst"]) ? ($_POST["inst"]) : '';
379 if (($config == 1) && ($state < 4)) {
380 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";
381 } else {
382 switch ($state) {
383 case 1:
384 $step1 = <<<STP1
385 <fieldset>
386 <legend>Step $state - Select Database Setup</legend>
387 <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.
388 <br>
389 <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>.
390 <br>
391 <form method='post'>
392 <input name='state' type='hidden' value='2'>
393 <input name='site' type='hidden' value='$site_id'>
394 <label for='inst1'>
395 <input checked id='inst1' name='inst' type='radio' value='1'>Have setup create the database
396 </label><br>
397 <label for='inst2'>
398 <input id='inst2' name='inst' type='radio' value='2'>I have already created the database
399 </label><br>
400 <br>
401 <button type='submit' value='Continue'><b>Proceed to Step 2</b></button>
402 </form><br>
403 </fieldset>
404 STP1;
405 echo $step1 ."\r\n";
406 break;
408 case 2:
409 $step2top = <<<STP2TOP
410 <fieldset>
411 <legend>Step $state - Database and OpenEMR Initial User Setup Details</legend>
412 <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.
413 <br><br>
414 <form method='post' id='myform'>
415 <input name='state' type='hidden' value='3'>
416 <input name='site' type='hidden' value='$site_id'>
417 <input name='inst' type='hidden' value='$inst'>
418 STP2TOP;
419 echo $step2top ."\r\n";
422 $step2tabletop1 = <<<STP2TBLTOP1
423 <fieldset>
424 <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>
425 <div class="row">
426 <div class="col-xs-12 ">
427 <div class="col-sm-4">
428 <div class="clearfix form-group">
429 <div class="label-div">
430 <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>
431 </div>
432 <div>
433 <input name='server' id='server' type='text' class='form-control' value='localhost'>
435 </div>
436 </div>
437 <div id="server_info" class="collapse">
438 <a href="#server_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
439 <p>If you run MySQL and Apache/PHP on the same computer, then leave this as 'localhost'.
440 <p>If they are on separate computers, then enter the IP address of the computer running MySQL.
442 </div>
443 </div>
444 <div class="col-sm-4">
445 <div class="clearfix form-group">
446 <div class="label-div">
447 <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>
448 </div>
449 <div>
450 <input name='port' id='port' type='text' class='form-control' value='3306'>
451 </div>
452 </div>
453 <div id="port_info" class="collapse">
454 <a href="#port_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
455 <p>This is the MySQL port.
456 <p>The default port for MySQL is 3306.
457 </div>
458 </div>
459 <div class="col-sm-4">
460 <div class="clearfix form-group">
461 <div class="col-sm-12 label-div">
462 <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>
463 </div>
464 <div class="col-sm-12">
465 <input name='dbname' id='dbname' type='text' class='form-control' value='openemr'>
466 </div>
467 </div>
468 <div id="dbname_info" class="collapse">
469 <a href="#dbname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
470 <p>This will be the name of the OpenEMR database in MySQL.
471 <p>'openemr' is the recommended name.
472 <p>This database will contain patient data as well as data pertaining to the OpenEMR installation.
473 </div>
474 </div>
475 </div>
476 </div>
477 <div class="row">
478 <div class="col-xs-12 ">
479 <div class="col-sm-4">
480 <div class="clearfix form-group">
481 <div class="label-div">
482 <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>
483 </div>
484 <div>
485 <input name='login' ID='login' type='text' class='form-control' value='openemr'>
487 </div>
488 </div>
489 <div id="login_info" class="collapse">
490 <a href="#login_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
491 <p>This is the name that OpenEMR will use to login to the MySQL database.
492 <p>'openemr' is the recommended name.
493 </div>
494 </div>
495 <div class="col-sm-4">
496 <div class="clearfix form-group">
497 <div class="label-div">
498 <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>
499 </div>
500 <div>
501 <input name='pass' id='pass' class='form-control' type='password' value='' minlength='12' required>
502 </div>
503 </div>
504 <div id="pass_info" class="collapse">
505 <a href="#pass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
506 <p>This is the Login Password that OpemEMR will use to accesses the MySQL database.
507 <p>It should be at least 12 characters long and composed of both numbers and letters.
508 </div>
509 </div>
510 STP2TBLTOP1;
511 echo $step2tabletop1 ."\r\n";
512 if ($inst != 2) {
513 $step2tabletop2 = <<<STP2TBLTOP2
514 <div class="col-sm-4">
515 <div class="clearfix form-group">
516 <div class="col-sm-12 label-div">
517 <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>
518 </div>
519 <div class="col-sm-12">
520 <input name='root' id='root'type='text' class='form-control' value='root'>
521 </div>
522 </div>
523 <div id="root_info" class="collapse">
524 <a href="#root_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
525 <p>This is name for the MySQL root account.
526 <p>For localhost, it is usually ok to leave it as 'root'.
527 </div>
528 </div>
529 </div>
530 </div>
531 <div class="row">
532 <div class="col-xs-12 ">
533 <div class="col-sm-4">
534 <div class="clearfix form-group">
535 <div class="label-div">
536 <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>
537 </div>
538 <div>
539 <input name='rootpass' id='rootpass' type='password' class='form-control' value=''>
541 </div>
542 </div>
543 <div id="rootpass_info" class="collapse">
544 <a href="#rootpass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
545 <p>This is your MySQL server root password.
546 <p>For localhost, it is usually ok to leave it blank.
547 </div>
548 </div>
549 <div class="col-sm-4">
550 <div class="clearfix form-group">
551 <div class="label-div">
552 <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>
553 </div>
554 <div>
555 <input name='loginhost' id='loginhost' type='text' class='form-control' value='localhost'>
556 </div>
557 </div>
558 <div id="loginhost_info" class="collapse">
559 <a href="#loginhost_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
560 <p>If you run Apache/PHP and MySQL on the same computer, then leave this as 'localhost'.
561 <p>If they are on separate computers, then enter the IP address of the computer running Apache/PHP.
562 </div>
563 </div>
564 <div class="col-sm-4">
565 <div class="clearfix form-group">
566 <div class="col-sm-12 label-div">
567 <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>
568 </div>
569 <div class="col-sm-12">
570 <select name='collate' id=='collate' class='form-control'>
571 <option value='utf8_bin'>
573 </option>
574 <option value='utf8_czech_ci'>
575 Czech
576 </option>
577 <option value='utf8_danish_ci'>
578 Danish
579 </option>
580 <option value='utf8_esperanto_ci'>
581 Esperanto
582 </option>
583 <option value='utf8_estonian_ci'>
584 Estonian
585 </option>
586 <option selected value='utf8_general_ci'>
587 General
588 </option>
589 <option value='utf8_hungarian_ci'>
590 Hungarian
591 </option>
592 <option value='utf8_icelandic_ci'>
593 Icelandic
594 </option>
595 <option value='utf8_latvian_ci'>
596 Latvian
597 </option>
598 <option value='utf8_lithuanian_ci'>
599 Lithuanian
600 </option>
601 <option value='utf8_persian_ci'>
602 Persian
603 </option>
604 <option value='utf8_polish_ci'>
605 Polish
606 </option>
607 <option value='utf8_roman_ci'>
608 Roman
609 </option>
610 <option value='utf8_romanian_ci'>
611 Romanian
612 </option>
613 <option value='utf8_slovak_ci'>
614 Slovak
615 </option>
616 <option value='utf8_slovenian_ci'>
617 Slovenian
618 </option>
619 <option value='utf8_spanish2_ci'>
620 Spanish2 (Traditional)
621 </option>
622 <option value='utf8_spanish_ci'>
623 Spanish (Modern)
624 </option>
625 <option value='utf8_swedish_ci'>
626 Swedish
627 </option>
628 <option value='utf8_turkish_ci'>
629 Turkish
630 </option>
631 <option value='utf8_unicode_ci'>
632 Unicode (German, French, Russian, Armenian, Greek)
633 </option>
634 <option value=''>
635 None (Do not force UTF-8)
636 </option>
637 </select>
638 </div>
639 </div>
640 <div id="collate_info" class="collapse">
641 <a href="#collate_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
642 <p>This is the collation setting for MySQL.
643 <p>Collation refers to a set of rules that determine how data is sorted and compared in a database.
644 <p>Leave as 'General' if you are not sure.
645 <p>If the language you are planning to use in OpenEMR is in the menu, then you can select it.
646 <p>Otherwise, just select 'General'.
647 </div>
648 </div>
649 </div>
650 </div>
651 STP2TBLTOP2;
652 echo $step2tabletop2 ."\r\n";
654 // Include a "source" site ID drop-list and a checkbox to indicate
655 // if cloning its database. When checked, do not display initial user
656 // and group stuff below.
657 $dh = opendir($OE_SITES_BASE);
658 if (!$dh) {
659 die("Cannot read directory '$OE_SITES_BASE'.");
662 $siteslist = array();
663 while (false !== ($sfname = readdir($dh))) {
664 if (substr($sfname, 0, 1) == '.') {
665 continue;
668 if ($sfname == 'CVS') {
669 continue;
672 if ($sfname == $site_id) {
673 continue;
676 $sitedir = "$OE_SITES_BASE/$sfname";
677 if (!is_dir($sitedir)) {
678 continue;
681 if (!is_file("$sitedir/sqlconf.php")) {
682 continue;
685 $siteslist[$sfname] = $sfname;
688 closedir($dh);
689 // If this is not the first site...
690 if (!empty($siteslist)) {
691 ksort($siteslist);
692 $source_site_top = <<<SOURCESITETOP
693 <div class="row">
694 <div class="col-xs-12 ">
695 <div class="col-sm-4">
696 <div class="clearfix form-group">
697 <div class="label-div">
698 <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>
699 </div>
700 <div>
701 <select name='source_site_id'id='source_site_id' class='form-control'>
702 SOURCESITETOP;
703 echo $source_site_top . "\r\n";
704 foreach ($siteslist as $sfname) {
705 echo "<option value='$sfname'";
706 if ($sfname == 'default') {
707 echo " selected";
710 echo ">$sfname</option>";
712 $source_site_bot = <<<SOURCESITEBOT
713 </select>
715 </div>
716 </div>
717 <div id="source_site_id_info" class="collapse">
718 <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>
719 <p>The site directory that will be a model for the new site.
720 </div>
721 </div>
722 <div class="col-sm-4">
723 <div class="clearfix form-group">
724 <div class="label-div">
725 <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>
726 </div>
727 <div>
728 <input type='checkbox' name='clone_database' onclick='cloneClicked()' />
729 </div>
730 </div>
731 <div id="clone_database_info" class="collapse">
732 <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>
733 <p>Clone the source site's database instead of creating a fresh one.
734 </div>
735 </div>
736 </div>
737 </div>
738 SOURCESITEBOT;
739 echo $source_site_bot ."\r\n";
741 $randomusername = chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . "-admin-" . rand(0, 9) . rand(0, 9);
742 $step2tablebot = <<<STP2TBLBOT
743 </fieldset>
744 <br>
745 <fieldset class='noclone'>
746 <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>
747 <div class="row">
748 <div class="col-xs-12 ">
749 <div class="col-sm-4">
750 <div class="clearfix form-group">
751 <div class="label-div">
752 <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>
753 </div>
754 <div>
755 <input name='iuser' id='iuser' type='text' class='form-control' value='$randomusername' minlength='12'>
757 </div>
758 </div>
759 <div id="iuser_info" class="collapse">
760 <a href="#iuser_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
761 <p>This is the login name of the first user that will be created for you.
762 <p>Limit this to one word with at least 12 characters and composed of both numbers and letters.
764 </div>
765 </div>
766 <div class="col-sm-4">
767 <div class="clearfix form-group">
768 <div class="label-div">
769 <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>
770 </div>
771 <div>
772 <input name='iuserpass' id='iuserpass' type='password' class='form-control' value='' minlength='12'>
773 </div>
774 </div>
775 <div id="iuserpass_info" class="collapse">
776 <a href="#iuserpass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
777 <p>This is the password for the initial user.
778 </div>
779 </div>
780 <div class="col-sm-4">
781 <div class="clearfix form-group">
782 <div class="col-sm-12 label-div">
783 <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>
784 </div>
785 <div class="col-sm-12">
786 <input name='iufname' id='iufname 'type='text' class='form-control' value='Administrator'>
787 </div>
788 </div>
789 <div id="iufname_info" class="collapse">
790 <a href="#iufname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
791 <p>This is the First name of the 'initial user'.
792 </div>
793 </div>
794 </div>
795 </div>
796 <div class="row">
797 <div class="col-xs-12 ">
798 <div class="col-sm-4">
799 <div class="clearfix form-group">
800 <div class="label-div">
801 <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>
802 </div>
803 <div>
804 <input name='iuname' id='iuname' type='text' class='form-control' value='Administrator'>
806 </div>
807 </div>
808 <div id="iuname_info" class="collapse">
809 <a href="#iuname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
810 <p>This is the Last name of the 'initial user'.
811 </div>
812 </div>
813 <div class="col-sm-4">
814 <div class="clearfix form-group">
815 <div class="label-div">
816 <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>
817 </div>
818 <div>
819 <input name='igroup' id='igroup' class='form-control' type='text' value='Default'>
820 </div>
821 </div>
822 <div id="igroup_info" class="collapse">
823 <a href="#igroup_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
824 <p>This is the group that will be created for your users.
825 <p>This should be the name of your practice.
826 </div>
827 </div>
828 </div>
829 </div>
830 </fieldset>
831 <p class='bg-warning'>Click the <b>Create DB and User</b> button to create the database and first user. $note: This process will take a few minutes.</p>
832 <!--<p class='bg-success'>Upon successful completion will automatically take you to the next step.</p>-->
833 <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>
834 <button type='submit' id='create_db_button' value='Continue' class='wait'><b>Create DB and User</b></button>
835 </form>
836 </fieldset>
837 STP2TBLBOT;
838 echo $step2tablebot ."\r\n";
839 break;
841 case 3:
842 // Form Validation
843 // (applicable if not cloning from another database)
845 $pass_step2_validation = true;
846 $error_step2_message = "$error - ";
848 if (! $installer->char_is_valid($_REQUEST['server'])) {
849 $pass_step2_validation = false;
850 $error_step2_message .= "A database server host is required <br>\n";
853 if (! $installer->char_is_valid($_REQUEST['port'])) {
854 $pass_step2_validation = false;
855 $error_step2_message .= "A database server port value is required <br>\n";
858 if (! $installer->databaseNameIsValid($_REQUEST['dbname'])) {
859 $pass_step2_validation = false;
860 $error_step2_message .= "A database name is required <br>\n";
863 if (! $installer->collateNameIsValid($_REQUEST['collate'])) {
864 $pass_step2_validation = false;
865 $error_step2_message .= "A collation name is required <br>\n";
868 if (! $installer->char_is_valid($_REQUEST['login'])) {
869 $pass_step2_validation = false;
870 $error_step2_message .= "A database login name is required <br>\n";
873 if (! $installer->char_is_valid($_REQUEST['pass'])) {
874 $pass_step2_validation = false;
875 $error_step2_message .= "A database login password is required <br>\n";
878 if (!$pass_step2_validation) {
879 $error_step2_message .= $error_page_end . "\r\n";
880 die($error_step2_message);
884 if (empty($installer->clone_database)) {
885 if (! $installer->login_is_valid()) {
886 echo "$error. Please pick a proper 'Login Name'.<br>\n";
887 echo "Click Back in browser to re-enter.<br>\n";
888 break;
891 if (! $installer->iuser_is_valid()) {
892 echo "$error. The 'Initial User' field can only contain one word and no spaces.<br>\n";
893 echo "Click Back in browser to re-enter.<br>\n";
894 break;
897 if (! $installer->user_password_is_valid()) {
898 echo "$error. Please pick a proper 'Initial User Password'.<br>\n";
899 echo "Click Back in browser to re-enter.<br>\n";
900 break;
904 if (! $installer->password_is_valid()) {
905 echo "$error. Please pick a proper 'Password'.<br>\n";
906 echo "Click Back in browser to re-enter.<br>\n";
907 break;
910 echo "<fieldset>";
911 echo "<legend>Step $state - Creating Database and First User</legend>";
913 // Skip below if database shell has already been created.
914 if ($inst != 2) {
915 echo "Connecting to MySQL Server...\n";
916 flush();
917 if (! $installer->root_database_connection()) {
918 echo "$error. Check your login credentials.\n";
919 echo $installer->error_message;
920 break;
921 } else {
922 echo "$ok.<br>\n";
923 flush();
927 // Only pertinent if cloning another installation database
928 if ($allow_cloning_setup && !empty($installer->clone_database)) {
929 echo "Dumping source database...";
930 flush();
931 if (! $installer->create_dumpfiles()) {
932 echo $installer->error_message;
933 break;
934 } else {
935 echo "$ok.<br>\n";
936 flush();
940 // Only pertinent if mirroring another installation directory
941 if (! empty($installer->source_site_id)) {
942 echo "Creating site directory...";
943 if (! $installer->create_site_directory()) {
944 echo $installer->error_message;
945 break;
946 } else {
947 echo "$ok.<br>";
948 flush();
952 // Skip below if database shell has already been created.
953 if ($inst != 2) {
954 echo "Creating database...\n";
955 flush();
956 if (! $installer->create_database()) {
957 echo "$error. Check your login credentials.\n";
958 echo $installer->error_message;
959 break;
960 } else {
961 echo "$ok.<br>\n";
962 flush();
965 echo "Creating user with permissions for database...\n";
966 flush();
967 $user_mysql_error = true;
968 if (! $installer->create_database_user()) {
969 echo "$error when creating specified user.\n";
970 echo $installer->error_message;
971 break;
972 } else {
973 $user_mysql_error = false;
975 if (! $installer->grant_privileges()) {
976 echo "$error when granting privileges to the specified user.\n";
977 echo $installer->error_message;
978 break;
979 } else {
980 $user_mysql_error = false;
982 if (!$user_mysql_error) {
983 echo "$ok.<br>\n";
984 flush();
987 echo "Reconnecting as new user...\n";
988 flush();
989 $installer->disconnect();
990 } else {
991 echo "Connecting to MySQL Server...\n";
994 if (! $installer->user_database_connection()) {
995 echo "$error. Check your login credentials.\n";
996 echo $installer->error_message;
997 break;
998 } else {
999 echo "$ok.<br>\n";
1000 flush();
1003 // Load the database files
1004 $dump_results = $installer->load_dumpfiles();
1005 if (! $dump_results) {
1006 echo "$error.\n";
1007 echo $installer->error_message;
1008 break;
1009 } else {
1010 echo $dump_results;
1011 flush();
1014 echo "Writing SQL configuration...\n";
1015 flush();
1016 if (! $installer->write_configuration_file()) {
1017 echo "$error.\n";
1018 echo $installer->error_message;
1019 break;
1020 } else {
1021 echo "$ok.<br>\n";
1022 flush();
1025 // Only pertinent if not cloning another installation database
1026 if (empty($installer->clone_database)) {
1027 echo "Setting version indicators...\n";
1028 flush();
1029 if (! $installer->add_version_info()) {
1030 echo "$error.\n";
1031 echo $installer->error_message;
1033 break;
1034 } else {
1035 echo "$ok<br>\n";
1036 flush();
1039 echo "Writing global configuration defaults...\n";
1040 flush();
1041 if (! $installer->insert_globals()) {
1042 echo "$error.\n";
1043 echo $installer->error_message;
1045 break;
1046 } else {
1047 echo "$ok<br>\n";
1048 flush();
1051 echo "Adding Initial User...\n";
1052 flush();
1053 if (! $installer->add_initial_user()) {
1054 echo "$error.\n";
1055 echo $installer->error_message;
1056 break;
1059 echo "$ok<br>\n";
1060 flush();
1063 if ($allow_cloning_setup && !empty($installer->clone_database)) {
1064 // Database was cloned, skip ACL setup.
1065 $btn_text = 'Proceed to Final Step';
1066 echo "<br>";
1067 echo "<p>The database was cloned, access control list exists therefore skipping ACL setup and skipping theme setup</p>";
1068 echo "<p class='bg-warning'>Click <b>$btn_text</b> for further instructions.</p>";
1069 $next_state = 8;
1070 } else {
1071 $btn_text = 'Proceed to Step 4';
1072 echo "<br>";
1073 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>";
1074 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>";
1075 $next_state = 4;
1078 $form_top = <<<FRMTOP
1079 <form method='post'>
1080 <input name='state' type='hidden' value='$next_state'>
1081 <input name='site' type='hidden' value='$site_id'>
1082 <input name='iuser' type='hidden' value='{$installer->iuser}'>
1083 <input name='iuserpass' type='hidden' value='{$installer->iuserpass}'>
1084 <input name='iuname' type='hidden' value='{$installer->iuname}'>
1085 <input name='iufname' type='hidden' value='{$installer->iufname}'>
1086 <input name='login' type='hidden' value='{$installer->login}'>
1087 <input name='pass' type='hidden' value='{$installer->pass}'>
1088 <input name='server' type='hidden' value='{$installer->server}'>
1089 <input name='port' type='hidden' value='{$installer->port}'>
1090 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1091 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1092 FRMTOP;
1093 echo $form_top . "\r\n";
1094 if ($allow_cloning_setup) {
1095 echo "<input type='hidden' name='clone_database' value='$installer->clone_database'>";
1097 $form_bottom = <<<FRMBOT
1098 <button type='submit' id='step-4-btn' value='Continue' class='wait'><b>$btn_text</b></button>
1099 <br>
1100 </form>
1101 </fieldset>
1102 FRMBOT;
1103 echo $form_bottom . "\r\n";
1104 break;
1105 case 4:
1106 $step4_top = <<<STP4TOP
1107 <fieldset>
1108 <legend>Step $state - Creating and Configuring Access Control List</legend>
1109 <p>Installing and Configuring Access Controls (php-GACL)...</p><br>
1110 STP4TOP;
1111 echo $step4_top . "\r\n";
1112 if (! $installer->install_gacl()) {
1113 echo "$error -.\n";
1114 echo $installer->error_message;
1115 break;
1116 } else {
1117 // display the status information for gacl setup
1118 echo $installer->debug_message;
1120 $btn_text = 'Proceed to Step 5';
1121 $step4_bottom = <<<STP4BOT
1122 <p>Gave the '{$installer->iuser}' user (password is '{$installer->iuserpass}') administrator access.</p>
1123 <p>Done installing and configuring access controls (php-gacl).</p>
1124 <p>The next step will configure php.</p>
1125 <p class='bg-warning'>Click <strong>$btn_text</strong> to continue.</p>
1126 <br>
1127 <form method='post'>
1128 <input name='state' type='hidden' value='5'>
1129 <input name='site' type='hidden' value='$site_id'>
1130 <input name='iuser' type='hidden' value='{$installer->iuser}'>
1131 <input name='iuserpass' type='hidden' value='{$installer->iuserpass}'>
1132 <input name='login' type='hidden' value='{$installer->login}'>
1133 <input name='pass' type='hidden' value='{$installer->pass}'>
1134 <input name='server' type='hidden' value='{$installer->server}'>
1135 <input name='port' type='hidden' value='{$installer->port}'>
1136 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1137 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1138 <button type='submit' value='Continue'><b>$btn_text</b></button>
1139 </form>
1140 </fieldset>
1141 STP4BOT;
1142 echo $step4_bottom . "\r\n";
1143 break;
1145 case 5:
1146 $step5_top = <<<STP5TOP
1147 <fieldset>
1148 <legend>Step $state - Configure PHP</legend>
1149 <p>Configuration of PHP...</p><br>
1150 <p>We recommend making the following changes to your PHP installation, which can normally be done by editing the php.ini configuration file:</p>
1151 <ul>
1152 STP5TOP;
1153 echo $step5_top . "\r\n";
1154 $gotFileFlag = 0;
1155 if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
1156 $phpINIfile = php_ini_loaded_file();
1157 if ($phpINIfile) {
1158 echo "<li><font color='green'>Your php.ini file can be found at ".$phpINIfile."</font></li>\n";
1159 $gotFileFlag = 1;
1163 $short_tag = ini_get('short_open_tag')?'On':'Off';
1164 $display_errors = ini_get('display_errors')?'On':'Off';
1165 $register_globals = ini_get('register_globals')?'On':'Off';
1166 $max_input_vars = ini_get('max_input_vars');
1167 $max_execution_time = ini_get('max_execution_time');
1168 $max_input_time = ini_get('max_input_time');
1169 $post_max_size = ini_get('post_max_size');
1170 $memory_limit = ini_get('memory_limit');
1172 $step5_table = <<<STP5TAB
1173 <li>To ensure proper functioning of OpenEMR you must make sure that PHP settings include:
1174 <table class='phpset'>
1175 <tr>
1176 <th>Setting</th>
1177 <th>Required value</th>
1178 <th>Current value</th>
1179 </tr>
1180 <tr>
1181 <td>short_open_tag</td>
1182 <td>Off</td>
1183 <td>$short_tag</td>
1184 </tr>
1185 <tr>
1186 <td>display_errors</td>
1187 <td>Off</td>
1188 <td>$display_errors</td>
1189 </tr>
1190 <tr>
1191 <td>register_globals</td>
1192 <td>Off</td>
1193 <td>$register_globals</td>
1194 </tr>
1195 <tr>
1196 <td>max_input_vars</td>
1197 <td>at least 3000</td>
1198 <td>$max_input_vars</td>
1199 </tr>
1200 <tr>
1201 <td>max_execution_time</td>
1202 <td>at least 60</td>
1203 <td>$max_execution_time</td>
1204 </tr>
1205 <tr>
1206 <td>max_input_time</td>
1207 <td>-1</td>
1208 <td>$max_input_time</td>
1209 </tr>
1210 <tr>
1211 <td>post_max_size</td>
1212 <td>at least 30M</td>
1213 <td>$post_max_size</td>
1214 </tr>
1215 <tr>
1216 <td>memory_limit</td>
1217 <td>at least 256M</td>
1218 <td>$memory_limit</td>
1219 </tr>
1220 </table>
1221 </li>
1222 <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.
1223 </li>
1224 STP5TAB;
1225 echo $step5_table . "\r\n";
1227 if (!$gotFileFlag) {
1228 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";
1231 $btn_text = 'Proceed to Step 6';
1232 $step5_bottom = <<<STP5BOT
1233 </ul>
1235 <p>We recommend you print these instructions for future reference.</p>
1236 <p>The next step will configure the Apache web server.</p>
1237 <p class='bg-warning'>Click <strong>$btn_text</strong> to continue.</p>
1238 <br>
1239 <form method='post'>
1240 <input type='hidden' name='state' value='6'>
1241 <input type='hidden' name='site' value='$site_id'>
1242 <input type='hidden' name='iuser' value='{$installer->iuser}'>
1243 <input type='hidden' name='iuserpass' value='{$installer->iuserpass}'>
1244 <input name='login' type='hidden' value='{$installer->login}'>
1245 <input name='pass' type='hidden' value='{$installer->pass}'>
1246 <input name='server' type='hidden' value='{$installer->server}'>
1247 <input name='port' type='hidden' value='{$installer->port}'>
1248 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1249 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1250 <button type='submit' value='Continue'><b>$btn_text</b></button>
1251 </form>
1252 </fieldset>
1253 STP5BOT;
1254 echo $step5_bottom . "\r\n";
1255 break;
1257 case 6:
1258 echo "<fieldset>";
1259 echo "<legend>Step $state - Configure Apache Web Server</legend>";
1260 echo "<p>Configuration of Apache web server...</p><br>\n";
1261 echo "The <strong>\"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\", \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory))."\"</strong> and <strong>\"".preg_replace("/${site_id}/", "*", realpath($billingDirectory2))."\"</strong> directories contain patient information, and
1262 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>
1263 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."\"&gt;<br>
1264 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride FileInfo<br>
1265 &nbsp;&nbsp;&lt;/Directory&gt;<br>
1266 &nbsp;&nbsp;&lt;Directory \"".realpath(dirname(__FILE__))."/sites\"&gt;<br>
1267 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride None<br>
1268 &nbsp;&nbsp;&lt;/Directory&gt;<br>
1269 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/", "*", realpath($docsDirectory))."\"&gt;<br>
1270 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
1271 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
1272 &nbsp;&nbsp;&lt;/Directory&gt;<br>
1273 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory))."\"&gt;<br>
1274 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
1275 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
1276 &nbsp;&nbsp;&lt;/Directory&gt;<br>
1277 &nbsp;&nbsp;&lt;Directory \"".preg_replace("/${site_id}/", "*", realpath($billingDirectory2))."\"&gt;<br>
1278 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;order deny,allow<br>
1279 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deny from all<br>
1280 &nbsp;&nbsp;&lt;/Directory&gt;<br><br>";
1282 $btn_text = 'Proceed to Select a Theme';
1283 $step6_bottom = <<<STP6BOT
1284 <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>
1285 <p>We recommend you print these instructions for future reference.</p>
1286 <p class='bg-warning'>Click <strong>'$btn_text'</strong> to select a theme.</p>
1287 <br>
1288 <form method='post'>
1289 <input type='hidden' name='state' value='7'>
1290 <input type='hidden' name='site' value='$site_id'>
1291 <input type='hidden' name='iuser' value='{$installer->iuser}'>
1292 <input type='hidden' name='iuserpass' value='{$installer->iuserpass}'>
1293 <input name='login' type='hidden' value='{$installer->login}'>
1294 <input name='pass' type='hidden' value='{$installer->pass}'>
1295 <input name='server' type='hidden' value='{$installer->server}'>
1296 <input name='port' type='hidden' value='{$installer->port}'>
1297 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1298 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1299 <button type='submit' value='Continue'><b>$btn_text</b></button>
1300 </form>
1301 <fieldset>
1302 STP6BOT;
1303 echo $step6_bottom . "\r\n";
1304 break;
1306 case 7:
1307 echo "<fieldset>";
1308 echo "<legend>Step $state - Select a Theme</legend>";
1309 echo "<p>Select a theme for OpenEMR...</p><br>\n";
1310 $btn_text = "Proceed to Final Step";
1311 $installer->displaySelectedThemeDiv();
1312 $theme_form = <<<TMF
1313 <div class='row'>
1314 <div class="col-sm-4 col-sm-offset-4">
1315 <form method='post'>
1316 <input type='hidden' name='state' value='8'>
1317 <input type='hidden' name='site' value='$site_id'>
1318 <input type='hidden' name='iuser' value='{$installer->iuser}'>
1319 <input type='hidden' name='iuserpass' value='{$installer->iuserpass}'>
1320 <input name='login' type='hidden' value='{$installer->login}'>
1321 <input name='pass' type='hidden' value='{$installer->pass}'>
1322 <input name='server' type='hidden' value='{$installer->server}'>
1323 <input name='port' type='hidden' value='{$installer->port}'>
1324 <input name='loginhost' type='hidden' value='{$installer->loginhost}'>
1325 <input name='dbname' type='hidden' value='{$installer->dbname}'>
1326 <input type='hidden' name='new_theme' id = 'new_theme' value='{$installer->getCurrentTheme()}'>
1327 <input name='clone_database' type='hidden' value='{$installer->clone_database}'>
1328 <h4>Select One:</h4>
1329 <div class="checkbox">
1330 <label><input type="checkbox" class="check" value="show_theme">Show More Themes</label>
1331 </div>
1332 <div class="checkbox">
1333 <label><input type="checkbox" class="check" value="keep_current">Keep Current</label>
1334 </div>
1335 <div class='hide_button' style="display:none;">
1336 <button type='submit' value='Continue' id='continue'>{$btn_text}</button>
1337 </div>
1338 </form>
1339 </div>
1340 </div>
1341 </fieldset>
1342 TMF;
1343 echo $theme_form ."\r\n";
1344 echo '<div class="row hideaway" style="display:none;">'."\r\n";
1345 echo '<div class="col-sm-12">'."\r\n";
1346 echo ' <h4>Select New Theme: <h5>(scroll down to view all)</h5></h4>'."\r\n";
1347 echo ' <br>'."\r\n";
1348 $installer->displayThemesDivs();
1349 break;
1351 case 0:
1352 default:
1353 $top = <<<TOP
1354 <fieldset>
1355 <legend>Pre Install - Checking File and Directory Permissions</legend>
1356 <p><span class="text">Welcome to OpenEMR. This utility will step you through the installation and configuration of OpenEMR for your practice.</span></p>
1357 <ul>
1358 <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>
1359 <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>
1360 <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.
1361 </li>
1362 </ul>
1363 TOP;
1364 echo $top;
1365 if ($checkPermissions) {
1366 echo "<p>We will now ensure correct file and directory permissions before starting installation:</p>\n";
1367 echo "<FONT COLOR='green'>Ensuring following files are world-writable...</FONT><br>\n";
1368 $errorWritable = 0;
1369 foreach ($writableFileList as $tempFile) {
1370 if (is_writable($tempFile)) {
1371 echo "'".realpath($tempFile)."' file is <FONT COLOR='green'><b>ready</b></FONT>.<br>\n";
1372 } else {
1373 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open file '".realpath($tempFile)."' for writing.<br>\n";
1374 echo "(configure file permissions; see below for further instructions)</p>\n";
1375 $errorWritable = 1;
1379 if ($errorWritable) {
1380 $check_file = <<<CHKFILE
1381 <p style="font-color:red;">You can't proceed until all above files are ready (world-writable).</p>
1382 <p>In linux, recommend changing file permissions with the <strong>'chmod 666 filename'</strong> command.</p>
1383 <p class='bg-danger'>Fix above file permissions and then click the <strong>'Check Again'</strong> button to re-check files.</p>
1384 <br>
1385 <form method='post'>
1386 <input type='hidden' name='site' value='$site_id'>
1387 <button type='submit' value='check again'><b>Check Again</b></button>
1388 </form>
1389 CHKFILE;
1390 echo $check_file . "\r\n";
1391 break;
1394 echo "<br><FONT COLOR='green'>Ensuring following directories have proper permissions...</FONT><br>\n";
1395 $errorWritable = 0;
1396 foreach ($writableDirList as $tempDir) {
1397 if (is_writable($tempDir)) {
1398 echo "'".realpath($tempDir)."' directory is <FONT COLOR='green'><b>ready</b></FONT>.<br>\r\n";
1399 } else {
1400 echo "<p><FONT COLOR='red'>UNABLE</FONT> to open directory '".realpath($tempDir)."' for writing by web server.<br>\r\n";
1401 echo "(configure directory permissions; see below for further instructions)</p>\r\n";
1402 $errorWritable = 1;
1406 if ($errorWritable) {
1407 $check_directory = <<<CHKDIR
1408 <p style="font-color:red;">You can't proceed until all directories are ready.</p>
1409 <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>
1410 <p class='bg-warning'>Fix above directory permissions and then click the <strong>'Check Again'</strong> button to re-check directories.</p>
1411 <br>
1412 <form method='post'>
1413 <input type='hidden' name='site' value='$site_id'>
1414 <button type='submit' value='check again'><b>Check Again</b></button>
1415 </form>
1416 CHKDIR;
1417 echo $check_directory . "\r\n";
1418 break;
1421 //RP_CHECK_LOGIC
1422 $form = <<<FRM
1423 <p>All required files and directories have been verified.</p>
1424 <p class='bg-warning'>Click <b>Proceed to Step 1</b> to continue with a new installation.</p>
1425 <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>
1426 <br>
1427 <form method='post'>
1428 <input name='state' type='hidden' value='1'>
1429 <input name='site' type='hidden' value='$site_id'>
1430 <button type='submit' value='Continue'><b>Proceed to Step 1</b></button>
1431 </form>
1432 FRM;
1433 echo $form ."\r\n";
1434 } else {
1435 echo "<br>Click to continue installation.<br>\n";
1439 $bot=<<<BOT
1440 </div>
1441 </div>
1442 BOT;
1443 echo $bot ."\r\n";
1447 </div><!--end of container div -->
1448 <?php $installer->setupHelpModal();?>
1449 <script>
1450 //jquery-ui tooltip
1451 $(document).ready(function() {
1452 $('.icon-tooltip').prop( "title", "Click to see more information").tooltip({
1453 show: {
1454 delay: 700,
1455 duration: 0
1458 $('.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();
1461 </script>
1462 <script type = "text/javascript" >
1463 $(document).ready(function() {
1464 $("input[type='radio']").click(function() {
1465 var radioValue = $("input[name='stylesheet']:checked").val();
1466 var imgPath = "public/images/stylesheets/";
1467 var currStyle = $("#current_theme_title").text();
1468 var currStyleTitle = currStyle;
1469 currStyle = currStyle.replace(/\b\w/g, l => l.toLowerCase());
1470 currStyle = currStyle.split(" ");
1471 currStyle = currStyle.join("_");
1472 currStyle = "style_" + currStyle + ".png";
1473 if (radioValue) {
1474 var currThemeText = radioValue.split("_");
1475 currThemeText = currThemeText.join(" ");
1476 currThemeText = currThemeText.replace(/\b\w/g, l => l.toUpperCase());
1477 var styleSelected = confirm("You have selected style - " + currThemeText + "\n" + "Click OK to apply selection");
1478 if (styleSelected) {
1479 $("#current_theme").attr("src", imgPath + "style_" + radioValue + ".png");
1480 $("#current_theme_title").text(currThemeText);
1481 $("#new_theme").val("style_" + radioValue + ".css");
1482 } else {
1483 $("#current_theme").attr("src", imgPath + currStyle);
1484 $("#current_theme_title").text(currStyleTitle);
1485 $(this).prop("checked", false);
1489 $('.check').click(function() {
1490 $('.check').not(this).prop('checked', false);
1491 if($('.check:checked').val() == 'show_theme'){
1492 $(".hideaway").show();
1493 } else if($('.check:checked').val() == 'keep_current'){
1494 $(".hideaway").hide();
1497 if($('.check').filter(':checked').length > 0) {
1498 $(".hide_button").show();
1499 } else {
1500 $(".hide_button").hide();
1501 $(".hideaway").hide();
1504 $('.wait').removeClass('button-wait');
1506 $( "#create_db_button" ).hover(
1507 function() {
1508 if ($('#pass' ).val().length > 11 && $('#iuserpass' ).val().length > 11 && $('#iuser' ).val().length > 11 ){
1510 $("button").click(function(){
1511 $(".oe-spinner").css("visibility", "visible");
1514 $('.wait').click(function(){
1515 $('.wait').addClass('button-wait');
1521 $("#step-4-btn").click(function(){
1522 $(".oe-spinner").css("visibility", "visible");
1523 $(this).addClass('button-wait');
1526 </script>
1527 </body>
1528 </html>