forked from mitodl/response-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.php
55 lines (50 loc) · 1.84 KB
/
configuration.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
<?php
class Config
{
public $database_host = '127.0.0.1';
public $database_port = 3306;
public $database_name = 'response_map';
public $database_user = 'rmap_user';
public $database_pass = '';
public $adminpassword = '19VZ7mDyYsHWs9iU3AWm';
public $google_key = '';
public $key_secret = '{}';
public $instructor_roles = '["Instructor", "Administrator", "ContentDeveloper"]';
// environment variables map with Config properties
private $envs = array(
'OPENSHIFT_MYSQL_DB_HOST' => 'database_host',
'OPENSHIFT_MYSQL_DB_PORT' => 'database_port',
'OPENSHIFT_APP_NAME' => 'database_name',
'OPENSHIFT_MYSQL_DB_USERNAME' => 'database_user',
'OPENSHIFT_MYSQL_DB_PASSWORD' => 'database_pass',
'DB_HOST' => 'database_host',
'DB_PORT' => 'database_port',
'DB_NAME' => 'database_name',
'DB_USERNAME' => 'database_user',
'DB_PASSWORD' => 'database_pass',
'ADMIN_PASSWORD' => 'adminpassword',
'GOOGLE_KEY' => 'google_key',
'OAUTH_CONSUMER' => 'key_secret',
'INSTRUCTOR_ROLES' => 'instructor_roles',
);
public function __construct()
{
// include config.php if exists
include('config.php');
foreach ($this->envs as $k => $v) {
$value = getenv($k);
// if environment variable is set
if ($value !== false) {
$this->$v = $value;
// if variable is set in config.php
} else if (isset($$v)) {
$this->$v = $$v;
}
}
}
}
// initialize the configuration
$config = new Config();
// Establish a connection to the database
$conn = mysqli_connect($config->database_host, $config->database_user, $config->database_pass, $config->database_name, $config->database_port);
mysqli_set_charset($conn, 'utf8');