[IMP] now in AJAX PHP file, it is not needed anymore to use DB IDs hard coded; Use the session dsn
This commit is contained in:
parent
b9bbb9598a
commit
ddbc3e12d2
73
index.php
73
index.php
@ -30,6 +30,7 @@ require_once './modules/InterfacePostgreSQL.php';
|
|||||||
require_once './modules/InterfaceTranslation.php';
|
require_once './modules/InterfaceTranslation.php';
|
||||||
require_once './modules/InterfaceEmail.php';
|
require_once './modules/InterfaceEmail.php';
|
||||||
|
|
||||||
|
require_once './modules/ClassDB.php';
|
||||||
require_once './modules/ClassConfig.php';
|
require_once './modules/ClassConfig.php';
|
||||||
require_once './modules/ClassTranslation.php';
|
require_once './modules/ClassTranslation.php';
|
||||||
require_once './modules/ClassController.php';
|
require_once './modules/ClassController.php';
|
||||||
@ -42,6 +43,7 @@ require_once './modules/ClassUser.php';
|
|||||||
require_once './modules/ClassEmail.php';
|
require_once './modules/ClassEmail.php';
|
||||||
require_once './modules/ClassForm.php';
|
require_once './modules/ClassForm.php';
|
||||||
|
|
||||||
|
$oDB = new ClassDB();
|
||||||
$oConf = new ClassConfig();
|
$oConf = new ClassConfig();
|
||||||
$oTrans = new ClassTranslation();
|
$oTrans = new ClassTranslation();
|
||||||
$oController = new ClassController($_REQUEST);
|
$oController = new ClassController($_REQUEST);
|
||||||
@ -70,48 +72,55 @@ if(file_exists($oConf->getPathCustom("modules.php"))){
|
|||||||
|
|
||||||
// Load configuration in _SESSION
|
// Load configuration in _SESSION
|
||||||
//unset($_SESSION['config']); //uncomment this line, even for test, creates a bug for translations for logged users
|
//unset($_SESSION['config']); //uncomment this line, even for test, creates a bug for translations for logged users
|
||||||
|
|
||||||
if (!isset($_SESSION['config'])) {
|
if (!isset($_SESSION['config'])) {
|
||||||
$_SESSION['config'] = $oConf->getConfig();
|
$_SESSION['config'] = $oConf->getConfig();
|
||||||
|
|
||||||
//////
|
//////
|
||||||
//// The code below creates a bug in Chromium "Too many redirections
|
//// 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]/";
|
//$find_lang = "/[a-zA-Z][a-zA-Z]-[a-zA-Z][a-zA-Z]/";
|
||||||
//preg_match($find_lang, $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang);
|
//preg_match($find_lang, $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang);
|
||||||
//$lang = str_replace('-', '_', strtolower($lang[0]));
|
//$lang = str_replace('-', '_', strtolower($lang[0]));
|
||||||
//$langs = $oLang->listLanguages();
|
//$langs = $oLang->listLanguages();
|
||||||
//
|
//
|
||||||
//foreach ($langs as $k=>$v) {
|
//foreach ($langs as $k=>$v) {
|
||||||
// if ($langs[$k]['code'] == $lang) {
|
// if ($langs[$k]['code'] == $lang) {
|
||||||
// $_SESSION['config']['default_lang_code'] = $lang;
|
// $_SESSION['config']['default_lang_code'] = $lang;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
$_SESSION['translations'] = $oTrans->listTranslations($_SESSION['config']['default_lang_code']);
|
$_SESSION['translations'] = $oTrans->listTranslations($_SESSION['config']['default_lang_code']);
|
||||||
$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
|
$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
|
||||||
$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
|
$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
|
||||||
$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
|
$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
|
||||||
$_SESSION['languages'] = $oLang->listLanguages();
|
$_SESSION['languages'] = $oLang->listLanguages();
|
||||||
$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
|
$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
|
||||||
|
//$_SESSION['dsn'] = $oPDOLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$_SESSION['dsn'] = ['host'=>$oDB->_host, 'port'=>$oDB->_port, 'dbname'=>$oDB->_dbname, 'user'=>$oDB->_user, 'password'=>$oDB->_password];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!isset($_SESSION['translations'])){
|
if(!isset($_SESSION['translations'])){
|
||||||
$_SESSION['translations'] = $oTrans->listTranslations('fr_fr');
|
$_SESSION['translations'] = $oTrans->listTranslations('fr_fr');
|
||||||
}
|
}
|
||||||
if(!isset($_SESSION['countries'])){
|
if(!isset($_SESSION['countries'])){
|
||||||
$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
|
$_SESSION['countries'] = $oCountry->listCountries('priority ASC, name ASC');
|
||||||
}
|
}
|
||||||
if(!isset($_SESSION['activeCountries'])){
|
if(!isset($_SESSION['activeCountries'])){
|
||||||
$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
|
$_SESSION['activeCountries'] = $oCountry->listActiveCountries('priority ASC, name ASC');
|
||||||
}
|
}
|
||||||
if(!isset($_SESSION['currencies'])){
|
if(!isset($_SESSION['currencies'])){
|
||||||
$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
|
$_SESSION['currencies'] = $oCurrency->listCurrencies('priority ASC, name ASC');
|
||||||
}
|
}
|
||||||
if(!isset($_SESSION['languages'])){
|
if(!isset($_SESSION['languages'])){
|
||||||
$_SESSION['languages'] = $oLang->listLanguages();
|
$_SESSION['languages'] = $oLang->listLanguages();
|
||||||
}
|
}
|
||||||
if(!isset($_SESSION['activeLanguages'])){
|
if(!isset($_SESSION['activeLanguages'])){
|
||||||
$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
|
$_SESSION['activeLanguages'] = $oLang->listActiveLanguages();
|
||||||
}
|
}
|
||||||
|
|
||||||
//$data_updated = array();
|
//$data_updated = array();
|
||||||
@ -137,11 +146,11 @@ if (!isset($_REQUEST['page'])) header("Location: ".$oConf->getURLRoot($oFeatTran
|
|||||||
// Get features for menu
|
// Get features for menu
|
||||||
//unset($_SESSION['features']);
|
//unset($_SESSION['features']);
|
||||||
if (!isset($_SESSION['features'])) {
|
if (!isset($_SESSION['features'])) {
|
||||||
if(isset($_SESSION['user']['id'])) {
|
if(isset($_SESSION['user']['id'])) {
|
||||||
$_SESSION['features'] = $oFeat->getFeaturesOfUser($_SESSION['user']['id']);
|
$_SESSION['features'] = $oFeat->getFeaturesOfUser($_SESSION['user']['id']);
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['features'] = $oFeat->getFeatures($_SESSION['config']['default_lang_code']);
|
$_SESSION['features'] = $oFeat->getFeatures($_SESSION['config']['default_lang_code']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($oConf->getPathCustom("themes/".$_SESSION['config']['theme']."/index.php"))){
|
if(file_exists($oConf->getPathCustom("themes/".$_SESSION['config']['theme']."/index.php"))){
|
||||||
|
13
modules/ClassDB.php
Normal file
13
modules/ClassDB.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
class ClassDB implements InterfacePostgreSQL {
|
||||||
|
public function __construct(){
|
||||||
|
$this->_host = InterfacePostgreSQL::PG_SERVER;
|
||||||
|
$this->_port = InterfacePostgreSQL::PG_PORT;
|
||||||
|
$this->_dbname = InterfacePostgreSQL::PG_DBNAME;
|
||||||
|
$this->_user = InterfacePostgreSQL::PG_USER;
|
||||||
|
$this->_password = InterfacePostgreSQL::PG_PASSWORD;
|
||||||
|
}
|
||||||
|
public function __desctruct(){}
|
||||||
|
|
||||||
|
public static function databaseConnect(){}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user