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) {
17 $row = @mysql_fetch_array
(mysql_query($statement), MYSQL_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 = mysql_connect("$host:$port", "$login", "$pass");
73 $errmsg = "MySQL connect failed";
74 else if (!mysql_select_db($dbase, $dbh))
75 $errmsg = "Access to database failed";
78 echo " <td>$sfname</td>\n";
79 echo " <td>$dbase</td>\n";
82 echo " <td colspan='3'><a href='setup.php?site=$sfname'>Needs setup, click here to run it</a></td>\n";
85 echo " <td colspan='3' style='color:red'>$errmsg</td>\n";
88 // Get site name for display.
89 $row = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = 'openemr_name' LIMIT 1");
90 $openemr_name = $row ?
$row['gl_value'] : '';
92 // Get version indicators from the database.
93 $row = sqlQuery("SHOW TABLES LIKE 'version'");
95 $openemr_version = 'Unknown';
96 $database_version = 0;
99 $row = sqlQuery("SELECT * FROM version LIMIT 1");
100 $openemr_version = $row['v_major'] . "." . $row['v_minor'] . "." .
101 $row['v_patch'] . $row['v_tag'];
102 $database_version = 0 +
$row['v_database'];
105 // Display relevant columns.
106 echo " <td>$openemr_name</td>\n";
107 echo " <td>$openemr_version</td>\n";
108 if ($v_database == $database_version) {
109 echo " <td><a href='interface/login/login_frame.php?site=$sfname'>Log In</a></td>\n";
112 echo " <td><a href='sql_upgrade.php?site=$sfname'>Upgrade Database</a></td>\n";
117 if ($config && $dbh !== FALSE) mysql_close($dbh);
121 <form method
='post' action
='setup.php'>
122 <p
><input type
='submit' name
='form_submit' value
='Add New Site' /></p
>