Add multi-site support.
[openemr.git] / index.php
blob62cd3e5535ca06a9d08d83928ea47d22153a0139
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
6 // Set the site ID if required. This must be done before any database
7 // access is attempted.
9 if (!empty($_GET['site'])) {
10 $site_id = $_GET['site'];
11 } else if (is_dir("sites/" . $_SERVER['HTTP_HOST'])) {
12 $site_id = $_SERVER['HTTP_HOST'];
13 } else {
14 $site_id = 'default';
17 if (empty($site_id) || preg_match('/[^A-Za-z0-9\\-.]/', $site_id)) {
18 die("Site ID '".htmlspecialchars($site_id, ENT_NOQUOTES)."' contains invalid characters.");
21 require_once "sites/$site_id/sqlconf.php";
23 if ($config == 1) {
24 header("Location: interface/login/login.php?site=$site_id");
25 } else {
26 header("Location: setup.php?site=$site_id");