add support of rtl on datepicker openemr (#486)
[openemr.git] / admin.php
blob655e0a13181839d4d7e460b8f00c4b3e3b36659f
1 <?php
2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once "version.php";
11 // Please note that the plain sql is used over the Doctrine ORM for
12 // `version` table interactions because it cannot connect due to a
13 // lack of context (this code is ran outside of the OpenEMR context).
15 $webserver_root = dirname(__FILE__);
16 if (stripos(PHP_OS,'WIN') === 0)
17 $webserver_root = str_replace("\\","/",$webserver_root);
18 $OE_SITES_BASE = "$webserver_root/sites";
20 function sqlQuery($statement, $link) {
21 $row = mysqli_fetch_array(mysqli_query($link, $statement), MYSQLI_ASSOC);
22 return $row;
25 <html>
26 <head>
27 <title>OpenEMR Site Administration</title>
28 <link rel='STYLESHEET' href='interface/themes/style_sky_blue.css'>
29 <style>
30 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; font-weight:bold; }
31 tr.detail { font-size:10pt; }
32 a, a:visited, a:hover { color:#0000cc; text-decoration:none; }
33 </style>
34 </head>
35 <body>
36 <center>
37 <p><span class='title'>OpenEMR Site Administration</span></p>
38 <table width='100%' cellpadding='1' cellspacing='2'>
39 <tr class='head'>
40 <td>Site ID</td>
41 <td>DB Name</td>
42 <td>Site Name</td>
43 <td>Version</td>
44 <td>Action</td>
45 </tr>
46 <?php
47 $dh = opendir($OE_SITES_BASE);
48 if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
49 $siteslist = array();
51 while (false !== ($sfname = readdir($dh))) {
52 if (substr($sfname, 0, 1) == '.') continue;
53 if ($sfname == 'CVS' ) continue;
54 $sitedir = "$OE_SITES_BASE/$sfname";
55 if (!is_dir($sitedir) ) continue;
56 if (!is_file("$sitedir/sqlconf.php")) continue;
57 $siteslist[$sfname] = $sfname;
60 closedir($dh);
61 ksort($siteslist);
63 foreach ($siteslist as $sfname) {
64 $sitedir = "$OE_SITES_BASE/$sfname";
65 $errmsg = '';
66 ++$encount;
67 $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd");
69 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
71 // Access the site's database.
72 include "$sitedir/sqlconf.php";
74 if ($config) {
75 $dbh = mysqli_connect("$host", "$login", "$pass", $dbase, $port);
76 if (!$dbh)
77 $errmsg = "MySQL connect failed";
80 echo " <td>$sfname</td>\n";
81 echo " <td>$dbase</td>\n";
83 if (!$config) {
84 echo " <td colspan='3'><a href='setup.php?site=$sfname'>Needs setup, click here to run it</a></td>\n";
86 else if ($errmsg) {
87 echo " <td colspan='3' style='color:red'>$errmsg</td>\n";
89 else {
90 // Get site name for display.
91 $row = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'openemr_name' LIMIT 1", $dbh);
92 $openemr_name = $row ? $row['gl_value'] : '';
94 // Get version indicators from the database.
95 $row = sqlQuery("SHOW TABLES LIKE 'version'", $dbh);
96 if (empty($row)) {
97 $openemr_version = 'Unknown';
98 $database_version = 0;
100 else {
101 $row = sqlQuery("SELECT * FROM version LIMIT 1", $dbh);
102 $database_patch_txt = "";
103 if ( !(empty($row['v_realpatch'])) && $row['v_realpatch'] != 0 ) {
104 $database_patch_txt = " (" . $row['v_realpatch'] .")";
106 $openemr_version = $row['v_major'] . "." . $row['v_minor'] . "." .
107 $row['v_patch'] . $row['v_tag'] . $database_patch_txt;
108 $database_version = 0 + $row['v_database'];
109 $database_acl = 0 + $row['v_acl'];
110 $database_patch = 0 + $row['v_realpatch'];
113 // Display relevant columns.
114 echo " <td>$openemr_name</td>\n";
115 echo " <td>$openemr_version</td>\n";
116 if ($v_database != $database_version) {
117 echo " <td><a href='sql_upgrade.php?site=$sfname'>Upgrade Database</a></td>\n";
119 else if ( ($v_acl > $database_acl) ) {
120 echo " <td><a href='acl_upgrade.php?site=$sfname'>Upgrade Access Controls</a></td>\n";
122 else if ( ($v_realpatch != $database_patch) ) {
123 echo " <td><a href='sql_patch.php?site=$sfname'>Patch Database</a></td>\n";
125 else {
126 echo " <td><a href='interface/login/login.php?site=$sfname'>Log In</a></td>\n";
129 echo " </tr>\n";
131 if ($config && $dbh !== FALSE) mysqli_close($dbh);
134 </table>
135 <form method='post' action='setup.php'>
136 <p><input type='submit' name='form_submit' value='Add New Site' /></p>
137 </form>
138 </center>
139 </body>
140 </html>