2019-10-29 14:57:13 +01:00
|
|
|
<?php
|
2019-10-29 18:33:30 +01:00
|
|
|
namespace descartes;
|
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
/*
|
|
|
|
* Define Descartes env
|
|
|
|
*/
|
2024-02-25 11:04:45 +01:00
|
|
|
$http_dir_path = ''; //Path we need to put after servername in url to access app
|
2023-05-29 21:53:09 +02:00
|
|
|
$https = $_SERVER['HTTPS'] ?? 0;
|
|
|
|
|
|
|
|
// Check for proxy forward
|
|
|
|
$forwarded_https = ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? $_SERVER['HTTP_FORWARDED_PROTO'] ?? NULL) == 'https';
|
|
|
|
$forwarded_ssl = ($_SERVER['HTTP_X_FORWARDED_SSL'] ?? NULL) == 'on';
|
|
|
|
$proxy = $forwarded_https || $forwarded_ssl;
|
|
|
|
|
|
|
|
$http_protocol = 'http://';
|
|
|
|
if ($https)
|
2019-10-29 18:33:30 +01:00
|
|
|
{
|
2023-05-29 21:53:09 +02:00
|
|
|
$http_protocol = 'https://';
|
2019-10-29 18:33:30 +01:00
|
|
|
}
|
|
|
|
|
2023-05-29 21:53:09 +02:00
|
|
|
$http_server_name = $_SERVER['SERVER_NAME'] ?? 'localhost';
|
2022-11-04 20:00:27 +01:00
|
|
|
|
2023-05-29 21:53:09 +02:00
|
|
|
// Check port to only set it if not default port
|
|
|
|
$port = $_SERVER['SERVER_PORT'] ?? '';
|
|
|
|
$port = ($port == 80 && !$https) ? '' : $port;
|
|
|
|
$port = ($port == 443 && $https) ? '' : $port;
|
|
|
|
$port = $proxy ? '' : $port;
|
|
|
|
$http_server_port = $port ? ':' . $port : '';
|
|
|
|
|
2024-02-25 11:04:45 +01:00
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
$pwd = substr(__DIR__, 0, strrpos(__DIR__, '/'));
|
2024-02-25 11:04:45 +01:00
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
|
|
|
|
$env = [
|
|
|
|
//Global http and file path
|
|
|
|
'HTTP_DIR_PATH' => $http_dir_path,
|
|
|
|
'HTTP_PROTOCOL' => $http_protocol,
|
|
|
|
'HTTP_SERVER_NAME' => $http_server_name,
|
|
|
|
'HTTP_SERVER_PORT' => $http_server_port,
|
|
|
|
'PWD' => $pwd,
|
2024-02-25 11:04:45 +01:00
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
//path of back resources
|
|
|
|
'PWD_CONTROLLER' => $pwd . '/controllers', //Controllers dir
|
|
|
|
'PWD_MODEL' => $pwd . '/models', //Models dir
|
|
|
|
'PWD_TEMPLATES' => $pwd . '/templates', //Templates dir
|
|
|
|
|
|
|
|
//path of front resources
|
2024-02-25 11:04:45 +01:00
|
|
|
'PWD_ASSETS' => $pwd . '/assets', //Assets dir
|
2019-10-29 14:57:13 +01:00
|
|
|
|
|
|
|
//images
|
|
|
|
'PWD_IMG' => $pwd . '/assets' . '/img',
|
2024-02-25 11:04:45 +01:00
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
//css
|
|
|
|
'PWD_CSS' => $pwd . '/assets' . '/css',
|
2024-02-25 11:04:45 +01:00
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
//javascript
|
|
|
|
'PWD_JS' => $pwd . '/assets' . '/js',
|
2024-02-25 11:04:45 +01:00
|
|
|
|
2019-10-29 14:57:13 +01:00
|
|
|
//fonts
|
|
|
|
'PWD_FONT' => $pwd . '/assets' . '/font',
|
|
|
|
];
|
|
|
|
|