1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (!function_exists('ifdef')) |
4
|
|
|
{ |
5
|
|
|
function ifdef($value, Array $array) |
6
|
|
|
{ |
7
|
|
|
$global = __DIR__ . '/../../../config/global.config.php'; |
8
|
|
|
|
9
|
|
|
if (file_exists($global)) |
10
|
|
|
{ |
11
|
|
|
$key = array_shift($array); |
12
|
|
|
$in = include $global; |
13
|
|
|
|
14
|
|
|
do |
15
|
|
|
{ |
16
|
|
|
if (is_array($in)) |
17
|
|
|
{ |
18
|
|
|
if (array_key_exists($key, $in)) |
19
|
|
|
$in = $in[$key]; |
20
|
|
|
else |
21
|
|
|
return $value; |
22
|
|
|
} |
23
|
|
|
else |
24
|
|
|
return $value; |
25
|
|
|
|
26
|
|
|
$key = ($array) ? array_shift($array) : NULL; |
27
|
|
|
|
28
|
|
|
if (!$key) |
29
|
|
|
return $in; |
30
|
|
|
|
31
|
|
|
} while($key); |
32
|
|
|
} |
33
|
|
|
else |
34
|
|
|
return $value; |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return [ |
39
|
|
|
'project' => [ |
40
|
|
|
'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
41
|
|
|
], |
42
|
|
|
'mail' => [ |
43
|
|
|
/** CHECKING: |
44
|
|
|
* If checking is enabled, the registering process will require e-mail verification. |
45
|
|
|
* If checking is enabled, the user will log in after registering. |
46
|
|
|
*/ |
47
|
|
|
'checking' => [ |
48
|
|
|
'enabled' => "N", |
49
|
|
|
'from' => ifdef('[email protected]', ["mail", "noreply"]) |
50
|
|
|
], |
51
|
|
|
"host" => ifdef('localhost', ["mail", "host"]) |
52
|
|
|
], |
53
|
|
|
"authentication" => [ |
54
|
|
|
"method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
55
|
|
|
"key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
56
|
|
|
/** AUTH TYPE: |
57
|
|
|
* db_table: get credentials from a table in a database |
58
|
|
|
* db_user: get credentials from database users (database authentication) |
59
|
|
|
*/ |
60
|
|
|
"type" => "db_table", |
61
|
|
|
/** DB GATEWAY: |
62
|
|
|
* Gateway is used to connect to database. It consists in an entity that connects to |
63
|
|
|
* a database and checks the specified credentials. Theses will checked only if the AUTH TYPE is db_table. |
64
|
|
|
*/ |
65
|
|
|
"gateway" => [ |
66
|
|
|
"entity" => "USER", # Table name (without prefix if exists) |
67
|
|
|
/** CREDENTIALS: |
68
|
|
|
* The field names of credentials in the table. |
69
|
|
|
*/ |
70
|
|
|
"credentials" => [ |
71
|
|
|
"username" => "USERNAME", |
72
|
|
|
"password" => "USER_PASSWORD" |
73
|
|
|
], |
74
|
|
|
|
75
|
|
|
// [TO DO] - Add validations for the following ... |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** TABLE INFO: |
79
|
|
|
* Other information may be required for abstraction. If mail_checking is not enabled, your must define |
80
|
|
|
* at least the id_field for the table. |
81
|
|
|
*/ |
82
|
|
|
"table_info" => [ |
83
|
|
|
"columns" => [ |
84
|
|
|
"id_field" => "USER_ID", # often the primary key |
85
|
|
|
"state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
86
|
|
|
"email_field" => "EMAIL" # required registration process |
87
|
|
|
], |
88
|
|
|
"column_values" => [ |
89
|
|
|
"state_field" => [ |
90
|
|
|
"pending_email" => 1, # required if mail_checking is enabled |
91
|
|
|
"user_active" => 2, # required if mail_checking is enabled |
92
|
|
|
] |
93
|
|
|
] |
94
|
|
|
] |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
], |
98
|
|
|
], |
99
|
|
|
/** AUTHORIZATION: |
100
|
|
|
* |
101
|
|
|
* If authorization is enabled, after user registering someone must authorize the first login of a user. |
102
|
|
|
* After that, the user will log in because it was authorized. Basically, the authorization consist in to |
103
|
|
|
* assign a role to the user. |
104
|
|
|
* |
105
|
|
|
* If authorization is not enabled, users will log in after registration process without a previous authorization. |
106
|
|
|
*/ |
107
|
|
|
"authorization" => [ |
108
|
|
|
"enabled" => "N" |
109
|
|
|
], |
110
|
|
|
"database" => [ |
111
|
|
|
/** TABLE PREFIX: |
112
|
|
|
* Database prefix of tables, specifically here, the prefix of entity gateway above. |
113
|
|
|
*/ |
114
|
|
|
"prefix" => ifdef('APP', ["database", "prefix"]) |
115
|
|
|
], |
116
|
|
|
"redirect" => "Workarea" # the module that will be redirect to, after authentication |
117
|
|
|
]; |