2010-12-02 23:34:41 +00:00
< ? php
2012-04-09 18:48:44 -04:00
/**
2012-11-20 17:48:54 -04:00
* Bootstrap . php
2012-04-09 18:48:44 -04:00
*
* ProcessMaker Open Source Edition
2012-11-07 17:09:51 -04:00
* Copyright ( C ) 2004 - 2008 Colosa Inc .
2012-04-09 18:48:44 -04:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation , either version 3 of the
* License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
2012-12-06 16:47:05 -04:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . BaseCaseTrackerObjectPeerSee the
2012-04-09 18:48:44 -04:00
* GNU Affero General Public License for more details .
*
* You should have received a copy of the GNU Affero General Public License
2012-11-20 17:48:54 -04:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2012-04-09 18:48:44 -04:00
*
* For more information , contact Colosa Inc , 2566 Le Jeune Rd . ,
* Coral Gables , FL , 33134 , USA , or email info @ colosa . com .
*/
2017-08-07 13:02:26 -04:00
use Illuminate\Foundation\Http\Kernel ;
2017-08-10 16:55:51 -04:00
use ProcessMaker\Plugins\PluginRegistry ;
2012-04-09 18:48:44 -04:00
/**
2012-11-20 17:48:54 -04:00
* bootstrap - ProcessMaker Bootstrap
2012-05-02 11:11:41 -04:00
* this file is used initialize main variables , redirect and dispatch all requests
2012-04-09 18:48:44 -04:00
*/
2014-03-20 12:37:30 -04:00
2013-04-22 18:08:13 -04:00
function transactionLog ( $transactionName ){
if ( extension_loaded ( 'newrelic' )) {
$baseName = " ProcessMaker " ;
2013-06-03 18:13:38 -04:00
2013-04-22 18:08:13 -04:00
//Application base name
newrelic_set_appname ( $baseName );
2013-06-03 18:13:38 -04:00
2013-04-22 18:08:13 -04:00
//Custom parameters
2017-10-10 12:33:25 -04:00
if ( ! empty ( config ( " system.workspace " ))){
newrelic_add_custom_parameter ( " workspace " , config ( " system.workspace " ));
2013-04-24 11:29:08 -04:00
}
if ( defined ( " SYS_LANG " )){
newrelic_add_custom_parameter ( " lang " , SYS_LANG );
}
if ( defined ( " SYS_SKIN " )){
newrelic_add_custom_parameter ( " skin " , SYS_SKIN );
}
if ( defined ( " SYS_COLLECTION " )){
newrelic_add_custom_parameter ( " collection " , SYS_COLLECTION );
}
if ( defined ( " SYS_TARGET " )){
newrelic_add_custom_parameter ( " target " , SYS_TARGET );
}
if ( defined ( " SYS_URI " )){
newrelic_add_custom_parameter ( " uri " , SYS_URI );
}
if ( defined ( " PATH_CORE " )){
newrelic_add_custom_parameter ( " path_core " , PATH_CORE );
}
if ( defined ( " PATH_DATA_SITE " )){
newrelic_add_custom_parameter ( " path_site " , PATH_DATA_SITE );
}
2013-06-03 18:13:38 -04:00
2013-04-22 18:08:13 -04:00
//Show correct transaction name
2017-10-10 12:33:25 -04:00
if ( ! empty ( config ( " system.workspace " ))){
newrelic_set_appname ( " PM- " . config ( " system.workspace " ) . " ; $baseName " );
2013-04-22 18:08:13 -04:00
}
if ( defined ( " PATH_CORE " )){
$transactionName = str_replace ( PATH_CORE , " " , $transactionName );
}
newrelic_name_transaction ( $transactionName );
}
}
2013-06-12 16:58:48 -04:00
2014-01-24 10:56:41 -04:00
// Validating if exists 'HTTP_USER_AGENT' key in $_SERVER array
if ( ! isset ( $_SERVER [ 'HTTP_USER_AGENT' ])) {
$_SERVER [ 'HTTP_USER_AGENT' ] = '' ;
}
2012-11-20 17:48:54 -04:00
// Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/'
define ( 'PATH_SEP' , '/' );
// Defining the Home Directory
$realdocuroot = str_replace ( '\\' , '/' , $_SERVER [ 'DOCUMENT_ROOT' ] );
$docuroot = explode ( PATH_SEP , $realdocuroot );
array_pop ( $docuroot );
$pathhome = implode ( PATH_SEP , $docuroot ) . PATH_SEP ;
// try to find automatically the trunk directory where are placed the RBAC and Gulliver directories
// in a normal installation you don't need to change it.
array_pop ( $docuroot );
$pathTrunk = implode ( PATH_SEP , $docuroot ) . PATH_SEP ;
array_pop ( $docuroot );
$pathOutTrunk = implode ( PATH_SEP , $docuroot ) . PATH_SEP ;
define ( 'PATH_HOME' , $pathhome );
define ( 'PATH_TRUNK' , $pathTrunk );
define ( 'PATH_OUTTRUNK' , $pathOutTrunk );
//we are focusing in have this behaivour
//1. if the uri is a existing file return the file inmediately
//2. if the uri point to png, jpg, js, or css mapped in other place, return it inmediately
//3. process the uri,
//here we are putting approved CONSTANTS, I mean constants be sure we need,
define ( 'PATH_HTML' , PATH_HOME . 'public_html' . PATH_SEP );
//this is the first path, if the file exists...
2012-12-14 16:42:57 -04:00
$request = substr ( $_SERVER [ 'REQUEST_URI' ], 1 , strlen ( $_SERVER [ 'REQUEST_URI' ])); //removes the first '/'
2012-11-23 11:52:02 -04:00
$fileWithoutParam = explode ( " ? " , $request ); // split the URI by '?'
$request = $fileWithoutParam [ 0 ]; // get the first element of the split URI
$requestFile = PATH_HTML . $request ; // temporary assemble a path for the file embedded in the URI
2012-11-20 17:48:54 -04:00
if ( file_exists ( $requestFile )) {
if ( ! is_file ( $requestFile )) {
header ( " location: /errors/error404.php?url= " . urlencode ( $_SERVER [ 'REQUEST_URI' ] ) );
die ;
}
2017-02-09 17:55:37 -04:00
if ( $request === " app.php " || $request === " sysGeneric.php " ) {
//HTTP/1.0 403 Forbidden
http_response_code ( 403 );
}
2012-11-20 17:48:54 -04:00
$pos = strripos ( $request , " . " ) + 1 ;
$size = strlen ( $request );
if ( $pos < $size ) {
//if this file got an extension then assign the content
2014-01-15 11:14:59 -04:00
$ext_file = substr ( $request , $pos , $size );
2012-11-27 13:44:02 -04:00
if ( $ext_file == " gif " || $ext_file == " png " ) {
2012-11-20 17:48:54 -04:00
$ext_file = 'image/' . $ext_file ;
2012-11-27 13:44:02 -04:00
} elseif ( $ext_file == " jpg " || $ext_file == " jpeg " ) {
$ext_file = 'image/jpeg' ;
2012-11-20 17:48:54 -04:00
} elseif ( $ext_file == " swf " ) {
$ext_file = " application/x-shockwave-flash " ;
} elseif ( $ext_file == " json " || $ext_file == " htc " ) {
$ext_file = " text/plain " ;
} elseif ( $ext_file == " htm " || $ext_file == " html " || $ext_file == " txt " ) {
$ext_file = " text/html " ;
} elseif ( $ext_file == " doc " || $ext_file == " pdf " || $ext_file == " pm " || $ext_file == " po " ) {
$ext_file = " application/octet-stream " ;
} elseif ( $ext_file == " tar " ) {
$ext_file = " application/x-tar " ;
2014-02-21 01:01:50 -04:00
} elseif ( $ext_file == " woff " ) {
$ext_file = " application/font-woff " ;
} elseif ( $ext_file == " js " ) {
$ext_file = " text/javascript " ;
2014-01-15 11:14:59 -04:00
} elseif ( $ext_file == " css " ) {
//may this line be innecesary, all the .css are been generated at run time
2014-02-21 01:01:50 -04:00
$ext_file = 'text/css' ;
2014-01-15 11:14:59 -04:00
} else {
$ext_file = " application/octet-stream " ;
}
header ( 'Content-Type: ' . $ext_file );
2012-11-20 17:48:54 -04:00
}
header ( 'Pragma: cache' );
$mtime = filemtime ( $requestFile );
2014-01-15 11:14:59 -04:00
$gmt_mtime = gmdate ( " D, d M Y H:i:s " , $mtime ) . " GMT " ;
2015-03-31 15:29:15 -04:00
header ( 'ETag: "' . Bootstrap :: encryptOld ( $mtime . $requestFile ) . '"' );
2014-01-15 11:14:59 -04:00
header ( " Last-Modified: " . $gmt_mtime );
header ( 'Cache-Control: public' );
2012-11-20 17:48:54 -04:00
$userAgent = strtolower ( $_SERVER [ 'HTTP_USER_AGENT' ] );
2014-01-15 11:14:59 -04:00
if ( preg_match ( " /msie/i " , $userAgent )) {
header ( " Expires: " . gmdate ( " D, d M Y H:i:s " , time () + 60 * 10 ) . " GMT " );
} else {
header ( " Expires: " . gmdate ( " D, d M Y H:i:s " , time () + 90 * 60 * 60 * 24 ) . " GMT " );
if ( isset ( $_SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] )) {
if ( $_SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] == $gmt_mtime ) {
header ( 'HTTP/1.1 304 Not Modified' );
}
}
if ( isset ( $_SERVER [ 'HTTP_IF_NONE_MATCH' ] )) {
2015-03-31 15:29:15 -04:00
if ( str_replace ( '"' , '' , stripslashes ( $_SERVER [ 'HTTP_IF_NONE_MATCH' ] ) ) == Bootstrap :: encryptOld ( $mtime . $requestFile )) {
2014-01-15 11:14:59 -04:00
header ( " HTTP/1.1 304 Not Modified " );
2012-11-20 17:48:54 -04:00
}
2014-01-15 11:14:59 -04:00
}
}
2012-11-20 17:48:54 -04:00
readfile ( $requestFile );
die ;
}
2012-11-23 11:52:02 -04:00
2012-11-20 17:48:54 -04:00
// Defining RBAC Paths constants
define ( 'PATH_RBAC_HOME' , PATH_TRUNK . 'rbac' . PATH_SEP );
// 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 );
2017-08-04 11:23:34 -04:00
define ( 'PATH_THIRDPARTY' , PATH_TRUNK . 'thirdparty' . PATH_SEP );
2012-11-20 17:48:54 -04:00
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 );
// Defining PMCore Path constants
define ( 'PATH_CORE' , PATH_HOME . 'engine' . PATH_SEP );
2014-03-14 11:57:27 -04:00
define ( 'PATH_CLASSES' , PATH_HOME . " engine " . PATH_SEP . " classes " . PATH_SEP );
2012-11-20 17:48:54 -04:00
define ( 'PATH_SKINS' , PATH_CORE . 'skins' . PATH_SEP );
define ( 'PATH_SKIN_ENGINE' , PATH_CORE . 'skinEngine' . PATH_SEP );
define ( 'PATH_METHODS' , PATH_CORE . 'methods' . PATH_SEP );
define ( 'PATH_XMLFORM' , PATH_CORE . 'xmlform' . PATH_SEP );
define ( 'PATH_CONFIG' , PATH_CORE . 'config' . PATH_SEP );
define ( 'PATH_PLUGINS' , PATH_CORE . 'plugins' . PATH_SEP );
define ( 'PATH_HTMLMAIL' , PATH_CORE . 'html_templates' . PATH_SEP );
define ( 'PATH_TPL' , PATH_CORE . 'templates' . PATH_SEP );
define ( 'PATH_TEST' , PATH_CORE . 'test' . PATH_SEP );
define ( 'PATH_FIXTURES' , PATH_TEST . 'fixtures' . PATH_SEP );
define ( 'PATH_RTFDOCS' , PATH_CORE . 'rtf_templates' . PATH_SEP );
define ( 'PATH_DYNACONT' , PATH_CORE . 'content' . PATH_SEP . 'dynaform' . PATH_SEP );
//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_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
if ( file_exists ( FILE_PATHS_INSTALLED )) {
// include the server installed configuration
require_once FILE_PATHS_INSTALLED ;
// defining system constant when a valid server 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' );
2012-12-14 16:42:57 -04:00
2012-11-30 15:16:14 -04:00
/* TO DO: put these line in other part of code*/
Bootstrap :: verifyPath ( PATH_SMARTY_C , true );
Bootstrap :: verifyPath ( PATH_SMARTY_CACHE , true );
2012-11-20 17:48:54 -04:00
}
// set include path
set_include_path ( PATH_CORE . PATH_SEPARATOR .
PATH_THIRDPARTY . PATH_SEPARATOR .
PATH_THIRDPARTY . 'pear' . PATH_SEPARATOR .
PATH_RBAC_CORE . PATH_SEPARATOR .
get_include_path ()
);
/**
* Global definitions , before it was the defines . php file
*/
// URL Key
define ( " URL_KEY " , 'c0l0s40pt1mu59r1m3' );
// 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' );
$G_CONTENT = NULL ;
$G_MESSAGE = " " ;
$G_MESSAGE_TYPE = " info " ;
$G_MENU_SELECTED = - 1 ;
$G_MAIN_MENU = " default " ;
// 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 );
// 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' );
2017-08-11 15:11:24 -04:00
G :: defineConstants ();
2014-03-12 18:20:35 -04:00
$config = Bootstrap :: getSystemConfiguration ();
2013-06-12 16:58:48 -04:00
2014-03-12 18:20:35 -04:00
// starting session
if ( isset ( $config [ 'session.gc_maxlifetime' ])) {
2014-03-14 15:53:41 -04:00
$timelife = $config [ 'session.gc_maxlifetime' ];
2014-03-12 18:20:35 -04:00
} else {
2014-03-14 15:53:41 -04:00
$timelife = ini_get ( 'session.gc_maxlifetime' );
2014-03-12 18:20:35 -04:00
}
if ( is_null ( $timelife )) {
2014-03-14 15:53:41 -04:00
$timelife = 1440 ;
2014-03-12 18:20:35 -04:00
}
ini_set ( 'session.gc_maxlifetime' , $timelife );
2014-05-14 13:27:08 -04:00
if (( preg_match ( " /msie/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) != 1 ||
$config [ 'ie_cookie_lifetime' ] == 1 ) &&
( ! ( preg_match ( " /safari/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) == 1 && preg_match ( " /chrome/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) == 0 ) ||
$config [ 'safari_cookie_lifetime' ] == 1 )) {
2014-03-14 15:53:41 -04:00
ini_set ( 'session.cookie_lifetime' , $timelife );
2014-03-12 18:20:35 -04:00
}
2014-06-11 12:33:28 -04:00
session_start ();
2014-03-12 18:20:35 -04:00
2016-09-22 17:25:00 -04:00
if ( ! ( array_key_exists ( 'REMOTE_USER' , $_SERVER ) && ( string )( $_SERVER [ 'REMOTE_USER' ]) != '' )) {
ini_set ( 'session.cookie_httponly' , 1 );
ini_set ( 'session.cookie_secure' , 1 );
}
2014-03-12 18:33:22 -04:00
//$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;
2014-05-23 16:32:18 -04:00
//$e_all = E_ALL & ~ E_DEPRECATED & ~ E_STRICT & ~ E_NOTICE & ~E_WARNING;
2014-03-12 18:20:35 -04:00
// Do not change any of these settings directly, use env.ini instead
2014-03-12 18:33:22 -04:00
ini_set ( 'display_errors' , $config [ 'display_errors' ]);
ini_set ( 'error_reporting' , $config [ 'error_reporting' ]);
2014-03-12 18:20:35 -04:00
ini_set ( 'short_open_tag' , 'On' );
ini_set ( 'default_charset' , " UTF-8 " );
ini_set ( 'memory_limit' , $config [ 'memory_limit' ] );
ini_set ( 'soap.wsdl_cache_enabled' , $config [ 'wsdl_cache' ] );
2015-12-04 16:43:45 -04:00
ini_set ( 'date.timezone' , $config [ 'time_zone' ]); //Set Time Zone
2014-03-12 18:20:35 -04:00
define ( 'DEBUG_SQL_LOG' , $config [ 'debug_sql' ] );
2014-06-17 10:28:54 -04:00
define ( 'DEBUG_SQL' , $config [ 'debug' ] );
2014-03-12 18:20:35 -04:00
define ( 'DEBUG_TIME_LOG' , $config [ 'debug_time' ] );
define ( 'DEBUG_CALENDAR_LOG' , $config [ 'debug_calendar' ] );
define ( 'MEMCACHED_ENABLED' , $config [ 'memcached' ] );
define ( 'MEMCACHED_SERVER' , $config [ 'memcached_server' ] );
2014-06-25 08:50:01 -04:00
define ( 'WS_IN_LOGIN' , isset ( $config [ 'WS_IN_LOGIN' ]) ? $config [ 'WS_IN_LOGIN' ] : 'serverconf' );
2014-06-23 15:12:57 -04:00
2016-11-22 11:47:41 -05:00
define ( 'LOAD_HEADERS_IE' , $config [ 'load_headers_ie' ]);
2016-12-02 14:14:18 -04:00
define ( 'LEAVE_CASE_WARNING' , $config [ 'leave_case_warning' ]);
2016-12-06 10:58:25 -05:00
define ( 'REDIRECT_TO_MOBILE' , $config [ 'redirect_to_mobile' ]);
2017-02-08 16:01:52 -04:00
define ( 'DISABLE_PHP_UPLOAD_EXECUTION' , $config [ 'disable_php_upload_execution' ]);
2017-03-10 10:59:49 -04:00
define ( 'DISABLE_DOWNLOAD_DOCUMENTS_SESSION_VALIDATION' , $config [ 'disable_download_documents_session_validation' ]);
2016-12-02 14:14:18 -04:00
2014-03-12 18:20:35 -04:00
// IIS Compatibility, SERVER_ADDR doesn't exist on that env, so we need to define it.
$_SERVER [ 'SERVER_ADDR' ] = isset ( $_SERVER [ 'SERVER_ADDR' ] ) ? $_SERVER [ 'SERVER_ADDR' ] : $_SERVER [ 'SERVER_NAME' ];
//to do: make different environments. sys
//check if it is a installation instance
if ( ! defined ( 'PATH_C' )) {
2014-03-12 18:33:22 -04:00
// is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily
define ( 'PATH_C' , ( rtrim ( Bootstrap :: sys_get_temp_dir (), PATH_SEP ) . PATH_SEP ) );
define ( 'PATH_LANGUAGECONT' , PATH_HOME . 'engine/content/languages/' );
2014-03-12 18:20:35 -04:00
}
2013-06-12 16:58:48 -04:00
2015-04-10 14:34:40 -04:00
//Load filter class
2014-03-12 18:20:35 -04:00
$skinPathErrors = G :: skinGetPathToSrcByVirtualUri ( " errors " , $config );
$skinPathUpdate = G :: skinGetPathToSrcByVirtualUri ( " update " , $config );
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
// defining Virtual URLs
$virtualURITable = array ();
$virtualURITable [ '/plugin/(*)' ] = 'plugin' ;
2015-12-10 12:53:17 -04:00
$virtualURITable [ '/(sys\w{0,})/(\w{0,}.js)' ] = 'jsMethod' ;
2014-03-12 18:20:35 -04:00
$virtualURITable [ '/js/(*)' ] = PATH_GULLIVER_HOME . 'js/' ;
$virtualURITable [ '/jscore/(*)' ] = PATH_CORE . 'js/' ;
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
if ( defined ( 'PATH_C' )) {
$virtualURITable [ '/jsform/(*.js)' ] = PATH_C . 'xmlform/' ;
$virtualURITable [ '/extjs/(*)' ] = PATH_C . 'ExtJs/' ;
}
2013-06-03 18:13:38 -04:00
2014-03-12 18:20:35 -04:00
$virtualURITable [ '/htmlarea/(*)' ] = PATH_THIRDPARTY . 'htmlarea/' ;
//$virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed';
$virtualURITable [ '/(sys*)' ] = FALSE ;
$virtualURITable [ " /errors/(*) " ] = ( $skinPathErrors != " " ) ? $skinPathErrors : PATH_GULLIVER_HOME . " methods " . PATH_SEP . " errors " . PATH_SEP ;
$virtualURITable [ '/gulliver/(*)' ] = PATH_GULLIVER_HOME . 'methods/' ;
$virtualURITable [ '/controls/(*)' ] = PATH_GULLIVER_HOME . 'methods/controls/' ;
$virtualURITable [ '/html2ps_pdf/(*)' ] = PATH_THIRDPARTY . 'html2ps_pdf/' ;
//$virtualURITable['/images/'] = 'errorFile';
//$virtualURITable['/skins/'] = 'errorFile';
//$virtualURITable['/files/'] = 'errorFile';
$virtualURITable [ " /update/(*) " ] = ( $skinPathUpdate != " " ) ? $skinPathUpdate : PATH_GULLIVER_HOME . " methods " . PATH_SEP . " update " . PATH_SEP ;
//$virtualURITable['/(*)'] = PATH_HTML;
$virtualURITable [ '/css/(*)' ] = PATH_HTML . 'css/' ; //ugly
$virtualURITable [ '/skin/(*)' ] = PATH_HTML ;
$virtualURITable [ '/skins/(*)' ] = PATH_HTML . 'skins/' ; //ugly
$virtualURITable [ '/images/(*)' ] = PATH_HTML . 'images/' ; //ugly
$virtualURITable [ '/[a-zA-Z][a-zA-Z0-9]{0,}/' ] = 'errorFile' ;
// Verify if we need to redirect or stream the file, if G:VirtualURI returns true means we are going to redirect the page
if ( Bootstrap :: virtualURI ( $_SERVER [ 'REQUEST_URI' ], $virtualURITable , $realPath )) {
// review if the file requested belongs to public_html plugin
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 = '' ;
// Get the query side
// Did we use this variable $pathsQuery for something??
$forQuery = explode ( " ? " , $realPath );
if ( isset ( $forQuery [ 1 ] )) {
$pathsQuery = $forQuery [ 1 ];
}
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
//Get that path in array
$paths = explode ( PATH_SEP , $forQuery [ 0 ] );
//remove the "plugin" word from
$paths [ 0 ] = substr ( $paths [ 0 ], 6 );
//Get the Plugin Folder, always the first element
$pluginFolder = array_shift ( $paths );
//The other parts are the realpath into public_html (no matter how many elements)
$filePath = implode ( PATH_SEP , $paths );
$pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html' . PATH_SEP . $filePath ;
if ( file_exists ( $pluginFilename )) {
//NewRelic Snippet - By JHL
transactionLog ( $pluginFilename );
2012-04-09 18:48:44 -04:00
2014-03-12 18:20:35 -04:00
Bootstrap :: streamFile ( $pluginFilename , false , '' , true );
2012-11-20 17:48:54 -04:00
}
2014-03-12 18:20:35 -04:00
die ();
}
2010-12-02 23:34:41 +00:00
2014-03-12 18:20:35 -04:00
$requestUriArray = explode ( " / " , $_SERVER [ 'REQUEST_URI' ] );
2013-08-05 16:40:33 -04:00
2014-03-12 18:20:35 -04:00
if (( isset ( $requestUriArray [ 1 ] )) && ( $requestUriArray [ 1 ] == 'skin' )) {
// This will allow to public images of Custom Skins, By JHL Feb 28, 11
$pathsQuery = " " ;
// Get the query side
// This way we remove garbage
$forQuery = explode ( " ? " , $realPath );
if ( isset ( $forQuery [ 1 ] )) {
$pathsQuery = $forQuery [ 1 ];
}
2012-08-10 16:54:12 -04:00
2014-03-12 18:20:35 -04:00
//Get that path in array
$paths = explode ( PATH_SEP , $forQuery [ 0 ] );
$url = ( preg_match ( " /^(.*) \ ?.* $ / " , $_SERVER [ " REQUEST_URI " ], $arrayMatch )) ? $arrayMatch [ 1 ] : $_SERVER [ " REQUEST_URI " ];
2013-06-03 18:13:38 -04:00
2014-03-12 18:20:35 -04:00
$fileToBeStreamed = str_replace ( " /skin/ " , PATH_CUSTOM_SKINS , $url );
2013-06-12 16:58:48 -04:00
2014-03-12 18:20:35 -04:00
if ( file_exists ( $fileToBeStreamed )) {
//NewRelic Snippet - By JHL
transactionLog ( $fileToBeStreamed );
2013-06-03 18:13:38 -04:00
2014-03-12 18:20:35 -04:00
Bootstrap :: streamFile ( $fileToBeStreamed );
2013-08-23 10:03:45 -04:00
}
2014-03-12 18:20:35 -04:00
die ();
}
2010-12-02 23:34:41 +00:00
2014-03-12 18:20:35 -04:00
switch ( $realPath ) {
case 'jsMethod' :
Bootstrap :: parseURI ( getenv ( " REQUEST_URI " ) );
$filename = PATH_METHODS . SYS_COLLECTION . '/' . SYS_TARGET . '.js' ;
//NewRelic Snippet - By JHL
transactionLog ( $filename );
Bootstrap :: streamFile ( $filename );
die ();
break ;
case 'errorFile' :
2016-06-20 16:04:22 -04:00
header ( 'Status: 404' );
2014-03-12 18:20:35 -04:00
header ( " location: /errors/error404.php?url= " . urlencode ( $_SERVER [ 'REQUEST_URI' ] ) );
if ( DEBUG_TIME_LOG )
Bootstrap :: logTimeByPage (); //log this page
die ();
break ;
default :
//Process files loaded with tag head in HTML
2014-03-14 13:12:48 -04:00
$realPath = explode ( '?' , $realPath );
$realPath [ 0 ] .= strpos ( basename ( $realPath [ 0 ] ), '.' ) === false ? '.php' : '' ;
//NewRelic Snippet - By JHL
transactionLog ( $realPath [ 0 ]);
2014-03-12 18:20:35 -04:00
2014-03-14 13:12:48 -04:00
Bootstrap :: streamFile ( $realPath [ 0 ] );
die ();
2014-03-12 18:20:35 -04:00
}
} //virtual URI parser
2010-12-02 23:34:41 +00:00
2014-03-12 18:20:35 -04:00
// the request correspond to valid php page, now parse the URI
2016-06-07 16:52:49 -04:00
$arrayFriendlyUri = [];
$arrayFriendlyUri [ 'cases/opencase' ] = '/^[\w\-]{32}$/' ;
Bootstrap :: parseURI ( getenv ( 'REQUEST_URI' ), $arrayFriendlyUri );
if ( SYS_TARGET === false ) {
2016-06-20 16:04:22 -04:00
header ( 'Status: 404' );
2016-06-07 16:52:49 -04:00
header ( 'Location: /errors/error404.php?url=' . urlencode ( $_SERVER [ 'REQUEST_URI' ]));
exit ( 0 );
}
2012-08-10 16:54:12 -04:00
2014-03-12 18:20:35 -04:00
// Bootstrap::mylog("sys_temp: ".SYS_TEMP);
2016-07-19 13:41:10 -04:00
$arrayUpdating = Bootstrap :: isPMUnderUpdating ();
if ( $arrayUpdating [ 'action' ]) {
if ( $arrayUpdating [ 'workspace' ] == " true " || $arrayUpdating [ 'workspace' ] == SYS_TEMP ) {
header ( " location: /update/updating.php " );
if ( DEBUG_TIME_LOG )
Bootstrap :: logTimeByPage ();
die ();
}
2014-03-12 18:20:35 -04:00
}
2012-05-15 17:05:47 -04:00
2014-03-12 18:20:35 -04:00
// verify if index.html exists
if ( ! file_exists ( PATH_HTML . 'index.html' )) { // if not, create it from template
2014-08-12 12:27:32 -04:00
file_put_contents ( PATH_HTML . " index.html " , Bootstrap :: parseTemplate ( PATH_TPL . " index.html " , array ( " lang " => (( defined ( " SYS_LANG " ) && SYS_LANG != " " ) ? SYS_LANG : " en " ), " skin " => SYS_SKIN
2014-03-12 18:20:35 -04:00
) ) );
}
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
define ( 'SYS_URI' , '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/' );
2012-03-29 16:42:09 -04:00
2014-03-12 18:20:35 -04:00
// defining the serverConf singleton
if ( defined ( 'PATH_DATA' ) && file_exists ( PATH_DATA )) {
//Instance Server Configuration Singleton
2017-08-14 10:56:14 -04:00
$oServerConf = & ServerConf :: getSingleton ();
2014-03-12 18:20:35 -04:00
}
2017-02-15 16:26:02 +00:00
2014-03-12 18:20:35 -04:00
// Create headPublisher singleton
2017-02-15 16:26:02 +00:00
2014-03-12 18:20:35 -04:00
$oHeadPublisher = & headPublisher :: getSingleton ();
// Installer, redirect to install if we don't have a valid shared data folder
if ( ! defined ( 'PATH_DATA' ) || ! file_exists ( PATH_DATA )) {
// new installer, extjs based
define ( 'PATH_DATA' , PATH_C );
//NewRelic Snippet - By JHL
transactionLog ( PATH_CONTROLLERS . 'installer.php' );
2015-04-10 14:34:40 -04:00
$pathFile = PATH_CONTROLLERS . 'installer.php' ;
require_once ( $pathFile );
2017-08-23 15:39:12 -04:00
$controller = InstallerModule :: class ;
2014-03-12 18:20:35 -04:00
// if the method name is empty set default to index method
if ( strpos ( SYS_TARGET , '/' ) !== false ) {
list ( $controller , $controllerAction ) = explode ( '/' , SYS_TARGET );
} else {
$controllerAction = SYS_TARGET ;
2013-08-23 10:03:45 -04:00
}
2012-03-29 16:42:09 -04:00
2014-03-12 18:20:35 -04:00
$controllerAction = ( $controllerAction != '' && $controllerAction != 'login' ) ? $controllerAction : 'index' ;
// create the installer controller and call its method
2017-08-23 15:39:12 -04:00
if ( is_callable ( Array ( InstallerModule :: class , $controllerAction
2014-03-12 18:20:35 -04:00
) )) {
$installer = new $controller ();
$installer -> setHttpRequestData ( $_REQUEST );
2013-04-22 18:08:13 -04:00
//NewRelic Snippet - By JHL
2014-03-12 18:20:35 -04:00
transactionLog ( $controllerAction );
2013-06-03 18:13:38 -04:00
2014-03-12 18:20:35 -04:00
$installer -> call ( $controllerAction );
} else {
$_SESSION [ 'phpFileNotFound' ] = $_SERVER [ 'REQUEST_URI' ];
2016-06-20 16:04:22 -04:00
header ( 'Status: 404' );
2014-03-12 18:20:35 -04:00
header ( " location: /errors/error404.php?url= " . urlencode ( $_SERVER [ 'REQUEST_URI' ] ) );
}
die ();
}
2012-11-20 17:48:54 -04:00
2017-08-07 13:02:26 -04:00
app () -> useStoragePath ( realpath ( PATH_DATA ));
app () -> make ( Kernel :: class ) -> bootstrap ();
2017-08-31 15:26:44 -04:00
restore_error_handler ();
2017-08-07 13:02:26 -04:00
//Overwrite with the Processmaker env.ini configuration used in production environments
//@todo: move env.ini configuration to .env
ini_set ( 'display_errors' , $config [ 'display_errors' ]);
ini_set ( 'error_reporting' , $config [ 'error_reporting' ]);
ini_set ( 'short_open_tag' , 'On' );
ini_set ( 'default_charset' , " UTF-8 " );
ini_set ( 'memory_limit' , $config [ 'memory_limit' ] );
ini_set ( 'soap.wsdl_cache_enabled' , $config [ 'wsdl_cache' ] );
ini_set ( 'date.timezone' , $config [ 'time_zone' ]); //Set Time Zone
2014-03-12 18:20:35 -04:00
// Load Language Translation
Bootstrap :: LoadTranslationObject ( defined ( 'SYS_LANG' ) ? SYS_LANG : " en " );
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
// look for a disabled workspace
if ( $oServerConf -> isWSDisabled ( SYS_TEMP )) {
$aMessage [ 'MESSAGE' ] = Bootstrap :: LoadTranslation ( 'ID_DISB_WORKSPACE' );
$G_PUBLISH = new Publisher ();
$G_PUBLISH -> AddContent ( 'xmlform' , 'xmlform' , 'login/showMessage' , '' , $aMessage );
Bootstrap :: RenderPage ( 'publish' );
die ();
}
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
// database and workspace definition
// if SYS_TEMP exists, the URL has a workspace, now we need to verify if exists their db.php file
if ( defined ( 'SYS_TEMP' ) && SYS_TEMP != '' ) {
//this is the default, the workspace db.php file is in /shared/workflow/sites/SYS_SYS
2015-04-10 14:34:40 -04:00
$pathFile = PATH_DB . SYS_TEMP . '/db.php' ;
if ( file_exists ( $pathFile )) {
require_once ( $pathFile );
2014-03-12 18:20:35 -04:00
define ( 'SYS_SYS' , SYS_TEMP );
2017-10-10 12:33:25 -04:00
config ([ " system.workspace " => SYS_TEMP ]);
2014-03-12 18:20:35 -04:00
// defining constant for workspace shared directory
2017-10-10 12:33:25 -04:00
define ( 'PATH_WORKSPACE' , PATH_DB . config ( " system.workspace " ) . PATH_SEP );
2014-03-12 18:20:35 -04:00
// including workspace shared classes -> particularlly for pmTables
set_include_path ( get_include_path () . PATH_SEPARATOR . PATH_WORKSPACE );
} else {
if ( SYS_LANG != '' && SYS_SKIN != '' ) {
Bootstrap :: SendTemporalMessage ( 'ID_NOT_WORKSPACE' , " error " );
Bootstrap :: header ( 'location: /sys/' . SYS_LANG . '/' . SYS_SKIN . '/main/sysLogin?errno=2' );
2013-04-22 16:53:46 -04:00
} else {
2016-06-20 16:04:22 -04:00
header ( 'Status: 404' );
2014-03-12 18:20:35 -04:00
header ( 'location: /errors/error404.php?url=' . urlencode ( $_SERVER [ 'REQUEST_URI' ]));
2013-04-22 16:53:46 -04:00
}
2012-11-20 17:48:54 -04:00
die ();
2010-12-02 23:34:41 +00:00
}
2014-03-12 18:20:35 -04:00
} else { //when we are in global pages, outside any valid workspace
if ( SYS_TARGET === 'newSite' ) {
$phpFile = G :: ExpandPath ( 'methods' ) . SYS_COLLECTION . " / " . SYS_TARGET . '.php' ;
//NewRelic Snippet - By JHL
transactionLog ( $phpFile );
require_once ( $phpFile );
2012-11-20 17:48:54 -04:00
die ();
2014-03-12 18:20:35 -04:00
} else {
if ( SYS_TARGET == " dbInfo " ) { //Show dbInfo when no SYS_SYS
2015-04-10 14:34:40 -04:00
$pathFile = PATH_METHODS . " login/dbInfo.php " ;
require_once ( $pathFile );
2012-11-20 17:48:54 -04:00
} else {
2014-03-12 18:20:35 -04:00
if ( substr ( SYS_SKIN , 0 , 2 ) === 'ux' && SYS_TARGET != 'sysLoginVerify' ) { // new ux sysLogin - extjs based form
2017-02-07 12:29:35 -04:00
$pathFile = PATH_CONTROLLERS . 'main.php' ;
2015-04-10 14:34:40 -04:00
require_once $pathFile ;
2014-03-12 18:20:35 -04:00
$controllerClass = 'Main' ;
$controllerAction = SYS_TARGET == 'sysLoginVerify' ? SYS_TARGET : 'sysLogin' ;
//if the method exists
if ( is_callable ( Array ( $controllerClass , $controllerAction
) )) {
$controller = new $controllerClass ();
$controller -> setHttpRequestData ( $_REQUEST );
$controller -> call ( $controllerAction );
2012-11-20 17:48:54 -04:00
}
2014-03-12 18:20:35 -04:00
} else { // classic sysLogin interface
2017-02-07 12:29:35 -04:00
$pathFile = PATH_METHODS . " login/sysLogin.php " ;
2015-04-10 14:34:40 -04:00
require_once ( $pathFile );
2014-03-12 18:20:35 -04:00
die ();
2012-11-20 17:48:54 -04:00
}
}
2014-03-12 18:20:35 -04:00
if ( DEBUG_TIME_LOG )
Bootstrap :: logTimeByPage (); //log this page
die ();
2010-12-02 23:34:41 +00:00
}
2014-03-12 18:20:35 -04:00
}
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
// PM Paths DATA
2017-10-10 12:33:25 -04:00
define ( 'PATH_DATA_SITE' , PATH_DATA . 'sites/' . config ( " system.workspace " ) . '/' );
2014-03-12 18:20:35 -04:00
define ( 'PATH_DOCUMENT' , PATH_DATA_SITE . 'files/' );
define ( 'PATH_DATA_MAILTEMPLATES' , PATH_DATA_SITE . 'mailTemplates/' );
define ( 'PATH_DATA_PUBLIC' , PATH_DATA_SITE . 'public/' );
define ( 'PATH_DATA_REPORTS' , PATH_DATA_SITE . 'reports/' );
define ( 'PATH_DYNAFORM' , PATH_DATA_SITE . 'xmlForms/' );
define ( 'PATH_IMAGES_ENVIRONMENT_FILES' , PATH_DATA_SITE . 'usersFiles' . PATH_SEP );
define ( 'PATH_IMAGES_ENVIRONMENT_USERS' , PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP );
define ( 'SERVER_NAME' , $_SERVER [ 'SERVER_NAME' ] );
define ( 'SERVER_PORT' , $_SERVER [ 'SERVER_PORT' ] );
// create memcached singleton
2017-10-10 12:33:25 -04:00
$memcache = & PMmemcached :: getSingleton ( config ( " system.workspace " ) );
2014-03-12 18:20:35 -04:00
// load Plugins base class
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
// setup propel definitions and logging
//changed to autoloader
2013-08-23 10:03:45 -04:00
2014-03-12 18:20:35 -04:00
if ( defined ( 'DEBUG_SQL_LOG' ) && DEBUG_SQL_LOG ) {
define ( 'PM_PID' , mt_rand ( 1 , 999999 ) );
require_once 'Log.php' ;
2013-08-23 10:03:45 -04:00
2014-03-12 18:20:35 -04:00
// register debug connection decorator driver
Creole :: registerDriver ( '*' , 'creole.contrib.DebugConnection' );
2013-08-23 10:03:45 -04:00
2014-03-12 18:20:35 -04:00
// initialize Propel with converted config file
Propel :: init ( PATH_CORE . " config/databases.php " );
2013-08-23 10:03:45 -04:00
2014-03-12 18:20:35 -04:00
// unified log file for all databases
$logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log' ;
2017-10-10 12:33:25 -04:00
$logger = Log :: singleton ( 'file' , $logFile , 'wf ' . config ( " system.workspace " ), null , PEAR_LOG_INFO );
2014-03-12 18:20:35 -04:00
Propel :: setLogger ( $logger );
// log file for workflow database
$con = Propel :: getConnection ( 'workflow' );
if ( $con instanceof DebugConnection ) {
$con -> setLogger ( $logger );
}
// log file for rbac database
$con = Propel :: getConnection ( 'rbac' );
2013-08-23 10:03:45 -04:00
2014-03-12 18:20:35 -04:00
if ( $con instanceof DebugConnection ) {
$con -> setLogger ( $logger );
}
2010-12-02 23:34:41 +00:00
2014-03-12 18:20:35 -04:00
// log file for report database
$con = Propel :: getConnection ( 'rp' );
if ( $con instanceof DebugConnection ) {
$con -> setLogger ( $logger );
2012-04-09 18:48:44 -04:00
}
2014-03-12 18:20:35 -04:00
} else {
Propel :: init ( PATH_CORE . " config/databases.php " );
}
2010-12-02 23:34:41 +00:00
2017-07-21 16:56:44 -04:00
//here we are loading all plugins registered
//the singleton has a list of enabled plugins
2017-08-10 16:55:51 -04:00
$oPluginRegistry = PluginRegistry :: loadSingleton ();
2017-07-21 16:56:44 -04:00
$attributes = $oPluginRegistry -> getAttributes ();
Bootstrap :: LoadTranslationPlugins ( defined ( 'SYS_LANG' ) ? SYS_LANG : " en " , $attributes );
2015-12-04 16:43:45 -04:00
//Set Time Zone
/*----------------------------------********---------------------------------*/
2017-02-07 12:29:35 -04:00
$_SESSION [ '__SYSTEM_UTC_TIME_ZONE__' ] = ( int )( $config [ 'system_utc_time_zone' ]) == 1 ;
2015-12-04 16:43:45 -04:00
/*----------------------------------********---------------------------------*/
ini_set ( 'date.timezone' , ( isset ( $_SESSION [ '__SYSTEM_UTC_TIME_ZONE__' ]) && $_SESSION [ '__SYSTEM_UTC_TIME_ZONE__' ]) ? 'UTC' : $config [ 'time_zone' ]); //Set Time Zone
define ( 'TIME_ZONE' , ini_get ( 'date.timezone' ));
/*----------------------------------********---------------------------------*/
$_GET = \ProcessMaker\Util\DateTime :: convertDataToUtc ( $_GET );
$_POST = \ProcessMaker\Util\DateTime :: convertDataToUtc ( $_POST );
$_REQUEST = \ProcessMaker\Util\DateTime :: convertDataToUtc ( $_REQUEST );
/*----------------------------------********---------------------------------*/
2014-03-12 18:20:35 -04:00
Creole :: registerDriver ( 'dbarray' , 'creole.contrib.DBArrayConnection' );
2010-12-02 23:34:41 +00:00
2014-03-12 18:20:35 -04:00
// Session Initializations
ini_set ( 'session.auto_start' , '1' );
2012-08-10 16:54:12 -04:00
2014-03-12 18:20:35 -04:00
// The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off.
// ini_set( 'register_globals', 'Off' );
//session_start();
ob_start ();
2012-08-10 16:54:12 -04:00
2014-03-12 18:20:35 -04:00
// Rebuild the base Workflow translations if not exists
if ( ! is_file ( PATH_LANGUAGECONT . 'translation.en' )) {
2017-02-07 12:29:35 -04:00
$pathFile = PATH_CLASSES . " model " . PATH_SEP . " Translation.php " ;
2015-04-21 11:23:32 -04:00
2015-04-10 14:34:40 -04:00
require_once ( $pathFile );
2015-04-21 11:23:32 -04:00
$pmTranslation = new Translation ();
$fields = $pmTranslation -> generateFileTranslation ( " en " );
2017-05-15 13:34:14 -04:00
// Load Language Translation
Bootstrap :: LoadTranslationObject ( " en " );
2014-03-12 18:20:35 -04:00
}
2012-04-09 18:48:44 -04:00
2014-03-12 18:20:35 -04:00
// TODO: Verify if the language set into url is defined in translations env.
if ( SYS_LANG != 'en' && ! is_file ( PATH_LANGUAGECONT . 'translation.' . SYS_LANG )) {
2017-02-07 12:29:35 -04:00
$pathFile = PATH_CLASSES . " model " . PATH_SEP . " Translation.php " ;
2015-04-21 11:23:32 -04:00
2015-04-10 14:34:40 -04:00
require_once ( $pathFile );
2015-04-21 11:23:32 -04:00
$pmTranslation = new Translation ();
$fields = $pmTranslation -> generateFileTranslation ( SYS_LANG );
2017-05-15 13:34:14 -04:00
// Load Language Translation
Bootstrap :: LoadTranslationObject ( SYS_LANG );
2014-03-12 18:20:35 -04:00
}
2010-12-23 22:30:39 +00:00
2017-07-26 16:15:32 -04:00
// Setup plugins
$oPluginRegistry -> setupPlugins (); //get and setup enabled plugins
$avoidChangedWorkspaceValidation = false ;
2014-03-12 18:20:35 -04:00
// Load custom Classes and Model from Plugins.
Bootstrap :: LoadAllPluginModelClasses ();
// jump to php file in methods directory
$collectionPlugin = '' ;
if ( $oPluginRegistry -> isRegisteredFolder ( SYS_COLLECTION )) {
$phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET . '.php' ;
$targetPlugin = explode ( '/' , SYS_TARGET );
$collectionPlugin = $targetPlugin [ 0 ];
$avoidChangedWorkspaceValidation = true ;
} else {
$phpFile = Bootstrap :: ExpandPath ( 'methods' ) . SYS_COLLECTION . PATH_SEP . SYS_TARGET . '.php' ;
}
2010-12-02 23:34:41 +00:00
2014-03-12 18:20:35 -04:00
// services is a special folder,
if ( SYS_COLLECTION == 'services' ) {
$avoidChangedWorkspaceValidation = true ;
$targetPlugin = explode ( '/' , SYS_TARGET );
2012-04-09 18:48:44 -04:00
2014-03-12 18:20:35 -04:00
if ( $targetPlugin [ 0 ] == 'webdav' ) {
$phpFile = Bootstrap :: ExpandPath ( 'methods' ) . SYS_COLLECTION . PATH_SEP . 'webdav.php' ;
2010-12-02 23:34:41 +00:00
}
2014-03-12 18:20:35 -04:00
}
2012-04-09 18:48:44 -04:00
2014-03-12 18:20:35 -04:00
if ( SYS_COLLECTION == 'login' && SYS_TARGET == 'login' ) {
$avoidChangedWorkspaceValidation = true ;
}
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
$bWE = false ;
$isControllerCall = false ;
$isPluginController = false ;
if ( substr ( SYS_COLLECTION , 0 , 8 ) === 'gulliver' ) {
$phpFile = PATH_GULLIVER_HOME . 'methods/' . substr ( SYS_COLLECTION , 8 ) . SYS_TARGET . '.php' ;
} else {
//when the file is part of the public directory of any PROCESS, this a ProcessMaker feature
if ( preg_match ( '/^[0-9][[:alnum:]]+$/' , SYS_COLLECTION ) == 1 ) { //the pattern is /sysSYS/LANG/SKIN/PRO_UID/file
$auxPart = explode ( '/' , $_SERVER [ 'REQUEST_URI' ] );
$aAux = explode ( '?' , $auxPart [ count ( $auxPart ) - 1 ] );
//$extPart = explode ( '.' , $auxPart[ count($auxPart)-1] );
$extPart = explode ( '.' , $aAux [ 0 ] );
$queryPart = isset ( $aAux [ 1 ] ) ? $aAux [ 1 ] : " " ;
$extension = $extPart [ count ( $extPart ) - 1 ];
$phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . urldecode ( $auxPart [ count ( $auxPart ) - 1 ] );
$aAux = explode ( '?' , $phpFile );
$phpFile = $aAux [ 0 ];
if ( $extension != 'php' ) {
//NewRelic Snippet - By JHL
transactionLog ( $phpFile );
2017-03-09 18:24:34 -04:00
Bootstrap :: streamFile ( $phpFile );
2014-03-12 18:20:35 -04:00
die ();
2012-11-20 17:48:54 -04:00
}
2012-04-09 18:48:44 -04:00
2017-03-09 18:24:34 -04:00
$isWebEntry = \ProcessMaker\BusinessModel\WebEntry :: isWebEntry ( SYS_COLLECTION , $phpFile );
if ( \Bootstrap :: getDisablePhpUploadExecution () === 1 && ! $isWebEntry ) {
2017-02-08 16:01:52 -04:00
$message = \G :: LoadTranslation ( 'THE_PHP_FILES_EXECUTION_WAS_DISABLED' );
\Bootstrap :: registerMonologPhpUploadExecution ( 'phpExecution' , 550 , $message , $phpFile );
echo $message ;
die ();
} else {
2017-08-17 12:31:39 -04:00
//Backward compatibility: Preload PmDynaform for old generated webentry files.
class_exists ( 'PmDynaform' );
2017-02-08 16:01:52 -04:00
\Bootstrap :: registerMonologPhpUploadExecution ( 'phpExecution' , 200 , 'Php Execution' , $phpFile );
}
2012-11-20 17:48:54 -04:00
$avoidChangedWorkspaceValidation = true ;
2014-03-12 18:20:35 -04:00
$bWE = true ;
//$phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . $auxPart[ count($auxPart)-1];
2010-12-02 23:34:41 +00:00
}
2011-10-19 12:27:56 -04:00
2014-03-12 18:20:35 -04:00
//erik: verify if it is a Controller Class or httpProxyController Class
if ( is_file ( PATH_CONTROLLERS . SYS_COLLECTION . '.php' )) {
2017-02-15 16:26:02 +00:00
2017-02-07 12:29:35 -04:00
$pathFile = PATH_CONTROLLERS . SYS_COLLECTION . '.php' ;
2015-04-10 14:34:40 -04:00
require_once $pathFile ;
2014-03-12 18:20:35 -04:00
$controllerClass = SYS_COLLECTION ;
//if the method name is empty set default to index method
$controllerAction = SYS_TARGET != '' ? SYS_TARGET : 'index' ;
//if the method exists
if ( is_callable ( Array ( $controllerClass , $controllerAction ) )) {
$isControllerCall = true ;
2012-11-20 17:48:54 -04:00
}
2013-02-07 16:55:06 -04:00
2014-03-12 18:20:35 -04:00
if ( substr ( SYS_SKIN , 0 , 2 ) != " ux " && $controllerClass == " main " ) {
$isControllerCall = false ;
2013-02-07 16:55:06 -04:00
}
2014-03-12 18:20:35 -04:00
}
2013-06-18 11:54:34 -04:00
2014-03-12 18:20:35 -04:00
if ( is_dir ( PATH_PLUGINS . SYS_COLLECTION ) && $oPluginRegistry -> isRegisteredFolder ( SYS_COLLECTION )) {
$pluginName = SYS_COLLECTION ;
$pluginResourceRequest = explode ( '/' , rtrim ( SYS_TARGET , '/' ));
$isPluginController = true ;
2013-06-18 22:14:40 +00:00
2014-03-12 18:20:35 -04:00
if ( $pluginResourceRequest > 0 ) {
$controllerClass = $pluginResourceRequest [ 0 ];
2013-06-18 11:54:34 -04:00
2014-03-12 18:20:35 -04:00
if ( count ( $pluginResourceRequest ) == 1 ) {
$controllerAction = 'index' ;
} else {
$controllerAction = $pluginResourceRequest [ 1 ];
2013-06-18 22:14:40 +00:00
}
2014-03-12 18:20:35 -04:00
}
2013-06-18 11:54:34 -04:00
2014-03-12 18:20:35 -04:00
$pluginControllerPath = PATH_PLUGINS . $pluginName . PATH_SEP . 'controllers' . PATH_SEP ;
2013-06-18 11:54:34 -04:00
2015-04-08 15:47:39 -04:00
$pathFile = $pluginControllerPath . $controllerClass . '.php' ;
if ( is_file ( $pathFile )) {
require_once $pathFile ;
2014-03-12 18:20:35 -04:00
} elseif ( is_file ( $pluginControllerPath . ucfirst ( $controllerClass ) . '.php' )) {
$controllerClass = ucfirst ( $controllerClass );
2015-04-08 15:47:39 -04:00
require_once $pathFile ;
2014-03-12 18:20:35 -04:00
} elseif ( is_file ( $pluginControllerPath . ucfirst ( $controllerClass ) . 'Controller.php' )) {
$controllerClass = ucfirst ( $controllerClass ) . 'Controller' ;
2015-04-08 15:47:39 -04:00
require_once $pathFile ;
2013-06-18 12:20:48 -04:00
}
2014-03-12 18:20:35 -04:00
//if the method exists
if ( is_callable ( array ( $controllerClass , $controllerAction ))) {
$isControllerCall = true ;
2013-06-18 11:54:34 -04:00
}
}
2014-03-14 13:12:48 -04:00
if ( ! $isControllerCall && ! file_exists ( $phpFile )) {
2014-03-12 18:20:35 -04:00
$_SESSION [ 'phpFileNotFound' ] = $_SERVER [ 'REQUEST_URI' ];
2016-06-20 16:04:22 -04:00
header ( 'Status: 404' );
2014-03-12 18:20:35 -04:00
header ( " location: /errors/error404.php?url= " . urlencode ( $_SERVER [ 'REQUEST_URI' ] ) );
2012-11-20 17:48:54 -04:00
die ();
2010-12-02 23:34:41 +00:00
}
2014-03-12 18:20:35 -04:00
}
2012-11-07 17:09:51 -04:00
2014-03-12 18:20:35 -04:00
//redirect to login, if user changed the workspace in the URL
2017-10-10 12:33:25 -04:00
if ( ! $avoidChangedWorkspaceValidation && isset ( $_SESSION [ 'WORKSPACE' ] ) && $_SESSION [ 'WORKSPACE' ] != config ( " system.workspace " )) {
$_SESSION [ 'WORKSPACE' ] = config ( " system.workspace " );
2014-03-12 18:20:35 -04:00
Bootstrap :: SendTemporalMessage ( 'ID_USER_HAVENT_RIGHTS_SYSTEM' , " error " );
// verify if the current skin is a 'ux' variant
$urlPart = substr ( SYS_SKIN , 0 , 2 ) == 'ux' && SYS_SKIN != 'uxs' ? '/main/login' : '/login/login' ;
2017-10-10 12:33:25 -04:00
header ( 'Location: /sys' . config ( " system.workspace " ) . '/' . SYS_LANG . '/' . SYS_SKIN . $urlPart );
2014-03-12 18:20:35 -04:00
die ();
}
// enable rbac
2017-02-15 16:26:02 +00:00
2014-03-12 18:20:35 -04:00
$RBAC = & RBAC :: getSingleton ( PATH_DATA , session_id () );
$RBAC -> sSystem = 'PROCESSMAKER' ;
// define and send Headers for all pages
if ( ! defined ( 'EXECUTE_BY_CRON' )) {
header ( " Expires: " . gmdate ( " D, d M Y H:i:s " , mktime ( 0 , 0 , 0 , date ( 'm' ), date ( 'd' ) - 1 , date ( 'Y' ) ) ) . " GMT " );
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " );
header ( " Cache-Control: no-store, no-cache, must-revalidate " );
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " );
// get the language direction from ServerConf
define ( 'SYS_LANG_DIRECTION' , $oServerConf -> getLanDirection () );
if (( isset ( $_SESSION [ 'USER_LOGGED' ] )) && ( ! ( isset ( $_GET [ 'sid' ] )))) {
2014-05-14 13:27:08 -04:00
if (( preg_match ( " /msie/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) != 1 ||
$config [ 'ie_cookie_lifetime' ] == 1 ) &&
( ! ( preg_match ( " /safari/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) == 1 && preg_match ( " /chrome/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) == 0 ) ||
$config [ 'safari_cookie_lifetime' ] == 1 )) {
2014-03-12 18:20:35 -04:00
if ( PHP_VERSION < 5.2 ) {
setcookie ( session_name (), session_id (), time () + $timelife , '/' , '; HttpOnly' );
} else {
2016-06-23 15:14:15 -04:00
setcookie ( session_name (), session_id (), time () + $timelife , '/' , null , G :: is_https (), true );
2013-08-23 10:03:45 -04:00
}
2014-03-12 18:20:35 -04:00
}
$RBAC -> initRBAC ();
//using optimization with memcache, the user data will be in memcache 8 hours, or until session id goes invalid
$memKey = 'rbacSession' . session_id ();
if (( $RBAC -> aUserInfo = $memcache -> get ( $memKey )) === false ) {
$RBAC -> loadUserRolePermission ( $RBAC -> sSystem , $_SESSION [ 'USER_LOGGED' ] );
$memcache -> set ( $memKey , $RBAC -> aUserInfo , PMmemcached :: EIGHT_HOURS );
}
} else {
// this is the blank list to allow execute scripts with no login (without session started)
$noLoginFiles = $noLoginFolders = array ();
$noLoginFiles [] = 'login' ;
$noLoginFiles [] = 'authentication' ;
2016-05-19 14:52:24 -04:00
$noLoginFiles [] = 'authenticationSso' ;
2014-03-12 18:20:35 -04:00
$noLoginFiles [] = 'login_Ajax' ;
$noLoginFiles [] = 'dbInfo' ;
$noLoginFiles [] = 'sysLoginVerify' ;
$noLoginFiles [] = 'processes_Ajax' ;
$noLoginFiles [] = 'showLogoFile' ;
$noLoginFiles [] = 'forgotPassword' ;
$noLoginFiles [] = 'retrivePassword' ;
$noLoginFiles [] = 'steps_Ajax' ;
$noLoginFiles [] = 'proxyCasesList' ;
2015-04-21 12:16:22 -04:00
$noLoginFiles [] = 'proxyNewCasesList' ;
2014-03-12 18:20:35 -04:00
$noLoginFiles [] = 'casesStartPage_Ajax' ;
$noLoginFiles [] = 'cases_Ajax' ;
$noLoginFiles [] = 'casesList_Ajax' ;
$noLoginFiles [] = 'proxyReassignCasesList' ;
$noLoginFiles [] = 'ajaxListener' ;
$noLoginFiles [] = 'cases_Step' ;
$noLoginFiles [] = 'cases_ShowOutputDocument' ;
2017-03-10 10:59:49 -04:00
$noLoginFiles [] = 'cases_ShowDocument' ;
2014-03-12 18:20:35 -04:00
$noLoginFiles [] = 'cases_CatchExecute' ;
$noLoginFiles [] = 'cases_SaveData' ;
$noLoginFiles [] = 'cases_Derivate' ;
$noLoginFiles [] = 'cases_NextStep' ;
$noLoginFiles [] = 'genericAjax' ;
$noLoginFiles [] = 'casesSaveDataView' ;
2014-12-03 13:42:09 -04:00
$noLoginFiles [] = 'propelTableAjax' ;
$noLoginFiles [] = 'licenseUpdate' ;
2015-02-25 13:48:45 -04:00
$noLoginFiles [] = 'casesStreamingFile' ;
2017-01-18 16:38:39 -04:00
$noLoginFiles [] = 'opencase' ;
2017-05-05 12:25:12 -04:00
$noLoginFiles [] = 'defaultAjaxDynaform' ;
2014-03-12 18:20:35 -04:00
$noLoginFolders [] = 'services' ;
$noLoginFolders [] = 'tracker' ;
$noLoginFolders [] = 'installer' ;
// This sentence is used when you lost the Session
2014-03-14 13:12:48 -04:00
if ( ! in_array ( SYS_TARGET , $noLoginFiles ) && ! in_array ( SYS_COLLECTION , $noLoginFolders ) && $bWE != true && $collectionPlugin != 'services' ) {
2014-03-12 18:20:35 -04:00
$bRedirect = true ;
if ( isset ( $_GET [ 'sid' ] )) {
$oSessions = new Sessions ();
if ( $aSession = $oSessions -> verifySession ( $_GET [ 'sid' ] )) {
2015-07-06 16:55:09 -04:00
require_once 'classes/model/Users.php' ;
2014-03-12 18:20:35 -04:00
$oUser = new Users ();
$aUser = $oUser -> load ( $aSession [ 'USR_UID' ] );
2017-10-13 07:57:22 -04:00
initUserSession (
$_SESSION [ 'USER_LOGGED' ],
$aUser [ 'USR_USERNAME' ]
);
2014-03-12 18:20:35 -04:00
$bRedirect = false ;
2014-05-14 13:27:08 -04:00
if (( preg_match ( " /msie/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) != 1 ||
$config [ 'ie_cookie_lifetime' ] == 1 ) &&
( ! ( preg_match ( " /safari/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) == 1 && preg_match ( " /chrome/i " , $_SERVER [ 'HTTP_USER_AGENT' ]) == 0 ) ||
$config [ 'safari_cookie_lifetime' ] == 1 )) {
2014-03-12 18:20:35 -04:00
if ( PHP_VERSION < 5.2 ) {
setcookie ( session_name (), session_id (), time () + $timelife , '/' , '; HttpOnly' );
} else {
2016-06-23 15:14:15 -04:00
setcookie ( session_name (), session_id (), time () + $timelife , '/' , null , G :: is_https (), true );
2013-08-23 10:03:45 -04:00
}
2013-02-22 10:38:53 -04:00
}
2014-03-12 18:20:35 -04:00
$RBAC -> initRBAC ();
$RBAC -> loadUserRolePermission ( $RBAC -> sSystem , $_SESSION [ 'USER_LOGGED' ] );
$memKey = 'rbacSession' . session_id ();
$memcache -> set ( $memKey , $RBAC -> aUserInfo , PMmemcached :: EIGHT_HOURS );
2012-11-20 17:48:54 -04:00
}
2014-03-12 18:20:35 -04:00
}
2012-11-20 17:48:54 -04:00
2017-10-11 14:20:59 -04:00
if ( isset ( $_GET [ 'tracker_designer' ]) && intval ( $_GET [ 'tracker_designer' ]) !== 1 ) {
unset ( $_GET [ 'tracker_designer' ]);
}
if ( $bRedirect && ( ! isset ( $_GET [ 'tracker_designer' ]) || ( ! isset ( $_SESSION [ 'CASE' ]) && ! isset ( $_SESSION [ 'PIN' ])))) {
2017-10-11 12:56:52 -04:00
if ( substr ( SYS_SKIN , 0 , 2 ) === 'ux' && SYS_SKIN !== 'uxs' ) { // verify if the current skin is a 'ux' variant
2014-03-12 18:20:35 -04:00
$loginUrl = 'main/login' ;
2017-10-11 12:56:52 -04:00
} else if ( strpos ( $_SERVER [ 'REQUEST_URI' ], '/home' ) !== false ) { //verify is it is using the uxs skin for simplified interface
2014-03-12 18:20:35 -04:00
$loginUrl = 'home/login' ;
} else {
$loginUrl = 'login/login' ; // just set up the classic login
}
2012-11-20 17:48:54 -04:00
2017-10-11 12:56:52 -04:00
if ( empty ( $_POST )) {
header ( 'location: ' . SYS_URI . $loginUrl . '?u=' . urlencode ( $_SERVER [ 'REQUEST_URI' ]));
2012-11-20 17:48:54 -04:00
2014-03-12 18:20:35 -04:00
} else {
if ( $isControllerCall ) {
2017-10-11 12:56:52 -04:00
header ( " HTTP/1.0 302 session lost in controller " );
2012-11-20 17:48:54 -04:00
} else {
2017-10-11 12:56:52 -04:00
header ( 'location: ' . SYS_URI . $loginUrl );
2012-11-20 17:48:54 -04:00
}
}
2014-03-12 18:20:35 -04:00
die ();
2012-03-29 16:42:09 -04:00
}
2010-12-02 23:34:41 +00:00
}
2014-03-12 18:20:35 -04:00
}
$_SESSION [ 'phpLastFileFound' ] = $_SERVER [ 'REQUEST_URI' ];
2017-08-23 16:14:48 -04:00
// Initialization functions plugins
$oPluginRegistry -> init ();
2014-03-12 18:20:35 -04:00
/**
* New feature for Gulliver framework to support Controllers & HttpProxyController classes handling
*
* @ author < erik @ colosa . com
*/
if ( $isControllerCall ) { //Instance the Controller object and call the request method
$controller = new $controllerClass ();
$controller -> setHttpRequestData ( $_REQUEST ); //NewRelic Snippet - By JHL
transactionLog ( $controllerAction );
if ( $isPluginController ) {
$controller -> setPluginName ( $pluginName );
$controller -> setPluginHomeDir ( PATH_PLUGINS . $pluginName . PATH_SEP );
2013-08-23 10:03:45 -04:00
}
2011-10-19 12:27:56 -04:00
2014-03-12 18:20:35 -04:00
$controller -> call ( $controllerAction );
} else {
//NewRelic Snippet - By JHL
transactionLog ( $phpFile );
require_once $phpFile ;
}
2012-04-09 18:48:44 -04:00
2014-03-12 18:20:35 -04:00
if ( defined ( 'SKIP_HEADERS' )) {
header ( " Expires: " . gmdate ( " D, d M Y H:i:s " , mktime ( 0 , 0 , 0 , date ( 'm' ), date ( 'd' ), date ( 'Y' ) + 1 ) ) . " GMT " );
header ( 'Cache-Control: public' );
header ( 'Pragma: ' );
}
ob_end_flush ();
if ( DEBUG_TIME_LOG ) {
bootstrap :: logTimeByPage (); //log this page
2012-08-10 16:54:12 -04:00
}
2012-11-20 17:48:54 -04:00
}