forked from Eric-Brison/dynacase-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
75 lines (67 loc) · 2.27 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
<?php
/*
* @author Anakeen
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
* @package FDL
*/
/**
* Main program to activate action in WHAT software
*
* All HTTP requests call index.php to execute action within application
*
* @author Anakeen
* @version $Id: index.php,v 1.64 2008/12/16 15:51:53 jerome Exp $
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
* @package FDL
* @subpackage
*/
/**
*/
include_once ('WHAT/Lib.Main.php');
include_once ('WHAT/Class.AuthenticatorManager.php');
include_once ('WHAT/Class.ActionRouter.php');
$guestMode = getDbAccessValue("useIndexAsGuest");
$needToBeGuest = false;
$noAsk = ($guestMode == true);
$status = AuthenticatorManager::checkAccess(null, $noAsk);
switch ($status) {
case AuthenticatorManager::AccessOk: // it'good, user is authentified
$_SERVER['PHP_AUTH_USER'] = AuthenticatorManager::$auth->getAuthUser();
break;
case AuthenticatorManager::AccessBug:
// User must change his password
// $action->session->close();
AuthenticatorManager::$auth->logout("authent.php?sole=A&app=AUTHENT&action=ERRNO_BUG_639");
exit(0);
break;
case AuthenticatorManager::NeedAsk:
$needToBeGuest = true;
break;
default:
sleep(1); // for robots
// Redirect to authentication
AuthenticatorManager::$auth->askAuthentication(array());
// AuthenticatorManager::$auth->askAuthentication(array("error" => $status));
// Redirect($action, 'AUTHENT', 'LOGINFORM&error='.$status.'&auth_user='.urlencode($_POST['auth_user']));
exit(0);
}
$account = AuthenticatorManager::getAccount();
if ($account === false) {
if (!$needToBeGuest) {
throw new \Dcp\Exception("You are not supposed to be here...");
}
}
if ($needToBeGuest) {
$account = new Account();
if ($account->setLoginName("anonymous") === false) {
throw new \Dcp\Exception("anonymous account not found.");
}
}
if (ActionRouter::inMaintenance()) {
if ($account->login != 'admin') {
include_once ('TOOLBOX/stop.php');
exit(0);
}
}
$actionRouter = new ActionRouter($account, AuthenticatorManager::$auth);
$actionRouter->executeAction();