BUG 0000 "improvements on System::getSystemConfiguration() function"
- this is a important improvement, now we can have two configurations levels 1. Global Configuration Level (workflow/engine/config/env.ini) 2. Workspace Configuration Level (.../shared/sites/some_workflow/env.ini) - improvement to read env's ini files once and store on session, - if any file has been changed (verify by checksum files) that session value is updated
This commit is contained in:
@@ -915,7 +915,7 @@ class G
|
||||
* @param string $urlLink
|
||||
* @return string
|
||||
*/
|
||||
function parseURI($uri, $config = array())
|
||||
static function parseURI($uri, $config = array())
|
||||
{
|
||||
//*** process the $_POST with magic_quotes enabled
|
||||
// The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0.
|
||||
|
||||
@@ -1008,36 +1008,86 @@ class System {
|
||||
return $cities;
|
||||
}
|
||||
|
||||
public static function getSystemConfiguration($iniFile='')
|
||||
public static function getSystemConfiguration($globalIniFile = '', $wsIniFile = '')
|
||||
{
|
||||
$readGlobalIniFile = false;
|
||||
$readWsIniFile = false;
|
||||
|
||||
if (empty($globalIniFile)) {
|
||||
$globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
|
||||
}
|
||||
|
||||
if (empty($wsIniFile)) {
|
||||
if (defined('PATH_DB')) { // if we're on a valid workspace env.
|
||||
$uriParts = explode('/', getenv("REQUEST_URI"));
|
||||
|
||||
if (substr($uriParts[1], 0, 3 ) == 'sys') {
|
||||
$wsName = substr($uriParts[1], 3);
|
||||
$wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$readGlobalIniFile = file_exists($globalIniFile) ? true : false;
|
||||
$readWsIniFile = file_exists($wsIniFile) ? true : false;
|
||||
|
||||
if (isset($_SESSION['PROCESSMAKER_ENV'])) {
|
||||
$md5 = array();
|
||||
|
||||
if ($readGlobalIniFile)
|
||||
$md5[] = md5_file($globalIniFile);
|
||||
|
||||
if ($readWsIniFile)
|
||||
$md5[] = md5_file($wsIniFile);
|
||||
|
||||
$hash = implode('-', $md5);
|
||||
|
||||
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
|
||||
$_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
|
||||
return $_SESSION['PROCESSMAKER_ENV'];
|
||||
}
|
||||
}
|
||||
|
||||
// default configuration
|
||||
$config = array(
|
||||
'debug' => 0,
|
||||
'debug_sql' => 0,
|
||||
'debug_time' => 0,
|
||||
'debug_calendar' => 0,
|
||||
'wsdl_cache' => 1,
|
||||
'memory_limit' => '100M',
|
||||
'time_zone' => 'America/La_Paz',
|
||||
'memcached' => 0,
|
||||
'memcached_server' =>'',
|
||||
'default_skin' => 'classic',
|
||||
'default_lang' => 'en'
|
||||
'debug' => 0,
|
||||
'debug_sql' => 0,
|
||||
'debug_time' => 0,
|
||||
'debug_calendar' => 0,
|
||||
'wsdl_cache' => 1,
|
||||
'memory_limit' => '100M',
|
||||
'time_zone' => 'America/La_Paz',
|
||||
'memcached' => 0,
|
||||
'memcached_server' => '',
|
||||
'default_skin' => 'classic',
|
||||
'default_lang' => 'en'
|
||||
);
|
||||
|
||||
if (empty($iniFile) || !file_exists($iniFile)) {
|
||||
return $config;
|
||||
// read the global env.ini configuration file
|
||||
if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) {
|
||||
$config = array_merge($config, $globalConf);
|
||||
}
|
||||
|
||||
/* Read the env.ini */
|
||||
$ini_contents = parse_ini_file($iniFile, false);
|
||||
|
||||
if ($ini_contents !== false) {
|
||||
$config = array_merge($config, $ini_contents);
|
||||
// Workspace environment configuration
|
||||
if ($readWsIniFile && ($wsConf = @parse_ini_file($wsIniFile)) !== false) {
|
||||
$config = array_merge($config, $wsConf);
|
||||
}
|
||||
|
||||
// validation debug config, ony accept bynary values, 1 to enable
|
||||
// validation debug config, only binary value is valid; debug = 1, to enable
|
||||
$config['debug'] = $config['debug'] == 1 ? 1 : 0;
|
||||
|
||||
$md5 = array();
|
||||
if ($readGlobalIniFile)
|
||||
$md5[] = md5_file($globalIniFile);
|
||||
|
||||
if ($readWsIniFile)
|
||||
$md5[] = md5_file($wsIniFile);
|
||||
|
||||
$hash = implode('-', $md5);
|
||||
|
||||
$_SESSION['PROCESSMAKER_ENV'] = $config;
|
||||
$_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,24 +23,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//***************** System Directories & Paths **************************
|
||||
/**
|
||||
* System Directories & Paths
|
||||
*/
|
||||
|
||||
//***************** RBAC Paths **************************
|
||||
// Defining RBAC Paths constants
|
||||
define( 'PATH_RBAC_HOME', PATH_TRUNK . 'rbac' . PATH_SEP );
|
||||
|
||||
//***************** GULLIVER Paths **************************
|
||||
// Defining Gulliver framework paths constants
|
||||
define( 'PATH_GULLIVER_HOME', PATH_TRUNK . 'gulliver' . PATH_SEP );
|
||||
define( 'PATH_GULLIVER', PATH_GULLIVER_HOME . 'system' . PATH_SEP ); //gulliver system classes
|
||||
define( 'PATH_GULLIVER_BIN', PATH_GULLIVER_HOME . 'bin' . PATH_SEP ); //gulliver bin classes
|
||||
define( 'PATH_TEMPLATE', PATH_GULLIVER_HOME . 'templates' . PATH_SEP );
|
||||
define( 'PATH_THIRDPARTY', PATH_GULLIVER_HOME . 'thirdparty' . PATH_SEP );
|
||||
|
||||
define( 'PATH_RBAC', PATH_RBAC_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP ); //to enable rbac version 2
|
||||
define( 'PATH_RBAC_CORE', PATH_RBAC_HOME . 'engine' . PATH_SEP );
|
||||
|
||||
define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP );
|
||||
|
||||
//***************** PM Paths CORE **************************
|
||||
// Defining PMCore Path constants
|
||||
define( 'PATH_CORE', PATH_HOME . 'engine' . PATH_SEP );
|
||||
define( 'PATH_SKINS', PATH_CORE . 'skins' . PATH_SEP );
|
||||
define( 'PATH_SKIN_ENGINE', PATH_CORE . 'skinEngine' . PATH_SEP );
|
||||
@@ -57,44 +57,48 @@
|
||||
//define( 'PATH_LANGUAGECONT',PATH_CORE . 'content' . PATH_SEP . 'languages' . PATH_SEP );
|
||||
define( 'SYS_UPLOAD_PATH', PATH_HOME . "public_html/files/" );
|
||||
define( 'PATH_UPLOAD', PATH_HTML . 'files' . PATH_SEP);
|
||||
define( 'PATH_WORKFLOW_MYSQL_DATA', PATH_CORE . 'data' . PATH_SEP.'mysql'.PATH_SEP);
|
||||
define( 'PATH_RBAC_MYSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP.'mysql'.PATH_SEP);
|
||||
|
||||
define( 'FILE_PATHS_INSTALLED', PATH_CORE . 'config' . PATH_SEP . 'paths_installed.php' );
|
||||
define( 'PATH_WORKFLOW_MYSQL_DATA', PATH_CORE . 'data' . PATH_SEP.'mysql'.PATH_SEP);
|
||||
define( 'PATH_RBAC_MYSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP.'mysql'.PATH_SEP);
|
||||
define( 'FILE_PATHS_INSTALLED', PATH_CORE . 'config' . PATH_SEP . 'paths_installed.php' );
|
||||
define( 'PATH_WORKFLOW_MSSQL_DATA', PATH_CORE . 'data' . PATH_SEP.'mssql'.PATH_SEP);
|
||||
define( 'PATH_RBAC_MSSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP.'mssql'.PATH_SEP);
|
||||
define( 'PATH_CONTROLLERS', PATH_CORE . 'controllers' . PATH_SEP );
|
||||
|
||||
define( 'PATH_WORKFLOW_MSSQL_DATA', PATH_CORE . 'data' . PATH_SEP.'mssql'.PATH_SEP);
|
||||
define( 'PATH_RBAC_MSSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP.'mssql'.PATH_SEP);
|
||||
|
||||
define( 'PATH_CONTROLLERS', PATH_CORE . 'controllers' . PATH_SEP );
|
||||
|
||||
//************ include Gulliver Class **************
|
||||
// include Gulliver Class
|
||||
require_once( PATH_GULLIVER . PATH_SEP . 'class.g.php');
|
||||
|
||||
//************ the Smarty Directories **************
|
||||
|
||||
if(file_exists(FILE_PATHS_INSTALLED)) {
|
||||
//parsing for old definitions in the compiled path constant
|
||||
// backward compatibility; parsing old definitions in the compiled path constant
|
||||
$tmp = file_get_contents(FILE_PATHS_INSTALLED);
|
||||
if( strpos($tmp, 'PATH_OUTTRUNK') !== false ){
|
||||
|
||||
if (strpos($tmp, 'PATH_OUTTRUNK') !== false) {
|
||||
@file_put_contents(FILE_PATHS_INSTALLED, str_replace('PATH_OUTTRUNK', 'PATH_DATA', $tmp));
|
||||
}
|
||||
// end backward compatibility
|
||||
|
||||
require_once ( FILE_PATHS_INSTALLED );
|
||||
// include the workspace installed configuration
|
||||
require_once FILE_PATHS_INSTALLED;
|
||||
|
||||
define( 'PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP );
|
||||
// defining system constant when a valid workspace environment exists
|
||||
define('PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP);
|
||||
define('PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP);
|
||||
define('PATH_TEMPORAL', PATH_C . 'dynEditor/');
|
||||
define('PATH_DB', PATH_DATA . 'sites' . PATH_SEP);
|
||||
// smarty constants
|
||||
define('PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c');
|
||||
define('PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache');
|
||||
|
||||
define( 'PATH_CUSTOM_SKINS',PATH_DATA . 'skins' . PATH_SEP );
|
||||
if (!is_dir(PATH_SMARTY_C)) {
|
||||
G::mk_dir(PATH_SMARTY_C);
|
||||
}
|
||||
|
||||
// TODO: This path defines where to save temporal data, similar to $_SESSION.
|
||||
define( 'PATH_TEMPORAL', PATH_C . 'dynEditor/');
|
||||
|
||||
define( 'PATH_DB', PATH_DATA . 'sites' . PATH_SEP );
|
||||
define( 'PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c' );
|
||||
define( 'PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache' );
|
||||
if (!is_dir(PATH_SMARTY_C)) G::mk_dir(PATH_SMARTY_C);
|
||||
if (!is_dir(PATH_SMARTY_CACHE)) G::mk_dir(PATH_SMARTY_CACHE);
|
||||
if (!is_dir(PATH_SMARTY_CACHE)) {
|
||||
G::mk_dir(PATH_SMARTY_CACHE);
|
||||
}
|
||||
}
|
||||
//***************** set include path ***********************
|
||||
|
||||
// set include path
|
||||
set_include_path(
|
||||
PATH_CORE . PATH_SEPARATOR .
|
||||
PATH_THIRDPARTY . PATH_SEPARATOR .
|
||||
@@ -103,47 +107,36 @@
|
||||
get_include_path()
|
||||
);
|
||||
|
||||
//******************* some global definitions, before it was the defines.php file ********
|
||||
/**
|
||||
* Global definitions, before it was the defines.php file
|
||||
*/
|
||||
|
||||
//***************** URL KEY *********************************************
|
||||
// URL Key
|
||||
define("URL_KEY", 'c0l0s40pt1mu59r1m3' );
|
||||
|
||||
//************ Other definitions **************
|
||||
//web service timeout
|
||||
define( 'TIMEOUT_RESPONSE', 100 );
|
||||
//to login like workflow system
|
||||
define( 'APPLICATION_CODE', 'ProcessMaker' );
|
||||
// Other definitions
|
||||
define('TIMEOUT_RESPONSE', 100 ); //web service timeout
|
||||
define('APPLICATION_CODE', 'ProcessMaker' ); //to login like workflow system
|
||||
define('MAIN_POFILE', 'processmaker');
|
||||
define('PO_SYSTEM_VERSION', 'PM 4.0.1');
|
||||
|
||||
define ( 'MAIN_POFILE', 'processmaker');
|
||||
define ( 'PO_SYSTEM_VERSION', 'PM 4.0.1');
|
||||
|
||||
///************TimeZone Set***************//
|
||||
if (defined('TIME_ZONE') && function_exists('date_default_timezone_set')) {
|
||||
date_default_timezone_set(TIME_ZONE);
|
||||
}
|
||||
|
||||
$G_CONTENT = NULL;
|
||||
$G_MESSAGE = "";
|
||||
$G_MESSAGE_TYPE = "info";
|
||||
$G_CONTENT = NULL;
|
||||
$G_MESSAGE = "";
|
||||
$G_MESSAGE_TYPE = "info";
|
||||
$G_MENU_SELECTED = -1;
|
||||
$G_MAIN_MENU = "default";
|
||||
$G_MAIN_MENU = "default";
|
||||
|
||||
//remove this, when migrate to Propel
|
||||
// define ( 'PEAR_DATABASE', 'mysql');
|
||||
// define ( 'ENABLE_ENCRYPT', 'no' );
|
||||
// define('DB_ERROR_BACKTRACE', TRUE);
|
||||
// Environment definitions
|
||||
define('G_PRO_ENV', 'PRODUCTION');
|
||||
define('G_DEV_ENV', 'DEVELOPMENT');
|
||||
define('G_TEST_ENV', 'TEST');
|
||||
|
||||
//************ Environment definitions **************
|
||||
define ( 'G_PRO_ENV', 'PRODUCTION' );
|
||||
define ( 'G_DEV_ENV', 'DEVELOPMENT' );
|
||||
define ( 'G_TEST_ENV', 'TEST' );
|
||||
// Number of files per folder at PATH_UPLOAD (cases documents)
|
||||
define('APPLICATION_DOCUMENTS_PER_FOLDER', 1000);
|
||||
|
||||
//********* Number of files per folder at PATH_UPLOAD (cases documents) *****
|
||||
define( 'APPLICATION_DOCUMENTS_PER_FOLDER', 1000 );
|
||||
|
||||
//********* Server of ProcessMaker Library *****
|
||||
define ( 'PML_SERVER' , 'http://library.processmaker.com' );
|
||||
define ( 'PML_WSDL_URL' , PML_SERVER . '/syspmLibrary/en/green/services/wsdl');
|
||||
define ( 'PML_UPLOAD_URL', PML_SERVER . '/syspmLibrary/en/green/services/uploadProcess');
|
||||
define ( 'PML_DOWNLOAD_URL', PML_SERVER . '/syspmLibrary/en/green/services/download');
|
||||
// Server of ProcessMaker Library
|
||||
define('PML_SERVER' , 'http://library.processmaker.com');
|
||||
define('PML_WSDL_URL' , PML_SERVER . '/syspmLibrary/en/green/services/wsdl');
|
||||
define('PML_UPLOAD_URL', PML_SERVER . '/syspmLibrary/en/green/services/uploadProcess');
|
||||
define('PML_DOWNLOAD_URL', PML_SERVER . '/syspmLibrary/en/green/services/download');
|
||||
|
||||
|
||||
@@ -52,9 +52,16 @@
|
||||
define('PATH_TRUNK', $pathTrunk);
|
||||
define('PATH_OUTTRUNK', $pathOutTrunk);
|
||||
|
||||
require_once $pathhome . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
|
||||
$config = System::getSystemConfiguration($pathhome . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini');
|
||||
// Including these files we get the PM paths and definitions (that should be just one file.
|
||||
require_once $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php';
|
||||
require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php';
|
||||
|
||||
// starting session
|
||||
session_start();
|
||||
echo '<pre>';
|
||||
$config = System::getSystemConfiguration();
|
||||
print_r($config);
|
||||
print_r($_SESSION); die;
|
||||
$e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
|
||||
$e_all = defined('E_STRICT') ? $e_all & ~E_STRICT : $e_all;
|
||||
$e_all = $config['debug'] ? $e_all : $e_all & ~E_NOTICE;
|
||||
@@ -75,9 +82,6 @@
|
||||
define ('MEMCACHED_SERVER', $config['memcached_server']);
|
||||
define ('TIME_ZONE', $config['time_zone']);
|
||||
|
||||
// Including these files we get the PM paths and definitions (that should be just one file.
|
||||
require_once $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php';
|
||||
|
||||
// Verifiying permissions processmaker writable directories
|
||||
$writableDirs = array(PATH_CONFIG, PATH_XMLFORM, PATH_HTML, PATH_PLUGINS);
|
||||
|
||||
@@ -178,7 +182,7 @@
|
||||
if ( substr ( $realPath, 0,6) == 'plugin' ) {
|
||||
// Another way to get the path of Plugin public_html and stream the correspondent file, By JHL Jul 14, 08
|
||||
// TODO: $pathsQuery will be used?
|
||||
$pathsQuery="";
|
||||
$pathsQuery = '';
|
||||
// Get the query side
|
||||
// Did we use this variable $pathsQuery for something??
|
||||
$forQuery = explode("?",$realPath);
|
||||
@@ -187,13 +191,13 @@
|
||||
}
|
||||
|
||||
//Get that path in array
|
||||
$paths = explode ( PATH_SEP, $forQuery[0] );
|
||||
$paths = explode ( PATH_SEP, $forQuery[0] );
|
||||
//remove the "plugin" word from
|
||||
$paths[0] = substr ( $paths[0],6);
|
||||
$paths[0] = substr ( $paths[0],6);
|
||||
//Get the Plugin Folder, always the first element
|
||||
$pluginFolder=array_shift($paths);
|
||||
$pluginFolder = array_shift($paths);
|
||||
//The other parts are the realpath into public_html (no matter how many elements)
|
||||
$filePath=implode(PATH_SEP,$paths);
|
||||
$filePath = implode(PATH_SEP,$paths);
|
||||
$pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html'. PATH_SEP . $filePath;
|
||||
|
||||
if ( file_exists ( $pluginFilename ) ) {
|
||||
@@ -253,7 +257,7 @@
|
||||
}
|
||||
|
||||
// the request correspond to valid php page, now parse the URI
|
||||
G::parseURI(getenv("REQUEST_URI"), $config);
|
||||
G::parseURI(getenv("REQUEST_URI"));
|
||||
|
||||
// verify if index.html exists
|
||||
if (!file_exists(PATH_HTML . 'index.html')) { // if not, create it from template
|
||||
@@ -467,7 +471,7 @@
|
||||
|
||||
// The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off.
|
||||
// ini_set( 'register_globals', 'Off' );
|
||||
session_start();
|
||||
//session_start();
|
||||
ob_start();
|
||||
|
||||
// Rebuild the base Workflow translations if not exists
|
||||
|
||||
Reference in New Issue
Block a user