forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
227 lines (201 loc) · 10.3 KB
/
admin.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
<?php
/**
*
* Multi Site Administration script.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Rod Roark <rod@sunsetsystems.com>
* @author Ranganath Pathak <pathak@scrs1.org>
* @copyright Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
* @copyright Copyright (c) 2019 Ranganath Pathak <pathak@scrs1.org>
* @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));
}
require_once "version.php";
$webserver_root = dirname(__FILE__);
if (stripos(PHP_OS, 'WIN') === 0) {
$webserver_root = str_replace("\\", "/", $webserver_root);
}
$OE_SITES_BASE = "$webserver_root/sites";
function sqlQuery($statement, $link)
{
$row = mysqli_fetch_array(mysqli_query($link, $statement), MYSQLI_ASSOC);
return $row;
}
?>
<html>
<head>
<title>OpenEMR Site Administration</title>
<link rel="stylesheet" href="public/assets/bootstrap/dist/css/bootstrap.min.css">
<script src="public/assets/jquery/dist/jquery.min.js"></script>
<script src="public/assets/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="public/assets/@fortawesome/fontawesome-free/css/all.min.css">
<link rel="shortcut icon" href="public/images/favicon.ico" />
</head>
<body>
<div class='container mt-3'>
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center">
<h2>OpenEMR Multi Site Administration</h2>
<a class="text-secondary" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href">
<i class="fa fa-question-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Click to view Help"></i>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="table-responsive">
<table class='table table-striped text-center'>
<tr>
<th>Site ID</th>
<th>DB Name</th>
<th>Site Name</th>
<th>Version</th>
<th>Is Current</th>
<th>Log In</th>
</tr>
<?php
$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;
}
$sitedir = "$OE_SITES_BASE/$sfname";
if (!is_dir($sitedir)) {
continue;
}
if (!is_file("$sitedir/sqlconf.php")) {
continue;
}
$siteslist[$sfname] = $sfname;
}
closedir($dh);
ksort($siteslist);
$encount = 0;
foreach ($siteslist as $sfname) {
$sitedir = "$OE_SITES_BASE/$sfname";
$errmsg = '';
++$encount;
echo " <tr>\n";
// Access the site's database.
include "$sitedir/sqlconf.php";
if ($config) {
$dbh = mysqli_connect("$host", "$login", "$pass", $dbase, $port);
if (!$dbh) {
$errmsg = "MySQL connect failed";
}
}
echo " <td>$sfname</td>\n";
echo " <td>$dbase</td>\n";
if (!$config) {
echo " <td colspan='3'><a href='setup.php?site=$sfname' class='text-decoration-none'>Needs setup, click here to run it</a></td>\n";
} elseif ($errmsg) {
echo " <td colspan='3' class='text-danger'>$errmsg</td>\n";
} else {
// Get site name for display.
$row = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'openemr_name' LIMIT 1", $dbh);
$openemr_name = $row ? $row['gl_value'] : '';
// Get version indicators from the database.
$row = sqlQuery("SHOW TABLES LIKE 'version'", $dbh);
if (empty($row)) {
$openemr_version = 'Unknown';
$database_version = 0;
} else {
$row = sqlQuery("SELECT * FROM version LIMIT 1", $dbh);
$database_patch_txt = "";
if (!(empty($row['v_realpatch'])) && $row['v_realpatch'] != 0) {
$database_patch_txt = " (" . $row['v_realpatch'] . ")";
}
$openemr_version = $row['v_major'] . "." . $row['v_minor'] . "." .
$row['v_patch'] . $row['v_tag'] . $database_patch_txt;
$database_version = 0 + $row['v_database'];
$database_acl = 0 + $row['v_acl'];
$database_patch = 0 + $row['v_realpatch'];
}
// Display relevant columns.
echo " <td>$openemr_name</td>\n";
echo " <td>$openemr_version</td>\n";
if ($v_database != $database_version) {
echo " <td><a href='sql_upgrade.php?site=$sfname' class='text-decoration-none'>Upgrade Database</a></td>\n";
} elseif (($v_acl > $database_acl)) {
echo " <td><a href='acl_upgrade.php?site=$sfname' class='text-decoration-none'>Upgrade Access Controls</a></td>\n";
} elseif (($v_realpatch != $database_patch)) {
echo " <td><a href='sql_patch.php?site=$sfname' class='text-decoration-none'>Patch Database</a></td>\n";
} else {
echo " <td><i class='fa fa-check fa-lg text-success' aria-hidden='true' ></i></a></td>\n";
}
if (($v_database == $database_version) && ($v_acl <= $database_acl) && ($v_realpatch == $database_patch)) {
echo " <td><a href='interface/login/login.php?site=$sfname' class='text-decoration-none'><i class='fa fa-sign-in-alt fa-lg' aria-hidden='true' data-toggle='tooltip' data-placement='top' title ='Login to site $sfname'></i></a></td>\n";
} else {
echo " <td><i class='fa fa-ban fa-lg text-secondary' aria-hidden='true'></i></td>\n";
}
}
echo " </tr>\n";
if ($config && $dbh !== false) {
mysqli_close($dbh);
}
}
?>
</table>
</div>
<form method='post' action='setup.php'>
<button type='submit' class='btn btn-primary font-weight-bold' name='form_submit' value='Add New Site'>Add New Site</button>
</form>
</div>
</div>
</div><!--end of container div-->
<div class="row">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="height:700px">
<div class="modal-header clearfix">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" style="color:var(--black); font-size:1.5em;">×</span>
</button>
</div>
<div class="modal-body" style="height:80%;">
<iframe src="" id="targetiframe" class="h-100 w-100" style="overflow-x: hidden; border:none"
allowtransparency="true"></iframe>
</div>
<div class="modal-footer mt-0">
<button class="btn btn-secondary" data-dismiss="modal" type="button">Close</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(function () {
$('#help-href').click (function() {
document.getElementById('targetiframe').src = "Documentation/help_files/openemr_multisite_admin_help.php";
});
});
$(function () {
$('#print-help-href').click (function(){
$("#targetiframe").get(0).contentWindow.print();
});
});
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
// Jquery draggable
$(".modal-dialog").addClass('drag-action');
$(".modal-content").addClass('resize-action');
</script>
</body>
</html>