forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
1674 lines (1554 loc) · 95.6 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
*
* Installation script.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Roberto Vasquez <[email protected]>
* @author Scott Wakefield <[email protected]>
* @author Ranganath Pathak <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2016 Roberto Vasquez <[email protected]>
* @copyright Copyright (c) 2016 Scott Wakefield <[email protected]>
* @copyright Copyright (c) 2019 Ranganath Pathak <[email protected]>
* @copyright Copyright (c) 2019 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
// Checks if the server's PHP version is compatible with OpenEMR:
require_once(dirname(__FILE__) . "/src/Common/Compatibility/Checker.php");
$response = OpenEMR\Common\Compatibility\Checker::checkPhpVersion();
if ($response !== true) {
die(htmlspecialchars($response));
}
// Set the maximum excution time and time limit to unlimited.
ini_set('max_execution_time', 0);
ini_set('display_errors', 0);
set_time_limit(0);
// Warning. If you set $allow_multisite_setup to true, this is a potential security vulnerability.
// Recommend setting it back to false (or removing this setup.php script entirely) after you
// are done with the multisite procedure.
$allow_multisite_setup = false;
// Warning. If you set $allow_cloning_setup to true, this is a potential security vulnerability.
// Recommend setting it back to false (or removing this setup.php script entirely) after you
// are done with the cloning setup procedure.
$allow_cloning_setup = false;
if (!$allow_cloning_setup && !empty($_REQUEST['clone_database'])) {
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");
}
function recursive_writable_directory_test($dir)
{
// first, collect the directory and subdirectories
$ri = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
$dirNames = array();
foreach ($ri as $file) {
if ($file->isDir()) {
if (!preg_match("/\.\.$/", $file->getPathname())) {
$dirName = realpath($file->getPathname());
if (!in_array($dirName, $dirNames)) {
$dirNames[] = $dirName;
}
}
}
}
// second, flag the directories that are not writable
$resultsNegative = array();
foreach ($dirNames as $value) {
if (!is_writable($value)) {
$resultsNegative[] = $value;
}
}
// third, send the output and return if didn't pass the test
if (!empty($resultsNegative)) {
echo "<p>";
$mainDirTest = "";
$outputs = array();
foreach ($resultsNegative as $failedDir) {
if (basename($failedDir) == basename($dir)) {
// need to reorder output so the main directory is at the top of the list
$mainDirTest = "<FONT COLOR='red'>UNABLE</FONT> to open directory '" . realpath($failedDir) . "' for writing by web server.<br>\r\n";
} else {
$outputs[] = "<FONT COLOR='red'>UNABLE</FONT> to open subdirectory '" . realpath($failedDir) . "' for writing by web server.<br>\r\n";
}
}
if ($mainDirTest) {
// need to reorder output so the main directory is at the top of the list
array_unshift($outputs, $mainDirTest);
}
foreach ($outputs as $output) {
echo $output;
}
echo "(configure directory permissions; see below for further instructions)</p>\r\n";
return 1;
} else {
echo "'" . realpath($dir) . "' directory and its subdirectories are <FONT COLOR='green'><b>ready</b></FONT>.<br>\r\n";
return 0;
}
}
// Include standard libraries/classes
require_once dirname(__FILE__) ."/vendor/autoload.php";
use OpenEMR\Common\Utils\RandomGenUtils;
$COMMAND_LINE = php_sapi_name() == 'cli';
$state = isset($_POST["state"]) ? ($_POST["state"]) : '';
$installer = new Installer($_REQUEST);
// Make this true for IPPF.
$ippf_specific = false;
$error_page_end = <<<EPE
</div>
</div>
</div><!--end of container div-->
</body>
</html>
EPE;
// If this script was invoked with no site ID, then ask for one.
if (!$COMMAND_LINE && empty($_REQUEST['site'])) {
$site_id = <<<SITEID
<!DOCTYPE html>
<html>
<head>
<title>OpenEMR Setup Tool</title>
<!--<link rel=stylesheet href="interface/themes/style_blue.css">-->
<link rel="stylesheet" href="public/assets/bootstrap/dist/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="public/assets/jquery-ui/jquery-ui.css" type="text/css">
<script type="text/javascript" src="public/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="public/assets/bootstrap/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="public/assets/font-awesome/css/font-awesome.min.css" type="text/css">
<link rel="shortcut icon" href="public/images/favicon.ico" />
<script type="text/javascript" src="public/assets/jquery-ui/jquery-ui.js"></script>
<style>
.oe-pull-away {
float:right;
}
</style>
</head>
<body>
<div class = 'container'>
<div class="row">
<div class="row">
<div class="col-sm-12">
<div class="page-header">
<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>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<fieldset>
<legend>Optional Site ID Selection</legend>
<p>Most OpenEMR installations support only one site. If that is
true for you then ignore the rest of this text and just click Continue.</p>
<p class='bg-warning'>If you are using the multisite setup module for the first time please read the
'Multi Site Installation' section of the help file before proceeding.</p>
<p>Otherwise please enter a unique Site ID here.</p>
<p>A Site ID is a short identifier with no spaces or special
characters other than periods or dashes. It is case-sensitive and we
suggest sticking to lower case letters for ease of use.</p>
<p>If each site will have its own host/domain name, then use that
name as the Site ID (e.g. www.example.com).</p>
<p>The site ID is used to identify which site you will log in to.
If it is a hostname then it is taken from the hostname in the URL.
Otherwise you must append "?site=<i>siteid</i>" to the URL used for
logging in.</p>
<p>It is OK for one of the sites to have "default" as its ID. This
is the ID that will be used if it cannot otherwise be determined.</p>
<br>
<form method='post'>
<input type='hidden' name='state' value='0'>
Site ID: <input type='text' name='site' value='default'>
<button type='submit' value='Continue'>Continue</button>
</form>
</fieldset>
</div>
</div>
</div><!--end of container div-->
SITEID;
echo $site_id . "\r\n";
$installer->setupHelpModal();
echo "</body>". "\r\n";
echo "</html>". "\r\n";
exit();
}
// Support "?site=siteid" in the URL, otherwise assume "default".
$site_id = 'default';
if (!$COMMAND_LINE && !empty($_REQUEST['site'])) {
$site_id = trim($_REQUEST['site']);
}
// Die if site ID is empty or has invalid characters.
if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) {
die("Site ID '".htmlspecialchars($site_id, ENT_NOQUOTES)."' contains invalid characters.");
}
// If multisite is turned off, then only allow default for site.
if (!$allow_multisite_setup && $site_id != 'default') {
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");
}
//If having problems with file and directory permission
// checking, then can be manually disabled here.
$checkPermissions = true;
global $OE_SITE_DIR; // The Installer sets this
$docsDirectory = "$OE_SITE_DIR/documents";
//These are files and dir checked before install for
// correct permissions.
if (is_dir($OE_SITE_DIR)) {
$writableFileList = array($installer->conffile);
$writableDirList = array($docsDirectory);
} else {
$writableFileList = array();
$writableDirList = array($OE_SITES_BASE);
}
// Include the sqlconf file if it exists yet.
$config = 0;
if (file_exists($OE_SITE_DIR)) {
include_once($installer->conffile);
} elseif ($state > 3) {
// State 3 should have created the site directory if it is missing.
die("Internal error, site directory is missing.");
}
?>
<html>
<head>
<title>OpenEMR Setup Tool</title>
<!--<link rel=stylesheet href="interface/themes/style_blue.css">-->
<link rel="stylesheet" href="public/assets/bootstrap/dist/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="public/assets/jquery-ui/jquery-ui.css" type="text/css">
<script type="text/javascript" src="public/assets/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="public/assets/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="public/assets/jquery-ui/jquery-ui.js"></script>
<link rel="stylesheet" href="public/assets/font-awesome/css/font-awesome.min.css" type="text/css">
<link rel="shortcut icon" href="public/images/favicon.ico" />
<style>
.noclone { }
table.phpset {
border-collapse:collapse;
}
table.phpset td, table.phpset th {
font-size:9pt;
border:1px solid gray;
padding:2px;
}
.table.no-border tr td, .table.no-border tr th {
border-width: 0;
}
td {
font-size:10pt;
}
.inputtext {
padding-left:2px;
padding-right:2px;
}
.button {
font-family:sans-serif;
font-size:9pt;
font-weight:bold;
}
.label-div > a {
display:none;
}
.label-div:hover > a {
display:inline-block;
}
div[id$="_info"] {
background: #F7FAB3;
padding: 20px;
margin: 10px 15px 0px 15px;
}
div[id$="_info"] > a {
margin-left:10px;
}
.checkboxgroup {
display: inline-block;
text-align: center;
}
.checkboxgroup label {
display: block;
}
.oe-pull-away{
float:right;
}
.oe-help-x {
color: grey;
padding: 0 5px;
}
.oe-superscript {
position: relative;
top: -.5em;
font-size: 70%!important;
}
.oe-setup-legend{
background-color: WHITESMOKE;
padding:0 10px;
}
.oe-margin-b-5 {
margin-bottom: 5px;
}
button {
font-weight:bold;
}
.button-wait {
color: grey;
cursor: not-allowed;
opacity: 0.6;
}
@media only screen {
fieldset > [class*="col-"] {
width: 100%;
text-align:left!Important;
}
}
</style>
<script language="javascript">
// onclick handler for "clone database" checkbox
function cloneClicked() {
var cb = document.forms[0].clone_database;
$('.noclone').css('display', cb.checked ? 'none' : 'block');
}
</script>
</head>
<body>
<div class = 'container'>
<div class="row">
<div class="col-sm-12">
<div class="page-header">
<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>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<?php
$error = "<span class='text-danger'><b>ERROR</b></span>";
$caution = "<span class='text-danger'><b>CAUTION</b></span>";
$ok = "<span class='text-success'><b>OK</b></span>";
$note = "<span class='text-primary'><b>NOTE</b></span>";
if (strtolower(ini_get('register_globals')) != 'off' && (bool) ini_get('register_globals')) {
echo "$caution: It appears that you have register_globals enabled in your php.ini\n" .
"configuration file. This causes unacceptable security risks. You must\n" .
"turn it off before continuing with installation.\n";
exit(1);
}
if (!extension_loaded("xml")) {
echo "$error: PHP XML extension missing. To continue, install PHP XML extension, then restart web server.";
exit(1);
}
if (!(extension_loaded("mysql") || extension_loaded("mysqlnd") || extension_loaded("mysqli"))) {
echo "$error: PHP MySQL extension missing. To continue, install and enable MySQL extension, then restart web server.";
exit(1);
}
if (!(extension_loaded("mbstring") )) {
echo "$error: PHP mb_string extension missing. To continue, install and enable mb_string extension, then restart web server.";
exit(1);
}
if (!(extension_loaded("openssl") )) {
echo "$error: PHP openssl extension missing. To continue, install PHP openssl extension, then restart web server.";
exit(1);
}
?>
<?php
if ($state == 8) {
?>
<fieldset>
<legend>Final step - Success</legend>
<p>Congratulations! OpenEMR is now installed.</p>
<ul>
<li>Access controls (php-GACL) are installed for fine-grained security, and can be administered in
OpenEMR's admin->acl menu.</li>
<li>Reviewing <?php echo $OE_SITE_DIR; ?>/config.php is a good idea. This file
contains some settings that you may want to change.</li>
<li>There's much information and many extra tools bundled within the OpenEMR installation directory.
Please refer to openemr/Documentation. Many forms and other useful scripts can be found at openemr/contrib.</li>
<li>To ensure a consistent look and feel throughout the application,
<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>
<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>
<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:[email protected]">[email protected]</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>
</ul>
<p>We recommend you print these instructions for future reference.</p>
<?php
echo "<p> The selected theme is :</p>";
$installer->displayNewThemeDiv();
if (empty($installer->clone_database)) {
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>";
} else {
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>";
}
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>";
echo "<p>In Linux use the following command:</p>";
echo "<p><code>sudo apachectl -k restart</code></p>";
?>
<p>
<a href='./?site=<?php echo $site_id; ?>'>Click here to start using OpenEMR. </a>
</p>
</fieldset>
<?php
$installer->setCurrentTheme();
$end_div = <<<ENDDIV
</div>
</div>
</div><!--end of container div-->
ENDDIV;
echo $end_div . "\r\n";
$installer->setupHelpModal();
echo "</body>". "\r\n";
echo "</html>". "\r\n";
exit();
}
?>
<?php
$inst = isset($_POST["inst"]) ? ($_POST["inst"]) : '';
if (($config == 1) && ($state < 4)) {
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";
} else {
switch ($state) {
case 1:
$step1 = <<<STP1
<fieldset>
<legend>Step $state - Select Database Setup</legend>
<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.
<br>
<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>.
<br>
<form method='post'>
<input name='state' type='hidden' value='2'>
<input name='site' type='hidden' value='$site_id'>
<label for='inst1'>
<input checked id='inst1' name='inst' type='radio' value='1'>Have setup create the database
</label><br>
<label for='inst2'>
<input id='inst2' name='inst' type='radio' value='2'>I have already created the database
</label><br>
<br>
<button type='submit' value='Continue'><b>Proceed to Step 2</b></button>
</form><br>
</fieldset>
STP1;
echo $step1 ."\r\n";
break;
case 2:
$step2top = <<<STP2TOP
<fieldset>
<legend>Step $state - Database and OpenEMR Initial User Setup Details</legend>
<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.
<br><br>
<form method='post' id='myform'>
<input name='state' type='hidden' value='3'>
<input name='site' type='hidden' value='$site_id'>
<input name='inst' type='hidden' value='$inst'>
STP2TOP;
echo $step2top ."\r\n";
$step2tabletop1 = <<<STP2TBLTOP1
<fieldset>
<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>
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='server' id='server' type='text' class='form-control' value='localhost'>
</div>
</div>
<div id="server_info" class="collapse">
<a href="#server_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>If you run MySQL and Apache/PHP on the same computer, then leave this as 'localhost'.
<p>If they are on separate computers, then enter the IP address of the computer running MySQL.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='port' id='port' type='text' class='form-control' value='3306'>
</div>
</div>
<div id="port_info" class="collapse">
<a href="#port_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the MySQL port.
<p>The default port for MySQL is 3306.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="col-sm-12 label-div">
<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>
</div>
<div class="col-sm-12">
<input name='dbname' id='dbname' type='text' class='form-control' value='openemr'>
</div>
</div>
<div id="dbname_info" class="collapse">
<a href="#dbname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This will be the name of the OpenEMR database in MySQL.
<p>'openemr' is the recommended name.
<p>This database will contain patient data as well as data pertaining to the OpenEMR installation.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='login' ID='login' type='text' class='form-control' value='openemr'>
</div>
</div>
<div id="login_info" class="collapse">
<a href="#login_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the name that OpenEMR will use to login to the MySQL database.
<p>'openemr' is the recommended name.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='pass' id='pass' class='form-control' type='password' value='' required>
</div>
</div>
<div id="pass_info" class="collapse">
<a href="#pass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the Login Password that OpenEMR will use to accesses the MySQL database.
<p>It should be at least 12 characters long and composed of both numbers and letters.
</div>
</div>
STP2TBLTOP1;
echo $step2tabletop1 ."\r\n";
if ($inst != 2) {
$step2tabletop2 = <<<STP2TBLTOP2
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="col-sm-12 label-div">
<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>
</div>
<div class="col-sm-12">
<input name='root' id='root'type='text' class='form-control' value='root'>
</div>
</div>
<div id="root_info" class="collapse">
<a href="#root_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is name for the MySQL root account.
<p>For localhost, it is usually ok to leave it as 'root'.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='rootpass' id='rootpass' type='password' class='form-control' value=''>
</div>
</div>
<div id="rootpass_info" class="collapse">
<a href="#rootpass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is your MySQL server root password.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='loginhost' id='loginhost' type='text' class='form-control' value='localhost'>
</div>
</div>
<div id="loginhost_info" class="collapse">
<a href="#loginhost_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>If you run Apache/PHP and MySQL on the same computer, then leave this as 'localhost'.
<p>If they are on separate computers, then enter the IP address of the computer running Apache/PHP.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="col-sm-12 label-div">
<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>
</div>
<div class="col-sm-12">
<select name='collate' id=='collate' class='form-control'>
<option value='utf8_bin'>
Bin
</option>
<option value='utf8_czech_ci'>
Czech
</option>
<option value='utf8_danish_ci'>
Danish
</option>
<option value='utf8_esperanto_ci'>
Esperanto
</option>
<option value='utf8_estonian_ci'>
Estonian
</option>
<option selected value='utf8_general_ci'>
General
</option>
<option value='utf8_hungarian_ci'>
Hungarian
</option>
<option value='utf8_icelandic_ci'>
Icelandic
</option>
<option value='utf8_latvian_ci'>
Latvian
</option>
<option value='utf8_lithuanian_ci'>
Lithuanian
</option>
<option value='utf8_persian_ci'>
Persian
</option>
<option value='utf8_polish_ci'>
Polish
</option>
<option value='utf8_roman_ci'>
Roman
</option>
<option value='utf8_romanian_ci'>
Romanian
</option>
<option value='utf8_slovak_ci'>
Slovak
</option>
<option value='utf8_slovenian_ci'>
Slovenian
</option>
<option value='utf8_spanish2_ci'>
Spanish2 (Traditional)
</option>
<option value='utf8_spanish_ci'>
Spanish (Modern)
</option>
<option value='utf8_swedish_ci'>
Swedish
</option>
<option value='utf8_turkish_ci'>
Turkish
</option>
<option value='utf8_unicode_ci'>
Unicode (German, French, Russian, Armenian, Greek)
</option>
<option value=''>
None (Do not force UTF-8)
</option>
</select>
</div>
</div>
<div id="collate_info" class="collapse">
<a href="#collate_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the collation setting for MySQL.
<p>Collation refers to a set of rules that determine how data is sorted and compared in a database.
<p>Leave as 'General' if you are not sure.
<p>If the language you are planning to use in OpenEMR is in the menu, then you can select it.
<p>Otherwise, just select 'General'.
</div>
</div>
</div>
</div>
STP2TBLTOP2;
echo $step2tabletop2 ."\r\n";
}
// Include a "source" site ID drop-list and a checkbox to indicate
// if cloning its database. When checked, do not display initial user
// and group stuff below.
$dh = opendir($OE_SITES_BASE);
if (!$dh) {
die("Cannot read directory '$OE_SITES_BASE'.");
}
$siteslist = array();
while (false !== ($sfname = readdir($dh))) {
if (substr($sfname, 0, 1) == '.') {
continue;
}
if ($sfname == 'CVS') {
continue;
}
if ($sfname == $site_id) {
continue;
}
$sitedir = "$OE_SITES_BASE/$sfname";
if (!is_dir($sitedir)) {
continue;
}
if (!is_file("$sitedir/sqlconf.php")) {
continue;
}
$siteslist[$sfname] = $sfname;
}
closedir($dh);
// If this is not the first site...
if (!empty($siteslist)) {
ksort($siteslist);
$source_site_top = <<<SOURCESITETOP
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<select name='source_site_id'id='source_site_id' class='form-control'>
SOURCESITETOP;
echo $source_site_top . "\r\n";
foreach ($siteslist as $sfname) {
echo "<option value='$sfname'";
if ($sfname == 'default') {
echo " selected";
}
echo ">$sfname</option>";
}
$source_site_bot = <<<SOURCESITEBOT
</select>
</div>
</div>
<div id="source_site_id_info" class="collapse">
<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>
<p>The site directory that will be a model for the new site.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input type='checkbox' name='clone_database' id='clone_database' onclick='cloneClicked()' />
</div>
</div>
<div id="clone_database_info" class="collapse">
<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>
<p>Clone the source site's database instead of creating a fresh one.
</div>
</div>
</div>
</div>
SOURCESITEBOT;
echo $source_site_bot ."\r\n";
}
$randomusernamepre = RandomGenUtils::produceRandomString(3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
$randomusernamepost = RandomGenUtils::produceRandomString(2, "0123456789");
$randomusername = $randomusernamepre . "-admin-" . $randomusernamepost;
// App Based TOTP secret
// Shared key (per rfc6238 and rfc4226) should be 20 bytes (160 bits) and encoded in base32, which should
// be 32 characters in base32
// Would be nice to use the OpenEMR\Common\Utils\RandomGenUtils\produceRandomBytes() function and then encode to base32,
// but does not appear to be a standard way to encode binary to base32 in php.
$randomsecret = RandomGenUtils::produceRandomString(32, "234567ABCDEFGHIJKLMNOPQRSTUVWXYZ");
if (empty($randomsecret) || empty($randomusernamepre) || empty($randomusernamepost)) {
error_log('OpenEMR Error : Random String error - exiting');
die();
}
$disableCheckbox = "";
if (empty($randomsecret)) {
$randomsecret = "";
$disableCheckbox = "disabled";
}
$step2tablebot = <<<STP2TBLBOT
</fieldset>
<br>
<fieldset class='noclone'>
<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>
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='iuser' id='iuser' type='text' class='form-control' value='$randomusername' minlength='12'>
</div>
</div>
<div id="iuser_info" class="collapse">
<a href="#iuser_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the login name of the first user that will be created for you.
<p>Limit this to one word with at least 12 characters and composed of both numbers and letters.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='iuserpass' id='iuserpass' type='password' class='form-control' value='' minlength='12'>
</div>
</div>
<div id="iuserpass_info" class="collapse">
<a href="#iuserpass_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the password for the initial user.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="col-sm-12 label-div">
<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>
</div>
<div class="col-sm-12">
<input name='iufname' id='iufname 'type='text' class='form-control' value='Administrator'>
</div>
</div>
<div id="iufname_info" class="collapse">
<a href="#iufname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the First name of the 'initial user'.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='iuname' id='iuname' type='text' class='form-control' value='Administrator'>
</div>
</div>
<div id="iuname_info" class="collapse">
<a href="#iuname_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the Last name of the 'initial user'.
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<div class="label-div">
<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>
</div>
<div>
<input name='igroup' id='igroup' class='form-control' type='text' value='Default'>
</div>
</div>
<div id="igroup_info" class="collapse">
<a href="#igroup_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>This is the group that will be created for your users.
<p>This should be the name of your practice.
</div>
</div>
</div>
</div>
</fieldset>
<br>
<fieldset class='noclone bg-danger oe-margin-b-5'>
<legend name="form_legend" id="form_legend" class='oe-setup-legend text-danger'>Enable 2 Factor Authentication for Initial User (more secure - optional) <i id="2fa-section" class="fa fa-info-circle oe-text-black oe-superscript 2fa-section-tooltip" aria-hidden="true"></i></legend>
<div class="row">
<div class="col-xs-12 ">
<div class="col-sm-3">
<div class="clearfix form-group">
<div class="label-div">
<label class="control-label" for="i2fa">Configure 2FA:</label> <a href="#i2fa_info" class="info-anchor icon-tooltip" data-toggle="collapse" ><i class="fa fa-question-circle" aria-hidden="true"></i></a>
</div>
<div>
<input name='i2faenable' id='i2faenable' type='checkbox' $disableCheckbox/> Enable 2FA
<input type='hidden' name='i2fasecret' id='i2fasecret' value='$randomsecret' />
</div>
</div>
<div id="i2fa_info" class="collapse">
<a href="#i2fa_info" data-toggle="collapse" class="oe-pull-away"><i class="fa fa-times oe-help-x" aria-hidden="true"></i></a>
<p>If selected will allow TOTP 2 factor authentication for the initial user.</p>
<p>Click on the help file for more information.</p>
</div>
</div>
<div class="col-sm-5">
<div class="clearfix form-group">
<p class="text-danger"><b>IMPORTANT IF ENABLED</b></p>
<p>If enabled, you must have an authenticator app on your phone ready to scan the QR code displayed next.</p>
</div>
</div>
<div class="col-sm-4">
<div class="clearfix form-group">
<p>Example authenticator apps include:</p>
<ul>
<li>Google Auth
(<a href="https://itunes.apple.com/us/app/google-authenticator/id388497605?mt=8" target="_blank">ios</a>, <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en">android</a>)</li>
<li>Authy
(<a href="https://itunes.apple.com/us/app/authy/id494168017?mt=8">ios</a>, <a href="https://play.google.com/store/apps/details?id=com.authy.authy&hl=en">android</a>)</li>
</ul>
</div>
</div>
</div>
</div>
</fieldset>
<p class='bg-warning'>Click the <b>Create DB and User</b> button below to create the database and first user <a href='#create_db_button' title='Click me'><i class="fa fa-arrow-circle-down" aria-hidden="true"></i></a>. $note: This process will take a few minutes.</p>
<!--<p class='bg-success'>Upon successful completion will automatically take you to the next step.</p>-->
<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>
<button type='submit' id='create_db_button' value='Continue' class='wait'><b>Create DB and User</b></button>
</form>
</fieldset>
STP2TBLBOT;
echo $step2tablebot ."\r\n";
break;
case 3:
// Form Validation
// (applicable if not cloning from another database)
$pass_step2_validation = true;
$error_step2_message = "$error - ";
if (! $installer->char_is_valid($_REQUEST['server'])) {
$pass_step2_validation = false;
$error_step2_message .= "A database server host is required <br>\n";
}
if (! $installer->char_is_valid($_REQUEST['port'])) {
$pass_step2_validation = false;
$error_step2_message .= "A database server port value is required <br>\n";
}
if (! $installer->databaseNameIsValid($_REQUEST['dbname'])) {
$pass_step2_validation = false;
$error_step2_message .= "A database name is required <br>\n";
}
if (! $installer->collateNameIsValid($_REQUEST['collate'])) {
$pass_step2_validation = false;
$error_step2_message .= "A collation name is required <br>\n";
}
if (! $installer->char_is_valid($_REQUEST['login'])) {
$pass_step2_validation = false;
$error_step2_message .= "A database login name is required <br>\n";
}
if (! $installer->char_is_valid($_REQUEST['pass'])) {
$pass_step2_validation = false;
$error_step2_message .= "A database login password is required <br>\n";
}
if (!$pass_step2_validation) {
$error_step2_message .= $error_page_end . "\r\n";
die($error_step2_message);