-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.php
More file actions
66 lines (55 loc) · 2.12 KB
/
init.php
File metadata and controls
66 lines (55 loc) · 2.12 KB
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
<?php
/* Init script. (The magic)
*
* Responsible for very simple bootstrapping process outlined below:
*
* -----------------------------------------------------------------
* 1. overrides.php
* If a user creates an overrides file they can redefine the
* configuration and `defines` as neccesary.
*
* 2. bootstrap/conf.php1
* sets up configuration settings and connects to database
*
* 3. load all core classes
* loads core entitys representing the data in the program
*
* 4. load security classes
* load up password compatability classes and etc
*
* 5. load all services
* load up services that operate on the data that can be called from controllers
*/
$dirname = dirname(__FILE__);
/* Configuration for easily loading neccesary files that do not require
* any dependencys besides Entity etc. (aka, core classes)
*/
$axiomClasses = array('Entity', 'Goal', 'User', 'GoalType', 'LineItem', 'Account');
/* Configure Services to load as well. Note this is before overrides so
* we can shut off services or replace them with different ones if desired
*/
$servicesToLoad = array('Authentication', 'User', 'Account', 'LineItem', 'Goal', 'Metrics');
@include $dirname . '/overrides.php';
include $dirname . '/bootstrap/conf.php';
foreach ($axiomClasses as $axiom) {
include $dirname . '/core/'.$axiom.'.class.php';
}
include $dirname . '/bootstrap/database.php';
include $dirname . '/lib/password_compat/password.php';
/* Set password cryptography options for auth and user services (global var) */
$cryptOptions = array("cost" => 11);
foreach ($servicesToLoad as $service) {
include $dirname . '/service/'.$service.'Service.php';
}
include $dirname . '/view/ViewController.class.php';
$controller = new ViewController();
/* Attempt to Connect to the database to ensure we can */
Database::instance();
session_start();
function ensureUserLoggedin() {
if (!AuthenticationService::isUserLoggedIn()) {
echo '<div class="message warning">Session Timed Out</div>';
echo '<script type="text/javascript">window.alert("Session Timed Out!");</script>';
echo '<META http-equiv="refresh" content="0;URL=/login" />';
}
}