forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
267 lines (241 loc) · 10.8 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
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
<?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__) . "/common/compatibility/Checker.php");
use OpenEMR\Common\Checker;
$response = Checker::checkPhpVersion();
if ($response !== true) {
die($response);
}
require_once "version.php";
// Please note that the plain sql is used over the Doctrine ORM for
// `version` table interactions because it cannot connect due to a
// lack of context (this code is ran outside of the OpenEMR context).
$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" 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>
.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-text-green {
color: green;
}
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>
</head>
<body>
<div class='container'>
<div class="row">
<div class="col-sm-12">
<div class="page-header">
<h2>OpenEMR Multi Site Administration <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">
<table class='table table-striped'>
<tr class='head'>
<td>Site ID</td>
<td>DB Name</td>
<td>Site Name</td>
<td>Version</td>
<td align='center'>Is Current</td>
<td align='center'>Log In</td>
</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;
$bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
echo " <tr class='detail' bgcolor='$bgcolor'>\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'>Needs setup, click here to run it</a></td>\n";
} elseif ($errmsg) {
echo " <td colspan='3' style='color:red'>$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 align='center'><a href='sql_upgrade.php?site=$sfname'>Upgrade Database</a></td>\n";
} elseif (($v_acl > $database_acl)) {
echo " <td align='center'><a href='acl_upgrade.php?site=$sfname'>Upgrade Access Controls</a></td>\n";
} elseif (($v_realpatch != $database_patch)) {
echo " <td align='center'><a href='sql_patch.php?site=$sfname'>Patch Database</a></td>\n";
} else {
echo " <td align='center'><i class='fa fa-check fa-lg oe-text-green' aria-hidden='true' ></i></a></td>\n";
}
if (($v_database == $database_version) && ($v_acl <= $database_acl) && ($v_realpatch == $database_patch)) {
echo " <td align='center'><a href='interface/login/login.php?site=$sfname' title =' Login to site $sfname' ><i class='fa fa-sign-in fa-lg' aria-hidden='true'></i></a></td>\n";
} else {
echo " <td align='center'><i class='fa fa-ban fa-lg button-wait' aria-hidden='true'></i></td>\n";
}
}
echo " </tr>\n";
if ($config && $dbh !== false) {
mysqli_close($dbh);
}
}
?>
</table>
<form method='post' action='setup.php'>
<button type='submit' name='form_submit' value='Add New Site'><b>Add New Site</b></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 oe-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:#000000; font-size:1.5em;">×</span></button>
</div>
<div class="modal-body" style="height:80%;">
<iframe src="" id="targetiframe" style="height:100%; width:100%; overflow-x: hidden; border:none"
allowtransparency="true"></iframe>
</div>
<div class="modal-footer" style="margin-top:0px;">
<button class="btn btn-link btn-cancel oe-pull-away" data-dismiss="modal" type="button">Close</button>
<!--<button class="btn btn-default btn-print oe-pull-away" data-dismiss="modal" id="print-help-href" type="button">Print</button>-->
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#help-href').click (function(){
document.getElementById('targetiframe').src = "Documentation/help_files/openemr_multisite_admin_help.php";
})
});
$(document).ready(function() {
$('#print-help-href').click (function(){
$("#targetiframe").get(0).contentWindow.print();
})
});
// Jquery draggable
$('.modal-dialog').draggable({
handle: ".modal-header, .modal-footer"
});
$( ".modal-content" ).resizable({
aspectRatio: true,
minHeight: 300,
minWidth: 300
});
</script>
</body>
</html>