eesyphp/includes/core.php

98 lines
2.7 KiB
PHP

<?php
use EesyPHP\Email;
use EesyPHP\Log;
use EesyPHP\SentryIntegration;
use EesyPHP\SentrySpan;
use EesyPHP\SentryTransaction;
use EesyPHP\Session;
use EesyPHP\Url;
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
// Root directory path
$script = null;
if (defined('__FILE__') && constant('__FILE__')) {
$script = __FILE__;
}
else {
// Fallback method : detect path from core.php path
foreach(get_included_files() as $script)
if (basename($script) == 'core.php')
break;
}
if (!$script) die('Fail to detect root directory path');
$root_dir_path = realpath(dirname($script).'/../');
// Include App's includes and vendor directories to PHP include paths
set_include_path($root_dir_path.'/includes' . PATH_SEPARATOR . get_include_path());
// Load composer autoload.php
require("$root_dir_path/vendor/autoload.php");
// Load configuration
require_once('translation.php');
require_once('config.inc.php');
// Load local configuration file is present
if (is_file("$root_dir_path/includes/config.local.php")) {
require "$root_dir_path/includes/config.local.php";
}
SentryIntegration :: init(
isset($sentry_dsn)?$sentry_dsn:null,
isset($sentry_traces_sample_rate)?$sentry_traces_sample_rate:null,
isset($sentry_php_error_types)?$sentry_php_error_types:null,
);
$sentry_transaction = new SentryTransaction();
$sentry_span = new SentrySpan('core.init', 'Core initialization');
// Define upload_tmp_dir
if (isset($upload_tmp_dir))
ini_set('upload_tmp_dir', $upload_tmp_dir);
if (!isset($log_file))
die('Log file path not configured');
Log::init(
$log_file,
isset($log_level)?$log_level:null,
isset($log_php_errors_levels)?$log_php_errors_levels:null
);
require_once('functions.php');
Session :: init(
isset($session_max_duration)?$session_max_duration:null,
isset($session_timeout)?$session_timeout:null
);
// Nomenclatures
$status_list = array (
'pending' => ___('Pending'),
'validated' => ___('Validated'),
'refused' => ___('Refused'),
'archived' => ___('Archived'),
);
require_once('cli.php');
require_once('translation-cli.php');
require_once('smarty.php');
Url::init(isset($public_root_url)?$public_root_url:null);
require_once('url-helpers.php');
require_once('db.php');
Email :: init(
isset($mail_sender)?$mail_sender:null,
isset($mail_send_method)?$mail_send_method:null,
isset($mail_send_params)?$mail_send_params:null,
isset($mail_catch_all)?$mail_catch_all:null,
isset($mail_headers)?$mail_headers:null,
isset($php_mail_path)?$php_mail_path:null,
isset($php_mail_mime_path)?$php_mail_mime_path:null,
);
// Initialize translation
init_translation();
foreach($status_list as $key => $value)
$status_list[$key] = _($value);
$sentry_span->finish();
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab