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__
) . "/src/Common/Compatibility/Checker.php");
16 $response = OpenEMR\Common\Compatibility\Checker
::checkPhpVersion();
17 if ($response !== true) {
18 die(htmlspecialchars($response));
21 require_once "version.php";
23 // Please note that the plain sql is used over the Doctrine ORM for
24 // `version` table interactions because it cannot connect due to a
25 // lack of context (this code is ran outside of the OpenEMR context).
27 $webserver_root = dirname(__FILE__
);
28 if (stripos(PHP_OS
, 'WIN') === 0) {
29 $webserver_root = str_replace("\\", "/", $webserver_root);
32 $OE_SITES_BASE = "$webserver_root/sites";
34 function sqlQuery($statement, $link)
36 $row = mysqli_fetch_array(mysqli_query($link, $statement), MYSQLI_ASSOC
);
42 <title
>OpenEMR Site Administration
</title
>
43 <link rel
="stylesheet" href
="public/assets/bootstrap/dist/css/bootstrap.min.css" type
="text/css">
44 <link rel
="stylesheet" href
="public/assets/jquery-ui/jquery-ui.css" type
="text/css">
45 <script type
="text/javascript" src
="public/assets/jquery/dist/jquery.min.js"></script
>
46 <script type
="text/javascript" src
="public/assets/bootstrap/dist/js/bootstrap.min.js"></script
>
47 <script type
="text/javascript" src
="public/assets/jquery-ui/jquery-ui.js"></script
>
48 <link rel
="stylesheet" href
="public/assets/font-awesome/css/font-awesome.min.css" type
="text/css">
49 <link rel
="shortcut icon" href
="public/images/favicon.ico" />
61 font
-size
: 70%
!important
;
64 background
-color
: WHITESMOKE
;
79 fieldset
> [class*="col-"] {
81 text
-align
:left
!Important
;
87 <div
class='container'>
89 <div
class="col-sm-12">
90 <div
class="page-header">
91 <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
>
97 <div
class="col-sm-12">
98 <table
class='table table-striped'>
104 <td align
='center'>Is Current
</td
>
105 <td align
='center'>Log In
</td
>
108 $dh = opendir($OE_SITES_BASE);
110 die("Cannot read directory '$OE_SITES_BASE'.");
113 $siteslist = array();
115 while (false !== ($sfname = readdir($dh))) {
116 if (substr($sfname, 0, 1) == '.') {
120 if ($sfname == 'CVS') {
124 $sitedir = "$OE_SITES_BASE/$sfname";
125 if (!is_dir($sitedir)) {
129 if (!is_file("$sitedir/sqlconf.php")) {
133 $siteslist[$sfname] = $sfname;
140 foreach ($siteslist as $sfname) {
141 $sitedir = "$OE_SITES_BASE/$sfname";
144 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
146 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
148 // Access the site's database.
149 include "$sitedir/sqlconf.php";
152 $dbh = mysqli_connect("$host", "$login", "$pass", $dbase, $port);
154 $errmsg = "MySQL connect failed";
158 echo " <td>$sfname</td>\n";
159 echo " <td>$dbase</td>\n";
162 echo " <td colspan='3'><a href='setup.php?site=$sfname'>Needs setup, click here to run it</a></td>\n";
164 echo " <td colspan='3' style='color:red'>$errmsg</td>\n";
166 // Get site name for display.
167 $row = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'openemr_name' LIMIT 1", $dbh);
168 $openemr_name = $row ?
$row['gl_value'] : '';
170 // Get version indicators from the database.
171 $row = sqlQuery("SHOW TABLES LIKE 'version'", $dbh);
173 $openemr_version = 'Unknown';
174 $database_version = 0;
176 $row = sqlQuery("SELECT * FROM version LIMIT 1", $dbh);
177 $database_patch_txt = "";
178 if (!(empty($row['v_realpatch'])) && $row['v_realpatch'] != 0) {
179 $database_patch_txt = " (" . $row['v_realpatch'] .")";
182 $openemr_version = $row['v_major'] . "." . $row['v_minor'] . "." .
183 $row['v_patch'] . $row['v_tag'] . $database_patch_txt;
184 $database_version = 0 +
$row['v_database'];
185 $database_acl = 0 +
$row['v_acl'];
186 $database_patch = 0 +
$row['v_realpatch'];
189 // Display relevant columns.
190 echo " <td>$openemr_name</td>\n";
191 echo " <td>$openemr_version</td>\n";
192 if ($v_database != $database_version) {
193 echo " <td align='center'><a href='sql_upgrade.php?site=$sfname'>Upgrade Database</a></td>\n";
194 } elseif (($v_acl > $database_acl)) {
195 echo " <td align='center'><a href='acl_upgrade.php?site=$sfname'>Upgrade Access Controls</a></td>\n";
196 } elseif (($v_realpatch != $database_patch)) {
197 echo " <td align='center'><a href='sql_patch.php?site=$sfname'>Patch Database</a></td>\n";
199 echo " <td align='center'><i class='fa fa-check fa-lg oe-text-green' aria-hidden='true' ></i></a></td>\n";
201 if (($v_database == $database_version) && ($v_acl <= $database_acl) && ($v_realpatch == $database_patch)) {
202 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";
204 echo " <td align='center'><i class='fa fa-ban fa-lg button-wait' aria-hidden='true'></i></td>\n";
210 if ($config && $dbh !== false) {
216 <form method
='post' action
='setup.php'>
217 <button type
='submit' name
='form_submit' value
='Add New Site'><b
>Add
New Site
</b
></button
>
221 </div
><!--end of container div
-->
223 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="myModalLabel" aria
-hidden
="true">
224 <div
class="modal-dialog modal-lg">
225 <div
class="modal-content oe-modal-content" style
="height:700px">
226 <div
class="modal-header clearfix">
227 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
=Close
>
228 <span aria
-hidden
="true" style
="color:#000000; font-size:1.5em;">×
</span
></button
>
230 <div
class="modal-body" style
="height:80%;">
231 <iframe src
="" id
="targetiframe" style
="height:100%; width:100%; overflow-x: hidden; border:none"
232 allowtransparency
="true"></iframe
>
234 <div
class="modal-footer" style
="margin-top:0px;">
235 <button
class="btn btn-link btn-cancel oe-pull-away" data
-dismiss
="modal" type
="button">Close
</button
>
236 <!--<button
class="btn btn-default btn-print oe-pull-away" data
-dismiss
="modal" id
="print-help-href" type
="button">Print</button
>-->
244 $
('#help-href').click (function(){
245 document
.getElementById('targetiframe').src
= "Documentation/help_files/openemr_multisite_admin_help.php";
249 $
('#print-help-href').click (function(){
250 $
("#targetiframe").get(0).contentWindow
.print();
254 $
('.modal-dialog').draggable({
255 handle
: ".modal-header, .modal-footer"
257 $
( ".modal-content" ).resizable({