forked from gaiaehr/gaiaehr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
92 lines (82 loc) · 2.99 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* GaiaEHR (Electronic Health Records)
* Copyright (C) 2013 Certun, LLC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
session_cache_limiter('private');
session_cache_expire(1);
session_regenerate_id(false);
session_name('GaiaEHR');
session_start();
setcookie(session_name(),session_id(),time()+86400, '/', null, false, true);
header('Content-type: text/html; charset=utf-8');
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 100);
define('_GaiaEXEC', 1);
if(isset($_SESSION['hooks'])) unset($_SESSION['hooks']);
/**
* Startup the registry
* This contains SESSION Variables to use in the application
* and mobile_detect class is used to detect mobile browsers.
*/
include_once('registry.php');
/**
* Make the auth process
* lets check for 4 things to allow the user in
* 1. $_SESSION['user'] is set (this helps to app clean of PHP NOTICES)
* 2. $_SESSION['user']['auth'] is true (check if the user is authorized)
* 3. $_SESSION['user']['site'] is $site ($site == $_GET['site] or 'default')
* 4. $_SESSION['inactive']['life'] is less than $_SESSION['inactive']['time']
* (to make sure ths user hasn't been out for a long time)
*
*/
if(isset($_SESSION['user']) &&
$_SESSION['user']['auth'] == true &&
$_SESSION['user']['site'] == $site &&
$_SESSION['inactive']['life'] < $_SESSION['inactive']['time'])
{
/**
* if mobile go to mobile app, else go to app
*/
$_SESSION['install'] = false;
if(isset($_SESSION['site']['checkInMode']) && $_SESSION['site']['checkInMode']){
include_once('checkin/checkin.php');
} else {
if(isset($_REQUEST['dual']) && $_REQUEST['dual']){
include_once('_dual.php');
}else{
include_once('_app.php');
}
}
} else { // Make the logon process or Setup process
/**
* If no directory is found inside sites dir run the setup wizard,
* if a directory is found inside sites dir run the logon screen
*/
if(sites_count == 0){
unset($_SESSION['site']);
$_SESSION['install'] = true;
include_once('_install.php');
} else {
$_SESSION['user']['auth'] = false;
$_SESSION['install'] = false;
include_once('_login.php');
}
}
$_SESSION['inactive']['timeout'] = time();