Convert LDAP / Active Directory authentication to use native PHP LDAP… (#2746)
[openemr.git] / admin.php
blob91848be08137d3028455f931594085f430e17f7a
1 <?php
2 /**
4 * Multi Site Administration script.
6 * @package OpenEMR
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);
37 return $row;
40 <html>
41 <head>
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" />
50 <style>
51 .oe-pull-away{
52 float:right;
54 .oe-help-x {
55 color: grey;
56 padding: 0 5px;
58 .oe-superscript {
59 position: relative;
60 top: -.5em;
61 font-size: 70%!important;
63 .oe-setup-legend{
64 background-color: WHITESMOKE;
65 padding:0 10px;
67 .oe-text-green {
68 color: green;
70 button {
71 font-weight:bold;
73 .button-wait {
74 color: grey;
75 cursor: not-allowed;
76 opacity: 0.6;
78 @media only screen {
79 fieldset > [class*="col-"] {
80 width: 100%;
81 text-align:left!Important;
84 </style>
85 </head>
86 <body>
87 <div class='container'>
88 <div class="row">
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>
92 </div>
93 </div>
94 </div>
96 <div class="row">
97 <div class="col-sm-12">
98 <table class='table table-striped'>
99 <tr class='head'>
100 <td>Site ID</td>
101 <td>DB Name</td>
102 <td>Site Name</td>
103 <td>Version</td>
104 <td align='center'>Is Current</td>
105 <td align='center'>Log In</td>
106 </tr>
107 <?php
108 $dh = opendir($OE_SITES_BASE);
109 if (!$dh) {
110 die("Cannot read directory '$OE_SITES_BASE'.");
113 $siteslist = array();
115 while (false !== ($sfname = readdir($dh))) {
116 if (substr($sfname, 0, 1) == '.') {
117 continue;
120 if ($sfname == 'CVS') {
121 continue;
124 $sitedir = "$OE_SITES_BASE/$sfname";
125 if (!is_dir($sitedir)) {
126 continue;
129 if (!is_file("$sitedir/sqlconf.php")) {
130 continue;
133 $siteslist[$sfname] = $sfname;
136 closedir($dh);
137 ksort($siteslist);
139 $encount = 0;
140 foreach ($siteslist as $sfname) {
141 $sitedir = "$OE_SITES_BASE/$sfname";
142 $errmsg = '';
143 ++$encount;
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";
151 if ($config) {
152 $dbh = mysqli_connect("$host", "$login", "$pass", $dbase, $port);
153 if (!$dbh) {
154 $errmsg = "MySQL connect failed";
158 echo " <td>$sfname</td>\n";
159 echo " <td>$dbase</td>\n";
161 if (!$config) {
162 echo " <td colspan='3'><a href='setup.php?site=$sfname'>Needs setup, click here to run it</a></td>\n";
163 } elseif ($errmsg) {
164 echo " <td colspan='3' style='color:red'>$errmsg</td>\n";
165 } else {
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);
172 if (empty($row)) {
173 $openemr_version = 'Unknown';
174 $database_version = 0;
175 } else {
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";
198 } else {
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";
203 } else {
204 echo " <td align='center'><i class='fa fa-ban fa-lg button-wait' aria-hidden='true'></i></td>\n";
208 echo " </tr>\n";
210 if ($config && $dbh !== false) {
211 mysqli_close($dbh);
215 </table>
216 <form method='post' action='setup.php'>
217 <button type='submit' name='form_submit' value='Add New Site'><b>Add New Site</b></button>
218 </form>
219 </div>
220 </div>
221 </div><!--end of container div-->
222 <div class="row">
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>
229 </div>
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>
233 </div>
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>-->
237 </div>
238 </div>
239 </div>
240 </div>
241 </div>
242 <script>
243 $(function() {
244 $('#help-href').click (function(){
245 document.getElementById('targetiframe').src = "Documentation/help_files/openemr_multisite_admin_help.php";
248 $(function() {
249 $('#print-help-href').click (function(){
250 $("#targetiframe").get(0).contentWindow.print();
253 // Jquery draggable
254 $('.modal-dialog').draggable({
255 handle: ".modal-header, .modal-footer"
257 $( ".modal-content" ).resizable({
258 aspectRatio: true,
259 minHeight: 300,
260 minWidth: 300
262 </script>
263 </body>
264 </html>