2019-11-03 18:23:06 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2020-11-27 07:44:04 +00:00
|
|
|
* @author David DRAPEAU <david.drapeau@jmdn-solutions.com>
|
|
|
|
* @author Benjamin LECHALUPE <benjamin.lechalupe@jmdn-solutions.com>
|
2019-11-03 18:23:06 +00:00
|
|
|
* @version 0.1
|
|
|
|
*/
|
2020-11-27 07:44:04 +00:00
|
|
|
ini_set('display_errors', 1);
|
|
|
|
ini_set('display_startup_errors', 1);
|
|
|
|
error_reporting(E_ALL);
|
2019-11-03 18:23:06 +00:00
|
|
|
|
|
|
|
// Send page content into a buffer instead of draw it directly.
|
2020-11-27 07:44:04 +00:00
|
|
|
// Required for file downloads and redirections from modules!!
|
2019-11-03 18:23:06 +00:00
|
|
|
ob_start();
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
|
2020-11-27 07:44:04 +00:00
|
|
|
if(!isset($_COOKIE['firstvisit'])){
|
|
|
|
setcookie("firstvisit", "false", time()+60*60*24*60);
|
|
|
|
}
|
2019-11-03 18:23:06 +00:00
|
|
|
|
2020-11-27 07:44:04 +00:00
|
|
|
// Reporte toutes les erreurs PHP (Voir l'historique des modifications)
|
|
|
|
if(isset($_SESSION['config']['framework_environment']) && $_SESSION['config']['framework_environment']=="dev"){
|
|
|
|
ini_set("display_errors", "stdout");
|
|
|
|
error_reporting(E_ALL & E_NOTICE);
|
2019-11-03 18:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require_once './modules/InterfaceConfig.php';
|
2020-11-27 07:44:04 +00:00
|
|
|
require_once './modules/InterfaceController.php';
|
|
|
|
require_once './modules/InterfacePostgreSQL.php';
|
2019-11-03 18:23:06 +00:00
|
|
|
require_once './modules/InterfaceTranslation.php';
|
|
|
|
require_once './modules/InterfaceEmail.php';
|
|
|
|
|
|
|
|
require_once './modules/ClassConfig.php';
|
|
|
|
require_once './modules/ClassTranslation.php';
|
|
|
|
require_once './modules/ClassController.php';
|
|
|
|
require_once './modules/ClassLang.php';
|
|
|
|
require_once './modules/ClassFeature.php';
|
|
|
|
require_once './modules/ClassFeatureTranslation.php';
|
|
|
|
require_once './modules/ClassCountry.php';
|
|
|
|
require_once './modules/ClassCurrency.php';
|
|
|
|
require_once './modules/ClassUser.php';
|
|
|
|
require_once './modules/ClassEmail.php';
|
|
|
|
require_once './modules/ClassForm.php';
|
|
|
|
|
2020-11-27 07:44:04 +00:00
|
|
|
$oConf = new ClassConfig();
|
2019-11-03 18:23:06 +00:00
|
|
|
$oTrans = new ClassTranslation();
|
|
|
|
$oController = new ClassController($_REQUEST);
|
|
|
|
$oLang = new ClassLang();
|
|
|
|
$oFeat = new ClassFeature();
|
|
|
|
$oFeatTrans = new ClassFeatureTranslation();
|
2020-11-27 07:44:04 +00:00
|
|
|
$oUser = new ClassUser();
|
2019-11-03 18:23:06 +00:00
|
|
|
$oCountry = new ClassCountry();
|
|
|
|
$oCurrency = new ClassCurrency();
|
2020-11-27 07:44:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
$oPDOLink = $oConf->databaseConnect();
|
|
|
|
} catch(PDOException $e){
|
|
|
|
print "Error:". $e->getMessage()."<br/>";
|
|
|
|
die("If you are seeing this message, please send urgently a message to contact@jmdn-solutions.com");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IMPORT MODULES FROM CUSTOM DIRECTORY
|
|
|
|
if(file_exists($oConf->getPathCustom("modules.php"))){
|
|
|
|
include($oConf->getPathCustom("modules.php"));
|
|
|
|
}
|
2019-11-03 18:23:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Load configuration in _SESSION
|
|
|
|
//unset($_SESSION['config']); //uncomment this line, even for test, creates a bug for translations for logged users
|
2020-11-27 07:44:04 +00:00
|
|
|
|
2019-11-03 18:23:06 +00:00
|
|
|
if (!isset($_SESSION['config'])) {
|
|
|
|
$_SESSION['config'] = $oConf->getConfig();
|
2020-11-27 07:44:04 +00:00
|
|
|
|
2019-11-03 18:23:06 +00:00
|
|
|
//////
|
|
|
|
//// The code below creates a bug in Chromium "Too many redirections
|
|
|
|
//$find_lang = "/[a-zA-Z][a-zA-Z]-[a-zA-Z][a-zA-Z]/";
|
|
|
|
//preg_match($find_lang, $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang);
|
|
|
|
//$lang = str_replace('-', '_', strtolower($lang[0]));
|
|
|
|
//$langs = $oLang->listLanguages();
|
|
|
|
//
|
|
|
|
//foreach ($langs as $k=>$v) {
|
|
|
|
// if ($langs[$k]['code'] == $lang) {
|
|
|
|
// $_SESSION['config']['default_lang_code'] = $lang;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
$_SESSION['translations'] = $oTrans->listTranslations($_SESSION['config']['default_lang_code']);
|
|
|
|
$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
|
|
|
|
$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
|
|
|
|
$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
|
|
|
|
$_SESSION['languages'] = $oLang->listLanguages();
|
|
|
|
$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!isset($_SESSION['translations'])){
|
|
|
|
$_SESSION['translations'] = $oTrans->listTranslations('fr_fr');
|
|
|
|
}
|
|
|
|
if(!isset($_SESSION['countries'])){
|
|
|
|
$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
|
|
|
|
}
|
|
|
|
if(!isset($_SESSION['activeCountries'])){
|
|
|
|
$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
|
|
|
|
}
|
|
|
|
if(!isset($_SESSION['currencies'])){
|
|
|
|
$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
|
|
|
|
}
|
|
|
|
if(!isset($_SESSION['languages'])){
|
|
|
|
$_SESSION['languages'] = $oLang->listLanguages();
|
|
|
|
}
|
|
|
|
if(!isset($_SESSION['activeLanguages'])){
|
|
|
|
$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
|
|
|
|
}
|
|
|
|
|
|
|
|
//$data_updated = array();
|
|
|
|
//$user = array();
|
|
|
|
//if(isset($_SESSION['user']) && isset($_POST['submit_personal_data'])){
|
|
|
|
// $_SESSION['data_updated'] = $oUser->updatePersonalData($_SESSION['user']['id'], $_POST);
|
|
|
|
// //$data_updated = $oUser->updatePersonalData($_SESSION['user']['id'], $_POST);
|
|
|
|
// $user = $oUser->getFullProfile($_SESSION['user']['id']);
|
|
|
|
// $_SESSION['user']['core_lang_id'] = $user['core_lang_id'];
|
|
|
|
// $_SESSION['user']['core_country_id'] = $user['core_country_id'];
|
|
|
|
// $_SESSION['user']['lang_code'] = $user['lang_code'];
|
|
|
|
// $_SESSION['translations'] = $oTrans->listTranslations($user['lang_code']);
|
|
|
|
// $_SESSION['features'] = $oFeat->getFeaturesOfUser($_SESSION['user']['id'], $_SESSION['user']['lang_code']);
|
|
|
|
// unset($_POST);
|
|
|
|
// unset($user);
|
|
|
|
// //$_SESSION['data_updated'] = $data_updated;
|
|
|
|
// //unset($data_updated);
|
|
|
|
//}
|
|
|
|
|
|
|
|
// If no requested page defined, load default page in default lang code
|
|
|
|
if (!isset($_REQUEST['page'])) header("Location: ".$oConf->getURLRoot($oFeatTrans->getFeatureTranslation('menu_home_url', $_SESSION['config']['default_lang_code'])));
|
|
|
|
|
|
|
|
// Get features for menu
|
|
|
|
//unset($_SESSION['features']);
|
|
|
|
if (!isset($_SESSION['features'])) {
|
2020-11-27 07:44:04 +00:00
|
|
|
if(isset($_SESSION['user']['id'])) {
|
2019-11-03 18:23:06 +00:00
|
|
|
$_SESSION['features'] = $oFeat->getFeaturesOfUser($_SESSION['user']['id']);
|
2020-11-27 07:44:04 +00:00
|
|
|
} else {
|
|
|
|
$_SESSION['features'] = $oFeat->getFeatures($_SESSION['config']['default_lang_code']);
|
2019-11-03 18:23:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-27 07:44:04 +00:00
|
|
|
if(file_exists($oConf->getPathCustom("themes/".$_SESSION['config']['theme']."/index.php"))){
|
|
|
|
include($oConf->getPathCustom("themes/".$_SESSION['config']['theme']."/index.php"));
|
|
|
|
} elseif(file_exists("./themes/".$_SESSION['config']['theme']."/index.php")) {
|
|
|
|
include("themes/".$_SESSION['config']['theme']."/index.php");
|
|
|
|
} else {
|
|
|
|
include("themes/default/index.php");
|
|
|
|
}
|
2019-11-03 18:23:06 +00:00
|
|
|
|
2020-11-27 07:44:04 +00:00
|
|
|
// Commit the buffer (display the page)
|
2019-11-03 18:23:06 +00:00
|
|
|
ob_end_flush();
|
|
|
|
?>
|