File size: 2,172 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
<?php

use Illuminate\Foundation\Http\Kernel;
use Maveriks\WebApplication;
use Maveriks\Http\Response;
use Maveriks\Pattern\Mvc\PhtmlView;
use ProcessMaker\Exception\RBACException;

// Because laravel has a __ helper function, it's important we include the class.g file to ensure our __ is used.
require_once __DIR__ . '/../../gulliver/system/class.g.php';
require_once __DIR__ . '/../../bootstrap/autoload.php';
require_once __DIR__ . '/../../bootstrap/app.php';


register_shutdown_function(
    create_function(
        "",
        "
        if (class_exists(\"Propel\")) {
            Propel::close();
        }
        "
    )
);

ini_set("session.cookie_httponly", 1);

if (isset($_SERVER['UNENCODED_URL'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
}

try {
    $rootDir = realpath(__DIR__ . "/../../") . DIRECTORY_SEPARATOR;

    $app = new WebApplication();

    $app->setRootDir($rootDir);
    $app->setRequestUri($_SERVER['REQUEST_URI']);
    $stat = $app->route();

    switch ($stat) {
        case WebApplication::RUNNING_WORKFLOW:
            include "sysGeneric.php";
            break;

        case WebApplication::RUNNING_API:
            $app->run(WebApplication::SERVICE_API);
            break;

        case WebApplication::RUNNING_OAUTH2:
            $app->run(WebApplication::SERVICE_OAUTH2);
            break;

        case WebApplication::RUNNING_INDEX:
            $response = new Response(file_get_contents("index.html"), 302);
            $response->send();
            break;

        case WebApplication::RUNNING_DEFAULT:
            $response = new Response("", 302);
            //TODO compose this def url with configuration data from env.ini
            $response->setHeader("location", "/sys/en/neoclassic/login/login");
            $response->send();
            break;
    }
} catch (RBACException $e) {
    G::header('location: ' . $e->getPath());
} catch (Exception $e) {
    $view = new PhtmlView($rootDir . "framework/src/templates/Exception.phtml");
    $view->set("message", $e->getMessage());
    $view->set("exception", $e);

    $response = new Response($view->getOutput(), 503);
    $response->send();
}