2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
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 $webserver_root = dirname(__FILE__
);
12 if (stripos(PHP_OS
,'WIN') === 0)
13 $webserver_root = str_replace("\\","/",$webserver_root);
14 $OE_SITES_BASE = "$webserver_root/sites";
16 function sqlQuery($statement, $link) {
17 $row = mysqli_fetch_array(mysqli_query($link, $statement), MYSQLI_ASSOC
);
23 <title
>OpenEMR Site Administration
</title
>
24 <link rel
='STYLESHEET' href
='interface/themes/style_sky_blue.css'>
26 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; font-weight:bold; }
27 tr
.detail
{ font
-size
:10pt
; }
28 a
, a
:visited
, a
:hover
{ color
:#0000cc; text-decoration:none; }
33 <p
><span
class='title'>OpenEMR Site Administration
</span
></p
>
34 <table width
='100%' cellpadding
='1' cellspacing
='2'>
43 $dh = opendir($OE_SITES_BASE);
44 if (!$dh) die("Cannot read directory '$OE_SITES_BASE'.");
47 while (false !== ($sfname = readdir($dh))) {
48 if (substr($sfname, 0, 1) == '.') continue;
49 if ($sfname == 'CVS' ) continue;
50 $sitedir = "$OE_SITES_BASE/$sfname";
51 if (!is_dir($sitedir) ) continue;
52 if (!is_file("$sitedir/sqlconf.php")) continue;
53 $siteslist[$sfname] = $sfname;
59 foreach ($siteslist as $sfname) {
60 $sitedir = "$OE_SITES_BASE/$sfname";
63 $bgcolor = "#" . (($encount & 1) ?
"ddddff" : "ffdddd");
65 echo " <tr class='detail' bgcolor='$bgcolor'>\n";
67 // Access the site's database.
68 include "$sitedir/sqlconf.php";
71 $dbh = mysqli_connect("$host", "$login", "$pass", $dbase, $port);
73 $errmsg = "MySQL connect failed";
76 echo " <td>$sfname</td>\n";
77 echo " <td>$dbase</td>\n";
80 echo " <td colspan='3'><a href='setup.php?site=$sfname'>Needs setup, click here to run it</a></td>\n";
83 echo " <td colspan='3' style='color:red'>$errmsg</td>\n";
86 // Get site name for display.
87 $row = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'openemr_name' LIMIT 1", $dbh);
88 $openemr_name = $row ?
$row['gl_value'] : '';
90 // Get version indicators from the database.
91 $row = sqlQuery("SHOW TABLES LIKE 'version'", $dbh);
93 $openemr_version = 'Unknown';
94 $database_version = 0;
97 $row = sqlQuery("SELECT * FROM version LIMIT 1", $dbh);
98 $database_patch_txt = "";
99 if ( !(empty($row['v_realpatch'])) && $row['v_realpatch'] != 0 ) {
100 $database_patch_txt = " (" . $row['v_realpatch'] .")";
102 $openemr_version = $row['v_major'] . "." . $row['v_minor'] . "." .
103 $row['v_patch'] . $row['v_tag'] . $database_patch_txt;
104 $database_version = 0 +
$row['v_database'];
105 $database_acl = 0 +
$row['v_acl'];
106 $database_patch = 0 +
$row['v_realpatch'];
109 // Display relevant columns.
110 echo " <td>$openemr_name</td>\n";
111 echo " <td>$openemr_version</td>\n";
112 if ($v_database != $database_version) {
113 echo " <td><a href='sql_upgrade.php?site=$sfname'>Upgrade Database</a></td>\n";
115 else if ( ($v_acl > $database_acl) ) {
116 echo " <td><a href='acl_upgrade.php?site=$sfname'>Upgrade Access Controls</a></td>\n";
118 else if ( ($v_realpatch != $database_patch) ) {
119 echo " <td><a href='sql_patch.php?site=$sfname'>Patch Database</a></td>\n";
122 echo " <td><a href='interface/login/login_frame.php?site=$sfname'>Log In</a></td>\n";
127 if ($config && $dbh !== FALSE) mysqli_close($dbh);
131 <form method
='post' action
='setup.php'>
132 <p
><input type
='submit' name
='form_submit' value
='Add New Site' /></p
>