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