2014-03-07 13:20:06 -04:00
|
|
|
<?php
|
2017-08-16 10:07:09 -04:00
|
|
|
|
2017-07-28 06:14:34 -07:00
|
|
|
use Illuminate\Foundation\Http\Kernel;
|
2017-08-16 10:07:09 -04:00
|
|
|
use Maveriks\WebApplication;
|
|
|
|
|
use Maveriks\Http\Response;
|
|
|
|
|
use Maveriks\Pattern\Mvc\PhtmlView;
|
2018-08-29 09:44:42 -04:00
|
|
|
use ProcessMaker\Core\AppEvent;
|
2017-08-16 10:07:09 -04:00
|
|
|
use ProcessMaker\Exception\RBACException;
|
2017-07-28 06:14:34 -07:00
|
|
|
|
2017-07-27 15:29:55 -07:00
|
|
|
// Because laravel has a __ helper function, it's important we include the class.g file to ensure our __ is used.
|
2017-08-07 13:02:26 -04:00
|
|
|
require_once __DIR__ . '/../../gulliver/system/class.g.php';
|
|
|
|
|
require_once __DIR__ . '/../../bootstrap/autoload.php';
|
|
|
|
|
require_once __DIR__ . '/../../bootstrap/app.php';
|
2017-07-28 06:14:34 -07:00
|
|
|
|
2025-04-05 10:45:25 +00:00
|
|
|
//Initialize application event
|
2018-08-29 09:44:42 -04:00
|
|
|
AppEvent::getAppEvent();
|
2017-07-27 15:29:55 -07:00
|
|
|
|
2025-04-05 10:45:25 +00:00
|
|
|
// Register shutdown function to close Propel if it exists
|
2015-03-30 15:02:48 -04:00
|
|
|
register_shutdown_function(
|
2019-11-27 14:22:09 -04:00
|
|
|
function () {
|
|
|
|
|
if (class_exists('Propel')) {
|
2015-03-30 15:02:48 -04:00
|
|
|
Propel::close();
|
|
|
|
|
}
|
2019-11-27 14:22:09 -04:00
|
|
|
}
|
2015-03-30 15:02:48 -04:00
|
|
|
);
|
|
|
|
|
|
2025-04-05 10:45:25 +00:00
|
|
|
// Set session cookie settings
|
2015-04-20 17:01:38 -04:00
|
|
|
ini_set("session.cookie_httponly", 1);
|
|
|
|
|
|
2025-04-05 10:45:25 +00:00
|
|
|
// Handle unencoded URL
|
2014-06-24 12:12:59 -04:00
|
|
|
if (isset($_SERVER['UNENCODED_URL'])) {
|
|
|
|
|
$_SERVER['REQUEST_URI'] = $_SERVER['UNENCODED_URL'];
|
|
|
|
|
}
|
2015-04-20 17:01:38 -04:00
|
|
|
|
2014-03-10 16:02:09 -04:00
|
|
|
try {
|
|
|
|
|
$rootDir = realpath(__DIR__ . "/../../") . DIRECTORY_SEPARATOR;
|
2017-08-16 10:07:09 -04:00
|
|
|
$app = new WebApplication();
|
2014-03-10 16:02:09 -04:00
|
|
|
$app->setRootDir($rootDir);
|
|
|
|
|
$app->setRequestUri($_SERVER['REQUEST_URI']);
|
2025-04-05 10:45:25 +00:00
|
|
|
|
|
|
|
|
// Route the application
|
2014-03-11 18:05:50 -04:00
|
|
|
$stat = $app->route();
|
2014-03-10 16:02:09 -04:00
|
|
|
|
2017-08-16 10:07:09 -04:00
|
|
|
switch ($stat) {
|
|
|
|
|
case WebApplication::RUNNING_WORKFLOW:
|
2014-03-10 16:02:09 -04:00
|
|
|
include "sysGeneric.php";
|
|
|
|
|
break;
|
2014-03-12 18:20:35 -04:00
|
|
|
|
2017-08-16 10:07:09 -04:00
|
|
|
case WebApplication::RUNNING_API:
|
|
|
|
|
$app->run(WebApplication::SERVICE_API);
|
2014-03-10 16:02:09 -04:00
|
|
|
break;
|
2014-03-13 10:23:50 -04:00
|
|
|
|
2017-08-16 10:07:09 -04:00
|
|
|
case WebApplication::RUNNING_OAUTH2:
|
|
|
|
|
$app->run(WebApplication::SERVICE_OAUTH2);
|
2014-09-23 15:12:04 -04:00
|
|
|
break;
|
|
|
|
|
|
2017-08-16 10:07:09 -04:00
|
|
|
case WebApplication::RUNNING_INDEX:
|
|
|
|
|
$response = new Response(file_get_contents("index.html"), 302);
|
2014-03-13 10:23:50 -04:00
|
|
|
$response->send();
|
|
|
|
|
break;
|
|
|
|
|
|
2017-08-16 10:07:09 -04:00
|
|
|
case WebApplication::RUNNING_DEFAULT:
|
|
|
|
|
$response = new Response("", 302);
|
2014-03-17 09:48:23 -04:00
|
|
|
//TODO compose this def url with configuration data from env.ini
|
|
|
|
|
$response->setHeader("location", "/sys/en/neoclassic/login/login");
|
|
|
|
|
$response->send();
|
2014-03-13 10:23:50 -04:00
|
|
|
break;
|
2014-03-10 16:02:09 -04:00
|
|
|
}
|
2017-08-16 10:07:09 -04:00
|
|
|
} catch (RBACException $e) {
|
2025-04-05 10:45:25 +00:00
|
|
|
handleRBACException($e);
|
2014-03-10 16:02:09 -04:00
|
|
|
} catch (Exception $e) {
|
2025-04-05 10:45:25 +00:00
|
|
|
//handleGeneralException($e, $rootDir);
|
2017-08-16 10:07:09 -04:00
|
|
|
$view = new PhtmlView($rootDir . "framework/src/templates/Exception.phtml");
|
2014-03-12 18:20:35 -04:00
|
|
|
$view->set("message", $e->getMessage());
|
|
|
|
|
$view->set("exception", $e);
|
|
|
|
|
|
2017-08-16 10:07:09 -04:00
|
|
|
$response = new Response($view->getOutput(), 503);
|
2014-03-12 18:20:35 -04:00
|
|
|
$response->send();
|
2025-04-05 10:45:25 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle the application state based on routing status.
|
|
|
|
|
*
|
|
|
|
|
* @param int $stat
|
|
|
|
|
* @param WebApplication $app
|
|
|
|
|
*/
|
|
|
|
|
function handleApplicationState(int $stat, WebApplication $app): void {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle RBAC exceptions by redirecting to the specified path.
|
|
|
|
|
*
|
|
|
|
|
* @param RBACException $e
|
|
|
|
|
*/
|
|
|
|
|
function handleRBACException(RBACException $e): void {
|
|
|
|
|
G::header('location: ' . $e->getPath());
|
2014-03-10 16:02:09 -04:00
|
|
|
}
|
2015-04-20 17:01:38 -04:00
|
|
|
|
2025-04-05 10:45:25 +00:00
|
|
|
/**
|
|
|
|
|
* Handle general exceptions by rendering an error view.
|
|
|
|
|
*
|
|
|
|
|
* @param Exception $e
|
|
|
|
|
* @param string $rootDir
|
|
|
|
|
*/
|
|
|
|
|
function handleGeneralException(Exception $e, string $rootDir): void {
|
|
|
|
|
$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();
|
|
|
|
|
}
|