BUG 0000 Some Fixes like unversioning index.html, cleaning up of sysGeneric

This commit is contained in:
Erik Amaru Ortiz
2012-04-09 18:48:44 -04:00
parent abc8f00daa
commit 32eace4cee
10 changed files with 453 additions and 293 deletions

View File

@@ -2066,7 +2066,7 @@ function run_workspace_backup($task, $args) {
//new db restore rotines, by Erik <erik@colosa.com> on May 17th, 2010 //new db restore rotines, by Erik <erik@colosa.com> on May 17th, 2010
//set the temporal directory for all tables into wf, rb, and rp databases //set the temporal directory for all tables into wf, rb, and rp databases
$tmpDir = G::getSysTemDir() . PATH_SEP . 'pmDbBackup' . PATH_SEP; $tmpDir = G::sys_get_temp_dir() . PATH_SEP . 'pmDbBackup' . PATH_SEP;
//create the db maintenance temporal dir //create the db maintenance temporal dir
G::mk_dir($tmpDir); G::mk_dir($tmpDir);

View File

@@ -914,6 +914,12 @@ class G
*/ */
function parseURI($uri, $config = array()) 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.
if (get_magic_quotes_gpc() === 1) {
$_POST = G::strip_slashes($_POST);
}
$aRequestUri = explode('/', $uri ); $aRequestUri = explode('/', $uri );
if ( substr ( $aRequestUri[1], 0, 3 ) == 'sys' ) { if ( substr ( $aRequestUri[1], 0, 3 ) == 'sys' ) {
@@ -992,6 +998,42 @@ class G
} }
} }
function strip_slashes($vVar) {
if (is_array($vVar)) {
foreach($vVar as $sKey => $vValue) {
if (is_array($vValue)) {
G::strip_slashes($vVar[$sKey]);
}
else {
$vVar[$sKey] = stripslashes($vVar[$sKey]);
}
}
}
else {
$vVar = stripslashes($vVar);
}
return $vVar;
}
/**
* function to calculate the time used to render a page
*/
function logTimeByPage()
{
if (!defined(PATH_DATA)) {
return false;
}
$serverAddr = $_SERVER['SERVER_ADDR'];
global $startingTime;
$endTime = microtime(true);
$time = $endTime - $startingTime;
$fpt= fopen ( PATH_DATA . 'log/time.log', 'a' );
fwrite( $fpt, sprintf ( "%s.%03d %15s %s %5.3f %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), substr($serverAddr,-4), $time, $_SERVER['REQUEST_URI'] ));
fclose( $fpt);
}
/** /**
* streaming a big JS file with small js files * streaming a big JS file with small js files
* *
@@ -3138,7 +3180,7 @@ $output = $outputHeader.$output;
* Get the temporal directory path on differents O.S. i.e. /temp -> linux, C:/Temp -> win * Get the temporal directory path on differents O.S. i.e. /temp -> linux, C:/Temp -> win
* @author <erik@colosa.com> * @author <erik@colosa.com>
*/ */
function getSysTemDir() { function sys_get_temp_dir() {
if ( !function_exists('sys_get_temp_dir') ){ if ( !function_exists('sys_get_temp_dir') ){
// Based on http://www.phpit.net/ // Based on http://www.phpit.net/
// article/creating-zip-tar-archives-dynamically-php/2/ // article/creating-zip-tar-archives-dynamically-php/2/
@@ -4922,6 +4964,56 @@ function getDirectorySize($path,$maxmtime=0)
file_put_contents($file, $content); file_put_contents($file, $content);
} }
function verifyWriteAccess($resources)
{
$noWritable = array();
foreach ($resources as $i => $resource) {
if (!is_writable($resource)) {
$noWritable[] = $resource;
}
}
if (count($noWritable) > 0) {
$e = new Exception("Write access not allowed for ProcessMaker resources");
$e->files = $noWritable;
throw $e;
}
}
function renderTemplate($template, $data=array())
{
if (!defined('PATH_THIRDPARTY')) {
throw new Exception('System constant (PATH_THIRDPARTY) is not defined!');
}
require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_dir = G::sys_get_temp_dir();
$smarty->cache_dir = G::sys_get_temp_dir();
$smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs';
$smarty->template_dir = PATH_TEMPLATE;
$smarty->force_compile = true;
foreach ($data as $key => $value) {
$smarty->assign($key, $value);
}
$smarty->display("$template.tpl");
}
function parseTemplate($template, $data=array())
{
$content = '';
ob_start();
G::renderTemplate($template, $data);
$content = ob_get_contents();
ob_get_clean();
return $content;
}
}; };
/** /**

View File

@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="robots" content="noindex,nofollow" />
<title>Whoops, looks like something went wrong.</title>
<style>
{literal}
/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
html { background: #eee; padding: 10px }
body { font: 11px Verdana, Arial, sans-serif; color: #333 }
img { border: 0; }
.clear { clear:both; height:0; font-size:0; line-height:0; }
.clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
.clear_fix { display:inline-block; }
* html .clear_fix { height:1%; }
.clear_fix { display:block; }
#content { width:970px; margin:0 auto; }
.exceptionreset, .exceptionreset .block { margin: auto }
.exceptionreset abbr { border-bottom: 1px dotted #000; cursor: help; }
.exceptionreset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
.exceptionreset strong { font-weight:bold; }
.exceptionreset a { color:#6c6159; }
.exceptionreset a img { border:none; }
.exceptionreset a:hover { text-decoration:underline; }
.exceptionreset em { font-style:italic; }
.exceptionreset h1, .exceptionreset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
.exceptionreset h2 span { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; }
.exceptionreset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
.exceptionreset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
-webkit-border-bottom-right-radius: 16px;
-webkit-border-bottom-left-radius: 16px;
-moz-border-radius-bottomright: 16px;
-moz-border-radius-bottomleft: 16px;
border-bottom-right-radius: 16px;
border-bottom-left-radius: 16px;
border-bottom:1px solid #ccc;
border-right:1px solid #ccc;
border-left:1px solid #ccc;
}
.exceptionreset .block_exception { background-color:#ddd; color: #333; padding:20px;
-webkit-border-top-left-radius: 16px;
-webkit-border-top-right-radius: 16px;
-moz-border-radius-topleft: 16px;
-moz-border-radius-topright: 16px;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
border-top:1px solid #ccc;
border-right:1px solid #ccc;
border-left:1px solid #ccc;
}
.exceptionreset li a { background:none; color:#868686; text-decoration:none; }
.exceptionreset li a:hover { background:none; color:#313131; text-decoration:underline; }
.exceptionreset ol { padding: 10px 0; }
.exceptionreset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
border: 1px solid #ccc;
}
{/literal}
</style>
</head>
<body>
<div id="content" class="exceptionreset">
<h1>ProcessMaker Start, looks like something went wrong.</h1>
<div class="block_exception clear_fix"><h2>
<abbr title="RuntimeException">RuntimeException</abbr>:
Unable to write on ProcessMaker directories, change permissions to run properly.</h2>
</div>
<div class="block">
<ol class="traces list_exception">
{foreach from=$files item=file}
<li>at <abbr title="{$file}">{$file}</abbr> .... <font color="red">not writable.</font></li>
{/foreach}
</ol>
</div>
</div>
</body>
</html>

View File

@@ -142,7 +142,7 @@ class Sessions {
*/ */
public function registerGlobal($name, $value) public function registerGlobal($name, $value)
{ {
$this->tmpfile = G::getSysTemDir() . PATH_SEP . "pm-rg-{$this->sessionId}"; $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
if($this->sessionId == NULL){ if($this->sessionId == NULL){
throw new Exception('session id was not set.'); throw new Exception('session id was not set.');
@@ -180,7 +180,7 @@ class Sessions {
*/ */
public function getGlobal($name) public function getGlobal($name)
{ {
$this->tmpfile = G::getSysTemDir() . PATH_SEP . "pm-rg-{$this->sessionId}"; $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
if($this->sessionId == NULL){ if($this->sessionId == NULL){
throw new Exception('session id was not set.'); throw new Exception('session id was not set.');
@@ -217,7 +217,7 @@ class Sessions {
*/ */
public function getGlobals() public function getGlobals()
{ {
$this->tmpfile = G::getSysTemDir() . PATH_SEP . "pm-rg-{$this->sessionId}"; $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
if($this->sessionId == NULL){ if($this->sessionId == NULL){
throw new Exception('session id was not set.'); throw new Exception('session id was not set.');
@@ -250,7 +250,7 @@ class Sessions {
if($this->sessionId == NULL){ if($this->sessionId == NULL){
throw new Exception('session id was not set.'); throw new Exception('session id was not set.');
} }
$this->tmpfile = G::getSysTemDir() . PATH_SEP . "pm-rg-{$this->sessionId}"; $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
@unlink($this->tmpfile); @unlink($this->tmpfile);
} }

View File

@@ -1240,8 +1240,8 @@ case "removeUserFromGroup" :
if ( isset($_FILES['form']) ) { if ( isset($_FILES['form']) ) {
foreach ($_FILES['form']['name'] as $sFieldName => $vValue) { foreach ($_FILES['form']['name'] as $sFieldName => $vValue) {
if ( $_FILES['form']['error'][$sFieldName] == 0 ){ if ( $_FILES['form']['error'][$sFieldName] == 0 ){
file_put_contents(G::getSysTemDir().PATH_SEP.$_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName])); file_put_contents(G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName]));
$filename = G::getSysTemDir().PATH_SEP.$_FILES['form']['name'][$sFieldName]; $filename = G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName];
} }
} }
} }

View File

@@ -3,6 +3,6 @@
<title>Redirector</title> <title>Redirector</title>
<meta http-equiv="PRAGMA" content="NO-CACHE" /> <meta http-equiv="PRAGMA" content="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" content="NO-STORE" /> <meta http-equiv="CACHE-CONTROL" content="NO-STORE" />
<meta http-equiv="REFRESH" content="0;URL=/sys/{lang}/{skin}/login/login" /> <meta http-equiv="REFRESH" content="0;URL=/sys/{$lang}/{$skin}/login/login" />
</head> </head>
</html> </html>

View File

@@ -36,8 +36,8 @@
if ( isset($_FILES['form']) ) { if ( isset($_FILES['form']) ) {
foreach ($_FILES['form']['name'] as $sFieldName => $vValue) { foreach ($_FILES['form']['name'] as $sFieldName => $vValue) {
if ( $_FILES['form']['error'][$sFieldName] == 0 ){ if ( $_FILES['form']['error'][$sFieldName] == 0 ){
file_put_contents(G::getSysTemDir().PATH_SEP.$_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName])); file_put_contents(G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName]));
$fpath = G::getSysTemDir().PATH_SEP.$_FILES['form']['name'][$sFieldName]; $fpath = G::sys_get_temp_dir().PATH_SEP.$_FILES['form']['name'][$sFieldName];
if( isset($_POST['INPUTS'][$sFieldName]) && $_POST['INPUTS'][$sFieldName] != '' ){ #input file type if( isset($_POST['INPUTS'][$sFieldName]) && $_POST['INPUTS'][$sFieldName] != '' ){ #input file type
ws_sendFile($fpath, $USR_UID, $caseId, 1, $_POST['INPUTS'][$sFieldName]); ws_sendFile($fpath, $USR_UID, $caseId, 1, $_POST['INPUTS'][$sFieldName]);

View File

@@ -268,7 +268,7 @@
$t->is( $methods[89] , 'pr' ,$i++. ' pr'); $t->is( $methods[89] , 'pr' ,$i++. ' pr');
$t->is( $methods[90] , 'dump' ,$i++. ' dump'); $t->is( $methods[90] , 'dump' ,$i++. ' dump');
$t->is( $methods[91] , 'stripCDATA' ,$i++. ' stripCDATA'); $t->is( $methods[91] , 'stripCDATA' ,$i++. ' stripCDATA');
$t->is( $methods[92] , 'getSysTemDir' ,$i++. ' getSysTemDir'); $t->is( $methods[92] , 'sys_get_temp_dir' ,$i++. ' sys_get_temp_dir');
$t->is( $methods[93] , 'PMWSCompositeResponse' ,$i++. ' PMWSCompositeResponse'); $t->is( $methods[93] , 'PMWSCompositeResponse' ,$i++. ' PMWSCompositeResponse');
$t->is( $methods[94] , 'emailAddress' ,$i++. ' emailAddress'); $t->is( $methods[94] , 'emailAddress' ,$i++. ' emailAddress');
$t->is( count( $methods ) , --$i , count( $methods ).' = '.$i.' ok'); $t->is( count( $methods ) , --$i , count( $methods ).' = '.$i.' ok');

View File

@@ -1,8 +0,0 @@
<html>
<head>
<title>Redirector</title>
<meta http-equiv="PRAGMA" content="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" content="NO-STORE" />
<meta http-equiv="REFRESH" content="0;URL=sys/en/classic/login/login" />
</head>
</html>

View File

@@ -1,176 +1,159 @@
<?php <?php
//sysGeneric, this file is used initialize main variables and redirect to each and all pages /**
$startingTime = microtime(true); * sysGeneric.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
//*** process the $_POST with magic_quotes enabled /**
function strip_slashes(&$vVar) { * sysGeneric - ProcessMaker Bootstrap
if (is_array($vVar)) { * this file is used initialize main variables and redirect to each and all pages
foreach($vVar as $sKey => $vValue) { */
if (is_array($vValue)) {
strip_slashes($vVar[$sKey]);
}
else {
$vVar[$sKey] = stripslashes($vVar[$sKey]);
}
}
}
else {
$vVar = stripslashes($vVar);
}
}
// The magic_quotes_gpc feature has been DEPRECATED as of PHP 5.3.0.
// if (ini_get('magic_quotes_gpc') == '1') {
if (get_magic_quotes_gpc() === 1) {
strip_slashes($_POST);
}
//******** function to calculate the time used to render this page ***** $startingTime = microtime(true);
function logTimeByPage() {
$serverAddr = $_SERVER['SERVER_ADDR'];
global $startingTime;
$endTime = microtime(true);
$time = $endTime - $startingTime;
$fpt= fopen ( PATH_DATA . 'log/time.log', 'a' );
fwrite( $fpt, sprintf ( "%s.%03d %15s %s %5.3f %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), substr($serverAddr,-4), $time, $_SERVER['REQUEST_URI'] ));
fclose( $fpt);
}
//******** defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/' ************************** // Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/'
define('PATH_SEP', '/'); define('PATH_SEP', '/');
//***************** Defining the Home Directory ********************************* // Defining the Home Directory
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']); $realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$docuroot = explode ( PATH_SEP , $realdocuroot ); $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); array_pop($docuroot);
$pathOutTrunk = implode( PATH_SEP, $docuroot ) . PATH_SEP ; $pathhome = implode(PATH_SEP, $docuroot) . PATH_SEP;
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
define('PATH_HOME', $pathhome ); // try to find automatically the trunk directory where are placed the RBAC and Gulliver directories
define('PATH_TRUNK', $pathTrunk ); // in a normal installation you don't need to change it.
define('PATH_OUTTRUNK', $pathOutTrunk ); array_pop($docuroot);
$pathTrunk = implode(PATH_SEP, $docuroot) . PATH_SEP ;
//////////////////////////// start, from paths.php array_pop($docuroot);
$pathOutTrunk = implode(PATH_SEP, $docuroot) . PATH_SEP ;
/* Default configuration values (do not change these, use env.ini) */ define('PATH_HOME', $pathhome);
// $default_config = array( define('PATH_TRUNK', $pathTrunk);
// 'debug' => 0, define('PATH_OUTTRUNK', $pathOutTrunk);
// 'debug_sql' => 0,
// 'debug_time' => 0,
// 'debug_calendar' => 0,
// 'wsdl_cache' => 1,
// 'memory_limit' => '100M',
// 'time_zone' => 'America/La_Paz',
// 'memcached' => 0,
// 'memcached_server' => ''
// );
// /* Read the env.ini */
// $env_file = realpath($pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini');
// $config = $default_config;
// if ($env_file !== false && file_exists($env_file)) {
// $ini_contents = parse_ini_file($env_file, false);
// if ($ini_contents !== false)
// $config = array_merge($default_config, $ini_contents);
// }
//var_dump($pathhome . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php'); die;
require_once $pathhome . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php'; require_once $pathhome . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
$config = System::getSystemConfiguration($pathhome . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini'); $config = System::getSystemConfiguration($pathhome . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini');
$e_all = defined('E_DEPRECATED') ? E_ALL ^ E_DEPRECATED : E_ALL;
//*** Do not change any of these settings directly, use env.ini instead // Do not change any of these settings directly, use env.ini instead
ini_set('display_errors','On'); ini_set('display_errors','On');
ini_set('short_open_tag', 'on'); ini_set('short_open_tag', 'on');
ini_set('asp_tags', 'on'); ini_set('asp_tags', 'on');
// The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off.
// ini_set('register_globals', 'off');
ini_set('default_charset', "UTF-8"); ini_set('default_charset', "UTF-8");
$e_all = defined('E_DEPRECATED') ? E_ALL ^ E_DEPRECATED : E_ALL; ini_set('error_reporting', ($config['debug'] ? $e_all : $e_all ^ E_NOTICE));
ini_set('error_reporting', ($config['debug'] ? $e_all : $e_all ^ E_NOTICE) );
ini_set('memory_limit', $config['memory_limit']); ini_set('memory_limit', $config['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']); ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']);
define ('DEBUG_SQL_LOG', $config['debug_sql'] ); define ('DEBUG_SQL_LOG', $config['debug_sql']);
define ('DEBUG_TIME_LOG', $config['debug_time'] ); define ('DEBUG_TIME_LOG', $config['debug_time']);
define ('DEBUG_CALENDAR_LOG', $config['debug_calendar'] ); define ('DEBUG_CALENDAR_LOG', $config['debug_calendar']);
define ('MEMCACHED_ENABLED', $config['memcached']); define ('MEMCACHED_ENABLED', $config['memcached']);
define ('MEMCACHED_SERVER', $config['memcached_server']); define ('MEMCACHED_SERVER', $config['memcached_server']);
define ('TIME_ZONE', $config['time_zone']); define ('TIME_ZONE', $config['time_zone']);
//////////////////////////// end, from paths.php
// 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);
if (defined('PATH_DATA')) {
$writableDirs[] = PATH_DATA;
}
if (defined('PATH_LANGUAGECONT')) {
$writableDirs[] = PATH_LANGUAGECONT;
}
try {
G::verifyWriteAccess($writableDirs);
}
catch (Exception $e) {
G::renderTemplate('write_access_denied.exception', array('files' => $e->files));
die();
}
// end permissions verification
//************* 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' );
//******************* Error handler and log error *******************
//to do: make different environments. sys //to do: make different environments. sys
//G::setErrorHandler ( );
//G::setFatalErrorHandler ( );
define ('ERROR_SHOW_SOURCE_CODE', true); // enable ERROR_SHOW_SOURCE_CODE to display the source code for any WARNING OR NOTICE define ('ERROR_SHOW_SOURCE_CODE', true); // enable ERROR_SHOW_SOURCE_CODE to display the source code for any WARNING OR NOTICE
//define ( 'ERROR_LOG_NOTICE_ERROR', true ); //enable ERROR_LOG_NOTICE_ERROR to log Notices messages in default apache log //define ( 'ERROR_LOG_NOTICE_ERROR', true ); //enable ERROR_LOG_NOTICE_ERROR to log Notices messages in default apache log
// ***** create headPublisher singleton ***************** // Create headPublisher singleton
G::LoadSystem('headPublisher'); G::LoadSystem('headPublisher');
$oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher =& headPublisher::getSingleton();
// ***** defining the maborak js file, this file is the concat of many js files and here we are including all of them **** // Defining the maborak js file, this file is the concat of many js files and here we are including all of them.
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/maborak.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/maborak.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/common.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/common.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/effects.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/effects.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/webResource.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/core/webResource.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'dveditor/core/dveditor.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'dveditor/core/dveditor.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/tree/tree.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'common/tree/tree.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'json/core/json.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'json/core/json.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/form.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/form.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/pagedTable.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'form/core/pagedTable.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'grid/core/grid.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'grid/core/grid.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.panel.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.panel.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.validator.js', true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.validator.js', true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.app.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.app.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.rpc.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.rpc.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.fx.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.fx.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drag.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drag.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drop.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.drop.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dom.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dom.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.abbr.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.abbr.js' , true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dashboard.js', true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dashboard.js', true );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/js-calendar/js-calendar.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/js-calendar/js-calendar.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/suggest/bsn.AutoSuggest_2.1.3.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/suggest/bsn.AutoSuggest_2.1.3.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/tooltip/pmtooltip.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/tooltip/pmtooltip.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'thirdparty/krumo/krumo.js' ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'thirdparty/krumo/krumo.js' );
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/calendar/pmcalendar.js' , true ); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/calendar/pmcalendar.js' , true );
$oHeadPublisher->addMaborakFile( PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases.js' , true ); $oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases.js' , true );
$oHeadPublisher->addMaborakFile( PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases_Step.js', true ); $oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases_Step.js', true );
$oHeadPublisher->addMaborakFile( PATH_CORE . 'js' . PATH_SEP . 'processmap/core/processmap.js', true ); $oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'processmap/core/processmap.js', true );
$oHeadPublisher->addMaborakFile( PATH_CORE . 'js' . PATH_SEP . 'appFolder/core/appFolderList.js', true ); $oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'appFolder/core/appFolderList.js', true );
$oHeadPublisher->addMaborakFile( PATH_THIRDPARTY . 'htmlarea/editor.js', true ); $oHeadPublisher->addMaborakFile(PATH_THIRDPARTY . 'htmlarea/editor.js', true );
//erik: if it is a installation instance //check if it is a installation instance
if(!defined('PATH_C')) { if(!defined('PATH_C')) {
$tmpDir = G::getSysTemDir(); // is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily
define('PATH_C', $tmpDir . ((substr($tmpDir, -1) == PATH_SEP)? '': PATH_SEP)); define('PATH_C', (rtrim(G::sys_get_temp_dir(), PATH_SEP) . PATH_SEP));
define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' ); define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' );
} }
//************ defining Virtual URLs ****************/ // defining Virtual URLs
$virtualURITable = array(); $virtualURITable = array();
$virtualURITable['/plugin/(*)'] = 'plugin'; $virtualURITable['/plugin/(*)'] = 'plugin';
$virtualURITable['/(sys*)/(*.js)'] = 'jsMethod'; $virtualURITable['/(sys*)/(*.js)'] = 'jsMethod';
$virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/'; $virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/';
$virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/'; $virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/';
if ( defined('PATH_C') ) { if ( defined('PATH_C') ) {
$virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/'; $virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/';
$virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/'; $virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/';
} }
$virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/'; $virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/';
$virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed'; $virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed';
$virtualURITable['/(sys*)'] = FALSE; $virtualURITable['/(sys*)'] = FALSE;
@@ -179,33 +162,25 @@
$virtualURITable['/controls/(*)'] = PATH_GULLIVER_HOME . 'methods/controls/'; $virtualURITable['/controls/(*)'] = PATH_GULLIVER_HOME . 'methods/controls/';
$virtualURITable['/html2ps_pdf/(*)'] = PATH_THIRDPARTY . 'html2ps_pdf/'; $virtualURITable['/html2ps_pdf/(*)'] = PATH_THIRDPARTY . 'html2ps_pdf/';
$virtualURITable['/Krumo/(*)'] = PATH_THIRDPARTY . 'krumo/'; $virtualURITable['/Krumo/(*)'] = PATH_THIRDPARTY . 'krumo/';
// $virtualURITable['/codepress/(*)'] = PATH_THIRDPARTY . 'codepress/'; //$virtualURITable['/codepress/(*)'] = PATH_THIRDPARTY . 'codepress/';
$virtualURITable['/images/'] = 'errorFile'; $virtualURITable['/images/'] = 'errorFile';
$virtualURITable['/skins/'] = 'errorFile'; $virtualURITable['/skins/'] = 'errorFile';
$virtualURITable['/files/'] = 'errorFile'; $virtualURITable['/files/'] = 'errorFile';
$virtualURITable['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed';
$virtualURITable['/(*)'] = PATH_HTML;
$virtualURITable['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed'; // Verify if we need to redirect or stream the file, if G:VirtualURI returns true means we are going to redirect the page
$virtualURITable['/(*)'] = PATH_HTML;
//****** verify if we need to redirect or stream the file, if G:VirtualURI returns true means we are going to redirect the page *****
if ( G::virtualURI($_SERVER['REQUEST_URI'], $virtualURITable , $realPath )) { if ( G::virtualURI($_SERVER['REQUEST_URI'], $virtualURITable , $realPath )) {
// review if the file requested belongs to public_html plugin // review if the file requested belongs to public_html plugin
if ( substr ( $realPath, 0,6) == '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
* By JHL Jul 14, 08 // TODO: $pathsQuery will be used?
* Another way to get the path of Plugin public_html and stream the correspondent file
* TODO: $pathsQuery will be used?
*/
$pathsQuery=""; $pathsQuery="";
//Get the query side // Get the query side
/* // Did we use this variable $pathsQuery for something??
* Did we use this variable $pathsQuery for something?? $forQuery = explode("?",$realPath);
*/ if (isset($forQuery[1])) {
$forQuery=explode("?",$realPath); $pathsQuery = $forQuery[1];
if(isset($forQuery[1])) {
$pathsQuery=$forQuery[1];
} }
//Get that path in array //Get that path in array
@@ -217,48 +192,39 @@
//The other parts are the realpath into public_html (no matter how many elements) //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; $pluginFilename = PATH_PLUGINS . $pluginFolder . PATH_SEP . 'public_html'. PATH_SEP . $filePath;
if ( file_exists ( $pluginFilename ) ) { if ( file_exists ( $pluginFilename ) ) {
G::streamFile ( $pluginFilename ); G::streamFile ( $pluginFilename );
} }
die; die;
} }
$requestUriArray = explode("/",$_SERVER['REQUEST_URI']);
if((isset($requestUriArray[1]))&&($requestUriArray[1] == 'skin')) {
$requestUriArray=explode("/",$_SERVER['REQUEST_URI']); // This will allow to public images of Custom Skins, By JHL Feb 28, 11
if((isset($requestUriArray[1]))&&($requestUriArray[1]=='skin')) {
/*
* By JHL Feb 28, 11
* This will allow to public images of Custom Skins
*/
$pathsQuery=""; $pathsQuery="";
//Get the query side // Get the query side
/* // This way we remove garbage
* This way we remove garbage $forQuery = explode("?",$realPath);
*/ if (isset($forQuery[1])) {
$forQuery=explode("?",$realPath); $pathsQuery = $forQuery[1];
if(isset($forQuery[1])) {
$pathsQuery=$forQuery[1];
} }
//Get that path in array //Get that path in array
$paths = explode ( PATH_SEP, $forQuery[0] ); $paths = explode ( PATH_SEP, $forQuery[0] );
$fileToBeStreamed=str_replace("/skin/",PATH_CUSTOM_SKINS,$_SERVER['REQUEST_URI']); $fileToBeStreamed=str_replace("/skin/",PATH_CUSTOM_SKINS,$_SERVER['REQUEST_URI']);
if ( file_exists ( $fileToBeStreamed ) ) { if ( file_exists ( $fileToBeStreamed ) ) {
G::streamFile ( $fileToBeStreamed ); G::streamFile ( $fileToBeStreamed );
} }
die; die;
} }
switch ($realPath) {
switch ( $realPath ) {
case 'sysUnnamed' : case 'sysUnnamed' :
require_once('sysUnnamed.php'); die; require_once('sysUnnamed.php');
die;
break; break;
case 'sysNamed' : case 'sysNamed' :
header('location : ' . $_SERVER['REQUEST_URI'] . 'en/green/login/login' ); header('location : ' . $_SERVER['REQUEST_URI'] . 'en/green/login/login' );
@@ -272,7 +238,7 @@
break; break;
case 'errorFile': case 'errorFile':
header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
if ( DEBUG_TIME_LOG ) logTimeByPage(); //log this page if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page
die; die;
break; break;
default : default :
@@ -280,24 +246,31 @@
$realPath[0] .= strpos(basename($realPath[0]), '.') === false ? '.php' : ''; $realPath[0] .= strpos(basename($realPath[0]), '.') === false ? '.php' : '';
G::streamFile ( $realPath[0] ); G::streamFile ( $realPath[0] );
die; die;
} }
} }
//************** the request correspond to valid php page, now parse the URI ************** // the request correspond to valid php page, now parse the URI
G::parseURI(getenv("REQUEST_URI"), $config);
G::parseURI(getenv("REQUEST_URI" ), $config); // verify if index.html exists
if (!file_exists(PATH_HTML . 'index.html')) { // if not, create it from template
file_put_contents(
PATH_HTML . 'index.html',
G::parseTemplate(PATH_TPL . 'index.html', array('lang' => SYS_LANG, 'skin' => SYS_SKIN))
);
}
$oHeadPublisher->addMaborakFile( PATH_GULLIVER_HOME . 'js' . PATH_SEP . "widgets/jscalendar/lang/calendar-" . SYS_LANG . ".js"); $oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . "widgets/jscalendar/lang/calendar-" . SYS_LANG . ".js");
define( 'SYS_URI' , '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/' ); define('SYS_URI' , '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/');
//************** defining the serverConf singleton ************** // defining the serverConf singleton
if(defined('PATH_DATA') && file_exists(PATH_DATA)){ if (defined('PATH_DATA') && file_exists(PATH_DATA)) {
//Instance Server Configuration Singleton //Instance Server Configuration Singleton
G::LoadClass('serverConfiguration'); G::LoadClass('serverConfiguration');
$oServerConf =& serverConf::getSingleton(); $oServerConf =& serverConf::getSingleton();
} }
//***************** Call Gulliver Classes **************************
// Call Gulliver Classes
G::LoadThirdParty('pear/json','class.json'); G::LoadThirdParty('pear/json','class.json');
G::LoadThirdParty('smarty/libs','Smarty.class'); G::LoadThirdParty('smarty/libs','Smarty.class');
G::LoadSystem('error'); G::LoadSystem('error');
@@ -321,24 +294,25 @@
G::LoadSystem('pmException'); G::LoadSystem('pmException');
//G::LoadSystem('pagedTable'); //G::LoadSystem('pagedTable');
//************** Installer, redirect to install if we don't have a valid shared data folder ***************/ // Installer, redirect to install if we don't have a valid shared data folder
if ( !defined('PATH_DATA') || !file_exists(PATH_DATA)) { if ( !defined('PATH_DATA') || !file_exists(PATH_DATA)) {
/*new installer, extjs based*/ // new installer, extjs based
define('PATH_DATA', PATH_C); define('PATH_DATA', PATH_C);
require_once ( PATH_CONTROLLERS . 'installer.php' ); require_once ( PATH_CONTROLLERS . 'installer.php' );
$controller = 'Installer'; $controller = 'Installer';
//if the method name is empty set default to index method // if the method name is empty set default to index method
if (strpos(SYS_TARGET, '/') !== false) if (strpos(SYS_TARGET, '/') !== false) {
list($controller, $controllerAction) = explode('/', SYS_TARGET); list($controller, $controllerAction) = explode('/', SYS_TARGET);
else }
else {
$controllerAction = SYS_TARGET; $controllerAction = SYS_TARGET;
}
$controllerAction = ($controllerAction != '' && $controllerAction != 'login')? $controllerAction: 'index'; $controllerAction = ($controllerAction != '' && $controllerAction != 'login')? $controllerAction: 'index';
//create the installer controller and call its method // create the installer controller and call its method
if( is_callable(Array('Installer', $controllerAction)) ) { if( is_callable(Array('Installer', $controllerAction)) ) {
$installer = new $controller(); $installer = new $controller();
$installer->setHttpRequestData($_REQUEST); $installer->setHttpRequestData($_REQUEST);
@@ -351,10 +325,10 @@
die; die;
} }
// ************* Load Language Translation ***************** // Load Language Translation
G::LoadTranslationObject(defined('SYS_LANG')?SYS_LANG:"en"); G::LoadTranslationObject(defined('SYS_LANG')?SYS_LANG:"en");
//******** look for a disabled workspace **** // look for a disabled workspace
if($oServerConf->isWSDisabled(SYS_TEMP)){ if($oServerConf->isWSDisabled(SYS_TEMP)){
$aMessage['MESSAGE'] = G::LoadTranslation('ID_DISB_WORKSPACE'); $aMessage['MESSAGE'] = G::LoadTranslation('ID_DISB_WORKSPACE');
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher;
@@ -363,8 +337,8 @@
die; die;
} }
//********** database and workspace definition ************************ // 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 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 != '') { if ( defined('SYS_TEMP') && SYS_TEMP != '') {
//this is the default, the workspace db.php file is in /shared/workflow/sites/SYS_SYS //this is the default, the workspace db.php file is in /shared/workflow/sites/SYS_SYS
if ( file_exists( PATH_DB . SYS_TEMP . '/db.php' ) ) { if ( file_exists( PATH_DB . SYS_TEMP . '/db.php' ) ) {
@@ -390,7 +364,7 @@
} }
else { else {
if(SYS_TARGET=="dbInfo"){ //Show dbInfo when no SYS_SYS if(SYS_TARGET=="dbInfo"){ //Show dbInfo when no SYS_SYS
require_once( PATH_METHODS . "login/dbInfo.php" ) ; require_once( PATH_METHODS . "login/dbInfo.php" );
} }
else{ else{
@@ -410,45 +384,46 @@
die(); die();
} }
} }
if ( DEBUG_TIME_LOG ) logTimeByPage(); //log this page if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page
die(); die();
} }
} }
// ***** create memcached singleton ***************** // create memcached singleton
G::LoadClass ( 'memcached' ); G::LoadClass ( 'memcached' );
$memcache = & PMmemcached::getSingleton(SYS_SYS); $memcache = & PMmemcached::getSingleton(SYS_SYS);
//***************** PM Paths DATA ************************** // PM Paths DATA
define( 'PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/'); define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
define( 'PATH_DOCUMENT', PATH_DATA_SITE . 'files/' ); define('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
define( 'PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/' ); define('PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/');
define( 'PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/' ); define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
define( 'PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/' ); define('PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/');
define( 'PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/' ); define('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
define( 'PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles'.PATH_SEP); define('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles'.PATH_SEP);
define( 'PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies'.PATH_SEP); define('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies'.PATH_SEP);
define( 'SERVER_NAME', $_SERVER ['SERVER_NAME']); define('SERVER_NAME', $_SERVER ['SERVER_NAME']);
define( 'SERVER_PORT', $_SERVER ['SERVER_PORT']); define('SERVER_PORT', $_SERVER ['SERVER_PORT']);
//***************** Plugins ************************** // load Plugins base class
G::LoadClass('plugin'); G::LoadClass('plugin');
//here we are loading all plugins registered //here we are loading all plugins registered
//the singleton has a list of enabled plugins //the singleton has a list of enabled plugins
$sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton';
$oPluginRegistry =& PMPluginRegistry::getSingleton(); $oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( file_exists ($sSerializedFile) )
$oPluginRegistry->unSerializeInstance( file_get_contents ( $sSerializedFile ) );
if (file_exists ($sSerializedFile)) {
$oPluginRegistry->unSerializeInstance(file_get_contents($sSerializedFile));
}
//******* setup propel definitions and logging **** // setup propel definitions and logging
require_once ( "propel/Propel.php" ); require_once ( "propel/Propel.php" );
require_once ( "creole/Creole.php" ); require_once ( "creole/Creole.php" );
if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) { if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) {
define ( 'PM_PID', mt_rand(1,999999) ); define('PM_PID', mt_rand(1,999999));
require_once ( "Log.php" ); require_once 'Log.php';
// register debug connection decorator driver // register debug connection decorator driver
Creole::registerDriver('*', 'creole.contrib.DebugConnection'); Creole::registerDriver('*', 'creole.contrib.DebugConnection');
@@ -456,72 +431,84 @@
// initialize Propel with converted config file // initialize Propel with converted config file
Propel::init( PATH_CORE . "config/databases.php" ); Propel::init( PATH_CORE . "config/databases.php" );
//unified log file for all databases // unified log file for all databases
$logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log'; $logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log';
$logger = Log::singleton('file', $logFile, 'wf ' . SYS_SYS, null, PEAR_LOG_INFO); $logger = Log::singleton('file', $logFile, 'wf ' . SYS_SYS, null, PEAR_LOG_INFO);
Propel::setLogger($logger); Propel::setLogger($logger);
//log file for workflow database // log file for workflow database
$con = Propel::getConnection('workflow'); $con = Propel::getConnection('workflow');
if ($con instanceof DebugConnection) $con->setLogger($logger); if ($con instanceof DebugConnection) {
$con->setLogger($logger);
//log file for rbac database }
// log file for rbac database
$con = Propel::getConnection('rbac'); $con = Propel::getConnection('rbac');
if ($con instanceof DebugConnection) $con->setLogger($logger);
//log file for report database if ($con instanceof DebugConnection) {
$con->setLogger($logger);
}
// log file for report database
$con = Propel::getConnection('rp'); $con = Propel::getConnection('rp');
if ($con instanceof DebugConnection) $con->setLogger($logger); if ($con instanceof DebugConnection) {
$con->setLogger($logger);
}
} }
else else {
Propel::init( PATH_CORE . "config/databases.php" ); Propel::init( PATH_CORE . "config/databases.php" );
}
Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
//***************** Session Initializations **************************/ // Session Initializations
ini_set( 'session.auto_start', '1' ); ini_set('session.auto_start', '1');
// The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off. // The register_globals feature has been DEPRECATED as of PHP 5.3.0. default value Off.
// ini_set( 'register_globals', 'Off' ); // ini_set( 'register_globals', 'Off' );
session_start(); session_start();
ob_start(); ob_start();
//Rebuild the base Workflow translations if not exists // Rebuild the base Workflow translations if not exists
if( ! is_file(PATH_LANGUAGECONT . 'translation.en') ){ if( ! is_file(PATH_LANGUAGECONT . 'translation.en') ){
require_once ( "classes/model/Translation.php" ); require_once ( "classes/model/Translation.php" );
$fields = Translation::generateFileTranslation('en'); $fields = Translation::generateFileTranslation('en');
} }
//TODO: Verify if the language set into url is defined in translations env.
// TODO: Verify if the language set into url is defined in translations env.
if( SYS_LANG != 'en' && ! is_file(PATH_LANGUAGECONT . 'translation.' . SYS_LANG) ){ if( SYS_LANG != 'en' && ! is_file(PATH_LANGUAGECONT . 'translation.' . SYS_LANG) ){
require_once ( "classes/model/Translation.php" ); require_once ( "classes/model/Translation.php" );
$fields = Translation::generateFileTranslation(SYS_LANG); $fields = Translation::generateFileTranslation(SYS_LANG);
} }
//********* Setup plugins ************* // Setup plugins
$oPluginRegistry->setupPlugins(); //get and setup enabled plugins $oPluginRegistry->setupPlugins(); //get and setup enabled plugins
$avoidChangedWorkspaceValidation = false; $avoidChangedWorkspaceValidation = false;
//Load custom Classes and Model from Plugins. // Load custom Classes and Model from Plugins.
G::LoadAllPluginModelClasses(); G::LoadAllPluginModelClasses();
//*********jump to php file in methods directory ************* // jump to php file in methods directory
$collectionPlugin = ''; $collectionPlugin = '';
if ( $oPluginRegistry->isRegisteredFolder( SYS_COLLECTION ) ) { if ($oPluginRegistry->isRegisteredFolder(SYS_COLLECTION)) {
$phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php'; $phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php';
$targetPlugin = explode( '/', SYS_TARGET ); $targetPlugin = explode( '/', SYS_TARGET );
$collectionPlugin = $targetPlugin[0]; $collectionPlugin = $targetPlugin[0];
$avoidChangedWorkspaceValidation = true; $avoidChangedWorkspaceValidation = true;
} }
else else {
$phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php'; $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php';
}
//services is a special folder, // services is a special folder,
if ( SYS_COLLECTION == 'services' ) { if ( SYS_COLLECTION == 'services' ) {
$avoidChangedWorkspaceValidation = true; $avoidChangedWorkspaceValidation = true;
$targetPlugin = explode( '/', SYS_TARGET ); $targetPlugin = explode( '/', SYS_TARGET );
if ( $targetPlugin[0] == 'webdav' ) { if ( $targetPlugin[0] == 'webdav' ) {
$phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . 'webdav.php'; $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . 'webdav.php';
} }
} }
if(SYS_COLLECTION=='login' && SYS_TARGET=='login'){
if (SYS_COLLECTION == 'login' && SYS_TARGET == 'login') {
$avoidChangedWorkspaceValidation = true; $avoidChangedWorkspaceValidation = true;
} }
@@ -538,10 +525,9 @@
} }
else { else {
//when the file is part of the public directory of any PROCESS, this a ProcessMaker feature //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) if (preg_match('/^[0-9][[:alnum:]]+$/', SYS_COLLECTION) == 1) { //the pattern is /sysSYS/LANG/SKIN/PRO_UID/file
{ //the pattern is /sysSYS/LANG/SKIN/PRO_UID/file $auxPart = explode ( '/' , $_SERVER['REQUEST_URI']);
$auxPart = explode ( '/' , $_SERVER['REQUEST_URI']); $aAux = explode('?', $auxPart[ count($auxPart)-1]);
$aAux = explode('?', $auxPart[ count($auxPart)-1]);
//$extPart = explode ( '.' , $auxPart[ count($auxPart)-1] ); //$extPart = explode ( '.' , $auxPart[ count($auxPart)-1] );
$extPart = explode ( '.' , $aAux[0] ); $extPart = explode ( '.' , $aAux[0] );
$queryPart = isset($aAux[1])?$aAux[1]:""; $queryPart = isset($aAux[1])?$aAux[1]:"";
@@ -549,37 +535,38 @@
$phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . urldecode ($auxPart[ count($auxPart)-1]); $phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . urldecode ($auxPart[ count($auxPart)-1]);
$aAux = explode('?', $phpFile); $aAux = explode('?', $phpFile);
$phpFile = $aAux[0]; $phpFile = $aAux[0];
if ( $extension != 'php' ) {
G::streamFile ( $phpFile ); if ($extension != 'php') {
G::streamFile($phpFile);
die; die;
} }
$avoidChangedWorkspaceValidation=true; $avoidChangedWorkspaceValidation=true;
$bWE = true; $bWE = true;
//$phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . $auxPart[ count($auxPart)-1]; //$phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . $auxPart[ count($auxPart)-1];
} }
//erik: verify if it is a Controller Class or httpProxyController Class //erik: verify if it is a Controller Class or httpProxyController Class
if( is_file(PATH_CONTROLLERS . SYS_COLLECTION . '.php') ) { if (is_file(PATH_CONTROLLERS . SYS_COLLECTION . '.php')) {
require_once PATH_CONTROLLERS . SYS_COLLECTION . '.php'; require_once PATH_CONTROLLERS . SYS_COLLECTION . '.php';
$controllerClass = SYS_COLLECTION; $controllerClass = SYS_COLLECTION;
//if the method name is empty set default to index method //if the method name is empty set default to index method
$controllerAction = SYS_TARGET != '' ? SYS_TARGET : 'index'; $controllerAction = SYS_TARGET != '' ? SYS_TARGET : 'index';
//if the method exists //if the method exists
if( is_callable(Array($controllerClass, $controllerAction)) ) { if (is_callable(Array($controllerClass, $controllerAction)) ) {
$isControllerCall = true; $isControllerCall = true;
} }
} }
if ( ! $isControllerCall && ! file_exists( $phpFile ) ) { if (!$isControllerCall && ! file_exists($phpFile)) {
$_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI'];
print $phpFile; header("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); die;
die;
} }
} }
//redirect to login, if user changed the workspace in the URL //redirect to login, if user changed the workspace in the URL
if( ! $avoidChangedWorkspaceValidation && isset( $_SESSION['WORKSPACE'] ) && $_SESSION['WORKSPACE'] != SYS_SYS) { if (! $avoidChangedWorkspaceValidation && isset($_SESSION['WORKSPACE']) && $_SESSION['WORKSPACE'] != SYS_SYS) {
$_SESSION['WORKSPACE'] = SYS_SYS; $_SESSION['WORKSPACE'] = SYS_SYS;
G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error"); G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error");
@@ -587,19 +574,19 @@
die; die;
} }
//***************** enable rbac ************************** // enable rbac
$RBAC =& RBAC::getSingleton( PATH_DATA, session_id() ); $RBAC = &RBAC::getSingleton( PATH_DATA, session_id() );
$RBAC->sSystem = 'PROCESSMAKER'; $RBAC->sSystem = 'PROCESSMAKER';
//****** define and send Headers for all pages ******************* // define and send Headers for all pages
if ( ! defined('EXECUTE_BY_CRON') ) { 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("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("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false); header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); header("Pragma: no-cache");
//get the language direction from ServerConf // get the language direction from ServerConf
define('SYS_LANG_DIRECTION', $oServerConf->getLanDirection() ); define('SYS_LANG_DIRECTION', $oServerConf->getLanDirection() );
if((isset( $_SESSION['USER_LOGGED'] ))&&(!(isset($_GET['sid'])))) { if((isset( $_SESSION['USER_LOGGED'] ))&&(!(isset($_GET['sid'])))) {
@@ -634,7 +621,7 @@
$noLoginFolders[] = 'tracker'; $noLoginFolders[] = 'tracker';
$noLoginFolders[] = 'installer'; $noLoginFolders[] = 'installer';
//This sentence is used when you lost the Session // This sentence is used when you lost the Session
if ( !in_array(SYS_TARGET, $noLoginFiles) && !in_array(SYS_COLLECTION, $noLoginFolders) && $bWE != true && $collectionPlugin != 'services') { if ( !in_array(SYS_TARGET, $noLoginFiles) && !in_array(SYS_COLLECTION, $noLoginFolders) && $bWE != true && $collectionPlugin != 'services') {
$bRedirect = true; $bRedirect = true;
@@ -651,24 +638,27 @@
$RBAC->initRBAC(); $RBAC->initRBAC();
$RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] ); $RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] );
$memKey = 'rbacSession' . session_id(); $memKey = 'rbacSession' . session_id();
$memcache->set( $memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS ); $memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS );
} }
} }
if ($bRedirect) { if ($bRedirect) {
//g::pr($_SERVER); die; if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') { // verify if the current skin is a 'ux' variant
if (strpos($_SERVER['REQUEST_URI'], '/home') !== false) { $loginUrl = 'main/login';
}
else if (strpos($_SERVER['REQUEST_URI'], '/home') !== false){ //verify is it is using the uxs skin for simplified interface
$loginUrl = 'home/login'; $loginUrl = 'home/login';
} }
else { else {
$loginUrl = 'main/login'; $loginUrl = 'login/login'; // just set up the classic login
} }
if (empty($_POST)) { if (empty($_POST)) {
header('location: ' . SYS_URI . $loginUrl . '?u=' . urlencode($_SERVER['REQUEST_URI'])); header('location: ' . SYS_URI . $loginUrl . '?u=' . urlencode($_SERVER['REQUEST_URI']));
} }
else { else {
if ( $isControllerCall ) { if ($isControllerCall) {
header("HTTP/1.0 302 session lost in controller"); header("HTTP/1.0 302 session lost in controller");
} }
else { else {
header('location: ' . SYS_URI . $loginUrl); header('location: ' . SYS_URI . $loginUrl);
@@ -680,23 +670,27 @@
} }
$_SESSION['phpLastFileFound'] = $_SERVER['REQUEST_URI']; $_SESSION['phpLastFileFound'] = $_SERVER['REQUEST_URI'];
/*** /**
* New feature for Gulliver framework to support Controllers & HttpProxyController classes handling * New feature for Gulliver framework to support Controllers & HttpProxyController classes handling
*
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com> * @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
*/ */
if( $isControllerCall ) { //Instance the Controller object and call the request method if ($isControllerCall) { //Instance the Controller object and call the request method
$controller = new $controllerClass(); $controller = new $controllerClass();
$controller->setHttpRequestData($_REQUEST); $controller->setHttpRequestData($_REQUEST);
$controller->call($controllerAction); $controller->call($controllerAction);
} else }
require_once( $phpFile ); else {
require_once $phpFile;
}
if ( defined('SKIP_HEADERS') ) { 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("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('Cache-Control: public');
header('Pragma: '); header('Pragma: ');
} }
ob_end_flush(); ob_end_flush();
if ( DEBUG_TIME_LOG ) logTimeByPage(); //log this page if (DEBUG_TIME_LOG) {
G::logTimeByPage(); //log this page
}
} }