Commit b0f22c90 authored by f4eyq's avatar f4eyq

update 2020-05-17

parent 0ea04961
------------------------
-----------------------------------------
CRX FRAMEWORK
-----------------------------------------
Date: 01/2008
Current version: 3.0 ( 6 )
-----------------------------------------
Current version: 3.1 (year update 8)
-----------------------------------------
------------------------
Update 17/05/2020
------------------------
- Improve crxUser, add new start_module option.
------------------------
Update 04/03/2020
......
......@@ -251,7 +251,7 @@ extends crxCore{
if(isset($this->_env['redirect_process']) && !empty($this->_env['redirect_process'])){
return crxFrameworkWebCommon::redirect($this->_env['redirect_process']);
return crxFrameworkWebCommon::sredirect($this->_env['redirect_process']);
}
......
......@@ -3,14 +3,14 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK
* @creation date 2005
* @revision 20/03/2020
* @revision 15/05/2020
* @module crxFrameworkWeb
* @copyright see header
* @version 2.0 (7)
* @version 2.0 (8)
*/
namespace crx;
class crxFrameworkWebCommon {
var $_debug_lng = 0;
var $_lng_cache = 1;
......@@ -55,7 +55,9 @@ class crxFrameworkWebCommon {
function initContext(){
//From PHP :
//var_dump(crxFramework::getAvailableLanguage());
//$framework_lng_supported = array('en','es','fr','gm','it'); // old static values.
......@@ -299,43 +301,70 @@ class crxFrameworkWebCommon {
}
function parseIniLangFileOrIncludeLangPhpFile($module_name,$current_lng,$language_ini_path=null){
if(!$language_ini_path)
if(!$language_ini_path){
$language_ini_path = _APPLI_MAIN_MODULES_PATH_ . 'common/lang_files/'.$current_lng.'/lang.ini';
}
debugAndContinue('[INFO] Launch parsing or include process:'.$language_ini_path.'',$this->_debug_lng);
$dic = new crxLanguage($debug=FALSE);
$dic -> setCurrentLanguagesAvailableList(self::$_languages);
//_languages_coding_list
$dic -> setCurrentLanguageIsInUse($this->getGlobalValue('lang'));
$i=crxModule::getInstance()->getModuleInfo(TRUE,'module_name');
$mi=$i[$module_name];
$dic -> setCurrentModuleInformation($mi);
$dic -> setDic($language_ini_path);
return $dic -> loadDictionnary(0,$this->_debug_lng);
return $dic -> loadDictionnary(0,$this->_debug_lng,'common');
}
function loadGlobalLng($current_lng){
$path = _APPLI_MAIN_MODULES_PATH_ . 'common/lang_files/'.$current_lng.'/lang.ini';
$path = _APPLI_MAIN_MODULES_PATH_ . 'common/lang_files/'.$current_lng.'/lang.ini';///app-php/common/lang_files/en/lang.ini
if(crxFramework::getFrameworkObjectsOption('caching_ini_to_user_session')){
$cache_init = crxFramework::getFrameworkObjectsOption('caching_ini_to_user_session');
//debugAndContinue('[INFO] caching_ini_to_user_session => 1',$this->_debug_lng);
debugAndContinue('[INFO] -> Caching ini file data to user session',DEBUG_LNG_LAYER);
if($cache_init){
debugAndContinue('[INFO] -> Caching ini file data to user session (caching_ini_to_user_session=>1)',DEBUG_LNG_LAYER);
$cached_languages = $this->getCommmonUsersGlobalValue('cached_languages');
//@debug :
//unset($cached_languages['common'][$current_lng]);
//print_r($cached_languages['common']);
unset($cached_languages['common'][$current_lng]);
if(!isset($cached_languages['common'][$current_lng])){
debugAndContinue('[INFO] Loading dictionnary : '.$current_lng.' file ('.$path.')',$this->_debug_lng);
$cached_languages['common'][$current_lng] = $this->parseIniLangFileOrIncludeLangPhpFile('common',$current_lng,$path);
}else{
}
else{//Found the common into cache :
debugAndContinue('[INFO] Loading dictionnary from user session (cache) : '.$current_lng,$this->_debug_lng);
}
self::setCommmonUsersGlobalValue('cached_languages',$cached_languages);
self::$_modules_dictionnary['common'][$current_lng] = $cached_languages['common'][$current_lng];
}
else{
......@@ -377,43 +406,31 @@ class crxFrameworkWebCommon {
}
function lng($key,$current_module){
//$df=DEBUG_LNG_LAYER;//$df=0;
/*if($key=='LNG_LOG_PUB_QSO_MAP_VIEW'){
$this->_debug_lng = 1;}
else $this->_debug_lng=0;*/
//$df=DEBUG_LNG_LAYER;
//$df=0;
//if($key=='LNG_REPOSITORY_APPS_AVAILABLES'){$this->_debug_lng = 1;}
//else $this->_debug_lng=0;
//else{$this->_debug_lng = 0;}
///$this->_debug_lng = $df;
//$this->disableLngCache();
//$this->_debug_lng = 1;//$this->disableLngCache();
$current_lang = $this->getGlobalValue('lang');
//if(!isset($current_lang))$current_lang='en'; normally set via global xml conf.
debugAndContinue('[INFO][lng()] current language set is : <b>'.$current_lang.'</b> ,
module is : <b>'.$current_module.'</b>,
key is : <b>'.$key.'</b> ',$this->_debug_lng);
$disable_cache_ini_2_php=0;
//$this->_lng_cache == 0 => disable also ini to php caching :
$disable_cache_ini_2_php=1;
if($this->_lng_cache<>0){
$disable_cache_ini_2_php=0;
$r=$this->initCache(
$current_module,
$current_lang
);
}
//$this->_lng_cache == 0 => disable also ini to php caching :
else{
$disable_cache_ini_2_php=1;
}
//$disable_cache=0;
//if($this->_lng_cache==0){$disable_cache=1;}
//DEBUG FORCE IT :
//$disable_cache_ini_2_php=1;
//cache didnt exist, we force loading data :
$this->_crxWebApp = crxWebApplication::getInstance();
......@@ -422,11 +439,8 @@ class crxFrameworkWebCommon {
}
if( $this->_lng_cache<>0 && !$r ){
debugAndContinue('[INFO] <b> _lng_cache<> 0 </b>',$this->_debug_lng);
$this->__forceLoadModuleDictionnary($current_module,$current_lang,$key);
}
if($this->_lng_cache<>0){
......@@ -445,6 +459,7 @@ class crxFrameworkWebCommon {
debugAndContinue('[INFO] Cache is enable, call loadGlobalLng()',$this->_debug_lng);
$this->loadGlobalLng($current_lang);
}
if(is_string($key) && isset(self::$_modules_dictionnary['common'][$current_lang][$key])){
return self::$_modules_dictionnary['common'][$current_lang][$key];
}
......@@ -455,9 +470,7 @@ class crxFrameworkWebCommon {
elseif($this->_lng_cache == 0){
debugAndContinue('[INFO] Cache is disable (session + ini to php cache), <b> _lng_cache == 0 </b>',$this->_debug_lng);
}
//Try current lang ( P1 ) :
$i = crxModule::getInstance()->getModuleInfo(TRUE,'module_name');
$dic = new crxLanguage(FALSE);
......@@ -470,19 +483,20 @@ class crxFrameworkWebCommon {
debugAndContinue('[INFO] disable_cache_ini_2_php => '.$disable_cache_ini_2_php,DEBUG_LNG_LAYER);
if(isset($dic_data[$key])){
//Update memory and put the result inside the lang stack :
$cached_languages = $this->getCommmonUsersGlobalValue('cached_languages');
$cached_languages[$current_module][$current_lang][$key] = $dic_data[$key];
self::setCommmonUsersGlobalValue('cached_languages',$cached_languages);
//Finnaly return the result :
debugAndContinue('[FOUND]['.$current_lang.'] value:[<b>'.$dic_data[$key].'</b>] and update cache ( #cached_languages ).',$this->_debug_lng);
return $dic_data[$key];
}else{
debugAndContinue('[INFO] lng key:<b>'.$key.'</b> not found from:'.$current_module.'/'.$current_lang,$this->_debug_lng);
}
else{
debugAndContinue('[INFO] lng key:<b>'.$key.'</b> not found from:'.$current_module.'/'.$current_lang.', try now common module language.',$this->_debug_lng);
}
//Try common module :
......@@ -498,9 +512,8 @@ class crxFrameworkWebCommon {
}else{
debugAndContinue('[INFO] lng key:<b>'.$key.'</b> not found from:common/'.$current_lang,$this->_debug_lng);
}
//echo $current_lang;
//var_dump(self::$_modules_dictionnary['common'][$current_lang]);
//Try current English ( P2 ) :
$dic = new crxLanguage(FALSE);
$dic -> setCurrentLanguagesAvailableList(self::$_languages);
......@@ -687,6 +700,13 @@ class crxFrameworkWebCommon {
header('Location: '.$redirect);
}
static function sredirect($url=NULL){
if($url==NULL) $redirect=$_SERVER['HTTP_REFERER'];
else $redirect=$url;
header('Location: '.$redirect);
}
function __initUserWebInterfaceLanguage(){
......@@ -810,6 +830,8 @@ class crxFrameworkWebCommon {
){
//@APPEND CODE
$url_encodage_mode = crxFramework::getFrameworkConfigurationValue('enforceUriSecurityMode');
if($url_encodage_mode=='b64id'){
......@@ -819,17 +841,25 @@ class crxFrameworkWebCommon {
$_SESSION['cache']=NULL;
$this->__initUserWebInterfaceLanguage();
$meth=crxFramework::getFrameworkConfigurationValue('on_user_login_in_module_method');
/////////////////////////
$onloginmodule = crxFramework::getFrameworkConfigurationValue('on_user_login_in_module');
$user_define=crxFramework::getFrameworkConfigurationValue('user_can_defined_startup_module');
if($user_define==1){
$user = crxFramework::getUserInstance();
$stm = $user->getValue('start_module',crxFrameworkWebCommon::getGlobalValue('userId'));
if(isset($stm))$onloginmodule = $stm; //user can overide default start module.
}
/////////////////////////
$meth=crxFramework::getFrameworkConfigurationValue('on_user_login_in_module_method');
if($meth==null){
$call=array(
'mt' => crxFramework::getFrameworkConfigurationValue('on_user_login_in_module')
'mt' => $onloginmodule
);
}
else{
$call=array(
'mt' => crxFramework::getFrameworkConfigurationValue('on_user_login_in_module'),
'mt' => $onloginmodule,
'action' => crxFramework::getFrameworkConfigurationValue('on_user_login_in_module_method')
);
}
......@@ -873,17 +903,25 @@ class crxFrameworkWebCommon {
}
if(!crxFramework::getFrameworkObjectsOption('maintenance_mode')){
/////////////////////////
$onloginmodule = crxFramework::getFrameworkConfigurationValue('on_user_login_in_module');
$user_define=crxFramework::getFrameworkConfigurationValue('user_can_defined_startup_module');
if($user_define==1){
$user = crxFramework::getUserInstance();
$stm = $user->getValue('start_module',crxFrameworkWebCommon::getGlobalValue('userId'));
if(isset($stm))$onloginmodule = $stm; //user can overide default start module.
}
/////////////////////////
$meth=crxFramework::getFrameworkConfigurationValue('on_user_login_in_module_method');
if($meth==null){
$call=array(
'mt' => crxFramework::getFrameworkConfigurationValue('on_user_login_in_module')
'mt' => $onloginmodule
);
}
else{
$call=array(
'mt' => crxFramework::getFrameworkConfigurationValue('on_user_login_in_module'),
'mt' => $onloginmodule,
'action' => crxFramework::getFrameworkConfigurationValue('on_user_login_in_module_method')
);
}
......@@ -926,7 +964,9 @@ class crxFrameworkWebCommon {
$uri['data']=array();
if(isset($uri['action']))$uri['data']['action'] = $uri['action'];
}
if(!isset($uri['mt']))$uri['mt']='index';
//if(!crxFramework::getFrameworkConfigurationValue('maintenance_mode'))
crxFramework::setFrameworkAction(
$uri['mt'],
......
......@@ -192,7 +192,8 @@ CREATE TABLE `crx_users_donation` (
'date_register',
'user_description',
'date_visit',
'user_display_conf'
'user_display_conf',
'start_module'
);
var $_userTableDirectoryShema = array(
......@@ -540,6 +541,7 @@ $exec='curl -X POST '.$uri.' \
return array();
}
//@todo missing disable cache parameter use
function getValue($k,$user_id,$disable_cache=FALSE){
if(isset($_SESSION['user_cache_get_value'][$user_id][$k])){
return $_SESSION['user_cache_get_value'][$user_id][$k];
......@@ -652,7 +654,8 @@ $exec='curl -X POST '.$uri.' \
function checkLoginAndPassword($login,$password){
$hm=crxFramework::getFrameworkConfigurationValue('userPasswordHashMethod');
$l=false;
if($hm==null){$hm='sha256';}
$this->_dataAccess->formatSqlQuery('',$this->_table_users,'DISPLAY','',
......@@ -663,42 +666,53 @@ $exec='curl -X POST '.$uri.' \
);
$this->_dataAccess -> execSql();
$getHashMethod = $this->_dataAccess->returnLine();
$getHashMethod=explode(':',$getHashMethod['pwd_user']);
//No hash conf in password :
if(count($getHashMethod) == 1 ){
if(isset($getHashMethod['pwd_user'])){
$getHashMethod=explode(':',$getHashMethod['pwd_user']);
}
//No hash conf in password :
if(is_array($getHashMethod) && count($getHashMethod) == 1 ){
$password_test = md5($password);//old method/compatible for the moment for old profile/or non updated password.
$method = 'md5';
}
////Ex: sha256:[SUM PWD STRING]
else{
$method = $getHashMethod[0];
$password_test = $method.':'.hash($method,$password);//old method.
if(isset($getHashMethod[0])){
$method = $getHashMethod[0];
$password_test = $method.':'.hash($method,$password);//old method.
}
else{
$password_test = -1;
}
}
$this->_dataAccess->formatSqlQuery('',$this->_table_users,'DISPLAY','',
array(
'filter_key' => 'login_user',
if($password_test<>-1){
$this->_dataAccess->formatSqlQuery('',$this->_table_users,'DISPLAY','',
array(
'filter_key' => 'login_user',
'filter_key_value' => $login,
'AND_filter_key' => 'pwd_user',
'AND_filter_value' => $password_test,
)
);
$this->_dataAccess -> execSql();
$m_ = $l = $this->_dataAccess->returnLine();
);
$this->_dataAccess -> execSql();
$m_ = $l = $this->_dataAccess->returnLine();
}
$this->__loadCrxSysLog();
$ip = $this->getIP();
$m="succefully open web session.";
if(!$l){
if(!isset($l) || !$l){
$m="failed to open web session.";
}
if(isset($m_['id_user']) && $l['account_enable']<>1){
$m="account not enable.";
$m="account not enable.";
$l=FALSE;
}
$call='';
$call='';
$uid=-1;
if(isset($m_['login_user'])) $call = $m_['login_user'];
if(isset($m_['callsign_main'])) $call .= '/'.$m_['callsign_main'];
......
......@@ -188,7 +188,6 @@ class genericOb{
$this->itemsProperties=array();
}
function retreive($fields=array(),$use_field='',$return_method='BOTH'){
......
......@@ -3,7 +3,7 @@
* CRX-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 28/05/2019
* @revision 15/05/2019
* @lib languages
* @version 1.2.2-1
*/
......@@ -125,19 +125,25 @@ class crxLanguage extends crxFramework{
}
function loadDictionnary($disable_cache=0,$debug=0){
function loadDictionnary($disable_cache=0,$debug=0,$force_module_dir=''){
$d=0;
if($force_module_dir=='common'){$d=1;}
if(!isset($this->_current_module_information['module_directory']))return;
$module_dir_name=$this->_current_module_information['module_directory'];
$this->_debug_lng=$debug;
if($disable_cache == 0 && crxFramework::getFrameworkObjectsOption('caching_ini_to_php')){
//debugAndContinue('[INFO] try to load php file => '.$path_cache_lang_include_php_file,$this->_debug_lng);
//Try to load compiled version :
$path_cache_lang_include_php_file = _CACHE_PXML_FOLDER_.$this->_current_module_information['module_directory']._SD_.$this->_currentLanguageInUse._SD_.'lang.php';
$path_cache_lang_include_php_file = _CACHE_PXML_FOLDER_.$module_dir_name._SD_.$this->_currentLanguageInUse._SD_.'lang.php';
debugAndContinue('[INFO] try to load php file => '.$path_cache_lang_include_php_file,$this->_debug_lng);
$lang = $this->_currentLanguageInUse;
if(file_exists($path_cache_lang_include_php_file)){
......@@ -145,12 +151,23 @@ class crxLanguage extends crxFramework{
debugAndContinue('[INFO] caching_ini_to_php => 1',DEBUG_LNG_LAYER);
debugAndContinue('[INFO] Loading php lng file : '.$path_cache_lang_include_php_file.' lang ('.$this->_currentLanguageInUse.')',DEBUG_LNG_LAYER);
require($path_cache_lang_include_php_file);
require($path_cache_lang_include_php_file);
//require_once doesnt work now.
/*if($this->_debug_lng){
var_dump($path_cache_lang_include_php_file);
var_dump($this->_dic);
echo time();
}*/
if( empty($this->_dic) || !($this->_dic)){
debugAndContinue('[INFO] Language values not found lang => '.$lang.', module=>'.$this->_current_module_information['module_directory'],DEBUG_LNG_LAYER);
}else{
debugAndContinue('[INFO] Language ('.count($this->_dic).')values found, lang => '.$lang.', module=>'.$this->_current_module_information['module_directory'],DEBUG_LNG_LAYER);
debugAndContinue('[INFO] Language values not found lang => '.$lang.', module=>'.$module_dir_name,DEBUG_LNG_LAYER);
}
else{
debugAndContinue('[INFO] Language ('.count($this->_dic).')values found, lang => '.$lang.', module=>'.$module_dir_name,DEBUG_LNG_LAYER);
}
return $this->_dic;
}
else{
......@@ -159,7 +176,7 @@ class crxLanguage extends crxFramework{
if(file_exists($path_cache_lang_include_php_file)){
require($path_cache_lang_include_php_file);
if( empty($this->_dic) || !($this->_dic)){
debugAndContinue('[INFO] Language values not found lang => '.$lang.', module=>'.$this->_current_module_information['module_directory'],$this->_debug_lng);
debugAndContinue('[INFO] Language values not found lang => '.$lang.', module=>'.$module_dir_name,$this->_debug_lng);
}else{
debugAndContinue('[INFO] Successfully load PHP file:'.$path_cache_lang_include_php_file,$this->_debug_lng);
}
......
<?php
//////////////////////////////////////////////////////////
//Interface class to use dxClusterSpot HAM or 11M.
//u:122019
//up:15/05/2020
//////////////////////////////////////////////////////////
namespace crx;
class dxClusterSpot {
var $__mode = '';
var $c_db = '';
var $debug = false;
function setDebug($d){
$this->debug=$d;
$this->d=$d;
}
function getDxClusterStatsContinentDxSpotRepartition($db='spot',$time_select=array('start','end'),$user_continent='EU',$nb_total_spots=0,$user_band_selected='ALL',$debug=0){
//HAM Radio mode :
if($this->__mode == 'HAM'){
......@@ -36,9 +31,7 @@ class dxClusterSpot {
}
$sp->d=$this->d;
$sp->setTableSpotName($db);
$sp->initCqZoneByContinent();
return $sp->getDxClusterStatsContinentDxSpotRepartition(
......@@ -65,15 +58,17 @@ class dxClusterSpot {
function getSpotDataKey($mode){
$spot_data_keys['HAM']['spotter']='spotter';
$spot_data_keys['HAM']['spotcall']='spotcall';
$spot_data_keys['11M']['spotter']='callsign_sender';
$spot_data_keys['11M']['spotcall']='callsign_dx';
$spot_data_keys['HAM']['spotter'] = 'spotter';
$spot_data_keys['HAM']['spotcall'] = 'spotcall';
$spot_data_keys['HAM']['freq'] = 'freq';
$spot_data_keys['HAM']['comment'] = 'comment';
$spot_data_keys['HAM']['time'] = 'time';
$spot_data_keys['11M']['spotter'] = 'callsign_sender';
$spot_data_keys['11M']['spotcall'] = 'callsign_dx';
$spot_data_keys['11M']['freq'] = 'frequency';
$spot_data_keys['11M']['comment'] = 'comment';
$spot_data_keys['11M']['time'] = 'date_spot';
return $spot_data_keys[$mode];
......@@ -180,8 +175,9 @@ class dxClusterSpot {
$s=new dxClusterSpot11m();
$s->setDbHandler($this->c_db);
$s->setDebug($this->debug);
$filters['tbl_crx_spots'] = 'crx_cluster_spots';
$filters['filters_order_by'] = 'date_spot';
$filters['tbl_crx_spots'] = 'crx_cluster_spots';
$filters['filters_order_by'] = 'date_spot';
$filters['bands_filtering_selected'] = array(0=>11,1=>'PMR');
}
$s->setCallsignSender($usr['callsign_main']);
......
<?php
/**
* @date 01/01/2005
* @revision 08/04/2020
* @revision 15/05/2020
* @lib radioamator
* @copyright see header
*/
......@@ -458,7 +458,11 @@ class dxClusterSpot11m extends abstractDxClusterSpot{
$bands=0;
foreach($this->bands_filtering_selected as $k=>$v){
if($v==1)$sql_set_filter .= ' band = "'.$k.'" ';
if($k=='11m')$k='11';
//if($k=='11m')$k='PMR';
if($v==1)$sql_set_filter .= ' `band` = "'.$k.'" ';
if($i>=0 && $i<=(count($this->bands_filtering_selected)-2)){
$sql_set_filter .= 'OR';