...
 
Commits (2)
------------------------
CRX FRAMEWORK
Date: 01/2008
Current version: 3.0.2 - 4
Current version: 3.0 ( 6 )
------------------------
Update 04/03/2020
------------------------
- Correct bug's into class.crx.geo.sun.php and dxClusterSpotHam.php.
------------------------
Update 25-28/02/2020
------------------------
- Improve module configuration cache management (now dynamic).
- Also improve global modules definition (add dynamic caching).
- Add new framework loader options :
on_user_login_in_module_method,
create_account_link_enable,
load_password_link_enable.
------------------------
Update 20/02/2020
......
......@@ -47,6 +47,12 @@ extends crxCore{
}
function getModuleSchema(){
return $this->_moduleShema;
}
public $_charSet = 'utf8';
var $_moduleShema = array(
......@@ -192,6 +198,7 @@ extends crxCore{
if(is_object(self::$_GOB_db)){
if(self::$_frameworkConfiguration['load_user_module']){
self::$_userItemInstance = new crxUser('main instance');
self::$_userItemInstance -> setDataInstance(self::$_GOB_db);
self::$_userItemInstance -> setDataKey('id_user');
......@@ -205,35 +212,39 @@ extends crxCore{
}
}
}
}else{
}
else{
//Missing DATABASE instance to load user part :
if(self::$_frameworkConfiguration['load_user_module']){
//throw new crxException(' Missing db instance !') ;
//not possible with SETUP module.
}
}
}
function createProcessAndRun(){
function createProcessAndRun($frm_conf){
////dbg('crxFramework::createProcessAndRun() => _FRAMEWORK_PROCESS_TYPE_ = ' . _FRAMEWORK_PROCESS_TYPE_);
switch( _FRAMEWORK_PROCESS_TYPE_ ){
case 'webapp':
$this->__createFrameworkProcessHttp();
$this->__createFrameworkProcessHttp($frm_conf);
break;
case 'webserviceCrx':
$this->__createFrameworkProcessHttpWebserviceCrx();
$this->__createFrameworkProcessHttpWebserviceCrx($frm_conf);
break;
case 'ajaxapp':
$this->__createFrameworkProcessHttpAjax();
$this->__createFrameworkProcessHttpAjax($frm_conf);
break;
case 'scriptap':
$this->__createFrameworkProcessScript();
$this->__createFrameworkProcessScript($frm_conf);
break;
}
......@@ -355,7 +366,7 @@ extends crxCore{
*
*/
//HTTP - CRX WEBSERVICE Call :
function __createFrameworkProcessHttpWebserviceCrx(){
function __createFrameworkProcessHttpWebserviceCrx($frm_conf){
require_once('crxFrameworkWebCommon.php');
require_once('crxFrameworkWebserviceCrx.php');
self::$_frameworkProcess=new crxFrameworkWebserviceCrx();
......@@ -367,7 +378,7 @@ extends crxCore{
}
//HTTP
function __createFrameworkProcessHttp(){
function __createFrameworkProcessHttp($frm_conf){
require_once('crxFrameworkWebCommon.php');
......@@ -378,13 +389,15 @@ extends crxCore{
self::$_frameworkProcess=new crxFrameworkWeb();
self::$_frameworkProcess->initContext();
$this->_env = self::$_frameworkProcess->listenAction();
if(!isset($frm_conf['maintenance_mode']))$frm_conf['maintenance_mode']=false;
$this->_env = self::$_frameworkProcess->listenAction(array('maintenance_mode'=>$frm_conf['maintenance_mode']));
}
//HTTP AJAX (didn't display with TEMPLATE XHTML
function __createFrameworkProcessHttpAjax(){
function __createFrameworkProcessHttpAjax($frm_conf){
require_once('crxFrameworkWebCommon.php');
......@@ -400,7 +413,7 @@ extends crxCore{
}
//Simple script / process PHP display NOTHING
function __createFrameworkProcessScript(){
function __createFrameworkProcessScript($frm_conf){
require_once('crxFrameworkScript.php');
......@@ -445,8 +458,11 @@ extends crxCore{
//////////////////////////////////////////
static function setFrameworkAction($module,$parameters=array()){
self::$_process_module_to_load = $module;
self::$_process_options_for_module_to_load = $parameters;
}
static function setFrameworkCurrentModule($mod){
......@@ -484,6 +500,12 @@ extends crxCore{
return self::$_frameworkConfiguration[$k];
}
static public function setFrameworkConfigurationValue($k,$v){
self::$_frameworkConfiguration[$k]=$v;
}
function getLng($k,$mod=null){
return $this->lng($k,$mod=null);
......@@ -519,6 +541,8 @@ extends crxCore{
$module = crxFramework::getFrameworkCurrentModule();
}
$out = self::$_frameworkProcess->lng($key,$module,$lng_selected);
/*$_SESSION['lngc'][$lng_selected][$key]=$out;*/
......@@ -725,19 +749,13 @@ extends crxCore{
$this->_mods = $this->getModulesInfo(false,'module_name');
$mod = $this->_mods[$module_name];
$path = _APPLI_MAIN_MODULES_PATH_ . $mod['module_directory'].'/'.$mod['module_user_controler']._PHP_F_EX_;
//require_once($path);
if(file_exists($path)){
require_once($path);
}else{
throw new crxException('@');
}
else{
throw new crxException('Missing module controler : '.$mod['module_directory']);
}
return $mod['module_user_controler'];
}
......
......@@ -3,9 +3,9 @@
* CRX-PHP-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 03/04/2019
* @revision 05/03/2020
* @package core
* @version 3.1
* @version 3.2 ( 1 )
* @web http://git.crx.cloud/crx-php/crx-framework
*/
......@@ -85,7 +85,10 @@ class crxFrameworkModuleLoader{
}
static $runModuleProcess = array();
static function run(
$module_to_load,
......@@ -97,7 +100,13 @@ class crxFrameworkModuleLoader{
$disable_acl_control=TRUE
){
/*if(isset(self::$runModuleProcess[$module_to_load]) && self::$runModuleProcess[$module_to_load]==1){
return;
}
//self::$runModuleProcess[$module_to_load] = 1; // Run module only one time.
*/
//dbg('crxFrameworkModuleLoader::run => '.$module_to_load);
//dbg('options :');
//dbg($_process_options_for_module_to_load);
......@@ -125,6 +134,7 @@ class crxFrameworkModuleLoader{
$_frameworkConfiguration['load_common_module'] &&
$disabled_common_module_loading == FALSE
){
//debugAndContinue('[INFO] crxFrameworkModuleLoader::run => => '.dumper($module_to_load),DEBUG_FRMW_MODULE_LOADER_LAYER);
self::runModule(
$_frameworkConfiguration['common_module_name'],
......@@ -137,7 +147,7 @@ class crxFrameworkModuleLoader{
//Default module is not set and nothing is send what can we do ?
if(!isset($module_info[$module_to_load])){
#if(DEBUG_FRMW_MODULE_LOADER_LAYER){debugAndContinue(dumper($module_info));}
debugAndContinue('[ERROR] Unknow module ('.$module_to_load.'), please check modules.xml registry configuration.',DEBUG_FRMW_MODULE_LOADER_LAYER);
......@@ -178,11 +188,8 @@ class crxFrameworkModuleLoader{
}
#var_dump($module_info[$module_to_load]);
if( $module_info[$module_to_load]['module_is_private']==1 ){
//Private module :
if( isset($module_info[$module_to_load]) && $module_info[$module_to_load]['module_is_private']==1 ){
$start=0;
$bmode=crxBootLoader::getBootMode();
if($bmode=='bootScript'){$start=1;}
......@@ -200,7 +207,15 @@ class crxFrameworkModuleLoader{
}
//Public module :
else{
//Try to load unknow public module :
if(!isset($module_info[$module_to_load])){
return crxFramework::execCrx()->onModuleLoadingError(
$_frameworkConfiguration['if_access_to_unknow_module'],
'view_404'
);
}
//All is ok we can run it :
//echo($module_to_load)._BR_;
self::runModule(
$module_to_load,
......@@ -209,9 +224,9 @@ class crxFrameworkModuleLoader{
$controller_type,
$disable_acl_control
);
}
$framework_conf_display_html_modules_output = crxFramework::getFrameworkConfigurationValue('display_modules_output');
if(!$framework_conf_display_html_modules_output)
return;
......@@ -316,7 +331,17 @@ class crxFrameworkModuleLoader{
$controller_type='module_user_controler',
$disable_acl_control=TRUE
){
if($moduleInfo['module_is_enable']<>1){
$inf=self::getModulesInfo(
1,
'module_name'
);
//var_dump($moduleInfo);
$module_name='error';
$moduleInfo=$inf['error'];
$process_options_for_module_to_load['action']='showDisableModuleWarning';
}
self::$process_options_for_module_to_load['data'] = $process_options_for_module_to_load;
self::$process_options_for_module_to_load = $process_options_for_module_to_load;
......@@ -324,8 +349,7 @@ class crxFrameworkModuleLoader{
//print 'runModule : '.$module_name._BR_;
///print_r($moduleInfo)._BR_;
$path_user_controler = _APPLI_MAIN_MODULES_PATH_ . $moduleInfo['module_directory'] . _SD_ . $moduleInfo[$controller_type] . _PHP_F_EX_;
//var_dump($moduleInfo);
//var_dump($path_user_controler);
......@@ -424,7 +448,7 @@ class crxFrameworkModuleLoader{
try{
//var_dump($_moduleInstance ->_currentModuleConfiguration);
//var_dump(self::$process_options_for_module_to_load);
$_moduleInstance -> runMain(
self::$process_options_for_module_to_load
);
......@@ -537,19 +561,19 @@ class crxFrameworkModuleLoader{
$u=crxFramework::getUserInstance();
$u->currentModuleGid=self::$_currentModuleGid;
$acl=$u->getUserRightsOnCurrentModule();
$module_instance->ACL = $acl;
if($u==null){
//throw new crxException('[ERROR] Missing "users" module. ');
$module_instance->ACL=array();
}
else{
$u->currentModuleGid=self::$_currentModuleGid;
$acl=$u->getUserRightsOnCurrentModule();
$module_instance->ACL = $acl;
}
}
else{
$module_instance->ACL=array();
}
self::$_userPreferedLanguageInterface = 'fr';
......
<?php
namespace crx;
class crxFrameworkWebserviceCrx extends crxFrameworkWebCommon {
//Overwrite parent (not use in webservice mode)
......
......@@ -3,10 +3,10 @@
* CRX-PHP-FRAMEWORK http://git.crx.cloud/crx-php/crx-framework
* @author Bastien Barbe
* @date 01/01/2005
* @revision 20/02/2020
* @revision 02/03/2020
* @package core/crxUsers , frameworkCrxUser.
* @copyright see header
* @version 1.8.3 - 3
* @version 1.8 ( 4 )
*/
namespace crx;
......@@ -225,21 +225,17 @@ CREATE TABLE `crx_users_donation` (
'root'
);
var $_group_users_root_name = 'G_ROOT_USERS';
var $_group_users_root_name = 'G_ROOT_USERS';
var $_table_users_donation = 'users_donation';
var $_table_users = 'users';
var $_table_users_sms_request = 'users_sms_request';
var $_table_users = 'users';
var $_table_users_sms_request = 'users_sms_request';
var $_table_groups = 'groups';
var $_table_groups = 'groups';
var $_table_users_login_activity = 'users_login_activity';
var $_table_users_login_activity = 'users_login_activity';
var $_table_groups_members = 'groups_members';
......@@ -416,6 +412,24 @@ $exec='curl -X POST '.$uri.' \
return $exec;
}
function __getUserGroupsMembers($uid){
$u=crxFramework::getUserInstance();
$grp=$u->getUserGroupsMembers($uid);
$groups=array();
if(is_array($grp))
foreach($grp as $k=>$v){
$groups[$v['name']]=1;
}
return $groups;
}
function __initUserGroupsMembers(){
if(empty($_SESSION['userRight']['donator']) || empty($_SESSION['userRight']['chat'])){
......@@ -518,23 +532,18 @@ $exec='curl -X POST '.$uri.' \
**/
function getLastLogin($uid){
$q='
SELECT MAX(`login_date`), ip_user
FROM `crx_users_login_activity`, crx_users
WHERE crx_users_login_activity.id_user = '.(int)$uid.'
';
$q='SELECT MAX(`login_date`), ip_user FROM `crx_users_login_activity`, crx_users WHERE crx_users_login_activity.id_user = '.(int)$uid.'';
//$q='SELECT `login_date`, `ip_user` FROM `crx_users_login_activity`, crx_users WHERE crx_users_login_activity.id_user = '.(int)$uid.' LIMIT 1;';
$this->_dataAccess -> execSql($q);
$r=$this->_dataAccess->returnLine();
return $r[0];
if(isset($r[0]))return $r[0];
return array();
}
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];
}
//Mod 5/2/2013: add $k in first param :
$this->_dataAccess->formatSqlQuery($k,$this->_table_users,'DISPLAY','',
array(
......@@ -542,18 +551,12 @@ $exec='curl -X POST '.$uri.' \
'filter_key_value' => $user_id
)
);
#$this->_dataAccess -> printQuery();
$this->_dataAccess -> execSql();
$r = $this->_dataAccess->returnLine();
if($user_id<>null){
$_SESSION['user_cache_get_value'][$user_id][$k]=$r[$k];
return $r[$k];
}
}
......@@ -1683,9 +1686,12 @@ $exec='curl -X POST '.$uri.' \
$userId=$this->_dataAccess->returnLine();
}
if($userId['id_user']){
$dxclustermod='dxClusterWeb';
if(DXM=='11M'){$dxclustermod='dxClusterWebCb';}
$url=$this->prepareUrl(
'dxClusterWeb',
$dxclustermod,
array('action'=>'ajaxShowUserProfile','uid'=>$userId['id_user'],'ajax_mode'=>'0'),
FALSE,
FALSE
......
......@@ -20,10 +20,10 @@
/**
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 01/01/2005
* @revision 31/03/2019
* @revision 25/02/2020
* @crx-core classes
* @copyright see header
* @version 1.2.2
* @version 1.2.2-1
*/
namespace crx;
......@@ -155,18 +155,25 @@ class crxCore{
private function _genNSphpCache($ns_values){
touch($this->_nsdata_caching_path);
$cache_str=null;
$cache_str.='<?php'."\n";
foreach($ns_values as $key=>$ns){
foreach($ns as $km=>$vm){
foreach($vm as $kmm => $vmm){
$cache_str.='$cache[\''.$key.'\'][\''.$km.'\'][\''.$kmm.'\']="'.$vmm.'";'.CRLF;
}
}
}
$cache_str.='?>';
file_put_contents($this->_nsdata_caching_path,$cache_str);
//create cache dir if missing :
if(!is_dir(_CACHE_PXML_FOLDER_)){
@mkdir(_CACHE_PXML_FOLDER_);
}
touch($this->_nsdata_caching_path);
$cache_str=null;
$cache_str.='<?php'."\n";
foreach($ns_values as $key=>$ns){
foreach($ns as $km=>$vm){
foreach($vm as $kmm => $vmm){
$cache_str.='$cache[\''.$key.'\'][\''.$km.'\'][\''.$kmm.'\']="'.$vmm.'";'.CRLF;
}
}
}
$cache_str.='?>';
file_put_contents($this->_nsdata_caching_path,$cache_str);
}
public function getNameSpaceData($xml_dir_namespace,$key_namespace){
......
......@@ -5,15 +5,17 @@
*************************************************************************************
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 01/01/2005
* @revision 09122019
* @revision 06032020
* @crx-core classes
* @copyright see header
* @version 1.2.1-1
* @version 1.2 ( 2 )
*/
namespace crx;
class crxXml {
var $debug = false;
//Xml cache use : html\__cache\interface to store parsed xml file
var $_enable_xml_cache = false;
......@@ -47,6 +49,8 @@ class crxXml {
//print "crxXml()"._BR_;
$this->StartXml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
$this->_itemId=0;
$this->MSTree = "<channel>";
......@@ -160,6 +164,13 @@ class crxXml {
$itemType=$this->xmlItemType;//defineItemName( )
$ress_xml = simplexml_load_file($this->_pathOfXmlFile);
//var_dump($this->_pathOfXmlFile);die();
if($ress_xml==false){
$this->_finalItem=array();
return $this->_finalItem;
}
$p_cnt = count($ress_xml->$itemType);
for($i = 0; $i < $p_cnt; $i++) {
$item=$ress_xml->$itemType[$i];
......@@ -368,6 +379,11 @@ class crxXml {
$this->FileIsXml = false;
$this->FileIsRss = false;
if($mode=='xml'){
$this->FileIsXml = true;
}
if($this->FileIsXml){
$this->FileContent = $this->StartXml;
}
......@@ -390,24 +406,14 @@ class crxXml {
}
function addItem(){
function addItem($item){
$j=0;
$item="\r\n".$this->MSItem."\n";//Start Item
$c = count($this->_tabFieldConstructor);
while($j < $c){
$str = (string)func_get_arg($j);
$item_xml_key = (string)$this->_tabFieldConstructor[$j];
$item.="\t".'<'.$item_xml_key.'>'.$str.'</'.$item_xml_key.'>'."\n";
$j++;
$xml="\r\n".$this->MSItem."\n";//Start Item
foreach($this->_tabFieldConstructor as $k=>$item_xml_key){
$xml.="\t".'<'.$item_xml_key.'>'.$item[$item_xml_key].'</'.$item_xml_key.'>'."\n";
}
$item.=$this->MEItem;
$this->FileContent .= $item;
$xml.=$this->MEItem;
$this->FileContent .= $xml;
}
function saveFile($file=NULL){
......@@ -415,14 +421,12 @@ class crxXml {
$this->EOF();
if(!$this->gunzip){
///$Filedescriptor = fopen($this->_pathOfXmlFile, "w");
if($this->debug)
print $this->_pathOfXmlFile.'<br />';
$fp = fopen($this->_pathOfXmlFile, "wb");
fputs($fp,$this->FileContent);
fclose($fp);
return crxFile::setFileContent($this->_pathOfXmlFile,$this->FileContent);
}
else{
......@@ -642,7 +646,6 @@ function loadFile(){
/*
if($this->Cache==TRUE){
if($_SESSION["cache"]){
session_start();
$this->_aFileXmlLines = unserialize($_SESSION["cache"]);
}
else{
......@@ -651,7 +654,6 @@ function loadFile(){
}
@fclose($fd);
$this->_aFileXmlLines = file($this->_pathOfXmlFile);
session_start();
session_register("cache");
$_SESSION["cache"] = serialize( $this->_aFileXmlLines );
}
......
......@@ -4,9 +4,9 @@
* @author Bastien Barbe
* @date 01/01/2005
* @revision 04042019
* @revision 25/02/2020
* @crx-core classes
* @version 1.2
* @version 1.2-1
*/
namespace crx;
......@@ -45,8 +45,12 @@ class crxException extends \Exception {
// mode : html / console :
$it=new crxHtmlInterface();
$file_name=str_replace(' ','',$this->getFile());
$ref="#";
if(isset($_SERVER['HTTP_REFERER'])){$ref=$_SERVER['HTTP_REFERER'];}
if($mode=="html"){
$str = "<b>Exeption has been generated : </b>&nbsp;&nbsp;&nbsp;&nbsp;".$it->linkHtml(' return ',$_SERVER['HTTP_REFERER'])._BR_;
$str = "<b>Exeption has been generated : </b>&nbsp;&nbsp;&nbsp;&nbsp;".$it->linkHtml(' return ',$ref)._BR_;
$str .= "<u>Message : </u>" . $this->getMessage() . _BR_;
$str .= "File name : " . $file_name . _BR_;
$str .= "Line number : " . $this->getLine() . _BR_;
......@@ -58,7 +62,7 @@ class crxException extends \Exception {
$str .= '<tr><th>File</th><th>Line</th><th>Args</th></tr>';
foreach($t as $k=>$bt){
ob_start();
var_dump($bt['args']);
if(isset($bt['args']))var_dump($bt['args']);
$bt['args']=ob_get_contents();
ob_end_clean();
//@ob_flush();
......
......@@ -899,21 +899,17 @@ class crxHtmlInterface extends crxFramework{
$this->ObjInt .= '<div id="'.$bloc_id.'">'."\n";
}
//options ex: 'target="_blank"'
function linkHtml($text,$link,$options=NULL){
if($options)$opt=$options;
else $opt=NULL;
if(isset($opt['acro_message'])){
$text = '<acronym title="'.$opt['acro_message'].'">'.$text.'</acronym>';
$opt = null;
}
return '<a href="'.$link.'"'.$opt.'>'.$text.'</a>';
}
function pictureHtml($path,$link=NULL,$options=NULL){
if($link<>NULL)
......
......@@ -3,7 +3,7 @@
* CRX-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 07/06/2019
* @revision 28/02/2020
* @crx-core classes
* @version 2.2.1-2
*/
......@@ -11,6 +11,7 @@ namespace crx;
class crxTemplateXhtmlWrapper extends crxFramework{
//see installer/app-js/minjs.conf.php from common cms module.
var $_js_gfiles=array(
'lib_ajax.js',
'lib_browser.js',
......@@ -75,6 +76,26 @@ class crxTemplateXhtmlWrapper extends crxFramework{
);
}
static $_jsMin = array();
static function jsFilesGroupFromModule($module_name,$rv=1){
$bn="\n";
$cp=_APPLI_MAIN_MODULES_PATH_.$module_name.'/installer/app-js/minjs.conf.php';
if(!isset(self::$_jsMin[$module_name])){
require_once($cp);
self::$_jsMin[$module_name]=$js;
}
else{$js=self::$_jsMin[$module_name];}
if(!isset($js['js_file_list']) || empty($js['js_file_list'])){
return false;
}
$devroot_cmt='/app-php/'.$module_name.'/installer/app-js/';
$includehtmljs='';
foreach($js['js_file_list'] as $kfs=>$vfl){
$includehtmljs.='<script src="'.$devroot_cmt.$vfl.'?r='.$rv.'" type="text/javascript"></script>'.$bn.'';
}
return $includehtmljs;
}
function _genHtmlBlocSearch(){
$uri=$this->prepareUrl(
......@@ -185,7 +206,7 @@ class crxTemplateXhtmlWrapper extends crxFramework{
}
function defineCssFile2Minify($final_css,$css_input_file){
if(!DEV_MODE && !isset($_GET['rebuild_css'])){return;}
......@@ -268,10 +289,8 @@ class crxTemplateXhtmlWrapper extends crxFramework{
self::__defineCssToInclude(array(300=>_APPLI_CSS_HTML_PATH_ABS_ . $this->_userPreferences['website_skin'] . '/kickstart-buttons.css'));
self::__defineCssToInclude(array(400=>_APPLI_CSS_HTML_PATH_ABS_ . 'global.css'));
}else{
}
else{
self::__defineCssToInclude(array(100=>_APPLI_CSS_HTML_PATH_ABS_ . $this->_userPreferences['website_skin'].'/'.$style.'-main-min.css'));
self::__defineCssToInclude(array(200=>_APPLI_CSS_HTML_PATH_ABS_ . $this->_userPreferences['website_skin'].'/kickstart-min.css'));
......@@ -344,6 +363,51 @@ class crxTemplateXhtmlWrapper extends crxFramework{
}
function javaScript2MinifyFromAdmin($module_name,$final_js,$js_file_list){
$this->error_files = array();
$debug = 0;
$root_js_compress = _APPLI_MAIN_PATH_.'app-js/';
$root_js = _APPLI_MAIN_PATH_.'app-js/'.$module_name.'/';
if(!file_exists($root_js_compress.$final_js)){
$toupdate = FALSE;
$ftime = 0;
if(file_exists($root_js_compress.$final_js)){
$ftime=filemtime($root_js_compress.$final_js);
}else{
$toupdate = TRUE;
if($debug)echo "file not exists: $root_js_compress$final_js"._BR_;
}
/*foreach($js_file_list as $k=>$f){
if(@filemtime($root_js.$f) > $ftime){
$toupdate=TRUE;
if($debug)echo "file time: $root_js$f / $ftime"._BR_;
}
}*/
$toupdate = TRUE; //forceit here ( call from crxInstaller lib ).
if($debug)echo "FORCE_REFRESH_JS_CACHE"._BR_;
if($toupdate){
if($debug)echo "Update content: ".$root_js_compress.$final_js._BR_;
if(file_exists($root_js_compress.$final_js)){
unlink($root_js_compress.$final_js);
}
$final_content='';
foreach($js_file_list as $k=>$f){
$c=@file_get_contents($root_js.$f);
if($c==false){
$this->error_files[]=$root_js.$f;
}
$output = Minifier::minify($c);
$date = 'g:'.gmdate('d/m/Y|H:i:s');
$file_header="\r".'/* '.$date.' - '.$f.' */'."\r";
if(file_exists($root_js_compress.$final_js)){
$final_content=file_get_contents($root_js_compress.$final_js);
}
$f=file_put_contents($root_js_compress.$final_js,$final_content.$file_header.$output);
}
}
}
}
function defineJavaScript2Minify($module_name,$final_js,$js_file_list){
if(!DEV_MODE && !$_GET['rebuild_js']){return;}
......@@ -382,7 +446,7 @@ class crxTemplateXhtmlWrapper extends crxFramework{
foreach($js_file_list as $k=>$f){
$c=file_get_contents($root_js.$f);
$output = Minifier::minify($c);
$date = 'g:'.date('d/m/Y|H:i:s');
$date = 'g:'.gmdate('d/m/Y|H:i:s');
$file_header="\r".'/* '.$date.' - '.$f.' */'."\r";
if(file_exists($root_js_compress.$final_js)){
$final_content=file_get_contents($root_js_compress.$final_js);
......@@ -403,10 +467,12 @@ class crxTemplateXhtmlWrapper extends crxFramework{
return;
}
if(DEV_MODE){
$final_js='crx.g.common.js';
$this->defineJavaScript2Minify('common',$final_js,$this->_js_gfiles);
}
//@TODO1
//if(DEV_MODE){
// $final_js='crx.g.common.js';
// $this->defineJavaScript2Minify('common',$final_js,$this->_js_gfiles);
//}
//$module_js_def
$i=$this->__getJsToInclude();
......@@ -417,22 +483,22 @@ class crxTemplateXhtmlWrapper extends crxFramework{
}
}
$jquery = '<script type="text/javascript" src="app-js/jqueryui/jquery-1.11.1.min.js"></script>';
//old version was 2.1.5 now move to 2.1.7:
//$fancybox='<link rel="stylesheet" type="text/css" href="/app-js/fancybox/current/jquery.fancybox.min.css?v=3.5.7" media="screen" />'."\n";
//$fancybox.='<script src="/app-js/fancybox/current/jquery.fancybox.min.js?v=3.5.7"></script>'."\n";
//prod:
$jquery = '<script type="text/javascript" src="app-js/common/jqueryui/jquery-1.11.1.min.js"></script>';
$p='/app-js/fancybox/current/source';
//test:
//$jquery = '<script type="text/javascript" src="app-js/common/jqueryui/jquery-1.12.4.min.js"></script>';
//$jquery = '<script type="text/javascript" src="app-js/common/jqueryui/jquery-1.2.3.min.js"></script>';
$fancybox='';
$p='/app-js/common/fancybox/current/source';
$fancybox="\n";
$fancybox.='<link rel="stylesheet" href="'.$p.'/jquery.fancybox.css?v=2.1.7" type="text/css" media="screen" />'."\n";
$fancybox.='<script src="'.$p.'/jquery.fancybox.pack.js?v=2.1.7"></script>'."\n";
$fancybox.='<link rel="stylesheet" href="'.$p.'/helpers/jquery.fancybox-buttons.css?v=1.0.5" type="text/css" media="screen" />'."\n";
$fancybox.='<link rel="stylesheet" href="'.$p.'/helpers/jquery.fancybox-thumbs.css?v=1.0.7" type="text/css" media="screen" />'."\n";
$fancybox.='<script type="text/javascript" src="'.$p.'/jquery.fancybox.pack.js?v=2.1.7"></script>'."\n";
$fancybox.='<script type="text/javascript" src="'.$p.'/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>'."\n";
$fancybox.='<script type="text/javascript" src="'.$p.'/helpers/jquery.fancybox-media.js?v=1.0.6"></script>'."\n";
$fancybox.='<link rel="stylesheet" href="'.$p.'/helpers/jquery.fancybox-thumbs.css?v=1.0.7" type="text/css" media="screen" />'."\n";
$fancybox.='<script type="text/javascript" src="'.$p.'/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>'."\n";
if(self::$__js_disable_default_jquery){
......@@ -441,21 +507,28 @@ class crxTemplateXhtmlWrapper extends crxFramework{
$n="\n";
$global_js_lib='<script type="text/javascript" src="app-js/crx.g.common.js"></script>';
if(DEV_MODE){
$global_js_lib='';
$global_js_lib=self::jsFilesGroupFromModule('common',time());
/*$global_js_lib='';
foreach($this->_js_gfiles as $k=>$v){
$global_js_lib.='<script type="text/javascript" src="app-js/common/'.$v.'"></script>'."\n";
}
}*/
}
$this->_tplMainInterface -> assign('JAVA_SCRIPT','
<!-- framework web js def -->
'.$global_js_lib.$n.'
<!-- jquery and tools def -->
'.$jquery.' '.$n.'
'.$fancybox.'
<script type="text/javascript" src="app-js/html5/kickstart-min.js"></script>
<!-- framework web js def -->
'.$global_js_lib.$n.'
<script type="text/javascript" src="app-js/common/html5/kickstart-min.js"></script>
<!-- module js def -->
'.$module_js_def.' '.$n.'
');
......@@ -637,14 +710,20 @@ class crxTemplateXhtmlWrapper extends crxFramework{
'/[\r\n]+([\t ]?[\r\n]+)+/s' => "\n",
//BUG
//retire les espaces
//retire les espaces ??
//@remove empty lines (between HTML tags); cannot remove just any line-end characters because in inline JS they can matter!
//'/\>[\r\n\t ]+\</s' => '><'
//'/\>[\r\n\t ]+\</s' => '><',
//BUG
//remove "empty" lines containing only JS's block end character; join with next line (e.g. "}\n}\n</script>" --> "}}</script>"
//'/}[\r\n\t ]+/s' => '}',
//'/}[\r\n\t ]+,[\r\n\t ]+/s' => '},'
//'/}[\r\n\t ]+,[\r\n\t ]+/s' => '},',
//remove new-line after JS's function or condition start; join with next line
'/\)[\r\n\t ]?{[\r\n\t ]+/s' => '){',
......
......@@ -7,6 +7,9 @@
* @copyright see header
* @version 1.1.20080203
*/
namespace crx;
class crxApplication
extends crxDataXml{
......@@ -68,13 +71,6 @@ extends crxDataXml{
$values['modules'] = $modules;
$values['libs'] = $libs;
$this->_applications[$pk_key_name]=$values;
}
......@@ -88,4 +84,4 @@ extends crxDataXml{
}
?>
\ No newline at end of file
?>
<?php
class crxPackage{
namespace crx;
class crxPackage{
function getUpgrade($p,$force=false){
......@@ -329,4 +331,4 @@ $conf_package=array(
}
?>
\ No newline at end of file
?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<librairie>
<version>0.1</version>
<description>This librairy provide crxPackage(package management via ssh) and crxApplication witch is app definition via applications.xml.</description>
<classes>
<class>
<autoload>1</autoload>
<name>crxApplication</name>
<file>crxApplication.php</file>
<desc>applications.xml</desc>
</class>
<class>
<autoload>1</autoload>
<name>crxPackage</name>
<file>crxPackage.php</file>
<desc>crxPackage provide a package system over ssh, like ansible.</desc>
</class>
</classes>
</librairie>
......@@ -3,29 +3,52 @@
* CRX-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 05/04/2019
* @revision 06/03/2020
* @lib compression
* @copyright see header
* @version 1.2
* @version 1.3 ( 1 )
*/
namespace crx;
class crxZip{
private $_destination_path=null;
namespace crx;
function __construct(){
}
class crxZip extends \ZipArchive {
function createArchive(){
//TODO
}
private $_destination_path=null;
function __construct(){}
function setDestinationPath($dest){
$this->_destination_path=$dest;
}
function createArchive($path_src,$path_zip_dst){
$za = new crxZip();
$res = $za->open($path_zip_dst, \ZipArchive::CREATE);
if($res === TRUE){
$za->addDir($path_src, basename($path_src));
$za->close();
return true;
}
else{
return false;
}
}
public function addDir($location, $name){
$this->addEmptyDir($name);
$this->addDirDo($location, $name);
}
private function addDirDo($location, $name){
$name .= '/';
$location .= '/';
$dir = opendir ($location);
while ($file = readdir($dir)){
if ($file == '.' || $file == '..') continue;
$do = (filetype( $location . $file) == 'dir') ? 'addDir' : 'addFile';
$this->$do($location . $file, $name . $file);
}
}
function getArchiveInfo($archive_path,$options=array()){
......@@ -74,6 +97,8 @@ class crxZip{
function uncompressArchive($archive_path,$destination_folder="tmp",$read_archive_only=false){
$verbose = 0;
if (($fd = zip_open($archive_path))) {
if(!is_resource($fd)){
......
<?php
/**
* @author Bastien Barbe - CRX-FRAMEWORK (cms part)
* @date 01/01/2005
* @revision 13/01/2019
* @author Bastien Barbe - CRX-FRAMEWORK
* @date 20/03/2020
* @revision 13/01/2019
* @module crypto
* @copyright see header
* @version 1.2.1
*/
class crxEncrypt{
namespace crx;
class crxEncrypt{
function __construct(){
if(function_exists('mcrypt_encrypt')){
......
......@@ -3,9 +3,9 @@
CRX-FRAMEWORK
* @author Bastien Barbe
* @date 01/01/2005
* @revision 06/02/2020
* @revision 01/03/2020
* @lib webapp
* @version 1.5.3-4
* @version 1.5 ( 5 )
*/
namespace crx;
......@@ -34,6 +34,14 @@ class crxDataSource extends crxSchema{
);
}
*/
function __construct($data_src=null){
if($data_src<>null){
$this->_dataSrcName = $data_src;
}
}
function getExecSqlError(){
return $this->ERROR;
......@@ -207,11 +215,9 @@ class crxDataSource extends crxSchema{
}
if(is_array($uniq_field) && count($uniq_field) > 0 ){
if(is_array($uniq_field) && count($uniq_field) > 0 && $mysql_bulk==0){
$cancel_creation=0;
foreach($uniq_field as $k=>$v){
if(isset($data[$v])){
$s=$this->dbi->formatSqlQuery($k,$table_name,'DISPLAY','',
array(
......@@ -228,7 +234,6 @@ class crxDataSource extends crxSchema{
}
}
}
}
if($this->_debugProcess)
......@@ -458,15 +463,6 @@ class crxDataSource extends crxSchema{
}
function __construct($data_src=null){
if($data_src<>null){
$this->_dataSrcName = $data_src;
}
}
static function getDs($name){
$c=new \crx\crxDataSource($name);
......@@ -489,36 +485,51 @@ class crxDataSource extends crxSchema{
function getDataSources($except_buildin_data_sources=false){
$path = $this->getDataSourcesPath();
$path = $this->getDataSourcesPath();
$data_src_ressources_xml_files=crxFile::ls($path,false);
if(!is_dir($path))return array();
$match='(buildin)';
foreach($data_src_ressources_xml_files as $k=>$file){
$this->_crxItemInstance->setStorageOptions(array(
'xmlFilePath' => $this->builtSourcePathName($file),
'item_l1' => 'ROOT',
'item_l2' => 'data_source',
));
$data_src_name = str_replace(".xml","",$file);
$key=array();
$key['source_name']=$data_src_name;
$r=$this->_crxItemInstance->getValues($key);
$match='buildin';
if(($except_buildin_data_sources && !preg_match("/$match/",$file)) || !$except_buildin_data_sources){
//if(($except_buildin_data_sources && !ereg('buildin',$file)) || !$except_buildin_data_sources){
$ressources[$k] = array(
'file'=>$k,
'dataSourceInfo'=>$r
);
}
if(preg_match('/(.*).xml$/',$file)){
$x=new crxXml();
$x->defineItemName('data_source');
$x->setPath($path.$file);
$x->setXmlSchema(array(
'source_name',
'source_type',
'source_dn_path',
'source_dbname',
'source_tbl_prefix',
'source_user',
'source_pwd',
'source_host',
'source_port'
));
$conf=$x->parseAndReturnValues();
if(isset($conf[0])){
if((!preg_match("/$match/",$file))){
$ressources[$k] = array(
'file'=>$k,
$conf[0]
);
}
if($except_buildin_data_sources){
if((preg_match("/$match/",$file))){
$ressources[$k] = array(
'file'=>$k,
$conf[0]
);
}
}
}
}
}
return $ressources;
}
......@@ -567,9 +578,16 @@ class crxDataSource extends crxSchema{
function setOptions($opts){
//var_dump($opts);
//die();
$this->dbi -> setOptions ($opts) ;
$this->_overwrite_existing_data_source = $opts['overwrite_existing_source'];
if(isset($opts['overwrite_existing_source']))
$this->_overwrite_existing_data_source = $opts['overwrite_existing_source'];
else
$this->_overwrite_existing_data_source = false;
}
......@@ -677,7 +695,7 @@ class crxDataSource extends crxSchema{
$this->_dataSourceInformation['source_type']
);
$this->_dataSourceInformation['xml_conf']=$this->_currentXmlDsConfiguration;
if($this->dbi == NULL)return FALSE;
......@@ -784,7 +802,9 @@ class crxDataSource extends crxSchema{
}
*/
function getValues($key=null){
return $this->dbi -> getValues($key);
}
function buildDataDriversPath($driver_name){
......@@ -1014,7 +1034,7 @@ class crxDataSource extends crxSchema{
$this->loadDataAccess();
var_dump($this->dbi);
//var_dump($this->dbi);
}
$this->dbi->execSql($q);
......
<?php
/*
*************************************************************************************
*
* Crx-cms powered by CRX-PHP-FRAMEWORK http://git.crx.cloud/crx-php/crx-framework
* Copyright (c) Bastien Barbe and contributors. All rights
* reserved.
*
* Crx-cms is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Crx-cms is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*************************************************************************************
*/
/**
* @author Bastien Barbe - CRX-FRAMEWORK (cms part)
* CRX-PHP-FRAMEWORK http://git.crx.cloud/crx-php/crx-framework
* @author Bastien Barbe
* @date 01/01/2005
* @revision 26/01/2020
* @revision 05/03/2020
* @module data
* @copyright see header
* @version 1.2-1
* @version 1.2 ( 3 )
*/
/**
XML Reader part :
......@@ -42,17 +26,26 @@
*/
namespace crx;
class crxDataXml
extends crxFramework{
class crxDataXml extends crxFramework{
var $items = array();
var $_childs = array();
var $_debug = false;
private $_xmlFile = null;
private $_xmlCfg = array(); //Configure XML Parser ;)
var $_rssChannels = array();
var $_xmlDoc_encoding = "ISO-8859-1";
var $_buff_cap_xml = null;
var $_rootKey = false;
function __construct(){
$this->OID=time();
......@@ -76,10 +69,16 @@ extends crxFramework{
}
public function appendNewChild($v){
$i=0;
foreach($v as $k=>$k){
$i++;
}if($i>0)
$this->childs[]=$v;
}
if($i>0)
$this->childs[]=$v;
}
public function setRootKey($k){
......@@ -246,14 +245,25 @@ extends crxFramework{
function readerStrXml($str,$item_level1_root,$item_level2){
/*
if($item_level1_root && $item_level2){
//Normalize XML string, avoid error :
ereg("(<".$item_level1_root.">)(.*)(</".$item_level1_root.">)",$str,$analyse);
$reg_xml_content="/(<".$item_level1_root.">)(.*)(<\/".$item_level1_root.">)/";
$analyse=preg_match($reg_xml_content,$str,$matches);
var_dump($matches);
var_dump($reg_xml_content);
var_dump($analyse);
die();
$str='<?xml version="1.0"?>'."\r";// encoding="utf-8"
$str.=$analyse[1];//Root xml tag start
$str.=$analyse[2];//CONTENT XML Items
$str.=$analyse[3];//Root xml tag end
}
}*/
$_handle_simple_xml = simplexml_load_string($str);
if(!is_object($_handle_simple_xml)){return false;}
......@@ -269,22 +279,39 @@ extends crxFramework{
}
function getItem($item_val_and_key){
function getItem($item_val_and_key=''){
foreach($item_val_and_key as $k=>$v){$pk_k = $k;$pk_value = $v;}
if(is_array($this->items)){
if($item_val_and_key<>''){
foreach($item_val_and_key as $k=>$v){$pk_k = $k;$pk_value = $v;}
foreach($this->items as $kit=>$items){
foreach($items as $kitem=>$valitem){
if( $kitem == $pk_k && $valitem == $pk_value){
$this->_itemIndex=$kit;
return $this->items[$kit];
if(is_array($this->items)){
foreach($this->items as $kit=>$items){
foreach($items as $kitem=>$valitem){
if( $kitem == $pk_k && $valitem == $pk_value){
$this->_itemIndex=$kit;
return $this->items[$kit];
}
}
}
}
return false;
}
return false;
else{
//only one item to return :
foreach($this->items as $k=>$item){}
return $item;
}
}
function reader($_path_xml_file,$item_level1,$item_level2){
......@@ -330,9 +357,11 @@ extends crxFramework{
if(is_array($this->_xmlGenerator['childSchema'][$schema_key]))
foreach($this->_xmlGenerator['childSchema'][$schema_key] as $k_=>$child_property){
if(!isset($_tmp_childs[$k]))$_tmp_childs[$k]=new \stdClass();
$_tmp_childs[$k]->$child_property = $this->childs[$k]->$child_property;
}
}
......@@ -360,31 +389,30 @@ extends crxFramework{
//Looking for the childs array to update :
if(is_array($this->childs))
foreach($this->childs as $k=>$c){
//Searching the child to update
//we've found it !! so we update it with : schema + values (from $_POST)
if(!$disable_key && $c->$keyName == $keyValue){
//print $c->$keyName._BR_;
//$this->childs[$k]
//update child values :
foreach($this->_xmlGenerator['childSchema'][$shema_key] as $k_=>$child_property){
$this->childs[$k]->$child_property=$data[$child_property];
if(isset($data[$child_property]))//update only non-empty field :
$this->childs[$k]->$child_property=$data[$child_property];
}
}
if($disable_key){
foreach($this->_xmlGenerator['childSchema'][$shema_key] as $k_=>$child_property){
$this->childs[$k]->$child_property=$data[$child_property];
}
}
}
}
function openTag($input){
......@@ -412,7 +440,8 @@ extends crxFramework{
else $_xmlCode = '<?xml version="1.0"?>'.CRLF;
if($this->_rootKey) $_xmlCode .= $this->_rootKey['open'].CRLF;
if($this->_xmlGenerator['parentName'][$key]) $_xmlCode .= $this->openTag($this->_xmlGenerator['parentName'][$key]).CRLF;
if(is_array($this->_rssChannels)){
if(is_array($this->_rssChannels) && !empty($this->_rssChannels)){
foreach($this->_rssChannels as $k=>$channel){
foreach($channel as $k=>$chan){
$_xmlCode.=$this->_TAB_.$this->openTag($k);
......@@ -497,12 +526,20 @@ extends crxFramework{
return $_xmlCode;
}
function setSimpleXmlHandle($h,$item){
$this->_hSxml=$h;
if(!is_object($this->_hSxml))return;
foreach ($this->_hSxml->xpath('//'.$item) as $opt) {
$this->appendNewChild($opt);
}
if($this->_debug)print_r($this->childs);
}
......
......@@ -3,10 +3,9 @@
* CRX-FRAMEWORK
* @author Bastien Barbe
* @date 01/2005
* @revision 26/01/2020
* @revision 06/03/2020
* @module file
* @copyright see header
* @version 1.3.4-1
* @version 1.3 ( 5 )
*/
namespace crx;
......@@ -23,6 +22,15 @@ class crxFile{
$this->IDRefer = "";
}
static function wget($http_path,$local_path,$opt=array()){
$data = file_get_contents($http_path);
self::setFileContent($local_path,$data);
}
static function sfileExist($file){
if(file_exists($file))return true;
return false;
......@@ -225,10 +233,12 @@ class crxFile{
if(empty($file))return false;
if(!file_exists($file)){
$r=touch($file);
if(!$r){
return false;
}
}
}
$f=file_put_contents($file,$content);
return true;
/*
......@@ -280,6 +290,7 @@ class crxFile{
}
// => Call via : octdec($filemode) with $filemode = 777 for exemple.
function __chmod($path, $filemode, $recursive=false) {
if (!is_dir($path))
return chmod($path, $filemode);
......@@ -449,7 +460,6 @@ class crxFile{
$this->loading_file();//If file doesn't exist we upload the file
}
function gen_small_picture(){
......@@ -566,8 +576,6 @@ class crxFile{
}
}
function returnPathAvatar(){
return $this->dest_pathResizePicture;
}
......@@ -616,19 +624,50 @@ class crxFile{
}
}
static function cpR( $source, $destination ) {
if