-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.php
executable file
·66 lines (59 loc) · 2.21 KB
/
engine.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
<?php
require_once 'init.php';
// AdiantiCoreApplication::setRouter(array('AdiantiRouteTranslator', 'translate'));
class TApplication extends AdiantiCoreApplication
{
public static function run($debug = null)
{
new TSession;
ApplicationTranslator::setLanguage( TSession::getValue('user_language'), true ); // multi-lang
if ($_REQUEST)
{
$ini = AdiantiApplicationConfig::get();
$class = isset($_REQUEST['class']) ? $_REQUEST['class'] : '';
$public = in_array($class, $ini['permission']['public_classes']);
$debug = is_null($debug)? $ini['general']['debug'] : $debug;
if (TSession::getValue('logged')) // logged
{
$programs = (array) TSession::getValue('programs'); // programs with permission
$programs = array_merge($programs, self::getDefaultPermissions());
if( isset($programs[$class]) OR $public )
{
parent::run($debug);
}
else
{
http_response_code(401);
new TMessage('error', _t('Permission denied') );
}
}
else if ($class == 'LoginForm' OR $public )
{
parent::run($debug);
}
else
{
http_response_code(401);
new TMessage('error', _t('Permission denied'), new TAction(array('LoginForm','onLogout')) );
}
}
}
/**
* Return default programs for logged users
*/
public static function getDefaultPermissions()
{
return ['Adianti\Base\TStandardSeek' => TRUE,
'LoginForm' => TRUE,
'AdiantiMultiSearchService' => TRUE,
'AdiantiUploaderService' => TRUE,
'AdiantiAutocompleteService' => TRUE,
'SystemDocumentUploaderService' => TRUE,
'EmptyPage' => TRUE,
'MessageList' => TRUE,
'NotificationList' => TRUE,
'SearchBox' => TRUE,
'SearchInputBox' => TRUE];
}
}
TApplication::run();