4 * Multi Site Administration script.
7 * @link https://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Ranganath Pathak <pathak@scrs1.org>
10 * @copyright Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2019 Ranganath Pathak <pathak@scrs1.org>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 // Checks if the server's PHP version is compatible with OpenEMR:
15 require_once(dirname(__FILE__
) . "/common/compatibility/Checker.php");
17 use OpenEMR\Common\Checker
;
19 $response = Checker
::checkPhpVersion();
20 if ($response !== true) {
24 require_once "version.php";
26 // Please note that the plain sql is used over the Doctrine ORM for
27 // `version` table interactions because it cannot connect due to a
28 // lack of context (this code is ran outside of the OpenEMR context).
30 $webserver_root = dirname(__FILE__
);
31 if (stripos(PHP_OS
, 'WIN') === 0) {
32 $webserver_root = str_replace("\\", "/", $webserver_root);
35 $OE_SITES_BASE = "$webserver_root/sites";
37 function sqlQuery($statement, $link)
39 $row = mysqli_fetch_array(mysqli_query($link, $statement), MYSQLI_ASSOC
);
45 <title
>OpenEMR Site Administration
</title
>
46 <link rel
="stylesheet" href
="public/assets/bootstrap/dist/css/bootstrap.min.css" type
="text/css">
47 <link rel
="stylesheet" href
="public/assets/jquery-ui/jquery-ui.css" type
="text/css">
48 <script type
="text/javascript" src
="public/assets/jquery/dist/jquery.min.js"></script
>
49 <script type
="text/javascript" src
="public/assets/bootstrap/dist/js/bootstrap.min.js"></script
>
50 <script type
="text/javascript" src
="public/assets/jquery-ui/jquery-ui.js"></script
>
51 <link rel
="stylesheet" href
="public/assets/font-awesome/css/font-awesome.min.css" type
="text/css">
52 <link rel
="shortcut icon" href
="public/images/favicon.ico" />
64 font
-size
: 70%
!important
;
67 background
-color
: WHITESMOKE
;
82 fieldset
> [class*="col-"] {
84 text
-align
:left
!Important
;
90 <div
class='container'>
92 <div
class="col-sm-12">
93 <div
class="page-header">
94 <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
>
100 <div
class="col-sm-12">
101 <table
class='table table-striped'>
107 <td align
='center'>Is Current
</td
>
108 <td align
='center'>Log In
</td
>
111 $dh = opendir($OE_SITES_BASE);
113 die("Cannot read directory '$OE_SITES_BASE'.");
116 $siteslist = array();
118 while (false !== ($sfname = readdir($dh))) {
119 if (substr($sfname, 0, 1) == '.') {
123 if ($sfname == 'CVS') {
127 $sitedir = "$OE_SITES_BASE/$sfname";
128 if (!is_dir($sitedir)) {
132 if (!is_file("$sitedir/sqlconf.php")) {
136 $siteslist[$sfname] = $sfname;
143 foreach ($siteslist as $sfname) {
144 $sitedir = "$OE_SITES_BASE/$sfname";
147 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
149 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
151 // Access the site's database.
152 include "$sitedir/sqlconf.php";
155 $dbh = mysqli_connect("$host", "$login", "$pass", $dbase, $port);
157 $errmsg = "MySQL connect failed";
161 echo " <td>$sfname</td>\n";
162 echo " <td>$dbase</td>\n";
165 echo " <td colspan='3'><a href='setup.php?site=$sfname'>Needs setup, click here to run it</a></td>\n";
167 echo " <td colspan='3' style='color:red'>$errmsg</td>\n";
169 // Get site name for display.
170 $row = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'openemr_name' LIMIT 1", $dbh);
171 $openemr_name = $row ?
$row['gl_value'] : '';
173 // Get version indicators from the database.
174 $row = sqlQuery("SHOW TABLES LIKE 'version'", $dbh);
176 $openemr_version = 'Unknown';
177 $database_version = 0;
179 $row = sqlQuery("SELECT * FROM version LIMIT 1", $dbh);
180 $database_patch_txt = "";
181 if (!(empty($row['v_realpatch'])) && $row['v_realpatch'] != 0) {
182 $database_patch_txt = " (" . $row['v_realpatch'] .")";
185 $openemr_version = $row['v_major'] . "." . $row['v_minor'] . "." .
186 $row['v_patch'] . $row['v_tag'] . $database_patch_txt;
187 $database_version = 0 +
$row['v_database'];
188 $database_acl = 0 +
$row['v_acl'];
189 $database_patch = 0 +
$row['v_realpatch'];
192 // Display relevant columns.
193 echo " <td>$openemr_name</td>\n";
194 echo " <td>$openemr_version</td>\n";
195 if ($v_database != $database_version) {
196 echo " <td align='center'><a href='sql_upgrade.php?site=$sfname'>Upgrade Database</a></td>\n";
197 } elseif (($v_acl > $database_acl)) {
198 echo " <td align='center'><a href='acl_upgrade.php?site=$sfname'>Upgrade Access Controls</a></td>\n";
199 } elseif (($v_realpatch != $database_patch)) {
200 echo " <td align='center'><a href='sql_patch.php?site=$sfname'>Patch Database</a></td>\n";
202 echo " <td align='center'><i class='fa fa-check fa-lg oe-text-green' aria-hidden='true' ></i></a></td>\n";
204 if (($v_database == $database_version) && ($v_acl <= $database_acl) && ($v_realpatch == $database_patch)) {
205 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";
207 echo " <td align='center'><i class='fa fa-ban fa-lg button-wait' aria-hidden='true'></i></td>\n";
213 if ($config && $dbh !== false) {
219 <form method
='post' action
='setup.php'>
220 <button type
='submit' name
='form_submit' value
='Add New Site'><b
>Add
New Site
</b
></button
>
224 </div
><!--end of container div
-->
226 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="myModalLabel" aria
-hidden
="true">
227 <div
class="modal-dialog modal-lg">
228 <div
class="modal-content oe-modal-content" style
="height:700px">
229 <div
class="modal-header clearfix">
230 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
=Close
>
231 <span aria
-hidden
="true" style
="color:#000000; font-size:1.5em;">×
</span
></button
>
233 <div
class="modal-body" style
="height:80%;">
234 <iframe src
="" id
="targetiframe" style
="height:100%; width:100%; overflow-x: hidden; border:none"
235 allowtransparency
="true"></iframe
>
237 <div
class="modal-footer" style
="margin-top:0px;">
238 <button
class="btn btn-link btn-cancel oe-pull-away" data
-dismiss
="modal" type
="button">Close
</button
>
239 <!--<button
class="btn btn-default btn-print oe-pull-away" data
-dismiss
="modal" id
="print-help-href" type
="button">Print</button
>-->
246 $
(document
).ready(function() {
247 $
('#help-href').click (function(){
248 document
.getElementById('targetiframe').src
= "Documentation/help_files/openemr_multisite_admin_help.php";
251 $
(document
).ready(function() {
252 $
('#print-help-href').click (function(){
253 $
("#targetiframe").get(0).contentWindow
.print();
257 $
('.modal-dialog').draggable({
258 handle
: ".modal-header, .modal-footer"
260 $
( ".modal-content" ).resizable({