From 564fa3ee524dab3e71682589df20734636928388 Mon Sep 17 00:00:00 2001 From: Ralph Asendeteufrer Date: Thu, 8 Nov 2012 15:13:08 -0400 Subject: [PATCH 01/70] enter Speedy --- workflow/public_html/sysGeneric.php | 1 - 1 file changed, 1 deletion(-) diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index 473428c5c..e2324bb55 100755 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -49,7 +49,6 @@ define('PATH_HOME', $pathhome); define('PATH_TRUNK', $pathTrunk); define('PATH_OUTTRUNK', $pathOutTrunk); - // Including these files we get the PM paths and definitions (that should be just one file. require_once $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php'; require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php'; From 6765f9be897a019e6c4660c4dc968b4f49fb952c Mon Sep 17 00:00:00 2001 From: Ralph Asendeteufrer Date: Thu, 8 Nov 2012 15:30:20 -0400 Subject: [PATCH 02/70] enter bootstrap.php --- workflow/public_html/bootstrap.php | 692 +++++++++++++++++++++++++++++ 1 file changed, 692 insertions(+) create mode 100755 workflow/public_html/bootstrap.php diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php new file mode 100755 index 000000000..e2324bb55 --- /dev/null +++ b/workflow/public_html/bootstrap.php @@ -0,0 +1,692 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +/** + * sysGeneric - ProcessMaker Bootstrap + * this file is used initialize main variables, redirect and dispatch all requests + */ + + // 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); + // Including these files we get the PM paths and definitions (that should be just one file. + require_once $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php'; + require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php'; + + // starting session + session_start(); + + $config = System::getSystemConfiguration(); + + $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; + + // Do not change any of these settings directly, use env.ini instead + ini_set('display_errors', $config['debug']); + ini_set('error_reporting', $e_all); + 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']); + + define ('DEBUG_SQL_LOG', $config['debug_sql']); + 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']); + define ('TIME_ZONE', $config['time_zone']); + + // 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 + + 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 + + //check if it is a installation instance + if(!defined('PATH_C')) { + // is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily + define('PATH_C', (rtrim(G::sys_get_temp_dir(), PATH_SEP) . PATH_SEP)); + define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' ); + } + + // defining Virtual URLs + $virtualURITable = array(); + $virtualURITable['/plugin/(*)'] = 'plugin'; + $virtualURITable['/(sys*)/(*.js)'] = 'jsMethod'; + $virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/'; + $virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/'; + + if ( defined('PATH_C') ) { + $virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/'; + $virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/'; + } + + $virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/'; + $virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed'; + $virtualURITable['/(sys*)'] = FALSE; + $virtualURITable['/errors/(*)'] = PATH_GULLIVER_HOME . 'methods/errors/'; + $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['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed'; + $virtualURITable['/rest/(*)'] = 'rest-service'; + $virtualURITable['/update/(*)'] = PATH_GULLIVER_HOME . 'methods/update/'; + $virtualURITable['/(*)'] = PATH_HTML; + + $isRestRequest = false; + + // 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 )) + { + // 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]; + } + + //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 ) ) { + G::streamFile ( $pluginFilename ); + } + die; + } + + $requestUriArray = explode("/",$_SERVER['REQUEST_URI']); + + 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]; + } + + //Get that path in array + $paths = explode ( PATH_SEP, $forQuery[0] ); + $fileToBeStreamed=str_replace("/skin/",PATH_CUSTOM_SKINS,$_SERVER['REQUEST_URI']); + + if ( file_exists ( $fileToBeStreamed ) ) { + G::streamFile ( $fileToBeStreamed ); + } + die; + } + switch ($realPath) { + case 'sysUnnamed' : + require_once('sysUnnamed.php'); + die; + break; + case 'sysNamed' : + header('location : ' . $_SERVER['REQUEST_URI'] . '/' .SYS_LANG. '/classic/login/login' ); + die; + break; + case 'jsMethod' : + G::parseURI ( getenv( "REQUEST_URI" ) ); + $filename = PATH_METHODS . SYS_COLLECTION . '/' . SYS_TARGET . '.js'; + G::streamFile ( $filename ); + die; + break; + case 'errorFile': + header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); + if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page + die; + break; + default : + if (substr($realPath, 0, 12) == 'rest-service') { + $isRestRequest = true; + } else { + $realPath = explode('?', $realPath); + $realPath[0] .= strpos(basename($realPath[0]), '.') === false ? '.php' : ''; + G::streamFile ( $realPath[0] ); + die; + } + } + }//virtual URI parser + + // the request correspond to valid php page, now parse the URI + G::parseURI(getenv("REQUEST_URI"), $isRestRequest); + + if(G::isPMUnderUpdating()) + { + header("location: /update/updating.php"); + if ( DEBUG_TIME_LOG ) G::logTimeByPage(); + die; + } + + // 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)) + ); + } + + define('SYS_URI' , '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/'); + + // defining the serverConf singleton + if (defined('PATH_DATA') && file_exists(PATH_DATA)) { + //Instance Server Configuration Singleton + G::LoadClass('serverConfiguration'); + $oServerConf =& serverConf::getSingleton(); + } + + // Call Gulliver Classes + G::LoadThirdParty('pear/json','class.json'); + G::LoadThirdParty('smarty/libs','Smarty.class'); + G::LoadSystem('error'); + G::LoadSystem('dbconnection'); + G::LoadSystem('dbsession'); + G::LoadSystem('dbrecordset'); + G::LoadSystem('dbtable'); + G::LoadSystem('rbac' ); + G::LoadSystem('publisher'); + G::LoadSystem('templatePower'); + G::LoadSystem('xmlDocument'); + G::LoadSystem('xmlform'); + G::LoadSystem('xmlformExtension'); + G::LoadSystem('form'); + G::LoadSystem('menu'); + G::LoadSystem("xmlMenu"); + G::LoadSystem('dvEditor'); + G::LoadSystem('controller'); + G::LoadSystem('httpProxyController'); + G::LoadSystem('pmException'); + + // Create headPublisher singleton + G::LoadSystem('headPublisher'); + $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); + require_once ( PATH_CONTROLLERS . 'installer.php' ); + $controller = 'Installer'; + + // 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; + } + + $controllerAction = ($controllerAction != '' && $controllerAction != 'login')? $controllerAction: 'index'; + + // create the installer controller and call its method + if( is_callable(Array('Installer', $controllerAction)) ) { + $installer = new $controller(); + $installer->setHttpRequestData($_REQUEST); + $installer->call($controllerAction); + } + else { + $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; + header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); + } + die; + } + + // Load Language Translation + G::LoadTranslationObject(defined('SYS_LANG')?SYS_LANG:"en"); + + // look for a disabled workspace + if($oServerConf->isWSDisabled(SYS_TEMP)){ + $aMessage['MESSAGE'] = G::LoadTranslation('ID_DISB_WORKSPACE'); + $G_PUBLISH = new Publisher; + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); + G::RenderPage( 'publish' ); + die; + } + + // 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 + if ( file_exists( PATH_DB . SYS_TEMP . '/db.php' ) ) { + require_once( PATH_DB . SYS_TEMP . '/db.php' ); + define ( 'SYS_SYS' , SYS_TEMP ); + + // defining constant for workspace shared directory + define ( 'PATH_WORKSPACE' , PATH_DB . SYS_SYS . PATH_SEP ); + // including workspace shared classes -> particularlly for pmTables + set_include_path(get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE); + } + else { + G::SendTemporalMessage ('ID_NOT_WORKSPACE', "error"); + G::header('location: /sys/' . SYS_LANG . '/' . SYS_SKIN . '/main/sysLogin?errno=2'); + die; + } + } + else { //when we are in global pages, outside any valid workspace + if (SYS_TARGET==='newSite') { + $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . "/" . SYS_TARGET.'.php'; + require_once($phpFile); + die(); + } + else { + if(SYS_TARGET=="dbInfo"){ //Show dbInfo when no SYS_SYS + require_once( PATH_METHODS . "login/dbInfo.php" ); + } + else{ + + if (substr(SYS_SKIN, 0, 2) === 'ux' && SYS_TARGET != 'sysLoginVerify') { // new ux sysLogin - extjs based form + require_once PATH_CONTROLLERS . 'main.php'; + $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); + } + } + else { // classic sysLogin interface + require_once( PATH_METHODS . "login/sysLogin.php" ) ; + die(); + } + } + if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page + die(); + } + } + + // PM Paths DATA + define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/'); + 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 + G::LoadClass ( 'memcached' ); + $memcache = & PMmemcached::getSingleton(SYS_SYS); + + // verify configuration for rest service + if ($isRestRequest) { + // disable until confirm that rest is enabled & configured on rest-config.ini file + $isRestRequest = false; + $confFile = ''; + $restApiClassPath = ''; + + // try load and getting rest configuration + if (file_exists(PATH_DATA_SITE . 'rest-config.ini')) { + $confFile = PATH_DATA_SITE . 'rest-config.ini'; + $restApiClassPath = PATH_DATA_SITE; + } elseif (file_exists(PATH_CONFIG . 'rest-config.ini')) { + $confFile = PATH_CONFIG . 'rest-config.ini'; + } + if (! empty($confFile) && $restConfig = @parse_ini_file($confFile, true)) { + if (array_key_exists('enable_service', $restConfig)) { + if ($restConfig['enable_service'] == 'true' || $restConfig['enable_service'] == '1') { + $isRestRequest = true; // rest service enabled + } + } + } + } + + // load Plugins base class + G::LoadClass('plugin'); + + //here we are loading all plugins registered + //the singleton has a list of enabled plugins + $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; + $oPluginRegistry =& PMPluginRegistry::getSingleton(); + + if (file_exists ($sSerializedFile)) { + $oPluginRegistry->unSerializeInstance(file_get_contents($sSerializedFile)); + } + + // setup propel definitions and logging + require_once ( "propel/Propel.php" ); + require_once ( "creole/Creole.php" ); + + if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) { + define('PM_PID', mt_rand(1,999999)); + require_once 'Log.php'; + + // register debug connection decorator driver + Creole::registerDriver('*', 'creole.contrib.DebugConnection'); + + // initialize Propel with converted config file + Propel::init( PATH_CORE . "config/databases.php" ); + + // unified log file for all databases + $logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log'; + $logger = Log::singleton('file', $logFile, 'wf ' . SYS_SYS, null, PEAR_LOG_INFO); + 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'); + + if ($con instanceof DebugConnection) { + $con->setLogger($logger); + } + + // log file for report database + $con = Propel::getConnection('rp'); + if ($con instanceof DebugConnection) { + $con->setLogger($logger); + } + } + else { + Propel::init( PATH_CORE . "config/databases.php" ); + } + + Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); + + // Session Initializations + ini_set('session.auto_start', '1'); + + // 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(); + + // Rebuild the base Workflow translations if not exists + if( ! is_file(PATH_LANGUAGECONT . 'translation.en') ){ + require_once ( "classes/model/Translation.php" ); + $fields = Translation::generateFileTranslation('en'); + } + + // TODO: Verify if the language set into url is defined in translations env. + if( SYS_LANG != 'en' && ! is_file(PATH_LANGUAGECONT . 'translation.' . SYS_LANG) ){ + require_once ( "classes/model/Translation.php" ); + $fields = Translation::generateFileTranslation(SYS_LANG); + } + + // Setup plugins + $oPluginRegistry->setupPlugins(); //get and setup enabled plugins + $avoidChangedWorkspaceValidation = false; + + // Load custom Classes and Model from Plugins. + G::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 = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php'; + } + + // services is a special folder, + if ( SYS_COLLECTION == 'services' ) { + $avoidChangedWorkspaceValidation = true; + $targetPlugin = explode( '/', SYS_TARGET ); + + if ( $targetPlugin[0] == 'webdav' ) { + $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . 'webdav.php'; + } + } + + if (SYS_COLLECTION == 'login' && SYS_TARGET == 'login') { + $avoidChangedWorkspaceValidation = true; + } + + //the index.php file, this new feature will allow automatically redirects to valid php file inside any methods folder + /* DEPRECATED + if ( SYS_TARGET == '' ) { + $phpFile = str_replace ( '.php', 'index.php', $phpFile ); + $phpFile = include ( $phpFile ); + }*/ + $bWE = false; + $isControllerCall = 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') { + G::streamFile($phpFile); + die; + } + + $avoidChangedWorkspaceValidation=true; + $bWE = true; + //$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 + if (is_file(PATH_CONTROLLERS . SYS_COLLECTION . '.php')) { + require_once PATH_CONTROLLERS . SYS_COLLECTION . '.php'; + $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; + } + } + + if (!$isControllerCall && ! file_exists($phpFile) && ! $isRestRequest) { + $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; + header("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); + die; + } + } + + //redirect to login, if user changed the workspace in the URL + if (! $avoidChangedWorkspaceValidation && isset($_SESSION['WORKSPACE']) && $_SESSION['WORKSPACE'] != SYS_SYS) { + $_SESSION['WORKSPACE'] = SYS_SYS; + G::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'; + + header('Location: /sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . $urlPart); + die; + } + + // enable rbac + $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'])))) { + $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'; + $noLoginFiles[] = 'login_Ajax'; + $noLoginFiles[] = 'dbInfo'; + $noLoginFiles[] = 'sysLoginVerify'; + $noLoginFiles[] = 'processes_Ajax'; + $noLoginFiles[] = 'updateTranslation'; + $noLoginFiles[] = 'autoinstallProcesses'; + $noLoginFiles[] = 'autoinstallPlugins'; + $noLoginFiles[] = 'heartbeatStatus'; + $noLoginFiles[] = 'showLogoFile'; + $noLoginFiles[] = 'forgotPassword'; + $noLoginFiles[] = 'retrivePassword'; + $noLoginFiles[] = 'defaultAjaxDynaform'; + $noLoginFiles[] = 'dynaforms_checkDependentFields'; + + $noLoginFolders[] = 'services'; + $noLoginFolders[] = 'tracker'; + $noLoginFolders[] = 'installer'; + + // This sentence is used when you lost the Session + if (! in_array(SYS_TARGET, $noLoginFiles) + && ! in_array(SYS_COLLECTION, $noLoginFolders) + && $bWE != true && $collectionPlugin != 'services' + && ! $isRestRequest + ) { + $bRedirect = true; + + if (isset($_GET['sid'])) { + G::LoadClass('sessions'); + $oSessions = new Sessions(); + if ($aSession = $oSessions->verifySession($_GET['sid'])) { + require_once 'classes/model/Users.php'; + $oUser = new Users(); + $aUser = $oUser->load($aSession['USR_UID']); + $_SESSION['USER_LOGGED'] = $aUser['USR_UID']; + $_SESSION['USR_USERNAME'] = $aUser['USR_USERNAME']; + $bRedirect = false; + $RBAC->initRBAC(); + $RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] ); + $memKey = 'rbacSession' . session_id(); + $memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS ); + } + } + + if ($bRedirect) { + if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') { // verify if the current skin is a 'ux' variant + $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'; + } + else { + $loginUrl = 'login/login'; // just set up the classic login + } + + if (empty($_POST)) { + header('location: ' . SYS_URI . $loginUrl . '?u=' . urlencode($_SERVER['REQUEST_URI'])); + + } + else { + if ($isControllerCall) { + header("HTTP/1.0 302 session lost in controller"); + } + else { + header('location: ' . SYS_URI . $loginUrl); + } + } + die(); + } + } + } + $_SESSION['phpLastFileFound'] = $_SERVER['REQUEST_URI']; + + /** + * New feature for Gulliver framework to support Controllers & HttpProxyController classes handling + * @author Erik Amaru Ortiz + */ + if ($isControllerCall) { //Instance the Controller object and call the request method + $controller = new $controllerClass(); + $controller->setHttpRequestData($_REQUEST); + $controller->call($controllerAction); + } elseif ($isRestRequest) { + G::dispatchRestService(SYS_TARGET, $restConfig, $restApiClassPath); + } else { + require_once $phpFile; + } + + 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) { + G::logTimeByPage(); //log this page + } + } From 72b5b2b5313a270fcdd00d27655374aec206abca Mon Sep 17 00:00:00 2001 From: user Date: Thu, 8 Nov 2012 17:02:56 -0400 Subject: [PATCH 03/70] Adding PATHs to bootstrap.php --- workflow/public_html/bootstrap.php | 117 ++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index e2324bb55..fcdcb77cf 100755 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -49,8 +49,123 @@ define('PATH_HOME', $pathhome); define('PATH_TRUNK', $pathTrunk); define('PATH_OUTTRUNK', $pathOutTrunk); + + + // 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 ); + define( 'PATH_THIRDPARTY', PATH_GULLIVER_HOME . 'thirdparty' . PATH_SEP ); + define( 'PATH_RBAC', PATH_RBAC_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP ); //to enable rbac version 2 + define( 'PATH_RBAC_CORE', PATH_RBAC_HOME . 'engine' . PATH_SEP ); + define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP ); + + // Defining PMCore Path constants + define( 'PATH_CORE', PATH_HOME . 'engine' . PATH_SEP ); + define( 'PATH_SKINS', PATH_CORE . 'skins' . PATH_SEP ); + define( 'PATH_SKIN_ENGINE', PATH_CORE . 'skinEngine' . PATH_SEP ); + 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 ); + define( 'PATH_SERVICES_REST', PATH_CORE . 'services' . PATH_SEP . 'rest' . PATH_SEP); + + // include Gulliver Class + require_once( PATH_GULLIVER . PATH_SEP . 'class.g.php'); + + if(file_exists(FILE_PATHS_INSTALLED)) { + // backward compatibility; parsing old definitions in the compiled path constant + $tmp = file_get_contents(FILE_PATHS_INSTALLED); + + if (strpos($tmp, 'PATH_OUTTRUNK') !== false) { + @file_put_contents(FILE_PATHS_INSTALLED, str_replace('PATH_OUTTRUNK', 'PATH_DATA', $tmp)); + } + // end backward compatibility + + // include the workspace installed configuration + require_once FILE_PATHS_INSTALLED; + + // defining system constant when a valid workspace environment exists + define('PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP); + define('PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP); + define('PATH_TEMPORAL', PATH_C . 'dynEditor/'); + define('PATH_DB', PATH_DATA . 'sites' . PATH_SEP); + // smarty constants + define('PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c'); + define('PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache'); + + if (!is_dir(PATH_SMARTY_C)) { + G::mk_dir(PATH_SMARTY_C); + } + + if (!is_dir(PATH_SMARTY_CACHE)) { + G::mk_dir(PATH_SMARTY_CACHE); + } + } + + // 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'); + // Including these files we get the PM paths and definitions (that should be just one file. - require_once $pathhome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php'; require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php'; // starting session From f8226b1864a2dc71877609d5bce6501b8080a30e Mon Sep 17 00:00:00 2001 From: user Date: Thu, 8 Nov 2012 18:06:09 -0400 Subject: [PATCH 04/70] Adding class.bootstrap.php --- gulliver/system/class.bootstrap.php | 2983 +++++++++++++++++++++++++++ workflow/public_html/bootstrap.php | 1304 ++++++------ 2 files changed, 3625 insertions(+), 662 deletions(-) create mode 100644 gulliver/system/class.bootstrap.php diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php new file mode 100644 index 000000000..72d4ce52f --- /dev/null +++ b/gulliver/system/class.bootstrap.php @@ -0,0 +1,2983 @@ + + * @param $resources array + * a list of files to verify write access + */ + public 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; + } + } + + /** + * render a smarty template + * + * @author Erik Amaru Ortiz + * @param $template string + * containing the template filename on /gulliver/templates/ + * directory + * @param $data associative + * array containig the template data + */ + public 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'; + $fInfo = pathinfo ( $template ); + + $tplExists = true; + + // file has absolute path + if (substr ( $template, 0, 1 ) != PATH_SEP) { + $template = PATH_TEMPLATE . $template; + } + + // fix for template that have dot in its name but is not a valid + // extension + if (isset ( $fInfo ['extension'] ) && ($fInfo ['extension'] != 'tpl' || $fInfo ['extension'] != 'html')) { + unset ( $fInfo ['extension'] ); + } + + if (! isset ( $fInfo ['extension'] )) { + if (file_exists ( $template . '.tpl' )) { + $template .= '.tpl'; + } elseif (file_exists ( $template . '.html' )) { + $template .= '.html'; + } else { + $tplExists = false; + } + } else { + if (! file_exists ( $template )) { + $tplExists = false; + } + } + + if (! $tplExists) { + throw new Exception ( "Template: $template, doesn't exist!" ); + } + + $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 ); + } + + /** + * Load Gulliver Classes + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strClass + * @return void + */ + public function LoadSystem($strClass) { + require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + } + + /** + * Get the temporal directory path on differents O.S. + * i.e. /temp -> linux, C:/Temp -> win + * + * @author + */ + public function sys_get_temp_dir() { + if (! function_exists ( 'sys_get_temp_dir' )) { + // Based on http://www.phpit.net/ + // article/creating-zip-tar-archives-dynamically-php/2/ + // Try to get from environment variable + if (! empty ( $_ENV ['TMP'] )) { + return realpath ( $_ENV ['TMP'] ); + } elseif (! empty ( $_ENV ['TMPDIR'] )) { + return realpath ( $_ENV ['TMPDIR'] ); + } elseif (! empty ( $_ENV ['TEMP'] )) { + return realpath ( $_ENV ['TEMP'] ); + } else { + // Detect by creating a temporary file + // Try to use system's temporary directory as random name + // shouldn't exist + $temp_file = tempnam ( md5 ( uniqid ( rand (), true ) ), '' ); + if ($temp_file) { + $temp_dir = realpath ( dirname ( $temp_file ) ); + unlink ( $temp_file ); + return $temp_dir; + } else { + return false; + } + } + } else { + return sys_get_temp_dir (); + } + } + + /** + * Transform a public URL into a local path. + * + * @author David S. Callizaya S. + * @access public + * @param string $url + * @param string $corvertionTable + * @param string $realPath + * = local path + * @return boolean + */ + public function virtualURI($url, $convertionTable, &$realPath) { + foreach ( $convertionTable as $urlPattern => $localPath ) { + // $urlPattern = addcslashes( $urlPattern , '/'); + $urlPattern = addcslashes ( $urlPattern, './' ); + $urlPattern = '/^' . str_replace ( array ( + '*', + '?' + ), array ( + '.*', + '.?' + ), $urlPattern ) . '$/'; + if (preg_match ( $urlPattern, $url, $match )) { + if ($localPath === false) { + $realPath = $url; + return false; + } + if ($localPath != 'jsMethod') { + $realPath = $localPath . $match [1]; + } else { + $realPath = $localPath; + } + return true; + } + } + $realPath = $url; + return false; + } + + /** + * streaming a file + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + public function streamFile($file, $download = false, $downloadFileName = '') { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $folderarray = explode ( '/', $file ); + $typearray = explode ( '.', basename ( $file ) ); + $typefile = $typearray [count ( $typearray ) - 1]; + $filename = $file; + + // trick to generate the translation.language.js file , merging two + // files and then minified the content. + if (strtolower ( $typefile ) == 'js' && $typearray [0] == 'translation') { + $output = g::streamJSTranslationFile ( $filename, $typearray [1] ); + print $output; + return; + } + + // trick to generate the big css file for ext style . + if (strtolower ( $typefile ) == 'css' && $folderarray [count ( $folderarray ) - 2] == 'css') { + $output = g::streamCSSBigFile ( $typearray [0] ); + print $output; + return; + } + + if (file_exists ( $filename )) { + switch (strtolower ( $typefile )) { + case 'swf' : + g::sendHeaders ( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); + break; + case 'js' : + g::sendHeaders ( $filename, 'text/javascript', $download, $downloadFileName ); + break; + case 'htm' : + case 'html' : + g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'htc' : + g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'json' : + g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'gif' : + g::sendHeaders ( $filename, 'image/gif', $download, $downloadFileName ); + break; + case 'png' : + g::sendHeaders ( $filename, 'image/png', $download, $downloadFileName ); + break; + case 'jpg' : + g::sendHeaders ( $filename, 'image/jpg', $download, $downloadFileName ); + break; + case 'css' : + g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'css' : + g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'xml' : + g::sendHeaders ( $filename, 'text/xml', $download, $downloadFileName ); + break; + case 'txt' : + g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'doc' : + case 'pdf' : + case 'pm' : + case 'po' : + g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + case 'php' : + if ($download) { + g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); + } else { + require_once ($filename); + return; + } + break; + case 'tar' : + g::sendHeaders ( $filename, 'application/x-tar', $download, $downloadFileName ); + break; + default : + // throw new Exception ( "Unknown type of file '$file'. " ); + g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + break; + } + } else { + if (strpos ( $file, 'gulliver' ) !== false) { + list ( $path, $filename ) = explode ( 'gulliver', $file ); + } + + $_SESSION ['phpFileNotFound'] = $file; + g::header ( "location: /errors/error404.php?l=" . $_SERVER ['REQUEST_URI'] ); + } + + switch (strtolower ( $typefile )) { + case "js" : + $paths = explode ( '/', $filename ); + $jsName = $paths [count ( $paths ) - 1]; + $output = ''; + $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; + switch ($jsName) { + // + case 'draw2d.js' : + $cachePath = PATH_C . 'ExtJs' . PATH_SEP; + $checksum = g::getCheckSum ( array ( + $pathJs . 'ext/wz_jsgraphics.js', + $pathJs . 'ext/mootools.js', + $pathJs . 'ext/moocanvas.js' + ) ); + + $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; + $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-draw2d-cache.*.js' ); + // error_log("draw2d.js ".$checksum ."==". + // $cfStored['checksum']); + if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { + $output = file_get_contents ( $cf ); + } else { + if (is_file ( $cfStored ['filename'] )) { + @unlink ( $cfStored ['filename'] ); + } + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/wz_jsgraphics.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/mootools.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/moocanvas.js' ) ); + $output .= file_get_contents ( $pathJs . 'ext/draw2d.js' ); // already + // minified + file_put_contents ( $cf, $output ); + } + break; + case 'ext-all.js' : + $cachePath = PATH_C . 'ExtJs' . PATH_SEP; + $checksum = g::getCheckSum ( array ( + $pathJs . 'ext/pmos-common.js', + $pathJs . 'ext/ux/miframe.js', + $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js', + $pathJs . 'ext/ux.statusbar/ext-statusbar.js', + $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' + ) ); + + $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-all-cache.*.js' ); + $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; + if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { + $output = file_get_contents ( $cf ); + } else { + if (is_file ( $cfStored ['filename'] )) { + @unlink ( $cfStored ['filename'] ); + } + + $output .= file_get_contents ( $pathJs . 'ext/ext-all.js' ); // already + // minified + $output .= file_get_contents ( $pathJs . 'ext/ux/ux-all.js' ); // already + // minified + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/pmos-common.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux/miframe.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); + + file_put_contents ( $cf, $output ); + } + break; + case 'maborak.js' : + $oHeadPublisher = & headPublisher::getSingleton (); + foreach ( $oHeadPublisher->maborakFiles as $fileJS ) { + $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); + } + break; + case 'maborak.loader.js' : + $oHeadPublisher = & headPublisher::getSingleton (); + foreach ( $oHeadPublisher->maborakLoaderFiles as $fileJS ) { + $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); + } + break; + default : + $output = JSMin::minify ( file_get_contents ( $filename ) ); + break; + } + print $output; + break; + case 'css' : + print g::trimSourceCodeFile ( $filename ); + break; + default : + @readfile ( $filename ); + break; + } + } + + /** + * Parsing the URI + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + static public function parseURI($uri, $isRestRequest = false) { + // *** 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 ); + if ($isRestRequest) { + $args = self::parseRestUri ( $aRequestUri ); + } else { + $args = self::parseNormalUri ( $aRequestUri ); + } + + define ( "SYS_LANG", $args ['SYS_LANG'] ); + define ( "SYS_SKIN", $args ['SYS_SKIN'] ); + define ( 'SYS_COLLECTION', $args ['SYS_COLLECTION'] ); + define ( 'SYS_TARGET', $args ['SYS_TARGET'] ); + + if ($args ['SYS_COLLECTION'] == 'js2') { + print "ERROR"; + die (); + } + } + + /** + * isPMUnderUpdating, Used to set a file flag to check if PM is upgrading. + * + * @setFlag Contains the flag to set or unset the temporary file: + * 0 to delete the temporary file flag + * 1 to set the temporary file flag. + * 2 or bigger to check if the temporary file exists. + * return true if the file exists, otherwise false. + */ + public function isPMUnderUpdating($setFlag = 2) { + $fileCheck = PATH_DATA . "UPDATE.dat"; + if ($setFlag == 0) { + if (file_exists ( $fileCheck )) { + unlink ( $fileCheck ); + } + } elseif ($setFlag == 1) { + $fp = fopen ( $fileCheck, 'w' ); + $line = fputs ( $fp, "true" ); + } + // checking temporary file + if ($setFlag >= 1) { + if (file_exists ( $fileCheck )) { + return true; + } + } + return false; + } + + /** + * parse a smarty template and return teh result as string + * + * @author Erik Amaru Ortiz + * @param $template string + * containing the template filename on /gulliver/templates/ + * directory + * @param $data associative + * array containig the template data + * @return $content string containing the parsed template content + */ + public function parseTemplate($template, $data = array()) { + $content = ''; + + ob_start (); + g::renderTemplate ( $template, $data ); + $content = ob_get_contents (); + ob_get_clean (); + + return $content; + } + + /** + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ + public function LoadClass($strClass) { + $classfile = g::ExpandPath ( "classes" ) . 'class.' . $strClass . '.php'; + if (! file_exists ( $classfile )) { + if (file_exists ( PATH_GULLIVER . 'class.' . $strClass . '.php' )) { + return require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + } else { + return false; + } + } else { + return require_once ($classfile); + } + } + + /** + * Loads a Class. + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ + public function LoadThirdParty($sPath, $sFile) { + $classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr ( $sFile, 0, - 4 ) !== '.php') ? '.php' : ''); + return require_once ($classfile); + } + + /** + * Function LoadTranslationObject + * It generates a global Translation variable that will be used in all the + * system. + * Per script + * + * @author Hugo Loza. + * @access public + * @param + * eter string lang + * @return void + */ + public function LoadTranslationObject($lang = SYS_LANG) { + $defaultTranslations = Array (); + $foreignTranslations = Array (); + + // if the default translations table doesn't exist we can't proceed + if (! is_file ( PATH_LANGUAGECONT . 'translation.en' )) { + return null; + } + // load the translations table + require_once (PATH_LANGUAGECONT . 'translation.en'); + $defaultTranslations = $translation; + + // if some foreign language was requested and its translation file + // exists + if ($lang != 'en' && file_exists ( PATH_LANGUAGECONT . 'translation.' . $lang )) { + require_once (PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table + $foreignTranslations = $translation; + } + + global $translation; + if (defined ( "SHOW_UNTRANSLATED_AS_TAG" ) && SHOW_UNTRANSLATED_AS_TAG != 0) { + $translation = $foreignTranslations; + } else { + $translation = array_merge ( $defaultTranslations, $foreignTranslations ); + } + return true; + } + + /** + * Render Page + * + * @author Fernando Ontiveros Lira + * @access public + * @param object $objContent + * @param string $strTemplate + * @param string $strSkin + * @return void + */ + public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '') { + global $G_CONTENT; + global $G_TEMPLATE; + global $G_SKIN; + global $G_PUBLISH; + + $G_CONTENT = $objContent; + $G_TEMPLATE = $strTemplate; + $G_SKIN = $strSkin; + + try { + $file = g::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; + include $file; + $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); + $skinEngine->setLayout ( $layout ); + $skinEngine->dispatch (); + } catch ( Exception $e ) { + global $G_PUBLISH; + if (is_null ( $G_PUBLISH )) { + $G_PUBLISH = new Publisher (); + } + if (count ( $G_PUBLISH->Parts ) == 1) { + array_shift ( $G_PUBLISH->Parts ); + } + global $oHeadPublisher; + $leimnudInitString = $oHeadPublisher->leimnudInitString; + $oHeadPublisher->clearScripts (); + $oHeadPublisher->leimnudInitString = $leimnudInitString; + $oHeadPublisher->addScriptFile ( '/js/maborak/core/maborak.js' ); + $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', null, array ( + 'MESSAGE' => $e->getMessage () + ) ); + if (class_exists ( 'SkinEngine' )) { + $skinEngine = new SkinEngine ( 'publish', 'blank', '' ); + $skinEngine->dispatch (); + } else { + die ( $e->getMessage () ); + } + } + } + + /** + * SendTemporalMessage + * + * @param string $msgID + * @param string $strType + * @param string $sType + * default value 'LABEL' + * @param date $time + * default value null + * @param integer $width + * default value null + * @param string $customLabels + * default value null + * + * @return void + */ + public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null) { + if (isset ( $width )) { + $_SESSION ['G_MESSAGE_WIDTH'] = $width; + } + if (isset ( $time )) { + $_SESSION ['G_MESSAGE_TIME'] = $time; + } + switch (strtolower ( $sType )) { + case 'label' : + case 'labels' : + $_SESSION ['G_MESSAGE_TYPE'] = $strType; + $_SESSION ['G_MESSAGE'] = nl2br ( g::LoadTranslation ( $msgID ) ); + break; + case 'string' : + $_SESSION ['G_MESSAGE_TYPE'] = $strType; + $_SESSION ['G_MESSAGE'] = nl2br ( $msgID ); + break; + } + if ($customLabels != null) { + $message = $_SESSION ['G_MESSAGE']; + foreach ( $customLabels as $key => $val ) { + $message = str_replace ( '{' . nl2br ( $key ) . '}', nl2br ( $val ), $message ); + } + $_SESSION ['G_MESSAGE'] = $message; + } + } + + /** + * Redirect URL + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $parameter + * @return string + */ + public function header($parameter) { + if (defined ( 'ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr ( $parameter, 0, 9 ) == 'location:')) { + $url = g::encrypt ( substr ( $parameter, 10 ), URL_KEY ); + header ( 'location:' . $url ); + } else { + header ( $parameter ); + } + return; + } + + /** + * Include all model plugin files + * + * LoadAllPluginModelClasses + * + * @author Hugo Loza + * @access public + * @return void + */ + public function LoadAllPluginModelClasses() { + // Get the current Include path, where the plugins directories should be + if (! defined ( 'PATH_SEPARATOR' )) { + define ( 'PATH_SEPARATOR', (substr ( PHP_OS, 0, 3 ) == 'WIN') ? ';' : ':' ); + } + $path = explode ( PATH_SEPARATOR, get_include_path () ); + + foreach ( $path as $possiblePath ) { + if (strstr ( $possiblePath, "plugins" )) { + $baseDir = $possiblePath . 'classes' . PATH_SEP . 'model'; + if (file_exists ( $baseDir )) { + if ($handle = opendir ( $baseDir )) { + while ( false !== ($file = readdir ( $handle )) ) { + if (strpos ( $file, '.php', 1 ) && ! strpos ( $file, 'Peer.php', 1 )) { + require_once ($baseDir . PATH_SEP . $file); + } + } + } + // Include also the extendGulliverClass that could have some + // new definitions for fields + if (file_exists ( $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php' )) { + include_once $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php'; + } + } + } + } + } + + /** + * Expand the path using the path constants + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath + * @return string + */ + public function expandPath($strPath = '') { + $res = ""; + $res = PATH_CORE; + if ($strPath != "") { + $res .= $strPath . "/"; + } + return $res; + } + + /** + * This method allow dispatch rest services using 'Restler' thirdparty library + * + * @author Erik Amaru Ortiz + */ + public function dispatchRestService ($uri, $config, $apiClassesPath = '') + { + require_once 'restler/restler.php'; + + $rest = new Restler(); + $rest->setSupportedFormats( 'JsonFormat', 'XmlFormat' ); + // getting all services class + $restClasses = array (); + $restClassesList = g::rglob( '*', 0, PATH_CORE . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { + $restClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + } + } + if (! empty( $apiClassesPath )) { + $pluginRestClasses = array (); + $restClassesList = g::rglob( '*', 0, $apiClassesPath . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { + $pluginRestClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + } + } + $restClasses = array_merge( $restClasses, $pluginRestClasses ); + } + // hook to get rest api classes from plugins + if (class_exists( 'PMPluginRegistry' )) { + $pluginRegistry = & PMPluginRegistry::getSingleton(); + $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); + $restClasses = array_merge( $restClasses, $pluginClasses ); + } + foreach ($restClasses as $key => $classFile) { + if (! file_exists( $classFile )) { + unset( $restClasses[$key] ); + continue; + } + //load the file, and check if exist the class inside it. + require_once $classFile; + $namespace = 'Services_Rest_'; + $className = str_replace( '.php', '', basename( $classFile ) ); + + // if the core class does not exists try resolve the for a plugin + if (! class_exists( $namespace . $className )) { + $namespace = 'Plugin_Services_Rest_'; + // Couldn't resolve the class name, just skipp it + if (! class_exists( $namespace . $className )) { + unset( $restClasses[$key] ); + continue; + } + } + // verify if there is an auth class implementing 'iAuthenticate' + $classNameAuth = $namespace . $className; + $reflClass = new ReflectionClass( $classNameAuth ); + // that wasn't from plugin + if ($reflClass->implementsInterface( 'iAuthenticate' ) && $namespace != 'Plugin_Services_Rest_') { + // auth class found, set as restler authentication class handler + $rest->addAuthenticationClass( $classNameAuth ); + } else { + // add api class + $rest->addAPIClass( $classNameAuth ); + } + } + //end foreach rest class + // resolving the class for current request + $uriPart = explode( '/', $uri ); + $requestedClass = ''; + if (isset( $uriPart[1] )) { + $requestedClass = ucfirst( $uriPart[1] ); + } + if (class_exists( 'Services_Rest_' . $requestedClass )) { + $namespace = 'Services_Rest_'; + } elseif (class_exists( 'Plugin_Services_Rest_' . $requestedClass )) { + $namespace = 'Plugin_Services_Rest_'; + } else { + $namespace = ''; + } + // end resolv. + // Send additional headers (if exists) configured on rest-config.ini + if (array_key_exists( 'HEADERS', $config )) { + foreach ($config['HEADERS'] as $name => $value) { + header( "$name: $value" ); + } + } + // to handle a request with "OPTIONS" method + if (! empty( $namespace ) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { + $reflClass = new ReflectionClass( $namespace . $requestedClass ); + // if the rest class has not a "options" method + if (! $reflClass->hasMethod( 'options' )) { + header( 'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS' ); + header( 'Access-Control-Allow-Headers: authorization, content-type' ); + header( "Access-Control-Allow-Credentials", "false" ); + header( 'Access-Control-Max-Age: 60' ); + exit(); + } + } + // override global REQUEST_URI to pass to Restler library + $_SERVER['REQUEST_URI'] = '/' . strtolower( $namespace ) . ltrim( $uri, '/' ); + // handle the rest request + $rest->handle(); + } + + /** + * function to calculate the time used to render a page + */ + public 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 + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + public function streamJSTranslationFile($filename, $locale = 'en') { + header ( 'Content-Type: text/javascript' ); + + if (! g::LoadTranslationObject ( $locale )) { + header ( 'Cache-Control: no-cache' ); + header ( 'Pragma: no-cache' ); + return; + } + + global $translation; + + // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE + // behaivor. + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + if (file_exists ( $filename )) { + $mtime = filemtime ( $filename ); + } else { + $mtime = date ( 'U' ); + } + + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'Pragma: cache' ); + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 30 * 60 * 60 * 24 ) . " GMT" ); // 1 + // month + if (isset ( $_SERVER ['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER ['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header ( 'HTTP/1.1 304 Not Modified' ); + exit (); + } + } + + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + exit (); + } + } + + return JSMin::minify ( 'var TRANSLATIONS = ' . g::json_encode ( $translation ) . ';' ); + } + + /** + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @return string + */ + public function streamCSSBigFile ($filename) + { + header( 'Content-Type: text/css' ); + + //First get Skin info + $filenameParts = explode( "-", $filename ); + $skinName = $filenameParts[0]; + $skinVariant = "skin"; + + if (isset( $filenameParts[1] )) { + $skinVariant = strtolower( $filenameParts[1] ); + } + + $configurationFile = ''; + if ($skinName == "jscolors") { + $skinName = "classic"; + } + if ($skinName == "xmlcolors") { + $skinName = "classic"; + } + if ($skinName == "classic") { + $configurationFile = g::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; + } else { + $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; + + if (! is_file( $configurationFile )) { + $configurationFile = g::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; + } + } + + //Read Configuration File + $xmlConfiguration = file_get_contents( $configurationFile ); + $xmlConfigurationObj = g::xmlParser( $xmlConfiguration ); + $baseSkinDirectory = dirname( $configurationFile ); + $directorySize = g::getDirectorySize( $baseSkinDirectory ); + $mtime = $directorySize['maxmtime']; + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); + + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'Pragma: cache' ); + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 30 * 60 * 60 * 24 ) . " GMT" ); //1 month + //header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*60*24 ) . " GMT"); //1 day - tempor + if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header( 'HTTP/1.1 304 Not Modified' ); + exit(); + } + } + + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { + if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { + header( "HTTP/1.1 304 Not Modified" ); + exit(); + } + } + + $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; + $outputHeader .= " Skin: $filename\n"; + $outputHeader .= " Configuration: $configurationFile\n"; + $mtimeNow = date( 'U' ); + $gmt_mtimeNow = gmdate( "D, d M Y H:i:s", $mtimeNow ) . " GMT"; + $outputHeader .= " Date: $gmt_mtimeNow*/\n"; + $output = ""; + //Base files + switch (strtolower( $skinVariant )) { + case "extjs": + //Basepublic function getDirectorySize ($path, $maxmtime = 0) + { + $totalsize = 0; + $totalcount = 0; + $dircount = 0; + if ($handle = opendir( $path )) { + while (false !== ($file = readdir( $handle ))) { + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { + if (is_dir( $nextpath )) { + $dircount ++; + $result = g::getDirectorySize( $nextpath, $maxmtime ); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; + } elseif (is_file( $nextpath )) { + $totalsize += filesize( $nextpath ); + $totalcount ++; + + $mtime = filemtime( $nextpath ); + if ($mtime > $maxmtime) { + $maxmtime = $mtime; + } + } + } + } + } + closedir( $handle ); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + $total['maxmtime'] = $maxmtime; + + return $total; + } + + $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; + $output .= file_get_contents( $baseCSSPath . 'ext-all-notheme.css' ); + //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); + + //Classic Skin + $extJsSkin = 'xtheme-gray'; + + break; + default: + + break; + + } + + //Get Browser Info + $infoBrowser = g::browser_detection( 'full_assoc' ); + $browserName = $infoBrowser['browser_working']; + if (isset( $infoBrowser[$browserName . '_data'] )) { + if ($infoBrowser[$browserName . '_data'][0] != "") { + $browserName = $infoBrowser[$browserName . '_data'][0]; + } + } + + //Read Configuration File + $xmlConfiguration = file_get_contents ( $configurationFile ); + $xmlConfigurationObj = g::xmlParser($xmlConfiguration); + + $skinFilesArray=$xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['cssFiles']['__CONTENT__'][$skinVariant]['__CONTENT__']['cssFile'] ; + foreach ($skinFilesArray as $keyFile => $cssFileInfo) { + $enabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['enabledBrowsers']); + $disabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['disabledBrowsers']); + + if (((in_array($browserName, $enabledBrowsers))||(in_array('ALL', $enabledBrowsers)))&&(!(in_array($browserName, $disabledBrowsers)))) { + if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') { + g::LoadClass('serverConfiguration'); + $oServerConf =& serverConf::getSingleton(); + if (!(defined('SYS_LANG'))) { + if (isset($_SERVER['HTTP_REFERER'])) { + $syss = explode('://', $_SERVER['HTTP_REFERER']); + $sysObjets = explode('/', $syss['1']); + $sysLang = $sysObjets['2']; + } else { + $sysLang = 'en'; + } + } else { + $sysLang = SYS_LANG; + } + if ($oServerConf->isRtl($sysLang)) { + $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + } + } else { + $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + } + } + } + + //Remove comments.. + $regex = array ("`^([\t\s]+)`ism" => '',"`^\/\*(.+?)\*\/`ism" => "","`([\n\A;]+)\/\*(.+?)\*\/`ism" => "$1","`([\n\A;\s]+)//(.+?)[\n\r]`ism" => "$1\n","`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism" => "\n" ); + $output = preg_replace( array_keys( $regex ), $regex, $output ); + $output = $outputHeader . $output; + + return $output; + } + + /** + * sendHeaders + * + * @param string $filename + * @param string $contentType + * default value '' + * @param boolean $download + * default value false + * @param string $downloadFileName + * default value '' + * + * @return void + */ + public function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '') { + if ($download) { + if ($downloadFileName == '') { + $aAux = explode ( '/', $filename ); + $downloadFileName = $aAux [count ( $aAux ) - 1]; + } + header ( 'Content-Disposition: attachment; filename="' . $downloadFileName . '"' ); + } + header ( 'Content-Type: ' . $contentType ); + + // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE + // behaivor. + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + if (preg_match ( "/msie/i", $userAgent )) { + // if ( ereg("msie", $userAgent)) { + header ( 'Pragma: cache' ); + + $mtime = filemtime ( $filename ); + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 60 * 10 ) . " GMT" ); // ten + // minutes + return; + } + + if (! $download) { + + header ( 'Pragma: cache' ); + + if (file_exists ( $filename )) { + $mtime = filemtime ( $filename ); + } else { + $mtime = date ( 'U' ); + } + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + 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' ); + exit (); + } + } + + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + exit (); + } + } + } + } + + /** + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ + public function getCheckSum ($files) + { + g::LoadClass( 'system' ); + $key = System::getVersion(); + + if (! is_array( $files )) { + $tmp = $files; + $files = array (); + $files[0] = $tmp; + } + + $checkSum = ''; + foreach ($files as $file) { + if (is_file( $file )) { + $checkSum .= md5_file( $file ); + } + } + return md5( $checkSum . $key ); + } + + /** + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ + public function getCacheFileNameByPattern ($path, $pattern) + { + if ($file = glob( $path . $pattern )) { + preg_match( '/[a-f0-9]{32}/', $file[0], $match ); + } else { + $file[0] = ''; + } + return array ('filename' => $file[0],'checksum' => (isset( $match[0] ) ? $match[0] : '')); + } + + /** + * trimSourceCodeFile + * + * @param string $filename + * + * @return string $output + */ + public function trimSourceCodeFile ($filename) + { + $handle = fopen( $filename, "r" ); + $lastChar = ''; + $firstChar = ''; + $content = ''; + $line = ''; + + if ($handle) { + while (! feof( $handle )) { + //$line = trim( fgets($handle, 16096) ) . "\n" ; + $line = fgets( $handle, 16096 ); + $content .= $line; + } + fclose( $handle ); + } + return $content; + + $index = 0; + $output = ''; + while ($index < strlen( $content )) { + $car = $content[$index]; + $index ++; + if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { + $endComment = false; + $index ++; + while ($endComment == false && $index < strlen( $content )) { + if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { + $endComment = true; + $index ++; + } + $index ++; + } + $car = ''; + } + $output .= $car; + } + return $output; + } + + + /** + * strip_slashes + * @param vVar + */ + public 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 LoadTranslation + * + * @author Aldo Mauricio Veliz Valenzuela. + * @access public + * @param eter string msgID + * @param eter string file + * @param eter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label" + * @return string + */ + public function LoadTranslation ($msgID, $lang = SYS_LANG, $data = null) + { + global $translation; + + // if the second parameter $lang is an array does mean it was especified to use as data + if (is_array( $lang )) { + $data = $lang; + $lang = SYS_LANG; + } + + if (isset( $translation[$msgID] )) { + $translationString = preg_replace( "[\n|\r|\n\r]", ' ', $translation[$msgID] ); + + if (isset( $data ) && is_array( $data )) { + foreach ($data as $label => $value) { + $translationString = str_replace( '{' . $label . '}', $value, $translationString ); + } + } + + return $translationString; + } else { + if (defined( "UNTRANSLATED_MARK" )) { + $untranslatedMark = strip_tags( UNTRANSLATED_MARK ); + } else { + $untranslatedMark = "**"; + } + return $untranslatedMark . $msgID . $untranslatedMark; + } + + } + + /** + * Recursive version of glob php standard function + * + * @author Erik Amaru Ortiz + * + * @param $path path to scan recursively the write permission + * @param $flags to notive glob function + * @param $pattern pattern to filter some especified files + * @return array containing the recursive glob results + */ + public function rglob($pattern = '*', $flags = 0, $path = '') + { + $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); + $files = glob($path.$pattern, $flags); + foreach ($paths as $path) { + $files = array_merge($files, g::rglob($pattern, $flags, $path)); + } + return $files; + } + + /** + * JSON encode + * + * @author Erik A.O. + */ + public function json_encode($Json) + { + if ( function_exists('json_encode') ) { + return json_encode($Json); + } else { + g::LoadThirdParty('pear/json', 'class.json'); + $oJSON = new Services_JSON(); + return $oJSON->encode($Json); + } + } + + /** + * JSON decode + * + * @author Erik A.O. + */ + public function json_decode($Json) + { + if (function_exists('json_decode')) { + return json_decode($Json); + } else { + g::LoadThirdParty('pear/json', 'class.json'); + $oJSON = new Services_JSON(); + return $oJSON->decode($Json); + } + } + + + /** + * ************************************* init ********************************************** + * Xml parse collection functions + * Returns a associative array within the xml structure and data + * + * @author Erik Amaru Ortiz + */ + public function xmlParser (&$string) + { + $parser = xml_parser_create(); + xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); + xml_parse_into_struct( $parser, $string, $vals, $index ); + + $mnary = array (); + $ary = &$mnary; + foreach ($vals as $r) { + $t = $r['tag']; + if ($r['type'] == 'open') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) { + $ary[$t][] = array (); + } else { + $ary[$t] = array ($ary[$t],array () ); + } + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else { + $cv = &$ary[$t]; + } + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) { + $cv['__ATTRIBUTES__'][$k] = $v; + } + } + // note by gustavo cruz gustavo[at]colosa[dot]com + // minor adjustments to validate if an open node have a value attribute. + // for example a dropdown has many childs, but also can have a value attribute. + if (isset( $r['value'] ) && trim( $r['value'] ) != '') { + $cv['__VALUE__'] = $r['value']; + } + // end added code + $cv['__CONTENT__'] = array (); + $cv['__CONTENT__']['_p'] = &$ary; + $ary = &$cv['__CONTENT__']; + + } elseif ($r['type'] == 'complete') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) { + $ary[$t][] = array (); + } else { + $ary[$t] = array ($ary[$t],array ()); + } + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else { + $cv = &$ary[$t]; + } + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) { + $cv['__ATTRIBUTES__'][$k] = $v; + } + } + $cv['__VALUE__'] = (isset( $r['value'] ) ? $r['value'] : ''); + + } elseif ($r['type'] == 'close') { + $ary = &$ary['_p']; + } + } + + self::_del_p( $mnary ); + + $obj_resp->code = xml_get_error_code( $parser ); + $obj_resp->message = xml_error_string( $obj_resp->code ); + $obj_resp->result = $mnary; + xml_parser_free( $parser ); + + return $obj_resp; + } + + /** + * + * @param unknown_type $path + * @param unknown_type $maxmtime + * @return Ambigous + */ + public function getDirectorySize ($path, $maxmtime = 0) + { + $totalsize = 0; + $totalcount = 0; + $dircount = 0; + if ($handle = opendir( $path )) { + while (false !== ($file = readdir( $handle ))) { + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { + if (is_dir( $nextpath )) { + $dircount ++; + $result = g::getDirectorySize( $nextpath, $maxmtime ); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; + } elseif (is_file( $nextpath )) { + $totalsize += filesize( $nextpath ); + $totalcount ++; + + $mtime = filemtime( $nextpath ); + if ($mtime > $maxmtime) { + $maxmtime = $mtime; + } + } + } + } + } + closedir( $handle ); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + $total['maxmtime'] = $maxmtime; + + return $total; + } + + + /** + * _del_p + * + * @param string &$ary + * + * @return void + */ + // _Internal: Remove recursion in result array + public function _del_p (&$ary) + { + foreach ($ary as $k => $v) { + if ($k === '_p') { + unset( $ary[$k] ); + } elseif (is_array( $ary[$k] )) { + self::_del_p( $ary[$k] ); + } + } + } + + /** + * + * @param unknown_type $which_test + * @param unknown_type $test_excludes + * @param unknown_type $external_ua_string + * @return multitype:unknown string boolean number multitype:string unknown multitype:string Ambigous unknown multitype:string Ambigous |Ambigous unknown , multitype:string , Ambigous > + */ + public function browser_detection($which_test, $test_excludes = '', $external_ua_string = '') + { + g::script_time(); // set script timer to start timing + + static $a_full_assoc_data, $a_mobile_data, $a_moz_data, $a_webkit_data, $b_dom_browser, $b_repeat, $b_safe_browser, $browser_name, $browser_number, $browser_math_number, $browser_user_agent, $browser_working, $ie_version, $mobile_test, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date, $moz_type, $os_number, $os_type, $true_ie_number, $ua_type, $webkit_type, $webkit_type_number; + + // switch off the optimization for external ua string testing. + if ( $external_ua_string ) { + $b_repeat = false; + } + + /* + this makes the test only run once no matter how many times you call it since + all the variables are filled on the first run through, it's only a matter of + returning the the right ones + */ + if ( !$b_repeat ) { + //initialize all variables with default values to prevent error + $a_browser_math_number = ''; + $a_full_assoc_data = ''; + $a_full_data = ''; + $a_mobile_data = ''; + $a_moz_data = ''; + $a_os_data = ''; + $a_unhandled_browser = ''; + $a_webkit_data = ''; + $b_dom_browser = false; + $b_os_test = true; + $b_mobile_test = true; + $b_safe_browser = false; + $b_success = false;// boolean for if browser found in main test + $browser_math_number = ''; + $browser_temp = ''; + $browser_working = ''; + $browser_number = ''; + $ie_version = ''; + $mobile_test = ''; + $moz_release_date = ''; + $moz_rv = ''; + $moz_rv_full = ''; + $moz_type = ''; + $moz_number = ''; + $os_number = ''; + $os_type = ''; + $run_time = ''; + $true_ie_number = ''; + $ua_type = 'bot';// default to bot since you never know with bots + $webkit_type = ''; + $webkit_type_number = ''; + + // set the excludes if required + if ( $test_excludes ) { + switch ( $test_excludes ){ + case '1': + $b_os_test = false; + break; + case '2': + $b_mobile_test = false; + break; + case '3': + $b_os_test = false; + $b_mobile_test = false; + break; + default: + die( 'Error: bad $test_excludes parameter 2 used: ' . $test_excludes ); + break; + } + } + + /* + make navigator user agent string lower case to make sure all versions get caught + isset protects against blank user agent failure. tolower also lets the script use + strstr instead of stristr, which drops overhead slightly. + */ + if ( $external_ua_string ) { + $browser_user_agent = strtolower( $external_ua_string ); + } elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { + $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); + } else { + $browser_user_agent = ''; + } + + // known browsers, list will be updated routinely, check back now and then + $a_browser_types = array( + array( 'opera', true, 'op', 'bro' ), + array( 'msie', true, 'ie', 'bro' ), + // webkit before gecko because some webkit ua strings say: like gecko + array( 'webkit', true, 'webkit', 'bro' ), + // konq will be using webkit soon + array( 'konqueror', true, 'konq', 'bro' ), + // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below + array( 'gecko', true, 'moz', 'bro' ), + array( 'netpositive', false, 'netp', 'bbro' ),// beos browser + array( 'lynx', false, 'lynx', 'bbro' ), // command line browser + array( 'elinks ', false, 'elinks', 'bbro' ), // new version of links + array( 'elinks', false, 'elinks', 'bbro' ), // alternate id for it + array( 'links2', false, 'links2', 'bbro' ), // alternate links version + array( 'links ', false, 'links', 'bbro' ), // old name for links + array( 'links', false, 'links', 'bbro' ), // alternate id for it + array( 'w3m', false, 'w3m', 'bbro' ), // open source browser, more features than lynx/links + array( 'webtv', false, 'webtv', 'bbro' ),// junk ms webtv + array( 'amaya', false, 'amaya', 'bbro' ),// w3c browser + array( 'dillo', false, 'dillo', 'bbro' ),// linux browser, basic table support + array( 'ibrowse', false, 'ibrowse', 'bbro' ),// amiga browser + array( 'icab', false, 'icab', 'bro' ),// mac browser + array( 'crazy browser', true, 'ie', 'bro' ),// uses ie rendering engine + + // search engine spider bots: + array( 'bingbot', false, 'bing', 'bot' ),// bing + array( 'exabot', false, 'exabot', 'bot' ),// exabot + array( 'googlebot', false, 'google', 'bot' ),// google + array( 'google web preview', false, 'googlewp', 'bot' ),// google preview + array( 'mediapartners-google', false, 'adsense', 'bot' ),// google adsense + array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),// old yahoo bot + array( 'yahoo! slurp', false, 'yahoo', 'bot' ), // new yahoo bot + array( 'yahoo-mm', false, 'yahoomm', 'bot' ), // gets Yahoo-MMCrawler and Yahoo-MMAudVid bots + array( 'inktomi', false, 'inktomi', 'bot' ), // inktomi bot + array( 'slurp', false, 'inktomi', 'bot' ), // inktomi bot + array( 'fast-webcrawler', false, 'fast', 'bot' ),// Fast AllTheWeb + array( 'msnbot', false, 'msn', 'bot' ),// msn search + array( 'ask jeeves', false, 'ask', 'bot' ), //jeeves/teoma + array( 'teoma', false, 'ask', 'bot' ),//jeeves teoma + array( 'scooter', false, 'scooter', 'bot' ),// altavista + array( 'openbot', false, 'openbot', 'bot' ),// openbot, from taiwan + array( 'ia_archiver', false, 'ia_archiver', 'bot' ),// ia archiver + array( 'zyborg', false, 'looksmart', 'bot' ),// looksmart + array( 'almaden', false, 'ibm', 'bot' ),// ibm almaden web crawler + array( 'baiduspider', false, 'baidu', 'bot' ),// Baiduspider asian search spider + array( 'psbot', false, 'psbot', 'bot' ),// psbot image crawler + array( 'gigabot', false, 'gigabot', 'bot' ),// gigabot crawler + array( 'naverbot', false, 'naverbot', 'bot' ),// naverbot crawler, bad bot, block + array( 'surveybot', false, 'surveybot', 'bot' ),// + array( 'boitho.com-dc', false, 'boitho', 'bot' ),//norwegian search engine + array( 'objectssearch', false, 'objectsearch', 'bot' ),// open source search engine + array( 'answerbus', false, 'answerbus', 'bot' ),// http://www.answerbus.com/, web questions + array( 'sohu-search', false, 'sohu', 'bot' ),// chinese media company, search component + array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ), + + // various http utility libaries + array( 'w3c_validator', false, 'w3c', 'lib' ), // uses libperl, make first + array( 'wdg_validator', false, 'wdg', 'lib' ), // + array( 'libwww-perl', false, 'libwww-perl', 'lib' ), + array( 'jakarta commons-httpclient', false, 'jakarta', 'lib' ), + array( 'python-urllib', false, 'python-urllib', 'lib' ), + // download apps + array( 'getright', false, 'getright', 'dow' ), + array( 'wget', false, 'wget', 'dow' ),// open source downloader, obeys robots.txt + // netscape 4 and earlier tests, put last so spiders don't get caught + array( 'mozilla/4.', false, 'ns', 'bbro' ), + array( 'mozilla/3.', false, 'ns', 'bbro' ), + array( 'mozilla/2.', false, 'ns', 'bbro' ) + ); + + //array( '', false ); // browser array template + + /* + moz types array + note the order, netscape6 must come before netscape, which is how netscape 7 id's itself. + rv comes last in case it is plain old mozilla. firefox/netscape/seamonkey need to be later + Thanks to: http://www.zytrax.com/tech/web/firefox-history.html + */ + $a_moz_types = array( 'bonecho', 'camino', 'epiphany', 'firebird', 'flock', 'galeon', 'iceape', 'icecat', 'k-meleon', 'minimo', 'multizilla', 'phoenix', 'songbird', 'swiftfox', 'seamonkey', 'shiretoko', 'iceweasel', 'firefox', 'minefield', 'netscape6', 'netscape', 'rv' ); + + /* + webkit types, this is going to expand over time as webkit browsers spread + konqueror is probably going to move to webkit, so this is preparing for that + It will now default to khtml. gtklauncher is the temp id for epiphany, might + change. Defaults to applewebkit, and will all show the webkit number. + */ + $a_webkit_types = array( 'arora', 'chrome', 'epiphany', 'gtklauncher', 'konqueror', 'midori', 'omniweb', 'safari', 'uzbl', 'applewebkit', 'webkit' ); + + /* + run through the browser_types array, break if you hit a match, if no match, assume old browser + or non dom browser, assigns false value to $b_success. + */ + $i_count = count( $a_browser_types ); + for ($i = 0; $i < $i_count; $i++) { + //unpacks browser array, assigns to variables, need to not assign til found in string + $browser_temp = $a_browser_types[$i][0];// text string to id browser from array + + if ( strstr( $browser_user_agent, $browser_temp ) ) { + /* + it defaults to true, will become false below if needed + this keeps it easier to keep track of what is safe, only + explicit false assignment will make it false. + */ + $b_safe_browser = true; + $browser_name = $browser_temp;// text string to id browser from array + + // assign values based on match of user agent string + $b_dom_browser = $a_browser_types[$i][1];// hardcoded dom support from array + $browser_working = $a_browser_types[$i][2];// working name for browser + $ua_type = $a_browser_types[$i][3];// sets whether bot or browser + + switch ( $browser_working ) { + // this is modified quite a bit, now will return proper netscape version number + // check your implementation to make sure it works + case 'ns': + $b_safe_browser = false; + $browser_number = g::get_item_version( $browser_user_agent, 'mozilla' ); + break; + case 'moz': + /* + note: The 'rv' test is not absolute since the rv number is very different on + different versions, for example Galean doesn't use the same rv version as Mozilla, + neither do later Netscapes, like 7.x. For more on this, read the full mozilla + numbering conventions here: http://www.mozilla.org/releases/cvstags.html + */ + // this will return alpha and beta version numbers, if present + $moz_rv_full = g::get_item_version( $browser_user_agent, 'rv' ); + // this slices them back off for math comparisons + $moz_rv = substr( $moz_rv_full, 0, 3 ); + + // this is to pull out specific mozilla versions, firebird, netscape etc.. + $j_count = count( $a_moz_types ); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $browser_user_agent, $a_moz_types[$j] ) ) { + $moz_type = $a_moz_types[$j]; + $moz_number = g::get_item_version( $browser_user_agent, $moz_type ); + break; + } + } + /* + this is necesary to protect against false id'ed moz'es and new moz'es. + this corrects for galeon, or any other moz browser without an rv number + */ + if ( !$moz_rv ) { + // you can use this if you are running php >= 4.2 + if ( function_exists( 'floatval' ) ) { + $moz_rv = floatval( $moz_number ); + } else { + $moz_rv = substr( $moz_number, 0, 3 ); + } + $moz_rv_full = $moz_number; + } + // this corrects the version name in case it went to the default 'rv' for the test + if ( $moz_type == 'rv' ) { + $moz_type = 'mozilla'; + } + + //the moz version will be taken from the rv number, see notes above for rv problems + $browser_number = $moz_rv; + // gets the actual release date, necessary if you need to do functionality tests + g::get_set_count( 'set', 0 ); + $moz_release_date = g::get_item_version( $browser_user_agent, 'gecko/' ); + /* + Test for mozilla 0.9.x / netscape 6.x + test your javascript/CSS to see if it works in these mozilla releases, if it + does, just default it to: $b_safe_browser = true; + */ + if ( ( $moz_release_date < 20020400 ) || ( $moz_rv < 1 ) ) { + $b_safe_browser = false; + } + break; + case 'ie': + /* + note we're adding in the trident/ search to return only first instance in case + of msie 8, and we're triggering the break last condition in the test, as well + as the test for a second search string, trident/ + */ + $browser_number = g::get_item_version( $browser_user_agent, $browser_name, true, 'trident/' ); + // construct the proper real number if it's in compat mode and msie 8.0/9.0 + if ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/5' ) ) { + // note that 7.0 becomes 9 when adding 1, but if it's 7.1 it will be 9.1 + $true_ie_number = $browser_number + 2; + } elseif ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/4' ) ) { + // note that 7.0 becomes 8 when adding 1, but if it's 7.1 it will be 8.1 + $true_ie_number = $browser_number + 1; + } + // the 9 series is finally standards compatible, html 5 etc, so worth a new id + if ( $browser_number >= 9 ) { + $ie_version = 'ie9x'; + } elseif ( $browser_number >= 7 ) { + $ie_version = 'ie7x'; + } elseif ( strstr( $browser_user_agent, 'mac') ) { + $ie_version = 'ieMac'; + } elseif ( $browser_number >= 5 ) { + $ie_version = 'ie5x'; + } elseif ( ( $browser_number > 3 ) && ( $browser_number < 5 ) ) { + $b_dom_browser = false; + $ie_version = 'ie4'; + // this depends on what you're using the script for, make sure this fits your needs + $b_safe_browser = true; + } else { + $ie_version = 'old'; + $b_dom_browser = false; + $b_safe_browser = false; + } + break; + case 'op': + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + // opera is leaving version at 9.80 (or xx) for 10.x - see this for explanation + // http://dev.opera.com/articles/view/opera-ua-string-changes/ + if ( strstr( $browser_number, '9.' ) && strstr( $browser_user_agent, 'version/' ) ) { + g::get_set_count( 'set', 0 ); + $browser_number = g::get_item_version( $browser_user_agent, 'version/' ); + } + + if ( $browser_number < 5 ) { + $b_safe_browser = false; + } + break; + case 'webkit': + // note that this is the Webkit version number + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + // this is to pull out specific webkit versions, safari, google-chrome etc.. + $j_count = count( $a_webkit_types ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $browser_user_agent, $a_webkit_types[$j])) { + $webkit_type = $a_webkit_types[$j]; + if ( $webkit_type == 'omniweb' ) { + g::get_set_count( 'set', 2 ); + } + $webkit_type_number = g::get_item_version( $browser_user_agent, $webkit_type ); + // epiphany hack + if ( $a_webkit_types[$j] == 'gtklauncher' ) { + $browser_name = 'epiphany'; + } else { + $browser_name = $a_webkit_types[$j]; + } + break; + } + } + break; + default: + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + break; + } + // the browser was id'ed + $b_success = true; + break; + } + } + + //assigns defaults if the browser was not found in the loop test + if ( !$b_success ) { + /* + this will return the first part of the browser string if the above id's failed + usually the first part of the browser string has the navigator useragent name/version in it. + This will usually correctly id the browser and the browser number if it didn't get + caught by the above routine. + If you want a '' to do a if browser == '' type test, just comment out all lines below + except for the last line, and uncomment the last line. If you want undefined values, + the browser_name is '', you can always test for that + */ + // delete this part if you want an unknown browser returned + $browser_name = substr( $browser_user_agent, 0, strcspn( $browser_user_agent , '();') ); + // this extracts just the browser name from the string, if something usable was found + if ( $browser_name && preg_match( '/[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*/', $browser_name, $a_unhandled_browser ) ) { + $browser_name = $a_unhandled_browser[0]; + if ( $browser_name == 'blackberry' ) { + g::get_set_count( 'set', 0 ); + } + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + } else { + $browser_name = 'NA'; + $browser_number = 'NA'; + } + } + // get os data, mac os x test requires browser/version information, this is a change from older scripts + if ($b_os_test) { + $a_os_data = g::get_os_data( $browser_user_agent, $browser_working, $browser_number ); + $os_type = $a_os_data[0];// os name, abbreviated + $os_number = $a_os_data[1];// os number or version if available + } + /* + this ends the run through once if clause, set the boolean + to true so the function won't retest everything + */ + $b_repeat = true; + if ($browser_number && preg_match( '/[0-9]*\.*[0-9]*/', $browser_number, $a_browser_math_number ) ) { + $browser_math_number = $a_browser_math_number[0]; + } + if ( $b_mobile_test ) { + $mobile_test = g::check_is_mobile( $browser_user_agent ); + if ( $mobile_test ) { + $a_mobile_data = g::get_mobile_data( $browser_user_agent ); + $ua_type = 'mobile'; + } + } + } + + switch ($which_test) { + case 'math_number': + $which_test = 'browser_math_number'; + break; + case 'number': + $which_test = 'browser_number'; + break; + case 'browser': + $which_test = 'browser_working'; + break; + case 'moz_version': + $which_test = 'moz_data'; + break; + case 'true_msie_version': + $which_test = 'true_ie_number'; + break; + case 'type': + $which_test = 'ua_type'; + break; + case 'webkit_version': + $which_test = 'webkit_data'; + break; + } + /* + assemble these first so they can be included in full return data, using static variables + Note that there's no need to keep repacking these every time the script is called + */ + if (!$a_moz_data) { + $a_moz_data = array( $moz_type, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date ); + } + if (!$a_webkit_data) { + $a_webkit_data = array( $webkit_type, $webkit_type_number, $browser_number ); + } + $run_time = g::script_time(); + + if ( !$a_full_assoc_data ) { + $a_full_assoc_data = array( + 'browser_working' => $browser_working, + 'browser_number' => $browser_number, + 'ie_version' => $ie_version, + 'dom' => $b_dom_browser, + 'safe' => $b_safe_browser, + 'os' => $os_type, + 'os_number' => $os_number, + 'browser_name' => $browser_name, + 'ua_type' => $ua_type, + 'browser_math_number' => $browser_math_number, + 'moz_data' => $a_moz_data, + 'webkit_data' => $a_webkit_data, + 'mobile_test' => $mobile_test, + 'mobile_data' => $a_mobile_data, + 'true_ie_number' => $true_ie_number, + 'run_time' => $run_time + ); + } + + // return parameters, either full data arrays, or by associative array index key + switch ($which_test) { + // returns all relevant browser information in an array with standard numberic indexes + case 'full': + $a_full_data = array($browser_working, + $browser_number, + $ie_version, + $b_dom_browser, + $b_safe_browser, + $os_type, + $os_number, + $browser_name, + $ua_type, + $browser_math_number, + $a_moz_data, + $a_webkit_data, + $mobile_test, + $a_mobile_data, + $true_ie_number, + $run_time + ); + return $a_full_data; + break; + case 'full_assoc': + return $a_full_assoc_data; + break; + default: + # check to see if the data is available, otherwise it's user typo of unsupported option + if (isset( $a_full_assoc_data[$which_test])) { + return $a_full_assoc_data[$which_test]; + } else { + die( "You passed the browser detector an unsupported option for parameter 1: " . $which_test ); + } + break; + } + } + + /** + * track total script execution time + */ + public function script_time () + { + static $script_time; + $elapsed_time = ''; + /* + note that microtime(true) requires php 5 or greater for microtime(true) + */ + if (sprintf( "%01.1f", phpversion() ) >= 5) { + if (is_null( $script_time )) { + $script_time = microtime( true ); + } else { + // note: (string)$var is same as strval($var) + // $elapsed_time = (string)( microtime(true) - $script_time ); + $elapsed_time = (microtime( true ) - $script_time); + $elapsed_time = sprintf( "%01.8f", $elapsed_time ); + $script_time = null; // can't unset a static variable + return $elapsed_time; + } + } + } + + /** + * + * @param unknown_type $pv_browser_user_agent + * @param unknown_type $pv_search_string + * @param unknown_type $pv_b_break_last + * @param unknown_type $pv_extra_search + * @return string + */ + public function get_item_version($pv_browser_user_agent, $pv_search_string, $pv_b_break_last = '', $pv_extra_search = '') + { + $substring_length = 15; + $start_pos = 0; // set $start_pos to 0 for first iteration + $string_working_number = ''; + for ($i = 0; $i < 4; $i++) { + //start the search after the first string occurrence + if (strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) !== false) { + $start_pos = strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) + strlen( $pv_search_string ); + if (!$pv_b_break_last || ( $pv_extra_search && strstr( $pv_browser_user_agent, $pv_extra_search ) )) { + break; + } + } else { + break; + } + } + + $start_pos += g::get_set_count( 'get' ); + $string_working_number = substr( $pv_browser_user_agent, $start_pos, $substring_length ); + $string_working_number = substr( $string_working_number, 0, strcspn($string_working_number, ' );/') ); + if (!is_numeric( substr( $string_working_number, 0, 1 ))) { + $string_working_number = ''; + } + return $string_working_number; + } + + /** + * + * @param unknown_type $pv_type + * @param unknown_type $pv_value + */ + public function get_set_count($pv_type, $pv_value = '') + { + static $slice_increment; + $return_value = ''; + switch ( $pv_type ) { + case 'get': + if ( is_null( $slice_increment ) ) { + $slice_increment = 1; + } + $return_value = $slice_increment; + $slice_increment = 1; // reset to default + return $return_value; + break; + case 'set': + $slice_increment = $pv_value; + break; + } + } + + /** + * gets which os from the browser string + */ + public function get_os_data ($pv_browser_string, $pv_browser_name, $pv_version_number) + { + // initialize variables + $os_working_type = ''; + $os_working_number = ''; + /* + packs the os array. Use this order since some navigator user agents will put 'macintosh' + in the navigator user agent string which would make the nt test register true + */ + $a_mac = array( 'intel mac', 'ppc mac', 'mac68k' );// this is not used currently + // same logic, check in order to catch the os's in order, last is always default item + $a_unix_types = array( 'dragonfly', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'unixware', 'solaris', 'sunos', 'sun4', 'sun5', 'suni86', 'sun', 'irix5', 'irix6', 'irix', 'hpux9', 'hpux10', 'hpux11', 'hpux', 'hp-ux', 'aix1', 'aix2', 'aix3', 'aix4', 'aix5', 'aix', 'sco', 'unixware', 'mpras', 'reliant', 'dec', 'sinix', 'unix' ); + // only sometimes will you get a linux distro to id itself... + $a_linux_distros = array( 'ubuntu', 'kubuntu', 'xubuntu', 'mepis', 'xandros', 'linspire', 'winspire', 'jolicloud', 'sidux', 'kanotix', 'debian', 'opensuse', 'suse', 'fedora', 'redhat', 'slackware', 'slax', 'mandrake', 'mandriva', 'gentoo', 'sabayon', 'linux' ); + $a_linux_process = array ( 'i386', 'i586', 'i686' );// not use currently + // note, order of os very important in os array, you will get failed ids if changed + $a_os_types = array( 'android', 'blackberry', 'iphone', 'palmos', 'palmsource', 'symbian', 'beos', 'os2', 'amiga', 'webtv', 'mac', 'nt', 'win', $a_unix_types, $a_linux_distros ); + + //os tester + $i_count = count( $a_os_types ); + for ($i = 0; $i < $i_count; $i++) { + // unpacks os array, assigns to variable $a_os_working + $os_working_data = $a_os_types[$i]; + /* + assign os to global os variable, os flag true on success + !strstr($pv_browser_string, "linux" ) corrects a linux detection bug + */ + if (!is_array($os_working_data) && strstr($pv_browser_string, $os_working_data ) && !strstr( $pv_browser_string, "linux")) { + $os_working_type = $os_working_data; + + switch ($os_working_type) { + // most windows now uses: NT X.Y syntax + case 'nt': + if (strstr( $pv_browser_string, 'nt 6.1' )) { + $os_working_number = 6.1; + } elseif (strstr( $pv_browser_string, 'nt 6.0')) { + $os_working_number = 6.0; + } elseif (strstr( $pv_browser_string, 'nt 5.2')) { + $os_working_number = 5.2; + } elseif (strstr( $pv_browser_string, 'nt 5.1') || strstr( $pv_browser_string, 'xp')) { + $os_working_number = 5.1;// + } elseif (strstr( $pv_browser_string, 'nt 5') || strstr( $pv_browser_string, '2000')) { + $os_working_number = 5.0; + } elseif (strstr( $pv_browser_string, 'nt 4')) { + $os_working_number = 4; + } elseif (strstr( $pv_browser_string, 'nt 3')) { + $os_working_number = 3; + } + break; + case 'win': + if (strstr( $pv_browser_string, 'vista')) { + $os_working_number = 6.0; + $os_working_type = 'nt'; + } elseif ( strstr( $pv_browser_string, 'xp')) { + $os_working_number = 5.1; + $os_working_type = 'nt'; + } elseif ( strstr( $pv_browser_string, '2003')) { + $os_working_number = 5.2; + $os_working_type = 'nt'; + } + elseif ( strstr( $pv_browser_string, 'windows ce' ) )// windows CE + { + $os_working_number = 'ce'; + $os_working_type = 'nt'; + } + elseif ( strstr( $pv_browser_string, '95' ) ) + { + $os_working_number = '95'; + } + elseif ( ( strstr( $pv_browser_string, '9x 4.9' ) ) || ( strstr( $pv_browser_string, ' me' ) ) ) + { + $os_working_number = 'me'; + } + elseif ( strstr( $pv_browser_string, '98' ) ) + { + $os_working_number = '98'; + } + elseif ( strstr( $pv_browser_string, '2000' ) )// windows 2000, for opera ID + { + $os_working_number = 5.0; + $os_working_type = 'nt'; + } + break; + case 'mac': + if (strstr($pv_browser_string, 'os x')) { + if (strstr($pv_browser_string, 'os x ')) { + $os_working_number = str_replace( '_', '.', g::get_item_version( $pv_browser_string, 'os x' ) ); + } else { + $os_working_number = 10; + } + } elseif ( ( $pv_browser_name == 'saf' ) || ( $pv_browser_name == 'cam' ) || + ( ( $pv_browser_name == 'moz' ) && ( $pv_version_number >= 1.3 ) ) || + ( ( $pv_browser_name == 'ie' ) && ( $pv_version_number >= 5.2 ) ) ) { + $os_working_number = 10; + } + break; + case 'iphone': + $os_working_number = 10; + break; + default: + break; + } + break; + } elseif ( is_array( $os_working_data ) && ( $i == ( $i_count - 2 ) ) ) { + $j_count = count($os_working_data); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $pv_browser_string, $os_working_data[$j])) { + $os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously... + $os_working_number = ( $os_working_data[$j] != 'unix' ) ? $os_working_data[$j] : '';// assign sub unix version from the unix array + break; + } + } + } elseif (is_array( $os_working_data ) && ( $i == ( $i_count - 1 ))) { + $j_count = count($os_working_data); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $pv_browser_string, $os_working_data[$j] )) { + $os_working_type = 'lin'; + // assign linux distro from the linux array, there's a default + //search for 'lin', if it's that, set version to '' + $os_working_number = ( $os_working_data[$j] != 'linux' ) ? $os_working_data[$j] : ''; + break; + } + } + } + } + + // pack the os data array for return to main function + $a_os_data = array( $os_working_type, $os_working_number ); + + return $a_os_data; + } + + /** + * + * @param unknown_type $pv_browser_user_agent + * @return string + */ + public function check_is_mobile($pv_browser_user_agent) + { + $mobile_working_test = ''; + $a_mobile_search = array( + 'android', 'epoc', 'linux armv', 'palmos', 'palmsource', 'windows ce', 'windows phone os', 'symbianos', 'symbian os', 'symbian', 'webos', + // devices - ipod before iphone or fails + 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lge ', 'lge-', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zune', 'j-phone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'sec-', 'sie-m', 'sie-s', 'spv ', 'vodaphone', 'smartphone', 'armv', 'midp', 'mobilephone', + // browsers + 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino', + // services - astel out of business + 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' + ); + + // then do basic mobile type search, this uses data from: get_mobile_data() + $j_count = count( $a_mobile_search ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $pv_browser_user_agent, $a_mobile_search[$j] )) { + $mobile_working_test = $a_mobile_search[$j]; + break; + } + } + return $mobile_working_test; + } + + /** + * + * @param unknown_type $pv_browser_user_agent + */ + public function get_mobile_data ($pv_browser_user_agent) + { + $mobile_browser = ''; + $mobile_browser_number = ''; + $mobile_device = ''; + $mobile_device_number = ''; + $mobile_os = ''; // will usually be null, sorry + $mobile_os_number = ''; + $mobile_server = ''; + $mobile_server_number = ''; + + $a_mobile_browser = array( 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino' ); + $a_mobile_device = array( 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'htc_dream', 'htc espresso', 'htc hero', 'htc halo', 'htc huangshan', 'htc legend', 'htc liberty', 'htc paradise', 'htc supersonic', 'htc tattoo', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zunehd', 'zune', 'j-phone', 'milestone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'lge ', 'lge-', 'sec-', 'sie-m', 'sie-s', 'spv ', 'smartphone', 'armv', 'midp', 'mobilephone' ); + $a_mobile_os = array( 'android', 'epoc', 'cpu os', 'iphone os', 'palmos', 'palmsource', 'windows phone os', 'windows ce', 'symbianos', 'symbian os', 'symbian', 'webos', 'linux armv' ); + $a_mobile_server = array( 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' ); + + $k_count = count( $a_mobile_browser ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_browser[$k] )) { + $mobile_browser = $a_mobile_browser[$k]; + $mobile_browser_number = g::get_item_version( $pv_browser_user_agent, $mobile_browser ); + break; + } + } + $k_count = count( $a_mobile_device ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_device[$k] )) { + $mobile_device = trim ( $a_mobile_device[$k], '-_' ); // but not space trims yet + if ($mobile_device == 'blackberry') { + g::get_set_count( 'set', 0 ); + } + $mobile_device_number = g::get_item_version( $pv_browser_user_agent, $mobile_device ); + $mobile_device = trim( $mobile_device ); // some of the id search strings have white space + break; + } + } + $k_count = count( $a_mobile_os ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_os[$k] )) { + $mobile_os = $a_mobile_os[$k]; + $mobile_os_number = str_replace( '_', '.', g::get_item_version( $pv_browser_user_agent, $mobile_os ) ); + break; + } + } + $k_count = count( $a_mobile_server ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_server[$k] )) { + $mobile_server = $a_mobile_server[$k]; + $mobile_server_number = g::get_item_version( $pv_browser_user_agent, $mobile_server ); + break; + } + } + // just for cases where we know it's a mobile device already + if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr( $pv_browser_user_agent, 'linux' ) ) { + $mobile_os = 'linux'; + $mobile_os_number = g::get_item_version( $pv_browser_user_agent, 'linux' ); + } + + $a_mobile_data = array( $mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number, $mobile_device_number ); + return $a_mobile_data; + } + + /** + * + * @param unknown_type $requestUri + */ + public function parseRestUri ($requestUri) + { + $args = array (); + //$args['SYS_TEMP'] = $requestUri[1]; + define( 'SYS_TEMP', $requestUri[2] ); + $restUri = ''; + + for ($i = 3; $i < count( $requestUri ); $i ++) { + $restUri .= '/' . $requestUri[$i]; + } + + $args['SYS_LANG'] = 'en'; // TODO, this can be set from http header + $args['SYS_SKIN'] = ''; + $args['SYS_COLLECTION'] = ''; + $args['SYS_TARGET'] = $restUri; + + return $args; + } + + /** + * + * @param unknown_type $aRequestUri + * @return multitype:string mixed Ambigous + */ + public function parseNormalUri ($aRequestUri) + { + if (substr( $aRequestUri[1], 0, 3 ) == 'sys') { + define( 'SYS_TEMP', substr( $aRequestUri[1], 3 ) ); + } else { + define( "ENABLE_ENCRYPT", 'yes' ); + define( 'SYS_TEMP', $aRequestUri[1] ); + $plain = '/sys' . SYS_TEMP; + + for ($i = 2; $i < count( $aRequestUri ); $i ++) { + $decoded = g::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); + if ($decoded == 'sWì›') { + $decoded = $VARS[$i]; //this is for the string "../" + } + $plain .= '/' . $decoded; + } + $_SERVER["REQUEST_URI"] = $plain; + } + + $work = explode( '?', $_SERVER["REQUEST_URI"] ); + + if (count( $work ) > 1) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } else { + define( 'SYS_CURRENT_PARMS', '' ); + } + + define( 'SYS_CURRENT_URI', $work[0] ); + + if (! defined( 'SYS_CURRENT_PARMS' )) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } + + $preArray = explode( '&', SYS_CURRENT_PARMS ); + $buffer = explode( '.', $work[0] ); + + if (count( $buffer ) == 1) { + $buffer[1] = ''; + } + + //request type + define( 'REQUEST_TYPE', ($buffer[1] != "" ? $buffer[1] : 'html') ); + + $toparse = substr( $buffer[0], 1, strlen( $buffer[0] ) - 1 ); + $uriVars = explode( '/', $toparse ); + + unset( $work ); + unset( $buffer ); + unset( $toparse ); + array_shift( $uriVars ); + + $args = array (); + $args['SYS_LANG'] = array_shift( $uriVars ); + $args['SYS_SKIN'] = array_shift( $uriVars ); + $args['SYS_COLLECTION'] = array_shift( $uriVars ); + $args['SYS_TARGET'] = array_shift( $uriVars ); + + //to enable more than 2 directories...in the methods structure + while (count( $uriVars ) > 0) { + $args['SYS_TARGET'] .= '/' . array_shift( $uriVars ); + } + + /* Fix to prevent use uxs skin outside siplified interface, + because that skin is not compatible with others interfaces*/ + if ($args['SYS_SKIN'] == 'uxs' && $args['SYS_COLLECTION'] != 'home' && $args['SYS_COLLECTION'] != 'cases') { + $config = System::getSystemConfiguration(); + $args['SYS_SKIN'] = $config['default_skin']; + } + + return $args; + } + + /** + * * Encrypt and decrypt functions *** + */ + /** + * Encrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + public function encrypt ($string, $key) + { + //print $string; + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + if (strpos( $string, '|', 0 ) !== false) { + return $string; + } + $result = ''; + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) + ord( $keychar ) ); + $result .= $char; + } + + $result = base64_encode( $result ); + $result = str_replace( '/', '°', $result ); + $result = str_replace( '=', '', $result ); + return $result; + } + + /** + * Decrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + public function decrypt ($string, $key) + { + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + //if (strpos($string, '|', 0) !== false) return $string; + $result = ''; + $string = str_replace( '°', '/', $string ); + $string_jhl = explode( "?", $string ); + $string = base64_decode( $string ); + $string = base64_decode( $string_jhl[0] ); + + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) - ord( $keychar ) ); + $result .= $char; + } + if (! empty( $string_jhl[1] )) { + $result .= '?' . $string_jhl[1]; + } + return $result; + } + + /** + * + * @param unknown_type $model + * @return unknown + */ + public function getModel($model) + { + require_once "classes/model/$model.php"; + return new $model(); + } + + /** + * Create an encrypted unique identifier based on $id and the selected scope id. + * + * @author David S. Callizaya S. + * @access public + * @param string $scope + * @param string $id + * @return string + */ + public function createUID ($scope, $id) + { + $e = $scope . $id; + $e = g::encrypt( $e, URL_KEY ); + $e = str_replace( array ('+','/','=' + ), array ('__','_','___' + ), base64_encode( $e ) ); + return $e; + } + + /** + * (Create an encrypted unique identificator based on $id and the selected scope id.) ^-1 + * getUIDName + * + * @author David S. Callizaya S. + * @access public + * @param string $id + * @param string $scope + * @return string + */ + public function getUIDName ($uid, $scope = '') + { + $e = str_replace( array ('=','+','/' + ), array ('___','__','_' + ), $uid ); + $e = base64_decode( $e ); + $e = g::decrypt( $e, URL_KEY ); + $e = substr( $e, strlen( $scope ) ); + return $e; + } + + /** + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @return array + */ + public function array_merges () + { + $array = array (); + $arrays = & func_get_args(); + foreach ($arrays as $array_i) { + if (is_array( $array_i )) { + g::array_merge_2( $array, $array_i ); + } + } + return $array; + } + + /** + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $array + * @param string $array_i + * @return array + */ + public function array_merge_2 (&$array, &$array_i) + { + foreach ($array_i as $k => $v) { + if (is_array( $v )) { + if (! isset( $array[$k] )) { + $array[$k] = array (); + } + g::array_merge_2( $array[$k], $v ); + } else { + if (isset( $array[$k] ) && is_array( $array[$k] )) { + $array[$k][0] = $v; + } else { + if (isset( $array ) && ! is_array( $array )) { + $temp = $array; + $array = array(); + $array[0] = $temp; + } + $array[$k] = $v; + } + } + } + } + + /* Returns a sql string with @@parameters replaced with its values defined + * in array $result using the next notation: + * NOTATION: + * @@ Quoted parameter acording to the SYSTEM's Database + * @Q Double quoted parameter \\ \" + * @q Single quoted parameter \\ \' + * @% URL string + * @# Non-quoted parameter + * @! Evaluate string : Replace the parameters in value and then in the sql string + * @fn() Evaluate string with the function "fn" + * @author David Callizaya + */ + public function replaceDataField ($sqlString, $result, $DBEngine = 'mysql') + { + if (! is_array( $result )) { + $result = array (); + } + $result = $result + g::getSystemConstants(); + $__textoEval = ""; + $u = 0; + //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); + $count = preg_match_all( '/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sqlString, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); + if ($count) { + for ($r = 0; $r < $count; $r ++) { + if (! isset( $result[$match[2][$r][0]] )) { + $result[$match[2][$r][0]] = ''; + } + if (! is_array( $result[$match[2][$r][0]] )) { + $__textoEval .= substr( $sqlString, $u, $match[0][$r][1] - $u ); + $u = $match[0][$r][1] + strlen( $match[0][$r][0] ); + //Mysql quotes scape + if (($match[1][$r][0] == '@') && (isset( $result[$match[2][$r][0]] ))) { + $__textoEval .= "\"" . g::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; + continue; + } + //URL encode + if (($match[1][$r][0]=='%')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=urlencode($result[$match[2][$r][0]]); + continue; + } + //Double quoted parameter + if (($match[1][$r][0]=='Q')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.='"'.addcslashes($result[$match[2][$r][0]],'\\"').'"'; + continue; + } + //Single quoted parameter + if (($match[1][$r][0]=='q')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.="'".addcslashes($result[$match[2][$r][0]],'\\\'')."'"; + continue; + } + //Substring (Sub replaceDataField) + if (($match[1][$r][0]=='!')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + //Call function + if (($match[1][$r][0]==='')&&($match[2][$r][0]==='')&&($match[3][$r][0]!=='')) { + eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(g::replaceDataField(stripslashes($match[4][$r][0]),$result),'\\\'') . '\');'); + + if ($match[3][$r][0] == "g::LoadTranslation") { + $arraySearch = array("'"); + $arrayReplace = array("\\'"); + $strAux = str_replace($arraySearch, $arrayReplace, $strAux); + } + + $__textoEval .= $strAux; + continue; + } + //Non-quoted + if (($match[1][$r][0]=='#')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + //Non-quoted = + if (($match[1][$r][0]=='=')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + } + } + } + $__textoEval.=substr($sqlString,$u); + return $__textoEval; + } + + /** + * microtime_float + * + * @return array_sum(explode(' ',microtime())) + */ + /*public static*/ + public function microtime_float () + { + return array_sum( explode( ' ', microtime() ) ); + } + + /** + * Return the System defined constants and Application variables + * Constants: SYS_* + * Sessions : USER_* , URS_* + */ + public function getSystemConstants($params = null) + { + $t1 = g::microtime_float(); + $sysCon = array(); + + if (defined("SYS_LANG")) { + $sysCon["SYS_LANG"] = SYS_LANG; + } + + if (defined("SYS_SKIN")) { + $sysCon["SYS_SKIN"] = SYS_SKIN; + } + + if (defined("SYS_SYS")) { + $sysCon["SYS_SYS"] = SYS_SYS; + } + + $sysCon["APPLICATION"] = (isset($_SESSION["APPLICATION"]))? $_SESSION["APPLICATION"] : ""; + $sysCon["PROCESS"] = (isset($_SESSION["PROCESS"]))? $_SESSION["PROCESS"] : ""; + $sysCon["TASK"] = (isset($_SESSION["TASK"]))? $_SESSION["TASK"] : ""; + $sysCon["INDEX"] = (isset($_SESSION["INDEX"]))? $_SESSION["INDEX"] : ""; + $sysCon["USER_LOGGED"] = (isset($_SESSION["USER_LOGGED"]))? $_SESSION["USER_LOGGED"] : ""; + $sysCon["USR_USERNAME"] = (isset($_SESSION["USR_USERNAME"]))? $_SESSION["USR_USERNAME"] : ""; + + //############################################################################################### + // Added for compatibility betweek aplication called from web Entry that uses just WS functions + //############################################################################################### + + if ($params != null) { + if (isset($params->option)) { + switch ($params->option) { + case "STORED SESSION": + if (isset($params->SID)) { + g::LoadClass("sessions"); + + $oSessions = new Sessions($params->SID); + $sysCon = array_merge($sysCon, $oSessions->getGlobals()); + } + break; + } + } + + if (isset($params->appData) && is_array($params->appData)) { + $sysCon["APPLICATION"] = $params->appData["APPLICATION"]; + $sysCon["PROCESS"] = $params->appData["PROCESS"]; + $sysCon["TASK"] = $params->appData["TASK"]; + $sysCon["INDEX"] = $params->appData["INDEX"]; + + if (empty($sysCon["USER_LOGGED"])) { + $sysCon["USER_LOGGED"] = $params->appData["USER_LOGGED"]; + $sysCon["USR_USERNAME"] = $params->appData["USR_USERNAME"]; + } + } + } + + return $sysCon; + } + + /** + * Escapes special characters in a string for use in a SQL statement + * @author David Callizaya + * @param string $sqlString The string to be escaped + * @param string $DBEngine Target DBMS + */ + public function sqlEscape ($sqlString, $DBEngine = DB_ADAPTER) + { + $DBEngine = DB_ADAPTER; + switch ($DBEngine) { + case 'mysql': + $con = Propel::getConnection( 'workflow' ); + return mysql_real_escape_string( stripslashes( $sqlString ), $con->getResource() ); + break; + case 'myxml': + $sqlString = str_replace( '"', '""', $sqlString ); + return str_replace( "'", "''", $sqlString ); + break; + default: + return addslashes( stripslashes( $sqlString ) ); + break; + } + } + + /** + * Load a template + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strTemplateName + * @return void + */ + public function LoadTemplate ($strTemplateName) + { + if ($strTemplateName == '') { + return; + } + + $temp = $strTemplateName . ".php"; + $file = g::ExpandPath( 'templates' ) . $temp; + // Check if its a user template + if (file_exists( $file )) { + //require_once( $file ); + include ($file); + } else { + // Try to get the global system template + $file = PATH_TEMPLATE . PATH_SEP . $temp; + //require_once( $file ); + if (file_exists( $file )) { + include ($file); + } + } + } + + /** + * verify path + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath path + * @param boolean $createPath if true this public function will create the path + * @return boolean + */ + public function verifyPath ($strPath, $createPath = false) + { + $folder_path = strstr( $strPath, '.' ) ? dirname( $strPath ) : $strPath; + + if (file_exists( $strPath ) || @is_dir( $strPath )) { + return true; + } else { + if ($createPath) { + //TODO:: Define Environment constants: Devel (0777), Production (0770), ... + G::mk_dir( $strPath, 0777 ); + } else { + return false; + } + } + return false; + } + + /** + * getformatedDate + * + * @param date $date + * @param string $format default value 'yyyy-mm-dd', + * @param string $lang default value '' + * + * @return string $ret + */ + public function getformatedDate ($date, $format = 'yyyy-mm-dd', $lang = '') + { + /** + * ****************************************************************************************************** + * if the year is 2008 and the format is yy then -> 08 + * if the year is 2008 and the format is yyyy then -> 2008 + * + * if the month is 05 and the format is mm then -> 05 + * if the month is 05 and the format is m and the month is less than 10 then -> 5 else digit normal + * if the month is 05 and the format is MM or M then -> May + * + * if the day is 5 and the format is dd then -> 05 + * if the day is 5 and the format is d and the day is less than 10 then -> 5 else digit normal + * if the day is 5 and the format is DD or D then -> five + * ******************************************************************************************************* + */ + + //scape the literal + switch ($lang) { + case 'es': + $format = str_replace( ' de ', '[of]', $format ); + break; + } + + //first we must formatted the string + $format = str_replace( 'yyyy', '{YEAR}', $format ); + $format = str_replace( 'yy', '{year}', $format ); + + $format = str_replace( 'mm', '{YONTH}', $format ); + $format = str_replace( 'm', '{month}', $format ); + $format = str_replace( 'M', '{XONTH}', $format ); + + $format = str_replace( 'dd', '{DAY}', $format ); + $format = str_replace( 'd', '{day}', $format ); + + $format = str_replace( 'h', '{h}', $format ); + $format = str_replace( 'i', '{i}', $format ); + $format = str_replace( 's', '{s}', $format ); + + if ($lang === '') { + $lang = defined( SYS_LANG ) ? SYS_LANG : 'en'; + } + $aux = explode( ' ', $date ); //para dividir la fecha del dia + $date = explode( '-', isset( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. + $time = explode( ':', isset( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. + + + $year = (int) ((isset( $date[0] )) ? $date[0] : '0'); //year + $month = (int) ((isset( $date[1] )) ? $date[1] : '0'); //month + $day = (int) ((isset( $date[2] )) ? $date[2] : '0'); //day + + + $h = isset( $time[0] ) ? $time[0] : '00'; //hour + $i = isset( $time[1] ) ? $time[1] : '00'; //minute + $s = isset( $time[2] ) ? $time[2] : '00'; //second + + + $MONTHS = Array (); + for ($i = 1; $i <= 12; $i ++) { + $MONTHS[$i] = g::LoadTranslation( "ID_MONTH_$i", $lang ); + } + + $d = (int) $day; + $dd = g::complete_field( $day, 2, 1 ); + + //missing D + + + $M = $MONTHS[$month]; + $m = (int) $month; + $mm = g::complete_field( $month, 2, 1 ); + + $yy = substr( $year, strlen( $year ) - 2, 2 ); + $yyyy = $year; + + $names = array ('{day}','{DAY}','{month}','{YONTH}','{XONTH}','{year}','{YEAR}','{h}','{i}','{s}' + ); + $values = array ($d,$dd,$m,$mm,$M,$yy,$yyyy,$h,$i,$s + ); + + $ret = str_replace( $names, $values, $format ); + + //recovering the original literal + switch ($lang) { + case 'es': + $ret = str_replace( '[of]', ' de ', $ret ); + break; + } + + return $ret; + } + + /** + * + * @author Erik Amaru Ortiz + * @name complete_field($string, $lenght, $type={1:number/2:string/3:float}) + */ + public function complete_field ($campo, $long, $tipo) + { + $campo = trim( $campo ); + switch ($tipo) { + case 1: //number + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = "0" . $campo; + } + break; + case 2: //string + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = " " . $campo; + } + break; + case 3: //float + if ($campo != "0") { + $vals = explode( ".", $long ); + $ints = $vals[0]; + + $decs = $vals[1]; + + $valscampo = explode( ".", $campo ); + + $intscampo = $valscampo[0]; + $decscampo = $valscampo[1]; + + $ints = $ints - strlen( $intscampo ); + + for ($i = 1; $i <= $ints; $i ++) { + $intscampo = "0" . $intscampo; + } + + //los decimales pueden ser 0 uno o dos + $decs = $decs - strlen( $decscampo ); + for ($i = 1; $i <= $decs; $i ++) { + $decscampo = $decscampo . "0"; + } + + $campo = $intscampo . "." . $decscampo; + } else { + $vals = explode( ".", $long ); + $ints = $vals[0]; + $decs = $vals[1]; + + $campo = ""; + for ($i = 1; $i <= $ints; $i ++) { + $campo = "0" . $campo; + } + $campod = ""; + for ($i = 1; $i <= $decs; $i ++) { + $campod = "0" . $campod; + } + + $campo = $campo . "." . $campod; + } + break; + } + return $campo; + } + + + /** + * evalJScript + * + * @param string $c + * + * @return void + */ + public function evalJScript ($c) + { + print ("") ; + } + + +} diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index fcdcb77cf..05b4510f2 100755 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -12,15 +12,14 @@ * * 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 + * 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 . + * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * */ /** @@ -28,780 +27,761 @@ * this file is used initialize main variables, redirect and dispatch all requests */ - // Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/' - define('PATH_SEP', '/'); +// 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); +// 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; +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 ; +// 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 ; +array_pop( $docuroot ); +$pathOutTrunk = implode( PATH_SEP, $docuroot ) . PATH_SEP; - define('PATH_HOME', $pathhome); - define('PATH_TRUNK', $pathTrunk); - define('PATH_OUTTRUNK', $pathOutTrunk); - - - // 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 ); - define( 'PATH_THIRDPARTY', PATH_GULLIVER_HOME . 'thirdparty' . PATH_SEP ); - define( 'PATH_RBAC', PATH_RBAC_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP ); //to enable rbac version 2 - define( 'PATH_RBAC_CORE', PATH_RBAC_HOME . 'engine' . PATH_SEP ); - define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP ); - - // Defining PMCore Path constants - define( 'PATH_CORE', PATH_HOME . 'engine' . PATH_SEP ); - define( 'PATH_SKINS', PATH_CORE . 'skins' . PATH_SEP ); - define( 'PATH_SKIN_ENGINE', PATH_CORE . 'skinEngine' . PATH_SEP ); - 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 ); - define( 'PATH_SERVICES_REST', PATH_CORE . 'services' . PATH_SEP . 'rest' . PATH_SEP); - - // include Gulliver Class - require_once( PATH_GULLIVER . PATH_SEP . 'class.g.php'); - - if(file_exists(FILE_PATHS_INSTALLED)) { - // backward compatibility; parsing old definitions in the compiled path constant - $tmp = file_get_contents(FILE_PATHS_INSTALLED); - - if (strpos($tmp, 'PATH_OUTTRUNK') !== false) { - @file_put_contents(FILE_PATHS_INSTALLED, str_replace('PATH_OUTTRUNK', 'PATH_DATA', $tmp)); - } - // end backward compatibility - - // include the workspace installed configuration - require_once FILE_PATHS_INSTALLED; - - // defining system constant when a valid workspace environment exists - define('PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP); - define('PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP); - define('PATH_TEMPORAL', PATH_C . 'dynEditor/'); - define('PATH_DB', PATH_DATA . 'sites' . PATH_SEP); - // smarty constants - define('PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c'); - define('PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache'); - - if (!is_dir(PATH_SMARTY_C)) { - G::mk_dir(PATH_SMARTY_C); - } - - if (!is_dir(PATH_SMARTY_CACHE)) { - G::mk_dir(PATH_SMARTY_CACHE); - } - } - - // 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'); - - // Including these files we get the PM paths and definitions (that should be just one file. - require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php'; +define( 'PATH_HOME', $pathhome ); +define( 'PATH_TRUNK', $pathTrunk ); +define( 'PATH_OUTTRUNK', $pathOutTrunk ); - // starting session - session_start(); +// Defining RBAC Paths constants +define( 'PATH_RBAC_HOME', PATH_TRUNK . 'rbac' . PATH_SEP ); - $config = System::getSystemConfiguration(); +// Defining Gulliver framework paths constants +define( 'PATH_GULLIVER_HOME', PATH_TRUNK . 'gulliver' . PATH_SEP ); +define( 'PATH_GULLIVER', PATH_GULLIVER_HOME . 'system' . PATH_SEP ); //gulliver system classes +define( 'PATH_GULLIVER_BIN', PATH_GULLIVER_HOME . 'bin' . PATH_SEP ); //gulliver bin classes +define( 'PATH_TEMPLATE', PATH_GULLIVER_HOME . 'templates' . PATH_SEP ); +define( 'PATH_THIRDPARTY', PATH_GULLIVER_HOME . 'thirdparty' . PATH_SEP ); +define( 'PATH_RBAC', PATH_RBAC_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP ); //to enable rbac version 2 +define( 'PATH_RBAC_CORE', PATH_RBAC_HOME . 'engine' . PATH_SEP ); +define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP ); - $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; +// Defining PMCore Path constants +define( 'PATH_CORE', PATH_HOME . 'engine' . PATH_SEP ); +define( 'PATH_SKINS', PATH_CORE . 'skins' . PATH_SEP ); +define( 'PATH_SKIN_ENGINE', PATH_CORE . 'skinEngine' . PATH_SEP ); +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 ); - // Do not change any of these settings directly, use env.ini instead - ini_set('display_errors', $config['debug']); - ini_set('error_reporting', $e_all); - 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']); +define( 'PATH_WORKFLOW_MYSQL_DATA', PATH_CORE . 'data' . PATH_SEP . 'mysql' . PATH_SEP ); +define( 'PATH_RBAC_MYSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP . 'mysql' . PATH_SEP ); +define( 'FILE_PATHS_INSTALLED', PATH_CORE . 'config' . PATH_SEP . 'paths_installed.php' ); +define( 'PATH_WORKFLOW_MSSQL_DATA', PATH_CORE . 'data' . PATH_SEP . 'mssql' . PATH_SEP ); +define( 'PATH_RBAC_MSSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP . 'mssql' . PATH_SEP ); +define( 'PATH_CONTROLLERS', PATH_CORE . 'controllers' . PATH_SEP ); +define( 'PATH_SERVICES_REST', PATH_CORE . 'services' . PATH_SEP . 'rest' . PATH_SEP ); - define ('DEBUG_SQL_LOG', $config['debug_sql']); - 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']); - define ('TIME_ZONE', $config['time_zone']); +// include Gulliver Class +require_once (PATH_GULLIVER . PATH_SEP . 'class.bootstrap.php'); - // 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 - - 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 - - //check if it is a installation instance - if(!defined('PATH_C')) { - // is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily - define('PATH_C', (rtrim(G::sys_get_temp_dir(), PATH_SEP) . PATH_SEP)); - define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' ); - } - - // defining Virtual URLs - $virtualURITable = array(); - $virtualURITable['/plugin/(*)'] = 'plugin'; - $virtualURITable['/(sys*)/(*.js)'] = 'jsMethod'; - $virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/'; - $virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/'; - - if ( defined('PATH_C') ) { - $virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/'; - $virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/'; - } - - $virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/'; - $virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed'; - $virtualURITable['/(sys*)'] = FALSE; - $virtualURITable['/errors/(*)'] = PATH_GULLIVER_HOME . 'methods/errors/'; - $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['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed'; - $virtualURITable['/rest/(*)'] = 'rest-service'; - $virtualURITable['/update/(*)'] = PATH_GULLIVER_HOME . 'methods/update/'; - $virtualURITable['/(*)'] = PATH_HTML; - - $isRestRequest = false; - - // 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 )) - { - // 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]; - } - - //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 ) ) { - G::streamFile ( $pluginFilename ); - } - die; +if (file_exists( FILE_PATHS_INSTALLED )) { + // backward compatibility; parsing old definitions in the compiled path constant + $tmp = file_get_contents( FILE_PATHS_INSTALLED ); + + if (strpos( $tmp, 'PATH_OUTTRUNK' ) !== false) { + @file_put_contents( FILE_PATHS_INSTALLED, str_replace( 'PATH_OUTTRUNK', 'PATH_DATA', $tmp ) ); } + // end backward compatibility + - $requestUriArray = explode("/",$_SERVER['REQUEST_URI']); + // include the workspace installed configuration + require_once FILE_PATHS_INSTALLED; + + // defining system constant when a valid workspace environment exists + define( 'PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP ); + define( 'PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP ); + define( 'PATH_TEMPORAL', PATH_C . 'dynEditor/' ); + define( 'PATH_DB', PATH_DATA . 'sites' . PATH_SEP ); + // smarty constants + define( 'PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c' ); + define( 'PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache' ); + + if (! is_dir( PATH_SMARTY_C )) { + G::mk_dir( PATH_SMARTY_C ); + } + + if (! is_dir( PATH_SMARTY_CACHE )) { + G::mk_dir( PATH_SMARTY_CACHE ); + } +} - if((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]; - } +// 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() ); - //Get that path in array - $paths = explode ( PATH_SEP, $forQuery[0] ); - $fileToBeStreamed=str_replace("/skin/",PATH_CUSTOM_SKINS,$_SERVER['REQUEST_URI']); +/** + * Global definitions, before it was the defines.php file + */ - if ( file_exists ( $fileToBeStreamed ) ) { - G::streamFile ( $fileToBeStreamed ); - } - die; +// 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' ); + +// Including these files we get the PM paths and definitions (that should be just one file. +require_once PATH_CORE . 'classes' . PATH_SEP . 'class.system.php'; + +// starting session +session_start(); + +$config = System::getSystemConfiguration(); + +$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; + +// Do not change any of these settings directly, use env.ini instead +ini_set( 'display_errors', $config['debug'] ); +ini_set( 'error_reporting', $e_all ); +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'] ); + +define( 'DEBUG_SQL_LOG', $config['debug_sql'] ); +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'] ); +define( 'TIME_ZONE', $config['time_zone'] ); + +// 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 + + +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 + + +//check if it is a installation instance +if (! defined( 'PATH_C' )) { + // is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily + define( 'PATH_C', (rtrim( G::sys_get_temp_dir(), PATH_SEP ) . PATH_SEP) ); + define( 'PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/' ); +} + +// defining Virtual URLs +$virtualURITable = array (); +$virtualURITable['/plugin/(*)'] = 'plugin'; +$virtualURITable['/(sys*)/(*.js)'] = 'jsMethod'; +$virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/'; +$virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/'; + +if (defined( 'PATH_C' )) { + $virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/'; + $virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/'; +} + +$virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/'; +$virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed'; +$virtualURITable['/(sys*)'] = FALSE; +$virtualURITable['/errors/(*)'] = PATH_GULLIVER_HOME . 'methods/errors/'; +$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['/[a-zA-Z][a-zA-Z0-9]{0,}()'] = 'sysUnnamed'; +$virtualURITable['/rest/(*)'] = 'rest-service'; +$virtualURITable['/update/(*)'] = PATH_GULLIVER_HOME . 'methods/update/'; +$virtualURITable['/(*)'] = PATH_HTML; + +$isRestRequest = false; + +// 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 )) { + // 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]; + } + + //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 )) { + G::streamFile( $pluginFilename ); + } + die(); + } + + $requestUriArray = explode( "/", $_SERVER['REQUEST_URI'] ); + + 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]; + } + + //Get that path in array + $paths = explode( PATH_SEP, $forQuery[0] ); + $fileToBeStreamed = str_replace( "/skin/", PATH_CUSTOM_SKINS, $_SERVER['REQUEST_URI'] ); + + if (file_exists( $fileToBeStreamed )) { + G::streamFile( $fileToBeStreamed ); + } + die(); } switch ($realPath) { - case 'sysUnnamed' : - require_once('sysUnnamed.php'); - die; - break; - case 'sysNamed' : - header('location : ' . $_SERVER['REQUEST_URI'] . '/' .SYS_LANG. '/classic/login/login' ); - die; - break; - case 'jsMethod' : - G::parseURI ( getenv( "REQUEST_URI" ) ); - $filename = PATH_METHODS . SYS_COLLECTION . '/' . SYS_TARGET . '.js'; - G::streamFile ( $filename ); - die; - break; - case 'errorFile': - header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); - if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page - die; - break; - default : - if (substr($realPath, 0, 12) == 'rest-service') { - $isRestRequest = true; - } else { - $realPath = explode('?', $realPath); - $realPath[0] .= strpos(basename($realPath[0]), '.') === false ? '.php' : ''; - G::streamFile ( $realPath[0] ); - die; - } + case 'sysUnnamed': + require_once ('sysUnnamed.php'); + die(); + break; + case 'sysNamed': + header( 'location : ' . $_SERVER['REQUEST_URI'] . '/' . SYS_LANG . '/classic/login/login' ); + die(); + break; + case 'jsMethod': + G::parseURI( getenv( "REQUEST_URI" ) ); + $filename = PATH_METHODS . SYS_COLLECTION . '/' . SYS_TARGET . '.js'; + G::streamFile( $filename ); + die(); + break; + case 'errorFile': + header( "location: /errors/error404.php?url=" . urlencode( $_SERVER['REQUEST_URI'] ) ); + if (DEBUG_TIME_LOG) + G::logTimeByPage(); //log this page + die(); + break; + default: + if (substr( $realPath, 0, 12 ) == 'rest-service') { + $isRestRequest = true; + } else { + $realPath = explode( '?', $realPath ); + $realPath[0] .= strpos( basename( $realPath[0] ), '.' ) === false ? '.php' : ''; + G::streamFile( $realPath[0] ); + die(); + } } - }//virtual URI parser +} //virtual URI parser - // the request correspond to valid php page, now parse the URI - G::parseURI(getenv("REQUEST_URI"), $isRestRequest); - if(G::isPMUnderUpdating()) - { - header("location: /update/updating.php"); - if ( DEBUG_TIME_LOG ) G::logTimeByPage(); - die; - } +// the request correspond to valid php page, now parse the URI +G::parseURI( getenv( "REQUEST_URI" ), $isRestRequest ); - // 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)) - ); - } +if (G::isPMUnderUpdating()) { + header( "location: /update/updating.php" ); + if (DEBUG_TIME_LOG) + G::logTimeByPage(); + die(); +} - define('SYS_URI' , '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/'); +// 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 + ) ) ); +} - // defining the serverConf singleton - if (defined('PATH_DATA') && file_exists(PATH_DATA)) { +define( 'SYS_URI', '/sys' . SYS_TEMP . '/' . SYS_LANG . '/' . SYS_SKIN . '/' ); + +// defining the serverConf singleton +if (defined( 'PATH_DATA' ) && file_exists( PATH_DATA )) { //Instance Server Configuration Singleton - G::LoadClass('serverConfiguration'); - $oServerConf =& serverConf::getSingleton(); - } + G::LoadClass( 'serverConfiguration' ); + $oServerConf = & serverConf::getSingleton(); +} - // Call Gulliver Classes - G::LoadThirdParty('pear/json','class.json'); - G::LoadThirdParty('smarty/libs','Smarty.class'); - G::LoadSystem('error'); - G::LoadSystem('dbconnection'); - G::LoadSystem('dbsession'); - G::LoadSystem('dbrecordset'); - G::LoadSystem('dbtable'); - G::LoadSystem('rbac' ); - G::LoadSystem('publisher'); - G::LoadSystem('templatePower'); - G::LoadSystem('xmlDocument'); - G::LoadSystem('xmlform'); - G::LoadSystem('xmlformExtension'); - G::LoadSystem('form'); - G::LoadSystem('menu'); - G::LoadSystem("xmlMenu"); - G::LoadSystem('dvEditor'); - G::LoadSystem('controller'); - G::LoadSystem('httpProxyController'); - G::LoadSystem('pmException'); +// Call Gulliver Classes +G::LoadThirdParty( 'pear/json', 'class.json' ); +G::LoadThirdParty( 'smarty/libs', 'Smarty.class' ); +G::LoadSystem( 'error' ); +G::LoadSystem( 'dbconnection' ); +G::LoadSystem( 'dbsession' ); +G::LoadSystem( 'dbrecordset' ); +G::LoadSystem( 'dbtable' ); +G::LoadSystem( 'rbac' ); +G::LoadSystem( 'publisher' ); +G::LoadSystem( 'templatePower' ); +G::LoadSystem( 'xmlDocument' ); +G::LoadSystem( 'xmlform' ); +G::LoadSystem( 'xmlformExtension' ); +G::LoadSystem( 'form' ); +G::LoadSystem( 'menu' ); +G::LoadSystem( "xmlMenu" ); +G::LoadSystem( 'dvEditor' ); +G::LoadSystem( 'controller' ); +G::LoadSystem( 'httpProxyController' ); +G::LoadSystem( 'pmException' ); - // Create headPublisher singleton - G::LoadSystem('headPublisher'); - $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)) { +// Create headPublisher singleton +G::LoadSystem( 'headPublisher' ); +$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); - require_once ( PATH_CONTROLLERS . 'installer.php' ); + define( 'PATH_DATA', PATH_C ); + require_once (PATH_CONTROLLERS . 'installer.php'); $controller = 'Installer'; - + // if the method name is empty set default to index method - if (strpos(SYS_TARGET, '/') !== false) { - list($controller, $controllerAction) = explode('/', SYS_TARGET); + if (strpos( SYS_TARGET, '/' ) !== false) { + list ($controller, $controllerAction) = explode( '/', SYS_TARGET ); + } else { + $controllerAction = SYS_TARGET; } - else { - $controllerAction = SYS_TARGET; - } - - $controllerAction = ($controllerAction != '' && $controllerAction != 'login')? $controllerAction: 'index'; - + + $controllerAction = ($controllerAction != '' && $controllerAction != 'login') ? $controllerAction : 'index'; + // create the installer controller and call its method - if( is_callable(Array('Installer', $controllerAction)) ) { - $installer = new $controller(); - $installer->setHttpRequestData($_REQUEST); - $installer->call($controllerAction); + if (is_callable( Array ('Installer',$controllerAction + ) )) { + $installer = new $controller(); + $installer->setHttpRequestData( $_REQUEST ); + $installer->call( $controllerAction ); + } else { + $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; + header( "location: /errors/error404.php?url=" . urlencode( $_SERVER['REQUEST_URI'] ) ); } - else { - $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; - header ("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); - } - die; - } + die(); +} - // Load Language Translation - G::LoadTranslationObject(defined('SYS_LANG')?SYS_LANG:"en"); +// Load Language Translation +G::LoadTranslationObject( defined( 'SYS_LANG' ) ? SYS_LANG : "en" ); - // look for a disabled workspace - if($oServerConf->isWSDisabled(SYS_TEMP)){ - $aMessage['MESSAGE'] = G::LoadTranslation('ID_DISB_WORKSPACE'); - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); +// look for a disabled workspace +if ($oServerConf->isWSDisabled( SYS_TEMP )) { + $aMessage['MESSAGE'] = G::LoadTranslation( 'ID_DISB_WORKSPACE' ); + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage ); G::RenderPage( 'publish' ); - die; - } + die(); +} - // 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 != '') { +// 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 - if ( file_exists( PATH_DB . SYS_TEMP . '/db.php' ) ) { - require_once( PATH_DB . SYS_TEMP . '/db.php' ); - define ( 'SYS_SYS' , SYS_TEMP ); - - // defining constant for workspace shared directory - define ( 'PATH_WORKSPACE' , PATH_DB . SYS_SYS . PATH_SEP ); - // including workspace shared classes -> particularlly for pmTables - set_include_path(get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE); + if (file_exists( PATH_DB . SYS_TEMP . '/db.php' )) { + require_once (PATH_DB . SYS_TEMP . '/db.php'); + define( 'SYS_SYS', SYS_TEMP ); + + // defining constant for workspace shared directory + define( 'PATH_WORKSPACE', PATH_DB . SYS_SYS . PATH_SEP ); + // including workspace shared classes -> particularlly for pmTables + set_include_path( get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE ); + } else { + G::SendTemporalMessage( 'ID_NOT_WORKSPACE', "error" ); + G::header( 'location: /sys/' . SYS_LANG . '/' . SYS_SKIN . '/main/sysLogin?errno=2' ); + die(); } - else { - G::SendTemporalMessage ('ID_NOT_WORKSPACE', "error"); - G::header('location: /sys/' . SYS_LANG . '/' . SYS_SKIN . '/main/sysLogin?errno=2'); - die; - } - } - else { //when we are in global pages, outside any valid workspace - if (SYS_TARGET==='newSite') { - $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . "/" . SYS_TARGET.'.php'; - require_once($phpFile); - die(); - } - else { - if(SYS_TARGET=="dbInfo"){ //Show dbInfo when no SYS_SYS - require_once( PATH_METHODS . "login/dbInfo.php" ); - } - else{ - - if (substr(SYS_SKIN, 0, 2) === 'ux' && SYS_TARGET != 'sysLoginVerify') { // new ux sysLogin - extjs based form - require_once PATH_CONTROLLERS . 'main.php'; - $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); - } +} else { //when we are in global pages, outside any valid workspace + if (SYS_TARGET === 'newSite') { + $phpFile = G::ExpandPath( 'methods' ) . SYS_COLLECTION . "/" . SYS_TARGET . '.php'; + require_once ($phpFile); + die(); + } else { + if (SYS_TARGET == "dbInfo") { //Show dbInfo when no SYS_SYS + require_once (PATH_METHODS . "login/dbInfo.php"); + } else { + + if (substr( SYS_SKIN, 0, 2 ) === 'ux' && SYS_TARGET != 'sysLoginVerify') { // new ux sysLogin - extjs based form + require_once PATH_CONTROLLERS . 'main.php'; + $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 ); + } + } else { // classic sysLogin interface + require_once (PATH_METHODS . "login/sysLogin.php"); + die(); + } } - else { // classic sysLogin interface - require_once( PATH_METHODS . "login/sysLogin.php" ) ; - die(); - } - } - if ( DEBUG_TIME_LOG ) G::logTimeByPage(); //log this page - die(); + if (DEBUG_TIME_LOG) + G::logTimeByPage(); //log this page + die(); } - } +} - // PM Paths DATA - define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/'); - 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']); +// PM Paths DATA +define( 'PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/' ); +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 - G::LoadClass ( 'memcached' ); - $memcache = & PMmemcached::getSingleton(SYS_SYS); +// create memcached singleton +G::LoadClass( 'memcached' ); +$memcache = & PMmemcached::getSingleton( SYS_SYS ); - // verify configuration for rest service - if ($isRestRequest) { - // disable until confirm that rest is enabled & configured on rest-config.ini file - $isRestRequest = false; - $confFile = ''; - $restApiClassPath = ''; +// verify configuration for rest service +if ($isRestRequest) { + // disable until confirm that rest is enabled & configured on rest-config.ini file + $isRestRequest = false; + $confFile = ''; + $restApiClassPath = ''; + + // try load and getting rest configuration + if (file_exists( PATH_DATA_SITE . 'rest-config.ini' )) { + $confFile = PATH_DATA_SITE . 'rest-config.ini'; + $restApiClassPath = PATH_DATA_SITE; + } elseif (file_exists( PATH_CONFIG . 'rest-config.ini' )) { + $confFile = PATH_CONFIG . 'rest-config.ini'; + } + if (! empty( $confFile ) && $restConfig = @parse_ini_file( $confFile, true )) { + if (array_key_exists( 'enable_service', $restConfig )) { + if ($restConfig['enable_service'] == 'true' || $restConfig['enable_service'] == '1') { + $isRestRequest = true; // rest service enabled + } + } + } +} - // try load and getting rest configuration - if (file_exists(PATH_DATA_SITE . 'rest-config.ini')) { - $confFile = PATH_DATA_SITE . 'rest-config.ini'; - $restApiClassPath = PATH_DATA_SITE; - } elseif (file_exists(PATH_CONFIG . 'rest-config.ini')) { - $confFile = PATH_CONFIG . 'rest-config.ini'; - } - if (! empty($confFile) && $restConfig = @parse_ini_file($confFile, true)) { - if (array_key_exists('enable_service', $restConfig)) { - if ($restConfig['enable_service'] == 'true' || $restConfig['enable_service'] == '1') { - $isRestRequest = true; // rest service enabled - } - } - } - } +// load Plugins base class +G::LoadClass( 'plugin' ); - // load Plugins base class - G::LoadClass('plugin'); +//here we are loading all plugins registered +//the singleton has a list of enabled plugins +$sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; +$oPluginRegistry = & PMPluginRegistry::getSingleton(); - //here we are loading all plugins registered - //the singleton has a list of enabled plugins - $sSerializedFile = PATH_DATA_SITE . 'plugin.singleton'; - $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 +require_once ("propel/Propel.php"); +require_once ("creole/Creole.php"); - // setup propel definitions and logging - require_once ( "propel/Propel.php" ); - require_once ( "creole/Creole.php" ); - - if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) { - define('PM_PID', mt_rand(1,999999)); +if (defined( 'DEBUG_SQL_LOG' ) && DEBUG_SQL_LOG) { + define( 'PM_PID', mt_rand( 1, 999999 ) ); require_once 'Log.php'; - + // register debug connection decorator driver - Creole::registerDriver('*', 'creole.contrib.DebugConnection'); - + Creole::registerDriver( '*', 'creole.contrib.DebugConnection' ); + // initialize Propel with converted config file Propel::init( PATH_CORE . "config/databases.php" ); - + // unified log file for all databases $logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log'; - $logger = Log::singleton('file', $logFile, 'wf ' . SYS_SYS, null, PEAR_LOG_INFO); - Propel::setLogger($logger); + $logger = Log::singleton( 'file', $logFile, 'wf ' . SYS_SYS, null, PEAR_LOG_INFO ); + Propel::setLogger( $logger ); // log file for workflow database - $con = Propel::getConnection('workflow'); + $con = Propel::getConnection( 'workflow' ); if ($con instanceof DebugConnection) { - $con->setLogger($logger); + $con->setLogger( $logger ); } // log file for rbac database - $con = Propel::getConnection('rbac'); - + $con = Propel::getConnection( 'rbac' ); + if ($con instanceof DebugConnection) { - $con->setLogger($logger); + $con->setLogger( $logger ); } - + // log file for report database - $con = Propel::getConnection('rp'); + $con = Propel::getConnection( 'rp' ); if ($con instanceof DebugConnection) { - $con->setLogger($logger); + $con->setLogger( $logger ); } - } - else { +} else { Propel::init( PATH_CORE . "config/databases.php" ); - } +} - Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); +Creole::registerDriver( 'dbarray', 'creole.contrib.DBArrayConnection' ); - // Session Initializations - ini_set('session.auto_start', '1'); +// Session Initializations +ini_set( 'session.auto_start', '1' ); - // 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(); +// 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(); - // Rebuild the base Workflow translations if not exists - if( ! is_file(PATH_LANGUAGECONT . 'translation.en') ){ - require_once ( "classes/model/Translation.php" ); - $fields = Translation::generateFileTranslation('en'); - } +// Rebuild the base Workflow translations if not exists +if (! is_file( PATH_LANGUAGECONT . 'translation.en' )) { + require_once ("classes/model/Translation.php"); + $fields = Translation::generateFileTranslation( 'en' ); +} - // TODO: Verify if the language set into url is defined in translations env. - if( SYS_LANG != 'en' && ! is_file(PATH_LANGUAGECONT . 'translation.' . SYS_LANG) ){ - require_once ( "classes/model/Translation.php" ); - $fields = Translation::generateFileTranslation(SYS_LANG); - } +// TODO: Verify if the language set into url is defined in translations env. +if (SYS_LANG != 'en' && ! is_file( PATH_LANGUAGECONT . 'translation.' . SYS_LANG )) { + require_once ("classes/model/Translation.php"); + $fields = Translation::generateFileTranslation( SYS_LANG ); +} - // Setup plugins - $oPluginRegistry->setupPlugins(); //get and setup enabled plugins - $avoidChangedWorkspaceValidation = false; +// Setup plugins +$oPluginRegistry->setupPlugins(); //get and setup enabled plugins +$avoidChangedWorkspaceValidation = false; - // Load custom Classes and Model from Plugins. - G::LoadAllPluginModelClasses(); +// Load custom Classes and Model from Plugins. +G::LoadAllPluginModelClasses(); - // jump to php file in methods directory - $collectionPlugin = ''; - if ($oPluginRegistry->isRegisteredFolder(SYS_COLLECTION)) { - $phpFile = PATH_PLUGINS . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php'; +// 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 = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . SYS_TARGET.'.php'; - } +} else { + $phpFile = G::ExpandPath( 'methods' ) . SYS_COLLECTION . PATH_SEP . SYS_TARGET . '.php'; +} - // services is a special folder, - if ( SYS_COLLECTION == 'services' ) { +// services is a special folder, +if (SYS_COLLECTION == 'services') { $avoidChangedWorkspaceValidation = true; $targetPlugin = explode( '/', SYS_TARGET ); - - if ( $targetPlugin[0] == 'webdav' ) { - $phpFile = G::ExpandPath('methods') . SYS_COLLECTION . PATH_SEP . 'webdav.php'; + + if ($targetPlugin[0] == 'webdav') { + $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; - } +} - //the index.php file, this new feature will allow automatically redirects to valid php file inside any methods folder - /* DEPRECATED +//the index.php file, this new feature will allow automatically redirects to valid php file inside any methods folder +/* DEPRECATED if ( SYS_TARGET == '' ) { $phpFile = str_replace ( '.php', 'index.php', $phpFile ); $phpFile = include ( $phpFile ); }*/ - $bWE = false; - $isControllerCall = false; - if ( substr(SYS_COLLECTION , 0,8) === 'gulliver' ) { - $phpFile = PATH_GULLIVER_HOME . 'methods/' . substr( SYS_COLLECTION , 8) . SYS_TARGET.'.php'; - } - else { +$bWE = false; +$isControllerCall = 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') { - G::streamFile($phpFile); - die; - } - - $avoidChangedWorkspaceValidation=true; - $bWE = true; - //$phpFile = PATH_DATA_SITE . 'public' . PATH_SEP . SYS_COLLECTION . PATH_SEP . $auxPart[ count($auxPart)-1]; + 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') { + G::streamFile( $phpFile ); + die(); + } + + $avoidChangedWorkspaceValidation = true; + $bWE = true; + //$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 - if (is_file(PATH_CONTROLLERS . SYS_COLLECTION . '.php')) { - require_once PATH_CONTROLLERS . SYS_COLLECTION . '.php'; - $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; - } + if (is_file( PATH_CONTROLLERS . SYS_COLLECTION . '.php' )) { + require_once PATH_CONTROLLERS . SYS_COLLECTION . '.php'; + $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; + } } - - if (!$isControllerCall && ! file_exists($phpFile) && ! $isRestRequest) { - $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; - header("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI'])); - die; + + if (! $isControllerCall && ! file_exists( $phpFile ) && ! $isRestRequest) { + $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI']; + header( "location: /errors/error404.php?url=" . urlencode( $_SERVER['REQUEST_URI'] ) ); + die(); } - } +} - //redirect to login, if user changed the workspace in the URL - if (! $avoidChangedWorkspaceValidation && isset($_SESSION['WORKSPACE']) && $_SESSION['WORKSPACE'] != SYS_SYS) { +//redirect to login, if user changed the workspace in the URL +if (! $avoidChangedWorkspaceValidation && isset( $_SESSION['WORKSPACE'] ) && $_SESSION['WORKSPACE'] != SYS_SYS) { $_SESSION['WORKSPACE'] = SYS_SYS; - G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', "error"); + G::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'; + $urlPart = substr( SYS_SKIN, 0, 2 ) == 'ux' && SYS_SKIN != 'uxs' ? '/main/login' : '/login/login'; + + header( 'Location: /sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . $urlPart ); + die(); +} - header('Location: /sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . $urlPart); - die; - } - - // enable rbac - $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"); +// enable rbac +$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'])))) { - $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'; - $noLoginFiles[] = 'login_Ajax'; - $noLoginFiles[] = 'dbInfo'; - $noLoginFiles[] = 'sysLoginVerify'; - $noLoginFiles[] = 'processes_Ajax'; - $noLoginFiles[] = 'updateTranslation'; - $noLoginFiles[] = 'autoinstallProcesses'; - $noLoginFiles[] = 'autoinstallPlugins'; - $noLoginFiles[] = 'heartbeatStatus'; - $noLoginFiles[] = 'showLogoFile'; - $noLoginFiles[] = 'forgotPassword'; - $noLoginFiles[] = 'retrivePassword'; - $noLoginFiles[] = 'defaultAjaxDynaform'; - $noLoginFiles[] = 'dynaforms_checkDependentFields'; - - $noLoginFolders[] = 'services'; - $noLoginFolders[] = 'tracker'; - $noLoginFolders[] = 'installer'; - - // This sentence is used when you lost the Session - if (! in_array(SYS_TARGET, $noLoginFiles) - && ! in_array(SYS_COLLECTION, $noLoginFolders) - && $bWE != true && $collectionPlugin != 'services' - && ! $isRestRequest - ) { - $bRedirect = true; - - if (isset($_GET['sid'])) { - G::LoadClass('sessions'); - $oSessions = new Sessions(); - if ($aSession = $oSessions->verifySession($_GET['sid'])) { - require_once 'classes/model/Users.php'; - $oUser = new Users(); - $aUser = $oUser->load($aSession['USR_UID']); - $_SESSION['USER_LOGGED'] = $aUser['USR_UID']; - $_SESSION['USR_USERNAME'] = $aUser['USR_USERNAME']; - $bRedirect = false; - $RBAC->initRBAC(); + define( 'SYS_LANG_DIRECTION', $oServerConf->getLanDirection() ); + + if ((isset( $_SESSION['USER_LOGGED'] )) && (! (isset( $_GET['sid'] )))) { + $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'] ); - $memKey = 'rbacSession' . session_id(); - $memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS ); - } + $memcache->set( $memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS ); } - - if ($bRedirect) { - if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') { // verify if the current skin is a 'ux' variant - $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'; - } - else { - $loginUrl = 'login/login'; // just set up the classic login - } - - if (empty($_POST)) { - header('location: ' . SYS_URI . $loginUrl . '?u=' . urlencode($_SERVER['REQUEST_URI'])); - - } - else { - if ($isControllerCall) { - header("HTTP/1.0 302 session lost in controller"); + } else { + // this is the blank list to allow execute scripts with no login (without session started) + $noLoginFiles = $noLoginFolders = array (); + $noLoginFiles[] = 'login'; + $noLoginFiles[] = 'authentication'; + $noLoginFiles[] = 'login_Ajax'; + $noLoginFiles[] = 'dbInfo'; + $noLoginFiles[] = 'sysLoginVerify'; + $noLoginFiles[] = 'processes_Ajax'; + $noLoginFiles[] = 'updateTranslation'; + $noLoginFiles[] = 'autoinstallProcesses'; + $noLoginFiles[] = 'autoinstallPlugins'; + $noLoginFiles[] = 'heartbeatStatus'; + $noLoginFiles[] = 'showLogoFile'; + $noLoginFiles[] = 'forgotPassword'; + $noLoginFiles[] = 'retrivePassword'; + $noLoginFiles[] = 'defaultAjaxDynaform'; + $noLoginFiles[] = 'dynaforms_checkDependentFields'; + + $noLoginFolders[] = 'services'; + $noLoginFolders[] = 'tracker'; + $noLoginFolders[] = 'installer'; + + // This sentence is used when you lost the Session + if (! in_array( SYS_TARGET, $noLoginFiles ) && ! in_array( SYS_COLLECTION, $noLoginFolders ) && $bWE != true && $collectionPlugin != 'services' && ! $isRestRequest) { + $bRedirect = true; + + if (isset( $_GET['sid'] )) { + G::LoadClass( 'sessions' ); + $oSessions = new Sessions(); + if ($aSession = $oSessions->verifySession( $_GET['sid'] )) { + require_once 'classes/model/Users.php'; + $oUser = new Users(); + $aUser = $oUser->load( $aSession['USR_UID'] ); + $_SESSION['USER_LOGGED'] = $aUser['USR_UID']; + $_SESSION['USR_USERNAME'] = $aUser['USR_USERNAME']; + $bRedirect = false; + $RBAC->initRBAC(); + $RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] ); + $memKey = 'rbacSession' . session_id(); + $memcache->set( $memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS ); + } } - else { - header('location: ' . SYS_URI . $loginUrl); + + if ($bRedirect) { + if (substr( SYS_SKIN, 0, 2 ) == 'ux' && SYS_SKIN != 'uxs') { // verify if the current skin is a 'ux' variant + $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'; + } else { + $loginUrl = 'login/login'; // just set up the classic login + } + + if (empty( $_POST )) { + header( 'location: ' . SYS_URI . $loginUrl . '?u=' . urlencode( $_SERVER['REQUEST_URI'] ) ); + + } else { + if ($isControllerCall) { + header( "HTTP/1.0 302 session lost in controller" ); + } else { + header( 'location: ' . SYS_URI . $loginUrl ); + } + } + die(); } - } - die(); } - } } $_SESSION['phpLastFileFound'] = $_SERVER['REQUEST_URI']; - + /** * New feature for Gulliver framework to support Controllers & HttpProxyController classes handling + * * @author Erik Amaru Ortiz */ if ($isControllerCall) { //Instance the Controller object and call the request method - $controller = new $controllerClass(); - $controller->setHttpRequestData($_REQUEST); - $controller->call($controllerAction); + $controller = new $controllerClass(); + $controller->setHttpRequestData( $_REQUEST ); + $controller->call( $controllerAction ); } elseif ($isRestRequest) { - G::dispatchRestService(SYS_TARGET, $restConfig, $restApiClassPath); + G::dispatchRestService( SYS_TARGET, $restConfig, $restApiClassPath ); } else { - require_once $phpFile; + require_once $phpFile; } - - 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: '); + + 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) { - G::logTimeByPage(); //log this page + G::logTimeByPage(); //log this page } - } +} From ae65ae8817412bf49e209e8ba5a1feb5ffd5e208 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Thu, 8 Nov 2012 18:40:37 -0400 Subject: [PATCH 05/70] CODE STYLE class.bootstrap.php --- gulliver/system/class.bootstrap.php | 4958 +++++++++++++-------------- 1 file changed, 2479 insertions(+), 2479 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index 72d4ce52f..33c8f4cb3 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -1,7 +1,7 @@ 0) { $e = new Exception ( "Write access not allowed for ProcessMaker resources" ); $e->files = $noWritable; throw $e; } } - + /** * render a smarty template * @@ -71,23 +71,23 @@ class G if (! defined ( 'PATH_THIRDPARTY' )) { throw new Exception ( 'System constant (PATH_THIRDPARTY) is not defined!' ); } - + require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php'; $fInfo = pathinfo ( $template ); - + $tplExists = true; - + // file has absolute path if (substr ( $template, 0, 1 ) != PATH_SEP) { $template = PATH_TEMPLATE . $template; } - + // fix for template that have dot in its name but is not a valid // extension if (isset ( $fInfo ['extension'] ) && ($fInfo ['extension'] != 'tpl' || $fInfo ['extension'] != 'html')) { unset ( $fInfo ['extension'] ); } - + if (! isset ( $fInfo ['extension'] )) { if (file_exists ( $template . '.tpl' )) { $template .= '.tpl'; @@ -101,26 +101,26 @@ class G $tplExists = false; } } - + if (! $tplExists) { throw new Exception ( "Template: $template, doesn't exist!" ); } - + $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 ); } - + /** * Load Gulliver Classes * @@ -132,7 +132,7 @@ class G public function LoadSystem($strClass) { require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); } - + /** * Get the temporal directory path on differents O.S. * i.e. /temp -> linux, C:/Temp -> win @@ -156,213 +156,213 @@ class G // shouldn't exist $temp_file = tempnam ( md5 ( uniqid ( rand (), true ) ), '' ); if ($temp_file) { - $temp_dir = realpath ( dirname ( $temp_file ) ); - unlink ( $temp_file ); - return $temp_dir; + $temp_dir = realpath ( dirname ( $temp_file ) ); + unlink ( $temp_file ); + return $temp_dir; } else { - return false; + return false; } + } + } else { + return sys_get_temp_dir (); + } + } + + /** + * Transform a public URL into a local path. + * + * @author David S. Callizaya S. + * @access public + * @param string $url + * @param string $corvertionTable + * @param string $realPath + * = local path + * @return boolean + */ + public function virtualURI($url, $convertionTable, &$realPath) { + foreach ( $convertionTable as $urlPattern => $localPath ) { + // $urlPattern = addcslashes( $urlPattern , '/'); + $urlPattern = addcslashes ( $urlPattern, './' ); + $urlPattern = '/^' . str_replace ( array ( + '*', + '?' + ), array ( + '.*', + '.?' + ), $urlPattern ) . '$/'; + if (preg_match ( $urlPattern, $url, $match )) { + if ($localPath === false) { + $realPath = $url; + return false; } + if ($localPath != 'jsMethod') { + $realPath = $localPath . $match [1]; } else { - return sys_get_temp_dir (); + $realPath = $localPath; } - } - - /** - * Transform a public URL into a local path. - * - * @author David S. Callizaya S. - * @access public - * @param string $url - * @param string $corvertionTable - * @param string $realPath - * = local path - * @return boolean - */ - public function virtualURI($url, $convertionTable, &$realPath) { - foreach ( $convertionTable as $urlPattern => $localPath ) { - // $urlPattern = addcslashes( $urlPattern , '/'); - $urlPattern = addcslashes ( $urlPattern, './' ); - $urlPattern = '/^' . str_replace ( array ( - '*', - '?' - ), array ( - '.*', - '.?' - ), $urlPattern ) . '$/'; - if (preg_match ( $urlPattern, $url, $match )) { - if ($localPath === false) { - $realPath = $url; - return false; - } - if ($localPath != 'jsMethod') { - $realPath = $localPath . $match [1]; - } else { - $realPath = $localPath; - } - return true; - } - } - $realPath = $url; - return false; - } - - /** - * streaming a file - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $file - * @param boolean $download - * @param string $downloadFileName - * @return string - */ - public function streamFile($file, $download = false, $downloadFileName = '') { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $folderarray = explode ( '/', $file ); - $typearray = explode ( '.', basename ( $file ) ); - $typefile = $typearray [count ( $typearray ) - 1]; - $filename = $file; - - // trick to generate the translation.language.js file , merging two - // files and then minified the content. - if (strtolower ( $typefile ) == 'js' && $typearray [0] == 'translation') { - $output = g::streamJSTranslationFile ( $filename, $typearray [1] ); - print $output; - return; - } - - // trick to generate the big css file for ext style . - if (strtolower ( $typefile ) == 'css' && $folderarray [count ( $folderarray ) - 2] == 'css') { - $output = g::streamCSSBigFile ( $typearray [0] ); - print $output; - return; - } - - if (file_exists ( $filename )) { - switch (strtolower ( $typefile )) { - case 'swf' : - g::sendHeaders ( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); - break; - case 'js' : - g::sendHeaders ( $filename, 'text/javascript', $download, $downloadFileName ); - break; - case 'htm' : - case 'html' : - g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); - break; - case 'htc' : - g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); - break; - case 'json' : - g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); - break; - case 'gif' : - g::sendHeaders ( $filename, 'image/gif', $download, $downloadFileName ); - break; - case 'png' : - g::sendHeaders ( $filename, 'image/png', $download, $downloadFileName ); - break; - case 'jpg' : - g::sendHeaders ( $filename, 'image/jpg', $download, $downloadFileName ); - break; - case 'css' : - g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); - break; - case 'css' : - g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); - break; - case 'xml' : - g::sendHeaders ( $filename, 'text/xml', $download, $downloadFileName ); - break; - case 'txt' : - g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); - break; - case 'doc' : - case 'pdf' : - case 'pm' : - case 'po' : - g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); - break; - case 'php' : - if ($download) { - g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); - } else { - require_once ($filename); - return; - } - break; - case 'tar' : - g::sendHeaders ( $filename, 'application/x-tar', $download, $downloadFileName ); - break; - default : - // throw new Exception ( "Unknown type of file '$file'. " ); - g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); - break; - break; - } - } else { - if (strpos ( $file, 'gulliver' ) !== false) { - list ( $path, $filename ) = explode ( 'gulliver', $file ); - } - - $_SESSION ['phpFileNotFound'] = $file; - g::header ( "location: /errors/error404.php?l=" . $_SERVER ['REQUEST_URI'] ); - } - - switch (strtolower ( $typefile )) { - case "js" : - $paths = explode ( '/', $filename ); - $jsName = $paths [count ( $paths ) - 1]; - $output = ''; - $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; - switch ($jsName) { - // - case 'draw2d.js' : - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = g::getCheckSum ( array ( - $pathJs . 'ext/wz_jsgraphics.js', - $pathJs . 'ext/mootools.js', - $pathJs . 'ext/moocanvas.js' - ) ); - - $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; - $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-draw2d-cache.*.js' ); - // error_log("draw2d.js ".$checksum ."==". - // $cfStored['checksum']); - if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { - $output = file_get_contents ( $cf ); - } else { - if (is_file ( $cfStored ['filename'] )) { - @unlink ( $cfStored ['filename'] ); - } - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/wz_jsgraphics.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/mootools.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/moocanvas.js' ) ); - $output .= file_get_contents ( $pathJs . 'ext/draw2d.js' ); // already - // minified - file_put_contents ( $cf, $output ); - } - break; - case 'ext-all.js' : - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = g::getCheckSum ( array ( - $pathJs . 'ext/pmos-common.js', - $pathJs . 'ext/ux/miframe.js', - $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js', - $pathJs . 'ext/ux.statusbar/ext-statusbar.js', - $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' - ) ); - - $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-all-cache.*.js' ); - $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; - if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { - $output = file_get_contents ( $cf ); - } else { + return true; + } + } + $realPath = $url; + return false; + } + + /** + * streaming a file + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + public function streamFile($file, $download = false, $downloadFileName = '') { + require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); + $folderarray = explode ( '/', $file ); + $typearray = explode ( '.', basename ( $file ) ); + $typefile = $typearray [count ( $typearray ) - 1]; + $filename = $file; + + // trick to generate the translation.language.js file , merging two + // files and then minified the content. + if (strtolower ( $typefile ) == 'js' && $typearray [0] == 'translation') { + $output = g::streamJSTranslationFile ( $filename, $typearray [1] ); + print $output; + return; + } + + // trick to generate the big css file for ext style . + if (strtolower ( $typefile ) == 'css' && $folderarray [count ( $folderarray ) - 2] == 'css') { + $output = g::streamCSSBigFile ( $typearray [0] ); + print $output; + return; + } + + if (file_exists ( $filename )) { + switch (strtolower ( $typefile )) { + case 'swf' : + g::sendHeaders ( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); + break; + case 'js' : + g::sendHeaders ( $filename, 'text/javascript', $download, $downloadFileName ); + break; + case 'htm' : + case 'html' : + g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'htc' : + g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'json' : + g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'gif' : + g::sendHeaders ( $filename, 'image/gif', $download, $downloadFileName ); + break; + case 'png' : + g::sendHeaders ( $filename, 'image/png', $download, $downloadFileName ); + break; + case 'jpg' : + g::sendHeaders ( $filename, 'image/jpg', $download, $downloadFileName ); + break; + case 'css' : + g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'css' : + g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'xml' : + g::sendHeaders ( $filename, 'text/xml', $download, $downloadFileName ); + break; + case 'txt' : + g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'doc' : + case 'pdf' : + case 'pm' : + case 'po' : + g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + case 'php' : + if ($download) { + g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); + } else { + require_once ($filename); + return; + } + break; + case 'tar' : + g::sendHeaders ( $filename, 'application/x-tar', $download, $downloadFileName ); + break; + default : + // throw new Exception ( "Unknown type of file '$file'. " ); + g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + break; + } + } else { + if (strpos ( $file, 'gulliver' ) !== false) { + list ( $path, $filename ) = explode ( 'gulliver', $file ); + } + + $_SESSION ['phpFileNotFound'] = $file; + g::header ( "location: /errors/error404.php?l=" . $_SERVER ['REQUEST_URI'] ); + } + + switch (strtolower ( $typefile )) { + case "js" : + $paths = explode ( '/', $filename ); + $jsName = $paths [count ( $paths ) - 1]; + $output = ''; + $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; + switch ($jsName) { + // + case 'draw2d.js' : + $cachePath = PATH_C . 'ExtJs' . PATH_SEP; + $checksum = g::getCheckSum ( array ( + $pathJs . 'ext/wz_jsgraphics.js', + $pathJs . 'ext/mootools.js', + $pathJs . 'ext/moocanvas.js' + ) ); + + $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; + $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-draw2d-cache.*.js' ); + // error_log("draw2d.js ".$checksum ."==". + // $cfStored['checksum']); + if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { + $output = file_get_contents ( $cf ); + } else { if (is_file ( $cfStored ['filename'] )) { - @unlink ( $cfStored ['filename'] ); + @unlink ( $cfStored ['filename'] ); } - + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/wz_jsgraphics.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/mootools.js' ) ); + $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/moocanvas.js' ) ); + $output .= file_get_contents ( $pathJs . 'ext/draw2d.js' ); // already + // minified + file_put_contents ( $cf, $output ); + } + break; + case 'ext-all.js' : + $cachePath = PATH_C . 'ExtJs' . PATH_SEP; + $checksum = g::getCheckSum ( array ( + $pathJs . 'ext/pmos-common.js', + $pathJs . 'ext/ux/miframe.js', + $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js', + $pathJs . 'ext/ux.statusbar/ext-statusbar.js', + $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' + ) ); + + $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-all-cache.*.js' ); + $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; + if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { + $output = file_get_contents ( $cf ); + } else { + if (is_file ( $cfStored ['filename'] )) { + @unlink ( $cfStored ['filename'] ); + } + $output .= file_get_contents ( $pathJs . 'ext/ext-all.js' ); // already // minified $output .= file_get_contents ( $pathJs . 'ext/ux/ux-all.js' ); // already @@ -372,249 +372,249 @@ class G $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); - + file_put_contents ( $cf, $output ); - } - break; - case 'maborak.js' : - $oHeadPublisher = & headPublisher::getSingleton (); - foreach ( $oHeadPublisher->maborakFiles as $fileJS ) { + } + break; + case 'maborak.js' : + $oHeadPublisher = & headPublisher::getSingleton (); + foreach ( $oHeadPublisher->maborakFiles as $fileJS ) { $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); } break; - case 'maborak.loader.js' : + case 'maborak.loader.js' : $oHeadPublisher = & headPublisher::getSingleton (); foreach ( $oHeadPublisher->maborakLoaderFiles as $fileJS ) { - $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); + $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); } break; - default : + default : $output = JSMin::minify ( file_get_contents ( $filename ) ); - break; - } - print $output; break; - case 'css' : - print g::trimSourceCodeFile ( $filename ); - break; - default : - @readfile ( $filename ); - break; - } - } - - /** - * Parsing the URI - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $urlLink - * @return string - */ - static public function parseURI($uri, $isRestRequest = false) { - // *** 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 ); - if ($isRestRequest) { - $args = self::parseRestUri ( $aRequestUri ); - } else { - $args = self::parseNormalUri ( $aRequestUri ); - } - - define ( "SYS_LANG", $args ['SYS_LANG'] ); - define ( "SYS_SKIN", $args ['SYS_SKIN'] ); - define ( 'SYS_COLLECTION', $args ['SYS_COLLECTION'] ); - define ( 'SYS_TARGET', $args ['SYS_TARGET'] ); - - if ($args ['SYS_COLLECTION'] == 'js2') { - print "ERROR"; - die (); + } + print $output; + break; + case 'css' : + print g::trimSourceCodeFile ( $filename ); + break; + default : + @readfile ( $filename ); + break; + } } - } - + /** - * isPMUnderUpdating, Used to set a file flag to check if PM is upgrading. - * - * @setFlag Contains the flag to set or unset the temporary file: - * 0 to delete the temporary file flag - * 1 to set the temporary file flag. - * 2 or bigger to check if the temporary file exists. - * return true if the file exists, otherwise false. - */ + * Parsing the URI + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + static public function parseURI($uri, $isRestRequest = false) { + // *** 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 ); + if ($isRestRequest) { + $args = self::parseRestUri ( $aRequestUri ); + } else { + $args = self::parseNormalUri ( $aRequestUri ); + } + + define ( "SYS_LANG", $args ['SYS_LANG'] ); + define ( "SYS_SKIN", $args ['SYS_SKIN'] ); + define ( 'SYS_COLLECTION', $args ['SYS_COLLECTION'] ); + define ( 'SYS_TARGET', $args ['SYS_TARGET'] ); + + if ($args ['SYS_COLLECTION'] == 'js2') { + print "ERROR"; + die (); + } + } + + /** + * isPMUnderUpdating, Used to set a file flag to check if PM is upgrading. + * + * @setFlag Contains the flag to set or unset the temporary file: + * 0 to delete the temporary file flag + * 1 to set the temporary file flag. + * 2 or bigger to check if the temporary file exists. + * return true if the file exists, otherwise false. + */ public function isPMUnderUpdating($setFlag = 2) { - $fileCheck = PATH_DATA . "UPDATE.dat"; - if ($setFlag == 0) { - if (file_exists ( $fileCheck )) { - unlink ( $fileCheck ); + $fileCheck = PATH_DATA . "UPDATE.dat"; + if ($setFlag == 0) { + if (file_exists ( $fileCheck )) { + unlink ( $fileCheck ); + } + } elseif ($setFlag == 1) { + $fp = fopen ( $fileCheck, 'w' ); + $line = fputs ( $fp, "true" ); + } + // checking temporary file + if ($setFlag >= 1) { + if (file_exists ( $fileCheck )) { + return true; + } + } + return false; } - } elseif ($setFlag == 1) { - $fp = fopen ( $fileCheck, 'w' ); - $line = fputs ( $fp, "true" ); - } - // checking temporary file - if ($setFlag >= 1) { - if (file_exists ( $fileCheck )) { - return true; - } - } - return false; - } - + /** - * parse a smarty template and return teh result as string - * - * @author Erik Amaru Ortiz - * @param $template string - * containing the template filename on /gulliver/templates/ - * directory - * @param $data associative - * array containig the template data - * @return $content string containing the parsed template content - */ + * parse a smarty template and return teh result as string + * + * @author Erik Amaru Ortiz + * @param $template string + * containing the template filename on /gulliver/templates/ + * directory + * @param $data associative + * array containig the template data + * @return $content string containing the parsed template content + */ public function parseTemplate($template, $data = array()) { - $content = ''; - - ob_start (); - g::renderTemplate ( $template, $data ); - $content = ob_get_contents (); - ob_get_clean (); - - return $content; + $content = ''; + + ob_start (); + g::renderTemplate ( $template, $data ); + $content = ob_get_contents (); + ob_get_clean (); + + return $content; } - + /** - * If the class is not defined by the aplication, it - * attempt to load the class from gulliver.system - * - * @author Fernando Ontiveros Lira , David S. Callizaya - * @access public - * @param string $strClass - * @return void - */ + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ public function LoadClass($strClass) { - $classfile = g::ExpandPath ( "classes" ) . 'class.' . $strClass . '.php'; - if (! file_exists ( $classfile )) { - if (file_exists ( PATH_GULLIVER . 'class.' . $strClass . '.php' )) { - return require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); - } else { - return false; + $classfile = g::ExpandPath ( "classes" ) . 'class.' . $strClass . '.php'; + if (! file_exists ( $classfile )) { + if (file_exists ( PATH_GULLIVER . 'class.' . $strClass . '.php' )) { + return require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); + } else { + return false; + } + } else { + return require_once ($classfile); + } } - } else { - return require_once ($classfile); - } - } - + /** - * Loads a Class. - * If the class is not defined by the aplication, it - * attempt to load the class from gulliver.system - * - * @author Fernando Ontiveros Lira , David S. Callizaya - * @access public - * @param string $strClass - * @return void - */ + * Loads a Class. + * If the class is not defined by the aplication, it + * attempt to load the class from gulliver.system + * + * @author Fernando Ontiveros Lira , David S. Callizaya + * @access public + * @param string $strClass + * @return void + */ public function LoadThirdParty($sPath, $sFile) { - $classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr ( $sFile, 0, - 4 ) !== '.php') ? '.php' : ''); - return require_once ($classfile); + $classfile = PATH_THIRDPARTY . $sPath . '/' . $sFile . ((substr ( $sFile, 0, - 4 ) !== '.php') ? '.php' : ''); + return require_once ($classfile); } - + /** - * Function LoadTranslationObject - * It generates a global Translation variable that will be used in all the - * system. - * Per script - * - * @author Hugo Loza. - * @access public - * @param - * eter string lang - * @return void - */ + * Function LoadTranslationObject + * It generates a global Translation variable that will be used in all the + * system. + * Per script + * + * @author Hugo Loza. + * @access public + * @param + * eter string lang + * @return void + */ public function LoadTranslationObject($lang = SYS_LANG) { - $defaultTranslations = Array (); - $foreignTranslations = Array (); - - // if the default translations table doesn't exist we can't proceed - if (! is_file ( PATH_LANGUAGECONT . 'translation.en' )) { - return null; + $defaultTranslations = Array (); + $foreignTranslations = Array (); + + // if the default translations table doesn't exist we can't proceed + if (! is_file ( PATH_LANGUAGECONT . 'translation.en' )) { + return null; + } + // load the translations table + require_once (PATH_LANGUAGECONT . 'translation.en'); + $defaultTranslations = $translation; + + // if some foreign language was requested and its translation file + // exists + if ($lang != 'en' && file_exists ( PATH_LANGUAGECONT . 'translation.' . $lang )) { + require_once (PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table + $foreignTranslations = $translation; + } + + global $translation; + if (defined ( "SHOW_UNTRANSLATED_AS_TAG" ) && SHOW_UNTRANSLATED_AS_TAG != 0) { + $translation = $foreignTranslations; + } else { + $translation = array_merge ( $defaultTranslations, $foreignTranslations ); + } + return true; } - // load the translations table - require_once (PATH_LANGUAGECONT . 'translation.en'); - $defaultTranslations = $translation; - - // if some foreign language was requested and its translation file - // exists - if ($lang != 'en' && file_exists ( PATH_LANGUAGECONT . 'translation.' . $lang )) { - require_once (PATH_LANGUAGECONT . 'translation.' . $lang); // load the foreign translations table - $foreignTranslations = $translation; - } - - global $translation; - if (defined ( "SHOW_UNTRANSLATED_AS_TAG" ) && SHOW_UNTRANSLATED_AS_TAG != 0) { - $translation = $foreignTranslations; - } else { - $translation = array_merge ( $defaultTranslations, $foreignTranslations ); - } - return true; - } - + /** - * Render Page - * - * @author Fernando Ontiveros Lira - * @access public - * @param object $objContent - * @param string $strTemplate - * @param string $strSkin - * @return void - */ + * Render Page + * + * @author Fernando Ontiveros Lira + * @access public + * @param object $objContent + * @param string $strTemplate + * @param string $strSkin + * @return void + */ public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '') { - global $G_CONTENT; - global $G_TEMPLATE; + global $G_CONTENT; + global $G_TEMPLATE; global $G_SKIN; global $G_PUBLISH; - + $G_CONTENT = $objContent; $G_TEMPLATE = $strTemplate; $G_SKIN = $strSkin; - + try { - $file = g::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; - include $file; - $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); - $skinEngine->setLayout ( $layout ); - $skinEngine->dispatch (); + $file = g::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; + include $file; + $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); + $skinEngine->setLayout ( $layout ); + $skinEngine->dispatch (); } catch ( Exception $e ) { - global $G_PUBLISH; - if (is_null ( $G_PUBLISH )) { - $G_PUBLISH = new Publisher (); + global $G_PUBLISH; + if (is_null ( $G_PUBLISH )) { + $G_PUBLISH = new Publisher (); + } + if (count ( $G_PUBLISH->Parts ) == 1) { + array_shift ( $G_PUBLISH->Parts ); + } + global $oHeadPublisher; + $leimnudInitString = $oHeadPublisher->leimnudInitString; + $oHeadPublisher->clearScripts (); + $oHeadPublisher->leimnudInitString = $leimnudInitString; + $oHeadPublisher->addScriptFile ( '/js/maborak/core/maborak.js' ); + $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', null, array ( + 'MESSAGE' => $e->getMessage () + ) ); + if (class_exists ( 'SkinEngine' )) { + $skinEngine = new SkinEngine ( 'publish', 'blank', '' ); + $skinEngine->dispatch (); + } else { + die ( $e->getMessage () ); + } } - if (count ( $G_PUBLISH->Parts ) == 1) { - array_shift ( $G_PUBLISH->Parts ); - } - global $oHeadPublisher; - $leimnudInitString = $oHeadPublisher->leimnudInitString; - $oHeadPublisher->clearScripts (); - $oHeadPublisher->leimnudInitString = $leimnudInitString; - $oHeadPublisher->addScriptFile ( '/js/maborak/core/maborak.js' ); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', null, array ( - 'MESSAGE' => $e->getMessage () - ) ); - if (class_exists ( 'SkinEngine' )) { - $skinEngine = new SkinEngine ( 'publish', 'blank', '' ); - $skinEngine->dispatch (); - } else { - die ( $e->getMessage () ); - } - } - } - - /** + } + + /** * SendTemporalMessage * * @param string $msgID @@ -630,34 +630,34 @@ class G * * @return void */ - public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null) { + public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null) { if (isset ( $width )) { - $_SESSION ['G_MESSAGE_WIDTH'] = $width; + $_SESSION ['G_MESSAGE_WIDTH'] = $width; } if (isset ( $time )) { - $_SESSION ['G_MESSAGE_TIME'] = $time; + $_SESSION ['G_MESSAGE_TIME'] = $time; } switch (strtolower ( $sType )) { - case 'label' : - case 'labels' : - $_SESSION ['G_MESSAGE_TYPE'] = $strType; - $_SESSION ['G_MESSAGE'] = nl2br ( g::LoadTranslation ( $msgID ) ); - break; - case 'string' : - $_SESSION ['G_MESSAGE_TYPE'] = $strType; - $_SESSION ['G_MESSAGE'] = nl2br ( $msgID ); - break; - } - if ($customLabels != null) { - $message = $_SESSION ['G_MESSAGE']; - foreach ( $customLabels as $key => $val ) { - $message = str_replace ( '{' . nl2br ( $key ) . '}', nl2br ( $val ), $message ); - } - $_SESSION ['G_MESSAGE'] = $message; + case 'label' : + case 'labels' : + $_SESSION ['G_MESSAGE_TYPE'] = $strType; + $_SESSION ['G_MESSAGE'] = nl2br ( g::LoadTranslation ( $msgID ) ); + break; + case 'string' : + $_SESSION ['G_MESSAGE_TYPE'] = $strType; + $_SESSION ['G_MESSAGE'] = nl2br ( $msgID ); + break; + } + if ($customLabels != null) { + $message = $_SESSION ['G_MESSAGE']; + foreach ( $customLabels as $key => $val ) { + $message = str_replace ( '{' . nl2br ( $key ) . '}', nl2br ( $val ), $message ); + } + $_SESSION ['G_MESSAGE'] = $message; } - } - - /** + } + + /** * Redirect URL * * @author Fernando Ontiveros Lira @@ -665,17 +665,17 @@ class G * @param string $parameter * @return string */ - public function header($parameter) { + public function header($parameter) { if (defined ( 'ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr ( $parameter, 0, 9 ) == 'location:')) { - $url = g::encrypt ( substr ( $parameter, 10 ), URL_KEY ); - header ( 'location:' . $url ); + $url = g::encrypt ( substr ( $parameter, 10 ), URL_KEY ); + header ( 'location:' . $url ); } else { - header ( $parameter ); + header ( $parameter ); } return; - } - - /** + } + + /** * Include all model plugin files * * LoadAllPluginModelClasses @@ -684,203 +684,203 @@ class G * @access public * @return void */ - public function LoadAllPluginModelClasses() { + public function LoadAllPluginModelClasses() { // Get the current Include path, where the plugins directories should be if (! defined ( 'PATH_SEPARATOR' )) { - define ( 'PATH_SEPARATOR', (substr ( PHP_OS, 0, 3 ) == 'WIN') ? ';' : ':' ); + define ( 'PATH_SEPARATOR', (substr ( PHP_OS, 0, 3 ) == 'WIN') ? ';' : ':' ); } $path = explode ( PATH_SEPARATOR, get_include_path () ); - + foreach ( $path as $possiblePath ) { if (strstr ( $possiblePath, "plugins" )) { - $baseDir = $possiblePath . 'classes' . PATH_SEP . 'model'; + $baseDir = $possiblePath . 'classes' . PATH_SEP . 'model'; if (file_exists ( $baseDir )) { - if ($handle = opendir ( $baseDir )) { - while ( false !== ($file = readdir ( $handle )) ) { - if (strpos ( $file, '.php', 1 ) && ! strpos ( $file, 'Peer.php', 1 )) { - require_once ($baseDir . PATH_SEP . $file); + if ($handle = opendir ( $baseDir )) { + while ( false !== ($file = readdir ( $handle )) ) { + if (strpos ( $file, '.php', 1 ) && ! strpos ( $file, 'Peer.php', 1 )) { + require_once ($baseDir . PATH_SEP . $file); + } + } + } + // Include also the extendGulliverClass that could have some + // new definitions for fields + if (file_exists ( $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php' )) { + include_once $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php'; + } } - } - } - // Include also the extendGulliverClass that could have some - // new definitions for fields - if (file_exists ( $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php' )) { - include_once $possiblePath . 'classes' . PATH_SEP . 'class.extendGulliver.php'; - } - } - } - } - } - - /** - * Expand the path using the path constants - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strPath - * @return string - */ - public function expandPath($strPath = '') { - $res = ""; - $res = PATH_CORE; - if ($strPath != "") { - $res .= $strPath . "/"; - } - return $res; - } - - /** - * This method allow dispatch rest services using 'Restler' thirdparty library - * - * @author Erik Amaru Ortiz - */ - public function dispatchRestService ($uri, $config, $apiClassesPath = '') - { - require_once 'restler/restler.php'; - - $rest = new Restler(); - $rest->setSupportedFormats( 'JsonFormat', 'XmlFormat' ); - // getting all services class - $restClasses = array (); - $restClassesList = g::rglob( '*', 0, PATH_CORE . 'services/' ); - foreach ($restClassesList as $classFile) { - if (substr( $classFile, - 4 ) === '.php') { + } + } + } + + /** + * Expand the path using the path constants + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath + * @return string + */ + public function expandPath($strPath = '') { + $res = ""; + $res = PATH_CORE; + if ($strPath != "") { + $res .= $strPath . "/"; + } + return $res; + } + + /** + * This method allow dispatch rest services using 'Restler' thirdparty library + * + * @author Erik Amaru Ortiz + */ + public function dispatchRestService ($uri, $config, $apiClassesPath = '') + { + require_once 'restler/restler.php'; + + $rest = new Restler(); + $rest->setSupportedFormats( 'JsonFormat', 'XmlFormat' ); + // getting all services class + $restClasses = array (); + $restClassesList = g::rglob( '*', 0, PATH_CORE . 'services/' ); + foreach ($restClassesList as $classFile) { + if (substr( $classFile, - 4 ) === '.php') { $restClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; - } - } - if (! empty( $apiClassesPath )) { - $pluginRestClasses = array (); - $restClassesList = g::rglob( '*', 0, $apiClassesPath . 'services/' ); - foreach ($restClassesList as $classFile) { + } + } + if (! empty( $apiClassesPath )) { + $pluginRestClasses = array (); + $restClassesList = g::rglob( '*', 0, $apiClassesPath . 'services/' ); + foreach ($restClassesList as $classFile) { if (substr( $classFile, - 4 ) === '.php') { - $pluginRestClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; + $pluginRestClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; } - } - $restClasses = array_merge( $restClasses, $pluginRestClasses ); - } - // hook to get rest api classes from plugins - if (class_exists( 'PMPluginRegistry' )) { - $pluginRegistry = & PMPluginRegistry::getSingleton(); - $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); - $restClasses = array_merge( $restClasses, $pluginClasses ); - } - foreach ($restClasses as $key => $classFile) { - if (! file_exists( $classFile )) { - unset( $restClasses[$key] ); - continue; - } - //load the file, and check if exist the class inside it. - require_once $classFile; - $namespace = 'Services_Rest_'; - $className = str_replace( '.php', '', basename( $classFile ) ); - - // if the core class does not exists try resolve the for a plugin - if (! class_exists( $namespace . $className )) { - $namespace = 'Plugin_Services_Rest_'; - // Couldn't resolve the class name, just skipp it - if (! class_exists( $namespace . $className )) { - unset( $restClasses[$key] ); - continue; - } - } - // verify if there is an auth class implementing 'iAuthenticate' - $classNameAuth = $namespace . $className; - $reflClass = new ReflectionClass( $classNameAuth ); - // that wasn't from plugin - if ($reflClass->implementsInterface( 'iAuthenticate' ) && $namespace != 'Plugin_Services_Rest_') { - // auth class found, set as restler authentication class handler - $rest->addAuthenticationClass( $classNameAuth ); - } else { - // add api class - $rest->addAPIClass( $classNameAuth ); - } - } - //end foreach rest class - // resolving the class for current request - $uriPart = explode( '/', $uri ); - $requestedClass = ''; - if (isset( $uriPart[1] )) { - $requestedClass = ucfirst( $uriPart[1] ); - } - if (class_exists( 'Services_Rest_' . $requestedClass )) { - $namespace = 'Services_Rest_'; - } elseif (class_exists( 'Plugin_Services_Rest_' . $requestedClass )) { - $namespace = 'Plugin_Services_Rest_'; - } else { - $namespace = ''; - } - // end resolv. - // Send additional headers (if exists) configured on rest-config.ini - if (array_key_exists( 'HEADERS', $config )) { - foreach ($config['HEADERS'] as $name => $value) { + } + $restClasses = array_merge( $restClasses, $pluginRestClasses ); + } + // hook to get rest api classes from plugins + if (class_exists( 'PMPluginRegistry' )) { + $pluginRegistry = & PMPluginRegistry::getSingleton(); + $pluginClasses = $pluginRegistry->getRegisteredRestClassFiles(); + $restClasses = array_merge( $restClasses, $pluginClasses ); + } + foreach ($restClasses as $key => $classFile) { + if (! file_exists( $classFile )) { + unset( $restClasses[$key] ); + continue; + } + //load the file, and check if exist the class inside it. + require_once $classFile; + $namespace = 'Services_Rest_'; + $className = str_replace( '.php', '', basename( $classFile ) ); + + // if the core class does not exists try resolve the for a plugin + if (! class_exists( $namespace . $className )) { + $namespace = 'Plugin_Services_Rest_'; + // Couldn't resolve the class name, just skipp it + if (! class_exists( $namespace . $className )) { + unset( $restClasses[$key] ); + continue; + } + } + // verify if there is an auth class implementing 'iAuthenticate' + $classNameAuth = $namespace . $className; + $reflClass = new ReflectionClass( $classNameAuth ); + // that wasn't from plugin + if ($reflClass->implementsInterface( 'iAuthenticate' ) && $namespace != 'Plugin_Services_Rest_') { + // auth class found, set as restler authentication class handler + $rest->addAuthenticationClass( $classNameAuth ); + } else { + // add api class + $rest->addAPIClass( $classNameAuth ); + } + } + //end foreach rest class + // resolving the class for current request + $uriPart = explode( '/', $uri ); + $requestedClass = ''; + if (isset( $uriPart[1] )) { + $requestedClass = ucfirst( $uriPart[1] ); + } + if (class_exists( 'Services_Rest_' . $requestedClass )) { + $namespace = 'Services_Rest_'; + } elseif (class_exists( 'Plugin_Services_Rest_' . $requestedClass )) { + $namespace = 'Plugin_Services_Rest_'; + } else { + $namespace = ''; + } + // end resolv. + // Send additional headers (if exists) configured on rest-config.ini + if (array_key_exists( 'HEADERS', $config )) { + foreach ($config['HEADERS'] as $name => $value) { header( "$name: $value" ); - } - } - // to handle a request with "OPTIONS" method - if (! empty( $namespace ) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { - $reflClass = new ReflectionClass( $namespace . $requestedClass ); - // if the rest class has not a "options" method - if (! $reflClass->hasMethod( 'options' )) { - header( 'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS' ); - header( 'Access-Control-Allow-Headers: authorization, content-type' ); - header( "Access-Control-Allow-Credentials", "false" ); - header( 'Access-Control-Max-Age: 60' ); - exit(); - } + } + } + // to handle a request with "OPTIONS" method + if (! empty( $namespace ) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') { + $reflClass = new ReflectionClass( $namespace . $requestedClass ); + // if the rest class has not a "options" method + if (! $reflClass->hasMethod( 'options' )) { + header( 'Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS' ); + header( 'Access-Control-Allow-Headers: authorization, content-type' ); + header( "Access-Control-Allow-Credentials", "false" ); + header( 'Access-Control-Max-Age: 60' ); + exit(); + } + } + // override global REQUEST_URI to pass to Restler library + $_SERVER['REQUEST_URI'] = '/' . strtolower( $namespace ) . ltrim( $uri, '/' ); + // handle the rest request + $rest->handle(); } - // override global REQUEST_URI to pass to Restler library - $_SERVER['REQUEST_URI'] = '/' . strtolower( $namespace ) . ltrim( $uri, '/' ); - // handle the rest request - $rest->handle(); - } - - /** + + /** * function to calculate the time used to render a page - */ - public function logTimeByPage() { - if (! defined ( PATH_DATA )) { - return false; - } - - $serverAddr = $_SERVER ['SERVER_ADDR']; - global $startingTime; - $endTime = microtime ( true ); + */ + public 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 - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $file - * @param boolean $download - * @param string $downloadFileName - * @return string - */ - public function streamJSTranslationFile($filename, $locale = 'en') { - header ( 'Content-Type: text/javascript' ); - - if (! g::LoadTranslationObject ( $locale )) { + fclose ( $fpt ); + } + + /** + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @param boolean $download + * @param string $downloadFileName + * @return string + */ + public function streamJSTranslationFile($filename, $locale = 'en') { + header ( 'Content-Type: text/javascript' ); + + if (! g::LoadTranslationObject ( $locale )) { header ( 'Cache-Control: no-cache' ); header ( 'Pragma: no-cache' ); return; - } - - global $translation; - - // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE - // behaivor. - $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); - if (file_exists ( $filename )) { + } + + global $translation; + + // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE + // behaivor. + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + if (file_exists ( $filename )) { $mtime = filemtime ( $filename ); - } else { - $mtime = date ( 'U' ); + } else { + $mtime = date ( 'U' ); } - + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; header ( 'Pragma: cache' ); header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); @@ -889,2095 +889,2095 @@ class G header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 30 * 60 * 60 * 24 ) . " GMT" ); // 1 // month if (isset ( $_SERVER ['HTTP_IF_MODIFIED_SINCE'] )) { - if ($_SERVER ['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { - header ( 'HTTP/1.1 304 Not Modified' ); - exit (); + if ($_SERVER ['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header ( 'HTTP/1.1 304 Not Modified' ); + exit (); + } } - } - + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { - if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { - header ( "HTTP/1.1 304 Not Modified" ); - exit (); + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + exit (); + } } - } - + return JSMin::minify ( 'var TRANSLATIONS = ' . g::json_encode ( $translation ) . ';' ); } - + /** - * streaming a big JS file with small js files - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $file - * @return string - */ + * streaming a big JS file with small js files + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $file + * @return string + */ public function streamCSSBigFile ($filename) { - header( 'Content-Type: text/css' ); - - //First get Skin info - $filenameParts = explode( "-", $filename ); - $skinName = $filenameParts[0]; - $skinVariant = "skin"; - - if (isset( $filenameParts[1] )) { - $skinVariant = strtolower( $filenameParts[1] ); - } - - $configurationFile = ''; - if ($skinName == "jscolors") { - $skinName = "classic"; - } - if ($skinName == "xmlcolors") { - $skinName = "classic"; - } - if ($skinName == "classic") { - $configurationFile = g::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; - } else { - $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; - - if (! is_file( $configurationFile )) { - $configurationFile = g::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; - } - } - - //Read Configuration File - $xmlConfiguration = file_get_contents( $configurationFile ); - $xmlConfigurationObj = g::xmlParser( $xmlConfiguration ); - $baseSkinDirectory = dirname( $configurationFile ); - $directorySize = g::getDirectorySize( $baseSkinDirectory ); - $mtime = $directorySize['maxmtime']; - - //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. - //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); - - $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; - header( 'Pragma: cache' ); - header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); - header( "Last-Modified: " . $gmt_mtime ); - header( 'Cache-Control: public' ); - header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 30 * 60 * 60 * 24 ) . " GMT" ); //1 month - //header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*60*24 ) . " GMT"); //1 day - tempor - if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { - if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { - header( 'HTTP/1.1 304 Not Modified' ); - exit(); - } - } - - if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { - if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { - header( "HTTP/1.1 304 Not Modified" ); - exit(); - } - } - - $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; - $outputHeader .= " Skin: $filename\n"; - $outputHeader .= " Configuration: $configurationFile\n"; - $mtimeNow = date( 'U' ); - $gmt_mtimeNow = gmdate( "D, d M Y H:i:s", $mtimeNow ) . " GMT"; - $outputHeader .= " Date: $gmt_mtimeNow*/\n"; - $output = ""; - //Base files - switch (strtolower( $skinVariant )) { - case "extjs": - //Basepublic function getDirectorySize ($path, $maxmtime = 0) - { - $totalsize = 0; - $totalcount = 0; - $dircount = 0; - if ($handle = opendir( $path )) { - while (false !== ($file = readdir( $handle ))) { - $nextpath = $path . '/' . $file; - if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { - if (is_dir( $nextpath )) { - $dircount ++; - $result = g::getDirectorySize( $nextpath, $maxmtime ); - $totalsize += $result['size']; - $totalcount += $result['count']; - $dircount += $result['dircount']; - $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; - } elseif (is_file( $nextpath )) { - $totalsize += filesize( $nextpath ); - $totalcount ++; - - $mtime = filemtime( $nextpath ); - if ($mtime > $maxmtime) { - $maxmtime = $mtime; - } - } - } - } - } - closedir( $handle ); - $total['size'] = $totalsize; - $total['count'] = $totalcount; - $total['dircount'] = $dircount; - $total['maxmtime'] = $maxmtime; - - return $total; - } - - $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; - $output .= file_get_contents( $baseCSSPath . 'ext-all-notheme.css' ); - //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); - - //Classic Skin - $extJsSkin = 'xtheme-gray'; - - break; - default: - - break; - - } - - //Get Browser Info - $infoBrowser = g::browser_detection( 'full_assoc' ); - $browserName = $infoBrowser['browser_working']; - if (isset( $infoBrowser[$browserName . '_data'] )) { - if ($infoBrowser[$browserName . '_data'][0] != "") { - $browserName = $infoBrowser[$browserName . '_data'][0]; - } - } - - //Read Configuration File - $xmlConfiguration = file_get_contents ( $configurationFile ); - $xmlConfigurationObj = g::xmlParser($xmlConfiguration); - - $skinFilesArray=$xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['cssFiles']['__CONTENT__'][$skinVariant]['__CONTENT__']['cssFile'] ; - foreach ($skinFilesArray as $keyFile => $cssFileInfo) { - $enabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['enabledBrowsers']); - $disabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['disabledBrowsers']); - - if (((in_array($browserName, $enabledBrowsers))||(in_array('ALL', $enabledBrowsers)))&&(!(in_array($browserName, $disabledBrowsers)))) { - if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') { - g::LoadClass('serverConfiguration'); - $oServerConf =& serverConf::getSingleton(); - if (!(defined('SYS_LANG'))) { - if (isset($_SERVER['HTTP_REFERER'])) { - $syss = explode('://', $_SERVER['HTTP_REFERER']); - $sysObjets = explode('/', $syss['1']); - $sysLang = $sysObjets['2']; - } else { - $sysLang = 'en'; + header( 'Content-Type: text/css' ); + + //First get Skin info + $filenameParts = explode( "-", $filename ); + $skinName = $filenameParts[0]; + $skinVariant = "skin"; + + if (isset( $filenameParts[1] )) { + $skinVariant = strtolower( $filenameParts[1] ); } + + $configurationFile = ''; + if ($skinName == "jscolors") { + $skinName = "classic"; + } + if ($skinName == "xmlcolors") { + $skinName = "classic"; + } + if ($skinName == "classic") { + $configurationFile = g::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; } else { - $sysLang = SYS_LANG; + $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; + + if (! is_file( $configurationFile )) { + $configurationFile = g::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; + } } - if ($oServerConf->isRtl($sysLang)) { - $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + + //Read Configuration File + $xmlConfiguration = file_get_contents( $configurationFile ); + $xmlConfigurationObj = g::xmlParser( $xmlConfiguration ); + $baseSkinDirectory = dirname( $configurationFile ); + $directorySize = g::getDirectorySize( $baseSkinDirectory ); + $mtime = $directorySize['maxmtime']; + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); + + $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; + header( 'Pragma: cache' ); + header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); + header( "Last-Modified: " . $gmt_mtime ); + header( 'Cache-Control: public' ); + header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 30 * 60 * 60 * 24 ) . " GMT" ); //1 month + //header("Expires: " . gmdate("D, d M Y H:i:s", time () + 60*60*24 ) . " GMT"); //1 day - tempor + if (isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] )) { + if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { + header( 'HTTP/1.1 304 Not Modified' ); + exit(); + } } - } else { - $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + + if (isset( $_SERVER['HTTP_IF_NONE_MATCH'] )) { + if (str_replace( '"', '', stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) == md5( $mtime . $filename )) { + header( "HTTP/1.1 304 Not Modified" ); + exit(); + } + } + + $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; + $outputHeader .= " Skin: $filename\n"; + $outputHeader .= " Configuration: $configurationFile\n"; + $mtimeNow = date( 'U' ); + $gmt_mtimeNow = gmdate( "D, d M Y H:i:s", $mtimeNow ) . " GMT"; + $outputHeader .= " Date: $gmt_mtimeNow*/\n"; + $output = ""; + //Base files + switch (strtolower( $skinVariant )) { + case "extjs": + //Basepublic function getDirectorySize ($path, $maxmtime = 0) + { + $totalsize = 0; + $totalcount = 0; + $dircount = 0; + if ($handle = opendir( $path )) { + while (false !== ($file = readdir( $handle ))) { + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { + if (is_dir( $nextpath )) { + $dircount ++; + $result = g::getDirectorySize( $nextpath, $maxmtime ); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; + } elseif (is_file( $nextpath )) { + $totalsize += filesize( $nextpath ); + $totalcount ++; + + $mtime = filemtime( $nextpath ); + if ($mtime > $maxmtime) { + $maxmtime = $mtime; + } + } + } + } + } + closedir( $handle ); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + $total['maxmtime'] = $maxmtime; + + return $total; + } + + $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; + $output .= file_get_contents( $baseCSSPath . 'ext-all-notheme.css' ); + //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); + + //Classic Skin + $extJsSkin = 'xtheme-gray'; + + break; + default: + + break; + + } + + //Get Browser Info + $infoBrowser = g::browser_detection( 'full_assoc' ); + $browserName = $infoBrowser['browser_working']; + if (isset( $infoBrowser[$browserName . '_data'] )) { + if ($infoBrowser[$browserName . '_data'][0] != "") { + $browserName = $infoBrowser[$browserName . '_data'][0]; + } + } + + //Read Configuration File + $xmlConfiguration = file_get_contents ( $configurationFile ); + $xmlConfigurationObj = g::xmlParser($xmlConfiguration); + + $skinFilesArray=$xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['cssFiles']['__CONTENT__'][$skinVariant]['__CONTENT__']['cssFile'] ; + foreach ($skinFilesArray as $keyFile => $cssFileInfo) { + $enabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['enabledBrowsers']); + $disabledBrowsers=explode(",",$cssFileInfo['__ATTRIBUTES__']['disabledBrowsers']); + + if (((in_array($browserName, $enabledBrowsers))||(in_array('ALL', $enabledBrowsers)))&&(!(in_array($browserName, $disabledBrowsers)))) { + if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') { + g::LoadClass('serverConfiguration'); + $oServerConf =& serverConf::getSingleton(); + if (!(defined('SYS_LANG'))) { + if (isset($_SERVER['HTTP_REFERER'])) { + $syss = explode('://', $_SERVER['HTTP_REFERER']); + $sysObjets = explode('/', $syss['1']); + $sysLang = $sysObjets['2']; + } else { + $sysLang = 'en'; + } + } else { + $sysLang = SYS_LANG; + } + if ($oServerConf->isRtl($sysLang)) { + $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + } + } else { + $output .= file_get_contents ( $baseSkinDirectory . PATH_SEP.'css'.PATH_SEP.$cssFileInfo['__ATTRIBUTES__']['file'] ); + } + } + } + + //Remove comments.. + $regex = array ("`^([\t\s]+)`ism" => '',"`^\/\*(.+?)\*\/`ism" => "","`([\n\A;]+)\/\*(.+?)\*\/`ism" => "$1","`([\n\A;\s]+)//(.+?)[\n\r]`ism" => "$1\n","`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism" => "\n" ); + $output = preg_replace( array_keys( $regex ), $regex, $output ); + $output = $outputHeader . $output; + + return $output; } - } - } - - //Remove comments.. - $regex = array ("`^([\t\s]+)`ism" => '',"`^\/\*(.+?)\*\/`ism" => "","`([\n\A;]+)\/\*(.+?)\*\/`ism" => "$1","`([\n\A;\s]+)//(.+?)[\n\r]`ism" => "$1\n","`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism" => "\n" ); - $output = preg_replace( array_keys( $regex ), $regex, $output ); - $output = $outputHeader . $output; - - return $output; - } - + /** - * sendHeaders - * - * @param string $filename - * @param string $contentType - * default value '' - * @param boolean $download - * default value false - * @param string $downloadFileName - * default value '' - * - * @return void - */ + * sendHeaders + * + * @param string $filename + * @param string $contentType + * default value '' + * @param boolean $download + * default value false + * @param string $downloadFileName + * default value '' + * + * @return void + */ public function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '') { - if ($download) { - if ($downloadFileName == '') { - $aAux = explode ( '/', $filename ); - $downloadFileName = $aAux [count ( $aAux ) - 1]; - } - header ( 'Content-Disposition: attachment; filename="' . $downloadFileName . '"' ); - } - header ( 'Content-Type: ' . $contentType ); - - // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE - // behaivor. - $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); - if (preg_match ( "/msie/i", $userAgent )) { + if ($download) { + if ($downloadFileName == '') { + $aAux = explode ( '/', $filename ); + $downloadFileName = $aAux [count ( $aAux ) - 1]; + } + header ( 'Content-Disposition: attachment; filename="' . $downloadFileName . '"' ); + } + header ( 'Content-Type: ' . $contentType ); + + // if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE + // behaivor. + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + if (preg_match ( "/msie/i", $userAgent )) { // if ( ereg("msie", $userAgent)) { header ( 'Pragma: cache' ); - + $mtime = filemtime ( $filename ); - $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; - header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); - header ( "Last-Modified: " . $gmt_mtime ); - header ( 'Cache-Control: public' ); - header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 60 * 10 ) . " GMT" ); // ten - // minutes - return; + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + 60 * 10 ) . " GMT" ); // ten + // minutes + return; + } + + if (! $download) { + + header ( 'Pragma: cache' ); + + if (file_exists ( $filename )) { + $mtime = filemtime ( $filename ); + } else { + $mtime = date ( 'U' ); } - - if (! $download) { - - header ( 'Pragma: cache' ); - - if (file_exists ( $filename )) { - $mtime = filemtime ( $filename ); - } else { - $mtime = date ( 'U' ); - } - $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; - header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); - header ( "Last-Modified: " . $gmt_mtime ); - header ( 'Cache-Control: public' ); - 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' ); - exit (); - } - } - - if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { - if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { - header ( "HTTP/1.1 304 Not Modified" ); - exit (); + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $filename ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + 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' ); + exit (); + } + } + + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + exit (); + } + } + } } - } - } - } - + /** - * Get checksum from multiple files - * - * @author erik amaru ortiz - */ + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ public function getCheckSum ($files) { - g::LoadClass( 'system' ); - $key = System::getVersion(); - - if (! is_array( $files )) { - $tmp = $files; - $files = array (); - $files[0] = $tmp; + g::LoadClass( 'system' ); + $key = System::getVersion(); + + if (! is_array( $files )) { + $tmp = $files; + $files = array (); + $files[0] = $tmp; + } + + $checkSum = ''; + foreach ($files as $file) { + if (is_file( $file )) { + $checkSum .= md5_file( $file ); + } + } + return md5( $checkSum . $key ); } - - $checkSum = ''; - foreach ($files as $file) { - if (is_file( $file )) { - $checkSum .= md5_file( $file ); - } - } - return md5( $checkSum . $key ); - } - + /** - * Get checksum from multiple files - * - * @author erik amaru ortiz - */ + * Get checksum from multiple files + * + * @author erik amaru ortiz + */ public function getCacheFileNameByPattern ($path, $pattern) { - if ($file = glob( $path . $pattern )) { - preg_match( '/[a-f0-9]{32}/', $file[0], $match ); - } else { - $file[0] = ''; + if ($file = glob( $path . $pattern )) { + preg_match( '/[a-f0-9]{32}/', $file[0], $match ); + } else { + $file[0] = ''; + } + return array ('filename' => $file[0],'checksum' => (isset( $match[0] ) ? $match[0] : '')); } - return array ('filename' => $file[0],'checksum' => (isset( $match[0] ) ? $match[0] : '')); - } - + /** - * trimSourceCodeFile - * - * @param string $filename - * - * @return string $output - */ + * trimSourceCodeFile + * + * @param string $filename + * + * @return string $output + */ public function trimSourceCodeFile ($filename) { - $handle = fopen( $filename, "r" ); - $lastChar = ''; - $firstChar = ''; - $content = ''; - $line = ''; - + $handle = fopen( $filename, "r" ); + $lastChar = ''; + $firstChar = ''; + $content = ''; + $line = ''; + if ($handle) { - while (! feof( $handle )) { - //$line = trim( fgets($handle, 16096) ) . "\n" ; - $line = fgets( $handle, 16096 ); - $content .= $line; + while (! feof( $handle )) { + //$line = trim( fgets($handle, 16096) ) . "\n" ; + $line = fgets( $handle, 16096 ); + $content .= $line; + } + fclose( $handle ); + } + return $content; + + $index = 0; + $output = ''; + while ($index < strlen( $content )) { + $car = $content[$index]; + $index ++; + if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { + $endComment = false; + $index ++; + while ($endComment == false && $index < strlen( $content )) { + if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { + $endComment = true; + $index ++; + } + $index ++; + } + $car = ''; + } + $output .= $car; + } + return $output; } - fclose( $handle ); - } - return $content; - - $index = 0; - $output = ''; - while ($index < strlen( $content )) { - $car = $content[$index]; - $index ++; - if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { - $endComment = false; - $index ++; - while ($endComment == false && $index < strlen( $content )) { - if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { - $endComment = true; - $index ++; - } - $index ++; - } - $car = ''; - } - $output .= $car; - } - return $output; - } - - + + /** - * strip_slashes - * @param vVar - */ + * strip_slashes + * @param vVar + */ public 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] ); + 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; } - } - } else { - $vVar = stripslashes( $vVar ); - } - - return $vVar; - } - - + + /** - * Function LoadTranslation - * - * @author Aldo Mauricio Veliz Valenzuela. - * @access public - * @param eter string msgID - * @param eter string file - * @param eter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label" - * @return string - */ + * Function LoadTranslation + * + * @author Aldo Mauricio Veliz Valenzuela. + * @access public + * @param eter string msgID + * @param eter string file + * @param eter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label" + * @return string + */ public function LoadTranslation ($msgID, $lang = SYS_LANG, $data = null) - { - global $translation; - - // if the second parameter $lang is an array does mean it was especified to use as data - if (is_array( $lang )) { - $data = $lang; - $lang = SYS_LANG; - } - - if (isset( $translation[$msgID] )) { - $translationString = preg_replace( "[\n|\r|\n\r]", ' ', $translation[$msgID] ); - - if (isset( $data ) && is_array( $data )) { - foreach ($data as $label => $value) { - $translationString = str_replace( '{' . $label . '}', $value, $translationString ); - } - } - - return $translationString; - } else { - if (defined( "UNTRANSLATED_MARK" )) { - $untranslatedMark = strip_tags( UNTRANSLATED_MARK ); - } else { - $untranslatedMark = "**"; - } - return $untranslatedMark . $msgID . $untranslatedMark; - } - - } - - /** - * Recursive version of glob php standard function - * - * @author Erik Amaru Ortiz - * - * @param $path path to scan recursively the write permission - * @param $flags to notive glob function - * @param $pattern pattern to filter some especified files - * @return array containing the recursive glob results - */ - public function rglob($pattern = '*', $flags = 0, $path = '') - { - $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); - $files = glob($path.$pattern, $flags); - foreach ($paths as $path) { - $files = array_merge($files, g::rglob($pattern, $flags, $path)); - } - return $files; - } - - /** - * JSON encode - * - * @author Erik A.O. - */ - public function json_encode($Json) - { - if ( function_exists('json_encode') ) { - return json_encode($Json); - } else { - g::LoadThirdParty('pear/json', 'class.json'); - $oJSON = new Services_JSON(); - return $oJSON->encode($Json); - } - } - - /** - * JSON decode - * - * @author Erik A.O. - */ - public function json_decode($Json) - { - if (function_exists('json_decode')) { - return json_decode($Json); - } else { - g::LoadThirdParty('pear/json', 'class.json'); - $oJSON = new Services_JSON(); - return $oJSON->decode($Json); + { + global $translation; + + // if the second parameter $lang is an array does mean it was especified to use as data + if (is_array( $lang )) { + $data = $lang; + $lang = SYS_LANG; + } + + if (isset( $translation[$msgID] )) { + $translationString = preg_replace( "[\n|\r|\n\r]", ' ', $translation[$msgID] ); + + if (isset( $data ) && is_array( $data )) { + foreach ($data as $label => $value) { + $translationString = str_replace( '{' . $label . '}', $value, $translationString ); + } + } + + return $translationString; + } else { + if (defined( "UNTRANSLATED_MARK" )) { + $untranslatedMark = strip_tags( UNTRANSLATED_MARK ); + } else { + $untranslatedMark = "**"; + } + return $untranslatedMark . $msgID . $untranslatedMark; + } + } - } - - + /** - * ************************************* init ********************************************** - * Xml parse collection functions - * Returns a associative array within the xml structure and data - * - * @author Erik Amaru Ortiz - */ + * Recursive version of glob php standard function + * + * @author Erik Amaru Ortiz + * + * @param $path path to scan recursively the write permission + * @param $flags to notive glob function + * @param $pattern pattern to filter some especified files + * @return array containing the recursive glob results + */ + public function rglob($pattern = '*', $flags = 0, $path = '') + { + $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); + $files = glob($path.$pattern, $flags); + foreach ($paths as $path) { + $files = array_merge($files, g::rglob($pattern, $flags, $path)); + } + return $files; + } + + /** + * JSON encode + * + * @author Erik A.O. + */ + public function json_encode($Json) + { + if ( function_exists('json_encode') ) { + return json_encode($Json); + } else { + g::LoadThirdParty('pear/json', 'class.json'); + $oJSON = new Services_JSON(); + return $oJSON->encode($Json); + } + } + + /** + * JSON decode + * + * @author Erik A.O. + */ + public function json_decode($Json) + { + if (function_exists('json_decode')) { + return json_decode($Json); + } else { + g::LoadThirdParty('pear/json', 'class.json'); + $oJSON = new Services_JSON(); + return $oJSON->decode($Json); + } + } + + + /** + * ************************************* init ********************************************** + * Xml parse collection functions + * Returns a associative array within the xml structure and data + * + * @author Erik Amaru Ortiz + */ public function xmlParser (&$string) { - $parser = xml_parser_create(); - xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); - xml_parse_into_struct( $parser, $string, $vals, $index ); - - $mnary = array (); - $ary = &$mnary; - foreach ($vals as $r) { - $t = $r['tag']; - if ($r['type'] == 'open') { - if (isset( $ary[$t] )) { - if (isset( $ary[$t][0] )) { - $ary[$t][] = array (); - } else { - $ary[$t] = array ($ary[$t],array () ); - } - $cv = &$ary[$t][count( $ary[$t] ) - 1]; - } else { - $cv = &$ary[$t]; + $parser = xml_parser_create(); + xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); + xml_parse_into_struct( $parser, $string, $vals, $index ); + + $mnary = array (); + $ary = &$mnary; + foreach ($vals as $r) { + $t = $r['tag']; + if ($r['type'] == 'open') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) { + $ary[$t][] = array (); + } else { + $ary[$t] = array ($ary[$t],array () ); + } + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else { + $cv = &$ary[$t]; + } + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) { + $cv['__ATTRIBUTES__'][$k] = $v; + } + } + // note by gustavo cruz gustavo[at]colosa[dot]com + // minor adjustments to validate if an open node have a value attribute. + // for example a dropdown has many childs, but also can have a value attribute. + if (isset( $r['value'] ) && trim( $r['value'] ) != '') { + $cv['__VALUE__'] = $r['value']; + } + // end added code + $cv['__CONTENT__'] = array (); + $cv['__CONTENT__']['_p'] = &$ary; + $ary = &$cv['__CONTENT__']; + + } elseif ($r['type'] == 'complete') { + if (isset( $ary[$t] )) { + if (isset( $ary[$t][0] )) { + $ary[$t][] = array (); + } else { + $ary[$t] = array ($ary[$t],array ()); + } + $cv = &$ary[$t][count( $ary[$t] ) - 1]; + } else { + $cv = &$ary[$t]; + } + if (isset( $r['attributes'] )) { + foreach ($r['attributes'] as $k => $v) { + $cv['__ATTRIBUTES__'][$k] = $v; + } + } + $cv['__VALUE__'] = (isset( $r['value'] ) ? $r['value'] : ''); + + } elseif ($r['type'] == 'close') { + $ary = &$ary['_p']; + } } - if (isset( $r['attributes'] )) { - foreach ($r['attributes'] as $k => $v) { - $cv['__ATTRIBUTES__'][$k] = $v; + + self::_del_p( $mnary ); + + $obj_resp->code = xml_get_error_code( $parser ); + $obj_resp->message = xml_error_string( $obj_resp->code ); + $obj_resp->result = $mnary; + xml_parser_free( $parser ); + + return $obj_resp; } - } - // note by gustavo cruz gustavo[at]colosa[dot]com - // minor adjustments to validate if an open node have a value attribute. - // for example a dropdown has many childs, but also can have a value attribute. - if (isset( $r['value'] ) && trim( $r['value'] ) != '') { - $cv['__VALUE__'] = $r['value']; - } - // end added code - $cv['__CONTENT__'] = array (); - $cv['__CONTENT__']['_p'] = &$ary; - $ary = &$cv['__CONTENT__']; - - } elseif ($r['type'] == 'complete') { - if (isset( $ary[$t] )) { - if (isset( $ary[$t][0] )) { - $ary[$t][] = array (); - } else { - $ary[$t] = array ($ary[$t],array ()); - } - $cv = &$ary[$t][count( $ary[$t] ) - 1]; - } else { - $cv = &$ary[$t]; - } - if (isset( $r['attributes'] )) { - foreach ($r['attributes'] as $k => $v) { - $cv['__ATTRIBUTES__'][$k] = $v; - } - } - $cv['__VALUE__'] = (isset( $r['value'] ) ? $r['value'] : ''); - - } elseif ($r['type'] == 'close') { - $ary = &$ary['_p']; - } - } - - self::_del_p( $mnary ); - - $obj_resp->code = xml_get_error_code( $parser ); - $obj_resp->message = xml_error_string( $obj_resp->code ); - $obj_resp->result = $mnary; - xml_parser_free( $parser ); - - return $obj_resp; - } - - /** + + /** * * @param unknown_type $path * @param unknown_type $maxmtime * @return Ambigous */ - public function getDirectorySize ($path, $maxmtime = 0) - { + public function getDirectorySize ($path, $maxmtime = 0) + { $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir( $path )) { while (false !== ($file = readdir( $handle ))) { - $nextpath = $path . '/' . $file; - if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { - if (is_dir( $nextpath )) { - $dircount ++; - $result = g::getDirectorySize( $nextpath, $maxmtime ); - $totalsize += $result['size']; - $totalcount += $result['count']; - $dircount += $result['dircount']; - $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; - } elseif (is_file( $nextpath )) { - $totalsize += filesize( $nextpath ); - $totalcount ++; - - $mtime = filemtime( $nextpath ); - if ($mtime > $maxmtime) { - $maxmtime = $mtime; + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { + if (is_dir( $nextpath )) { + $dircount ++; + $result = g::getDirectorySize( $nextpath, $maxmtime ); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; + } elseif (is_file( $nextpath )) { + $totalsize += filesize( $nextpath ); + $totalcount ++; + + $mtime = filemtime( $nextpath ); + if ($mtime > $maxmtime) { + $maxmtime = $mtime; + } + } + } + } + } + closedir( $handle ); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + $total['maxmtime'] = $maxmtime; + + return $total; } - } - } - } - } - closedir( $handle ); - $total['size'] = $totalsize; - $total['count'] = $totalcount; - $total['dircount'] = $dircount; - $total['maxmtime'] = $maxmtime; - - return $total; - } - - + + /** - * _del_p - * - * @param string &$ary - * - * @return void - */ + * _del_p + * + * @param string &$ary + * + * @return void + */ // _Internal: Remove recursion in result array public function _del_p (&$ary) { - foreach ($ary as $k => $v) { - if ($k === '_p') { - unset( $ary[$k] ); - } elseif (is_array( $ary[$k] )) { - self::_del_p( $ary[$k] ); + foreach ($ary as $k => $v) { + if ($k === '_p') { + unset( $ary[$k] ); + } elseif (is_array( $ary[$k] )) { + self::_del_p( $ary[$k] ); + } + } } - } - } - + /** - * - * @param unknown_type $which_test - * @param unknown_type $test_excludes - * @param unknown_type $external_ua_string - * @return multitype:unknown string boolean number multitype:string unknown multitype:string Ambigous unknown multitype:string Ambigous |Ambigous unknown , multitype:string , Ambigous > - */ + * + * @param unknown_type $which_test + * @param unknown_type $test_excludes + * @param unknown_type $external_ua_string + * @return multitype:unknown string boolean number multitype:string unknown multitype:string Ambigous unknown multitype:string Ambigous |Ambigous unknown , multitype:string , Ambigous > + */ public function browser_detection($which_test, $test_excludes = '', $external_ua_string = '') { - g::script_time(); // set script timer to start timing - - static $a_full_assoc_data, $a_mobile_data, $a_moz_data, $a_webkit_data, $b_dom_browser, $b_repeat, $b_safe_browser, $browser_name, $browser_number, $browser_math_number, $browser_user_agent, $browser_working, $ie_version, $mobile_test, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date, $moz_type, $os_number, $os_type, $true_ie_number, $ua_type, $webkit_type, $webkit_type_number; - - // switch off the optimization for external ua string testing. - if ( $external_ua_string ) { - $b_repeat = false; - } - - /* - this makes the test only run once no matter how many times you call it since - all the variables are filled on the first run through, it's only a matter of - returning the the right ones - */ - if ( !$b_repeat ) { - //initialize all variables with default values to prevent error - $a_browser_math_number = ''; - $a_full_assoc_data = ''; - $a_full_data = ''; - $a_mobile_data = ''; - $a_moz_data = ''; - $a_os_data = ''; - $a_unhandled_browser = ''; - $a_webkit_data = ''; - $b_dom_browser = false; - $b_os_test = true; - $b_mobile_test = true; - $b_safe_browser = false; - $b_success = false;// boolean for if browser found in main test - $browser_math_number = ''; - $browser_temp = ''; - $browser_working = ''; - $browser_number = ''; - $ie_version = ''; - $mobile_test = ''; - $moz_release_date = ''; - $moz_rv = ''; - $moz_rv_full = ''; - $moz_type = ''; - $moz_number = ''; - $os_number = ''; - $os_type = ''; - $run_time = ''; - $true_ie_number = ''; + g::script_time(); // set script timer to start timing + + static $a_full_assoc_data, $a_mobile_data, $a_moz_data, $a_webkit_data, $b_dom_browser, $b_repeat, $b_safe_browser, $browser_name, $browser_number, $browser_math_number, $browser_user_agent, $browser_working, $ie_version, $mobile_test, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date, $moz_type, $os_number, $os_type, $true_ie_number, $ua_type, $webkit_type, $webkit_type_number; + + // switch off the optimization for external ua string testing. + if ( $external_ua_string ) { + $b_repeat = false; + } + + /* + this makes the test only run once no matter how many times you call it since + all the variables are filled on the first run through, it's only a matter of + returning the the right ones + */ + if ( !$b_repeat ) { + //initialize all variables with default values to prevent error + $a_browser_math_number = ''; + $a_full_assoc_data = ''; + $a_full_data = ''; + $a_mobile_data = ''; + $a_moz_data = ''; + $a_os_data = ''; + $a_unhandled_browser = ''; + $a_webkit_data = ''; + $b_dom_browser = false; + $b_os_test = true; + $b_mobile_test = true; + $b_safe_browser = false; + $b_success = false;// boolean for if browser found in main test + $browser_math_number = ''; + $browser_temp = ''; + $browser_working = ''; + $browser_number = ''; + $ie_version = ''; + $mobile_test = ''; + $moz_release_date = ''; + $moz_rv = ''; + $moz_rv_full = ''; + $moz_type = ''; + $moz_number = ''; + $os_number = ''; + $os_type = ''; + $run_time = ''; + $true_ie_number = ''; $ua_type = 'bot';// default to bot since you never know with bots $webkit_type = ''; $webkit_type_number = ''; - + // set the excludes if required if ( $test_excludes ) { - switch ( $test_excludes ){ - case '1': - $b_os_test = false; - break; - case '2': - $b_mobile_test = false; - break; - case '3': - $b_os_test = false; - $b_mobile_test = false; - break; - default: - die( 'Error: bad $test_excludes parameter 2 used: ' . $test_excludes ); - break; - } - } - - /* - make navigator user agent string lower case to make sure all versions get caught - isset protects against blank user agent failure. tolower also lets the script use - strstr instead of stristr, which drops overhead slightly. - */ - if ( $external_ua_string ) { - $browser_user_agent = strtolower( $external_ua_string ); - } elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { - $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); - } else { - $browser_user_agent = ''; - } - - // known browsers, list will be updated routinely, check back now and then - $a_browser_types = array( - array( 'opera', true, 'op', 'bro' ), - array( 'msie', true, 'ie', 'bro' ), - // webkit before gecko because some webkit ua strings say: like gecko - array( 'webkit', true, 'webkit', 'bro' ), - // konq will be using webkit soon - array( 'konqueror', true, 'konq', 'bro' ), - // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below - array( 'gecko', true, 'moz', 'bro' ), - array( 'netpositive', false, 'netp', 'bbro' ),// beos browser - array( 'lynx', false, 'lynx', 'bbro' ), // command line browser - array( 'elinks ', false, 'elinks', 'bbro' ), // new version of links - array( 'elinks', false, 'elinks', 'bbro' ), // alternate id for it - array( 'links2', false, 'links2', 'bbro' ), // alternate links version - array( 'links ', false, 'links', 'bbro' ), // old name for links - array( 'links', false, 'links', 'bbro' ), // alternate id for it - array( 'w3m', false, 'w3m', 'bbro' ), // open source browser, more features than lynx/links - array( 'webtv', false, 'webtv', 'bbro' ),// junk ms webtv - array( 'amaya', false, 'amaya', 'bbro' ),// w3c browser - array( 'dillo', false, 'dillo', 'bbro' ),// linux browser, basic table support - array( 'ibrowse', false, 'ibrowse', 'bbro' ),// amiga browser - array( 'icab', false, 'icab', 'bro' ),// mac browser - array( 'crazy browser', true, 'ie', 'bro' ),// uses ie rendering engine - - // search engine spider bots: - array( 'bingbot', false, 'bing', 'bot' ),// bing - array( 'exabot', false, 'exabot', 'bot' ),// exabot - array( 'googlebot', false, 'google', 'bot' ),// google - array( 'google web preview', false, 'googlewp', 'bot' ),// google preview - array( 'mediapartners-google', false, 'adsense', 'bot' ),// google adsense - array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),// old yahoo bot - array( 'yahoo! slurp', false, 'yahoo', 'bot' ), // new yahoo bot - array( 'yahoo-mm', false, 'yahoomm', 'bot' ), // gets Yahoo-MMCrawler and Yahoo-MMAudVid bots - array( 'inktomi', false, 'inktomi', 'bot' ), // inktomi bot - array( 'slurp', false, 'inktomi', 'bot' ), // inktomi bot - array( 'fast-webcrawler', false, 'fast', 'bot' ),// Fast AllTheWeb - array( 'msnbot', false, 'msn', 'bot' ),// msn search - array( 'ask jeeves', false, 'ask', 'bot' ), //jeeves/teoma - array( 'teoma', false, 'ask', 'bot' ),//jeeves teoma - array( 'scooter', false, 'scooter', 'bot' ),// altavista - array( 'openbot', false, 'openbot', 'bot' ),// openbot, from taiwan - array( 'ia_archiver', false, 'ia_archiver', 'bot' ),// ia archiver - array( 'zyborg', false, 'looksmart', 'bot' ),// looksmart - array( 'almaden', false, 'ibm', 'bot' ),// ibm almaden web crawler - array( 'baiduspider', false, 'baidu', 'bot' ),// Baiduspider asian search spider - array( 'psbot', false, 'psbot', 'bot' ),// psbot image crawler - array( 'gigabot', false, 'gigabot', 'bot' ),// gigabot crawler - array( 'naverbot', false, 'naverbot', 'bot' ),// naverbot crawler, bad bot, block - array( 'surveybot', false, 'surveybot', 'bot' ),// - array( 'boitho.com-dc', false, 'boitho', 'bot' ),//norwegian search engine - array( 'objectssearch', false, 'objectsearch', 'bot' ),// open source search engine - array( 'answerbus', false, 'answerbus', 'bot' ),// http://www.answerbus.com/, web questions - array( 'sohu-search', false, 'sohu', 'bot' ),// chinese media company, search component - array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ), - - // various http utility libaries - array( 'w3c_validator', false, 'w3c', 'lib' ), // uses libperl, make first - array( 'wdg_validator', false, 'wdg', 'lib' ), // - array( 'libwww-perl', false, 'libwww-perl', 'lib' ), - array( 'jakarta commons-httpclient', false, 'jakarta', 'lib' ), - array( 'python-urllib', false, 'python-urllib', 'lib' ), - // download apps - array( 'getright', false, 'getright', 'dow' ), - array( 'wget', false, 'wget', 'dow' ),// open source downloader, obeys robots.txt - // netscape 4 and earlier tests, put last so spiders don't get caught - array( 'mozilla/4.', false, 'ns', 'bbro' ), - array( 'mozilla/3.', false, 'ns', 'bbro' ), - array( 'mozilla/2.', false, 'ns', 'bbro' ) - ); - - //array( '', false ); // browser array template - + switch ( $test_excludes ){ + case '1': + $b_os_test = false; + break; + case '2': + $b_mobile_test = false; + break; + case '3': + $b_os_test = false; + $b_mobile_test = false; + break; + default: + die( 'Error: bad $test_excludes parameter 2 used: ' . $test_excludes ); + break; + } + } + /* - moz types array + make navigator user agent string lower case to make sure all versions get caught + isset protects against blank user agent failure. tolower also lets the script use + strstr instead of stristr, which drops overhead slightly. + */ + if ( $external_ua_string ) { + $browser_user_agent = strtolower( $external_ua_string ); + } elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { + $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); + } else { + $browser_user_agent = ''; + } + + // known browsers, list will be updated routinely, check back now and then + $a_browser_types = array( + array( 'opera', true, 'op', 'bro' ), + array( 'msie', true, 'ie', 'bro' ), + // webkit before gecko because some webkit ua strings say: like gecko + array( 'webkit', true, 'webkit', 'bro' ), + // konq will be using webkit soon + array( 'konqueror', true, 'konq', 'bro' ), + // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below + array( 'gecko', true, 'moz', 'bro' ), + array( 'netpositive', false, 'netp', 'bbro' ),// beos browser + array( 'lynx', false, 'lynx', 'bbro' ), // command line browser + array( 'elinks ', false, 'elinks', 'bbro' ), // new version of links + array( 'elinks', false, 'elinks', 'bbro' ), // alternate id for it + array( 'links2', false, 'links2', 'bbro' ), // alternate links version + array( 'links ', false, 'links', 'bbro' ), // old name for links + array( 'links', false, 'links', 'bbro' ), // alternate id for it + array( 'w3m', false, 'w3m', 'bbro' ), // open source browser, more features than lynx/links + array( 'webtv', false, 'webtv', 'bbro' ),// junk ms webtv + array( 'amaya', false, 'amaya', 'bbro' ),// w3c browser + array( 'dillo', false, 'dillo', 'bbro' ),// linux browser, basic table support + array( 'ibrowse', false, 'ibrowse', 'bbro' ),// amiga browser + array( 'icab', false, 'icab', 'bro' ),// mac browser + array( 'crazy browser', true, 'ie', 'bro' ),// uses ie rendering engine + + // search engine spider bots: + array( 'bingbot', false, 'bing', 'bot' ),// bing + array( 'exabot', false, 'exabot', 'bot' ),// exabot + array( 'googlebot', false, 'google', 'bot' ),// google + array( 'google web preview', false, 'googlewp', 'bot' ),// google preview + array( 'mediapartners-google', false, 'adsense', 'bot' ),// google adsense + array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),// old yahoo bot + array( 'yahoo! slurp', false, 'yahoo', 'bot' ), // new yahoo bot + array( 'yahoo-mm', false, 'yahoomm', 'bot' ), // gets Yahoo-MMCrawler and Yahoo-MMAudVid bots + array( 'inktomi', false, 'inktomi', 'bot' ), // inktomi bot + array( 'slurp', false, 'inktomi', 'bot' ), // inktomi bot + array( 'fast-webcrawler', false, 'fast', 'bot' ),// Fast AllTheWeb + array( 'msnbot', false, 'msn', 'bot' ),// msn search + array( 'ask jeeves', false, 'ask', 'bot' ), //jeeves/teoma + array( 'teoma', false, 'ask', 'bot' ),//jeeves teoma + array( 'scooter', false, 'scooter', 'bot' ),// altavista + array( 'openbot', false, 'openbot', 'bot' ),// openbot, from taiwan + array( 'ia_archiver', false, 'ia_archiver', 'bot' ),// ia archiver + array( 'zyborg', false, 'looksmart', 'bot' ),// looksmart + array( 'almaden', false, 'ibm', 'bot' ),// ibm almaden web crawler + array( 'baiduspider', false, 'baidu', 'bot' ),// Baiduspider asian search spider + array( 'psbot', false, 'psbot', 'bot' ),// psbot image crawler + array( 'gigabot', false, 'gigabot', 'bot' ),// gigabot crawler + array( 'naverbot', false, 'naverbot', 'bot' ),// naverbot crawler, bad bot, block + array( 'surveybot', false, 'surveybot', 'bot' ),// + array( 'boitho.com-dc', false, 'boitho', 'bot' ),//norwegian search engine + array( 'objectssearch', false, 'objectsearch', 'bot' ),// open source search engine + array( 'answerbus', false, 'answerbus', 'bot' ),// http://www.answerbus.com/, web questions + array( 'sohu-search', false, 'sohu', 'bot' ),// chinese media company, search component + array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ), + + // various http utility libaries + array( 'w3c_validator', false, 'w3c', 'lib' ), // uses libperl, make first + array( 'wdg_validator', false, 'wdg', 'lib' ), // + array( 'libwww-perl', false, 'libwww-perl', 'lib' ), + array( 'jakarta commons-httpclient', false, 'jakarta', 'lib' ), + array( 'python-urllib', false, 'python-urllib', 'lib' ), + // download apps + array( 'getright', false, 'getright', 'dow' ), + array( 'wget', false, 'wget', 'dow' ),// open source downloader, obeys robots.txt + // netscape 4 and earlier tests, put last so spiders don't get caught + array( 'mozilla/4.', false, 'ns', 'bbro' ), + array( 'mozilla/3.', false, 'ns', 'bbro' ), + array( 'mozilla/2.', false, 'ns', 'bbro' ) + ); + + //array( '', false ); // browser array template + + /* + moz types array note the order, netscape6 must come before netscape, which is how netscape 7 id's itself. rv comes last in case it is plain old mozilla. firefox/netscape/seamonkey need to be later Thanks to: http://www.zytrax.com/tech/web/firefox-history.html */ $a_moz_types = array( 'bonecho', 'camino', 'epiphany', 'firebird', 'flock', 'galeon', 'iceape', 'icecat', 'k-meleon', 'minimo', 'multizilla', 'phoenix', 'songbird', 'swiftfox', 'seamonkey', 'shiretoko', 'iceweasel', 'firefox', 'minefield', 'netscape6', 'netscape', 'rv' ); - + /* - webkit types, this is going to expand over time as webkit browsers spread + webkit types, this is going to expand over time as webkit browsers spread konqueror is probably going to move to webkit, so this is preparing for that It will now default to khtml. gtklauncher is the temp id for epiphany, might change. Defaults to applewebkit, and will all show the webkit number. */ $a_webkit_types = array( 'arora', 'chrome', 'epiphany', 'gtklauncher', 'konqueror', 'midori', 'omniweb', 'safari', 'uzbl', 'applewebkit', 'webkit' ); - + /* - run through the browser_types array, break if you hit a match, if no match, assume old browser + run through the browser_types array, break if you hit a match, if no match, assume old browser or non dom browser, assigns false value to $b_success. */ $i_count = count( $a_browser_types ); for ($i = 0; $i < $i_count; $i++) { - //unpacks browser array, assigns to variables, need to not assign til found in string - $browser_temp = $a_browser_types[$i][0];// text string to id browser from array - - if ( strstr( $browser_user_agent, $browser_temp ) ) { - /* - it defaults to true, will become false below if needed - this keeps it easier to keep track of what is safe, only - explicit false assignment will make it false. - */ - $b_safe_browser = true; - $browser_name = $browser_temp;// text string to id browser from array - - // assign values based on match of user agent string - $b_dom_browser = $a_browser_types[$i][1];// hardcoded dom support from array - $browser_working = $a_browser_types[$i][2];// working name for browser - $ua_type = $a_browser_types[$i][3];// sets whether bot or browser - - switch ( $browser_working ) { - // this is modified quite a bit, now will return proper netscape version number - // check your implementation to make sure it works - case 'ns': - $b_safe_browser = false; - $browser_number = g::get_item_version( $browser_user_agent, 'mozilla' ); - break; - case 'moz': - /* - note: The 'rv' test is not absolute since the rv number is very different on - different versions, for example Galean doesn't use the same rv version as Mozilla, - neither do later Netscapes, like 7.x. For more on this, read the full mozilla - numbering conventions here: http://www.mozilla.org/releases/cvstags.html - */ - // this will return alpha and beta version numbers, if present - $moz_rv_full = g::get_item_version( $browser_user_agent, 'rv' ); - // this slices them back off for math comparisons - $moz_rv = substr( $moz_rv_full, 0, 3 ); - - // this is to pull out specific mozilla versions, firebird, netscape etc.. - $j_count = count( $a_moz_types ); - for ($j = 0; $j < $j_count; $j++) { - if ( strstr( $browser_user_agent, $a_moz_types[$j] ) ) { - $moz_type = $a_moz_types[$j]; - $moz_number = g::get_item_version( $browser_user_agent, $moz_type ); - break; + //unpacks browser array, assigns to variables, need to not assign til found in string + $browser_temp = $a_browser_types[$i][0];// text string to id browser from array + + if ( strstr( $browser_user_agent, $browser_temp ) ) { + /* + it defaults to true, will become false below if needed + this keeps it easier to keep track of what is safe, only + explicit false assignment will make it false. + */ + $b_safe_browser = true; + $browser_name = $browser_temp;// text string to id browser from array + + // assign values based on match of user agent string + $b_dom_browser = $a_browser_types[$i][1];// hardcoded dom support from array + $browser_working = $a_browser_types[$i][2];// working name for browser + $ua_type = $a_browser_types[$i][3];// sets whether bot or browser + + switch ( $browser_working ) { + // this is modified quite a bit, now will return proper netscape version number + // check your implementation to make sure it works + case 'ns': + $b_safe_browser = false; + $browser_number = g::get_item_version( $browser_user_agent, 'mozilla' ); + break; + case 'moz': + /* + note: The 'rv' test is not absolute since the rv number is very different on + different versions, for example Galean doesn't use the same rv version as Mozilla, + neither do later Netscapes, like 7.x. For more on this, read the full mozilla + numbering conventions here: http://www.mozilla.org/releases/cvstags.html + */ + // this will return alpha and beta version numbers, if present + $moz_rv_full = g::get_item_version( $browser_user_agent, 'rv' ); + // this slices them back off for math comparisons + $moz_rv = substr( $moz_rv_full, 0, 3 ); + + // this is to pull out specific mozilla versions, firebird, netscape etc.. + $j_count = count( $a_moz_types ); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $browser_user_agent, $a_moz_types[$j] ) ) { + $moz_type = $a_moz_types[$j]; + $moz_number = g::get_item_version( $browser_user_agent, $moz_type ); + break; + } + } + /* + this is necesary to protect against false id'ed moz'es and new moz'es. + this corrects for galeon, or any other moz browser without an rv number + */ + if ( !$moz_rv ) { + // you can use this if you are running php >= 4.2 + if ( function_exists( 'floatval' ) ) { + $moz_rv = floatval( $moz_number ); + } else { + $moz_rv = substr( $moz_number, 0, 3 ); + } + $moz_rv_full = $moz_number; + } + // this corrects the version name in case it went to the default 'rv' for the test + if ( $moz_type == 'rv' ) { + $moz_type = 'mozilla'; + } + + //the moz version will be taken from the rv number, see notes above for rv problems + $browser_number = $moz_rv; + // gets the actual release date, necessary if you need to do functionality tests + g::get_set_count( 'set', 0 ); + $moz_release_date = g::get_item_version( $browser_user_agent, 'gecko/' ); + /* + Test for mozilla 0.9.x / netscape 6.x + test your javascript/CSS to see if it works in these mozilla releases, if it + does, just default it to: $b_safe_browser = true; + */ + if ( ( $moz_release_date < 20020400 ) || ( $moz_rv < 1 ) ) { + $b_safe_browser = false; + } + break; + case 'ie': + /* + note we're adding in the trident/ search to return only first instance in case + of msie 8, and we're triggering the break last condition in the test, as well + as the test for a second search string, trident/ + */ + $browser_number = g::get_item_version( $browser_user_agent, $browser_name, true, 'trident/' ); + // construct the proper real number if it's in compat mode and msie 8.0/9.0 + if ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/5' ) ) { + // note that 7.0 becomes 9 when adding 1, but if it's 7.1 it will be 9.1 + $true_ie_number = $browser_number + 2; + } elseif ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/4' ) ) { + // note that 7.0 becomes 8 when adding 1, but if it's 7.1 it will be 8.1 + $true_ie_number = $browser_number + 1; + } + // the 9 series is finally standards compatible, html 5 etc, so worth a new id + if ( $browser_number >= 9 ) { + $ie_version = 'ie9x'; + } elseif ( $browser_number >= 7 ) { + $ie_version = 'ie7x'; + } elseif ( strstr( $browser_user_agent, 'mac') ) { + $ie_version = 'ieMac'; + } elseif ( $browser_number >= 5 ) { + $ie_version = 'ie5x'; + } elseif ( ( $browser_number > 3 ) && ( $browser_number < 5 ) ) { + $b_dom_browser = false; + $ie_version = 'ie4'; + // this depends on what you're using the script for, make sure this fits your needs + $b_safe_browser = true; + } else { + $ie_version = 'old'; + $b_dom_browser = false; + $b_safe_browser = false; + } + break; + case 'op': + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + // opera is leaving version at 9.80 (or xx) for 10.x - see this for explanation + // http://dev.opera.com/articles/view/opera-ua-string-changes/ + if ( strstr( $browser_number, '9.' ) && strstr( $browser_user_agent, 'version/' ) ) { + g::get_set_count( 'set', 0 ); + $browser_number = g::get_item_version( $browser_user_agent, 'version/' ); + } + + if ( $browser_number < 5 ) { + $b_safe_browser = false; + } + break; + case 'webkit': + // note that this is the Webkit version number + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + // this is to pull out specific webkit versions, safari, google-chrome etc.. + $j_count = count( $a_webkit_types ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $browser_user_agent, $a_webkit_types[$j])) { + $webkit_type = $a_webkit_types[$j]; + if ( $webkit_type == 'omniweb' ) { + g::get_set_count( 'set', 2 ); + } + $webkit_type_number = g::get_item_version( $browser_user_agent, $webkit_type ); + // epiphany hack + if ( $a_webkit_types[$j] == 'gtklauncher' ) { + $browser_name = 'epiphany'; + } else { + $browser_name = $a_webkit_types[$j]; + } + break; + } + } + break; + default: + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + break; + } + // the browser was id'ed + $b_success = true; + break; + } } - } - /* - this is necesary to protect against false id'ed moz'es and new moz'es. - this corrects for galeon, or any other moz browser without an rv number - */ - if ( !$moz_rv ) { - // you can use this if you are running php >= 4.2 - if ( function_exists( 'floatval' ) ) { - $moz_rv = floatval( $moz_number ); - } else { - $moz_rv = substr( $moz_number, 0, 3 ); - } - $moz_rv_full = $moz_number; - } - // this corrects the version name in case it went to the default 'rv' for the test - if ( $moz_type == 'rv' ) { - $moz_type = 'mozilla'; - } - - //the moz version will be taken from the rv number, see notes above for rv problems - $browser_number = $moz_rv; - // gets the actual release date, necessary if you need to do functionality tests - g::get_set_count( 'set', 0 ); - $moz_release_date = g::get_item_version( $browser_user_agent, 'gecko/' ); - /* - Test for mozilla 0.9.x / netscape 6.x - test your javascript/CSS to see if it works in these mozilla releases, if it - does, just default it to: $b_safe_browser = true; - */ - if ( ( $moz_release_date < 20020400 ) || ( $moz_rv < 1 ) ) { - $b_safe_browser = false; - } - break; - case 'ie': - /* - note we're adding in the trident/ search to return only first instance in case - of msie 8, and we're triggering the break last condition in the test, as well - as the test for a second search string, trident/ - */ - $browser_number = g::get_item_version( $browser_user_agent, $browser_name, true, 'trident/' ); - // construct the proper real number if it's in compat mode and msie 8.0/9.0 - if ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/5' ) ) { - // note that 7.0 becomes 9 when adding 1, but if it's 7.1 it will be 9.1 - $true_ie_number = $browser_number + 2; - } elseif ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/4' ) ) { - // note that 7.0 becomes 8 when adding 1, but if it's 7.1 it will be 8.1 - $true_ie_number = $browser_number + 1; - } - // the 9 series is finally standards compatible, html 5 etc, so worth a new id - if ( $browser_number >= 9 ) { - $ie_version = 'ie9x'; - } elseif ( $browser_number >= 7 ) { - $ie_version = 'ie7x'; - } elseif ( strstr( $browser_user_agent, 'mac') ) { - $ie_version = 'ieMac'; - } elseif ( $browser_number >= 5 ) { - $ie_version = 'ie5x'; - } elseif ( ( $browser_number > 3 ) && ( $browser_number < 5 ) ) { - $b_dom_browser = false; - $ie_version = 'ie4'; - // this depends on what you're using the script for, make sure this fits your needs - $b_safe_browser = true; - } else { - $ie_version = 'old'; - $b_dom_browser = false; - $b_safe_browser = false; - } - break; - case 'op': - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - // opera is leaving version at 9.80 (or xx) for 10.x - see this for explanation - // http://dev.opera.com/articles/view/opera-ua-string-changes/ - if ( strstr( $browser_number, '9.' ) && strstr( $browser_user_agent, 'version/' ) ) { - g::get_set_count( 'set', 0 ); - $browser_number = g::get_item_version( $browser_user_agent, 'version/' ); - } - - if ( $browser_number < 5 ) { - $b_safe_browser = false; - } - break; - case 'webkit': - // note that this is the Webkit version number - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - // this is to pull out specific webkit versions, safari, google-chrome etc.. - $j_count = count( $a_webkit_types ); - for ($j = 0; $j < $j_count; $j++) { - if (strstr( $browser_user_agent, $a_webkit_types[$j])) { - $webkit_type = $a_webkit_types[$j]; - if ( $webkit_type == 'omniweb' ) { - g::get_set_count( 'set', 2 ); - } - $webkit_type_number = g::get_item_version( $browser_user_agent, $webkit_type ); - // epiphany hack - if ( $a_webkit_types[$j] == 'gtklauncher' ) { - $browser_name = 'epiphany'; - } else { - $browser_name = $a_webkit_types[$j]; - } - break; - } - } - break; - default: - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - break; - } - // the browser was id'ed - $b_success = true; - break; - } - } - + //assigns defaults if the browser was not found in the loop test if ( !$b_success ) { - /* - this will return the first part of the browser string if the above id's failed - usually the first part of the browser string has the navigator useragent name/version in it. - This will usually correctly id the browser and the browser number if it didn't get - caught by the above routine. - If you want a '' to do a if browser == '' type test, just comment out all lines below - except for the last line, and uncomment the last line. If you want undefined values, - the browser_name is '', you can always test for that - */ - // delete this part if you want an unknown browser returned - $browser_name = substr( $browser_user_agent, 0, strcspn( $browser_user_agent , '();') ); - // this extracts just the browser name from the string, if something usable was found - if ( $browser_name && preg_match( '/[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*/', $browser_name, $a_unhandled_browser ) ) { - $browser_name = $a_unhandled_browser[0]; - if ( $browser_name == 'blackberry' ) { - g::get_set_count( 'set', 0 ); - } - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - } else { - $browser_name = 'NA'; - $browser_number = 'NA'; - } + /* + this will return the first part of the browser string if the above id's failed + usually the first part of the browser string has the navigator useragent name/version in it. + This will usually correctly id the browser and the browser number if it didn't get + caught by the above routine. + If you want a '' to do a if browser == '' type test, just comment out all lines below + except for the last line, and uncomment the last line. If you want undefined values, + the browser_name is '', you can always test for that + */ + // delete this part if you want an unknown browser returned + $browser_name = substr( $browser_user_agent, 0, strcspn( $browser_user_agent , '();') ); + // this extracts just the browser name from the string, if something usable was found + if ( $browser_name && preg_match( '/[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*/', $browser_name, $a_unhandled_browser ) ) { + $browser_name = $a_unhandled_browser[0]; + if ( $browser_name == 'blackberry' ) { + g::get_set_count( 'set', 0 ); + } + $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); + } else { + $browser_name = 'NA'; + $browser_number = 'NA'; + } } // get os data, mac os x test requires browser/version information, this is a change from older scripts if ($b_os_test) { - $a_os_data = g::get_os_data( $browser_user_agent, $browser_working, $browser_number ); - $os_type = $a_os_data[0];// os name, abbreviated - $os_number = $a_os_data[1];// os number or version if available + $a_os_data = g::get_os_data( $browser_user_agent, $browser_working, $browser_number ); + $os_type = $a_os_data[0];// os name, abbreviated + $os_number = $a_os_data[1];// os number or version if available } /* - this ends the run through once if clause, set the boolean - to true so the function won't retest everything - */ - $b_repeat = true; - if ($browser_number && preg_match( '/[0-9]*\.*[0-9]*/', $browser_number, $a_browser_math_number ) ) { + this ends the run through once if clause, set the boolean + to true so the function won't retest everything + */ + $b_repeat = true; + if ($browser_number && preg_match( '/[0-9]*\.*[0-9]*/', $browser_number, $a_browser_math_number ) ) { $browser_math_number = $a_browser_math_number[0]; - } - if ( $b_mobile_test ) { + } + if ( $b_mobile_test ) { $mobile_test = g::check_is_mobile( $browser_user_agent ); if ( $mobile_test ) { - $a_mobile_data = g::get_mobile_data( $browser_user_agent ); - $ua_type = 'mobile'; + $a_mobile_data = g::get_mobile_data( $browser_user_agent ); + $ua_type = 'mobile'; } - } - } - - switch ($which_test) { - case 'math_number': + } + } + + switch ($which_test) { + case 'math_number': $which_test = 'browser_math_number'; break; - case 'number': + case 'number': $which_test = 'browser_number'; break; - case 'browser': + case 'browser': $which_test = 'browser_working'; break; - case 'moz_version': + case 'moz_version': $which_test = 'moz_data'; - break; - case 'true_msie_version': - $which_test = 'true_ie_number'; - break; - case 'type': - $which_test = 'ua_type'; - break; - case 'webkit_version': - $which_test = 'webkit_data'; - break; - } - /* + break; + case 'true_msie_version': + $which_test = 'true_ie_number'; + break; + case 'type': + $which_test = 'ua_type'; + break; + case 'webkit_version': + $which_test = 'webkit_data'; + break; + } + /* assemble these first so they can be included in full return data, using static variables - Note that there's no need to keep repacking these every time the script is called - */ - if (!$a_moz_data) { + Note that there's no need to keep repacking these every time the script is called + */ + if (!$a_moz_data) { $a_moz_data = array( $moz_type, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date ); - } - if (!$a_webkit_data) { + } + if (!$a_webkit_data) { $a_webkit_data = array( $webkit_type, $webkit_type_number, $browser_number ); - } - $run_time = g::script_time(); - - if ( !$a_full_assoc_data ) { + } + $run_time = g::script_time(); + + if ( !$a_full_assoc_data ) { $a_full_assoc_data = array( - 'browser_working' => $browser_working, - 'browser_number' => $browser_number, - 'ie_version' => $ie_version, - 'dom' => $b_dom_browser, - 'safe' => $b_safe_browser, - 'os' => $os_type, - 'os_number' => $os_number, - 'browser_name' => $browser_name, - 'ua_type' => $ua_type, - 'browser_math_number' => $browser_math_number, - 'moz_data' => $a_moz_data, - 'webkit_data' => $a_webkit_data, - 'mobile_test' => $mobile_test, - 'mobile_data' => $a_mobile_data, - 'true_ie_number' => $true_ie_number, - 'run_time' => $run_time + 'browser_working' => $browser_working, + 'browser_number' => $browser_number, + 'ie_version' => $ie_version, + 'dom' => $b_dom_browser, + 'safe' => $b_safe_browser, + 'os' => $os_type, + 'os_number' => $os_number, + 'browser_name' => $browser_name, + 'ua_type' => $ua_type, + 'browser_math_number' => $browser_math_number, + 'moz_data' => $a_moz_data, + 'webkit_data' => $a_webkit_data, + 'mobile_test' => $mobile_test, + 'mobile_data' => $a_mobile_data, + 'true_ie_number' => $true_ie_number, + 'run_time' => $run_time + ); + } + + // return parameters, either full data arrays, or by associative array index key + switch ($which_test) { + // returns all relevant browser information in an array with standard numberic indexes + case 'full': + $a_full_data = array($browser_working, + $browser_number, + $ie_version, + $b_dom_browser, + $b_safe_browser, + $os_type, + $os_number, + $browser_name, + $ua_type, + $browser_math_number, + $a_moz_data, + $a_webkit_data, + $mobile_test, + $a_mobile_data, + $true_ie_number, + $run_time ); - } - - // return parameters, either full data arrays, or by associative array index key - switch ($which_test) { - // returns all relevant browser information in an array with standard numberic indexes - case 'full': - $a_full_data = array($browser_working, - $browser_number, - $ie_version, - $b_dom_browser, - $b_safe_browser, - $os_type, - $os_number, - $browser_name, - $ua_type, - $browser_math_number, - $a_moz_data, - $a_webkit_data, - $mobile_test, - $a_mobile_data, - $true_ie_number, - $run_time - ); - return $a_full_data; - break; - case 'full_assoc': - return $a_full_assoc_data; - break; - default: - # check to see if the data is available, otherwise it's user typo of unsupported option - if (isset( $a_full_assoc_data[$which_test])) { - return $a_full_assoc_data[$which_test]; - } else { - die( "You passed the browser detector an unsupported option for parameter 1: " . $which_test ); - } - break; - } - } - - /** - * track total script execution time - */ - public function script_time () - { - static $script_time; - $elapsed_time = ''; - /* - note that microtime(true) requires php 5 or greater for microtime(true) - */ - if (sprintf( "%01.1f", phpversion() ) >= 5) { - if (is_null( $script_time )) { - $script_time = microtime( true ); - } else { - // note: (string)$var is same as strval($var) - // $elapsed_time = (string)( microtime(true) - $script_time ); - $elapsed_time = (microtime( true ) - $script_time); - $elapsed_time = sprintf( "%01.8f", $elapsed_time ); - $script_time = null; // can't unset a static variable - return $elapsed_time; - } - } - } - - /** - * - * @param unknown_type $pv_browser_user_agent - * @param unknown_type $pv_search_string - * @param unknown_type $pv_b_break_last - * @param unknown_type $pv_extra_search - * @return string - */ - public function get_item_version($pv_browser_user_agent, $pv_search_string, $pv_b_break_last = '', $pv_extra_search = '') - { - $substring_length = 15; - $start_pos = 0; // set $start_pos to 0 for first iteration - $string_working_number = ''; - for ($i = 0; $i < 4; $i++) { - //start the search after the first string occurrence - if (strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) !== false) { - $start_pos = strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) + strlen( $pv_search_string ); - if (!$pv_b_break_last || ( $pv_extra_search && strstr( $pv_browser_user_agent, $pv_extra_search ) )) { - break; + return $a_full_data; + break; + case 'full_assoc': + return $a_full_assoc_data; + break; + default: + # check to see if the data is available, otherwise it's user typo of unsupported option + if (isset( $a_full_assoc_data[$which_test])) { + return $a_full_assoc_data[$which_test]; + } else { + die( "You passed the browser detector an unsupported option for parameter 1: " . $which_test ); + } + break; + } } - } else { - break; - } - } - - $start_pos += g::get_set_count( 'get' ); - $string_working_number = substr( $pv_browser_user_agent, $start_pos, $substring_length ); - $string_working_number = substr( $string_working_number, 0, strcspn($string_working_number, ' );/') ); - if (!is_numeric( substr( $string_working_number, 0, 1 ))) { - $string_working_number = ''; - } - return $string_working_number; - } - + /** - * - * @param unknown_type $pv_type - * @param unknown_type $pv_value - */ + * track total script execution time + */ + public function script_time () + { + static $script_time; + $elapsed_time = ''; + /* + note that microtime(true) requires php 5 or greater for microtime(true) + */ + if (sprintf( "%01.1f", phpversion() ) >= 5) { + if (is_null( $script_time )) { + $script_time = microtime( true ); + } else { + // note: (string)$var is same as strval($var) + // $elapsed_time = (string)( microtime(true) - $script_time ); + $elapsed_time = (microtime( true ) - $script_time); + $elapsed_time = sprintf( "%01.8f", $elapsed_time ); + $script_time = null; // can't unset a static variable + return $elapsed_time; + } + } + } + + /** + * + * @param unknown_type $pv_browser_user_agent + * @param unknown_type $pv_search_string + * @param unknown_type $pv_b_break_last + * @param unknown_type $pv_extra_search + * @return string + */ + public function get_item_version($pv_browser_user_agent, $pv_search_string, $pv_b_break_last = '', $pv_extra_search = '') + { + $substring_length = 15; + $start_pos = 0; // set $start_pos to 0 for first iteration + $string_working_number = ''; + for ($i = 0; $i < 4; $i++) { + //start the search after the first string occurrence + if (strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) !== false) { + $start_pos = strpos( $pv_browser_user_agent, $pv_search_string, $start_pos ) + strlen( $pv_search_string ); + if (!$pv_b_break_last || ( $pv_extra_search && strstr( $pv_browser_user_agent, $pv_extra_search ) )) { + break; + } + } else { + break; + } + } + + $start_pos += g::get_set_count( 'get' ); + $string_working_number = substr( $pv_browser_user_agent, $start_pos, $substring_length ); + $string_working_number = substr( $string_working_number, 0, strcspn($string_working_number, ' );/') ); + if (!is_numeric( substr( $string_working_number, 0, 1 ))) { + $string_working_number = ''; + } + return $string_working_number; + } + + /** + * + * @param unknown_type $pv_type + * @param unknown_type $pv_value + */ public function get_set_count($pv_type, $pv_value = '') { - static $slice_increment; - $return_value = ''; - switch ( $pv_type ) { - case 'get': - if ( is_null( $slice_increment ) ) { - $slice_increment = 1; + static $slice_increment; + $return_value = ''; + switch ( $pv_type ) { + case 'get': + if ( is_null( $slice_increment ) ) { + $slice_increment = 1; + } + $return_value = $slice_increment; + $slice_increment = 1; // reset to default + return $return_value; + break; + case 'set': + $slice_increment = $pv_value; + break; + } } - $return_value = $slice_increment; - $slice_increment = 1; // reset to default - return $return_value; - break; - case 'set': - $slice_increment = $pv_value; - break; - } - } - + /** - * gets which os from the browser string - */ + * gets which os from the browser string + */ public function get_os_data ($pv_browser_string, $pv_browser_name, $pv_version_number) { - // initialize variables - $os_working_type = ''; - $os_working_number = ''; - /* - packs the os array. Use this order since some navigator user agents will put 'macintosh' - in the navigator user agent string which would make the nt test register true - */ - $a_mac = array( 'intel mac', 'ppc mac', 'mac68k' );// this is not used currently - // same logic, check in order to catch the os's in order, last is always default item - $a_unix_types = array( 'dragonfly', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'unixware', 'solaris', 'sunos', 'sun4', 'sun5', 'suni86', 'sun', 'irix5', 'irix6', 'irix', 'hpux9', 'hpux10', 'hpux11', 'hpux', 'hp-ux', 'aix1', 'aix2', 'aix3', 'aix4', 'aix5', 'aix', 'sco', 'unixware', 'mpras', 'reliant', 'dec', 'sinix', 'unix' ); - // only sometimes will you get a linux distro to id itself... - $a_linux_distros = array( 'ubuntu', 'kubuntu', 'xubuntu', 'mepis', 'xandros', 'linspire', 'winspire', 'jolicloud', 'sidux', 'kanotix', 'debian', 'opensuse', 'suse', 'fedora', 'redhat', 'slackware', 'slax', 'mandrake', 'mandriva', 'gentoo', 'sabayon', 'linux' ); - $a_linux_process = array ( 'i386', 'i586', 'i686' );// not use currently - // note, order of os very important in os array, you will get failed ids if changed + // initialize variables + $os_working_type = ''; + $os_working_number = ''; + /* + packs the os array. Use this order since some navigator user agents will put 'macintosh' + in the navigator user agent string which would make the nt test register true + */ + $a_mac = array( 'intel mac', 'ppc mac', 'mac68k' );// this is not used currently + // same logic, check in order to catch the os's in order, last is always default item + $a_unix_types = array( 'dragonfly', 'freebsd', 'openbsd', 'netbsd', 'bsd', 'unixware', 'solaris', 'sunos', 'sun4', 'sun5', 'suni86', 'sun', 'irix5', 'irix6', 'irix', 'hpux9', 'hpux10', 'hpux11', 'hpux', 'hp-ux', 'aix1', 'aix2', 'aix3', 'aix4', 'aix5', 'aix', 'sco', 'unixware', 'mpras', 'reliant', 'dec', 'sinix', 'unix' ); + // only sometimes will you get a linux distro to id itself... + $a_linux_distros = array( 'ubuntu', 'kubuntu', 'xubuntu', 'mepis', 'xandros', 'linspire', 'winspire', 'jolicloud', 'sidux', 'kanotix', 'debian', 'opensuse', 'suse', 'fedora', 'redhat', 'slackware', 'slax', 'mandrake', 'mandriva', 'gentoo', 'sabayon', 'linux' ); + $a_linux_process = array ( 'i386', 'i586', 'i686' );// not use currently + // note, order of os very important in os array, you will get failed ids if changed $a_os_types = array( 'android', 'blackberry', 'iphone', 'palmos', 'palmsource', 'symbian', 'beos', 'os2', 'amiga', 'webtv', 'mac', 'nt', 'win', $a_unix_types, $a_linux_distros ); - + //os tester $i_count = count( $a_os_types ); for ($i = 0; $i < $i_count; $i++) { - // unpacks os array, assigns to variable $a_os_working - $os_working_data = $a_os_types[$i]; - /* - assign os to global os variable, os flag true on success - !strstr($pv_browser_string, "linux" ) corrects a linux detection bug - */ - if (!is_array($os_working_data) && strstr($pv_browser_string, $os_working_data ) && !strstr( $pv_browser_string, "linux")) { - $os_working_type = $os_working_data; - - switch ($os_working_type) { - // most windows now uses: NT X.Y syntax - case 'nt': - if (strstr( $pv_browser_string, 'nt 6.1' )) { - $os_working_number = 6.1; - } elseif (strstr( $pv_browser_string, 'nt 6.0')) { - $os_working_number = 6.0; - } elseif (strstr( $pv_browser_string, 'nt 5.2')) { - $os_working_number = 5.2; - } elseif (strstr( $pv_browser_string, 'nt 5.1') || strstr( $pv_browser_string, 'xp')) { - $os_working_number = 5.1;// - } elseif (strstr( $pv_browser_string, 'nt 5') || strstr( $pv_browser_string, '2000')) { - $os_working_number = 5.0; - } elseif (strstr( $pv_browser_string, 'nt 4')) { - $os_working_number = 4; - } elseif (strstr( $pv_browser_string, 'nt 3')) { - $os_working_number = 3; - } - break; - case 'win': - if (strstr( $pv_browser_string, 'vista')) { - $os_working_number = 6.0; - $os_working_type = 'nt'; - } elseif ( strstr( $pv_browser_string, 'xp')) { - $os_working_number = 5.1; - $os_working_type = 'nt'; - } elseif ( strstr( $pv_browser_string, '2003')) { - $os_working_number = 5.2; - $os_working_type = 'nt'; - } - elseif ( strstr( $pv_browser_string, 'windows ce' ) )// windows CE - { - $os_working_number = 'ce'; - $os_working_type = 'nt'; - } - elseif ( strstr( $pv_browser_string, '95' ) ) - { - $os_working_number = '95'; - } - elseif ( ( strstr( $pv_browser_string, '9x 4.9' ) ) || ( strstr( $pv_browser_string, ' me' ) ) ) + // unpacks os array, assigns to variable $a_os_working + $os_working_data = $a_os_types[$i]; + /* + assign os to global os variable, os flag true on success + !strstr($pv_browser_string, "linux" ) corrects a linux detection bug + */ + if (!is_array($os_working_data) && strstr($pv_browser_string, $os_working_data ) && !strstr( $pv_browser_string, "linux")) { + $os_working_type = $os_working_data; + + switch ($os_working_type) { + // most windows now uses: NT X.Y syntax + case 'nt': + if (strstr( $pv_browser_string, 'nt 6.1' )) { + $os_working_number = 6.1; + } elseif (strstr( $pv_browser_string, 'nt 6.0')) { + $os_working_number = 6.0; + } elseif (strstr( $pv_browser_string, 'nt 5.2')) { + $os_working_number = 5.2; + } elseif (strstr( $pv_browser_string, 'nt 5.1') || strstr( $pv_browser_string, 'xp')) { + $os_working_number = 5.1;// + } elseif (strstr( $pv_browser_string, 'nt 5') || strstr( $pv_browser_string, '2000')) { + $os_working_number = 5.0; + } elseif (strstr( $pv_browser_string, 'nt 4')) { + $os_working_number = 4; + } elseif (strstr( $pv_browser_string, 'nt 3')) { + $os_working_number = 3; + } + break; + case 'win': + if (strstr( $pv_browser_string, 'vista')) { + $os_working_number = 6.0; + $os_working_type = 'nt'; + } elseif ( strstr( $pv_browser_string, 'xp')) { + $os_working_number = 5.1; + $os_working_type = 'nt'; + } elseif ( strstr( $pv_browser_string, '2003')) { + $os_working_number = 5.2; + $os_working_type = 'nt'; + } + elseif ( strstr( $pv_browser_string, 'windows ce' ) )// windows CE { - $os_working_number = 'me'; + $os_working_number = 'ce'; + $os_working_type = 'nt'; + } + elseif ( strstr( $pv_browser_string, '95' ) ) + { + $os_working_number = '95'; + } + elseif ( ( strstr( $pv_browser_string, '9x 4.9' ) ) || ( strstr( $pv_browser_string, ' me' ) ) ) + { + $os_working_number = 'me'; + } + elseif ( strstr( $pv_browser_string, '98' ) ) + { + $os_working_number = '98'; + } + elseif ( strstr( $pv_browser_string, '2000' ) )// windows 2000, for opera ID + { + $os_working_number = 5.0; + $os_working_type = 'nt'; + } + break; + case 'mac': + if (strstr($pv_browser_string, 'os x')) { + if (strstr($pv_browser_string, 'os x ')) { + $os_working_number = str_replace( '_', '.', g::get_item_version( $pv_browser_string, 'os x' ) ); + } else { + $os_working_number = 10; + } + } elseif ( ( $pv_browser_name == 'saf' ) || ( $pv_browser_name == 'cam' ) || + ( ( $pv_browser_name == 'moz' ) && ( $pv_version_number >= 1.3 ) ) || + ( ( $pv_browser_name == 'ie' ) && ( $pv_version_number >= 5.2 ) ) ) { + $os_working_number = 10; + } + break; + case 'iphone': + $os_working_number = 10; + break; + default: + break; + } + break; + } elseif ( is_array( $os_working_data ) && ( $i == ( $i_count - 2 ) ) ) { + $j_count = count($os_working_data); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $pv_browser_string, $os_working_data[$j])) { + $os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously... + $os_working_number = ( $os_working_data[$j] != 'unix' ) ? $os_working_data[$j] : '';// assign sub unix version from the unix array + break; + } + } + } elseif (is_array( $os_working_data ) && ( $i == ( $i_count - 1 ))) { + $j_count = count($os_working_data); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $pv_browser_string, $os_working_data[$j] )) { + $os_working_type = 'lin'; + // assign linux distro from the linux array, there's a default + //search for 'lin', if it's that, set version to '' + $os_working_number = ( $os_working_data[$j] != 'linux' ) ? $os_working_data[$j] : ''; + break; + } + } + } + } + + // pack the os data array for return to main function + $a_os_data = array( $os_working_type, $os_working_number ); + + return $a_os_data; } - elseif ( strstr( $pv_browser_string, '98' ) ) - { - $os_working_number = '98'; - } - elseif ( strstr( $pv_browser_string, '2000' ) )// windows 2000, for opera ID - { - $os_working_number = 5.0; - $os_working_type = 'nt'; - } - break; - case 'mac': - if (strstr($pv_browser_string, 'os x')) { - if (strstr($pv_browser_string, 'os x ')) { - $os_working_number = str_replace( '_', '.', g::get_item_version( $pv_browser_string, 'os x' ) ); - } else { - $os_working_number = 10; - } - } elseif ( ( $pv_browser_name == 'saf' ) || ( $pv_browser_name == 'cam' ) || - ( ( $pv_browser_name == 'moz' ) && ( $pv_version_number >= 1.3 ) ) || - ( ( $pv_browser_name == 'ie' ) && ( $pv_version_number >= 5.2 ) ) ) { - $os_working_number = 10; - } - break; - case 'iphone': - $os_working_number = 10; - break; - default: - break; - } - break; - } elseif ( is_array( $os_working_data ) && ( $i == ( $i_count - 2 ) ) ) { - $j_count = count($os_working_data); - for ($j = 0; $j < $j_count; $j++) { - if (strstr( $pv_browser_string, $os_working_data[$j])) { - $os_working_type = 'unix'; //if the os is in the unix array, it's unix, obviously... - $os_working_number = ( $os_working_data[$j] != 'unix' ) ? $os_working_data[$j] : '';// assign sub unix version from the unix array - break; - } - } - } elseif (is_array( $os_working_data ) && ( $i == ( $i_count - 1 ))) { - $j_count = count($os_working_data); - for ($j = 0; $j < $j_count; $j++) { - if ( strstr( $pv_browser_string, $os_working_data[$j] )) { - $os_working_type = 'lin'; - // assign linux distro from the linux array, there's a default - //search for 'lin', if it's that, set version to '' - $os_working_number = ( $os_working_data[$j] != 'linux' ) ? $os_working_data[$j] : ''; - break; - } - } - } - } - - // pack the os data array for return to main function - $a_os_data = array( $os_working_type, $os_working_number ); - - return $a_os_data; - } - + /** - * - * @param unknown_type $pv_browser_user_agent - * @return string - */ + * + * @param unknown_type $pv_browser_user_agent + * @return string + */ public function check_is_mobile($pv_browser_user_agent) { - $mobile_working_test = ''; - $a_mobile_search = array( - 'android', 'epoc', 'linux armv', 'palmos', 'palmsource', 'windows ce', 'windows phone os', 'symbianos', 'symbian os', 'symbian', 'webos', - // devices - ipod before iphone or fails - 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lge ', 'lge-', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zune', 'j-phone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'sec-', 'sie-m', 'sie-s', 'spv ', 'vodaphone', 'smartphone', 'armv', 'midp', 'mobilephone', - // browsers - 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino', - // services - astel out of business - 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' - ); - - // then do basic mobile type search, this uses data from: get_mobile_data() - $j_count = count( $a_mobile_search ); - for ($j = 0; $j < $j_count; $j++) { - if (strstr( $pv_browser_user_agent, $a_mobile_search[$j] )) { - $mobile_working_test = $a_mobile_search[$j]; - break; + $mobile_working_test = ''; + $a_mobile_search = array( + 'android', 'epoc', 'linux armv', 'palmos', 'palmsource', 'windows ce', 'windows phone os', 'symbianos', 'symbian os', 'symbian', 'webos', + // devices - ipod before iphone or fails + 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lge ', 'lge-', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zune', 'j-phone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'sec-', 'sie-m', 'sie-s', 'spv ', 'vodaphone', 'smartphone', 'armv', 'midp', 'mobilephone', + // browsers + 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino', + // services - astel out of business + 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' + ); + + // then do basic mobile type search, this uses data from: get_mobile_data() + $j_count = count( $a_mobile_search ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $pv_browser_user_agent, $a_mobile_search[$j] )) { + $mobile_working_test = $a_mobile_search[$j]; + break; + } + } + return $mobile_working_test; } - } - return $mobile_working_test; - } - + /** - * - * @param unknown_type $pv_browser_user_agent - */ + * + * @param unknown_type $pv_browser_user_agent + */ public function get_mobile_data ($pv_browser_user_agent) { - $mobile_browser = ''; - $mobile_browser_number = ''; - $mobile_device = ''; - $mobile_device_number = ''; - $mobile_os = ''; // will usually be null, sorry - $mobile_os_number = ''; - $mobile_server = ''; - $mobile_server_number = ''; - + $mobile_browser = ''; + $mobile_browser_number = ''; + $mobile_device = ''; + $mobile_device_number = ''; + $mobile_os = ''; // will usually be null, sorry + $mobile_os_number = ''; + $mobile_server = ''; + $mobile_server_number = ''; + $a_mobile_browser = array( 'avantgo', 'blazer', 'elaine', 'eudoraweb', 'iemobile', 'minimo', 'mobile safari', 'mobileexplorer', 'opera mobi', 'opera mini', 'netfront', 'opwv', 'polaris', 'semc-browser', 'up.browser', 'webpro', 'wms pie', 'xiino' ); $a_mobile_device = array( 'benq', 'blackberry', 'danger hiptop', 'ddipocket', ' droid', 'htc_dream', 'htc espresso', 'htc hero', 'htc halo', 'htc huangshan', 'htc legend', 'htc liberty', 'htc paradise', 'htc supersonic', 'htc tattoo', 'ipad', 'ipod', 'iphone', 'kindle', 'lge-cx', 'lge-lx', 'lge-mx', 'lge vx', 'lg;lx', 'nintendo wii', 'nokia', 'palm', 'pdxgw', 'playstation', 'sagem', 'samsung', 'sec-sgh', 'sharp', 'sonyericsson', 'sprint', 'zunehd', 'zune', 'j-phone', 'milestone', 'n410', 'mot 24', 'mot-', 'htc-', 'htc_', 'htc ', 'lge ', 'lge-', 'sec-', 'sie-m', 'sie-s', 'spv ', 'smartphone', 'armv', 'midp', 'mobilephone' ); $a_mobile_os = array( 'android', 'epoc', 'cpu os', 'iphone os', 'palmos', 'palmsource', 'windows phone os', 'windows ce', 'symbianos', 'symbian os', 'symbian', 'webos', 'linux armv' ); $a_mobile_server = array( 'astel', 'docomo', 'novarra-vision', 'portalmmm', 'reqwirelessweb', 'vodafone' ); - + $k_count = count( $a_mobile_browser ); for ($k = 0; $k < $k_count; $k++) { - if (strstr( $pv_browser_user_agent, $a_mobile_browser[$k] )) { - $mobile_browser = $a_mobile_browser[$k]; - $mobile_browser_number = g::get_item_version( $pv_browser_user_agent, $mobile_browser ); - break; - } - } - $k_count = count( $a_mobile_device ); - for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_browser[$k] )) { + $mobile_browser = $a_mobile_browser[$k]; + $mobile_browser_number = g::get_item_version( $pv_browser_user_agent, $mobile_browser ); + break; + } + } + $k_count = count( $a_mobile_device ); + for ($k = 0; $k < $k_count; $k++) { if (strstr( $pv_browser_user_agent, $a_mobile_device[$k] )) { $mobile_device = trim ( $a_mobile_device[$k], '-_' ); // but not space trims yet if ($mobile_device == 'blackberry') { - g::get_set_count( 'set', 0 ); + g::get_set_count( 'set', 0 ); } $mobile_device_number = g::get_item_version( $pv_browser_user_agent, $mobile_device ); $mobile_device = trim( $mobile_device ); // some of the id search strings have white space break; - } - } - $k_count = count( $a_mobile_os ); - for ($k = 0; $k < $k_count; $k++) { - if (strstr( $pv_browser_user_agent, $a_mobile_os[$k] )) { - $mobile_os = $a_mobile_os[$k]; - $mobile_os_number = str_replace( '_', '.', g::get_item_version( $pv_browser_user_agent, $mobile_os ) ); - break; + } + } + $k_count = count( $a_mobile_os ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_os[$k] )) { + $mobile_os = $a_mobile_os[$k]; + $mobile_os_number = str_replace( '_', '.', g::get_item_version( $pv_browser_user_agent, $mobile_os ) ); + break; + } + } + $k_count = count( $a_mobile_server ); + for ($k = 0; $k < $k_count; $k++) { + if (strstr( $pv_browser_user_agent, $a_mobile_server[$k] )) { + $mobile_server = $a_mobile_server[$k]; + $mobile_server_number = g::get_item_version( $pv_browser_user_agent, $mobile_server ); + break; + } + } + // just for cases where we know it's a mobile device already + if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr( $pv_browser_user_agent, 'linux' ) ) { + $mobile_os = 'linux'; + $mobile_os_number = g::get_item_version( $pv_browser_user_agent, 'linux' ); + } + + $a_mobile_data = array( $mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number, $mobile_device_number ); + return $a_mobile_data; } - } - $k_count = count( $a_mobile_server ); - for ($k = 0; $k < $k_count; $k++) { - if (strstr( $pv_browser_user_agent, $a_mobile_server[$k] )) { - $mobile_server = $a_mobile_server[$k]; - $mobile_server_number = g::get_item_version( $pv_browser_user_agent, $mobile_server ); - break; - } - } - // just for cases where we know it's a mobile device already - if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr( $pv_browser_user_agent, 'linux' ) ) { - $mobile_os = 'linux'; - $mobile_os_number = g::get_item_version( $pv_browser_user_agent, 'linux' ); - } - - $a_mobile_data = array( $mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number, $mobile_device_number ); - return $a_mobile_data; - } - - /** - * - * @param unknown_type $requestUri - */ - public function parseRestUri ($requestUri) - { - $args = array (); - //$args['SYS_TEMP'] = $requestUri[1]; - define( 'SYS_TEMP', $requestUri[2] ); - $restUri = ''; - - for ($i = 3; $i < count( $requestUri ); $i ++) { - $restUri .= '/' . $requestUri[$i]; - } - - $args['SYS_LANG'] = 'en'; // TODO, this can be set from http header - $args['SYS_SKIN'] = ''; - $args['SYS_COLLECTION'] = ''; - $args['SYS_TARGET'] = $restUri; - - return $args; - } - + /** - * - * @param unknown_type $aRequestUri - * @return multitype:string mixed Ambigous - */ + * + * @param unknown_type $requestUri + */ + public function parseRestUri ($requestUri) + { + $args = array (); + //$args['SYS_TEMP'] = $requestUri[1]; + define( 'SYS_TEMP', $requestUri[2] ); + $restUri = ''; + + for ($i = 3; $i < count( $requestUri ); $i ++) { + $restUri .= '/' . $requestUri[$i]; + } + + $args['SYS_LANG'] = 'en'; // TODO, this can be set from http header + $args['SYS_SKIN'] = ''; + $args['SYS_COLLECTION'] = ''; + $args['SYS_TARGET'] = $restUri; + + return $args; + } + + /** + * + * @param unknown_type $aRequestUri + * @return multitype:string mixed Ambigous + */ public function parseNormalUri ($aRequestUri) { - if (substr( $aRequestUri[1], 0, 3 ) == 'sys') { + if (substr( $aRequestUri[1], 0, 3 ) == 'sys') { define( 'SYS_TEMP', substr( $aRequestUri[1], 3 ) ); - } else { + } else { define( "ENABLE_ENCRYPT", 'yes' ); define( 'SYS_TEMP', $aRequestUri[1] ); $plain = '/sys' . SYS_TEMP; - + for ($i = 2; $i < count( $aRequestUri ); $i ++) { - $decoded = g::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); - if ($decoded == 'sWì›') { + $decoded = g::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); + if ($decoded == 'sWì›') { $decoded = $VARS[$i]; //this is for the string "../" - } - $plain .= '/' . $decoded; - } - $_SERVER["REQUEST_URI"] = $plain; - } - - $work = explode( '?', $_SERVER["REQUEST_URI"] ); - - if (count( $work ) > 1) { - define( 'SYS_CURRENT_PARMS', $work[1] ); - } else { - define( 'SYS_CURRENT_PARMS', '' ); - } - - define( 'SYS_CURRENT_URI', $work[0] ); - - if (! defined( 'SYS_CURRENT_PARMS' )) { - define( 'SYS_CURRENT_PARMS', $work[1] ); - } - - $preArray = explode( '&', SYS_CURRENT_PARMS ); - $buffer = explode( '.', $work[0] ); - - if (count( $buffer ) == 1) { + } + $plain .= '/' . $decoded; + } + $_SERVER["REQUEST_URI"] = $plain; + } + + $work = explode( '?', $_SERVER["REQUEST_URI"] ); + + if (count( $work ) > 1) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } else { + define( 'SYS_CURRENT_PARMS', '' ); + } + + define( 'SYS_CURRENT_URI', $work[0] ); + + if (! defined( 'SYS_CURRENT_PARMS' )) { + define( 'SYS_CURRENT_PARMS', $work[1] ); + } + + $preArray = explode( '&', SYS_CURRENT_PARMS ); + $buffer = explode( '.', $work[0] ); + + if (count( $buffer ) == 1) { $buffer[1] = ''; + } + + //request type + define( 'REQUEST_TYPE', ($buffer[1] != "" ? $buffer[1] : 'html') ); + + $toparse = substr( $buffer[0], 1, strlen( $buffer[0] ) - 1 ); + $uriVars = explode( '/', $toparse ); + + unset( $work ); + unset( $buffer ); + unset( $toparse ); + array_shift( $uriVars ); + + $args = array (); + $args['SYS_LANG'] = array_shift( $uriVars ); + $args['SYS_SKIN'] = array_shift( $uriVars ); + $args['SYS_COLLECTION'] = array_shift( $uriVars ); + $args['SYS_TARGET'] = array_shift( $uriVars ); + + //to enable more than 2 directories...in the methods structure + while (count( $uriVars ) > 0) { + $args['SYS_TARGET'] .= '/' . array_shift( $uriVars ); + } + + /* Fix to prevent use uxs skin outside siplified interface, + because that skin is not compatible with others interfaces*/ + if ($args['SYS_SKIN'] == 'uxs' && $args['SYS_COLLECTION'] != 'home' && $args['SYS_COLLECTION'] != 'cases') { + $config = System::getSystemConfiguration(); + $args['SYS_SKIN'] = $config['default_skin']; + } + + return $args; } - - //request type - define( 'REQUEST_TYPE', ($buffer[1] != "" ? $buffer[1] : 'html') ); - - $toparse = substr( $buffer[0], 1, strlen( $buffer[0] ) - 1 ); - $uriVars = explode( '/', $toparse ); - - unset( $work ); - unset( $buffer ); - unset( $toparse ); - array_shift( $uriVars ); - - $args = array (); - $args['SYS_LANG'] = array_shift( $uriVars ); - $args['SYS_SKIN'] = array_shift( $uriVars ); - $args['SYS_COLLECTION'] = array_shift( $uriVars ); - $args['SYS_TARGET'] = array_shift( $uriVars ); - - //to enable more than 2 directories...in the methods structure - while (count( $uriVars ) > 0) { - $args['SYS_TARGET'] .= '/' . array_shift( $uriVars ); - } - - /* Fix to prevent use uxs skin outside siplified interface, - because that skin is not compatible with others interfaces*/ - if ($args['SYS_SKIN'] == 'uxs' && $args['SYS_COLLECTION'] != 'home' && $args['SYS_COLLECTION'] != 'cases') { - $config = System::getSystemConfiguration(); - $args['SYS_SKIN'] = $config['default_skin']; - } - - return $args; - } - - /** - * * Encrypt and decrypt functions *** - */ - /** - * Encrypt string - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $string - * @param string $key - * @return string - */ - public function encrypt ($string, $key) - { - //print $string; - // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { - if (strpos( $string, '|', 0 ) !== false) { - return $string; - } - $result = ''; - for ($i = 0; $i < strlen( $string ); $i ++) { - $char = substr( $string, $i, 1 ); - $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); - $char = chr( ord( $char ) + ord( $keychar ) ); - $result .= $char; - } - - $result = base64_encode( $result ); - $result = str_replace( '/', '°', $result ); - $result = str_replace( '=', '', $result ); - return $result; - } - - /** - * Decrypt string - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $string - * @param string $key - * @return string - */ - public function decrypt ($string, $key) - { - // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { - //if (strpos($string, '|', 0) !== false) return $string; - $result = ''; - $string = str_replace( '°', '/', $string ); - $string_jhl = explode( "?", $string ); - $string = base64_decode( $string ); - $string = base64_decode( $string_jhl[0] ); - - for ($i = 0; $i < strlen( $string ); $i ++) { - $char = substr( $string, $i, 1 ); - $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); - $char = chr( ord( $char ) - ord( $keychar ) ); - $result .= $char; - } - if (! empty( $string_jhl[1] )) { - $result .= '?' . $string_jhl[1]; - } + + /** + * * Encrypt and decrypt functions *** + */ + /** + * Encrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + public function encrypt ($string, $key) + { + //print $string; + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + if (strpos( $string, '|', 0 ) !== false) { + return $string; + } + $result = ''; + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) + ord( $keychar ) ); + $result .= $char; + } + + $result = base64_encode( $result ); + $result = str_replace( '/', '°', $result ); + $result = str_replace( '=', '', $result ); return $result; - } - + } + + /** + * Decrypt string + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $string + * @param string $key + * @return string + */ + public function decrypt ($string, $key) + { + // if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) { + //if (strpos($string, '|', 0) !== false) return $string; + $result = ''; + $string = str_replace( '°', '/', $string ); + $string_jhl = explode( "?", $string ); + $string = base64_decode( $string ); + $string = base64_decode( $string_jhl[0] ); + + for ($i = 0; $i < strlen( $string ); $i ++) { + $char = substr( $string, $i, 1 ); + $keychar = substr( $key, ($i % strlen( $key )) - 1, 1 ); + $char = chr( ord( $char ) - ord( $keychar ) ); + $result .= $char; + } + if (! empty( $string_jhl[1] )) { + $result .= '?' . $string_jhl[1]; + } + return $result; + } + /** * * @param unknown_type $model * @return unknown */ - public function getModel($model) - { + public function getModel($model) + { require_once "classes/model/$model.php"; return new $model(); - } - - /** - * Create an encrypted unique identifier based on $id and the selected scope id. - * - * @author David S. Callizaya S. - * @access public - * @param string $scope - * @param string $id - * @return string - */ + } + + /** + * Create an encrypted unique identifier based on $id and the selected scope id. + * + * @author David S. Callizaya S. + * @access public + * @param string $scope + * @param string $id + * @return string + */ public function createUID ($scope, $id) { - $e = $scope . $id; - $e = g::encrypt( $e, URL_KEY ); - $e = str_replace( array ('+','/','=' - ), array ('__','_','___' - ), base64_encode( $e ) ); - return $e; - } - + $e = $scope . $id; + $e = g::encrypt( $e, URL_KEY ); + $e = str_replace( array ('+','/','=' + ), array ('__','_','___' + ), base64_encode( $e ) ); + return $e; + } + /** - * (Create an encrypted unique identificator based on $id and the selected scope id.) ^-1 - * getUIDName - * - * @author David S. Callizaya S. - * @access public - * @param string $id - * @param string $scope - * @return string - */ + * (Create an encrypted unique identificator based on $id and the selected scope id.) ^-1 + * getUIDName + * + * @author David S. Callizaya S. + * @access public + * @param string $id + * @param string $scope + * @return string + */ public function getUIDName ($uid, $scope = '') { - $e = str_replace( array ('=','+','/' - ), array ('___','__','_' - ), $uid ); - $e = base64_decode( $e ); - $e = g::decrypt( $e, URL_KEY ); - $e = substr( $e, strlen( $scope ) ); - return $e; + $e = str_replace( array ('=','+','/' + ), array ('___','__','_' + ), $uid ); + $e = base64_decode( $e ); + $e = g::decrypt( $e, URL_KEY ); + $e = substr( $e, strlen( $scope ) ); + return $e; } - + /** - * Merge 2 arrays - * - * @author Fernando Ontiveros Lira - * @access public - * @return array - */ + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira + * @access public + * @return array + */ public function array_merges () { - $array = array (); - $arrays = & func_get_args(); - foreach ($arrays as $array_i) { - if (is_array( $array_i )) { - g::array_merge_2( $array, $array_i ); + $array = array (); + $arrays = & func_get_args(); + foreach ($arrays as $array_i) { + if (is_array( $array_i )) { + g::array_merge_2( $array, $array_i ); + } + } + return $array; } - } - return $array; - } - + /** - * Merge 2 arrays - * - * @author Fernando Ontiveros Lira + * Merge 2 arrays + * + * @author Fernando Ontiveros Lira * @access public * @param string $array * @param string $array_i * @return array */ - public function array_merge_2 (&$array, &$array_i) - { + public function array_merge_2 (&$array, &$array_i) + { foreach ($array_i as $k => $v) { - if (is_array( $v )) { - if (! isset( $array[$k] )) { - $array[$k] = array (); + if (is_array( $v )) { + if (! isset( $array[$k] )) { + $array[$k] = array (); + } + g::array_merge_2( $array[$k], $v ); + } else { + if (isset( $array[$k] ) && is_array( $array[$k] )) { + $array[$k][0] = $v; + } else { + if (isset( $array ) && ! is_array( $array )) { + $temp = $array; + $array = array(); + $array[0] = $temp; + } + $array[$k] = $v; + } + } } - g::array_merge_2( $array[$k], $v ); - } else { - if (isset( $array[$k] ) && is_array( $array[$k] )) { - $array[$k][0] = $v; - } else { - if (isset( $array ) && ! is_array( $array )) { - $temp = $array; - $array = array(); - $array[0] = $temp; - } - $array[$k] = $v; - } - } - } - } - - /* Returns a sql string with @@parameters replaced with its values defined + } + + /* Returns a sql string with @@parameters replaced with its values defined * in array $result using the next notation: - * NOTATION: - * @@ Quoted parameter acording to the SYSTEM's Database - * @Q Double quoted parameter \\ \" - * @q Single quoted parameter \\ \' - * @% URL string - * @# Non-quoted parameter - * @! Evaluate string : Replace the parameters in value and then in the sql string - * @fn() Evaluate string with the function "fn" - * @author David Callizaya - */ - public function replaceDataField ($sqlString, $result, $DBEngine = 'mysql') - { + * NOTATION: + * @@ Quoted parameter acording to the SYSTEM's Database + * @Q Double quoted parameter \\ \" + * @q Single quoted parameter \\ \' + * @% URL string + * @# Non-quoted parameter + * @! Evaluate string : Replace the parameters in value and then in the sql string + * @fn() Evaluate string with the function "fn" + * @author David Callizaya + */ + public function replaceDataField ($sqlString, $result, $DBEngine = 'mysql') + { if (! is_array( $result )) { - $result = array (); - } + $result = array (); + } $result = $result + g::getSystemConstants(); $__textoEval = ""; $u = 0; //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); $count = preg_match_all( '/\@(?:([\@\%\#\=\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*?)*)\))/', $sqlString, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ); if ($count) { - for ($r = 0; $r < $count; $r ++) { - if (! isset( $result[$match[2][$r][0]] )) { - $result[$match[2][$r][0]] = ''; - } - if (! is_array( $result[$match[2][$r][0]] )) { - $__textoEval .= substr( $sqlString, $u, $match[0][$r][1] - $u ); - $u = $match[0][$r][1] + strlen( $match[0][$r][0] ); - //Mysql quotes scape - if (($match[1][$r][0] == '@') && (isset( $result[$match[2][$r][0]] ))) { - $__textoEval .= "\"" . g::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; - continue; - } - //URL encode - if (($match[1][$r][0]=='%')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=urlencode($result[$match[2][$r][0]]); - continue; - } - //Double quoted parameter - if (($match[1][$r][0]=='Q')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.='"'.addcslashes($result[$match[2][$r][0]],'\\"').'"'; - continue; + for ($r = 0; $r < $count; $r ++) { + if (! isset( $result[$match[2][$r][0]] )) { + $result[$match[2][$r][0]] = ''; + } + if (! is_array( $result[$match[2][$r][0]] )) { + $__textoEval .= substr( $sqlString, $u, $match[0][$r][1] - $u ); + $u = $match[0][$r][1] + strlen( $match[0][$r][0] ); + //Mysql quotes scape + if (($match[1][$r][0] == '@') && (isset( $result[$match[2][$r][0]] ))) { + $__textoEval .= "\"" . g::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; + continue; + } + //URL encode + if (($match[1][$r][0]=='%')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=urlencode($result[$match[2][$r][0]]); + continue; + } + //Double quoted parameter + if (($match[1][$r][0]=='Q')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.='"'.addcslashes($result[$match[2][$r][0]],'\\"').'"'; + continue; + } + //Single quoted parameter + if (($match[1][$r][0]=='q')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.="'".addcslashes($result[$match[2][$r][0]],'\\\'')."'"; + continue; + } + //Substring (Sub replaceDataField) + if (($match[1][$r][0]=='!')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + //Call function + if (($match[1][$r][0]==='')&&($match[2][$r][0]==='')&&($match[3][$r][0]!=='')) { + eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(g::replaceDataField(stripslashes($match[4][$r][0]),$result),'\\\'') . '\');'); + + if ($match[3][$r][0] == "g::LoadTranslation") { + $arraySearch = array("'"); + $arrayReplace = array("\\'"); + $strAux = str_replace($arraySearch, $arrayReplace, $strAux); + } + + $__textoEval .= $strAux; + continue; + } + //Non-quoted + if (($match[1][$r][0]=='#')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + //Non-quoted = + if (($match[1][$r][0]=='=')&&(isset($result[$match[2][$r][0]]))) { + $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + continue; + } + } } - //Single quoted parameter - if (($match[1][$r][0]=='q')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.="'".addcslashes($result[$match[2][$r][0]],'\\\'')."'"; - continue; - } - //Substring (Sub replaceDataField) - if (($match[1][$r][0]=='!')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); - continue; - } - //Call function - if (($match[1][$r][0]==='')&&($match[2][$r][0]==='')&&($match[3][$r][0]!=='')) { - eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(g::replaceDataField(stripslashes($match[4][$r][0]),$result),'\\\'') . '\');'); - - if ($match[3][$r][0] == "g::LoadTranslation") { - $arraySearch = array("'"); - $arrayReplace = array("\\'"); - $strAux = str_replace($arraySearch, $arrayReplace, $strAux); - } - - $__textoEval .= $strAux; - continue; - } - //Non-quoted - if (($match[1][$r][0]=='#')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); - continue; - } - //Non-quoted = - if (($match[1][$r][0]=='=')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); - continue; - } - } - } } $__textoEval.=substr($sqlString,$u); return $__textoEval; - } - + } + /** * microtime_float * * @return array_sum(explode(' ',microtime())) - */ - /*public static*/ - public function microtime_float () - { - return array_sum( explode( ' ', microtime() ) ); - } - - /** - * Return the System defined constants and Application variables - * Constants: SYS_* - * Sessions : USER_* , URS_* - */ - public function getSystemConstants($params = null) - { - $t1 = g::microtime_float(); - $sysCon = array(); - - if (defined("SYS_LANG")) { - $sysCon["SYS_LANG"] = SYS_LANG; - } - - if (defined("SYS_SKIN")) { - $sysCon["SYS_SKIN"] = SYS_SKIN; - } - - if (defined("SYS_SYS")) { - $sysCon["SYS_SYS"] = SYS_SYS; + */ + /*public static*/ + public function microtime_float () + { + return array_sum( explode( ' ', microtime() ) ); } - $sysCon["APPLICATION"] = (isset($_SESSION["APPLICATION"]))? $_SESSION["APPLICATION"] : ""; - $sysCon["PROCESS"] = (isset($_SESSION["PROCESS"]))? $_SESSION["PROCESS"] : ""; - $sysCon["TASK"] = (isset($_SESSION["TASK"]))? $_SESSION["TASK"] : ""; - $sysCon["INDEX"] = (isset($_SESSION["INDEX"]))? $_SESSION["INDEX"] : ""; - $sysCon["USER_LOGGED"] = (isset($_SESSION["USER_LOGGED"]))? $_SESSION["USER_LOGGED"] : ""; - $sysCon["USR_USERNAME"] = (isset($_SESSION["USR_USERNAME"]))? $_SESSION["USR_USERNAME"] : ""; - - //############################################################################################### - // Added for compatibility betweek aplication called from web Entry that uses just WS functions - //############################################################################################### - - if ($params != null) { - if (isset($params->option)) { - switch ($params->option) { - case "STORED SESSION": - if (isset($params->SID)) { - g::LoadClass("sessions"); - - $oSessions = new Sessions($params->SID); - $sysCon = array_merge($sysCon, $oSessions->getGlobals()); - } - break; - } - } - - if (isset($params->appData) && is_array($params->appData)) { - $sysCon["APPLICATION"] = $params->appData["APPLICATION"]; - $sysCon["PROCESS"] = $params->appData["PROCESS"]; - $sysCon["TASK"] = $params->appData["TASK"]; - $sysCon["INDEX"] = $params->appData["INDEX"]; - - if (empty($sysCon["USER_LOGGED"])) { - $sysCon["USER_LOGGED"] = $params->appData["USER_LOGGED"]; - $sysCon["USR_USERNAME"] = $params->appData["USR_USERNAME"]; - } - } - } - - return $sysCon; - } - /** - * Escapes special characters in a string for use in a SQL statement - * @author David Callizaya - * @param string $sqlString The string to be escaped - * @param string $DBEngine Target DBMS - */ + * Return the System defined constants and Application variables + * Constants: SYS_* + * Sessions : USER_* , URS_* + */ + public function getSystemConstants($params = null) + { + $t1 = g::microtime_float(); + $sysCon = array(); + + if (defined("SYS_LANG")) { + $sysCon["SYS_LANG"] = SYS_LANG; + } + + if (defined("SYS_SKIN")) { + $sysCon["SYS_SKIN"] = SYS_SKIN; + } + + if (defined("SYS_SYS")) { + $sysCon["SYS_SYS"] = SYS_SYS; + } + + $sysCon["APPLICATION"] = (isset($_SESSION["APPLICATION"]))? $_SESSION["APPLICATION"] : ""; + $sysCon["PROCESS"] = (isset($_SESSION["PROCESS"]))? $_SESSION["PROCESS"] : ""; + $sysCon["TASK"] = (isset($_SESSION["TASK"]))? $_SESSION["TASK"] : ""; + $sysCon["INDEX"] = (isset($_SESSION["INDEX"]))? $_SESSION["INDEX"] : ""; + $sysCon["USER_LOGGED"] = (isset($_SESSION["USER_LOGGED"]))? $_SESSION["USER_LOGGED"] : ""; + $sysCon["USR_USERNAME"] = (isset($_SESSION["USR_USERNAME"]))? $_SESSION["USR_USERNAME"] : ""; + + //############################################################################################### + // Added for compatibility betweek aplication called from web Entry that uses just WS functions + //############################################################################################### + + if ($params != null) { + if (isset($params->option)) { + switch ($params->option) { + case "STORED SESSION": + if (isset($params->SID)) { + g::LoadClass("sessions"); + + $oSessions = new Sessions($params->SID); + $sysCon = array_merge($sysCon, $oSessions->getGlobals()); + } + break; + } + } + + if (isset($params->appData) && is_array($params->appData)) { + $sysCon["APPLICATION"] = $params->appData["APPLICATION"]; + $sysCon["PROCESS"] = $params->appData["PROCESS"]; + $sysCon["TASK"] = $params->appData["TASK"]; + $sysCon["INDEX"] = $params->appData["INDEX"]; + + if (empty($sysCon["USER_LOGGED"])) { + $sysCon["USER_LOGGED"] = $params->appData["USER_LOGGED"]; + $sysCon["USR_USERNAME"] = $params->appData["USR_USERNAME"]; + } + } + } + + return $sysCon; + } + + /** + * Escapes special characters in a string for use in a SQL statement + * @author David Callizaya + * @param string $sqlString The string to be escaped + * @param string $DBEngine Target DBMS + */ public function sqlEscape ($sqlString, $DBEngine = DB_ADAPTER) - { - $DBEngine = DB_ADAPTER; - switch ($DBEngine) { - case 'mysql': - $con = Propel::getConnection( 'workflow' ); - return mysql_real_escape_string( stripslashes( $sqlString ), $con->getResource() ); - break; - case 'myxml': - $sqlString = str_replace( '"', '""', $sqlString ); - return str_replace( "'", "''", $sqlString ); - break; - default: - return addslashes( stripslashes( $sqlString ) ); - break; - } - } + { + $DBEngine = DB_ADAPTER; + switch ($DBEngine) { + case 'mysql': + $con = Propel::getConnection( 'workflow' ); + return mysql_real_escape_string( stripslashes( $sqlString ), $con->getResource() ); + break; + case 'myxml': + $sqlString = str_replace( '"', '""', $sqlString ); + return str_replace( "'", "''", $sqlString ); + break; + default: + return addslashes( stripslashes( $sqlString ) ); + break; + } + } - /** - * Load a template - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strTemplateName - * @return void - */ - public function LoadTemplate ($strTemplateName) - { - if ($strTemplateName == '') { - return; - } + /** + * Load a template + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strTemplateName + * @return void + */ + public function LoadTemplate ($strTemplateName) + { + if ($strTemplateName == '') { + return; + } - $temp = $strTemplateName . ".php"; - $file = g::ExpandPath( 'templates' ) . $temp; - // Check if its a user template - if (file_exists( $file )) { - //require_once( $file ); - include ($file); - } else { - // Try to get the global system template - $file = PATH_TEMPLATE . PATH_SEP . $temp; - //require_once( $file ); - if (file_exists( $file )) { - include ($file); - } - } - } + $temp = $strTemplateName . ".php"; + $file = g::ExpandPath( 'templates' ) . $temp; + // Check if its a user template + if (file_exists( $file )) { + //require_once( $file ); + include ($file); + } else { + // Try to get the global system template + $file = PATH_TEMPLATE . PATH_SEP . $temp; + //require_once( $file ); + if (file_exists( $file )) { + include ($file); + } + } + } - /** - * verify path - * - * @author Fernando Ontiveros Lira - * @access public - * @param string $strPath path - * @param boolean $createPath if true this public function will create the path - * @return boolean - */ - public function verifyPath ($strPath, $createPath = false) - { - $folder_path = strstr( $strPath, '.' ) ? dirname( $strPath ) : $strPath; + /** + * verify path + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $strPath path + * @param boolean $createPath if true this public function will create the path + * @return boolean + */ + public function verifyPath ($strPath, $createPath = false) + { + $folder_path = strstr( $strPath, '.' ) ? dirname( $strPath ) : $strPath; - if (file_exists( $strPath ) || @is_dir( $strPath )) { - return true; - } else { - if ($createPath) { - //TODO:: Define Environment constants: Devel (0777), Production (0770), ... - G::mk_dir( $strPath, 0777 ); - } else { - return false; - } - } - return false; - } + if (file_exists( $strPath ) || @is_dir( $strPath )) { + return true; + } else { + if ($createPath) { + //TODO:: Define Environment constants: Devel (0777), Production (0770), ... + G::mk_dir( $strPath, 0777 ); + } else { + return false; + } + } + return false; + } - /** - * getformatedDate - * - * @param date $date - * @param string $format default value 'yyyy-mm-dd', - * @param string $lang default value '' - * - * @return string $ret - */ - public function getformatedDate ($date, $format = 'yyyy-mm-dd', $lang = '') - { - /** - * ****************************************************************************************************** - * if the year is 2008 and the format is yy then -> 08 - * if the year is 2008 and the format is yyyy then -> 2008 - * - * if the month is 05 and the format is mm then -> 05 - * if the month is 05 and the format is m and the month is less than 10 then -> 5 else digit normal - * if the month is 05 and the format is MM or M then -> May - * - * if the day is 5 and the format is dd then -> 05 - * if the day is 5 and the format is d and the day is less than 10 then -> 5 else digit normal - * if the day is 5 and the format is DD or D then -> five - * ******************************************************************************************************* - */ + /** + * getformatedDate + * + * @param date $date + * @param string $format default value 'yyyy-mm-dd', + * @param string $lang default value '' + * + * @return string $ret + */ + public function getformatedDate ($date, $format = 'yyyy-mm-dd', $lang = '') + { + /** + * ****************************************************************************************************** + * if the year is 2008 and the format is yy then -> 08 + * if the year is 2008 and the format is yyyy then -> 2008 + * + * if the month is 05 and the format is mm then -> 05 + * if the month is 05 and the format is m and the month is less than 10 then -> 5 else digit normal + * if the month is 05 and the format is MM or M then -> May + * + * if the day is 5 and the format is dd then -> 05 + * if the day is 5 and the format is d and the day is less than 10 then -> 5 else digit normal + * if the day is 5 and the format is DD or D then -> five + * ******************************************************************************************************* + */ - //scape the literal - switch ($lang) { - case 'es': - $format = str_replace( ' de ', '[of]', $format ); - break; - } + //scape the literal + switch ($lang) { + case 'es': + $format = str_replace( ' de ', '[of]', $format ); + break; + } - //first we must formatted the string - $format = str_replace( 'yyyy', '{YEAR}', $format ); - $format = str_replace( 'yy', '{year}', $format ); + //first we must formatted the string + $format = str_replace( 'yyyy', '{YEAR}', $format ); + $format = str_replace( 'yy', '{year}', $format ); - $format = str_replace( 'mm', '{YONTH}', $format ); - $format = str_replace( 'm', '{month}', $format ); - $format = str_replace( 'M', '{XONTH}', $format ); + $format = str_replace( 'mm', '{YONTH}', $format ); + $format = str_replace( 'm', '{month}', $format ); + $format = str_replace( 'M', '{XONTH}', $format ); - $format = str_replace( 'dd', '{DAY}', $format ); - $format = str_replace( 'd', '{day}', $format ); + $format = str_replace( 'dd', '{DAY}', $format ); + $format = str_replace( 'd', '{day}', $format ); - $format = str_replace( 'h', '{h}', $format ); - $format = str_replace( 'i', '{i}', $format ); - $format = str_replace( 's', '{s}', $format ); + $format = str_replace( 'h', '{h}', $format ); + $format = str_replace( 'i', '{i}', $format ); + $format = str_replace( 's', '{s}', $format ); - if ($lang === '') { - $lang = defined( SYS_LANG ) ? SYS_LANG : 'en'; - } - $aux = explode( ' ', $date ); //para dividir la fecha del dia - $date = explode( '-', isset( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. - $time = explode( ':', isset( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. + if ($lang === '') { + $lang = defined( SYS_LANG ) ? SYS_LANG : 'en'; + } + $aux = explode( ' ', $date ); //para dividir la fecha del dia + $date = explode( '-', isset( $aux[0] ) ? $aux[0] : '00-00-00' ); //para obtener los dias, el mes, y el año. + $time = explode( ':', isset( $aux[1] ) ? $aux[1] : '00:00:00' ); //para obtener las horas, minutos, segundos. - $year = (int) ((isset( $date[0] )) ? $date[0] : '0'); //year - $month = (int) ((isset( $date[1] )) ? $date[1] : '0'); //month - $day = (int) ((isset( $date[2] )) ? $date[2] : '0'); //day + $year = (int) ((isset( $date[0] )) ? $date[0] : '0'); //year + $month = (int) ((isset( $date[1] )) ? $date[1] : '0'); //month + $day = (int) ((isset( $date[2] )) ? $date[2] : '0'); //day - $h = isset( $time[0] ) ? $time[0] : '00'; //hour - $i = isset( $time[1] ) ? $time[1] : '00'; //minute - $s = isset( $time[2] ) ? $time[2] : '00'; //second + $h = isset( $time[0] ) ? $time[0] : '00'; //hour + $i = isset( $time[1] ) ? $time[1] : '00'; //minute + $s = isset( $time[2] ) ? $time[2] : '00'; //second - $MONTHS = Array (); - for ($i = 1; $i <= 12; $i ++) { - $MONTHS[$i] = g::LoadTranslation( "ID_MONTH_$i", $lang ); - } + $MONTHS = Array (); + for ($i = 1; $i <= 12; $i ++) { + $MONTHS[$i] = g::LoadTranslation( "ID_MONTH_$i", $lang ); + } - $d = (int) $day; - $dd = g::complete_field( $day, 2, 1 ); + $d = (int) $day; + $dd = g::complete_field( $day, 2, 1 ); - //missing D + //missing D - $M = $MONTHS[$month]; - $m = (int) $month; - $mm = g::complete_field( $month, 2, 1 ); + $M = $MONTHS[$month]; + $m = (int) $month; + $mm = g::complete_field( $month, 2, 1 ); - $yy = substr( $year, strlen( $year ) - 2, 2 ); - $yyyy = $year; + $yy = substr( $year, strlen( $year ) - 2, 2 ); + $yyyy = $year; - $names = array ('{day}','{DAY}','{month}','{YONTH}','{XONTH}','{year}','{YEAR}','{h}','{i}','{s}' - ); - $values = array ($d,$dd,$m,$mm,$M,$yy,$yyyy,$h,$i,$s - ); + $names = array ('{day}','{DAY}','{month}','{YONTH}','{XONTH}','{year}','{YEAR}','{h}','{i}','{s}' + ); + $values = array ($d,$dd,$m,$mm,$M,$yy,$yyyy,$h,$i,$s + ); - $ret = str_replace( $names, $values, $format ); + $ret = str_replace( $names, $values, $format ); - //recovering the original literal - switch ($lang) { - case 'es': - $ret = str_replace( '[of]', ' de ', $ret ); - break; - } + //recovering the original literal + switch ($lang) { + case 'es': + $ret = str_replace( '[of]', ' de ', $ret ); + break; + } - return $ret; - } + return $ret; + } - /** - * - * @author Erik Amaru Ortiz - * @name complete_field($string, $lenght, $type={1:number/2:string/3:float}) - */ - public function complete_field ($campo, $long, $tipo) - { - $campo = trim( $campo ); - switch ($tipo) { - case 1: //number - $long = $long - strlen( $campo ); - for ($i = 1; $i <= $long; $i ++) { - $campo = "0" . $campo; - } - break; - case 2: //string - $long = $long - strlen( $campo ); - for ($i = 1; $i <= $long; $i ++) { - $campo = " " . $campo; - } - break; - case 3: //float - if ($campo != "0") { - $vals = explode( ".", $long ); - $ints = $vals[0]; + /** + * + * @author Erik Amaru Ortiz + * @name complete_field($string, $lenght, $type={1:number/2:string/3:float}) + */ + public function complete_field ($campo, $long, $tipo) + { + $campo = trim( $campo ); + switch ($tipo) { + case 1: //number + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = "0" . $campo; + } + break; + case 2: //string + $long = $long - strlen( $campo ); + for ($i = 1; $i <= $long; $i ++) { + $campo = " " . $campo; + } + break; + case 3: //float + if ($campo != "0") { + $vals = explode( ".", $long ); + $ints = $vals[0]; - $decs = $vals[1]; + $decs = $vals[1]; - $valscampo = explode( ".", $campo ); + $valscampo = explode( ".", $campo ); - $intscampo = $valscampo[0]; - $decscampo = $valscampo[1]; + $intscampo = $valscampo[0]; + $decscampo = $valscampo[1]; - $ints = $ints - strlen( $intscampo ); + $ints = $ints - strlen( $intscampo ); - for ($i = 1; $i <= $ints; $i ++) { - $intscampo = "0" . $intscampo; - } + for ($i = 1; $i <= $ints; $i ++) { + $intscampo = "0" . $intscampo; + } - //los decimales pueden ser 0 uno o dos - $decs = $decs - strlen( $decscampo ); - for ($i = 1; $i <= $decs; $i ++) { - $decscampo = $decscampo . "0"; - } + //los decimales pueden ser 0 uno o dos + $decs = $decs - strlen( $decscampo ); + for ($i = 1; $i <= $decs; $i ++) { + $decscampo = $decscampo . "0"; + } - $campo = $intscampo . "." . $decscampo; - } else { - $vals = explode( ".", $long ); - $ints = $vals[0]; - $decs = $vals[1]; + $campo = $intscampo . "." . $decscampo; + } else { + $vals = explode( ".", $long ); + $ints = $vals[0]; + $decs = $vals[1]; - $campo = ""; - for ($i = 1; $i <= $ints; $i ++) { - $campo = "0" . $campo; - } - $campod = ""; - for ($i = 1; $i <= $decs; $i ++) { - $campod = "0" . $campod; - } + $campo = ""; + for ($i = 1; $i <= $ints; $i ++) { + $campo = "0" . $campo; + } + $campod = ""; + for ($i = 1; $i <= $decs; $i ++) { + $campod = "0" . $campod; + } - $campo = $campo . "." . $campod; - } - break; - } - return $campo; - } + $campo = $campo . "." . $campod; + } + break; + } + return $campo; + } - /** - * evalJScript - * - * @param string $c - * - * @return void - */ - public function evalJScript ($c) - { - print ("") ; - } - + /** + * evalJScript + * + * @param string $c + * + * @return void + */ + public function evalJScript ($c) + { + print ("") ; + } -} + + } From ed7b355d65583df8a0368a23b5b9413977381e6f Mon Sep 17 00:00:00 2001 From: user Date: Fri, 9 Nov 2012 13:59:06 -0400 Subject: [PATCH 06/70] Removing browser_detection function, cause it is too big Adding get_current_browser instead to get browse name info only. + generateUniqueID() used in authentification process. --- gulliver/system/class.bootstrap.php | 657 ++++++++-------------------- 1 file changed, 180 insertions(+), 477 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index 33c8f4cb3..fd7887a92 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -1036,7 +1036,7 @@ class G } //Get Browser Info - $infoBrowser = g::browser_detection( 'full_assoc' ); + $infoBrowser = g::get_current_browser(); $browserName = $infoBrowser['browser_working']; if (isset( $infoBrowser[$browserName . '_data'] )) { if ($infoBrowser[$browserName . '_data'][0] != "") { @@ -1500,487 +1500,176 @@ class G } /** - * - * @param unknown_type $which_test - * @param unknown_type $test_excludes - * @param unknown_type $external_ua_string - * @return multitype:unknown string boolean number multitype:string unknown multitype:string Ambigous unknown multitype:string Ambigous |Ambigous unknown , multitype:string , Ambigous > + * Refactor function + * @author Ralph A. + * @return multitype:array containing browser name and type */ - public function browser_detection($which_test, $test_excludes = '', $external_ua_string = '') + public function get_current_browser() { - g::script_time(); // set script timer to start timing + static $a_full_assoc_data, $a_mobile_data, $browser_user_agent; + static $browser_working, $moz_type, $webkit_type; + + //initialize all variables with default values to prevent error + $a_full_assoc_data = ''; + $a_mobile_data = ''; + $browser_temp = ''; + $browser_working = ''; + $mobile_test = ''; + $moz_type = ''; + $ua_type = 'bot';// default to bot since you never know with bots + $webkit_type = ''; + + /* + make navigator user agent string lower case to make sure all versions get caught + isset protects against blank user agent failure. tolower also lets the script use + strstr instead of stristr, which drops overhead slightly. + */ + $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); + + // known browsers, list will be updated routinely, check back now and then + $a_browser_types = array( + array( 'opera', true, 'op', 'bro' ), + array( 'msie', true, 'ie', 'bro' ), + // webkit before gecko because some webkit ua strings say: like gecko + array( 'webkit', true, 'webkit', 'bro' ), + // konq will be using webkit soon + array( 'konqueror', true, 'konq', 'bro' ), + // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below + array( 'gecko', true, 'moz', 'bro' ), + array( 'netpositive', false, 'netp', 'bbro' ),// beos browser + array( 'lynx', false, 'lynx', 'bbro' ), // command line browser + array( 'elinks ', false, 'elinks', 'bbro' ), // new version of links + array( 'elinks', false, 'elinks', 'bbro' ), // alternate id for it + array( 'links2', false, 'links2', 'bbro' ), // alternate links version + array( 'links ', false, 'links', 'bbro' ), // old name for links + array( 'links', false, 'links', 'bbro' ), // alternate id for it + array( 'w3m', false, 'w3m', 'bbro' ), // open source browser, more features than lynx/links + array( 'webtv', false, 'webtv', 'bbro' ),// junk ms webtv + array( 'amaya', false, 'amaya', 'bbro' ),// w3c browser + array( 'dillo', false, 'dillo', 'bbro' ),// linux browser, basic table support + array( 'ibrowse', false, 'ibrowse', 'bbro' ),// amiga browser + array( 'icab', false, 'icab', 'bro' ),// mac browser + array( 'crazy browser', true, 'ie', 'bro' ),// uses ie rendering engine + // search engine spider bots: + array( 'bingbot', false, 'bing', 'bot' ),// bing + array( 'exabot', false, 'exabot', 'bot' ),// exabot + array( 'googlebot', false, 'google', 'bot' ),// google + array( 'google web preview', false, 'googlewp', 'bot' ),// google preview + array( 'mediapartners-google', false, 'adsense', 'bot' ),// google adsense + array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),// old yahoo bot + array( 'yahoo! slurp', false, 'yahoo', 'bot' ), // new yahoo bot + array( 'yahoo-mm', false, 'yahoomm', 'bot' ), // gets Yahoo-MMCrawler and Yahoo-MMAudVid bots + array( 'inktomi', false, 'inktomi', 'bot' ), // inktomi bot + array( 'slurp', false, 'inktomi', 'bot' ), // inktomi bot + array( 'fast-webcrawler', false, 'fast', 'bot' ),// Fast AllTheWeb + array( 'msnbot', false, 'msn', 'bot' ),// msn search + array( 'ask jeeves', false, 'ask', 'bot' ), //jeeves/teoma + array( 'teoma', false, 'ask', 'bot' ),//jeeves teoma + array( 'scooter', false, 'scooter', 'bot' ),// altavista + array( 'openbot', false, 'openbot', 'bot' ),// openbot, from taiwan + array( 'ia_archiver', false, 'ia_archiver', 'bot' ),// ia archiver + array( 'zyborg', false, 'looksmart', 'bot' ),// looksmart + array( 'almaden', false, 'ibm', 'bot' ),// ibm almaden web crawler + array( 'baiduspider', false, 'baidu', 'bot' ),// Baiduspider asian search spider + array( 'psbot', false, 'psbot', 'bot' ),// psbot image crawler + array( 'gigabot', false, 'gigabot', 'bot' ),// gigabot crawler + array( 'naverbot', false, 'naverbot', 'bot' ),// naverbot crawler, bad bot, block + array( 'surveybot', false, 'surveybot', 'bot' ),// + array( 'boitho.com-dc', false, 'boitho', 'bot' ),//norwegian search engine + array( 'objectssearch', false, 'objectsearch', 'bot' ),// open source search engine + array( 'answerbus', false, 'answerbus', 'bot' ),// http://www.answerbus.com/, web questions + array( 'sohu-search', false, 'sohu', 'bot' ),// chinese media company, search component + array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ), + // various http utility libaries + array( 'w3c_validator', false, 'w3c', 'lib' ), // uses libperl, make first + array( 'wdg_validator', false, 'wdg', 'lib' ), // + array( 'libwww-perl', false, 'libwww-perl', 'lib' ), + array( 'jakarta commons-httpclient', false, 'jakarta', 'lib' ), + array( 'python-urllib', false, 'python-urllib', 'lib' ), + // download apps + array( 'getright', false, 'getright', 'dow' ), + array( 'wget', false, 'wget', 'dow' ),// open source downloader, obeys robots.txt + // netscape 4 and earlier tests, put last so spiders don't get caught + array( 'mozilla/4.', false, 'ns', 'bbro' ), + array( 'mozilla/3.', false, 'ns', 'bbro' ), + array( 'mozilla/2.', false, 'ns', 'bbro' ) + ); + /* + moz types array + note the order, netscape6 must come before netscape, which is how netscape 7 id's itself. + rv comes last in case it is plain old mozilla. firefox/netscape/seamonkey need to be later + Thanks to: http://www.zytrax.com/tech/web/firefox-history.html + */ + $a_moz_types = array( 'bonecho', 'camino', 'epiphany', 'firebird', 'flock', 'galeon', 'iceape', 'icecat', 'k-meleon', 'minimo', 'multizilla', 'phoenix', 'songbird', 'swiftfox', 'seamonkey', 'shiretoko', 'iceweasel', 'firefox', 'minefield', 'netscape6', 'netscape', 'rv' ); - static $a_full_assoc_data, $a_mobile_data, $a_moz_data, $a_webkit_data, $b_dom_browser, $b_repeat, $b_safe_browser, $browser_name, $browser_number, $browser_math_number, $browser_user_agent, $browser_working, $ie_version, $mobile_test, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date, $moz_type, $os_number, $os_type, $true_ie_number, $ua_type, $webkit_type, $webkit_type_number; + /* + webkit types, this is going to expand over time as webkit b$browser_namerowsers spread + konqueror is probably going to move to webkit, so this is preparing for that + It will now default to khtml. gtklauncher is the temp id for epiphany, might + change. Defaults to applewebkit, and will all show the webkit number. + */ + $a_webkit_types = array( 'arora', 'chrome', 'epiphany', 'gtklauncher', 'konqueror', 'midori', 'omniweb', 'safari', 'uzbl', 'applewebkit', 'webkit' ); - // switch off the optimization for external ua string testing. - if ( $external_ua_string ) { - $b_repeat = false; - } + /* + run through the browser_types array, break if you hit a match, if no match, assume old browser + or non dom browser. + */ + $i_count = count( $a_browser_types ); + for ($i = 0; $i < $i_count; $i++) { + //unpacks browser array, assigns to variables, need to not assign til found in string + $browser_temp = $a_browser_types[$i][0];// text string to id browser from array + if ( strstr( $browser_user_agent, $browser_temp ) ) { + $browser_working = $a_browser_types[$i][2];// working name for browser + $ua_type = $a_browser_types[$i][3];// sets whether bot or browser - /* - this makes the test only run once no matter how many times you call it since - all the variables are filled on the first run through, it's only a matter of - returning the the right ones - */ - if ( !$b_repeat ) { - //initialize all variables with default values to prevent error - $a_browser_math_number = ''; - $a_full_assoc_data = ''; - $a_full_data = ''; - $a_mobile_data = ''; - $a_moz_data = ''; - $a_os_data = ''; - $a_unhandled_browser = ''; - $a_webkit_data = ''; - $b_dom_browser = false; - $b_os_test = true; - $b_mobile_test = true; - $b_safe_browser = false; - $b_success = false;// boolean for if browser found in main test - $browser_math_number = ''; - $browser_temp = ''; - $browser_working = ''; - $browser_number = ''; - $ie_version = ''; - $mobile_test = ''; - $moz_release_date = ''; - $moz_rv = ''; - $moz_rv_full = ''; - $moz_type = ''; - $moz_number = ''; - $os_number = ''; - $os_type = ''; - $run_time = ''; - $true_ie_number = ''; - $ua_type = 'bot';// default to bot since you never know with bots - $webkit_type = ''; - $webkit_type_number = ''; + switch ( $browser_working ) { + case 'moz': + // this is to pull out specific mozilla versions, firebird, netscape etc.. + $j_count = count( $a_moz_types ); + for ($j = 0; $j < $j_count; $j++) { + if ( strstr( $browser_user_agent, $a_moz_types[$j] ) ) { + $moz_type = $a_moz_types[$j]; + break; + } + } + if ( $moz_type == 'rv' ) { + $moz_type = 'mozilla'; + } + break; + case 'webkit': + // this is to pull out specific webkit versions, safari, google-chrome etc.. + $j_count = count( $a_webkit_types ); + for ($j = 0; $j < $j_count; $j++) { + if (strstr( $browser_user_agent, $a_webkit_types[$j])) { + $webkit_type = $a_webkit_types[$j]; + break; + } + } + break; + default: + break; + } + break; + } + } + + $mobile_test = g::check_is_mobile( $browser_user_agent ); + if ( $mobile_test ) { + $a_mobile_data = g::get_mobile_data( $browser_user_agent ); + $ua_type = 'mobile'; + } - // set the excludes if required - if ( $test_excludes ) { - switch ( $test_excludes ){ - case '1': - $b_os_test = false; - break; - case '2': - $b_mobile_test = false; - break; - case '3': - $b_os_test = false; - $b_mobile_test = false; - break; - default: - die( 'Error: bad $test_excludes parameter 2 used: ' . $test_excludes ); - break; - } - } - - /* - make navigator user agent string lower case to make sure all versions get caught - isset protects against blank user agent failure. tolower also lets the script use - strstr instead of stristr, which drops overhead slightly. - */ - if ( $external_ua_string ) { - $browser_user_agent = strtolower( $external_ua_string ); - } elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { - $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); - } else { - $browser_user_agent = ''; - } - - // known browsers, list will be updated routinely, check back now and then - $a_browser_types = array( - array( 'opera', true, 'op', 'bro' ), - array( 'msie', true, 'ie', 'bro' ), - // webkit before gecko because some webkit ua strings say: like gecko - array( 'webkit', true, 'webkit', 'bro' ), - // konq will be using webkit soon - array( 'konqueror', true, 'konq', 'bro' ), - // covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below - array( 'gecko', true, 'moz', 'bro' ), - array( 'netpositive', false, 'netp', 'bbro' ),// beos browser - array( 'lynx', false, 'lynx', 'bbro' ), // command line browser - array( 'elinks ', false, 'elinks', 'bbro' ), // new version of links - array( 'elinks', false, 'elinks', 'bbro' ), // alternate id for it - array( 'links2', false, 'links2', 'bbro' ), // alternate links version - array( 'links ', false, 'links', 'bbro' ), // old name for links - array( 'links', false, 'links', 'bbro' ), // alternate id for it - array( 'w3m', false, 'w3m', 'bbro' ), // open source browser, more features than lynx/links - array( 'webtv', false, 'webtv', 'bbro' ),// junk ms webtv - array( 'amaya', false, 'amaya', 'bbro' ),// w3c browser - array( 'dillo', false, 'dillo', 'bbro' ),// linux browser, basic table support - array( 'ibrowse', false, 'ibrowse', 'bbro' ),// amiga browser - array( 'icab', false, 'icab', 'bro' ),// mac browser - array( 'crazy browser', true, 'ie', 'bro' ),// uses ie rendering engine - - // search engine spider bots: - array( 'bingbot', false, 'bing', 'bot' ),// bing - array( 'exabot', false, 'exabot', 'bot' ),// exabot - array( 'googlebot', false, 'google', 'bot' ),// google - array( 'google web preview', false, 'googlewp', 'bot' ),// google preview - array( 'mediapartners-google', false, 'adsense', 'bot' ),// google adsense - array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),// old yahoo bot - array( 'yahoo! slurp', false, 'yahoo', 'bot' ), // new yahoo bot - array( 'yahoo-mm', false, 'yahoomm', 'bot' ), // gets Yahoo-MMCrawler and Yahoo-MMAudVid bots - array( 'inktomi', false, 'inktomi', 'bot' ), // inktomi bot - array( 'slurp', false, 'inktomi', 'bot' ), // inktomi bot - array( 'fast-webcrawler', false, 'fast', 'bot' ),// Fast AllTheWeb - array( 'msnbot', false, 'msn', 'bot' ),// msn search - array( 'ask jeeves', false, 'ask', 'bot' ), //jeeves/teoma - array( 'teoma', false, 'ask', 'bot' ),//jeeves teoma - array( 'scooter', false, 'scooter', 'bot' ),// altavista - array( 'openbot', false, 'openbot', 'bot' ),// openbot, from taiwan - array( 'ia_archiver', false, 'ia_archiver', 'bot' ),// ia archiver - array( 'zyborg', false, 'looksmart', 'bot' ),// looksmart - array( 'almaden', false, 'ibm', 'bot' ),// ibm almaden web crawler - array( 'baiduspider', false, 'baidu', 'bot' ),// Baiduspider asian search spider - array( 'psbot', false, 'psbot', 'bot' ),// psbot image crawler - array( 'gigabot', false, 'gigabot', 'bot' ),// gigabot crawler - array( 'naverbot', false, 'naverbot', 'bot' ),// naverbot crawler, bad bot, block - array( 'surveybot', false, 'surveybot', 'bot' ),// - array( 'boitho.com-dc', false, 'boitho', 'bot' ),//norwegian search engine - array( 'objectssearch', false, 'objectsearch', 'bot' ),// open source search engine - array( 'answerbus', false, 'answerbus', 'bot' ),// http://www.answerbus.com/, web questions - array( 'sohu-search', false, 'sohu', 'bot' ),// chinese media company, search component - array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ), - - // various http utility libaries - array( 'w3c_validator', false, 'w3c', 'lib' ), // uses libperl, make first - array( 'wdg_validator', false, 'wdg', 'lib' ), // - array( 'libwww-perl', false, 'libwww-perl', 'lib' ), - array( 'jakarta commons-httpclient', false, 'jakarta', 'lib' ), - array( 'python-urllib', false, 'python-urllib', 'lib' ), - // download apps - array( 'getright', false, 'getright', 'dow' ), - array( 'wget', false, 'wget', 'dow' ),// open source downloader, obeys robots.txt - // netscape 4 and earlier tests, put last so spiders don't get caught - array( 'mozilla/4.', false, 'ns', 'bbro' ), - array( 'mozilla/3.', false, 'ns', 'bbro' ), - array( 'mozilla/2.', false, 'ns', 'bbro' ) - ); - - //array( '', false ); // browser array template - - /* - moz types array - note the order, netscape6 must come before netscape, which is how netscape 7 id's itself. - rv comes last in case it is plain old mozilla. firefox/netscape/seamonkey need to be later - Thanks to: http://www.zytrax.com/tech/web/firefox-history.html - */ - $a_moz_types = array( 'bonecho', 'camino', 'epiphany', 'firebird', 'flock', 'galeon', 'iceape', 'icecat', 'k-meleon', 'minimo', 'multizilla', 'phoenix', 'songbird', 'swiftfox', 'seamonkey', 'shiretoko', 'iceweasel', 'firefox', 'minefield', 'netscape6', 'netscape', 'rv' ); - - /* - webkit types, this is going to expand over time as webkit browsers spread - konqueror is probably going to move to webkit, so this is preparing for that - It will now default to khtml. gtklauncher is the temp id for epiphany, might - change. Defaults to applewebkit, and will all show the webkit number. - */ - $a_webkit_types = array( 'arora', 'chrome', 'epiphany', 'gtklauncher', 'konqueror', 'midori', 'omniweb', 'safari', 'uzbl', 'applewebkit', 'webkit' ); - - /* - run through the browser_types array, break if you hit a match, if no match, assume old browser - or non dom browser, assigns false value to $b_success. - */ - $i_count = count( $a_browser_types ); - for ($i = 0; $i < $i_count; $i++) { - //unpacks browser array, assigns to variables, need to not assign til found in string - $browser_temp = $a_browser_types[$i][0];// text string to id browser from array - - if ( strstr( $browser_user_agent, $browser_temp ) ) { - /* - it defaults to true, will become false below if needed - this keeps it easier to keep track of what is safe, only - explicit false assignment will make it false. - */ - $b_safe_browser = true; - $browser_name = $browser_temp;// text string to id browser from array - - // assign values based on match of user agent string - $b_dom_browser = $a_browser_types[$i][1];// hardcoded dom support from array - $browser_working = $a_browser_types[$i][2];// working name for browser - $ua_type = $a_browser_types[$i][3];// sets whether bot or browser - - switch ( $browser_working ) { - // this is modified quite a bit, now will return proper netscape version number - // check your implementation to make sure it works - case 'ns': - $b_safe_browser = false; - $browser_number = g::get_item_version( $browser_user_agent, 'mozilla' ); - break; - case 'moz': - /* - note: The 'rv' test is not absolute since the rv number is very different on - different versions, for example Galean doesn't use the same rv version as Mozilla, - neither do later Netscapes, like 7.x. For more on this, read the full mozilla - numbering conventions here: http://www.mozilla.org/releases/cvstags.html - */ - // this will return alpha and beta version numbers, if present - $moz_rv_full = g::get_item_version( $browser_user_agent, 'rv' ); - // this slices them back off for math comparisons - $moz_rv = substr( $moz_rv_full, 0, 3 ); - - // this is to pull out specific mozilla versions, firebird, netscape etc.. - $j_count = count( $a_moz_types ); - for ($j = 0; $j < $j_count; $j++) { - if ( strstr( $browser_user_agent, $a_moz_types[$j] ) ) { - $moz_type = $a_moz_types[$j]; - $moz_number = g::get_item_version( $browser_user_agent, $moz_type ); - break; - } - } - /* - this is necesary to protect against false id'ed moz'es and new moz'es. - this corrects for galeon, or any other moz browser without an rv number - */ - if ( !$moz_rv ) { - // you can use this if you are running php >= 4.2 - if ( function_exists( 'floatval' ) ) { - $moz_rv = floatval( $moz_number ); - } else { - $moz_rv = substr( $moz_number, 0, 3 ); - } - $moz_rv_full = $moz_number; - } - // this corrects the version name in case it went to the default 'rv' for the test - if ( $moz_type == 'rv' ) { - $moz_type = 'mozilla'; - } - - //the moz version will be taken from the rv number, see notes above for rv problems - $browser_number = $moz_rv; - // gets the actual release date, necessary if you need to do functionality tests - g::get_set_count( 'set', 0 ); - $moz_release_date = g::get_item_version( $browser_user_agent, 'gecko/' ); - /* - Test for mozilla 0.9.x / netscape 6.x - test your javascript/CSS to see if it works in these mozilla releases, if it - does, just default it to: $b_safe_browser = true; - */ - if ( ( $moz_release_date < 20020400 ) || ( $moz_rv < 1 ) ) { - $b_safe_browser = false; - } - break; - case 'ie': - /* - note we're adding in the trident/ search to return only first instance in case - of msie 8, and we're triggering the break last condition in the test, as well - as the test for a second search string, trident/ - */ - $browser_number = g::get_item_version( $browser_user_agent, $browser_name, true, 'trident/' ); - // construct the proper real number if it's in compat mode and msie 8.0/9.0 - if ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/5' ) ) { - // note that 7.0 becomes 9 when adding 1, but if it's 7.1 it will be 9.1 - $true_ie_number = $browser_number + 2; - } elseif ( strstr( $browser_number, '7.' ) && strstr( $browser_user_agent, 'trident/4' ) ) { - // note that 7.0 becomes 8 when adding 1, but if it's 7.1 it will be 8.1 - $true_ie_number = $browser_number + 1; - } - // the 9 series is finally standards compatible, html 5 etc, so worth a new id - if ( $browser_number >= 9 ) { - $ie_version = 'ie9x'; - } elseif ( $browser_number >= 7 ) { - $ie_version = 'ie7x'; - } elseif ( strstr( $browser_user_agent, 'mac') ) { - $ie_version = 'ieMac'; - } elseif ( $browser_number >= 5 ) { - $ie_version = 'ie5x'; - } elseif ( ( $browser_number > 3 ) && ( $browser_number < 5 ) ) { - $b_dom_browser = false; - $ie_version = 'ie4'; - // this depends on what you're using the script for, make sure this fits your needs - $b_safe_browser = true; - } else { - $ie_version = 'old'; - $b_dom_browser = false; - $b_safe_browser = false; - } - break; - case 'op': - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - // opera is leaving version at 9.80 (or xx) for 10.x - see this for explanation - // http://dev.opera.com/articles/view/opera-ua-string-changes/ - if ( strstr( $browser_number, '9.' ) && strstr( $browser_user_agent, 'version/' ) ) { - g::get_set_count( 'set', 0 ); - $browser_number = g::get_item_version( $browser_user_agent, 'version/' ); - } - - if ( $browser_number < 5 ) { - $b_safe_browser = false; - } - break; - case 'webkit': - // note that this is the Webkit version number - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - // this is to pull out specific webkit versions, safari, google-chrome etc.. - $j_count = count( $a_webkit_types ); - for ($j = 0; $j < $j_count; $j++) { - if (strstr( $browser_user_agent, $a_webkit_types[$j])) { - $webkit_type = $a_webkit_types[$j]; - if ( $webkit_type == 'omniweb' ) { - g::get_set_count( 'set', 2 ); - } - $webkit_type_number = g::get_item_version( $browser_user_agent, $webkit_type ); - // epiphany hack - if ( $a_webkit_types[$j] == 'gtklauncher' ) { - $browser_name = 'epiphany'; - } else { - $browser_name = $a_webkit_types[$j]; - } - break; - } - } - break; - default: - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - break; - } - // the browser was id'ed - $b_success = true; - break; - } - } - - //assigns defaults if the browser was not found in the loop test - if ( !$b_success ) { - /* - this will return the first part of the browser string if the above id's failed - usually the first part of the browser string has the navigator useragent name/version in it. - This will usually correctly id the browser and the browser number if it didn't get - caught by the above routine. - If you want a '' to do a if browser == '' type test, just comment out all lines below - except for the last line, and uncomment the last line. If you want undefined values, - the browser_name is '', you can always test for that - */ - // delete this part if you want an unknown browser returned - $browser_name = substr( $browser_user_agent, 0, strcspn( $browser_user_agent , '();') ); - // this extracts just the browser name from the string, if something usable was found - if ( $browser_name && preg_match( '/[^0-9][a-z]*-*\ *[a-z]*\ *[a-z]*/', $browser_name, $a_unhandled_browser ) ) { - $browser_name = $a_unhandled_browser[0]; - if ( $browser_name == 'blackberry' ) { - g::get_set_count( 'set', 0 ); - } - $browser_number = g::get_item_version( $browser_user_agent, $browser_name ); - } else { - $browser_name = 'NA'; - $browser_number = 'NA'; - } - } - // get os data, mac os x test requires browser/version information, this is a change from older scripts - if ($b_os_test) { - $a_os_data = g::get_os_data( $browser_user_agent, $browser_working, $browser_number ); - $os_type = $a_os_data[0];// os name, abbreviated - $os_number = $a_os_data[1];// os number or version if available - } - /* - this ends the run through once if clause, set the boolean - to true so the function won't retest everything - */ - $b_repeat = true; - if ($browser_number && preg_match( '/[0-9]*\.*[0-9]*/', $browser_number, $a_browser_math_number ) ) { - $browser_math_number = $a_browser_math_number[0]; - } - if ( $b_mobile_test ) { - $mobile_test = g::check_is_mobile( $browser_user_agent ); - if ( $mobile_test ) { - $a_mobile_data = g::get_mobile_data( $browser_user_agent ); - $ua_type = 'mobile'; - } - } - } - - switch ($which_test) { - case 'math_number': - $which_test = 'browser_math_number'; - break; - case 'number': - $which_test = 'browser_number'; - break; - case 'browser': - $which_test = 'browser_working'; - break; - case 'moz_version': - $which_test = 'moz_data'; - break; - case 'true_msie_version': - $which_test = 'true_ie_number'; - break; - case 'type': - $which_test = 'ua_type'; - break; - case 'webkit_version': - $which_test = 'webkit_data'; - break; - } - /* - assemble these first so they can be included in full return data, using static variables - Note that there's no need to keep repacking these every time the script is called - */ - if (!$a_moz_data) { - $a_moz_data = array( $moz_type, $moz_number, $moz_rv, $moz_rv_full, $moz_release_date ); - } - if (!$a_webkit_data) { - $a_webkit_data = array( $webkit_type, $webkit_type_number, $browser_number ); - } - $run_time = g::script_time(); - - if ( !$a_full_assoc_data ) { - $a_full_assoc_data = array( - 'browser_working' => $browser_working, - 'browser_number' => $browser_number, - 'ie_version' => $ie_version, - 'dom' => $b_dom_browser, - 'safe' => $b_safe_browser, - 'os' => $os_type, - 'os_number' => $os_number, - 'browser_name' => $browser_name, - 'ua_type' => $ua_type, - 'browser_math_number' => $browser_math_number, - 'moz_data' => $a_moz_data, - 'webkit_data' => $a_webkit_data, - 'mobile_test' => $mobile_test, - 'mobile_data' => $a_mobile_data, - 'true_ie_number' => $true_ie_number, - 'run_time' => $run_time - ); - } - - // return parameters, either full data arrays, or by associative array index key - switch ($which_test) { - // returns all relevant browser information in an array with standard numberic indexes - case 'full': - $a_full_data = array($browser_working, - $browser_number, - $ie_version, - $b_dom_browser, - $b_safe_browser, - $os_type, - $os_number, - $browser_name, - $ua_type, - $browser_math_number, - $a_moz_data, - $a_webkit_data, - $mobile_test, - $a_mobile_data, - $true_ie_number, - $run_time - ); - return $a_full_data; - break; - case 'full_assoc': - return $a_full_assoc_data; - break; - default: - # check to see if the data is available, otherwise it's user typo of unsupported option - if (isset( $a_full_assoc_data[$which_test])) { - return $a_full_assoc_data[$which_test]; - } else { - die( "You passed the browser detector an unsupported option for parameter 1: " . $which_test ); - } - break; - } + $a_full_assoc_data = array( + 'browser_working' => $browser_working, + 'ua_type' => $ua_type, + 'moz_data' => array($moz_type), + 'webkit_data' => array($webkit_type), + 'mobile_data' => array($a_mobile_data), + ); + + return $a_full_assoc_data; } - + /** * track total script execution time */ @@ -2978,6 +2667,20 @@ class G { print ("") ; } - - + + /** + * Generate random number + * + * @author Fernando Ontiveros Lira + * @access public + * @return int + */ + public function generateUniqueID () + { + do { + $sUID = str_replace( '.', '0', uniqid( rand( 0, 999999999 ), true ) ); + } while (strlen( $sUID ) != 32); + return $sUID; + //return strtoupper(substr(uniqid(rand(0, 9), false),0,14)); + } } From bdceea960fe73631904f4a641472f85a606df4de Mon Sep 17 00:00:00 2001 From: user Date: Fri, 9 Nov 2012 16:30:52 -0400 Subject: [PATCH 07/70] Adding encryptLink function --- gulliver/system/class.bootstrap.php | 85 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index fd7887a92..62c71412b 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -576,42 +576,42 @@ class G public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '') { global $G_CONTENT; global $G_TEMPLATE; - global $G_SKIN; - global $G_PUBLISH; + global $G_SKIN; + global $G_PUBLISH; - $G_CONTENT = $objContent; - $G_TEMPLATE = $strTemplate; - $G_SKIN = $strSkin; + $G_CONTENT = $objContent; + $G_TEMPLATE = $strTemplate; + $G_SKIN = $strSkin; - try { - $file = g::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; - include $file; - $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); - $skinEngine->setLayout ( $layout ); - $skinEngine->dispatch (); - } catch ( Exception $e ) { - global $G_PUBLISH; - if (is_null ( $G_PUBLISH )) { - $G_PUBLISH = new Publisher (); - } - if (count ( $G_PUBLISH->Parts ) == 1) { - array_shift ( $G_PUBLISH->Parts ); - } - global $oHeadPublisher; - $leimnudInitString = $oHeadPublisher->leimnudInitString; - $oHeadPublisher->clearScripts (); - $oHeadPublisher->leimnudInitString = $leimnudInitString; - $oHeadPublisher->addScriptFile ( '/js/maborak/core/maborak.js' ); - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', null, array ( - 'MESSAGE' => $e->getMessage () - ) ); - if (class_exists ( 'SkinEngine' )) { - $skinEngine = new SkinEngine ( 'publish', 'blank', '' ); - $skinEngine->dispatch (); - } else { - die ( $e->getMessage () ); - } - } + try { + $file = g::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; + include $file; + $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); + $skinEngine->setLayout ( $layout ); + $skinEngine->dispatch (); + } catch ( Exception $e ) { + global $G_PUBLISH; + if (is_null ( $G_PUBLISH )) { + $G_PUBLISH = new Publisher (); + } + if (count ( $G_PUBLISH->Parts ) == 1) { + array_shift ( $G_PUBLISH->Parts ); + } + global $oHeadPublisher; + $leimnudInitString = $oHeadPublisher->leimnudInitString; + $oHeadPublisher->clearScripts (); + $oHeadPublisher->leimnudInitString = $leimnudInitString; + $oHeadPublisher->addScriptFile ( '/js/maborak/core/maborak.js' ); + $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/showMessage', null, array ( + 'MESSAGE' => $e->getMessage () + ) ); + if (class_exists ( 'SkinEngine' )) { + $skinEngine = new SkinEngine ( 'publish', 'blank', '' ); + $skinEngine->dispatch (); + } else { + die ( $e->getMessage () ); + } + } } /** @@ -2683,4 +2683,21 @@ class G return $sUID; //return strtoupper(substr(uniqid(rand(0, 9), false),0,14)); } + + /** + * Encrypt URL + * + * @author Fernando Ontiveros Lira + * @access public + * @param string $urlLink + * @return string + */ + public function encryptlink ($url) + { + if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { + return urlencode( G::encrypt( $url, URL_KEY ) ); + } else { + return $url; + } + } } From b5c11b4198cec8e6241c2faa0e964b9701e92272 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Mon, 12 Nov 2012 14:44:44 -0400 Subject: [PATCH 08/70] SPEEDY first version of boostrap.php, with many changes --- gulliver/system/class.bootstrap.php | 551 ++++++++---------- gulliver/system/class.g.php | 366 +----------- gulliver/system/class.xmlform.php | 5 +- .../engine/classes/class.dashletRssReader.php | 4 +- workflow/engine/classes/class.memcached.php | 2 +- .../engine/classes/class.pluginRegistry.php | 2 +- workflow/engine/methods/login/login.php | 4 +- workflow/engine/methods/login/sysLogin.php | 11 +- .../methods/processes/processes_Ajax.php | 6 +- workflow/engine/methods/tasks/tasks_Ajax.php | 5 +- workflow/public_html/bootstrap.php | 280 +++++---- workflow/public_html/sysGeneric.php | 1 - 12 files changed, 444 insertions(+), 793 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index 62c71412b..9a2681ac2 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -1,14 +1,101 @@ 0,'debug_sql' => 0,'debug_time' => 0,'debug_calendar' => 0,'wsdl_cache' => 1,'memory_limit' => '128M','time_zone' => 'America/New_York','memcached' => 0,'memcached_server' => '','default_skin' => 'classic','default_lang' => 'en','proxy_host' => '','proxy_port' => '','proxy_user' => '','proxy_pass' => '' + ); + + // read the global env.ini configuration file + if ($readGlobalIniFile && ($globalConf = @parse_ini_file( $globalIniFile )) !== false) { + $config = array_merge( $config, $globalConf ); + } + + // Workspace environment configuration + if ($readWsIniFile && ($wsConf = @parse_ini_file( $wsIniFile )) !== false) { + $config = array_merge( $config, $wsConf ); + } + + // validation debug config, only binary value is valid; debug = 1, to enable + $config['debug'] = $config['debug'] == 1 ? 1 : 0; + + if ($config['proxy_pass'] != '') { + $config['proxy_pass'] = G::decrypt( $config['proxy_pass'], 'proxy_pass' ); + } + + $md5 = array (); + if ($readGlobalIniFile) { + $md5[] = md5_file( $globalIniFile ); + } + if ($readWsIniFile) { + $md5[] = md5_file( $wsIniFile ); + } + $hash = implode( '-', $md5 ); + + $_SESSION['PROCESSMAKER_ENV'] = $config; + $_SESSION['PROCESSMAKER_ENV_HASH'] = $hash; + + return $config; + } + + + //below this line, still not approved methods + /** * mk_dir , copied from class.G.php * @@ -217,191 +304,101 @@ class G * @param string $downloadFileName * @return string */ - public function streamFile($file, $download = false, $downloadFileName = '') { - require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); - $folderarray = explode ( '/', $file ); - $typearray = explode ( '.', basename ( $file ) ); - $typefile = $typearray [count ( $typearray ) - 1]; - $filename = $file; + public function streamFile ($file, $download = false, $downloadFileName = '') + { + $folderarray = explode( '/', $file ); + $typearray = explode( '.', basename( $file ) ); + $typefile = $typearray[count( $typearray ) - 1]; + $filename = $file; - // trick to generate the translation.language.js file , merging two - // files and then minified the content. - if (strtolower ( $typefile ) == 'js' && $typearray [0] == 'translation') { - $output = g::streamJSTranslationFile ( $filename, $typearray [1] ); - print $output; - return; - } + //trick to generate the translation.language.js file , merging two files + if (strtolower( $typefile ) == 'js' && $typearray[0] == 'translation') { + Bootstrap::sendHeaders( $filename, 'text/javascript', $download, $downloadFileName ); + $output = Bootstrap::streamJSTranslationFile( $filename, $typearray[1] ); + print $output; + return; + } - // trick to generate the big css file for ext style . - if (strtolower ( $typefile ) == 'css' && $folderarray [count ( $folderarray ) - 2] == 'css') { - $output = g::streamCSSBigFile ( $typearray [0] ); - print $output; - return; - } + //trick to generate the big css file for ext style . + if (strtolower( $typefile ) == 'css' && $folderarray[count( $folderarray ) - 2] == 'css') { + Bootstrap::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); + $output = Bootstrap::streamCSSBigFile( $typearray[0] ); + print $output; + return; + } - if (file_exists ( $filename )) { - switch (strtolower ( $typefile )) { - case 'swf' : - g::sendHeaders ( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); - break; - case 'js' : - g::sendHeaders ( $filename, 'text/javascript', $download, $downloadFileName ); - break; - case 'htm' : - case 'html' : - g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); - break; - case 'htc' : - g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); - break; - case 'json' : - g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); - break; - case 'gif' : - g::sendHeaders ( $filename, 'image/gif', $download, $downloadFileName ); - break; - case 'png' : - g::sendHeaders ( $filename, 'image/png', $download, $downloadFileName ); - break; - case 'jpg' : - g::sendHeaders ( $filename, 'image/jpg', $download, $downloadFileName ); - break; - case 'css' : - g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); - break; - case 'css' : - g::sendHeaders ( $filename, 'text/css', $download, $downloadFileName ); - break; - case 'xml' : - g::sendHeaders ( $filename, 'text/xml', $download, $downloadFileName ); - break; - case 'txt' : - g::sendHeaders ( $filename, 'text/html', $download, $downloadFileName ); - break; - case 'doc' : - case 'pdf' : - case 'pm' : - case 'po' : - g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); - break; - case 'php' : - if ($download) { - g::sendHeaders ( $filename, 'text/plain', $download, $downloadFileName ); - } else { - require_once ($filename); - return; - } - break; - case 'tar' : - g::sendHeaders ( $filename, 'application/x-tar', $download, $downloadFileName ); - break; - default : - // throw new Exception ( "Unknown type of file '$file'. " ); - g::sendHeaders ( $filename, 'application/octet-stream', $download, $downloadFileName ); - break; - break; - } - } else { - if (strpos ( $file, 'gulliver' ) !== false) { - list ( $path, $filename ) = explode ( 'gulliver', $file ); - } + if (file_exists( $filename )) { + switch (strtolower( $typefile )) { + case 'swf': + Bootstrap::sendHeaders( $filename, 'application/x-shockwave-flash', $download, $downloadFileName ); + break; + case 'js': + Bootstrap::sendHeaders( $filename, 'text/javascript', $download, $downloadFileName ); + break; + case 'htm': + case 'html': + Bootstrap::sendHeaders( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'htc': + Bootstrap::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'json': + Bootstrap::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + break; + case 'gif': + Bootstrap::sendHeaders( $filename, 'image/gif', $download, $downloadFileName ); + break; + case 'png': + Bootstrap::sendHeaders( $filename, 'image/png', $download, $downloadFileName ); + break; + case 'jpg': + Bootstrap::sendHeaders( $filename, 'image/jpg', $download, $downloadFileName ); + break; + case 'css': + Bootstrap::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); + break; + case 'xml': + Bootstrap::sendHeaders( $filename, 'text/xml', $download, $downloadFileName ); + break; + case 'txt': + Bootstrap::sendHeaders( $filename, 'text/html', $download, $downloadFileName ); + break; + case 'doc': + case 'pdf': + case 'pm': + case 'po': + Bootstrap::sendHeaders( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + case 'php': + if ($download) { + G::sendHeaders( $filename, 'text/plain', $download, $downloadFileName ); + } else { + require_once ($filename); + return; + } + break; + case 'tar': + Bootstrap::sendHeaders( $filename, 'application/x-tar', $download, $downloadFileName ); + break; + default: + //throw new Exception ( "Unknown type of file '$file'. " ); + Bootstrap::sendHeaders( $filename, 'application/octet-stream', $download, $downloadFileName ); + break; + } + } else { + if (strpos( $file, 'gulliver' ) !== false) { + list ($path, $filename) = explode( 'gulliver', $file ); + } - $_SESSION ['phpFileNotFound'] = $file; - g::header ( "location: /errors/error404.php?l=" . $_SERVER ['REQUEST_URI'] ); - } + $_SESSION['phpFileNotFound'] = $file; + Bootstrap::header( "location: /errors/error404.php?l=" . $_SERVER['REQUEST_URI'] ); + } - switch (strtolower ( $typefile )) { - case "js" : - $paths = explode ( '/', $filename ); - $jsName = $paths [count ( $paths ) - 1]; - $output = ''; - $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; - switch ($jsName) { - // - case 'draw2d.js' : - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = g::getCheckSum ( array ( - $pathJs . 'ext/wz_jsgraphics.js', - $pathJs . 'ext/mootools.js', - $pathJs . 'ext/moocanvas.js' - ) ); - - $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; - $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-draw2d-cache.*.js' ); - // error_log("draw2d.js ".$checksum ."==". - // $cfStored['checksum']); - if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { - $output = file_get_contents ( $cf ); - } else { - if (is_file ( $cfStored ['filename'] )) { - @unlink ( $cfStored ['filename'] ); - } - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/wz_jsgraphics.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/mootools.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/moocanvas.js' ) ); - $output .= file_get_contents ( $pathJs . 'ext/draw2d.js' ); // already - // minified - file_put_contents ( $cf, $output ); - } - break; - case 'ext-all.js' : - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = g::getCheckSum ( array ( - $pathJs . 'ext/pmos-common.js', - $pathJs . 'ext/ux/miframe.js', - $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js', - $pathJs . 'ext/ux.statusbar/ext-statusbar.js', - $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' - ) ); - - $cfStored = g::getCacheFileNameByPattern ( $cachePath, 'ext-all-cache.*.js' ); - $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; - if (is_file ( $cfStored ['filename'] ) && $checksum == $cfStored ['checksum']) { - $output = file_get_contents ( $cf ); - } else { - if (is_file ( $cfStored ['filename'] )) { - @unlink ( $cfStored ['filename'] ); - } - - $output .= file_get_contents ( $pathJs . 'ext/ext-all.js' ); // already - // minified - $output .= file_get_contents ( $pathJs . 'ext/ux/ux-all.js' ); // already - // minified - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/pmos-common.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux/miframe.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); - $output .= JSMin::minify ( file_get_contents ( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); - - file_put_contents ( $cf, $output ); - } - break; - case 'maborak.js' : - $oHeadPublisher = & headPublisher::getSingleton (); - foreach ( $oHeadPublisher->maborakFiles as $fileJS ) { - $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); - } - break; - case 'maborak.loader.js' : - $oHeadPublisher = & headPublisher::getSingleton (); - foreach ( $oHeadPublisher->maborakLoaderFiles as $fileJS ) { - $output .= JSMin::minify ( file_get_contents ( $fileJS ) ); - } - break; - default : - $output = JSMin::minify ( file_get_contents ( $filename ) ); - break; - } - print $output; - break; - case 'css' : - print g::trimSourceCodeFile ( $filename ); - break; - default : - @readfile ( $filename ); - break; - } - } + if ( substr($filename,-10) == "ext-all.js" ) { + $filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js'; + } + @readfile( $filename ); + } /** * Parsing the URI @@ -496,7 +493,7 @@ class G * @return void */ public function LoadClass($strClass) { - $classfile = g::ExpandPath ( "classes" ) . 'class.' . $strClass . '.php'; + $classfile = Bootstrap::ExpandPath ( "classes" ) . 'class.' . $strClass . '.php'; if (! file_exists ( $classfile )) { if (file_exists ( PATH_GULLIVER . 'class.' . $strClass . '.php' )) { return require_once (PATH_GULLIVER . 'class.' . $strClass . '.php'); @@ -531,8 +528,7 @@ class G * * @author Hugo Loza. * @access public - * @param - * eter string lang + * @param string lang * @return void */ public function LoadTranslationObject($lang = SYS_LANG) { @@ -584,7 +580,7 @@ class G $G_SKIN = $strSkin; try { - $file = g::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; + $file = Bootstrap::ExpandPath ( 'skinEngine' ) . 'skinEngine.php'; include $file; $skinEngine = new SkinEngine ( $G_TEMPLATE, $G_SKIN, $G_CONTENT ); $skinEngine->setLayout ( $layout ); @@ -641,7 +637,7 @@ class G case 'label' : case 'labels' : $_SESSION ['G_MESSAGE_TYPE'] = $strType; - $_SESSION ['G_MESSAGE'] = nl2br ( g::LoadTranslation ( $msgID ) ); + $_SESSION ['G_MESSAGE'] = nl2br ( Bootstrap::LoadTranslation ( $msgID ) ); break; case 'string' : $_SESSION ['G_MESSAGE_TYPE'] = $strType; @@ -667,7 +663,7 @@ class G */ public function header($parameter) { if (defined ( 'ENABLE_ENCRYPT' ) && (ENABLE_ENCRYPT == 'yes') && (substr ( $parameter, 0, 9 ) == 'location:')) { - $url = g::encrypt ( substr ( $parameter, 10 ), URL_KEY ); + $url = Bootstrap::encrypt ( substr ( $parameter, 10 ), URL_KEY ); header ( 'location:' . $url ); } else { header ( $parameter ); @@ -742,7 +738,7 @@ class G $rest->setSupportedFormats( 'JsonFormat', 'XmlFormat' ); // getting all services class $restClasses = array (); - $restClassesList = g::rglob( '*', 0, PATH_CORE . 'services/' ); + $restClassesList = Bootstrap::rglob( '*', 0, PATH_CORE . 'services/' ); foreach ($restClassesList as $classFile) { if (substr( $classFile, - 4 ) === '.php') { $restClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; @@ -750,7 +746,7 @@ class G } if (! empty( $apiClassesPath )) { $pluginRestClasses = array (); - $restClassesList = g::rglob( '*', 0, $apiClassesPath . 'services/' ); + $restClassesList = Bootstrap::rglob( '*', 0, $apiClassesPath . 'services/' ); foreach ($restClassesList as $classFile) { if (substr( $classFile, - 4 ) === '.php') { $pluginRestClasses[str_replace( '.php', '', basename( $classFile ) )] = $classFile; @@ -864,7 +860,7 @@ class G public function streamJSTranslationFile($filename, $locale = 'en') { header ( 'Content-Type: text/javascript' ); - if (! g::LoadTranslationObject ( $locale )) { + if (! Bootstrap::LoadTranslationObject ( $locale )) { header ( 'Cache-Control: no-cache' ); header ( 'Pragma: no-cache' ); return; @@ -902,7 +898,7 @@ class G } } - return JSMin::minify ( 'var TRANSLATIONS = ' . g::json_encode ( $translation ) . ';' ); + return 'var TRANSLATIONS = ' . Bootstrap::json_encode ( $translation ) . ";\n"; } /** @@ -934,25 +930,15 @@ class G $skinName = "classic"; } if ($skinName == "classic") { - $configurationFile = g::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; + $configurationFile = Bootstrap::ExpandPath( "skinEngine" ) . 'base' . PATH_SEP . 'config.xml'; } else { $configurationFile = PATH_CUSTOM_SKINS . $skinName . PATH_SEP . 'config.xml'; if (! is_file( $configurationFile )) { - $configurationFile = g::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; + $configurationFile = Bootstrap::ExpandPath( "skinEngine" ) . $skinName . PATH_SEP . 'config.xml'; } } - //Read Configuration File - $xmlConfiguration = file_get_contents( $configurationFile ); - $xmlConfigurationObj = g::xmlParser( $xmlConfiguration ); - $baseSkinDirectory = dirname( $configurationFile ); - $directorySize = g::getDirectorySize( $baseSkinDirectory ); - $mtime = $directorySize['maxmtime']; - - //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. - //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); - $gmt_mtime = gmdate( "D, d M Y H:i:s", $mtime ) . " GMT"; header( 'Pragma: cache' ); header( 'ETag: "' . md5( $mtime . $filename ) . '"' ); @@ -974,6 +960,16 @@ class G } } + //Read Configuration File + $xmlConfiguration = file_get_contents( $configurationFile ); + $xmlConfigurationObj = Bootstrap::xmlParser( $xmlConfiguration ); + $baseSkinDirectory = dirname( $configurationFile ); + $directorySize = Bootstrap::getDirectorySize( $baseSkinDirectory ); + $mtime = $directorySize['maxmtime']; + + //if userAgent (BROWSER) is MSIE we need special headers to avoid MSIE behaivor. + //$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); + $outputHeader = "/* Autogenerated CSS file by gulliver framework \n"; $outputHeader .= " Skin: $filename\n"; $outputHeader .= " Configuration: $configurationFile\n"; @@ -981,46 +977,11 @@ class G $gmt_mtimeNow = gmdate( "D, d M Y H:i:s", $mtimeNow ) . " GMT"; $outputHeader .= " Date: $gmt_mtimeNow*/\n"; $output = ""; + //Base files switch (strtolower( $skinVariant )) { case "extjs": - //Basepublic function getDirectorySize ($path, $maxmtime = 0) - { - $totalsize = 0; - $totalcount = 0; - $dircount = 0; - if ($handle = opendir( $path )) { - while (false !== ($file = readdir( $handle ))) { - $nextpath = $path . '/' . $file; - if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { - if (is_dir( $nextpath )) { - $dircount ++; - $result = g::getDirectorySize( $nextpath, $maxmtime ); - $totalsize += $result['size']; - $totalcount += $result['count']; - $dircount += $result['dircount']; - $maxmtime = $result['maxmtime'] > $maxmtime ? $result['maxmtime'] : $maxmtime; - } elseif (is_file( $nextpath )) { - $totalsize += filesize( $nextpath ); - $totalcount ++; - - $mtime = filemtime( $nextpath ); - if ($mtime > $maxmtime) { - $maxmtime = $mtime; - } - } - } - } - } - closedir( $handle ); - $total['size'] = $totalsize; - $total['count'] = $totalcount; - $total['dircount'] = $dircount; - $total['maxmtime'] = $maxmtime; - - return $total; - } - + //Base $baseCSSPath = PATH_SKIN_ENGINE . "base" . PATH_SEP . "baseCss" . PATH_SEP; $output .= file_get_contents( $baseCSSPath . 'ext-all-notheme.css' ); //$output .= file_get_contents ( $publicExtPath . 'ext-all.css' ); @@ -1030,13 +991,11 @@ class G break; default: - break; - } //Get Browser Info - $infoBrowser = g::get_current_browser(); + $infoBrowser = Bootstrap::get_current_browser(); $browserName = $infoBrowser['browser_working']; if (isset( $infoBrowser[$browserName . '_data'] )) { if ($infoBrowser[$browserName . '_data'][0] != "") { @@ -1046,7 +1005,7 @@ class G //Read Configuration File $xmlConfiguration = file_get_contents ( $configurationFile ); - $xmlConfigurationObj = g::xmlParser($xmlConfiguration); + $xmlConfigurationObj = Bootstrap::xmlParser($xmlConfiguration); $skinFilesArray=$xmlConfigurationObj->result['skinConfiguration']['__CONTENT__']['cssFiles']['__CONTENT__'][$skinVariant]['__CONTENT__']['cssFile'] ; foreach ($skinFilesArray as $keyFile => $cssFileInfo) { @@ -1055,7 +1014,7 @@ class G if (((in_array($browserName, $enabledBrowsers))||(in_array('ALL', $enabledBrowsers)))&&(!(in_array($browserName, $disabledBrowsers)))) { if ($cssFileInfo['__ATTRIBUTES__']['file'] == 'rtl.css') { - g::LoadClass('serverConfiguration'); + Bootstrap::LoadClass('serverConfiguration'); $oServerConf =& serverConf::getSingleton(); if (!(defined('SYS_LANG'))) { if (isset($_SERVER['HTTP_REFERER'])) { @@ -1126,9 +1085,9 @@ class G } if (! $download) { - + header ( 'Pragma: cache' ); - + if (file_exists ( $filename )) { $mtime = filemtime ( $filename ); } else { @@ -1145,7 +1104,7 @@ class G exit (); } } - + if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { header ( "HTTP/1.1 304 Not Modified" ); @@ -1162,7 +1121,7 @@ class G */ public function getCheckSum ($files) { - g::LoadClass( 'system' ); + Bootstrap::LoadClass( 'system' ); $key = System::getVersion(); if (! is_array( $files )) { @@ -1252,7 +1211,7 @@ class G if (is_array( $vVar )) { foreach ($vVar as $sKey => $vValue) { if (is_array( $vValue )) { - g::strip_slashes( $vVar[$sKey] ); + Bootstrap::strip_slashes( $vVar[$sKey] ); } else { $vVar[$sKey] = stripslashes( $vVar[$sKey] ); } @@ -1321,7 +1280,7 @@ class G $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); $files = glob($path.$pattern, $flags); foreach ($paths as $path) { - $files = array_merge($files, g::rglob($pattern, $flags, $path)); + $files = array_merge($files, Bootstrap::rglob($pattern, $flags, $path)); } return $files; } @@ -1336,7 +1295,7 @@ class G if ( function_exists('json_encode') ) { return json_encode($Json); } else { - g::LoadThirdParty('pear/json', 'class.json'); + Bootstrap::LoadThirdParty('pear/json', 'class.json'); $oJSON = new Services_JSON(); return $oJSON->encode($Json); } @@ -1352,7 +1311,7 @@ class G if (function_exists('json_decode')) { return json_decode($Json); } else { - g::LoadThirdParty('pear/json', 'class.json'); + Bootstrap::LoadThirdParty('pear/json', 'class.json'); $oJSON = new Services_JSON(); return $oJSON->decode($Json); } @@ -1453,7 +1412,7 @@ class G if ($file != '.' && $file != '..' && ! is_link( $nextpath ) && $file != '.svn') { if (is_dir( $nextpath )) { $dircount ++; - $result = g::getDirectorySize( $nextpath, $maxmtime ); + $result = Bootstrap::getDirectorySize( $nextpath, $maxmtime ); $totalsize += $result['size']; $totalcount += $result['count']; $dircount += $result['dircount']; @@ -1501,14 +1460,14 @@ class G /** * Refactor function - * @author Ralph A. + * @author Ralph A. * @return multitype:array containing browser name and type */ public function get_current_browser() { static $a_full_assoc_data, $a_mobile_data, $browser_user_agent; static $browser_working, $moz_type, $webkit_type; - + //initialize all variables with default values to prevent error $a_full_assoc_data = ''; $a_mobile_data = ''; @@ -1518,14 +1477,14 @@ class G $moz_type = ''; $ua_type = 'bot';// default to bot since you never know with bots $webkit_type = ''; - + /* make navigator user agent string lower case to make sure all versions get caught isset protects against blank user agent failure. tolower also lets the script use strstr instead of stristr, which drops overhead slightly. */ $browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] ); - + // known browsers, list will be updated routinely, check back now and then $a_browser_types = array( array( 'opera', true, 'op', 'bro' ), @@ -1651,11 +1610,11 @@ class G } break; } - } - - $mobile_test = g::check_is_mobile( $browser_user_agent ); + } + + $mobile_test = Bootstrap::check_is_mobile( $browser_user_agent ); if ( $mobile_test ) { - $a_mobile_data = g::get_mobile_data( $browser_user_agent ); + $a_mobile_data = Bootstrap::get_mobile_data( $browser_user_agent ); $ua_type = 'mobile'; } @@ -1666,10 +1625,10 @@ class G 'webkit_data' => array($webkit_type), 'mobile_data' => array($a_mobile_data), ); - + return $a_full_assoc_data; } - + /** * track total script execution time */ @@ -1719,7 +1678,7 @@ class G } } - $start_pos += g::get_set_count( 'get' ); + $start_pos += Bootstrap::get_set_count( 'get' ); $string_working_number = substr( $pv_browser_user_agent, $start_pos, $substring_length ); $string_working_number = substr( $string_working_number, 0, strcspn($string_working_number, ' );/') ); if (!is_numeric( substr( $string_working_number, 0, 1 ))) { @@ -1841,7 +1800,7 @@ class G case 'mac': if (strstr($pv_browser_string, 'os x')) { if (strstr($pv_browser_string, 'os x ')) { - $os_working_number = str_replace( '_', '.', g::get_item_version( $pv_browser_string, 'os x' ) ); + $os_working_number = str_replace( '_', '.', Bootstrap::get_item_version( $pv_browser_string, 'os x' ) ); } else { $os_working_number = 10; } @@ -1940,7 +1899,7 @@ class G for ($k = 0; $k < $k_count; $k++) { if (strstr( $pv_browser_user_agent, $a_mobile_browser[$k] )) { $mobile_browser = $a_mobile_browser[$k]; - $mobile_browser_number = g::get_item_version( $pv_browser_user_agent, $mobile_browser ); + $mobile_browser_number = Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_browser ); break; } } @@ -1949,9 +1908,9 @@ class G if (strstr( $pv_browser_user_agent, $a_mobile_device[$k] )) { $mobile_device = trim ( $a_mobile_device[$k], '-_' ); // but not space trims yet if ($mobile_device == 'blackberry') { - g::get_set_count( 'set', 0 ); + Bootstrap::get_set_count( 'set', 0 ); } - $mobile_device_number = g::get_item_version( $pv_browser_user_agent, $mobile_device ); + $mobile_device_number = Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_device ); $mobile_device = trim( $mobile_device ); // some of the id search strings have white space break; } @@ -1960,7 +1919,7 @@ class G for ($k = 0; $k < $k_count; $k++) { if (strstr( $pv_browser_user_agent, $a_mobile_os[$k] )) { $mobile_os = $a_mobile_os[$k]; - $mobile_os_number = str_replace( '_', '.', g::get_item_version( $pv_browser_user_agent, $mobile_os ) ); + $mobile_os_number = str_replace( '_', '.', Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_os ) ); break; } } @@ -1968,14 +1927,14 @@ class G for ($k = 0; $k < $k_count; $k++) { if (strstr( $pv_browser_user_agent, $a_mobile_server[$k] )) { $mobile_server = $a_mobile_server[$k]; - $mobile_server_number = g::get_item_version( $pv_browser_user_agent, $mobile_server ); + $mobile_server_number = Bootstrap::get_item_version( $pv_browser_user_agent, $mobile_server ); break; } } // just for cases where we know it's a mobile device already if (!$mobile_os && ( $mobile_browser || $mobile_device || $mobile_server ) && strstr( $pv_browser_user_agent, 'linux' ) ) { $mobile_os = 'linux'; - $mobile_os_number = g::get_item_version( $pv_browser_user_agent, 'linux' ); + $mobile_os_number = Bootstrap::get_item_version( $pv_browser_user_agent, 'linux' ); } $a_mobile_data = array( $mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number, $mobile_device_number ); @@ -2020,7 +1979,7 @@ class G $plain = '/sys' . SYS_TEMP; for ($i = 2; $i < count( $aRequestUri ); $i ++) { - $decoded = g::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); + $decoded = Bootstrap::decrypt( urldecode( $aRequestUri[$i] ), URL_KEY ); if ($decoded == 'sWì›') { $decoded = $VARS[$i]; //this is for the string "../" } @@ -2169,7 +2128,7 @@ class G public function createUID ($scope, $id) { $e = $scope . $id; - $e = g::encrypt( $e, URL_KEY ); + $e = Bootstrap::encrypt( $e, URL_KEY ); $e = str_replace( array ('+','/','=' ), array ('__','_','___' ), base64_encode( $e ) ); @@ -2192,7 +2151,7 @@ class G ), array ('___','__','_' ), $uid ); $e = base64_decode( $e ); - $e = g::decrypt( $e, URL_KEY ); + $e = Bootstrap::decrypt( $e, URL_KEY ); $e = substr( $e, strlen( $scope ) ); return $e; } @@ -2210,7 +2169,7 @@ class G $arrays = & func_get_args(); foreach ($arrays as $array_i) { if (is_array( $array_i )) { - g::array_merge_2( $array, $array_i ); + Bootstrap::array_merge_2( $array, $array_i ); } } return $array; @@ -2232,7 +2191,7 @@ class G if (! isset( $array[$k] )) { $array[$k] = array (); } - g::array_merge_2( $array[$k], $v ); + Bootstrap::array_merge_2( $array[$k], $v ); } else { if (isset( $array[$k] ) && is_array( $array[$k] )) { $array[$k][0] = $v; @@ -2265,7 +2224,7 @@ class G if (! is_array( $result )) { $result = array (); } - $result = $result + g::getSystemConstants(); + $result = $result + Bootstrap::getSystemConstants(); $__textoEval = ""; $u = 0; //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); @@ -2280,7 +2239,7 @@ class G $u = $match[0][$r][1] + strlen( $match[0][$r][0] ); //Mysql quotes scape if (($match[1][$r][0] == '@') && (isset( $result[$match[2][$r][0]] ))) { - $__textoEval .= "\"" . g::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; + $__textoEval .= "\"" . Bootstrap::sqlEscape( $result[$match[2][$r][0]], $DBEngine ) . "\""; continue; } //URL encode @@ -2300,14 +2259,14 @@ class G } //Substring (Sub replaceDataField) if (($match[1][$r][0]=='!')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + $__textoEval.=Bootstrap::replaceDataField($result[$match[2][$r][0]],$result); continue; } //Call function if (($match[1][$r][0]==='')&&($match[2][$r][0]==='')&&($match[3][$r][0]!=='')) { - eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(g::replaceDataField(stripslashes($match[4][$r][0]),$result),'\\\'') . '\');'); + eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(Bootstrap::replaceDataField(stripslashes($match[4][$r][0]),$result),'\\\'') . '\');'); - if ($match[3][$r][0] == "g::LoadTranslation") { + if ($match[3][$r][0] == "Bootstrap::LoadTranslation") { $arraySearch = array("'"); $arrayReplace = array("\\'"); $strAux = str_replace($arraySearch, $arrayReplace, $strAux); @@ -2318,12 +2277,12 @@ class G } //Non-quoted if (($match[1][$r][0]=='#')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + $__textoEval.=Bootstrap::replaceDataField($result[$match[2][$r][0]],$result); continue; } //Non-quoted = if (($match[1][$r][0]=='=')&&(isset($result[$match[2][$r][0]]))) { - $__textoEval.=g::replaceDataField($result[$match[2][$r][0]],$result); + $__textoEval.=Bootstrap::replaceDataField($result[$match[2][$r][0]],$result); continue; } } @@ -2351,7 +2310,7 @@ class G */ public function getSystemConstants($params = null) { - $t1 = g::microtime_float(); + $t1 = Bootstrap::microtime_float(); $sysCon = array(); if (defined("SYS_LANG")) { @@ -2382,7 +2341,7 @@ class G switch ($params->option) { case "STORED SESSION": if (isset($params->SID)) { - g::LoadClass("sessions"); + Bootstrap::LoadClass("sessions"); $oSessions = new Sessions($params->SID); $sysCon = array_merge($sysCon, $oSessions->getGlobals()); @@ -2446,7 +2405,7 @@ class G } $temp = $strTemplateName . ".php"; - $file = g::ExpandPath( 'templates' ) . $temp; + $file = Bootstrap::ExpandPath( 'templates' ) . $temp; // Check if its a user template if (file_exists( $file )) { //require_once( $file ); @@ -2479,7 +2438,7 @@ class G } else { if ($createPath) { //TODO:: Define Environment constants: Devel (0777), Production (0770), ... - G::mk_dir( $strPath, 0777 ); + Bootstrap::mk_dir( $strPath, 0777 ); } else { return false; } @@ -2555,18 +2514,18 @@ class G $MONTHS = Array (); for ($i = 1; $i <= 12; $i ++) { - $MONTHS[$i] = g::LoadTranslation( "ID_MONTH_$i", $lang ); + $MONTHS[$i] = Bootstrap::LoadTranslation( "ID_MONTH_$i", $lang ); } $d = (int) $day; - $dd = g::complete_field( $day, 2, 1 ); + $dd = Bootstrap::complete_field( $day, 2, 1 ); //missing D $M = $MONTHS[$month]; $m = (int) $month; - $mm = g::complete_field( $month, 2, 1 ); + $mm = Bootstrap::complete_field( $month, 2, 1 ); $yy = substr( $year, strlen( $year ) - 2, 2 ); $yyyy = $year; @@ -2667,7 +2626,7 @@ class G { print ("") ; } - + /** * Generate random number * @@ -2683,7 +2642,7 @@ class G return $sUID; //return strtoupper(substr(uniqid(rand(0, 9), false),0,14)); } - + /** * Encrypt URL * @@ -2695,7 +2654,7 @@ class G public function encryptlink ($url) { if (defined( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes') { - return urlencode( G::encrypt( $url, URL_KEY ) ); + return urlencode( Bootstrap::encrypt( $url, URL_KEY ) ); } else { return $url; } diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index baab52139..b472ca61d 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -214,231 +214,6 @@ class G { return array_sum( explode( ' ', microtime() ) ); } - /* custom error functions */ - - /** - * &setFatalErrorHandler - * - * @param string $newFatalErrorHandler default value null - * - * @return boolean true - */ - public function &setFatalErrorHandler ($newFatalErrorHandler = null) - { - if (isset( $newFatalErrorHandler )) { - set_error_handler( $newFatalErrorHandler ); - } else { - ob_start( array ('G','fatalErrorHandler' - ) ); - } - return true; - } - - /** - * setErrorHandler - * - * @param string setErrorHandler - * @param object $newCustomErrorHandler - * - * @return boolean true - */ - /*public static*/ - public function setErrorHandler ($newCustomErrorHandler = null) - { - if (isset( $newCustomErrorHandler )) { - set_error_handler( $newCustomErrorHandler ); - } else { - set_error_handler( array ("G","customErrorHandler") ); - } - return true; - } - - /** - * fatalErrorHandler - * - * @param string $buffer - * - * @return string $errorBox or $buffer - */ - /*public static*/ - public function fatalErrorHandler ($buffer) - { - // The ereg function has been DEPRECATED as of PHP 5.3.0. - // if (ereg("(error:)(.+)(:)(.+)(/", "", $regs[2] ); - G::customErrorLog( 'FATAL', $err, '', 0, '' ); - $ip_addr = G::getIpAddress(); - $errorBox = "
" . "" . "" . " " . "
ERROR CAUGHT check log file
IP address: $ip_addr
"; - return $errorBox; - } - return $buffer; - } - /** - * customErrorHandler - * - * @param string $errno - * @param string $msg - * @param string $file - * @param string $line - * @param string $context - * - * @return void - */ - /*public static*/ - public function customErrorHandler ($errno, $msg, $file, $line, $context) - { - switch ($errno) { - case E_ERROR: - case E_USER_ERROR: - $type = "FATAL"; - G::customErrorLog( $type, $msg, $file, $line ); - G::verboseError( $type, $errno, $msg, $file, $line, $context ); - if (defined( "ERROR_SHOW_SOURCE_CODE" ) && ERROR_SHOW_SOURCE_CODE) { - G::showErrorSource( $type, $msg, $file, $line, "#c00000" ); - } - die(); - break; - case E_WARNING: - case E_USER_WARNING: - $type = "WARNING"; - G::customErrorLog( $type, $msg, $file, $line ); - break; - case E_NOTICE: - case E_USER_NOTICE: - $type = "NOTICE"; - if (defined( "ERROR_LOG_NOTICE_ERROR" ) && ERROR_LOG_NOTICE_ERROR) { - G::customErrorLog( $type, $msg, $file, $line ); - } - break; - case E_STRICT: - $type = "STRICT"; //dont show STRICT Errors - break; - default: - $type = "ERROR ($errno)"; - G::customErrorLog( $type, $msg, $file, $line ); - break; - } - if (defined( "ERROR_SHOW_SOURCE_CODE" ) && ERROR_SHOW_SOURCE_CODE && $errno != E_STRICT) { - G::showErrorSource( $type, $msg, $file, $line ); - } - } - - /** - * public function showErrorSource - * - * @author David S. Callizaya S. - * @access public - * @param eter string type - * @param eter string msg - * @param eter string file - * @param eter string line - * @return string - */ - public function showErrorSource ($type, $msg, $file, $line) - { - global $__src_array; - $line_offset = 3; - - if (! isset( $__src_array[$file] )) { - $__src_array[$file] = @file( $file ); - } - if (! $__src_array[$file]) { - return; - } - if ($line - $line_offset < 1) { - $start = 1; - } else { - $start = $line - $line_offset; - } - if ($line + $line_offset > count( $__src_array[$file] )) { - $end = count( $__src_array[$file] ); - } else { - $end = $line + $line_offset; - } - print "
"; - print ""; - print " - - - "; - for ($i = $start; $i <= $end; $i ++) { - $str = @highlight_string( "", true ); - - $pos1 = strpos( $str, "<?" ); - $pos2 = strrpos( $str, "?>" ); - - $str = substr( $str, 0, $pos1 ) . substr( $str, $pos1 + 5, $pos2 - ($pos1 + 5) ) . substr( $str, $pos2 + 5 ); - - ($i == $line) ? $bgcolor = "bgcolor=#ffccaa" : $bgcolor = "bgcolor=#ffffff"; - print " - "; - } - - print "
$type: $msg
File: $file
$i$str

"; - } - - /** - * customErrorLog - * - * @param string $type - * @param string $msg - * @param string $file - * @param string $line - * - * @return void - */ - public function customErrorLog ($type, $msg, $file, $line) - { - global $HTTP_X_FORWARDED_FOR, $REMOTE_ADDR, $HTTP_USER_AGENT, $REQUEST_URI; - - $ip_addr = G::getIpAddress(); - - if (defined( 'APPLICATION_CODE' )) { - $name = APPLICATION_CODE; - } else { - $name = "php"; - } - if ($file != '') { - $msg .= " in $file:$line "; - } - $date = date( 'Y-m-d H:i:s' ); - $REQUEST_URI = getenv( 'REQUEST_URI' ); - $HTTP_USER_AGENT = getenv( 'HTTP_USER_AGENT' ); - error_log( "[$date] [$ip_addr] [$name] $type: $msg [$HTTP_USER_AGENT] URI: $REQUEST_URI", 0 ); - } - - /** - * verboseError - * - * @param string $type - * @param string $errno - * @param string $msg - * @param string $file - * @param string $line - * @param string $context - * - * @return void - */ - /*public static*/ - public function verboseError ($type, $errno, $msg, $file, $line, $context) - { - global $SERVER_ADMIN; - - print "

Error!

"; - print "An error occurred while executing this script. Please - contact the $SERVER_ADMIN to - report this error."; - print "

"; - print "Here is the information provided by the script:"; - print "


";
-        print "Error type: $type (code: $errno)
"; - print "Error message: $msg
"; - print "Script name and line number of error: $file:$line
"; - print "Variable context when error occurred:
"; - print_r( $context ); - print "

"; - } /** * * Encrypt and decrypt functions *** @@ -1330,129 +1105,10 @@ class G G::header( "location: /errors/error404.php?l=" . $_SERVER['REQUEST_URI'] ); } - switch (strtolower( $typefile )) { - case "js": - $paths = explode( '/', $filename ); - $jsName = $paths[count( $paths ) - 1]; - $output = ''; - $pathJs = PATH_GULLIVER_HOME . PATH_SEP . 'js' . PATH_SEP; - switch ($jsName) { - case 'draw2d.js': - $filename = PATH_GULLIVER_HOME . 'js/ext/min/draw2d.js'; - @readfile( $filename ); - /* this code is commented, because in run time we dont generate the file ext-all.js - the file was generate once and the committed to git. If there are changes in the included - files we need to regenerate the file manually. - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = G::getCheckSum( array ($pathJs . 'ext/wz_jsgraphics.js',$pathJs . 'ext/mootools.js',$pathJs . 'ext/moocanvas.js' - ) ); - - $cf = $cachePath . "ext-draw2d-cache.$checksum.js"; - $cfStored = G::getCacheFileNameByPattern( $cachePath, 'ext-draw2d-cache.*.js' ); - //error_log("draw2d.js ".$checksum ."==". $cfStored['checksum']); - if (is_file( $cfStored['filename'] ) && $checksum == $cfStored['checksum']) { - $output = file_get_contents( $cf ); - } else { - if (is_file( $cfStored['filename'] )) { - @unlink( $cfStored['filename'] ); - } - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/wz_jsgraphics.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/mootools.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/moocanvas.js' ) ); - $output .= file_get_contents( $pathJs . 'ext/draw2d.js' ); //already minified - file_put_contents( $cf, $output ); - } - */ - break; - case 'ext-all.js': - $filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js'; - @readfile( $filename ); - /* this code is commented, because in run time we dont generate the file ext-all.js - the file was generate once and the committed to git. If there are changes in the included - files we need to regenerate the file manually. - $cachePath = PATH_C . 'ExtJs' . PATH_SEP; - $checksum = G::getCheckSum( array ($pathJs . 'ext/pmos-common.js',$pathJs . 'ext/ux/miframe.js',$pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js',$pathJs . 'ext/ux.statusbar/ext-statusbar.js',$pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' - ) ); - - $cfStored = G::getCacheFileNameByPattern( $cachePath, 'ext-all-cache.*.js' ); - $cf = PATH_C . 'ExtJs' . PATH_SEP . "ext-all-cache.$checksum.js"; - if (is_file( $cfStored['filename'] ) && $checksum == $cfStored['checksum']) { - $output = file_get_contents( $cf ); - } else { - if (is_file( $cfStored['filename'] )) { - @unlink( $cfStored['filename'] ); - } - $output .= file_get_contents( $pathJs . 'ext/ext-all.js' ); //already minified - $output .= file_get_contents( $pathJs . 'ext/ux/ux-all.js' ); //already minified - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/pmos-common.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux/miframe.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.locationbar/Ext.ux.LocationBar.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.statusbar/ext-statusbar.js' ) ); - $output .= JSMin::minify( file_get_contents( $pathJs . 'ext/ux.treefilterx/Ext.ux.tree.TreeFilterX.js' ) ); - file_put_contents( $cf, $output ); - } - */ - break; - default: - @readfile( $filename ); - break; - } - print $output; - break; - case 'css': - print G::trimSourceCodeFile( $filename ); - break; - default: - @readfile( $filename ); - break; + if ( substr($filename,-10) == "ext-all.js" ) { + $filename = PATH_GULLIVER_HOME . 'js/ext/min/ext-all.js'; } - } - - /** - * trimSourceCodeFile - * - * @param string $filename - * - * @return string $output - */ - public function trimSourceCodeFile ($filename) - { - $handle = fopen( $filename, "r" ); - $lastChar = ''; - $firstChar = ''; - $content = ''; - $line = ''; - - if ($handle) { - while (! feof( $handle )) { - //$line = trim( fgets($handle, 16096) ) . "\n" ; - $line = fgets( $handle, 16096 ); - $content .= $line; - } - fclose( $handle ); - } - return $content; - - $index = 0; - $output = ''; - while ($index < strlen( $content )) { - $car = $content[$index]; - $index ++; - if ($car == '/' && isset( $content[$index] ) && $content[$index] == '*') { - $endComment = false; - $index ++; - while ($endComment == false && $index < strlen( $content )) { - if ($content[$index] == '*' && isset( $content[$index + 1] ) && $content[$index + 1] == '/') { - $endComment = true; - $index ++; - } - $index ++; - } - $car = ''; - } - $output .= $car; - } - return $output; + @readfile( $filename ); } /** @@ -3371,7 +3027,7 @@ class G /** * Validate and emai address in complete forms, * - * @author Erik A.O. + * @author Erik A.O. * i.e. if the param. is 'erik a.o. ' * -> returns a object within $o->email => erik@colosa.com and $o->name => erik A.O. in other case returns false * @@ -3404,7 +3060,7 @@ class G /** * JSON encode * - * @author Erik A.O. + * @author Erik A.O. */ public function json_encode($Json) { @@ -3420,7 +3076,7 @@ class G /** * JSON decode * - * @author Erik A.O. + * @author Erik A.O. */ public function json_decode($Json) { @@ -3689,11 +3345,11 @@ class G return $infoUser; } - public function getModel($model) - { - require_once "classes/model/$model.php"; - return new $model(); - } + //public function getModel($model) + //{ + // require_once "classes/model/$model.php"; + // return new $model(); + //} /** * Recursive Is writeable function diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index e86f1e98e..d3f7f33d0 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -4922,8 +4922,9 @@ class XmlForm } } - $oJSON = new Services_JSON(); - $this->objectRequiredFields = str_replace( '"', "%27", str_replace( "'", "%39", $oJSON->encode( $this->requiredFields ) ) ); + //$oJSON = new Services_JSON(); + $jsonRequired = G::json_encode( $this->requiredFields ); + $this->objectRequiredFields = str_replace( '"', "%27", str_replace( "'", "%39", $jsonRequired ) ); //Load the default values //$this->setDefaultValues(); diff --git a/workflow/engine/classes/class.dashletRssReader.php b/workflow/engine/classes/class.dashletRssReader.php index 4e3d6e9ed..cc1b935ea 100644 --- a/workflow/engine/classes/class.dashletRssReader.php +++ b/workflow/engine/classes/class.dashletRssReader.php @@ -50,8 +50,8 @@ class dashletRssReader implements DashletInterface curl_setopt( $pCurl, CURLOPT_CONNECTTIMEOUT, 10 ); curl_setopt( $pCurl, CURLOPT_TIMEOUT, 20 ); - curl_setopt( $pCurl, CURLOPT_NOPROGRESS, false ); - curl_setopt( $pCurl, CURLOPT_VERBOSE, true ); + curl_setopt( $pCurl, CURLOPT_NOPROGRESS, true ); + curl_setopt( $pCurl, CURLOPT_VERBOSE, false ); //Apply proxy settings $sysConf = System::getSystemConfiguration(); diff --git a/workflow/engine/classes/class.memcached.php b/workflow/engine/classes/class.memcached.php index b16ac6963..51cc4c864 100644 --- a/workflow/engine/classes/class.memcached.php +++ b/workflow/engine/classes/class.memcached.php @@ -66,7 +66,7 @@ class PMmemcached $this->version = $this->mem->getVersion(); } } else { - G::Loadclass( 'fileCache' ); + require_once ('classes/class.fileCache.php'); // create cache folder $cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/"; if (! file_exists( $cacheFolder )) { diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index e5facf576..c3eb2f033 100755 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -1102,7 +1102,7 @@ class PMPluginRegistry { try { $iPlugins = 0; - G::LoadClass( 'serverConfiguration' ); + require_once ( 'class.serverConfiguration.php' ); $oServerConf = & serverConf::getSingleton(); $oServerConf->addPlugin( SYS_SYS, $this->_aPluginDetails ); foreach ($this->_aPluginDetails as $namespace => $detail) { diff --git a/workflow/engine/methods/login/login.php b/workflow/engine/methods/login/login.php index f3e76dc88..eee79bd2d 100755 --- a/workflow/engine/methods/login/login.php +++ b/workflow/engine/methods/login/login.php @@ -120,7 +120,9 @@ if (strlen($msgType) > 0) { $_SESSION['FAILED_LOGINS'] = $sFailedLogins; //translation -$Translations = G::getModel("Translation"); +//$Translations = G::getModel("Translation"); +require_once "classes/model/Translation.php"; +$Translations = new Translation(); $translationsTable = $Translations->getTranslationEnvironments(); $availableLangArray = array (); diff --git a/workflow/engine/methods/login/sysLogin.php b/workflow/engine/methods/login/sysLogin.php index 81d6fd125..9628a4a09 100755 --- a/workflow/engine/methods/login/sysLogin.php +++ b/workflow/engine/methods/login/sysLogin.php @@ -83,10 +83,13 @@ function getWorkspacesAvailable() sort ($filesArray, SORT_STRING); return $filesArray; } + $availableWorkspace = getWorkspacesAvailable (); //Translations -$Translations = G::getModel("Translation"); +//$Translations = G::getModel("Translation"); <-- ugly way to get a class +require_once "classes/model/Translation.php"; +$Translations = new Translation(); $translationsTable = $Translations->getTranslationEnvironments(); $availableLangArray = array (); @@ -103,7 +106,6 @@ foreach ($translationsTable as $locale) { $availableLangArray [] = $aFields; } - $availableWorkspaceArray = array (); $availableWorkspaceArray [] = array ('ENV_ID' => 'char', 'ENV_NAME' => 'char'); foreach ($availableWorkspace as $envKey => $envName) { @@ -120,8 +122,9 @@ $_SESSION ['_DBArray'] = $_DBArray; $aField ['LOGIN_VERIFY_MSG'] = G::loadTranslation ('LOGIN_VERIFY_MSG'); $aField['USER_LANG'] = SYS_LANG; + //Get Server Configuration -G::LoadClass ('serverConfiguration'); +//G::LoadClass ('serverConfiguration'); //already called $oServerConf = & serverConf::getSingleton (); $G_PUBLISH = new Publisher (); @@ -131,8 +134,8 @@ if ($oServerConf->getProperty ('LOGIN_NO_WS')) { $G_PUBLISH->AddContent ('xmlform', 'xmlform', 'login/sysLogin', '', $aField, 'sysLogin'); } - G::RenderPage ("publish"); + ?> \n"; + //$script .= " \n"; /* $script .= " \n"; $script .= " \n"; diff --git a/workflow/engine/methods/processes/main.php b/workflow/engine/methods/processes/main.php index 4dc7ab618..b2fc2a860 100755 --- a/workflow/engine/methods/processes/main.php +++ b/workflow/engine/methods/processes/main.php @@ -48,7 +48,7 @@ $G_ID_MENU_SELECTED = 'PROCESSES'; $G_ID_SUB_MENU_SELECTED = '-'; $G_PUBLISH = new Publisher(); -// $oHeadPublisher = & headPublisher::geecho "TEST"tSingleton(); +// $oHeadPublisher = & headPublisher::getSingleton(); //$oHeadPublisher->addScriptFile('/jscore/processes/main.js'); $G_PUBLISH->AddContent( 'view', 'processes/mainLoad' ); From 222b0a64c1ef0146aa75acd55f71907eeb1c9af0 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 14 Nov 2012 09:56:43 -0400 Subject: [PATCH 15/70] Adding code to put content in the header of images at time to response the client. --- workflow/public_html/bootstrap.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index a023a91d7..7f04e3f8b 100755 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -58,14 +58,27 @@ define( 'PATH_OUTTRUNK', $pathOutTrunk ); define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP ); //this is the first path, if the file exists... -if (file_exists(PATH_HTML . $_SERVER['REQUEST_URI'])) { - if (!is_file(PATH_HTML . $_SERVER['REQUEST_URI'])) { +$requestFile = PATH_HTML . $_SERVER['REQUEST_URI']; +if (file_exists($requestFile)) { + if (!is_file($requestFile)) { header( "location: /errors/error404.php?url=" . urlencode( $_SERVER['REQUEST_URI'] ) ); - die(); + die; } - //we are missing the header part - //to do: add header mime part - readfile(PATH_HTML . $_SERVER['REQUEST_URI']); + $pos = strripos($requestFile, ".") + 1; + $size = strlen($requestFile); + if($pos < $size) { + //if this file got an extension then assign the content + $ext_file = substr($requestFile, $pos, $size); + if ($ext_file == "gif" || $ext_file == "png" || $ext_file == "jpg") { + $ext_file = 'image/'.$ext_file ; + } elseif ($ext_file=="css") { + //may this line be innecesary, all the css are been generated at run time + $ext_file = 'css/'.$ext_file; + } + header ('Content-Type: ' . $ext_file); + } + header ('Pragma: cache'); + readfile($requestFile); die; } From 1f120c557f08dd0bcf090188f717f13fd15ebfa1 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 14 Nov 2012 13:05:55 -0400 Subject: [PATCH 16/70] Adding more extension files content to set in headers --- workflow/public_html/bootstrap.php | 37 ++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index 7f04e3f8b..6c54758df 100755 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -71,13 +71,46 @@ if (file_exists($requestFile)) { $ext_file = substr($requestFile, $pos, $size); if ($ext_file == "gif" || $ext_file == "png" || $ext_file == "jpg") { $ext_file = 'image/'.$ext_file ; + } 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"; } elseif ($ext_file=="css") { - //may this line be innecesary, all the css are been generated at run time + //may this line be innecesary, all the .css are been generated at run time $ext_file = 'css/'.$ext_file; + } else { + $ext_file = "application/octet-stream"; } header ('Content-Type: ' . $ext_file); } - header ('Pragma: cache'); + header ( 'Pragma: cache' ); + $mtime = filemtime ( $requestFile ); + $gmt_mtime = gmdate ( "D, d M Y H:i:s", $mtime ) . " GMT"; + header ( 'ETag: "' . md5 ( $mtime . $requestFile ) . '"' ); + header ( "Last-Modified: " . $gmt_mtime ); + header ( 'Cache-Control: public' ); + $userAgent = strtolower ( $_SERVER ['HTTP_USER_AGENT'] ); + 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'] )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + header ( "HTTP/1.1 304 Not Modified" ); + } + } + } readfile($requestFile); die; } From 2a184b4b7963e155621c2da85fde0d3de1b4ade5 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 14 Nov 2012 17:00:42 -0400 Subject: [PATCH 17/70] Adding fix for double // in file fast dispatch --- workflow/public_html/bootstrap.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index 6c54758df..717350a76 100755 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -58,17 +58,18 @@ define( 'PATH_OUTTRUNK', $pathOutTrunk ); define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP ); //this is the first path, if the file exists... -$requestFile = PATH_HTML . $_SERVER['REQUEST_URI']; +$request = substr($_SERVER['REQUEST_URI'],1,strlen($_SERVER['REQUEST_URI'])); +$requestFile = PATH_HTML . $request; if (file_exists($requestFile)) { if (!is_file($requestFile)) { header( "location: /errors/error404.php?url=" . urlencode( $_SERVER['REQUEST_URI'] ) ); die; } - $pos = strripos($requestFile, ".") + 1; - $size = strlen($requestFile); + $pos = strripos($request, ".") + 1; + $size = strlen($request); if($pos < $size) { //if this file got an extension then assign the content - $ext_file = substr($requestFile, $pos, $size); + $ext_file = substr($request, $pos, $size); if ($ext_file == "gif" || $ext_file == "png" || $ext_file == "jpg") { $ext_file = 'image/'.$ext_file ; } elseif ($ext_file == "swf") { @@ -106,7 +107,7 @@ if (file_exists($requestFile)) { } } if (isset ( $_SERVER ['HTTP_IF_NONE_MATCH'] )) { - if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $filename )) { + if (str_replace ( '"', '', stripslashes ( $_SERVER ['HTTP_IF_NONE_MATCH'] ) ) == md5 ( $mtime . $requestFile )) { header ( "HTTP/1.1 304 Not Modified" ); } } From 6d52bdf65c7b151a06e17ffc38f3300097ea0d43 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 16 Nov 2012 17:13:48 -0400 Subject: [PATCH 18/70] Changing interface DB ORM classes include from class.case.php to bootstrap.php, to gain speed in Cases load time. --- workflow/engine/classes/class.case.php | 38 ++--- .../engine/classes/class.dynaFormField.php | 4 +- .../engine/classes/model/AppCacheView.php | 12 +- workflow/engine/classes/model/AppDelay.php | 2 +- .../engine/classes/model/AppDelegation.php | 10 +- workflow/engine/classes/model/AppDocument.php | 6 +- workflow/engine/classes/model/AppEvent.php | 2 +- workflow/engine/classes/model/AppHistory.php | 2 +- workflow/engine/classes/model/AppMessage.php | 2 +- workflow/engine/classes/model/AppNotes.php | 2 +- workflow/engine/classes/model/AppOwner.php | 2 +- .../engine/classes/model/AppSolrQueue.php | 4 +- workflow/engine/classes/model/AppThread.php | 2 +- workflow/engine/classes/model/Application.php | 4 +- workflow/engine/classes/model/CaseTracker.php | 2 +- .../classes/model/CaseTrackerObject.php | 2 +- .../engine/classes/model/Configuration.php | 4 +- workflow/engine/classes/model/Content.php | 2 +- workflow/engine/classes/model/DbSource.php | 4 +- workflow/engine/classes/model/Dynaform.php | 8 +- .../engine/classes/model/InputDocument.php | 4 +- workflow/engine/classes/model/IsoCountry.php | 2 +- workflow/engine/classes/model/IsoLocation.php | 2 +- .../engine/classes/model/IsoSubdivision.php | 2 +- workflow/engine/classes/model/Language.php | 8 +- .../engine/classes/model/ObjectPermission.php | 2 +- .../engine/classes/model/OutputDocument.php | 4 +- workflow/engine/classes/model/Process.php | 6 +- .../engine/classes/model/ProcessCategory.php | 2 +- workflow/engine/classes/model/ProcessUser.php | 2 +- workflow/engine/classes/model/ReportTable.php | 4 +- workflow/engine/classes/model/ReportVar.php | 2 +- workflow/engine/classes/model/Route.php | 4 +- workflow/engine/classes/model/Step.php | 2 +- .../engine/classes/model/StepSupervisor.php | 2 +- workflow/engine/classes/model/StepTrigger.php | 2 +- .../engine/classes/model/SubApplication.php | 2 +- workflow/engine/classes/model/Task.php | 4 +- workflow/engine/classes/model/TaskUser.php | 4 +- workflow/engine/classes/model/Translation.php | 2 +- workflow/engine/classes/model/Triggers.php | 4 +- workflow/engine/classes/model/Users.php | 8 +- workflow/public_html/bootstrap.php | 134 +++++++++++++++++- 43 files changed, 227 insertions(+), 95 deletions(-) diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 9a114126d..b731cac28 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -25,7 +25,7 @@ * */ -require_once ("classes/model/Application.php"); +/*require_once ("classes/model/Application.php"); require_once ("classes/model/AppCacheView.php"); require_once ("classes/model/AppDelay.php"); require_once ("classes/model/AppDelegation.php"); @@ -42,24 +42,24 @@ require_once ("classes/model/CaseTrackerObject.php"); require_once ("classes/model/Configuration.php"); require_once ("classes/model/Content.php"); require_once ("classes/model/DbSource.php"); -require_once ("classes/model/Dynaform.php"); -require_once ("classes/model/InputDocument.php"); -require_once ("classes/model/Language.php"); -require_once ("classes/model/ObjectPermission.php"); -require_once ("classes/model/OutputDocument.php"); -require_once ("classes/model/Process.php"); -require_once ("classes/model/ProcessUser.php"); -require_once ("classes/model/ReportTable.php"); -require_once ("classes/model/ReportVar.php"); -require_once ("classes/model/Route.php"); -require_once ("classes/model/Step.php"); -require_once ("classes/model/StepSupervisor.php"); -require_once ("classes/model/StepTrigger.php"); -require_once ("classes/model/SubApplication.php"); -require_once ("classes/model/Task.php"); -require_once ("classes/model/TaskUser.php"); -require_once ("classes/model/Triggers.php"); -require_once ("classes/model/Users.php"); +require_once ("classes/model/Dynaform.php");*/ +//require_once ("classes/model/InputDocument.php"); +//require_once ("classes/model/Language.php"); +//require_once ("classes/model/ObjectPermission.php"); +//require_once ("classes/model/OutputDocument.php"); +//require_once ("classes/model/Process.php"); +//require_once ("classes/model/ProcessUser.php"); +//require_once ("classes/model/ReportTable.php"); +//require_once ("classes/model/ReportVar.php"); +//require_once ("classes/model/Route.php"); +//require_once ("classes/model/Step.php"); +//require_once ("classes/model/StepSupervisor.php"); +//require_once ("classes/model/StepTrigger.php"); +//require_once ("classes/model/SubApplication.php"); +//require_once ("classes/model/Task.php"); +//require_once ("classes/model/TaskUser.php"); +//require_once ("classes/model/Triggers.php"); +//require_once ("classes/model/Users.php"); G::LoadClass("pmScript"); diff --git a/workflow/engine/classes/class.dynaFormField.php b/workflow/engine/classes/class.dynaFormField.php index 4f490f97d..3d1ab37d1 100755 --- a/workflow/engine/classes/class.dynaFormField.php +++ b/workflow/engine/classes/class.dynaFormField.php @@ -25,8 +25,8 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ -G::LoadClass('xmlDb'); -G::LoadSystem('dynaformhandler'); +//G::LoadClass('xmlDb'); +//G::LoadSystem('dynaformhandler'); /** * Dynaform Field - DynaformField class diff --git a/workflow/engine/classes/model/AppCacheView.php b/workflow/engine/classes/model/AppCacheView.php index 96e6a8fa4..300d87c77 100755 --- a/workflow/engine/classes/model/AppCacheView.php +++ b/workflow/engine/classes/model/AppCacheView.php @@ -4,7 +4,7 @@ * @package workflow.engine.classes.model */ -require_once ('classes/model/om/BaseAppCacheView.php'); +//require_once ('classes/model/om/BaseAppCacheView.php'); /** @@ -18,11 +18,11 @@ require_once ('classes/model/om/BaseAppCacheView.php'); * */ -require_once ('classes/model/Application.php'); -require_once ('classes/model/AppDelegation.php'); -require_once ('classes/model/AppDelay.php'); -require_once ('classes/model/Task.php'); -require_once ('classes/model/AdditionalTables.php'); +//require_once ('classes/model/Application.php'); +//require_once ('classes/model/AppDelegation.php'); +//require_once ('classes/model/AppDelay.php'); +//require_once ('classes/model/Task.php'); +//require_once ('classes/model/AdditionalTables.php'); /** diff --git a/workflow/engine/classes/model/AppDelay.php b/workflow/engine/classes/model/AppDelay.php index 4d4d27806..13d47a055 100755 --- a/workflow/engine/classes/model/AppDelay.php +++ b/workflow/engine/classes/model/AppDelay.php @@ -4,7 +4,7 @@ * @package workflow.engine.classes.model */ -require_once 'classes/model/om/BaseAppDelay.php'; +//require_once 'classes/model/om/BaseAppDelay.php'; /** diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index 6d83ba57e..0c2c0765f 100755 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -25,11 +25,11 @@ * */ -require_once 'classes/model/om/BaseAppDelegation.php'; -require_once ("classes/model/HolidayPeer.php"); -require_once ("classes/model/TaskPeer.php"); -require_once ("classes/model/Task.php"); -G::LoadClass( "dates" ); +//require_once 'classes/model/om/BaseAppDelegation.php'; +//require_once ("classes/model/HolidayPeer.php"); +//require_once ("classes/model/TaskPeer.php"); +//require_once ("classes/model/Task.php"); +//G::LoadClass( "dates" ); /** * Skeleton subclass for representing a row from the 'APP_DELEGATION' table. diff --git a/workflow/engine/classes/model/AppDocument.php b/workflow/engine/classes/model/AppDocument.php index 7e4f493b2..ac839192e 100755 --- a/workflow/engine/classes/model/AppDocument.php +++ b/workflow/engine/classes/model/AppDocument.php @@ -25,9 +25,9 @@ * */ -require_once 'classes/model/om/BaseAppDocument.php'; -require_once 'classes/model/Content.php'; -require_once 'classes/model/InputDocument.php'; +//require_once 'classes/model/om/BaseAppDocument.php'; +//require_once 'classes/model/Content.php'; +//require_once 'classes/model/InputDocument.php'; /** * Skeleton subclass for representing a row from the 'APP_DOCUMENT' table. diff --git a/workflow/engine/classes/model/AppEvent.php b/workflow/engine/classes/model/AppEvent.php index 28dd25975..420a1169c 100755 --- a/workflow/engine/classes/model/AppEvent.php +++ b/workflow/engine/classes/model/AppEvent.php @@ -5,7 +5,7 @@ * @package workflow.engine.classes.model */ -require_once 'classes/model/om/BaseAppEvent.php'; +//require_once 'classes/model/om/BaseAppEvent.php'; /** * Skeleton subclass for representing a row from the 'APP_EVENT' table. diff --git a/workflow/engine/classes/model/AppHistory.php b/workflow/engine/classes/model/AppHistory.php index ab69b1e17..95b0b7e35 100755 --- a/workflow/engine/classes/model/AppHistory.php +++ b/workflow/engine/classes/model/AppHistory.php @@ -4,7 +4,7 @@ * @package workflow.engine.classes.model */ -require_once 'classes/model/om/BaseAppHistory.php'; +//require_once 'classes/model/om/BaseAppHistory.php'; /** diff --git a/workflow/engine/classes/model/AppMessage.php b/workflow/engine/classes/model/AppMessage.php index 03b88fcf0..0ce2e71bc 100755 --- a/workflow/engine/classes/model/AppMessage.php +++ b/workflow/engine/classes/model/AppMessage.php @@ -23,7 +23,7 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ -require_once 'classes/model/om/BaseAppMessage.php'; +//require_once 'classes/model/om/BaseAppMessage.php'; /** * Skeleton subclass for representing a row from the 'APP_MESSAGE' table. diff --git a/workflow/engine/classes/model/AppNotes.php b/workflow/engine/classes/model/AppNotes.php index 56ca7f3d0..7040f2db5 100755 --- a/workflow/engine/classes/model/AppNotes.php +++ b/workflow/engine/classes/model/AppNotes.php @@ -1,6 +1,6 @@ Date: Mon, 19 Nov 2012 13:16:10 -0400 Subject: [PATCH 19/70] BUG-7802 In Advanced Search -> Information -> Dynaform, the Submit Button was enabled, like in edition mode. I changed the render of the Submit Button on file 'class.xmlform.php' in a view mode, to show this button disabled. --- gulliver/system/class.xmlform.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index e86f1e98e..bf9ce0a8e 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -3005,12 +3005,13 @@ class XmlForm_Field_Submit extends XmlForm_Field // return 'label .'\' disabled/>'; return "style}\" class='module_app_button___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; } elseif ($this->mode === 'view') { - // return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; + //return "style};display:none\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; //$sLinkNextStep = 'window.open("' . $owner->fields['__DYNAFORM_OPTIONS']->xmlMenu->values['NEXT_STEP'] . '", "_self");'; $html = ''; if (isset( $_SESSION['CURRENT_DYN_UID'] )) { $sLinkNextStep = 'window.location=("casesSaveDataView?UID=' . $_SESSION['CURRENT_DYN_UID'] . '");'; - $html = ''; + //$html = ''; + $html = "style};display:disabled\" disabled='disabled' class='module_app_button___gray module_app_buttonDisabled___gray {$this->className}' id=\"form[{$this->name}]\" name=\"form[{$this->name}]\" type='submit' value=\"{$this->label}\" " . (($this->onclick) ? 'onclick="' . htmlentities ( $onclick, ENT_COMPAT, 'utf-8' ) . '"' : '') . " />"; } $html .= 'name . ']" '; From e10d68ba58f04e49b5b9828245fe43a6a086e1c2 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Mon, 19 Nov 2012 14:35:10 -0400 Subject: [PATCH 20/70] BUG 7752 "No webservice to add notes" SOLVED - New feature - Web Services for add case note - Added functions "PMFAddCaseNote, WSAddCaseNote" in "class.pmFunctions.php" - Added function "addCaseNote" in "class.wsBase.php" - Added functionality for applications using Web Services * Available from version 2.0.46 --- workflow/engine/classes/class.pmFunctions.php | 73 +++ workflow/engine/classes/class.wsBase.php | 71 +++ workflow/engine/classes/model/AppNotes.php | 33 +- workflow/engine/controllers/appProxy.php | 504 +++++++++--------- workflow/engine/methods/services/pmos2.wsdl | 41 ++ workflow/engine/methods/services/soap2.php | 28 + 6 files changed, 485 insertions(+), 265 deletions(-) diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index c08b14391..e7a772d23 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -1290,6 +1290,49 @@ function WSUnpauseCase ($caseUid, $delIndex, $userUid) return $response; } +/** + * + * @method Add case note. + * + * @name WSAddCaseNote + * @label WS Add case note + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#WSAddCaseNote.28.29 + * + * @param string(32) | $caseUid | ID of the case | The unique ID of the case. + * @param string(32) | $processUid | ID of the process | The unique ID of the process. + * @param string(32) | $taskUid | ID of the task | The unique ID of the task. + * @param string(32) | $userUid | ID user | The unique ID of the user who will add note case. + * @param string | $note | Note of the case | Note of the case. + * @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case. + * @return array | $response | WS array | A WS Response associative array. + * + */ +function WSAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1) +{ + $client = WSOpen(); + + $sessionId = $_SESSION["WS_SESSION_ID"]; + + $params = array( + "sessionId" => $sessionId, + "caseUid" => $caseUid, + "processUid" => $processUid, + "taskUid" => $taskUid, + "userUid" => $userUid, + "note" => $note, + "sendMail" => $sendMail + ); + + $result = $client->__soapCall("addCaseNote", array($params)); + + $response = array(); + $response["status_code"] = $result->status_code; + $response["message"] = $result->message; + $response["time_stamp"] = $result->timestamp; + + return $response; +} + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2421,3 +2464,33 @@ function PMFUnpauseCase ($caseUid, $delIndex, $userUid) } } +/** + * + * @method Add case note. + * + * @name PMFAddCaseNote + * @label PMF Add case note + * + * @param string(32) | $caseUid | ID of the case | The unique ID of the case. + * @param string(32) | $processUid | ID of the process | The unique ID of the process. + * @param string(32) | $taskUid | ID of the task | The unique ID of the task. + * @param string(32) | $userUid | ID user | The unique ID of the user who will add note case. + * @param string | $note | Note of the case | Note of the case. + * @param int | $sendMail = 1 | Send mail | Optional parameter. If set to 1, will send an email to all participants in the case. + * @return int | $result | Result of the add case note | Returns 1 if the note has been added to the case.; otherwise, returns 0 if an error occurred. + * + */ +function PMFAddCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1) +{ + G::LoadClass("wsBase"); + + $ws = new wsBase(); + $result = $ws->addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail); + + if ($result->status_code == 0) { + return 1; + } else { + return 0; + } +} + diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index 83735c483..d386d54d9 100755 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -30,6 +30,7 @@ require_once ("classes/model/AppCacheView.php"); require_once ("classes/model/AppDelegation.php"); require_once ("classes/model/AppDocument.php"); require_once ("classes/model/AppDelay.php"); +require_once ("classes/model/AppNotes.php"); require_once ("classes/model/AppThread.php"); require_once ("classes/model/Department.php"); require_once ("classes/model/Dynaform.php"); @@ -3026,5 +3027,75 @@ class wsBase return $result; } } + + /** + * Add case note + * + * @param string caseUid : ID of the case. + * @param string processUid : ID of the process. + * @param string taskUid : ID of the task. + * @param string userUid : The unique ID of the user who will add note case. + * @param string note : Note of the case. + * @param int sendMail : Optional parameter. If set to 1, will send an email to all participants in the case. + * @return $result will return an object + */ + public function addCaseNote($caseUid, $processUid, $taskUid, $userUid, $note, $sendMail = 1) + { + try { + if (empty($caseUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " caseUid"); + + return $result; + } + + if (empty($processUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " processUid"); + + return $result; + } + + if (empty($taskUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " taskUid"); + + return $result; + } + + if (empty($userUid)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid"); + + return $result; + } + + if (empty($note)) { + $result = new wsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " note"); + + return $result; + } + + $case = new Cases(); + + $respView = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "VIEW"); + $respBlock = $case->getAllObjectsFrom($processUid, $caseUid, $taskUid, $userUid, "BLOCK"); + + if ($respView["CASES_NOTES"] == 0 && $respBlock["CASES_NOTES"] == 0) { + $result = new wsResponse(100, G::LoadTranslation("ID_CASES_NOTES_NO_PERMISSIONS")); + + return $result; + } + + //Add note case + $appNote = new AppNotes(); + $response = $appNote->addCaseNote($caseUid, $userUid, $note, $sendMail); + + //Response + $result = new wsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); + + return $result; + } catch (Exception $e) { + $result = new wsResponse(100, $e->getMessage()); + + return $result; + } + } } diff --git a/workflow/engine/classes/model/AppNotes.php b/workflow/engine/classes/model/AppNotes.php index 56ca7f3d0..e30dd7458 100755 --- a/workflow/engine/classes/model/AppNotes.php +++ b/workflow/engine/classes/model/AppNotes.php @@ -217,10 +217,10 @@ class AppNotes extends BaseAppNotes $sTo = ((($aUser['USR_FIRSTNAME'] != '') || ($aUser['USR_LASTNAME'] != '')) ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>'; $oSpool = new spoolRun(); - if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { - $aConfiguration['MESS_RAUTH'] = 0; - } else { - $aConfiguration['MESS_RAUTH'] = 1; + if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { + $aConfiguration['MESS_RAUTH'] = 0; + } else { + $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig( array ('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'],'MESS_SERVER' => $aConfiguration['MESS_SERVER'],'MESS_PORT' => $aConfiguration['MESS_PORT'],'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'],'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'],'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false,'SMTPSecure' => isset( $aConfiguration['SMTPSecure'] ) ? $aConfiguration['SMTPSecure'] : '') ); @@ -235,5 +235,30 @@ class AppNotes extends BaseAppNotes throw $oException; } } + + public function addCaseNote($applicationUid, $userUid, $note, $sendMail) + { + $response = $this->postNewNote($applicationUid, $userUid, $note, false); + + if ($sendMail == 1) { + G::LoadClass("case"); + + $case = new Cases(); + + $p = $case->getUsersParticipatedInCase($applicationUid); + $noteRecipientsList = array(); + + foreach ($p["array"] as $key => $userParticipated) { + $noteRecipientsList[] = $key; + } + + $noteRecipients = implode(",", $noteRecipientsList); + $note = stripslashes($note); + + $this->sendNoteNotification($applicationUid, $userUid, $note, $noteRecipients); + } + + return $response; + } } diff --git a/workflow/engine/controllers/appProxy.php b/workflow/engine/controllers/appProxy.php index c2e198546..b9d31cd71 100644 --- a/workflow/engine/controllers/appProxy.php +++ b/workflow/engine/controllers/appProxy.php @@ -1,37 +1,37 @@ - - * @herits Controller - * @access public - */ - -class AppProxy extends HttpProxyController -{ - - /** - * Get Notes List - * - * @param int $httpData->start - * @param int $httpData->limit - * @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION']) - * @return array containg the case notes - */ - function getNotesList ($httpData) - { - $appUid = null; - - if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { - $appUid = $httpData->appUid; - } else { - if (isset( $_SESSION['APPLICATION'] )) { - $appUid = $_SESSION['APPLICATION']; - } - } - - G::LoadClass( 'case' ); + + * @herits Controller + * @access public + */ + +class AppProxy extends HttpProxyController +{ + + /** + * Get Notes List + * + * @param int $httpData->start + * @param int $httpData->limit + * @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION']) + * @return array containg the case notes + */ + function getNotesList ($httpData) + { + $appUid = null; + + if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { + $appUid = $httpData->appUid; + } else { + if (isset( $_SESSION['APPLICATION'] )) { + $appUid = $_SESSION['APPLICATION']; + } + } + + G::LoadClass( 'case' ); $case = new Cases(); $caseLoad = ''; @@ -39,236 +39,218 @@ class AppProxy extends HttpProxyController $caseLoad = $case->loadCase($appUid); $httpData->pro = $caseLoad['PRO_UID']; } - - $proUid = (!isset($httpData->pro)) ? $_SESSION['PROCESS'] : $httpData->pro; - $tasUid = (!isset($httpData->tas)) ? ((isset($_SESSION['TASK'])) ? $_SESSION['TASK'] : '') : $httpData->tas; - $usrUid = $_SESSION['USER_LOGGED']; - - $respView = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'VIEW' ); - $respBlock = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'BLOCK' ); - - if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { - return array ('totalCount' => 0,'notes' => array (),'noPerms' => 1 - ); - } - - require_once ("classes/model/AppNotes.php"); - - if (! isset( $appUid )) { - throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); - } - - $usrUid = isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : ""; - $appNotes = new AppNotes(); - $response = $appNotes->getNotesList( $appUid, '', $httpData->start, $httpData->limit ); - - return $response['array']; - } - - /** - * post Note Action - * - * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION']) - * @return array containg the case notes - */ - function postNote ($httpData) - { + + $proUid = (!isset($httpData->pro)) ? $_SESSION['PROCESS'] : $httpData->pro; + $tasUid = (!isset($httpData->tas)) ? ((isset($_SESSION['TASK'])) ? $_SESSION['TASK'] : '') : $httpData->tas; + $usrUid = $_SESSION['USER_LOGGED']; + + $respView = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'VIEW' ); + $respBlock = $case->getAllObjectsFrom( $proUid, $appUid, $tasUid, $usrUid, 'BLOCK' ); + + if ($respView['CASES_NOTES'] == 0 && $respBlock['CASES_NOTES'] == 0) { + return array ('totalCount' => 0,'notes' => array (),'noPerms' => 1 + ); + } + + require_once ("classes/model/AppNotes.php"); + + if (! isset( $appUid )) { + throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); + } + + $usrUid = isset( $_SESSION['USER_LOGGED'] ) ? $_SESSION['USER_LOGGED'] : ""; + $appNotes = new AppNotes(); + $response = $appNotes->getNotesList( $appUid, '', $httpData->start, $httpData->limit ); + + return $response['array']; + } + + /** + * post Note Action + * + * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION']) + * @return array containg the case notes + */ + function postNote ($httpData) + { + require_once ("classes/model/AppNotes.php"); + //extract(getExtJSParams()); - if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { - $appUid = $httpData->appUid; - } else { - $appUid = $_SESSION['APPLICATION']; - } - - if (! isset( $appUid )) { - throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); - } - - $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; - require_once ("classes/model/AppNotes.php"); - - $appNotes = new AppNotes(); - $noteContent = addslashes( $httpData->noteText ); - - $result = $appNotes->postNewNote( $appUid, $usrUid, $noteContent, false ); - + if (isset( $httpData->appUid ) && trim( $httpData->appUid ) != "") { + $appUid = $httpData->appUid; + } else { + $appUid = $_SESSION['APPLICATION']; + } + + if (! isset( $appUid )) { + throw new Exception( 'Can\'t resolve the Apllication ID for this request.' ); + } + + $usrUid = (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : ""; + $noteContent = addslashes( $httpData->noteText ); + //Disabling the controller response because we handle a special behavior - $this->setSendResponse( false ); - + $this->setSendResponse(false); + + //Add note case + $appNote = new AppNotes(); + $response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail)); + //Send the response to client - @ini_set( 'implicit_flush', 1 ); - ob_start(); - echo G::json_encode( $result ); - @ob_flush(); - @flush(); - @ob_end_flush(); - ob_implicit_flush( 1 ); - - //Send notification in background - if (intval( $httpData->swSendMail ) == 1) { - G::LoadClass( "case" ); - - $oCase = new Cases(); - - $p = $oCase->getUsersParticipatedInCase( $appUid ); - $noteRecipientsList = array (); - - foreach ($p["array"] as $key => $userParticipated) { - $noteRecipientsList[] = $key; - } - - $noteRecipients = implode( ",", $noteRecipientsList ); - $noteContent = stripslashes( $noteContent ); - - $appNotes->sendNoteNotification( $appUid, $usrUid, $noteContent, $noteRecipients ); - } - } - - /** - * request to open the case summary - * - * @param string $httpData->appUid - * @param string $httpData->delIndex - * @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid - */ - function requestOpenSummary ($httpData) - { - global $RBAC; - $this->success = true; - $this->dynUid = ''; - - switch ($RBAC->userCanAccess( 'PM_CASES' )) { - case - 2: - throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_SYSTEM' ) ); - break; - case - 1: - throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_PAGE' ) ); - break; - } - - G::LoadClass( 'case' ); - $case = new Cases(); - - if ($RBAC->userCanAccess( 'PM_ALLCASES' ) < 0 && $case->userParticipatedInCase( $httpData->appUid, $_SESSION['USER_LOGGED'] ) == 0) { - throw new Exception( G::LoadTranslation( 'ID_NO_PERMISSION_NO_PARTICIPATED' ) ); - } - - if ($httpData->action == 'sent') { // Get the last valid delegation for participated list - $criteria = new Criteria(); - $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); - $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); - $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); - $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); - if (AppDelegationPeer::doCount($criteria) > 0) { - $dataset = AppDelegationPeer::doSelectRS($criteria); - $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $dataset->next(); - $row = $dataset->getRow(); - $httpData->delIndex = $row['DEL_INDEX']; - } - } - $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); - $process = new Process(); - $processData = $process->load( $applicationFields['PRO_UID'] ); - - if (isset( $processData['PRO_DYNAFORMS']['PROCESS'] )) { - $this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS']; - } - - $_SESSION['_applicationFields'] = $applicationFields; - $_SESSION['_processData'] = $processData; - $_SESSION['APPLICATION'] = $httpData->appUid; - $_SESSION['INDEX'] = $httpData->delIndex; - $_SESSION['PROCESS'] = $applicationFields['PRO_UID']; - $_SESSION['TASK'] = $applicationFields['TAS_UID']; - $_SESSION['STEP_POSITION'] = ''; - } - - /** - * get the case summary data - * - * @param string $httpData->appUid - * @param string $httpData->delIndex - * @return array containg the case summary data - */ - function getSummary ($httpData) - { - $labels = array (); - $form = new Form( 'cases/cases_Resume', PATH_XMLFORM, SYS_LANG ); - G::LoadClass( 'case' ); - $case = new Cases(); - - foreach ($form->fields as $fieldName => $field) { - $labels[$fieldName] = $field->label; - } - - if (isset( $_SESSION['_applicationFields'] ) && $_SESSION['_processData']) { - $applicationFields = $_SESSION['_applicationFields']; - unset( $_SESSION['_applicationFields'] ); - $processData = $_SESSION['_processData']; - unset( $_SESSION['_processData'] ); - } else { - if ($httpData->action == 'sent') { // Get the last valid delegation for participated list - $criteria = new Criteria(); - $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); - $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); - $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); - $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); - if (AppDelegationPeer::doCount($criteria) > 0) { - $dataset = AppDelegationPeer::doSelectRS($criteria); - $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $dataset->next(); - $row = $dataset->getRow(); - $httpData->delIndex = $row['DEL_INDEX']; - } - } - $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); - $process = new Process(); - $processData = $process->load( $applicationFields['PRO_UID'] ); - } - - $data = array (); - $task = new Task(); - $taskData = $task->load( $applicationFields['TAS_UID'] ); - $currentUser = $applicationFields['CURRENT_USER'] != '' ? $applicationFields['CURRENT_USER'] : '[' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ']'; - - $data[] = array ('label' => $labels['PRO_TITLE'],'value' => $processData['PRO_TITLE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['TITLE'],'value' => $applicationFields['TITLE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['APP_NUMBER'],'value' => $applicationFields['APP_NUMBER'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['STATUS'],'value' => $applicationFields['STATUS'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['APP_UID'],'value' => $applicationFields['APP_UID'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['CREATOR'],'value' => $applicationFields['CREATOR'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['CREATE_DATE'],'value' => $applicationFields['CREATE_DATE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['UPDATE_DATE'],'value' => $applicationFields['UPDATE_DATE'],'section' => $labels['TITLE1'] - ); - $data[] = array ('label' => $labels['DESCRIPTION'],'value' => $applicationFields['DESCRIPTION'],'section' => $labels['TITLE1'] - ); - + @ini_set("implicit_flush", 1); + ob_start(); + echo G::json_encode($response); + @ob_flush(); + @flush(); + @ob_end_flush(); + ob_implicit_flush(1); + } + + /** + * request to open the case summary + * + * @param string $httpData->appUid + * @param string $httpData->delIndex + * @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid + */ + function requestOpenSummary ($httpData) + { + global $RBAC; + $this->success = true; + $this->dynUid = ''; + + switch ($RBAC->userCanAccess( 'PM_CASES' )) { + case - 2: + throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_SYSTEM' ) ); + break; + case - 1: + throw new Exception( G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_PAGE' ) ); + break; + } + + G::LoadClass( 'case' ); + $case = new Cases(); + + if ($RBAC->userCanAccess( 'PM_ALLCASES' ) < 0 && $case->userParticipatedInCase( $httpData->appUid, $_SESSION['USER_LOGGED'] ) == 0) { + throw new Exception( G::LoadTranslation( 'ID_NO_PERMISSION_NO_PARTICIPATED' ) ); + } + + if ($httpData->action == 'sent') { // Get the last valid delegation for participated list + $criteria = new Criteria(); + $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); + $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); + $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); + if (AppDelegationPeer::doCount($criteria) > 0) { + $dataset = AppDelegationPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + $row = $dataset->getRow(); + $httpData->delIndex = $row['DEL_INDEX']; + } + } + $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); + $process = new Process(); + $processData = $process->load( $applicationFields['PRO_UID'] ); + + if (isset( $processData['PRO_DYNAFORMS']['PROCESS'] )) { + $this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS']; + } + + $_SESSION['_applicationFields'] = $applicationFields; + $_SESSION['_processData'] = $processData; + $_SESSION['APPLICATION'] = $httpData->appUid; + $_SESSION['INDEX'] = $httpData->delIndex; + $_SESSION['PROCESS'] = $applicationFields['PRO_UID']; + $_SESSION['TASK'] = $applicationFields['TAS_UID']; + $_SESSION['STEP_POSITION'] = ''; + } + + /** + * get the case summary data + * + * @param string $httpData->appUid + * @param string $httpData->delIndex + * @return array containg the case summary data + */ + function getSummary ($httpData) + { + $labels = array (); + $form = new Form( 'cases/cases_Resume', PATH_XMLFORM, SYS_LANG ); + G::LoadClass( 'case' ); + $case = new Cases(); + + foreach ($form->fields as $fieldName => $field) { + $labels[$fieldName] = $field->label; + } + + if (isset( $_SESSION['_applicationFields'] ) && $_SESSION['_processData']) { + $applicationFields = $_SESSION['_applicationFields']; + unset( $_SESSION['_applicationFields'] ); + $processData = $_SESSION['_processData']; + unset( $_SESSION['_processData'] ); + } else { + if ($httpData->action == 'sent') { // Get the last valid delegation for participated list + $criteria = new Criteria(); + $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteria->add(AppDelegationPeer::APP_UID, $httpData->appUid); + $criteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); + $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); + if (AppDelegationPeer::doCount($criteria) > 0) { + $dataset = AppDelegationPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + $row = $dataset->getRow(); + $httpData->delIndex = $row['DEL_INDEX']; + } + } + $applicationFields = $case->loadCase( $httpData->appUid, $httpData->delIndex ); + $process = new Process(); + $processData = $process->load( $applicationFields['PRO_UID'] ); + } + + $data = array (); + $task = new Task(); + $taskData = $task->load( $applicationFields['TAS_UID'] ); + $currentUser = $applicationFields['CURRENT_USER'] != '' ? $applicationFields['CURRENT_USER'] : '[' . G::LoadTranslation( 'ID_UNASSIGNED' ) . ']'; + + $data[] = array ('label' => $labels['PRO_TITLE'],'value' => $processData['PRO_TITLE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['TITLE'],'value' => $applicationFields['TITLE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['APP_NUMBER'],'value' => $applicationFields['APP_NUMBER'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['STATUS'],'value' => $applicationFields['STATUS'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['APP_UID'],'value' => $applicationFields['APP_UID'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['CREATOR'],'value' => $applicationFields['CREATOR'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['CREATE_DATE'],'value' => $applicationFields['CREATE_DATE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['UPDATE_DATE'],'value' => $applicationFields['UPDATE_DATE'],'section' => $labels['TITLE1'] + ); + $data[] = array ('label' => $labels['DESCRIPTION'],'value' => $applicationFields['DESCRIPTION'],'section' => $labels['TITLE1'] + ); + // note added by krlos pacha carlos[at]colosa[dot]com //getting this field if it doesn't exist. Related 7994 bug - $taskData['TAS_TITLE'] = (array_key_exists( 'TAS_TITLE', $taskData )) ? $taskData['TAS_TITLE'] : Content::Load( "TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG ); - - $data[] = array ('label' => $labels['TAS_TITLE'],'value' => $taskData['TAS_TITLE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['CURRENT_USER'],'value' => $currentUser,'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_DELEGATE_DATE'],'value' => $applicationFields['DEL_DELEGATE_DATE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_INIT_DATE'],'value' => $applicationFields['DEL_INIT_DATE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_TASK_DUE_DATE'],'value' => $applicationFields['DEL_TASK_DUE_DATE'],'section' => $labels['TITLE2'] - ); - $data[] = array ('label' => $labels['DEL_FINISH_DATE'],'value' => $applicationFields['DEL_FINISH_DATE'],'section' => $labels['TITLE2'] - ); + $taskData['TAS_TITLE'] = (array_key_exists( 'TAS_TITLE', $taskData )) ? $taskData['TAS_TITLE'] : Content::Load( "TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG ); + + $data[] = array ('label' => $labels['TAS_TITLE'],'value' => $taskData['TAS_TITLE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['CURRENT_USER'],'value' => $currentUser,'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_DELEGATE_DATE'],'value' => $applicationFields['DEL_DELEGATE_DATE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_INIT_DATE'],'value' => $applicationFields['DEL_INIT_DATE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_TASK_DUE_DATE'],'value' => $applicationFields['DEL_TASK_DUE_DATE'],'section' => $labels['TITLE2'] + ); + $data[] = array ('label' => $labels['DEL_FINISH_DATE'],'value' => $applicationFields['DEL_FINISH_DATE'],'section' => $labels['TITLE2'] + ); //$data[] = array('label'=>$labels['DYN_UID'] , 'value' => $processData['PRO_DYNAFORMS']['PROCESS'];, 'section'=>$labels['DYN_UID']); - return $data; - } -} - + return $data; + } +} + diff --git a/workflow/engine/methods/services/pmos2.wsdl b/workflow/engine/methods/services/pmos2.wsdl index 1ebd37649..8531027d5 100755 --- a/workflow/engine/methods/services/pmos2.wsdl +++ b/workflow/engine/methods/services/pmos2.wsdl @@ -871,6 +871,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -1099,6 +1121,12 @@ + + + + + + @@ -1261,6 +1289,10 @@ + + + + @@ -1625,6 +1657,15 @@ + + + + + + + + + diff --git a/workflow/engine/methods/services/soap2.php b/workflow/engine/methods/services/soap2.php index 1544ff581..8b908d577 100755 --- a/workflow/engine/methods/services/soap2.php +++ b/workflow/engine/methods/services/soap2.php @@ -1190,6 +1190,33 @@ function unpauseCase ($params) return $result; } +function addCaseNote($params) +{ + $result = isValidSession($params->sessionId); + + if ($result->status_code != 0) { + return $result; + } + + if (ifPermission($params->sessionId, "PM_CASES") == 0) { + $result = new wsResponse(2, "You do not have privileges"); + + return $result; + } + + $ws = new wsBase(); + $result = $ws->addCaseNote( + $params->caseUid, + $params->processUid, + $params->taskUid, + $params->userUid, + $params->note, + (isset($params->sendMail))? $params->sendMail : 1 + ); + + return $result; +} + $server = new SoapServer($wsdl); $server->addFunction("Login"); @@ -1233,5 +1260,6 @@ $server->addFunction("deleteCase"); $server->addFunction("cancelCase"); $server->addFunction("pauseCase"); $server->addFunction("unpauseCase"); +$server->addFunction("addCaseNote"); $server->handle(); From 6c0d91b0e608e37afeff7d404a031a41a09994a9 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 19 Nov 2012 15:03:13 -0400 Subject: [PATCH 21/70] Adding "translations" js file --- gulliver/system/class.headPublisher.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index 2feb17554..3f447dc11 100644 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -9,7 +9,7 @@ * Copyright (C) 2004 - 2011 Colosa Inc. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as + * it under the terms of the GNU Affero General Public License as$translationsFile = "/js/ext/translation." . SYS_LANG . ".js"; * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * @@ -18,7 +18,7 @@ * 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 + * You should have received a copy of the GNU Affero General Public LicensegetExtJsLibraries * along with this program. If not, see . * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., @@ -40,7 +40,6 @@ class headPublisher /* extJsSkin init coreLoad flag*/ var $extJsInit = 'false'; - /* extJsSkin store the current skin for the ExtJs*/ var $extJsSkin = ''; @@ -62,6 +61,8 @@ class headPublisher /* tplVariable array, to store the variables for template power */ var $tplVariable = array (); + var $translationsFile; + var $leimnudInitString = ' var leimnud = new maborak(); leimnud.make({ zip:true, @@ -90,6 +91,7 @@ class headPublisher public function __construct () { $this->addScriptFile( "/js/maborak/core/maborak.js" ); + $this->translationsFile = "/js/ext/translation." . SYS_LANG . ".js"; } function &getSingleton () @@ -211,12 +213,16 @@ class headPublisher $this->addScriptFile( "/js/widgets/js-calendar/unicode-letter.js" ); //$this->addScriptFile( "/js/widgets/js-calendar/lang/" . $sysLang . ".js" ); - + $head = ''; $head .= '' . $this->title . "\n"; foreach ($this->scriptFiles as $file) { $head .= "\n"; } + if(!in_array( $this->translationsFile, $this->scriptFiles)) { + $head .= "\n"; + } + $head .= "\n"; - $head .= " \n"; + // $head .= " \n"; if (! isset( $this->extJsSkin ) || $this->extJsSkin == '') { $this->extJsSkin = 'xtheme-gray'; @@ -390,13 +396,16 @@ class headPublisher } function getExtJsLibraries () - { + { $script = ''; if (isset( $this->extJsLibrary ) && is_array( $this->extJsLibrary )) { foreach ($this->extJsLibrary as $file) { $script .= " \n"; } } + if(!in_array( $this->translationsFile, $this->extJsLibrary)) { + $script .= " \n"; + } return $script; } From 83b9c448fae4b4c7639568efb06ec3eb4623b371 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Mon, 19 Nov 2012 15:16:29 -0400 Subject: [PATCH 22/70] BUG 8281 I added code to save variable __ERROR__ SOLVED I added code to save variable __ERROR__ and I verified that the variable __ERROR__ was refreshed for new cases --- workflow/engine/classes/class.pmScript.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workflow/engine/classes/class.pmScript.php b/workflow/engine/classes/class.pmScript.php index 49237f580..f61331c15 100755 --- a/workflow/engine/classes/class.pmScript.php +++ b/workflow/engine/classes/class.pmScript.php @@ -545,6 +545,7 @@ function handleErrors ($errno, $errstr, $errfile, $errline) if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { G::LoadClass( 'case' ); $oCase = new Cases(); + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } registerError( 1, $errstr, $errline - 1, $sCode ); @@ -578,6 +579,7 @@ function handleFatalErrors ($buffer) } global $oPMScript; if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } G::header( 'Location: ' . $aNextStep['PAGE'] ); @@ -586,6 +588,7 @@ function handleFatalErrors ($buffer) $_SESSION['_NO_EXECUTE_TRIGGERS_'] = 1; global $oPMScript; if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } G::header( 'Location: ' . $_SERVER['REQUEST_URI'] ); @@ -602,6 +605,7 @@ function handleFatalErrors ($buffer) } global $oPMScript; if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { + $oPMScript->aFields['__ERROR__'] = $aAux[0]; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } G::header( 'Location: ' . $aNextStep['PAGE'] ); From f420618e82ef7ee70c24cba4741fa04536b502c2 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Mon, 19 Nov 2012 15:45:30 -0400 Subject: [PATCH 23/70] BUG 8281 I changed the variable $errstr SOLVED I changed the variable $errstr --- workflow/engine/classes/class.pmScript.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/classes/class.pmScript.php b/workflow/engine/classes/class.pmScript.php index f61331c15..f55e7786a 100755 --- a/workflow/engine/classes/class.pmScript.php +++ b/workflow/engine/classes/class.pmScript.php @@ -545,7 +545,7 @@ function handleErrors ($errno, $errstr, $errfile, $errline) if (isset($oPMScript) && isset($_SESSION['APPLICATION'])) { G::LoadClass( 'case' ); $oCase = new Cases(); - $oPMScript->aFields['__ERROR__'] = $aAux[0]; + $oPMScript->aFields['__ERROR__'] = $errstr; $oCase->updateCase($_SESSION['APPLICATION'], array('APP_DATA' => $oPMScript->aFields)); } registerError( 1, $errstr, $errline - 1, $sCode ); From 3ef0b0bbc526c3fff3c5a72a36de6dd6e03f908b Mon Sep 17 00:00:00 2001 From: user Date: Mon, 19 Nov 2012 17:19:19 -0400 Subject: [PATCH 24/70] Commenting include DB interface files require, to gain time loading. --- workflow/engine/methods/cases/casesList_Ajax.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/engine/methods/cases/casesList_Ajax.php b/workflow/engine/methods/cases/casesList_Ajax.php index e8a1295ff..0a4bae004 100755 --- a/workflow/engine/methods/cases/casesList_Ajax.php +++ b/workflow/engine/methods/cases/casesList_Ajax.php @@ -21,7 +21,7 @@ * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ -require_once 'classes/model/Application.php'; +/*require_once 'classes/model/Application.php'; require_once 'classes/model/Users.php'; require_once 'classes/model/AppThread.php'; require_once 'classes/model/AppDelay.php'; @@ -30,7 +30,7 @@ require_once 'classes/model/Task.php'; require_once ("classes/model/AppCacheView.php"); require_once ("classes/model/AppDelegation.php"); require_once ("classes/model/AdditionalTables.php"); -require_once ("classes/model/AppDelay.php"); +require_once ("classes/model/AppDelay.php");*/ G::LoadClass( 'case' ); $actionAjax = isset( $_REQUEST['actionAjax'] ) ? $_REQUEST['actionAjax'] : null; From 7c1902a68e551dc3466f6e458357babd56d7ccc7 Mon Sep 17 00:00:00 2001 From: jennylee Date: Tue, 20 Nov 2012 09:56:34 -0400 Subject: [PATCH 25/70] BUG-7802 In Advanced Search -> Information -> Dynaform, the Submit Button was enabled, like in edition mode. I added a javascript code to disable the Submit Button on file 'workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php'. --- .../cases/casesHistoryDynaformPage_Ajax.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php b/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php index 3257165ed..1686b3af3 100644 --- a/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php +++ b/workflow/engine/methods/cases/casesHistoryDynaformPage_Ajax.php @@ -434,12 +434,28 @@ if ($actionAjax == 'historyDynaformGridPreview') { $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = '#'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'return false;'; $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['DYNUIDPRINT'] = $_POST['DYN_UID']; + ?> + + AddContent( 'dynaform', 'xmlform', $_SESSION['PROCESS'] . '/' . $_POST['DYN_UID'], '', $Fields['APP_DATA'], '', '', 'view' ); ?> \n"; + $head .= "\n"; return $head; } diff --git a/workflow/engine/bin/tasks/libraries.json b/workflow/engine/bin/tasks/libraries.json index 0281a861e..c7365cd89 100644 --- a/workflow/engine/bin/tasks/libraries.json +++ b/workflow/engine/bin/tasks/libraries.json @@ -135,6 +135,12 @@ "mini": "gulliver/js/maborak/core/module.dom.js", "minify": true }, + { + "name": "module.abbr", + "full": "gulliver/js/maborak/core/module.abbr.js", + "mini": "gulliver/js/maborak/core/module.abbr.js", + "minify": true + }, { "name": "module.dashboard", "full": "gulliver/js/maborak/core/module.dashboard.js", diff --git a/workflow/engine/classes/class.dynaformEditor.php b/workflow/engine/classes/class.dynaformEditor.php index ec01b0181..308863436 100755 --- a/workflow/engine/classes/class.dynaformEditor.php +++ b/workflow/engine/classes/class.dynaformEditor.php @@ -219,6 +219,7 @@ class dynaformEditor extends WebResource //for showHide tab option @Neyek $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_CONDITIONS_EDITOR"), $sName . '[9]', 'dynaformEditor.changeToShowHide', 'dynaformEditor.saveShowHide'); $G_PUBLISH->AddContent('panel-close'); + $oHeadPublisher->addScriptFile("/js/maborak/core/maborak.loader.js",2); $oHeadPublisher->addScriptFile('/jscore/dynaformEditor/core/dynaformEditor.js'); //$oHeadPublisher->addScriptFile('/js/dveditor/core/dveditor.js'); //$oHeadPublisher->addScriptFile('/codepress/codepress.js',1); From 8eaacc678a5714edc7cfb4a0f500d26a50979e20 Mon Sep 17 00:00:00 2001 From: ralph Date: Mon, 26 Nov 2012 17:51:55 -0400 Subject: [PATCH 52/70] Adding SteepSuperVisorPeer interface class --- workflow/engine/classes/model/StepSupervisorPeer.php | 4 ++-- workflow/public_html/sysGeneric.php | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/workflow/engine/classes/model/StepSupervisorPeer.php b/workflow/engine/classes/model/StepSupervisorPeer.php index 6e92b7a78..02bb99925 100755 --- a/workflow/engine/classes/model/StepSupervisorPeer.php +++ b/workflow/engine/classes/model/StepSupervisorPeer.php @@ -5,10 +5,10 @@ */ // include base peer class - require_once 'classes/model/om/BaseStepSupervisorPeer.php'; + //require_once 'classes/model/om/BaseStepSupervisorPeer.php'; // include object class - include_once 'classes/model/StepSupervisor.php'; + //include_once 'classes/model/StepSupervisor.php'; /** diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index f7a9d13da..be9967c27 100755 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -581,6 +581,9 @@ Bootstrap::registerClass('StepPeer', PATH_HOME . "engine/classes/mode Bootstrap::registerClass('BaseStepSupervisor', PATH_HOME . "engine/classes/model/om/BaseStepSupervisor.php"); Bootstrap::registerClass('StepSupervisor', PATH_HOME . "engine/classes/model/StepSupervisor.php"); +Bootstrap::registerClass('BaseStepSupervisorPeer',PATH_HOME . "engine/classes/model/om/BaseStepSupervisorPeer.php"); +Bootstrap::registerClass('StepSupervisorPeer', PATH_HOME . "engine/classes/model/StepSupervisorPeer.php"); + Bootstrap::registerClass('BaseStepTrigger', PATH_HOME . "engine/classes/model/om/BaseStepTrigger.php"); Bootstrap::registerClass('StepTrigger', PATH_HOME . "engine/classes/model/StepTrigger.php"); Bootstrap::registerClass('StepTriggerPeer', PATH_HOME . "engine/classes/model/StepTriggerPeer.php"); From c0ec55ee2b237182054132e9bb8d6194153f4166 Mon Sep 17 00:00:00 2001 From: ralph Date: Mon, 26 Nov 2012 18:03:59 -0400 Subject: [PATCH 53/70] Fix for Json message makes Trigger dropdown list fail. --- gulliver/js/form/core/form.js | 2 +- gulliver/js/maborak/core/maborak.js | 2 +- gulliver/methods/defaultAjax.php | 444 +++++++++++++------------- gulliver/system/class.webResource.php | 4 +- 4 files changed, 230 insertions(+), 222 deletions(-) diff --git a/gulliver/js/form/core/form.js b/gulliver/js/form/core/form.js index dda581c76..35ce0be5d 100755 --- a/gulliver/js/form/core/form.js +++ b/gulliver/js/form/core/form.js @@ -284,7 +284,7 @@ function G_Field ( form, element, name ) return me.element.value; }; this.toJSONString=function() { - return '{'+me.name+':'+me.element.value.toJSONString()+'}'; + return '{"'+me.name+'":'+me.element.value.toJSONString()+'}'; }; this.highLight=function(){ try{ diff --git a/gulliver/js/maborak/core/maborak.js b/gulliver/js/maborak/core/maborak.js index 92a315c83..4bdab5cba 100644 --- a/gulliver/js/maborak/core/maborak.js +++ b/gulliver/js/maborak/core/maborak.js @@ -960,7 +960,7 @@ var callServer;callServer=new leimnud.module.rpc.xmlhttp({url:me.form.ajaxServer else{for(var i=0;i1)dd.remove(0);}else{for(var key in dd.options){dd.options[key]=null;}} for(var o=0;o. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - - /*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/ - if ( isset($_SESSION['CURRENT_PAGE_INITILIZATION']) ) - eval($_SESSION['CURRENT_PAGE_INITILIZATION']); - - - //G::LoadThirdParty('pear/json','class.json'); - //$json=new Services_JSON(); - if (!defined('XMLFORM_AJAX_PATH')) define('XMLFORM_AJAX_PATH',PATH_XMLFORM); - - $_DBArray = array(); - if (isset($_SESSION['_DBArray'])) { - $_DBArray = $_SESSION['_DBArray']; - } - - $xmlFile = G::getUIDName(urlDecode($_POST['form'])); - $sPath = XMLFORM_AJAX_PATH; - - //if the xmlform file doesn't exist, then try with the plugins folders - if ( !is_file ( XMLFORM_AJAX_PATH . $xmlFile ) ) { - $aux = explode ( PATH_SEP, $xmlFile ); - //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment - if ( count($aux) == 2 && defined ( 'G_PLUGIN_CLASS' ) ) { - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->isRegisteredFolder($aux[0]) ) { - $sPath = PATH_PLUGINS; - } - } - } - $G_FORM=new form( $xmlFile , $sPath ); - $G_FORM->id=urlDecode($_POST['form']); - $G_FORM->values=isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array(); - $newValues=(Bootstrap::json_decode(urlDecode(stripslashes($_POST['fields'])))); - if (isset($_POST['grid'])) { - $_POST['row'] = (int)$_POST['row']; - $aAux = array(); - foreach ($newValues as $sKey => $newValue) { - $newValue = (array)$newValue; - $aKeys = array_keys($newValue); - $aValues = array(); - for ($i = 1; $i <= ($_POST['row'] - 1); $i++) { - $aValues[$i] = array($aKeys[0] => ''); - } - $aValues[$_POST['row']] = array($aKeys[0] => $newValue[$aKeys[0]]); - $newValues[$sKey]->$_POST['grid'] = $aValues; - unset($newValues[$sKey]->$aKeys[0]); - } - } - - //Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid. - if (sizeof($newValues)>1 && isset($_POST['grid'])){ - $fieldBase = array(); - foreach ($newValues as $key => $values){ - for ($r2=1; $r2 <= $_POST['row']; $r2++){ - foreach ($values as $class => $value){ - if ($class == $_POST['grid']){ - $value = (array) $value; - $arrayK = $value[$r2]; - foreach ($arrayK as $key2 => $val) { - $fieldBase[$r2][$key2] = is_array($val)? $val[$key2] : $val; - } - } - } - } - } - $newValues = array(); +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +/*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/ +if (isset( $_SESSION['CURRENT_PAGE_INITILIZATION'] )) + eval( $_SESSION['CURRENT_PAGE_INITILIZATION'] ); + + // G::LoadThirdParty('pear/json','class.json'); + // $json=new Services_JSON(); +if (! defined( 'XMLFORM_AJAX_PATH' )) + define( 'XMLFORM_AJAX_PATH', PATH_XMLFORM ); + +$_DBArray = array (); +if (isset( $_SESSION['_DBArray'] )) { + $_DBArray = $_SESSION['_DBArray']; +} + +$xmlFile = G::getUIDName( urlDecode( $_POST['form'] ) ); +$sPath = XMLFORM_AJAX_PATH; + +//if the xmlform file doesn't exist, then try with the plugins folders +if (! is_file( XMLFORM_AJAX_PATH . $xmlFile )) { + $aux = explode( PATH_SEP, $xmlFile ); + //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment + if (count( $aux ) == 2 && defined( 'G_PLUGIN_CLASS' )) { + $oPluginRegistry = & PMPluginRegistry::getSingleton(); + if ($oPluginRegistry->isRegisteredFolder( $aux[0] )) { + $sPath = PATH_PLUGINS; + } + } +} +$G_FORM = new form( $xmlFile, $sPath ); +$G_FORM->id = urlDecode( $_POST['form'] ); +$G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array (); +$newValues = (Bootstrap::json_decode( urlDecode( stripslashes( $_POST['fields'] ) ) )); +if (isset( $_POST['grid'] )) { + $_POST['row'] = (int) $_POST['row']; + $aAux = array (); + foreach ($newValues as $sKey => $newValue) { + $newValue = (array) $newValue; + $aKeys = array_keys( $newValue ); + $aValues = array (); + for ($i = 1; $i <= ($_POST['row'] - 1); $i ++) { + $aValues[$i] = array ($aKeys[0] => '' + ); + } + $aValues[$_POST['row']] = array ($aKeys[0] => $newValue[$aKeys[0]] + ); + $newValues[$sKey]->$_POST['grid'] = $aValues; + unset( $newValues[$sKey]->$aKeys[0] ); + } +} + +//Next Lines re-build newValues array to send multiple dependent fields merged by row into a grid. +if (sizeof( $newValues ) > 1 && isset( $_POST['grid'] )) { + $fieldBase = array (); + foreach ($newValues as $key => $values) { + for ($r2 = 1; $r2 <= $_POST['row']; $r2 ++) { + foreach ($values as $class => $value) { + if ($class == $_POST['grid']) { + $value = (array) $value; + $arrayK = $value[$r2]; + foreach ($arrayK as $key2 => $val) { + $fieldBase[$r2][$key2] = is_array( $val ) ? $val[$key2] : $val; + } + } + } + } + } + $newValues = array (); //$fieldBase = (array) $fieldBase; - $newValues[0]->$_POST['grid'] = $fieldBase; - } - - //Resolve dependencies - //Returns an array ($dependentFields) with the names of the fields - //that depends of fields passed through AJAX ($_GET/$_POST) - $dependentFields=array(); $aux=array(); - for($r=0;$rsetValues($newValues[$r]); - //Search dependent fields - foreach($newValues[$r] as $k => $v) { - if (!is_array($v)) { - $myDependentFields = subDependencies( $k , $G_FORM , $aux ); - $_SESSION[$G_FORM->id][$k] = $v; - } - else { - foreach($v[$_POST['row']] as $k1 => $v1) { - $myDependentFields = subDependencies( $k1 , $G_FORM , $aux, $_POST['grid'] ); - $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; - } - } - $dependentFields=array_merge($dependentFields, $myDependentFields); - } - } - if (isset($_POST['grid'])) $G_FORM->values=isset($_SESSION[$G_FORM->id]) ? $_SESSION[$G_FORM->id] : array(); - - $dependentFields=array_unique($dependentFields); - - //Parse and update the new content - $template = PATH_CORE . 'templates/xmlform.html'; - $newContent=$G_FORM->getFields($template, (isset($_POST['row']) ? $_POST['row'] : -1)); - //Returns the dependentFields's content - $sendContent=array(); - $r=0; - - foreach($dependentFields as $d) { - $sendContent[$r]->name=$d; - $sendContent[$r]->content=NULL; - if (!isset($_POST['grid'])) { - if (isset($G_FORM->fields[$d])) { - foreach($G_FORM->fields[$d] as $attribute => $value) { - switch($attribute) { - case 'type': - $sendContent[$r]->content->{$attribute}=$value;break; - case 'options': - $sendContent[$r]->content->{$attribute}=toJSArray($value, $sendContent[$r]->content->type); break; - } - } - $sendContent[$r]->value=isset($G_FORM->values[$d]) ? $G_FORM->values[$d] : ''; - } - } - else { - foreach($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { - switch($attribute) { - case 'type': - $sendContent[$r]->content->{$attribute}=$value; break; - case 'options': - if ($sendContent[$r]->content->type != 'text') { - $sendContent[$r]->content->{$attribute}=toJSArray($value); - } - else { - $sendContent[$r]->content->{$attribute}=toJSArray((isset($value[$_POST['row']]) ? array($value[$_POST['row']]) : array())); - } - break; - } - } - $sendContent[$r]->value=isset($G_FORM->values[$_POST['grid']][$_POST['row']][$d]) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; - } - $r++; - } - echo(Bootstrap::json_encode($sendContent)); - - function toJSArray($array, $type= '') - { - $result=array(); - foreach($array as $k => $v){ - $o=NULL; - $o->key=$k; - // TODO: review the condition to make the differentiation to dependent dropdowns in a grid function. - // this way of validation is if you have a dependent field in text fields - $o->value= ($type =='text' || $type =='textarea')? $k:$v; - $result[]=$o; - } - return $result; - } - - function subDependencies( $k , &$G_FORM , &$aux, $grid = '') { - if (array_search( $k, $aux )!==FALSE) return array(); - if ($grid == '') { - if (!array_key_exists( $k , $G_FORM->fields )) return array(); - if (!isset($G_FORM->fields[$k]->dependentFields)) return array(); - $aux[] = $k; - if (strpos($G_FORM->fields[$k]->dependentFields, ',') !== false) { - $myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields); - } - else { - $myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields); - } - for( $r=0 ; $r < sizeof($myDependentFields) ; $r++ ) { - if ($myDependentFields[$r]=="") unset($myDependentFields[$r]); - } - // $mD = $myDependentFields; - // foreach( $mD as $ki) { - // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) ); - // } - } - else { - if (!array_key_exists( $k , $G_FORM->fields[$grid]->fields )) return array(); - if (!isset($G_FORM->fields[$grid]->fields[$k]->dependentFields)) return array(); - $aux[] = $k; - if (strpos($G_FORM->fields[$grid]->fields[$k]->dependentFields, ',') !== false) { - $myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields); - } - else { - $myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields); - } - for( $r=0 ; $r < sizeof($myDependentFields) ; $r++ ) { - if ($myDependentFields[$r]=="") unset($myDependentFields[$r]); - } -// $mD = $myDependentFields; -// foreach( $mD as $ki) { -// $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) ); -// } - } - return $myDependentFields; - } -?> + $newValues[0]->$_POST['grid'] = $fieldBase; +} + +//Resolve dependencies +//Returns an array ($dependentFields) with the names of the fields +//that depends of fields passed through AJAX ($_GET/$_POST) +$dependentFields = array (); +$aux = array (); +for ($r = 0; $r < sizeof( $newValues ); $r ++) { + $newValues[$r] = (array) $newValues[$r]; + $G_FORM->setValues( $newValues[$r] ); + //Search dependent fields + foreach ($newValues[$r] as $k => $v) { + if (! is_array( $v )) { + $myDependentFields = subDependencies( $k, $G_FORM, $aux ); + $_SESSION[$G_FORM->id][$k] = $v; + } else { + foreach ($v[$_POST['row']] as $k1 => $v1) { + $myDependentFields = subDependencies( $k1, $G_FORM, $aux, $_POST['grid'] ); + $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1; + } + } + $dependentFields = array_merge( $dependentFields, $myDependentFields ); + } +} +if (isset( $_POST['grid'] )) + $G_FORM->values = isset( $_SESSION[$G_FORM->id] ) ? $_SESSION[$G_FORM->id] : array (); + +$dependentFields = array_unique( $dependentFields ); + +//Parse and update the new content +$template = PATH_CORE . 'templates/xmlform.html'; +$newContent = $G_FORM->getFields( $template, (isset( $_POST['row'] ) ? $_POST['row'] : - 1) ); +//Returns the dependentFields's content +$sendContent = array (); +$r = 0; + +foreach ($dependentFields as $d) { + $sendContent[$r]->name = $d; + $sendContent[$r]->content = NULL; + if (! isset( $_POST['grid'] )) { + if (isset( $G_FORM->fields[$d] )) { + foreach ($G_FORM->fields[$d] as $attribute => $value) { + switch ($attribute) { + case 'type': + $sendContent[$r]->content->{$attribute} = $value; + break; + case 'options': + $sendContent[$r]->content->{$attribute} = toJSArray( $value, $sendContent[$r]->content->type ); + break; + } + } + $sendContent[$r]->value = isset( $G_FORM->values[$d] ) ? $G_FORM->values[$d] : ''; + } + } else { + foreach ($G_FORM->fields[$_POST['grid']]->fields[$d] as $attribute => $value) { + switch ($attribute) { + case 'type': + $sendContent[$r]->content->{$attribute} = $value; + break; + case 'options': + if ($sendContent[$r]->content->type != 'text') { + $sendContent[$r]->content->{$attribute} = toJSArray( $value ); + } else { + $sendContent[$r]->content->{$attribute} = toJSArray( (isset( $value[$_POST['row']] ) ? array ($value[$_POST['row']] + ) : array ()) ); + } + break; + } + } + $sendContent[$r]->value = isset( $G_FORM->values[$_POST['grid']][$_POST['row']][$d] ) ? $G_FORM->values[$_POST['grid']][$_POST['row']][$d] : ''; + } + $r ++; +} +echo (Bootstrap::json_encode( $sendContent )); + +function toJSArray ($array, $type = '') +{ + $result = array (); + foreach ($array as $k => $v) { + $o = NULL; + $o->key = $k; + // TODO: review the condition to make the differentiation to dependent dropdowns in a grid function. + // this way of validation is if you have a dependent field in text fields + $o->value = ($type == 'text' || $type == 'textarea') ? $k : $v; + $result[] = $o; + } + return $result; +} + +function subDependencies ($k, &$G_FORM, &$aux, $grid = '') +{ + if (array_search( $k, $aux ) !== FALSE) + return array (); + if ($grid == '') { + if (! array_key_exists( $k, $G_FORM->fields )) + return array (); + if (! isset( $G_FORM->fields[$k]->dependentFields )) + return array (); + $aux[] = $k; + if (strpos( $G_FORM->fields[$k]->dependentFields, ',' ) !== false) { + $myDependentFields = explode( ',', $G_FORM->fields[$k]->dependentFields ); + } else { + $myDependentFields = explode( '|', $G_FORM->fields[$k]->dependentFields ); + } + for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) { + if ($myDependentFields[$r] == "") + unset( $myDependentFields[$r] ); + } + // $mD = $myDependentFields; + // foreach( $mD as $ki) { + // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux ) ); + // } + } else { + if (! array_key_exists( $k, $G_FORM->fields[$grid]->fields )) + return array (); + if (! isset( $G_FORM->fields[$grid]->fields[$k]->dependentFields )) + return array (); + $aux[] = $k; + if (strpos( $G_FORM->fields[$grid]->fields[$k]->dependentFields, ',' ) !== false) { + $myDependentFields = explode( ',', $G_FORM->fields[$grid]->fields[$k]->dependentFields ); + } else { + $myDependentFields = explode( '|', $G_FORM->fields[$grid]->fields[$k]->dependentFields ); + } + for ($r = 0; $r < sizeof( $myDependentFields ); $r ++) { + if ($myDependentFields[$r] == "") + unset( $myDependentFields[$r] ); + } + // $mD = $myDependentFields; + // foreach( $mD as $ki) { + // $myDependentFields = array_merge( $myDependentFields , subDependencies( $ki , $G_FORM , $aux, $grid) ); + // } + } + return $myDependentFields; +} diff --git a/gulliver/system/class.webResource.php b/gulliver/system/class.webResource.php index a64d3596d..021d00ba9 100755 --- a/gulliver/system/class.webResource.php +++ b/gulliver/system/class.webResource.php @@ -109,7 +109,7 @@ class WebResource } /* end class WebResource */ -if (! function_exists( 'json_encode' )) { +/*if (! function_exists( 'json_encode' )) { G::LoadThirdParty( 'pear/json', 'class.json' ); function json_encode (&$value) @@ -127,5 +127,5 @@ if (! function_exists( 'json_decode' )) { $json = new Services_JSON(); return $json->decode( $value ); } -} +}*/ From 11c7fe3b425fbba7f947dd973283dd529c17ae80 Mon Sep 17 00:00:00 2001 From: jennylee Date: Tue, 27 Nov 2012 10:21:32 -0400 Subject: [PATCH 54/70] BUG-6855 Error message in 'Database Conections' clicking in Edit or Delete title. I put an 'IF' validation in file 'workflow/engine/classes/class.propelTable.php.php', to prevent that this columns were sortable. --- gulliver/methods/propelTableAjax.php | 2 +- workflow/engine/classes/class.propelTable.php | 11 ++++++++--- .../engine/xmlform/dbConnections/dbConnections.xml | 5 ++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gulliver/methods/propelTableAjax.php b/gulliver/methods/propelTableAjax.php index b0a0bb573..a0f06a5cc 100755 --- a/gulliver/methods/propelTableAjax.php +++ b/gulliver/methods/propelTableAjax.php @@ -77,7 +77,7 @@ //order by $orderBy = get_ajax_value('order'); - if (isset($orderBy) && $orderBy !== 'ZDZXRHkzVzNmWVE___%3DASC' && $orderBy !== 'ZDZXRHkzUzRnSFhFdVE___%3DASC' && $orderBy !== 'ZXFpRXk0VzhlQQ______%3DASC') { + if (isset($orderBy)) { $orderBy = urldecode($orderBy); $ntable->orderBy = $orderBy; } diff --git a/workflow/engine/classes/class.propelTable.php b/workflow/engine/classes/class.propelTable.php index c4f616b8a..0cbd101df 100755 --- a/workflow/engine/classes/class.propelTable.php +++ b/workflow/engine/classes/class.propelTable.php @@ -338,8 +338,13 @@ class propelTable $this->tpl->newBlock( "headers" ); $sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'ASC')) ? 'DESC' : 'ASC'); $sortOrder = (((isset( $this->aOrder[$this->fields[$r]['Name']] )) && ($this->aOrder[$this->fields[$r]['Name']] === 'DESC')) ? '' : $sortOrder); - $this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage; - $this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;'; + if ($this->style[$r]['titleVisibility'] != '0') { + $this->style[$r]['href'] = $this->ownerPage . '?order=' . ($sortOrder !== '' ? (G::createUID( '', $this->fields[$r]['Name'] ) . '=' . $sortOrder) : '') . '&page=' . $this->currentPage; + $this->style[$r]['onsort'] = $this->id . '.doSort("' . G::createUID( '', $this->fields[$r]['Name'] ) . '" , "' . $sortOrder . '");return false;'; + } else { + $this->style[$r]['href'] = '#'; + $this->style[$r]['onsort'] = 'return false;'; + } if (isset( $this->style[$r]['href'] )) { $this->tpl->assign( "href", $this->style[$r]['href'] ); } @@ -492,7 +497,7 @@ class propelTable } } //Hidden titles - if (! (strpos( ' linknew button endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) { + if (! (strpos( ' linknew button link endgrid2 ', ' ' . $this->fields[$r]['Type'] . ' ' ) === false)) { $this->style[$r]['titleVisibility'] = '0'; } //Align titles diff --git a/workflow/engine/xmlform/dbConnections/dbConnections.xml b/workflow/engine/xmlform/dbConnections/dbConnections.xml index 5074224c8..f5120dc37 100755 --- a/workflow/engine/xmlform/dbConnections/dbConnections.xml +++ b/workflow/engine/xmlform/dbConnections/dbConnections.xml @@ -22,15 +22,14 @@ - + Edit - + Delete - From 7604e72740a556e7b41a270cc93c9ab70af90b24 Mon Sep 17 00:00:00 2001 From: jennylee Date: Tue, 27 Nov 2012 10:47:34 -0400 Subject: [PATCH 55/70] BUG-6855 Error message in 'Database Conections' clicking in Edit or Delete title. I put an 'IF' validation in file 'workflow/engine/classes/class.propelTable.php.php', to prevent that this columns were sortable. --- workflow/engine/xmlform/dbConnections/dbConnections.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/engine/xmlform/dbConnections/dbConnections.xml b/workflow/engine/xmlform/dbConnections/dbConnections.xml index f5120dc37..d9b931c44 100755 --- a/workflow/engine/xmlform/dbConnections/dbConnections.xml +++ b/workflow/engine/xmlform/dbConnections/dbConnections.xml @@ -21,11 +21,11 @@ Description - + Edit - + Delete From 23d03a7d2e6eab537700489ff8c6c1c5aa63b338 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 27 Nov 2012 12:56:10 -0400 Subject: [PATCH 56/70] BUG 8283 "PMFAddInputDocument function request" SOLVED - New feature - PM Function for add a input document - Added function "PMFAddInputDocument" in "class.pmFunctions.php" - The QA team should test with: * Dynaforms * KnowledgeTree plugin * Available from version 2.0.46 --- workflow/engine/classes/class.case.php | 203 +++++++++++++++++- workflow/engine/classes/class.pmFunctions.php | 84 +++++++- .../methods/cases/cases_SaveDocument.php | 180 ++++++---------- .../templates/triggers/triggersTree.php | 3 - .../engine/xmlform/triggers/triggerCopy.xml | 8 + 5 files changed, 351 insertions(+), 127 deletions(-) diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index b731cac28..250ebe228 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -3467,6 +3467,201 @@ class Cases } } + /** + * Add a input document + * + * Return the application document ID + * + * @param string $inputDocumentUid Input document ID + * @param string $appDocUid Application document ID + * @param int $docVersion Document version + * @param string $appDocType Document type + * @param string $appDocComment Document comment + * @param string $inputDocumentAction Action, posible values: null or empty (Add), "R" (Replace), "NV" (New Version) + * @param string $applicationUid Application ID + * @param int $delIndex Delegation index + * @param string $taskUid Task ID + * @param string $userUid User ID + * @param string $option Option, posible values: "xmlform", "file" + * @param string $file File ($_FILES["form"]["name"]["APP_DOC_FILENAME"] or path to file) + * @param int $fileError File error ($_FILES["form"]["error"]["APP_DOC_FILENAME"] or 0) + * @param string $fileTmpName File temporal name ($_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] or null) + * @return string Return application document ID + */ + public function addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $inputDocumentAction, + $applicationUid, + $delIndex, + $taskUid, + $userUid, + $option, + $file, + $fileError = 0, + $fileTmpName = null + ) { + $appDocFileName = null; + $sw = 0; + + switch ($option) { + case "xmlform": + $appDocFileName = $file; + + if ($fileError == 0) { + $sw = 1; + } + break; + case "file": + $appDocFileName = basename($file); + + if (file_exists($file) && is_file($file)) { + $sw = 1; + } + break; + } + + if ($sw == 0) { + return null; + } + + //Info + $inputDocument = new InputDocument(); + $arrayInputDocumentData = $inputDocument->load($inputDocumentUid); + + //Get the Custom Folder ID (create if necessary) + $appFolder = new AppFolder(); + $folderId = $appFolder->createFromPath($arrayInputDocumentData["INP_DOC_DESTINATION_PATH"], $applicationUid); + + $tags = $appFolder->parseTags($arrayInputDocumentData["INP_DOC_TAGS"], $applicationUid); + + $appDocument = new AppDocument(); + $arrayField = array(); + + switch ($inputDocumentAction) { + case "R": + //Replace + $arrayField = array( + "APP_DOC_UID" => $appDocUid, + "APP_UID" => $applicationUid, + "DOC_VERSION" => $docVersion, + "DEL_INDEX" => $delIndex, + "USR_UID" => $userUid, + "DOC_UID" => $inputDocumentUid, + "APP_DOC_TYPE" => $appDocType, + "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), + "APP_DOC_COMMENT" => $appDocComment, + "APP_DOC_TITLE" => "", + "APP_DOC_FILENAME" => $appDocFileName, + "FOLDER_UID" => $folderId, + "APP_DOC_TAGS" => $tags + ); + + $appDocument->update($arrayField); + break; + case "NV": + //New Version + $arrayField = array( + "APP_DOC_UID" => $appDocUid, + "APP_UID" => $applicationUid, + "DEL_INDEX" => $delIndex, + "USR_UID" => $userUid, + "DOC_UID" => $inputDocumentUid, + "APP_DOC_TYPE" => $appDocType, + "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), + "APP_DOC_COMMENT" => $appDocComment, + "APP_DOC_TITLE" => "", + "APP_DOC_FILENAME" => $appDocFileName, + "FOLDER_UID" => $folderId, + "APP_DOC_TAGS" => $tags + ); + + $appDocument->create($arrayField); + break; + default: + //New + $arrayField = array( + "APP_UID" => $applicationUid, + "DEL_INDEX" => $delIndex, + "USR_UID" => $userUid, + "DOC_UID" => $inputDocumentUid, + "APP_DOC_TYPE" => $appDocType, + "APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"), + "APP_DOC_COMMENT" => $appDocComment, + "APP_DOC_TITLE" => "", + "APP_DOC_FILENAME" => $appDocFileName, + "FOLDER_UID" => $folderId, + "APP_DOC_TAGS" => $tags + ); + + $appDocument->create($arrayField); + break; + } + + //Save the file + $appDocUid = $appDocument->getAppDocUid(); + $docVersion = $appDocument->getDocVersion(); + $arrayInfo = pathinfo($appDocument->getAppDocFilename()); + $extension = (isset($arrayInfo["extension"]))? $arrayInfo["extension"] : null; + $strPathName = PATH_DOCUMENT . $applicationUid . PATH_SEP; + $strFileName = $appDocUid . "_" . $docVersion . "." . $extension; + + switch ($option) { + case "xmlform": + G::uploadFile($fileTmpName, $strPathName, $strFileName); + break; + case "file": + $umaskOld = umask(0); + + if (!is_dir($strPathName)) { + G::verifyPath($strPathName, true); + } + + copy($file, $strPathName . $strFileName); + chmod($strPathName . $strFileName, 0666); + umask($umaskOld); + break; + } + + //Plugin Hook PM_UPLOAD_DOCUMENT for upload document + $pluginRegistry = &PMPluginRegistry::getSingleton(); + + if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) { + $triggerDetail = $pluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); + $documentData = new uploadDocumentData( + $applicationUid, + $userUid, + $strPathName . $strFileName, + $arrayField["APP_DOC_FILENAME"], + $appDocUid, + $docVersion + ); + $uploadReturn = $pluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); + + if ($uploadReturn) { + $arrayField["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace; + + if (!isset($arrayField["APP_DOC_UID"])) { + $arrayField["APP_DOC_UID"] = $appDocUid; + } + + if (!isset($arrayField["DOC_VERSION"])) { + $arrayField["DOC_VERSION"] = $docVersion; + } + + $appDocument->update($arrayField); + + unlink($strPathName . $strFileName); + } + } + //End plugin + + return $appDocUid; + } + /* * Return the input documents list to Review * @@ -4717,10 +4912,10 @@ class Cases if ($sTo != null) { $oSpool = new spoolRun(); - if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { - $aConfiguration['MESS_RAUTH'] = 0; - } else { - $aConfiguration['MESS_RAUTH'] = 1; + if ($aConfiguration['MESS_RAUTH'] == false || (is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false')) { + $aConfiguration['MESS_RAUTH'] = 0; + } else { + $aConfiguration['MESS_RAUTH'] = 1; } $oSpool->setConfig(array( diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 1e6437032..937b8bdd5 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -1446,6 +1446,65 @@ function PMFUserList () //its test was successfull return $rows; } +/** + * @method + * + * Add a input document. + * + * @name PMFAddInputDocument + * @label PMF Add a input document. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFAddInputDocument.28.29 + * + * @param string(32) | $inputDocumentUid | ID of the input document | The unique ID of the input document. + * @param string(32) | $appDocUid | ID of the application document | The unique ID of the application document; if action is set to null or empty (Add), then this parameter it set to null or empty. + * @param int | $docVersion | Document version | Document version. + * @param string | $appDocType = "INPUT" | Document type | Document type. + * @param string | $appDocComment | Document comment | Document comment. + * @param string | $inputDocumentAction | Action | Action, posible values: null or empty (Add), "R" (Replace), "NV" (New Version). + * @param string(32) | $caseUid | ID of the case | The unique ID of the case. + * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. + * @param string(32) | $taskUid | ID of the task | The unique ID of the task. + * @param string(32) | $userUid | ID user | The unique ID of the user who will add a input document. + * @param string | $option = "file" | Option | Option, value: "file". + * @param string | $file = "path_to_file/myfile.txt" | File, path to file | File, path to file. + * @return string | $appDocUid | ID of the application document | Returns ID if it has added the input document successfully; otherwise, returns null or empty if an error occurred. + * + */ +function PMFAddInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType = "INPUT", + $appDocComment, + $inputDocumentAction, + $caseUid, + $delIndex, + $taskUid, + $userUid, + $option = "file", + $file = "path_to_file/myfile.txt" +) { + G::LoadClass("case"); + $case = new Cases(); + + $appDocUid = $case->addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $inputDocumentAction, + $caseUid, + $delIndex, + $taskUid, + $userUid, + $option, + $file + ); + + return $appDocUid; +} + /** * * @method Generates an Output Document @@ -2365,10 +2424,13 @@ function PMFGetCaseNotes ($applicationID, $type = 'array', $userUid = '') /** * - * @method Delete a specified case. + * @method + * + * Delete a specified case. * * @name PMFDeleteCase * @label PMF Delete a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFDeleteCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @return int | $result | Result of the elimination | Returns 1 if the case is delete successfully; otherwise, returns 0 if an error occurred. @@ -2390,10 +2452,13 @@ function PMFDeleteCase ($caseUid) /** * - * @method Cancel a specified case. + * @method + * + * Cancel a specified case. * * @name PMFCancelCase * @label PMF Cancel a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFCancelCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. @@ -2427,10 +2492,13 @@ function PMFCancelCase ($caseUid, $delIndex, $userUid) /** * - * @method Pauses a specified case. + * @method + * + * Pauses a specified case. * * @name PMFPauseCase * @label PMF Pauses a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFPauseCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. @@ -2465,10 +2533,13 @@ function PMFPauseCase ($caseUid, $delIndex, $userUid, $unpauseDate = null) /** * - * @method Unpause a specified case. + * @method + * + * Unpause a specified case. * * @name PMFUnpauseCase * @label PMF Unpause a specified case. + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFUnpauseCase.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. @@ -2492,10 +2563,13 @@ function PMFUnpauseCase ($caseUid, $delIndex, $userUid) /** * - * @method Add case note. + * @method + * + * Add case note. * * @name PMFAddCaseNote * @label PMF Add case note + * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFAddCaseNote.28.29 * * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param string(32) | $processUid | ID of the process | The unique ID of the process. diff --git a/workflow/engine/methods/cases/cases_SaveDocument.php b/workflow/engine/methods/cases/cases_SaveDocument.php index d4209dd10..21f64884f 100755 --- a/workflow/engine/methods/cases/cases_SaveDocument.php +++ b/workflow/engine/methods/cases/cases_SaveDocument.php @@ -59,136 +59,86 @@ if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] die(); } -$docUid = $_POST['form']['DOC_UID']; -$appDocUid = $_POST['form']['APP_DOC_UID']; -$docVersion = $_POST['form']['docVersion']; -$actionType = $_POST['form']['actionType']; +G::LoadClass("case"); -//load the variables -G::LoadClass( 'case' ); -$oCase = new Cases(); -$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); -$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); -$Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); +$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"] +$appDocUid = $_POST["form"]["APP_DOC_UID"]; +$docVersion = intval($_POST["form"]["docVersion"]); +$appDocType = $_POST["form"]["APP_DOC_TYPE"]; +$appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : ""; +$actionType = $_POST["form"]["actionType"]; -#trigger debug routines... +$case = new Cases(); +$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "cases_List"); +//Load the fields +$arrayField = $case->loadCase($_SESSION["APPLICATION"]); +$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants()); -//cleaning debug variables -$_SESSION['TRIGGER_DEBUG']['ERRORS'] = Array (); -$_SESSION['TRIGGER_DEBUG']['DATA'] = Array (); -$_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = Array (); -$_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = Array (); +//Triggers +$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); -$triggers = $oCase->loadTriggers( $_SESSION['TASK'], 'INPUT_DOCUMENT', $_GET['UID'], 'AFTER' ); +//Trigger debug routines +//Cleaning debug variables +$_SESSION["TRIGGER_DEBUG"]["ERRORS"] = array(); +$_SESSION["TRIGGER_DEBUG"]["DATA"] = array(); +$_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = array(); +$_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = array(); -$_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] = count( $triggers ); -$_SESSION['TRIGGER_DEBUG']['TIME'] = 'AFTER'; -if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_NAMES'] = $oCase->getTriggerNames( $triggers ); - $_SESSION['TRIGGER_DEBUG']['TRIGGERS_VALUES'] = $triggers; +$_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] = count($arrayTrigger); +$_SESSION["TRIGGER_DEBUG"]["TIME"] = "AFTER"; + +if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { + $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = $case->getTriggerNames($arrayTrigger); + $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger; } -if ($_SESSION['TRIGGER_DEBUG']['NUM_TRIGGERS'] != 0) { - //Execute after triggers - Start - $Fields['APP_DATA'] = $oCase->ExecuteTriggers( $_SESSION['TASK'], 'INPUT_DOCUMENT', $_GET['UID'], 'AFTER', $Fields['APP_DATA'] ); - //Execute after triggers - End +if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { + //Trigger - Execute after - Start + $arrayField["APP_DATA"] = $case->executeTriggers( + $_SESSION["TASK"], + "INPUT_DOCUMENT", + $inputDocumentUid, + "AFTER", + $arrayField["APP_DATA"] + ); + //Trigger - Execute after - End } -//save data -$aData = array (); -$aData['APP_NUMBER'] = $Fields['APP_NUMBER']; -$aData['APP_PROC_STATUS'] = $Fields['APP_PROC_STATUS']; -$aData['APP_DATA'] = $Fields['APP_DATA']; -$aData['DEL_INDEX'] = $_SESSION['INDEX']; -$aData['TAS_UID'] = $_SESSION['TASK']; -//$aData = $oCase->loadCase($_SESSION['APPLICATION']); -$oCase->updateCase( $_SESSION['APPLICATION'], $aData ); +//Save data +$arrayData = array(); +$arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"]; +$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"]; +$arrayData["APP_DATA"] = $arrayField["APP_DATA"]; +$arrayData["DEL_INDEX"] = $_SESSION["INDEX"]; +$arrayData["TAS_UID"] = $_SESSION["TASK"]; -//save info +$case->updateCase($_SESSION["APPLICATION"], $arrayData); - -//require_once ("classes/model/AppDocument.php"); -//require_once ('classes/model/AppFolder.php'); -//require_once ('classes/model/InputDocument.php'); - -$oInputDocument = new InputDocument(); -$aID = $oInputDocument->load( $_GET['UID'] ); - -$oAppDocument = new AppDocument(); - -//Get the Custom Folder ID (create if necessary) -$oFolder = new AppFolder(); -$folderId = $oFolder->createFromPath( $aID['INP_DOC_DESTINATION_PATH'] ); - -//Tags -$fileTags = $oFolder->parseTags( $aID['INP_DOC_TAGS'] ); - -switch ($actionType) { - case "R": //replace - $aFields = array ('APP_DOC_UID' => $appDocUid,'APP_UID' => $_SESSION['APPLICATION'],'DOC_VERSION' => $docVersion,'DEL_INDEX' => $_SESSION['INDEX'],'USR_UID' => $_SESSION['USER_LOGGED'],'DOC_UID' => $docUid,'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],'APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_COMMENT' => isset( $_POST['form']['APP_DOC_COMMENT'] ) ? $_POST['form']['APP_DOC_COMMENT'] : '','APP_DOC_TITLE' => '','APP_DOC_FILENAME' => isset( $_FILES['form']['name']['APP_DOC_FILENAME'] ) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '','FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags - ); - - $oAppDocument->update( $aFields ); - break; - case "NV": //New Version - - - $aFields = array ('APP_DOC_UID' => $appDocUid,'APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'USR_UID' => $_SESSION['USER_LOGGED'],'DOC_UID' => $docUid,'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],'APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_COMMENT' => isset( $_POST['form']['APP_DOC_COMMENT'] ) ? $_POST['form']['APP_DOC_COMMENT'] : '','APP_DOC_TITLE' => '','APP_DOC_FILENAME' => isset( $_FILES['form']['name']['APP_DOC_FILENAME'] ) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '','FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags - ); - - $oAppDocument->create( $aFields ); - break; - default: //New - $aFields = array ('APP_UID' => $_SESSION['APPLICATION'],'DEL_INDEX' => $_SESSION['INDEX'],'USR_UID' => $_SESSION['USER_LOGGED'],'DOC_UID' => $docUid,'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],'APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_COMMENT' => isset( $_POST['form']['APP_DOC_COMMENT'] ) ? $_POST['form']['APP_DOC_COMMENT'] : '','APP_DOC_TITLE' => '','APP_DOC_FILENAME' => isset( $_FILES['form']['name']['APP_DOC_FILENAME'] ) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '','FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags - ); - - $oAppDocument->create( $aFields ); - break; -} - -$sAppDocUid = $oAppDocument->getAppDocUid(); -$iDocVersion = $oAppDocument->getDocVersion(); -$info = pathinfo( $oAppDocument->getAppDocFilename() ); -$ext = (isset( $info['extension'] ) ? $info['extension'] : ''); - -//save the file -if (! empty( $_FILES['form'] )) { - if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) { - $sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP; - $sFileName = $sAppDocUid . "_" . $iDocVersion . '.' . $ext; - G::uploadFile( $_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName ); - - //Plugin Hook PM_UPLOAD_DOCUMENT for upload document - $oPluginRegistry = & PMPluginRegistry::getSingleton(); - if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) { - $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); - $oData['APP_UID'] = $_SESSION['APPLICATION']; - $documentData = new uploadDocumentData( $_SESSION['APPLICATION'], $_SESSION['USER_LOGGED'], $sPathName . $sFileName, $aFields['APP_DOC_FILENAME'], $sAppDocUid, $iDocVersion ); - - $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); - if ($uploadReturn) { - $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; - if (! isset( $aFields['APP_DOC_UID'] )) { - $aFields['APP_DOC_UID'] = $sAppDocUid; - } - if (! isset( $aFields['DOC_VERSION'] )) { - $aFields['DOC_VERSION'] = $iDocVersion; - } - //$oAppDocument1 = new AppDocument(); - //G::pr($aFields);die; - $oAppDocument->update( $aFields ); - unlink( $sPathName . $sFileName ); - } - } - //end plugin - } +//Add Input Document +if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { + $appDocUid = $case->addInputDocument( + $inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + $actionType, + $_SESSION["APPLICATION"], + $_SESSION["INDEX"], + $_SESSION["TASK"], + $_SESSION["USER_LOGGED"], + "xmlform", + $_FILES["form"]["name"]["APP_DOC_FILENAME"], + $_FILES["form"]["error"]["APP_DOC_FILENAME"], + $_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"] + ); } //go to the next step //if (!isset($_POST['form']['MORE'])) { if (false) { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] ); + $aNextStep = $case->getNextStep($_SESSION["PROCESS"], $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["STEP_POSITION"]); $_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { @@ -212,7 +162,7 @@ if (false) { G::header( 'location: ' . $_SERVER['HTTP_REFERER'] ); die(); } else { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); + $aNextStep = $case->getNextStep($_SESSION["PROCESS"], $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["STEP_POSITION"] - 1); $_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { @@ -225,7 +175,7 @@ if (false) { die(); } } else { - $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); + $aNextStep = $case->getNextStep($_SESSION["PROCESS"], $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["STEP_POSITION"] - 1); $_SESSION['STEP_POSITION'] = $aNextStep['POSITION']; if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { diff --git a/workflow/engine/templates/triggers/triggersTree.php b/workflow/engine/templates/triggers/triggersTree.php index f5d39b062..3d840e026 100755 --- a/workflow/engine/templates/triggers/triggersTree.php +++ b/workflow/engine/templates/triggers/triggersTree.php @@ -70,9 +70,6 @@ try { } } - // error_log("\n*****\n", 3, "/home/victor/MyLog.log"); - // error_log(print_r($oTree, true), 3, "/home/victor/MyLog.log"); - echo $oTree->render(); } catch (Exception $e) { die($e->getMessage()); diff --git a/workflow/engine/xmlform/triggers/triggerCopy.xml b/workflow/engine/xmlform/triggers/triggerCopy.xml index a675c6229..d45f947e7 100644 --- a/workflow/engine/xmlform/triggers/triggerCopy.xml +++ b/workflow/engine/xmlform/triggers/triggerCopy.xml @@ -13,10 +13,12 @@ + Process @@ -25,11 +27,13 @@ + Trigger @@ -42,17 +46,21 @@ + Description of the new trigger + Script From 4d53c8af4f7c37c854cd0e798d3c10fbfd1a9ef5 Mon Sep 17 00:00:00 2001 From: ralph Date: Tue, 27 Nov 2012 13:44:02 -0400 Subject: [PATCH 57/70] Performace adds: - jpeg MIME content. - changing echo instead print for js and css files. --- gulliver/system/class.bootstrap.php | 4 ++-- workflow/public_html/sysGeneric.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index 71f26ab1e..7eece039c 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -341,7 +341,7 @@ class Bootstrap if (strtolower( $typefile ) == 'js' && $typearray[0] == 'translation') { Bootstrap::sendHeaders( $filename, 'text/javascript', $download, $downloadFileName ); $output = Bootstrap::streamJSTranslationFile( $filename, $typearray[1] ); - print $output; + echo $output; return; } @@ -349,7 +349,7 @@ class Bootstrap if (strtolower( $typefile ) == 'css' && $folderarray[count( $folderarray ) - 2] == 'css') { Bootstrap::sendHeaders( $filename, 'text/css', $download, $downloadFileName ); $output = Bootstrap::streamCSSBigFile( $typearray[0] ); - print $output; + echo $output; return; } diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index be9967c27..83d75b214 100755 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -71,8 +71,10 @@ if (file_exists($requestFile)) { if($pos < $size) { //if this file got an extension then assign the content $ext_file = substr($request, $pos, $size); - if ($ext_file == "gif" || $ext_file == "png" || $ext_file == "jpg") { + if ($ext_file == "gif" || $ext_file == "png") { $ext_file = 'image/'.$ext_file ; + } elseif ($ext_file == "jpg" || $ext_file == "jpeg") { + $ext_file = 'image/jpeg'; } elseif ($ext_file == "swf") { $ext_file = "application/x-shockwave-flash"; } elseif ($ext_file == "json" || $ext_file == "htc" ) { @@ -426,7 +428,7 @@ Bootstrap::registerClass('Calendar', PATH_HOME . "engine/classes/class.calen Bootstrap::registerClass('processMap', PATH_HOME . "engine/classes/class.processMap.php"); //DATABASE propel classes used in 'Cases' Options -Bootstrap::registerClass('Entity_Base', PATH_HOME . "engine/classes/entities/Base.php"); +Bootstrap::registerClass('Entity_Base', PATH_HOME . "engine/classes/entities/Base.php"); Bootstrap::registerClass('BaseContent', PATH_HOME . "engine/classes/model/om/BaseContent.php"); Bootstrap::registerClass('Content', PATH_HOME . "engine/classes/model/Content.php"); From b54dcce90698dbff1f1ad0c5ff1e5bb48f78ddd1 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 27 Nov 2012 15:46:44 -0400 Subject: [PATCH 58/70] Performance to cron --- workflow/engine/bin/cron_single.php | 62 ++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/workflow/engine/bin/cron_single.php b/workflow/engine/bin/cron_single.php index 9a2b984b3..0aa1f4ced 100755 --- a/workflow/engine/bin/cron_single.php +++ b/workflow/engine/bin/cron_single.php @@ -89,12 +89,62 @@ if (!defined('PATH_HOME')) { define ('TIME_ZONE', $config['time_zone']); } -require_once ("classes/model/Configuration.php"); -require_once ("classes/model/AppCacheView.php"); -require_once ("classes/model/AppDelegation.php"); -require_once ("classes/model/Event.php"); -require_once ("classes/model/AppEvent.php"); -require_once ("classes/model/CaseScheduler.php"); +require_once (PATH_GULLIVER . PATH_SEP . 'class.bootstrap.php'); +//define( 'PATH_GULLIVER_HOME', PATH_TRUNK . 'gulliver' . PATH_SEP ); + +spl_autoload_register(array('Bootstrap', 'autoloadClass')); + +Bootstrap::registerClass('BaseConfiguration', PATH_HOME . "engine/classes/model/om/BaseConfiguration.php"); +Bootstrap::registerClass('Configuration', PATH_HOME . "engine/classes/model/Configuration.php"); + +Bootstrap::registerClass('EventPeer', PATH_HOME . "engine/classes/model/EventPeer.php"); +Bootstrap::registerClass('ApplicationPeer', PATH_HOME . "engine/classes/model/ApplicationPeer.php"); + +Bootstrap::registerClass('BaseGroupUser', PATH_HOME . "engine/classes/model/om/BaseGroupUser.php"); +Bootstrap::registerClass('BaseUsers', PATH_HOME . "engine/classes/model/om/BaseUsers.php"); +Bootstrap::registerClass('BaseProcess', PATH_HOME . "engine/classes/model/om/BaseProcess.php"); +Bootstrap::registerClass('BaseContentPeer', PATH_HOME . "engine/classes/model/om/BaseContentPeer.php"); +Bootstrap::registerClass('BaseContent', PATH_HOME . "engine/classes/model/om/BaseContent.php"); +Bootstrap::registerClass('BaseLogCasesScheduler', PATH_HOME . "engine/classes/model/om/BaseLogCasesScheduler.php"); +Bootstrap::registerClass('BaseApplication', PATH_HOME . "engine/classes/model/om/BaseApplication.php"); +Bootstrap::registerClass('BaseEvent', PATH_HOME . "engine/classes/model/om/BaseEvent.php"); +Bootstrap::registerClass('BaseEventPeer', PATH_HOME . "engine/classes/model/om/BaseEventPeer.php"); +Bootstrap::registerClass('BaseTriggers', PATH_HOME . "engine/classes/model/om/BaseTriggers.php"); +Bootstrap::registerClass('BaseTriggersPeer', PATH_HOME . "engine/classes/model/om/BaseTriggersPeer.php"); +Bootstrap::registerClass('BaseAppMessage', PATH_HOME . "engine/classes/model/om/BaseAppMessage.php"); +Bootstrap::registerClass('BaseAppMessagePeer', PATH_HOME . "engine/classes/model/om/BaseAppMessagePeer.php"); + +Bootstrap::registerClass('BaseAppDelegation', PATH_HOME . "engine/classes/model/om/BaseAppDelegation.php"); +Bootstrap::registerClass('BaseHoliday', PATH_HOME . "engine/classes/model/om/BaseHoliday.php"); +Bootstrap::registerClass('BaseHolidayPeer', PATH_HOME . "engine/classes/model/om/BaseHolidayPeer.php"); +Bootstrap::registerClass('BaseTask', PATH_HOME . "engine/classes/model/om/BaseTask.php"); +Bootstrap::registerClass('BaseTaskPeer', PATH_HOME . "engine/classes/model/om/BaseTaskPeer.php"); +Bootstrap::registerClass('HolidayPeer', PATH_HOME . "engine/classes/model/HolidayPeer.php"); +Bootstrap::registerClass('Holiday', PATH_HOME . "engine/classes/model/Holiday.php"); + +Bootstrap::registerClass('Task', PATH_HOME . "engine/classes/model/Task.php"); +Bootstrap::registerClass('TaskPeer', PATH_HOME . "engine/classes/model/TaskPeer.php"); +Bootstrap::registerClass('dates', PATH_HOME . "engine/classes/class.dates.php"); +Bootstrap::registerClass('AppDelegation', PATH_HOME . "engine/classes/model/AppDelegation.php"); +Bootstrap::registerClass('AppDelegationPeer', PATH_HOME . "engine/classes/model/AppDelegationPeer.php"); +Bootstrap::registerClass('BaseAppDelay', PATH_HOME . "engine/classes/model/om/BaseAppDelay.php"); +Bootstrap::registerClass('AppDelayPeer', PATH_HOME . "engine/classes/model/AppDelayPeer.php"); +Bootstrap::registerClass('AppDelay', PATH_HOME . "engine/classes/model/AppDelay.php"); +Bootstrap::registerClass('BaseAdditionalTables',PATH_HOME . "engine/classes/model/om/BaseAdditionalTables.php"); +Bootstrap::registerClass('AdditionalTables', PATH_HOME . "engine/classes/model/AdditionalTables.php"); +Bootstrap::registerClass('BaseAppCacheView', PATH_HOME . "engine/classes/model/om/BaseAppCacheView.php"); +Bootstrap::registerClass('AppCacheView', PATH_HOME . "engine/classes/model/AppCacheView.php"); +Bootstrap::registerClass('AppCacheViewPeer', PATH_HOME . "engine/classes/model/AppCacheViewPeer.php"); + +Bootstrap::registerClass('BaseEvent', PATH_HOME . "engine/classes/model/om/BaseEvent.php"); +Bootstrap::registerClass('Event', PATH_HOME . "engine/classes/model/Event.php"); + +Bootstrap::registerClass('BaseAppEvent', PATH_HOME . "engine/classes/model/om/BaseAppEvent.php"); +Bootstrap::registerClass('AppEvent', PATH_HOME . "engine/classes/model/AppEvent.php"); +Bootstrap::registerClass('AppEventPeer', PATH_HOME . "engine/classes/model/AppEventPeer.php"); + +Bootstrap::registerClass('BaseCaseScheduler', PATH_HOME . "engine/classes/model/om/BaseCaseScheduler.php"); +Bootstrap::registerClass('CaseScheduler', PATH_HOME . "engine/classes/model/CaseScheduler.php"); G::LoadClass("case"); G::LoadClass("dates"); From 6d7c9f5da72a288a2f1cab577846dfc3265429ed Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Tue, 27 Nov 2012 16:32:20 -0400 Subject: [PATCH 59/70] BUG 9894 Active Directory User Import not working SOLVED - Fields deprecated and wrong default filter for the ldap class - Those parameters are not used, now it is only used the additional filter, with this field you can create the same filters or more complex filters. Also, we've detected that the filter by default we are using the following condition: (objectCategory=person) So, your filter is not working anymore, now we have been removed that condition to search in all objects and if you want to limit the objects on which searches can be done, you have to add your own filter. --- rbac/engine/classes/plugins/class.ldap.php | 8 +- .../templates/authSources/authSourcesEdit.js | 110 ++++++------------ .../authSources/authSourceskindof.js | 76 ++++-------- 3 files changed, 60 insertions(+), 134 deletions(-) diff --git a/rbac/engine/classes/plugins/class.ldap.php b/rbac/engine/classes/plugins/class.ldap.php index 1bd1f1872..55c6357a7 100755 --- a/rbac/engine/classes/plugins/class.ldap.php +++ b/rbac/engine/classes/plugins/class.ldap.php @@ -148,9 +148,9 @@ class LDAP } } $sFilter = '(&(|(objectClass=*))'; - + if ( isset( $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE']) && $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE'] == 'ad' ) { - $sFilter = "(&(|(objectClass=*))(|(samaccountname=$sKeyword)(userprincipalname=$sKeyword))(objectCategory=person))"; + $sFilter = "(&(|(objectClass=*))(|(samaccountname=$sKeyword)(userprincipalname=$sKeyword)))"; } else $sFilter = "(&(|(objectClass=*))(|(uid=$sKeyword)(cn=$sKeyword)))"; @@ -158,7 +158,7 @@ class LDAP //G::pr($sFilter); $aUsers = array(); $oSearch = @ldap_search($oLink, $aAuthSource['AUTH_SOURCE_BASE_DN'], $sFilter, array('dn','uid','samaccountname', 'cn','givenname','sn','mail','userprincipalname','objectcategory', 'manager')); - + if ($oError = @ldap_errno($oLink)) { return $aUsers; } @@ -179,7 +179,7 @@ class LDAP 'sFirstname' => isset($aAttr['givenname']) ? $aAttr['givenname'] : '', 'sLastname' => isset($aAttr['sn']) ? $aAttr['sn'] : '', 'sEmail' => isset($aAttr['mail']) ? $aAttr['mail'] : ( isset($aAttr['userprincipalname'])?$aAttr['userprincipalname'] : '') , - 'sDN' => $aAttr['dn'] ); + 'sDN' => $aAttr['dn'] ); } } while ($oEntry = @ldap_next_entry($oLink, $oEntry)); } diff --git a/workflow/engine/templates/authSources/authSourcesEdit.js b/workflow/engine/templates/authSources/authSourcesEdit.js index d61dba2b9..c066ed5dc 100644 --- a/workflow/engine/templates/authSources/authSourcesEdit.js +++ b/workflow/engine/templates/authSources/authSourcesEdit.js @@ -37,7 +37,7 @@ Ext.onReady(function(){ hiddenName: 'LDAP_TYPE', store: new Ext.data.SimpleStore({ fields: ['ldap','ad'], - data : my_values + data : my_values }), displayField: 'ldap', typeAhead: true, @@ -48,10 +48,8 @@ Ext.onReady(function(){ listeners:{ select: function(c,d,i){ if(i){ - formAuthSourceE.getForm().findField('AUTH_SOURCE_ATTRIBUTES').setValue('cn' + "\n" + 'samaccountname' + "\n" + 'givenname' + "\n" + 'sn' + "\n" + 'userprincipalname' + "\n" + 'telephonenumber'); formAuthSourceE.getForm().findField('AUTH_SOURCE_IDENTIFIER_FOR_USER').setValue('samaccountname'); } else { - formAuthSourceE.getForm().findField('AUTH_SOURCE_ATTRIBUTES').setValue('cn' + "\n" + 'uid' + "\n" + 'givenname' + "\n" + 'sn' + "\n" + 'mail' + "\n" + 'mobile'); formAuthSourceE.getForm().findField('AUTH_SOURCE_IDENTIFIER_FOR_USER').setValue('uid'); } } @@ -59,8 +57,8 @@ Ext.onReady(function(){ }); var txtServerName=new Ext.form.TextField({ - id: 'AUTH_SOURCE_SERVER_NAME', - fieldLabel: _('ID_SERVER_NAME'), + id: 'AUTH_SOURCE_SERVER_NAME', + fieldLabel: _('ID_SERVER_NAME'), xtype:'textfield', value:'', width: 200, @@ -75,8 +73,8 @@ Ext.onReady(function(){ }); var txtPort=new Ext.form.TextField({ - id: 'AUTH_SOURCE_PORT', - fieldLabel: _('ID_PORT'), + id: 'AUTH_SOURCE_PORT', + fieldLabel: _('ID_PORT'), xtype:'textfield', value:'389', width: 200, @@ -123,11 +121,11 @@ Ext.onReady(function(){ var txtBaseDN=new Ext.form.TextField({ - id: 'AUTH_SOURCE_BASE_DN', - fieldLabel: _('ID_BASE_DN'), + id: 'AUTH_SOURCE_BASE_DN', + fieldLabel: _('ID_BASE_DN'), xtype:'textfield', value:sUID, - width: 200, + width: 300, autoCreate: {tag: 'input', type: 'text', size: '10', autocomplete: 'off', maxlength: '128'}, allowBlank: false, listeners: { @@ -163,20 +161,20 @@ Ext.onReady(function(){ Ext.getCmp("AUTH_SOURCE_PASSWORD").show(); txtPassword.getEl().up('.x-form-item').setDisplayed(true); }else{ - Ext.getCmp("AUTH_SOURCE_SEARCH_USER").disable(); + Ext.getCmp("AUTH_SOURCE_SEARCH_USER").disable(); Ext.getCmp("AUTH_SOURCE_SEARCH_USER").hide(); txtSearchUser.getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp("AUTH_SOURCE_PASSWORD").disable(); + Ext.getCmp("AUTH_SOURCE_PASSWORD").disable(); Ext.getCmp("AUTH_SOURCE_PASSWORD").hide(); - txtPassword.getEl().up('.x-form-item').setDisplayed(false); - } + txtPassword.getEl().up('.x-form-item').setDisplayed(false); + } } } }); var txtSearchUser=new Ext.form.TextField({ - id: 'AUTH_SOURCE_SEARCH_USER', - fieldLabel: _('ID_SEARCH_USER'), + id: 'AUTH_SOURCE_SEARCH_USER', + fieldLabel: _('ID_SEARCH_USER'), xtype:'textfield', value:'', width: 200, @@ -191,7 +189,7 @@ Ext.onReady(function(){ var txtPassword=new Ext.form.TextField({ id: 'AUTH_SOURCE_PASSWORD', - fieldLabel: _('ID_CACHE_PASSWORD'), + fieldLabel: _('ID_CACHE_PASSWORD'), xtype:'textfield', inputType:'password', value:'', @@ -208,7 +206,7 @@ Ext.onReady(function(){ //Identifier for an imported user var txtIdentifier=new Ext.form.TextField({ id: 'AUTH_SOURCE_IDENTIFIER_FOR_USER', - fieldLabel: _('ID_IDENTIFIER_IMPORT_USER'), + fieldLabel: _('ID_IDENTIFIER_IMPORT_USER'), xtype:'textfield', value:'', width: 200, @@ -221,28 +219,13 @@ Ext.onReady(function(){ } } }); -//Object Classes - var txtaClass=new Ext.form.TextArea({ - id: 'AUTH_SOURCE_OBJECT_CLASSES', - fieldLabel: _('ID_OBJECT_CLASS'), - xtype:'textarea', - value:'*', - width: 200, - allowBlank: false, - listeners: { - 'render': function(c) { - c.getEl().on('keyup', function() { - }, c); - } - } - }); //Additional Filter var txtoAddFilter=new Ext.form.TextField({ id: 'AUTH_SOURCE_ADDITIONAL_FILTER', - fieldLabel: _('ID_ADDITIONAL_FILTER'), + fieldLabel: _('ID_ADDITIONAL_FILTER'), xtype:'textfield', value:'', - width: 200, + width: 300, autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '200'}, allowBlank: true, listeners: { @@ -252,21 +235,6 @@ Ext.onReady(function(){ } } }); -//Attributes - var txtAttributes=new Ext.form.TextArea({ - id: 'AUTH_SOURCE_ATTRIBUTES', - fieldLabel: _('ID_ATTRIBUTES'), - xtype:'textArea', - value:'cn' + "\n" + 'uid' + "\n" + 'givenname' + "\n" + 'sn' + "\n" + 'mail' + "\n" + 'mobile', - width: 200, - allowBlank: false, - listeners: { - 'render': function(c) { - c.getEl().on('keyup', function() { - }, c); - } - } - }); //here we are setting the fields fieldsAS = new Ext.form.FieldSet({ title: _('ID_AUTHENTICATION_SOURCE_INF_TITLE'), @@ -274,7 +242,7 @@ Ext.onReady(function(){ txtSourceId, txtName, cboxType, - txtServerName, + txtServerName, txtPort, cboxTLS, cboxVersion, @@ -283,14 +251,12 @@ Ext.onReady(function(){ txtSearchUser, txtPassword , txtIdentifier, - txtaClass, txtoAddFilter, - txtAttributes - ] + ] }); formAuthSourceE = new Ext.FormPanel({ - id:'formAuthSourceE', + id:'formAuthSourceE', labelWidth: 250, labelAlign:'right', autoScroll: true, @@ -304,7 +270,7 @@ Ext.onReady(function(){ allowBlank: false, resizable: true, msgTarget: 'side', - align:'center' + align:'center' }, items:[ fieldsAS @@ -312,19 +278,19 @@ Ext.onReady(function(){ buttons: [ { text: _('ID_SAVE'), - handler: saveAuthSources + handler: saveAuthSources }, - { + { text: _('ID_CANCEL'), handler: goback } ] - + }); formAuthSourceE.render(document.body); loadAuthSourceData(sUID, txtSearchUser, txtPassword); - + }); function goback(){ window.location = 'authSources_List'; @@ -334,7 +300,7 @@ Ext.onReady(function(){ url: '../adminProxy/saveAuthSources', params: { // action : 'tryit', - AUTH_SOURCE_UID: formAuthSourceE.getForm().findField('AUTH_SOURCE_UID').getValue(), + AUTH_SOURCE_UID: formAuthSourceE.getForm().findField('AUTH_SOURCE_UID').getValue(), AUTH_SOURCE_NAME: formAuthSourceE.getForm().findField('AUTH_SOURCE_NAME').getValue(), LDAP_TYPE: formAuthSourceE.getForm().findField('LDAP_TYPE').getValue(), AUTH_SOURCE_SERVER_NAME: formAuthSourceE.getForm().findField('AUTH_SOURCE_SERVER_NAME').getValue(), @@ -344,14 +310,12 @@ Ext.onReady(function(){ AUTH_SOURCE_SEARCH_USER: formAuthSourceE.getForm().findField('AUTH_SOURCE_SEARCH_USER').getValue(), AUTH_SOURCE_PASSWORD: formAuthSourceE.getForm().findField('AUTH_SOURCE_PASSWORD').getValue(), AUTH_SOURCE_VERSION: formAuthSourceE.getForm().findField('AUTH_SOURCE_VERSION').getValue(), - AUTH_SOURCE_BASE_DN: formAuthSourceE.getForm().findField('AUTH_SOURCE_BASE_DN').getValue(), - AUTH_SOURCE_OBJECT_CLASSES: formAuthSourceE.getForm().findField('AUTH_SOURCE_OBJECT_CLASSES').getValue(), - AUTH_SOURCE_ATTRIBUTES: formAuthSourceE.getForm().findField('AUTH_SOURCE_ATTRIBUTES').getValue() + AUTH_SOURCE_BASE_DN: formAuthSourceE.getForm().findField('AUTH_SOURCE_BASE_DN').getValue() }, - waitMsg : 'testing...', + waitMsg : _('ID_SAVING'), timeout : 3600, success: function(f,a){ - + resp = Ext.util.JSON.decode(a.response.responseText); if (resp.success){ window.location = 'authSources_List'; @@ -367,7 +331,7 @@ Ext.onReady(function(){ } }); } - + // Load authosource data for the Edit mode function loadAuthSourceData(sUID, txtSearchUser, txtPassword){ Ext.Ajax.request({ @@ -376,7 +340,7 @@ function loadAuthSourceData(sUID, txtSearchUser, txtPassword){ 'action': 'loadauthSourceData', sUID:sUID }, - waitMsg: _('ID_UPLOADING_PROCESS_FILE'), + waitMsg: _('ID_UPLOADING_PROCESS_FILE'), success: function(r,o){ var data = Ext.util.JSON.decode(r.responseText); @@ -388,16 +352,16 @@ function loadAuthSourceData(sUID, txtSearchUser, txtPassword){ Ext.getCmp("AUTH_SOURCE_PASSWORD").show(); txtPassword.getEl().up('.x-form-item').setDisplayed(true); }else{ - Ext.getCmp("AUTH_SOURCE_SEARCH_USER").disable(); + Ext.getCmp("AUTH_SOURCE_SEARCH_USER").disable(); Ext.getCmp("AUTH_SOURCE_SEARCH_USER").hide(); txtSearchUser.getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp("AUTH_SOURCE_PASSWORD").disable(); + Ext.getCmp("AUTH_SOURCE_PASSWORD").disable(); Ext.getCmp("AUTH_SOURCE_PASSWORD").hide(); - txtPassword.getEl().up('.x-form-item').setDisplayed(false); + txtPassword.getEl().up('.x-form-item').setDisplayed(false); } Ext.getCmp('formAuthSourceE').getForm().setValues({ - + AUTH_SOURCE_UID: data.sources.AUTH_SOURCE_UID, AUTH_SOURCE_NAME: data.sources.AUTH_SOURCE_NAME , LDAP_TYPE: (data.sources.LDAP_TYPE=='ad')?'Active Directory':data.sources.LDAP_TYPE, @@ -410,8 +374,6 @@ function loadAuthSourceData(sUID, txtSearchUser, txtPassword){ AUTH_SOURCE_IDENTIFIER_FOR_USER: data.sources.AUTH_SOURCE_IDENTIFIER_FOR_USER, AUTH_SOURCE_VERSION: data.sources.AUTH_SOURCE_VERSION, AUTH_SOURCE_BASE_DN: data.sources.AUTH_SOURCE_BASE_DN, - AUTH_SOURCE_OBJECT_CLASSES: data.sources.AUTH_SOURCE_OBJECT_CLASSES, - AUTH_SOURCE_ATTRIBUTES:data.sources.AUTH_SOURCE_ATTRIBUTES, AUTH_SOURCE_ADDITIONAL_FILTER:data.sources.AUTH_SOURCE_ADDITIONAL_FILTER }) }, diff --git a/workflow/engine/templates/authSources/authSourceskindof.js b/workflow/engine/templates/authSources/authSourceskindof.js index d0512dd36..e7e360500 100644 --- a/workflow/engine/templates/authSources/authSourceskindof.js +++ b/workflow/engine/templates/authSources/authSourceskindof.js @@ -47,7 +47,7 @@ Ext.onReady(function(){ hiddenName: 'LDAP_TYPE', store: new Ext.data.SimpleStore({ fields: ['ldap','ad'], - data : my_values + data : my_values }), displayField: 'ldap', typeAhead: true, @@ -59,10 +59,8 @@ Ext.onReady(function(){ listeners:{ select: function(c,d,i){ if(i){ - formAuthSource.getForm().findField('AUTH_SOURCE_ATTRIBUTES').setValue('cn' + "\n" + 'samaccountname' + "\n" + 'givenname' + "\n" + 'sn' + "\n" + 'userprincipalname' + "\n" + 'telephonenumber'); formAuthSource.getForm().findField('AUTH_SOURCE_IDENTIFIER_FOR_USER').setValue('samaccountname'); } else { - formAuthSource.getForm().findField('AUTH_SOURCE_ATTRIBUTES').setValue('cn' + "\n" + 'uid' + "\n" + 'givenname' + "\n" + 'sn' + "\n" + 'mail' + "\n" + 'mobile'); formAuthSource.getForm().findField('AUTH_SOURCE_IDENTIFIER_FOR_USER').setValue('uid'); } } @@ -71,7 +69,7 @@ Ext.onReady(function(){ var txtServerName=new Ext.form.TextField({ id: 'AUTH_SOURCE_SERVER_NAME', - fieldLabel: _('ID_SERVER_NAME'), + fieldLabel: _('ID_SERVER_NAME'), xtype:'textfield', value:'', width: 200, @@ -87,7 +85,7 @@ Ext.onReady(function(){ var txtPort=new Ext.form.TextField({ id: 'AUTH_SOURCE_PORT', - fieldLabel: _('ID_PORT'), + fieldLabel: _('ID_PORT'), xtype:'textfield', value:'389', width: 200, @@ -143,7 +141,7 @@ Ext.onReady(function(){ fieldLabel: _('ID_BASE_DN'), xtype:'textfield', value:'', - width: 200, + width: 300, autoCreate: {tag: 'input', type: 'text', size: '10', autocomplete: 'off', maxlength: '128'}, allowBlank: false, listeners: { @@ -181,20 +179,20 @@ Ext.onReady(function(){ Ext.getCmp("AUTH_SOURCE_PASSWORD").show(); txtPassword.getEl().up('.x-form-item').setDisplayed(true); }else{ - Ext.getCmp("AUTH_SOURCE_SEARCH_USER").disable(); + Ext.getCmp("AUTH_SOURCE_SEARCH_USER").disable(); Ext.getCmp("AUTH_SOURCE_SEARCH_USER").hide(); txtSearchUser.getEl().up('.x-form-item').setDisplayed(false); - Ext.getCmp("AUTH_SOURCE_PASSWORD").disable(); + Ext.getCmp("AUTH_SOURCE_PASSWORD").disable(); Ext.getCmp("AUTH_SOURCE_PASSWORD").hide(); txtPassword.getEl().up('.x-form-item').setDisplayed(false); - } + } } } }); var txtSearchUser=new Ext.form.TextField({ id: 'AUTH_SOURCE_SEARCH_USER', - fieldLabel: _('ID_SEARCH_USER'), + fieldLabel: _('ID_SEARCH_USER'), xtype:'textfield', value:'', width: 200, @@ -209,7 +207,7 @@ Ext.onReady(function(){ var txtPassword=new Ext.form.TextField({ id: 'AUTH_SOURCE_PASSWORD', - fieldLabel: _('ID_CACHE_PASSWORD'), + fieldLabel: _('ID_CACHE_PASSWORD'), xtype:'textfield', inputType:'password', value:'', @@ -226,7 +224,7 @@ Ext.onReady(function(){ //Identifier for an imported user var txtIdentifier=new Ext.form.TextField({ id: 'AUTH_SOURCE_IDENTIFIER_FOR_USER', - fieldLabel: _('ID_IDENTIFIER_IMPORT_USER'), + fieldLabel: _('ID_IDENTIFIER_IMPORT_USER'), xtype:'textfield', value:'uid', width: 200, @@ -239,28 +237,13 @@ Ext.onReady(function(){ } } }); -//Object Classes - var txtaClass=new Ext.form.TextArea({ - id: 'AUTH_SOURCE_OBJECT_CLASSES', - fieldLabel: _('ID_OBJECT_CLASS'), - xtype:'textarea', - value:'*', - width: 200, - allowBlank: false, - listeners: { - 'render': function(c) { - c.getEl().on('keyup', function() { - }, c); - } - } - }); //Additional Filter var txtoAddFilter=new Ext.form.TextField({ id: 'AUTH_SOURCE_ADDITIONAL_FILTER', fieldLabel: _('ID_ADDITIONAL_FILTER'), xtype:'textfield', value:'', - width: 200, + width: 300, autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '200'}, allowBlank: true, listeners: { @@ -270,21 +253,6 @@ Ext.onReady(function(){ } } }); -//Attributes - var txtAttributes=new Ext.form.TextArea({ - id: 'AUTH_SOURCE_ATTRIBUTES', - fieldLabel: _('ID_ATTRIBUTES'), - xtype:'textArea', - value:'cn' + "\n" + 'uid' + "\n" + 'givenname' + "\n" + 'sn' + "\n" + 'mail' + "\n" + 'mobile', - width: 200, - allowBlank: false, - listeners: { - 'render': function(c) { - c.getEl().on('keyup', function() { - }, c); - } - } - }); //here we are setting the fields fieldsAS = new Ext.form.FieldSet({ title: _('ID_AUTHENTICATION_SOURCE_INFORMATION'), @@ -302,9 +270,7 @@ Ext.onReady(function(){ txtSearchUser, txtPassword , txtIdentifier, - txtaClass, - txtoAddFilter, - txtAttributes + txtoAddFilter ] }); @@ -333,18 +299,18 @@ Ext.onReady(function(){ { text: _('ID_SAVE'), handler: TestSite - + }, - { + { text: _('ID_CANCEL'), handler: goback } ] - + }); formAuthSource.render(document.body); - + }); function goback(){ window.location = 'authSources_List'; @@ -354,7 +320,7 @@ Ext.onReady(function(){ url: '../adminProxy/saveAuthSources', params: { // action : 'tryit', - AUTH_SOURCE_UID: formAuthSource.getForm().findField('AUTH_SOURCE_UID').getValue(), + AUTH_SOURCE_UID: formAuthSource.getForm().findField('AUTH_SOURCE_UID').getValue(), AUTH_SOURCE_NAME: formAuthSource.getForm().findField('AUTH_SOURCE_NAME').getValue(), LDAP_TYPE: formAuthSource.getForm().findField('LDAP_TYPE').getValue(), AUTH_SOURCE_SERVER_NAME: formAuthSource.getForm().findField('AUTH_SOURCE_SERVER_NAME').getValue(), @@ -365,15 +331,13 @@ Ext.onReady(function(){ AUTH_SOURCE_PASSWORD: formAuthSource.getForm().findField('AUTH_SOURCE_PASSWORD').getValue(), AUTH_SOURCE_VERSION: formAuthSource.getForm().findField('AUTH_SOURCE_VERSION').getValue(), AUTH_SOURCE_BASE_DN: formAuthSource.getForm().findField('AUTH_SOURCE_BASE_DN').getValue(), - AUTH_SOURCE_OBJECT_CLASSES: formAuthSource.getForm().findField('AUTH_SOURCE_OBJECT_CLASSES').getValue(), - AUTH_SOURCE_ATTRIBUTES: formAuthSource.getForm().findField('AUTH_SOURCE_ATTRIBUTES').getValue(), AUTH_SOURCE_ADDITIONAL_FILTER: formAuthSource.getForm().findField('AUTH_SOURCE_ADDITIONAL_FILTER').getValue() - + }, - waitMsg : 'testing...', + waitMsg : _('ID_SAVING'), timeout : 3600, success: function(f,a){ - + resp = Ext.util.JSON.decode(a.response.responseText); if (resp.success){ window.location = 'authSources_List'; From 5e75009b646c3bf9685a4361ee1fb8ae078d1fc4 Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Tue, 27 Nov 2012 17:02:25 -0400 Subject: [PATCH 60/70] BUG 9894 Active Directory User Import not working IMPROVEMENT --- rbac/engine/classes/plugins/class.ldap.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rbac/engine/classes/plugins/class.ldap.php b/rbac/engine/classes/plugins/class.ldap.php index 55c6357a7..42d6d50a9 100755 --- a/rbac/engine/classes/plugins/class.ldap.php +++ b/rbac/engine/classes/plugins/class.ldap.php @@ -147,13 +147,16 @@ class LDAP $sKeyword .= '*'; } } + + $additionalFilter = isset($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) ? trim($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) : ''; + $sFilter = '(&(|(objectClass=*))'; if ( isset( $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE']) && $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE'] == 'ad' ) { - $sFilter = "(&(|(objectClass=*))(|(samaccountname=$sKeyword)(userprincipalname=$sKeyword)))"; + $sFilter = "(&(|(objectClass=*))(|(samaccountname=$sKeyword)(userprincipalname=$sKeyword))$additionalFilter)"; } else - $sFilter = "(&(|(objectClass=*))(|(uid=$sKeyword)(cn=$sKeyword)))"; + $sFilter = "(&(|(objectClass=*))(|(uid=$sKeyword)(cn=$sKeyword))$additionalFilter)"; //G::pr($sFilter); $aUsers = array(); From 72c53d4503f57eb86288d94368da995d5ece608e Mon Sep 17 00:00:00 2001 From: ralph Date: Tue, 27 Nov 2012 17:15:57 -0400 Subject: [PATCH 61/70] Removing G::getModel, deprecated function. --- workflow/engine/methods/setup/loginSettingsAjax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/methods/setup/loginSettingsAjax.php b/workflow/engine/methods/setup/loginSettingsAjax.php index eb191a601..a0a29bdc6 100755 --- a/workflow/engine/methods/setup/loginSettingsAjax.php +++ b/workflow/engine/methods/setup/loginSettingsAjax.php @@ -4,7 +4,7 @@ $request = isset( $_REQUEST['request'] ) ? $_REQUEST['request'] : null; switch ($request) { case 'getLangList': - $Translations = G::getModel( 'Translation' ); + $Translations = new Translation(); $result = new stdClass(); $result->rows = Array (); From 66c8366e8febda8cbcc2ad9b52170a37ca1e5c11 Mon Sep 17 00:00:00 2001 From: ralph Date: Wed, 28 Nov 2012 09:04:52 -0400 Subject: [PATCH 62/70] $_POST["functions"] is not arriving, seemed maborak.loader is not sending it. Fix. --- .../engine/methods/inputdocs/inputdocs_Save.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/workflow/engine/methods/inputdocs/inputdocs_Save.php b/workflow/engine/methods/inputdocs/inputdocs_Save.php index 0bbcc6554..4daa9be8d 100755 --- a/workflow/engine/methods/inputdocs/inputdocs_Save.php +++ b/workflow/engine/methods/inputdocs/inputdocs_Save.php @@ -36,16 +36,17 @@ try { break; } + $sfunction = ''; if (isset( $_POST['function'] )) { $sfunction = $_POST['function']; - } else { + } elseif (isset( $_POST['functions'] )){ $sfunction = $_POST['functions']; - } - + } + // Bootstrap::mylog("post:".$_POST['function']); switch ($sfunction) { case 'lookForNameInput': - require_once ('classes/model/Content.php'); - require_once ("classes/model/InputDocument.php"); + //require_once ('classes/model/Content.php'); + //require_once ("classes/model/InputDocument.php"); $snameInput = urldecode( $_POST['NAMEINPUT'] ); $sPRO_UID = urldecode( $_POST['proUid'] ); @@ -77,7 +78,7 @@ try { print $flag; break; default: - require_once 'classes/model/InputDocument.php'; + //require_once 'classes/model/InputDocument.php'; G::LoadClass( 'processMap' ); $oInputDocument = new InputDocument(); From 378f6a095ea66224a8b29c122376b3e5b5dd00bf Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Wed, 28 Nov 2012 12:29:23 -0400 Subject: [PATCH 63/70] BUG 10036 "No esta rezalizando un buen conteo de la..." SOLVED - Incorrect the displaying of the paging toolbar - Fix the displaying of the paging toolbar * Available from version 2.0.46 --- .../engine/templates/cases/casesDocuments.js | 22 ++++++++-------- workflow/engine/templates/setup/cron.js | 25 +++++++++++-------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/workflow/engine/templates/cases/casesDocuments.js b/workflow/engine/templates/cases/casesDocuments.js index 5f63c06d7..6574c617a 100755 --- a/workflow/engine/templates/cases/casesDocuments.js +++ b/workflow/engine/templates/cases/casesDocuments.js @@ -118,8 +118,8 @@ function chDir( directory, loadGridOnly ) { if( directory == '' || conn && !conn.isLoading()) { datastore.load({ params:{ - start:0, - limit:25, + start: 0, + limit: 100, dir: directory, node: directory, option:'gridDocuments', @@ -737,8 +737,8 @@ datastore = new Ext.data.Store({ url : "../appFolder/appFolderAjax.php", directory : "/", params : { - start : 0, - limit : 25, + start: 0, + limit: 100, dir : this.directory, node : this.directory, option : "gridDocuments", @@ -1082,11 +1082,11 @@ function filterDataStore(btn, e) { } // add a paging toolbar to the grid's footer var gridbb = new Ext.PagingToolbar({ - store : datastore, - pageSize : 25 , - displayInfo : true, - // displayMsg : '% % %', - emptyMsg : TRANSLATIONS.ID_DISPLAY_EMPTY, + store: datastore, + pageSize: 100, + displayInfo: true, + displayMsg: _("ID_DISPLAY_TOTAL"), + emptyMsg: _("ID_DISPLAY_EMPTY"), beforePageText : TRANSLATIONS.ID_PAGE, // afterPageText : 'of %', firstText : TRANSLATIONS.ID_FIRST, @@ -1299,8 +1299,8 @@ function loadDir() { // console.trace(); datastore.load({ params : { - start : 0, - limit : 25, + start: 0, + limit: 100, dir : datastore.directory, node : datastore.directory, option : 'gridDocuments', diff --git a/workflow/engine/templates/setup/cron.js b/workflow/engine/templates/setup/cron.js index cff5c4382..6c793923e 100644 --- a/workflow/engine/templates/setup/cron.js +++ b/workflow/engine/templates/setup/cron.js @@ -61,17 +61,19 @@ cron.application = { { var record = grdpnlMain.getSelectionModel().getSelected(); - var strData = "" + _("ID_DATE_LABEL") + "
" + record.get("DATE") + "
"; - strData = strData + "" + _("ID_WORKSPACE") + "
" + record.get("WORKSPACE") + "
"; - strData = strData + "" + _("ID_ACTION") + "
" + record.get("ACTION") + "
"; - strData = strData + "" + _("ID_STATUS") + "
" + record.get("STATUS") + "
"; - strData = strData + "" + _("ID_DESCRIPTION") + "
" + record.get("DESCRIPTION") + "
"; + if (typeof record != "undefined") { + var strData = "" + _("ID_DATE_LABEL") + "
" + record.get("DATE") + "
"; + strData = strData + "" + _("ID_WORKSPACE") + "
" + record.get("WORKSPACE") + "
"; + strData = strData + "" + _("ID_ACTION") + "
" + record.get("ACTION") + "
"; + strData = strData + "" + _("ID_STATUS") + "
" + record.get("STATUS") + "
"; + strData = strData + "" + _("ID_DESCRIPTION") + "
" + record.get("DESCRIPTION") + "
"; - var formItems = Ext.getCmp("frmLogView").form.items; - formItems.items[0].setValue(strData); + var formItems = Ext.getCmp("frmLogView").form.items; + formItems.items[0].setValue(strData); - winLog.setTitle("Log - " + _("ID_WORKSPACE") + " " + record.get("WORKSPACE")); - winLog.show(); + winLog.setTitle("Log - " + _("ID_WORKSPACE") + " " + record.get("WORKSPACE")); + winLog.show(); + } } //Variables @@ -233,7 +235,7 @@ cron.application = { var btnInfoView = new Ext.Action({ id: "btnInfoView", - text: _("ID_VIEW_INFO"), + text: _("ID_CRON_INFO"), iconCls: "button_menu_ext ss_sprite ss_zoom", handler: function () @@ -456,4 +458,5 @@ cron.application = { } } -Ext.onReady(cron.application.init, cron.application); \ No newline at end of file +Ext.onReady(cron.application.init, cron.application); + From 39d79e398b71a66ce6d4f313f627d7158aecd03b Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Wed, 28 Nov 2012 12:50:02 -0400 Subject: [PATCH 64/70] $title = ucfirst (strtolower ( G::LoadTranslation('ID_EMAILS'))); --- workflow/engine/classes/model/AppMessage.php | 8 + workflow/engine/menus/setup.php | 1 + workflow/engine/methods/mails/emailList.php | 96 +++++ workflow/engine/methods/mails/emailsAjax.php | 154 ++++++++ .../engine/templates/mails/emailList.html | 3 + workflow/engine/templates/mails/emailList.js | 355 ++++++++++++++++++ 6 files changed, 617 insertions(+) create mode 100644 workflow/engine/methods/mails/emailList.php create mode 100644 workflow/engine/methods/mails/emailsAjax.php create mode 100644 workflow/engine/templates/mails/emailList.html create mode 100644 workflow/engine/templates/mails/emailList.js diff --git a/workflow/engine/classes/model/AppMessage.php b/workflow/engine/classes/model/AppMessage.php index 0ce2e71bc..9b4996dbc 100755 --- a/workflow/engine/classes/model/AppMessage.php +++ b/workflow/engine/classes/model/AppMessage.php @@ -120,5 +120,13 @@ class AppMessage extends BaseAppMessage return $this->getAppMsgUid(); } } + + public function updateStatus($msgUid, $msgStatus) + { + $message = AppMessagePeer::retrieveByPk( $msgUid ); + $message->fromArray( $message, BasePeer::TYPE_FIELDNAME ); + $message->setAppMsgStatus($msgStatus); + $message->save(); + } } diff --git a/workflow/engine/menus/setup.php b/workflow/engine/menus/setup.php index bd0fd6a6f..7f562e290 100755 --- a/workflow/engine/menus/setup.php +++ b/workflow/engine/menus/setup.php @@ -85,5 +85,6 @@ if ($RBAC->userCanAccess('PM_SETUP') == 1) { $G_TMP_MENU->AddIdRawOption('EVENT', '../events/eventList', G::LoadTranslation('ID_EVENTS'), '', '', 'logs'); $G_TMP_MENU->AddIdRawOption('LOG_CASE_SCHEDULER', '../cases/cases_Scheduler_Log', G::LoadTranslation('ID_CASE_SCHEDULER'), "icon-logs-list.png",'', 'logs'); $G_TMP_MENU->AddIdRawOption("CRON", "../setup/cron", G::LoadTranslation("ID_CRON_ACTIONS"), null, null, "logs"); + $G_TMP_MENU->AddIdRawOption('EMAILS', '../mails/emailList', ucfirst (strtolower ( G::LoadTranslation('ID_EMAILS'))), '', '', 'logs'); } diff --git a/workflow/engine/methods/mails/emailList.php b/workflow/engine/methods/mails/emailList.php new file mode 100644 index 000000000..f0f02e952 --- /dev/null +++ b/workflow/engine/methods/mails/emailList.php @@ -0,0 +1,96 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +global $RBAC; +if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); +} + +G::LoadClass( 'configuration' ); +$c = new Configurations(); +$configPage = $c->getConfiguration( 'eventList', 'pageSize', '', $_SESSION['USER_LOGGED'] ); +$Config['pageSize'] = isset( $configPage['pageSize'] ) ? $configPage['pageSize'] : 20; + +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'logs'; +$G_ID_MENU_SELECTED = 'logs'; +$G_ID_SUB_MENU_SELECTED = 'EMAILS'; + +//get values for the comboBoxes +$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null; +$status = array ( + array ('',G::LoadTranslation( 'ID_ALL' )), + array ("sent", "Sent"), + array ("pending", "Pending") +); +//$type = array (array ('',G::LoadTranslation( 'ID_ALL' ) +//),array ('SEND_MESSAGE',G::LoadTranslation( 'ID_EVENT_MESSAGE' ) +//),array ('EXECUTE_TRIGGER',G::LoadTranslation( 'ID_EVENT_TIMER' ) +//),array ('EXECUTE_CONDITIONAL_TRIGGER',G::LoadTranslation( 'ID_EVENT_CONDITIONAL' ) +//) +//); +$processes = getProcessArray( $userUid ); + +$G_PUBLISH = new Publisher(); + +$oHeadPublisher = & headPublisher::getSingleton(); +$oHeadPublisher->addExtJsScript( 'mails/emailList', false ); //adding a javascript file .js +$oHeadPublisher->addContent( 'mails/emailList' ); //adding a html file .html. +//sending the columns to display in grid +//$oHeadPublisher->assign( 'typeValues', $type ); +$oHeadPublisher->assign( 'statusValues', $status ); +$oHeadPublisher->assign( 'processValues', $processes ); + +function getProcessArray ($userUid) +{ + global $oAppCache; + require_once ("classes/model/AppCacheView.php"); + + $processes = Array (); + $processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' )); + + $cProcess = new Criteria( 'workflow' ); + $cProcess->clearSelectColumns(); + $cProcess->addSelectColumn( AppCacheViewPeer::PRO_UID ); + $cProcess->addSelectColumn( AppCacheViewPeer::APP_PRO_TITLE ); + $cProcess->setDistinct( AppCacheViewPeer::PRO_UID ); + + $cProcess->addAscendingOrderByColumn( AppCacheViewPeer::APP_PRO_TITLE ); + + $oDataset = AppCacheViewPeer::doSelectRS( $cProcess ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + + while ($aRow = $oDataset->getRow()) { + $processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE']); + $oDataset->next(); + } + + return $processes; +} + +G::RenderPage( 'publish', 'extJs' ); + diff --git a/workflow/engine/methods/mails/emailsAjax.php b/workflow/engine/methods/mails/emailsAjax.php new file mode 100644 index 000000000..588761d33 --- /dev/null +++ b/workflow/engine/methods/mails/emailsAjax.php @@ -0,0 +1,154 @@ +status = 'OK'; + + $criteria = new Criteria(); + $criteria->addJoin(AppMessagePeer::APP_UID, ApplicationPeer::APP_UID); + if ($emailStatus != '') { + $criteria->add( AppMessagePeer::APP_MSG_STATUS, $emailStatus, Criteria::LESS_EQUAL ); + } + if ($proUid != '') { + $criteria->add( ApplicationPeer::PRO_UID, $proUid); + } + if ($dateFrom != '') { + if ($dateTo != '') { + $criteria->add( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ) ) ); + } else { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL ); + } + } elseif ($dateTo != '') { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ); + } + + $result = AppMessagePeer::doSelectRS($criteria); + $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $data = Array(); + while ( $result->next() ) { + $data[] = $result->getRow(); + } + $totalCount = count($data); + + $criteria = new Criteria(); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_UID); + $criteria->addSelectColumn(AppMessagePeer::APP_UID); + $criteria->addSelectColumn(AppMessagePeer::DEL_INDEX); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TYPE); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SUBJECT); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_FROM); + + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TO); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_BODY); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_STATUS); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_DATE); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SEND_DATE); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SHOW_MESSAGE); + + $criteria->addSelectColumn(ApplicationPeer::PRO_UID); + + $criteria->addAsColumn('PRO_TITLE', 'C2.CON_VALUE'); + $criteria->addAlias('C2', 'CONTENT'); + + if ($emailStatus != '') { + $criteria->add( AppMessagePeer::APP_MSG_STATUS, $emailStatus, Criteria::LESS_EQUAL ); + } + if ($proUid != '') { + $criteria->add( ApplicationPeer::PRO_UID, $proUid); + } + if ($dateFrom != '') { + if ($dateTo != '') { + $criteria->add( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ) ) ); + } else { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL ); + } + } elseif ($dateTo != '') { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ); + } + + if ($sort != '') { + if ($dir == 'ASC') { + $criteria->addAscendingOrderByColumn($sort); + } else { + $criteria->addDescendingOrderByColumn($sort); + } + } else { + $oCriteria->addDescendingOrderByColumn(AppMessagePeer::APP_MSG_SEND_DATE ); + } + if ($limit != '') { + $criteria->setLimit($limit); + $criteria->setOffset($start); + } + $criteria->addJoin(AppMessagePeer::APP_UID, ApplicationPeer::APP_UID); + + $conditions = array(); + $conditions[] = array(ApplicationPeer::PRO_UID, 'C2.CON_ID'); + $conditions[] = array( + 'C2.CON_CATEGORY', DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter() + ); + $conditions[] = array( + 'C2.CON_LANG', DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter() + ); + $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN); + $result = AppMessagePeer::doSelectRS($criteria); + $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $data = Array(); + $dataPro = array(); + $index = 0; + $content = new Content(); + $tasTitleDefault = G::LoadTranslation('ID_TASK_NOT_RELATED'); + while ( $result->next() ) { + + $row = $result->getRow(); + $row['APP_MSG_FROM'] =htmlentities($row['APP_MSG_FROM'], ENT_QUOTES, "UTF-8"); + $row['APP_MSG_STATUS'] = ucfirst ( $row['APP_MSG_STATUS']); + $row['TAS_TITLE'] = $tasTitleDefault; + if ($row['DEL_INDEX'] != 0) { + $criteria = new Criteria(); + $criteria->addSelectColumn(AppDelegationPeer::PRO_UID); + $criteria->addSelectColumn(AppDelegationPeer::TAS_UID); + $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteria->add(AppDelegationPeer::APP_UID, $row['APP_UID']); + $resultDelegation = AppDelegationPeer::doSelectRS($criteria); + $resultDelegation->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $row['TAS_TITLE'] = '-'; + while ($resultDelegation->next()) { + $rowDelegation = $resultDelegation->getRow(); + if ($row['DEL_INDEX'] == $rowDelegation['DEL_INDEX']) { + $row['TAS_TITLE'] = $content->load( 'TAS_TITLE', '', $rowDelegation['TAS_UID'], SYS_LANG ); + break; + } + } + } + + $data[] = $row; + } + $response = array(); + $response['totalCount'] = $totalCount; + $response['data'] = $data; + die(G::json_encode($response)); + break; + case 'updateStatusMessage': + if (isset($_REQUEST['APP_MSG_UID']) && isset($_REQUEST['APP_MSG_STATUS'])) { + $message = new AppMessage(); + $result = $message->updateStatus($_REQUEST['APP_MSG_UID'], $_REQUEST['APP_MSG_STATUS']); + } + break; +} + diff --git a/workflow/engine/templates/mails/emailList.html b/workflow/engine/templates/mails/emailList.html new file mode 100644 index 000000000..432f567b5 --- /dev/null +++ b/workflow/engine/templates/mails/emailList.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/workflow/engine/templates/mails/emailList.js b/workflow/engine/templates/mails/emailList.js new file mode 100644 index 000000000..ff1611a64 --- /dev/null +++ b/workflow/engine/templates/mails/emailList.js @@ -0,0 +1,355 @@ +/* + * @author: Marco Antonio + * Agos 17st, 2012 + */ +new Ext.KeyMap(document, [{ + key: Ext.EventObject.F5, + fn: function(keycode, e) { + if (! e.ctrlKey) { + if (Ext.isIE) { + // IE6 doesn't allow cancellation of the F5 key, so trick it into + // thinking some other key was pressed (backspace in this case) + e.browserEvent.keyCode = 8; + } + e.stopEvent(); + document.location = document.location; + } else { + Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); + } + } +} +]); + +var store; +var cmodel; +var emailsGrid; +var actions; +var filterStatus = ''; + +Ext.onReady(function(){ + Ext.QuickTips.init(); + var resultTpl = new Ext.XTemplate( + '
', + ' {APP_PRO_TITLE}', + '
' + ); + + var columnRenderer = function(data, metadata, record, rowIndex,columnIndex, store) { + var new_text = metadata.style.split(';'); + var style = ''; + for (var i = 0; i < new_text.length -1 ; i++) { + var chain = new_text[i] +";"; + if (chain.indexOf('width') == -1) { + style = style + chain; + } + } + metadata.attr = 'ext:qtip="' + data + '" style="'+ style +' white-space: normal; "'; + return data; + }; + + var dateFrom = new Ext.form.DateField({ + id:'dateFrom', + format: 'Y-m-d', + width: 120, + value: '' + }); + + var dateTo = new Ext.form.DateField({ + id:'dateTo', + format: 'Y-m-d', + width: 120, + value: '' + }); + + // ComboBox Status + var comboStatus = new Ext.form.ComboBox({ + width : 90, + boxMaxWidth : 90, + editable : false, + mode : 'local', + emptyText: _('ID_SELECT_STATUS'), + store : new Ext.data.ArrayStore({ + fields: ['id', 'value'], + data : statusValues + }), + valueField : 'id', + displayField : 'value', + triggerAction : 'all', + listeners:{ + scope: this, + 'select': function() { + filterStatus = comboStatus.value; + store.setBaseParam( 'status', filterStatus); + store.setBaseParam( 'start', 0); + store.setBaseParam( 'limit', 25); + store.load(); + } + }, + iconCls: 'no-icon' + }); + + var comboProcess = new Ext.form.ComboBox({ + width : 200, + boxMaxWidth : 200, + editable : true, + displayField : 'APP_PRO_TITLE', + valueField : 'PRO_UID', + forceSelection: false, + emptyText: _('ID_EMPTY_PROCESSES'), + selectOnFocus: true, + tpl: resultTpl, + + typeAhead: true, + mode: 'local', + autocomplete: true, + triggerAction: 'all', + + store : new Ext.data.ArrayStore({ + fields : ['PRO_UID','APP_PRO_TITLE'], + data : processValues + }), + listeners:{ + scope: this, + 'select': function() { + filterProcess = comboProcess.value; + + store.setBaseParam('process', filterProcess); + store.setBaseParam( 'start', 0); + store.setBaseParam( 'limit', 25); + store.load(); + }}, + iconCls: 'no-icon' + }); + + actions = _addPluginActions([ {xtype: 'tbfill'}, _('ID_PROCESS'), comboProcess, '-', /*_('ID_TYPE'), comboType, '-',*/ _('ID_STATUS'), comboStatus, _('ID_DELEGATE_DATE_FROM'), + dateFrom, + ' ', + _('ID_TO'), + dateTo, + new Ext.Button ({ + text: _('ID_FILTER_BY_DELEGATED_DATE'), + handler: function(){ + store.setBaseParam('dateFrom', dateFrom.getValue()); + store.setBaseParam('dateTo', dateTo.getValue()); + store.load({params:{ start : 0 , limit : 25 }}); + } + }) + ]); + + var stepsFields = Ext.data.Record.create([ + {name : 'APP_MSG_TYPE', type: 'string'}, + {name : 'APP_MSG_FROM', type: 'string'}, + {name : 'APP_MSG_TO', type: 'string'}, + {name : 'APP_MSG_DATE', type: 'string'}, + {name : 'APP_MSG_STATUS', type: 'string'} + + ]); + + store = new Ext.data.Store( { + proxy : new Ext.data.HttpProxy({ + url: 'emailsAjax?request=MessageList' + }), + remoteSort : true, + sortInfo : stepsFields, + reader : new Ext.data.JsonReader( { + root: 'data', + totalProperty: 'totalCount', + fields : [ + {name : 'APP_MSG_UID'}, + {name : 'APP_UID'}, + {name : 'DEL_INDEX'}, + {name : 'PRO_UID'}, + {name : 'TAS_UID'}, + {name : 'PRO_TITLE'}, + {name : 'TAS_TITLE'}, + {name : 'APP_MSG_TYPE'}, + {name : 'APP_MSG_SUBJECT'}, + {name : 'APP_MSG_FROM'}, + {name : 'APP_MSG_TO'}, + {name : 'APP_MSG_STATUS'}, + {name : 'APP_MSG_DATE'}, + {name : 'APP_MSG_SEND_DATE'}, + {name : 'APP_MSG_BODY'} + ] + }) + }); + store.setDefaultSort('APP_MSG_DATE', 'desc'); + + var expander = new Ext.ux.grid.RowExpander({ + tpl : new Ext.Template( + '


'+_('ID_PREVIEW')+':
'+ + '
'+ + '
'+ + '
 
'+ + '
{APP_MSG_BODY}
'+ + '
 
'+ + '
'+ + '
'+ + '



' + ) + }); + + var statusValuesGrid = statusValues; + statusValuesGrid.splice( 0, 1 ); + cmodel = new Ext.grid.ColumnModel({ + viewConfig: { + forceFit:true, + cls:"x-grid-empty", + emptyText: _('ID_NO_RECORDS_FOUND') + }, + defaults: { + width: 50 + }, + columns: [ + expander, + {id:'APP_MSG_UID', dataIndex: 'APP_MSG_UID', hidden:true, hideable:false}, + {header: 'APP_UID', dataIndex: 'APP_UID', hidden:true, hideable:false}, + {header: 'DEL_INDEX', dataIndex: 'DEL_INDEX', hidden:true, hideable:false}, + {header: 'PRO_UID', dataIndex: 'PRO_UID', hidden:true, hideable:false, sortable: false}, + {header: 'TAS_UID', dataIndex: 'TAS_UID', hidden:true, hideable:false, sortable: false}, + {header: _('ID_PROCESS'), dataIndex: 'PRO_TITLE', width: 100, hidden: false,renderer: columnRenderer, sortable: false}, + {header: _('ID_TASK'), dataIndex: 'TAS_TITLE', width: 100, hidden: false,renderer: columnRenderer, sortable: false}, + {header: _('ID_TYPE'), dataIndex: 'APP_MSG_TYPE', width: 50, hidden: false,renderer: columnRenderer, sortable: true}, + {header: _('ID_DATE_LABEL'), dataIndex: 'APP_MSG_DATE', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, + //{header: _('ID_DERIVED'), dataIndex: 'APP_MSG_SEND_DATE', width: 80,hidden:false,hideable:false, renderer: columnRenderer, sortable: true}, + {header: _('ID_SUBJECT'), dataIndex: 'APP_MSG_SUBJECT', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, + {header: _('ID_FROM'), dataIndex: 'APP_MSG_FROM', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, + {header: _('ID_TO'), dataIndex: 'APP_MSG_TO', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, + //{header: _('ID_STATUS'), dataIndex: 'APP_MSG_STATUS', width: 50,hidden:false,hideable:false, renderer: columnRenderer, sortable: true} + { + header: _('ID_STATUS'), + dataIndex: 'APP_MSG_STATUS', + width: 50, + //hidden:false, + //hideable:false, + renderer: columnRenderer, + //sortable: true, + editor: new Ext.form.ComboBox({ + listClass: 'x-combo-list-small', + mode: 'local', + displayField:'value', + lazyRender: true, + triggerAction: 'all', + valueField:'id', + editable: false, + store: new Ext.data.ArrayStore({ + fields: ['id', 'value'], + data : statusValuesGrid + }), + listeners: { + select: function(a, b) { + var row = emailsGrid.getSelectionModel().getSelected(); + Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} }); + Ext.Ajax.request({ + url : 'emailsAjax' , + params : { + request : 'updateStatusMessage', + APP_MSG_UID: row.data.APP_MSG_UID, + APP_MSG_STATUS: this.value + }, + success: function ( result, request ) { + Ext.MessageBox.hide(); + }, + failure: function ( result, request) { + if (typeof(result.responseText) != 'undefined') { + Ext.MessageBox.alert(_('ID_FAILED'), result.responseText); + } + } + }); + } + } + }) + } + ] + }); + + smodel = new Ext.grid.RowSelectionModel({ + singleSelect: true + }); + + bbarpaging = new Ext.PagingToolbar({ + pageSize : 25, + store : store, + displayInfo : true, + displayMsg : _('ID_GRID_PAGE_DISPLAYING_EMAIL_MESSAGE') + '    ', + emptyMsg : _('ID_GRID_PAGE_NO_EMAIL_MESSAGE') + }); + + emailsGrid = new Ext.grid.EditorGridPanel({ + region: 'center', + layout: 'fit', + id: 'emailsGrid', + height:100, + autoWidth : true, + stateful : true, + stateId : 'grid', + enableColumnResize: true, + enableHdMenu: true, + frame:false, + columnLines: false, + viewConfig: { + forceFit:true + }, + clicksToEdit: 1, + title : _('ID_EMAILS'), + store: store, + cm: cmodel, + sm: smodel, + tbar: actions, + bbar: bbarpaging, + plugins: expander, + listeners: { + render: function(){ + this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')}); + } + } + }); + + emailsGrid.store.load(); + + viewport = new Ext.Viewport({ + layout: 'fit', + autoScroll: false, + items: [ + emailsGrid + ] + }); + }); + +var _addPluginActions = function(defaultactions) { + try { + if (Ext.isArray(_pluginactions)) { + if (_pluginactions.length > 0) { + var positionToInsert = _tbfillPosition(defaultactions); + var leftactions = defaultactions.slice(0, positionToInsert); + var rightactions = defaultactions.slice(positionToInsert, defaultactions.length - 1); + return leftactions.concat(_pluginactions.concat(rightactions)); + } + else { + return defaultactions; + } + } + else { + return defaultactions; + } + } + catch (error) { + return defaultactions; + } +}; + +var _tbfillPosition = function(actions) { + try { + for (var i = 0; i < actions.length; i++) { + if (Ext.isObject(actions[i])) { + if (actions[i].xtype == 'tbfill') { + return i; + } + } + } + return i; + } + catch (error) { + return 0; + } +}; \ No newline at end of file From 29d4cb3fa0dbb1ca0809d9375baaf2d135ad16df Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Wed, 28 Nov 2012 12:50:02 -0400 Subject: [PATCH 65/70] =?UTF-8?q?BUG=2010110=20A=C3=B1r=20modulo=20de=20lo?= =?UTF-8?q?gs=20para=20envio=20de=20correos=20electronicos=20SOLVED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - According to the specifications. - Was add the the list of emails. enter the commit message for your changes. Lines starting --- workflow/engine/classes/model/AppMessage.php | 8 + workflow/engine/menus/setup.php | 1 + workflow/engine/methods/mails/emailList.php | 96 +++++ workflow/engine/methods/mails/emailsAjax.php | 154 ++++++++ .../engine/templates/mails/emailList.html | 3 + workflow/engine/templates/mails/emailList.js | 355 ++++++++++++++++++ 6 files changed, 617 insertions(+) create mode 100644 workflow/engine/methods/mails/emailList.php create mode 100644 workflow/engine/methods/mails/emailsAjax.php create mode 100644 workflow/engine/templates/mails/emailList.html create mode 100644 workflow/engine/templates/mails/emailList.js diff --git a/workflow/engine/classes/model/AppMessage.php b/workflow/engine/classes/model/AppMessage.php index 0ce2e71bc..9b4996dbc 100755 --- a/workflow/engine/classes/model/AppMessage.php +++ b/workflow/engine/classes/model/AppMessage.php @@ -120,5 +120,13 @@ class AppMessage extends BaseAppMessage return $this->getAppMsgUid(); } } + + public function updateStatus($msgUid, $msgStatus) + { + $message = AppMessagePeer::retrieveByPk( $msgUid ); + $message->fromArray( $message, BasePeer::TYPE_FIELDNAME ); + $message->setAppMsgStatus($msgStatus); + $message->save(); + } } diff --git a/workflow/engine/menus/setup.php b/workflow/engine/menus/setup.php index bd0fd6a6f..7f562e290 100755 --- a/workflow/engine/menus/setup.php +++ b/workflow/engine/menus/setup.php @@ -85,5 +85,6 @@ if ($RBAC->userCanAccess('PM_SETUP') == 1) { $G_TMP_MENU->AddIdRawOption('EVENT', '../events/eventList', G::LoadTranslation('ID_EVENTS'), '', '', 'logs'); $G_TMP_MENU->AddIdRawOption('LOG_CASE_SCHEDULER', '../cases/cases_Scheduler_Log', G::LoadTranslation('ID_CASE_SCHEDULER'), "icon-logs-list.png",'', 'logs'); $G_TMP_MENU->AddIdRawOption("CRON", "../setup/cron", G::LoadTranslation("ID_CRON_ACTIONS"), null, null, "logs"); + $G_TMP_MENU->AddIdRawOption('EMAILS', '../mails/emailList', ucfirst (strtolower ( G::LoadTranslation('ID_EMAILS'))), '', '', 'logs'); } diff --git a/workflow/engine/methods/mails/emailList.php b/workflow/engine/methods/mails/emailList.php new file mode 100644 index 000000000..f0f02e952 --- /dev/null +++ b/workflow/engine/methods/mails/emailList.php @@ -0,0 +1,96 @@ +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + */ + +global $RBAC; +if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) { + G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' ); + G::header( 'location: ../login/login' ); + die(); +} + +G::LoadClass( 'configuration' ); +$c = new Configurations(); +$configPage = $c->getConfiguration( 'eventList', 'pageSize', '', $_SESSION['USER_LOGGED'] ); +$Config['pageSize'] = isset( $configPage['pageSize'] ) ? $configPage['pageSize'] : 20; + +$G_MAIN_MENU = 'processmaker'; +$G_SUB_MENU = 'logs'; +$G_ID_MENU_SELECTED = 'logs'; +$G_ID_SUB_MENU_SELECTED = 'EMAILS'; + +//get values for the comboBoxes +$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null; +$status = array ( + array ('',G::LoadTranslation( 'ID_ALL' )), + array ("sent", "Sent"), + array ("pending", "Pending") +); +//$type = array (array ('',G::LoadTranslation( 'ID_ALL' ) +//),array ('SEND_MESSAGE',G::LoadTranslation( 'ID_EVENT_MESSAGE' ) +//),array ('EXECUTE_TRIGGER',G::LoadTranslation( 'ID_EVENT_TIMER' ) +//),array ('EXECUTE_CONDITIONAL_TRIGGER',G::LoadTranslation( 'ID_EVENT_CONDITIONAL' ) +//) +//); +$processes = getProcessArray( $userUid ); + +$G_PUBLISH = new Publisher(); + +$oHeadPublisher = & headPublisher::getSingleton(); +$oHeadPublisher->addExtJsScript( 'mails/emailList', false ); //adding a javascript file .js +$oHeadPublisher->addContent( 'mails/emailList' ); //adding a html file .html. +//sending the columns to display in grid +//$oHeadPublisher->assign( 'typeValues', $type ); +$oHeadPublisher->assign( 'statusValues', $status ); +$oHeadPublisher->assign( 'processValues', $processes ); + +function getProcessArray ($userUid) +{ + global $oAppCache; + require_once ("classes/model/AppCacheView.php"); + + $processes = Array (); + $processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' )); + + $cProcess = new Criteria( 'workflow' ); + $cProcess->clearSelectColumns(); + $cProcess->addSelectColumn( AppCacheViewPeer::PRO_UID ); + $cProcess->addSelectColumn( AppCacheViewPeer::APP_PRO_TITLE ); + $cProcess->setDistinct( AppCacheViewPeer::PRO_UID ); + + $cProcess->addAscendingOrderByColumn( AppCacheViewPeer::APP_PRO_TITLE ); + + $oDataset = AppCacheViewPeer::doSelectRS( $cProcess ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + + while ($aRow = $oDataset->getRow()) { + $processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE']); + $oDataset->next(); + } + + return $processes; +} + +G::RenderPage( 'publish', 'extJs' ); + diff --git a/workflow/engine/methods/mails/emailsAjax.php b/workflow/engine/methods/mails/emailsAjax.php new file mode 100644 index 000000000..588761d33 --- /dev/null +++ b/workflow/engine/methods/mails/emailsAjax.php @@ -0,0 +1,154 @@ +status = 'OK'; + + $criteria = new Criteria(); + $criteria->addJoin(AppMessagePeer::APP_UID, ApplicationPeer::APP_UID); + if ($emailStatus != '') { + $criteria->add( AppMessagePeer::APP_MSG_STATUS, $emailStatus, Criteria::LESS_EQUAL ); + } + if ($proUid != '') { + $criteria->add( ApplicationPeer::PRO_UID, $proUid); + } + if ($dateFrom != '') { + if ($dateTo != '') { + $criteria->add( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ) ) ); + } else { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL ); + } + } elseif ($dateTo != '') { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ); + } + + $result = AppMessagePeer::doSelectRS($criteria); + $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $data = Array(); + while ( $result->next() ) { + $data[] = $result->getRow(); + } + $totalCount = count($data); + + $criteria = new Criteria(); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_UID); + $criteria->addSelectColumn(AppMessagePeer::APP_UID); + $criteria->addSelectColumn(AppMessagePeer::DEL_INDEX); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TYPE); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SUBJECT); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_FROM); + + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TO); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_BODY); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_STATUS); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_DATE); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SEND_DATE); + $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SHOW_MESSAGE); + + $criteria->addSelectColumn(ApplicationPeer::PRO_UID); + + $criteria->addAsColumn('PRO_TITLE', 'C2.CON_VALUE'); + $criteria->addAlias('C2', 'CONTENT'); + + if ($emailStatus != '') { + $criteria->add( AppMessagePeer::APP_MSG_STATUS, $emailStatus, Criteria::LESS_EQUAL ); + } + if ($proUid != '') { + $criteria->add( ApplicationPeer::PRO_UID, $proUid); + } + if ($dateFrom != '') { + if ($dateTo != '') { + $criteria->add( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $criteria->getNewCriterion( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ) ) ); + } else { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateFrom, Criteria::GREATER_EQUAL ); + } + } elseif ($dateTo != '') { + $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateTo, Criteria::LESS_EQUAL ); + } + + if ($sort != '') { + if ($dir == 'ASC') { + $criteria->addAscendingOrderByColumn($sort); + } else { + $criteria->addDescendingOrderByColumn($sort); + } + } else { + $oCriteria->addDescendingOrderByColumn(AppMessagePeer::APP_MSG_SEND_DATE ); + } + if ($limit != '') { + $criteria->setLimit($limit); + $criteria->setOffset($start); + } + $criteria->addJoin(AppMessagePeer::APP_UID, ApplicationPeer::APP_UID); + + $conditions = array(); + $conditions[] = array(ApplicationPeer::PRO_UID, 'C2.CON_ID'); + $conditions[] = array( + 'C2.CON_CATEGORY', DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter() + ); + $conditions[] = array( + 'C2.CON_LANG', DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter() + ); + $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN); + $result = AppMessagePeer::doSelectRS($criteria); + $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $data = Array(); + $dataPro = array(); + $index = 0; + $content = new Content(); + $tasTitleDefault = G::LoadTranslation('ID_TASK_NOT_RELATED'); + while ( $result->next() ) { + + $row = $result->getRow(); + $row['APP_MSG_FROM'] =htmlentities($row['APP_MSG_FROM'], ENT_QUOTES, "UTF-8"); + $row['APP_MSG_STATUS'] = ucfirst ( $row['APP_MSG_STATUS']); + $row['TAS_TITLE'] = $tasTitleDefault; + if ($row['DEL_INDEX'] != 0) { + $criteria = new Criteria(); + $criteria->addSelectColumn(AppDelegationPeer::PRO_UID); + $criteria->addSelectColumn(AppDelegationPeer::TAS_UID); + $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteria->add(AppDelegationPeer::APP_UID, $row['APP_UID']); + $resultDelegation = AppDelegationPeer::doSelectRS($criteria); + $resultDelegation->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $row['TAS_TITLE'] = '-'; + while ($resultDelegation->next()) { + $rowDelegation = $resultDelegation->getRow(); + if ($row['DEL_INDEX'] == $rowDelegation['DEL_INDEX']) { + $row['TAS_TITLE'] = $content->load( 'TAS_TITLE', '', $rowDelegation['TAS_UID'], SYS_LANG ); + break; + } + } + } + + $data[] = $row; + } + $response = array(); + $response['totalCount'] = $totalCount; + $response['data'] = $data; + die(G::json_encode($response)); + break; + case 'updateStatusMessage': + if (isset($_REQUEST['APP_MSG_UID']) && isset($_REQUEST['APP_MSG_STATUS'])) { + $message = new AppMessage(); + $result = $message->updateStatus($_REQUEST['APP_MSG_UID'], $_REQUEST['APP_MSG_STATUS']); + } + break; +} + diff --git a/workflow/engine/templates/mails/emailList.html b/workflow/engine/templates/mails/emailList.html new file mode 100644 index 000000000..432f567b5 --- /dev/null +++ b/workflow/engine/templates/mails/emailList.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/workflow/engine/templates/mails/emailList.js b/workflow/engine/templates/mails/emailList.js new file mode 100644 index 000000000..ff1611a64 --- /dev/null +++ b/workflow/engine/templates/mails/emailList.js @@ -0,0 +1,355 @@ +/* + * @author: Marco Antonio + * Agos 17st, 2012 + */ +new Ext.KeyMap(document, [{ + key: Ext.EventObject.F5, + fn: function(keycode, e) { + if (! e.ctrlKey) { + if (Ext.isIE) { + // IE6 doesn't allow cancellation of the F5 key, so trick it into + // thinking some other key was pressed (backspace in this case) + e.browserEvent.keyCode = 8; + } + e.stopEvent(); + document.location = document.location; + } else { + Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); + } + } +} +]); + +var store; +var cmodel; +var emailsGrid; +var actions; +var filterStatus = ''; + +Ext.onReady(function(){ + Ext.QuickTips.init(); + var resultTpl = new Ext.XTemplate( + '
', + ' {APP_PRO_TITLE}', + '
' + ); + + var columnRenderer = function(data, metadata, record, rowIndex,columnIndex, store) { + var new_text = metadata.style.split(';'); + var style = ''; + for (var i = 0; i < new_text.length -1 ; i++) { + var chain = new_text[i] +";"; + if (chain.indexOf('width') == -1) { + style = style + chain; + } + } + metadata.attr = 'ext:qtip="' + data + '" style="'+ style +' white-space: normal; "'; + return data; + }; + + var dateFrom = new Ext.form.DateField({ + id:'dateFrom', + format: 'Y-m-d', + width: 120, + value: '' + }); + + var dateTo = new Ext.form.DateField({ + id:'dateTo', + format: 'Y-m-d', + width: 120, + value: '' + }); + + // ComboBox Status + var comboStatus = new Ext.form.ComboBox({ + width : 90, + boxMaxWidth : 90, + editable : false, + mode : 'local', + emptyText: _('ID_SELECT_STATUS'), + store : new Ext.data.ArrayStore({ + fields: ['id', 'value'], + data : statusValues + }), + valueField : 'id', + displayField : 'value', + triggerAction : 'all', + listeners:{ + scope: this, + 'select': function() { + filterStatus = comboStatus.value; + store.setBaseParam( 'status', filterStatus); + store.setBaseParam( 'start', 0); + store.setBaseParam( 'limit', 25); + store.load(); + } + }, + iconCls: 'no-icon' + }); + + var comboProcess = new Ext.form.ComboBox({ + width : 200, + boxMaxWidth : 200, + editable : true, + displayField : 'APP_PRO_TITLE', + valueField : 'PRO_UID', + forceSelection: false, + emptyText: _('ID_EMPTY_PROCESSES'), + selectOnFocus: true, + tpl: resultTpl, + + typeAhead: true, + mode: 'local', + autocomplete: true, + triggerAction: 'all', + + store : new Ext.data.ArrayStore({ + fields : ['PRO_UID','APP_PRO_TITLE'], + data : processValues + }), + listeners:{ + scope: this, + 'select': function() { + filterProcess = comboProcess.value; + + store.setBaseParam('process', filterProcess); + store.setBaseParam( 'start', 0); + store.setBaseParam( 'limit', 25); + store.load(); + }}, + iconCls: 'no-icon' + }); + + actions = _addPluginActions([ {xtype: 'tbfill'}, _('ID_PROCESS'), comboProcess, '-', /*_('ID_TYPE'), comboType, '-',*/ _('ID_STATUS'), comboStatus, _('ID_DELEGATE_DATE_FROM'), + dateFrom, + ' ', + _('ID_TO'), + dateTo, + new Ext.Button ({ + text: _('ID_FILTER_BY_DELEGATED_DATE'), + handler: function(){ + store.setBaseParam('dateFrom', dateFrom.getValue()); + store.setBaseParam('dateTo', dateTo.getValue()); + store.load({params:{ start : 0 , limit : 25 }}); + } + }) + ]); + + var stepsFields = Ext.data.Record.create([ + {name : 'APP_MSG_TYPE', type: 'string'}, + {name : 'APP_MSG_FROM', type: 'string'}, + {name : 'APP_MSG_TO', type: 'string'}, + {name : 'APP_MSG_DATE', type: 'string'}, + {name : 'APP_MSG_STATUS', type: 'string'} + + ]); + + store = new Ext.data.Store( { + proxy : new Ext.data.HttpProxy({ + url: 'emailsAjax?request=MessageList' + }), + remoteSort : true, + sortInfo : stepsFields, + reader : new Ext.data.JsonReader( { + root: 'data', + totalProperty: 'totalCount', + fields : [ + {name : 'APP_MSG_UID'}, + {name : 'APP_UID'}, + {name : 'DEL_INDEX'}, + {name : 'PRO_UID'}, + {name : 'TAS_UID'}, + {name : 'PRO_TITLE'}, + {name : 'TAS_TITLE'}, + {name : 'APP_MSG_TYPE'}, + {name : 'APP_MSG_SUBJECT'}, + {name : 'APP_MSG_FROM'}, + {name : 'APP_MSG_TO'}, + {name : 'APP_MSG_STATUS'}, + {name : 'APP_MSG_DATE'}, + {name : 'APP_MSG_SEND_DATE'}, + {name : 'APP_MSG_BODY'} + ] + }) + }); + store.setDefaultSort('APP_MSG_DATE', 'desc'); + + var expander = new Ext.ux.grid.RowExpander({ + tpl : new Ext.Template( + '


'+_('ID_PREVIEW')+':
'+ + '
'+ + '
'+ + '
 
'+ + '
{APP_MSG_BODY}
'+ + '
 
'+ + '
'+ + '
'+ + '



' + ) + }); + + var statusValuesGrid = statusValues; + statusValuesGrid.splice( 0, 1 ); + cmodel = new Ext.grid.ColumnModel({ + viewConfig: { + forceFit:true, + cls:"x-grid-empty", + emptyText: _('ID_NO_RECORDS_FOUND') + }, + defaults: { + width: 50 + }, + columns: [ + expander, + {id:'APP_MSG_UID', dataIndex: 'APP_MSG_UID', hidden:true, hideable:false}, + {header: 'APP_UID', dataIndex: 'APP_UID', hidden:true, hideable:false}, + {header: 'DEL_INDEX', dataIndex: 'DEL_INDEX', hidden:true, hideable:false}, + {header: 'PRO_UID', dataIndex: 'PRO_UID', hidden:true, hideable:false, sortable: false}, + {header: 'TAS_UID', dataIndex: 'TAS_UID', hidden:true, hideable:false, sortable: false}, + {header: _('ID_PROCESS'), dataIndex: 'PRO_TITLE', width: 100, hidden: false,renderer: columnRenderer, sortable: false}, + {header: _('ID_TASK'), dataIndex: 'TAS_TITLE', width: 100, hidden: false,renderer: columnRenderer, sortable: false}, + {header: _('ID_TYPE'), dataIndex: 'APP_MSG_TYPE', width: 50, hidden: false,renderer: columnRenderer, sortable: true}, + {header: _('ID_DATE_LABEL'), dataIndex: 'APP_MSG_DATE', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, + //{header: _('ID_DERIVED'), dataIndex: 'APP_MSG_SEND_DATE', width: 80,hidden:false,hideable:false, renderer: columnRenderer, sortable: true}, + {header: _('ID_SUBJECT'), dataIndex: 'APP_MSG_SUBJECT', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, + {header: _('ID_FROM'), dataIndex: 'APP_MSG_FROM', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, + {header: _('ID_TO'), dataIndex: 'APP_MSG_TO', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, + //{header: _('ID_STATUS'), dataIndex: 'APP_MSG_STATUS', width: 50,hidden:false,hideable:false, renderer: columnRenderer, sortable: true} + { + header: _('ID_STATUS'), + dataIndex: 'APP_MSG_STATUS', + width: 50, + //hidden:false, + //hideable:false, + renderer: columnRenderer, + //sortable: true, + editor: new Ext.form.ComboBox({ + listClass: 'x-combo-list-small', + mode: 'local', + displayField:'value', + lazyRender: true, + triggerAction: 'all', + valueField:'id', + editable: false, + store: new Ext.data.ArrayStore({ + fields: ['id', 'value'], + data : statusValuesGrid + }), + listeners: { + select: function(a, b) { + var row = emailsGrid.getSelectionModel().getSelected(); + Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} }); + Ext.Ajax.request({ + url : 'emailsAjax' , + params : { + request : 'updateStatusMessage', + APP_MSG_UID: row.data.APP_MSG_UID, + APP_MSG_STATUS: this.value + }, + success: function ( result, request ) { + Ext.MessageBox.hide(); + }, + failure: function ( result, request) { + if (typeof(result.responseText) != 'undefined') { + Ext.MessageBox.alert(_('ID_FAILED'), result.responseText); + } + } + }); + } + } + }) + } + ] + }); + + smodel = new Ext.grid.RowSelectionModel({ + singleSelect: true + }); + + bbarpaging = new Ext.PagingToolbar({ + pageSize : 25, + store : store, + displayInfo : true, + displayMsg : _('ID_GRID_PAGE_DISPLAYING_EMAIL_MESSAGE') + '    ', + emptyMsg : _('ID_GRID_PAGE_NO_EMAIL_MESSAGE') + }); + + emailsGrid = new Ext.grid.EditorGridPanel({ + region: 'center', + layout: 'fit', + id: 'emailsGrid', + height:100, + autoWidth : true, + stateful : true, + stateId : 'grid', + enableColumnResize: true, + enableHdMenu: true, + frame:false, + columnLines: false, + viewConfig: { + forceFit:true + }, + clicksToEdit: 1, + title : _('ID_EMAILS'), + store: store, + cm: cmodel, + sm: smodel, + tbar: actions, + bbar: bbarpaging, + plugins: expander, + listeners: { + render: function(){ + this.loadMask = new Ext.LoadMask(this.body, {msg:_('ID_LOADING_GRID')}); + } + } + }); + + emailsGrid.store.load(); + + viewport = new Ext.Viewport({ + layout: 'fit', + autoScroll: false, + items: [ + emailsGrid + ] + }); + }); + +var _addPluginActions = function(defaultactions) { + try { + if (Ext.isArray(_pluginactions)) { + if (_pluginactions.length > 0) { + var positionToInsert = _tbfillPosition(defaultactions); + var leftactions = defaultactions.slice(0, positionToInsert); + var rightactions = defaultactions.slice(positionToInsert, defaultactions.length - 1); + return leftactions.concat(_pluginactions.concat(rightactions)); + } + else { + return defaultactions; + } + } + else { + return defaultactions; + } + } + catch (error) { + return defaultactions; + } +}; + +var _tbfillPosition = function(actions) { + try { + for (var i = 0; i < actions.length; i++) { + if (Ext.isObject(actions[i])) { + if (actions[i].xtype == 'tbfill') { + return i; + } + } + } + return i; + } + catch (error) { + return 0; + } +}; \ No newline at end of file From 9581c9d3e7365162c4c9c3c739da1509c27ef64c Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Wed, 28 Nov 2012 14:19:35 -0400 Subject: [PATCH 66/70] BUG 7222 Etiquetas con HTML muestran caracteres html extra en las filas SOLVED - El valor que se coloca en el atributo pm:label no estaba siendo validado - El valor ahora es validado usando entidades --- gulliver/system/class.xmlform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 56c7ea2a2..589007a0c 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -807,7 +807,7 @@ class XmlForm_Field public function NSGridLabel ($show = false) { - $idv = 'pm:label="' . $this->pmLabel . '"'; + $idv = 'pm:label="' . htmlentities($this->pmLabel, ENT_COMPAT, 'utf-8') . '"'; if ($show) { return $idv; } else { From f26704e315daf1b5533e04a2a2b77e9d3006c5ab Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Wed, 28 Nov 2012 14:30:12 -0400 Subject: [PATCH 67/70] =?UTF-8?q?BUG=2010110=20A=C3=B1r=20modulo=20de=20lo?= =?UTF-8?q?gs=20para=20envio=20de=20correos=20electronicos=20SOLVED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - According to the specifications. - Was add the the list of emails. --- workflow/engine/templates/mails/emailList.js | 25 ++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/workflow/engine/templates/mails/emailList.js b/workflow/engine/templates/mails/emailList.js index ff1611a64..91abcdf12 100644 --- a/workflow/engine/templates/mails/emailList.js +++ b/workflow/engine/templates/mails/emailList.js @@ -121,7 +121,7 @@ Ext.onReady(function(){ iconCls: 'no-icon' }); - actions = _addPluginActions([ {xtype: 'tbfill'}, _('ID_PROCESS'), comboProcess, '-', /*_('ID_TYPE'), comboType, '-',*/ _('ID_STATUS'), comboStatus, _('ID_DELEGATE_DATE_FROM'), + actions = _addPluginActions([ {xtype: 'tbfill'}, _('ID_PROCESS'), comboProcess, '-', _('ID_STATUS'), comboStatus, _('ID_DELEGATE_DATE_FROM'), dateFrom, ' ', _('ID_TO'), @@ -177,15 +177,15 @@ Ext.onReady(function(){ var expander = new Ext.ux.grid.RowExpander({ tpl : new Ext.Template( - '


'+_('ID_PREVIEW')+':
'+ - '
'+ - '
'+ - '
 
'+ - '
{APP_MSG_BODY}
'+ - '
 
'+ - '
'+ - '
'+ - '



' + "
"+ + _('ID_PREVIEW')+ + ":
"+ + "
"+ + "
 
"+ + "
{APP_MSG_BODY}
"+ + "
 
"+ + "
"+ + "

" ) }); @@ -211,19 +211,14 @@ Ext.onReady(function(){ {header: _('ID_TASK'), dataIndex: 'TAS_TITLE', width: 100, hidden: false,renderer: columnRenderer, sortable: false}, {header: _('ID_TYPE'), dataIndex: 'APP_MSG_TYPE', width: 50, hidden: false,renderer: columnRenderer, sortable: true}, {header: _('ID_DATE_LABEL'), dataIndex: 'APP_MSG_DATE', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, - //{header: _('ID_DERIVED'), dataIndex: 'APP_MSG_SEND_DATE', width: 80,hidden:false,hideable:false, renderer: columnRenderer, sortable: true}, {header: _('ID_SUBJECT'), dataIndex: 'APP_MSG_SUBJECT', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, {header: _('ID_FROM'), dataIndex: 'APP_MSG_FROM', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, {header: _('ID_TO'), dataIndex: 'APP_MSG_TO', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, - //{header: _('ID_STATUS'), dataIndex: 'APP_MSG_STATUS', width: 50,hidden:false,hideable:false, renderer: columnRenderer, sortable: true} { header: _('ID_STATUS'), dataIndex: 'APP_MSG_STATUS', width: 50, - //hidden:false, - //hideable:false, renderer: columnRenderer, - //sortable: true, editor: new Ext.form.ComboBox({ listClass: 'x-combo-list-small', mode: 'local', From 9e40d41b675f0bbca63444e6cb4879cd347cc7c9 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Wed, 28 Nov 2012 14:50:36 -0400 Subject: [PATCH 68/70] =?UTF-8?q?BUG=2010110=20A=C3=B1r=20modulo=20de=20lo?= =?UTF-8?q?gs=20para=20envio=20de=20correos=20electronicos=20SOLVED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - According to the specifications. - Was add the the list of emails. --- workflow/engine/templates/mails/emailList.js | 33 ++------------------ 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/workflow/engine/templates/mails/emailList.js b/workflow/engine/templates/mails/emailList.js index a22499437..02cfc145f 100644 --- a/workflow/engine/templates/mails/emailList.js +++ b/workflow/engine/templates/mails/emailList.js @@ -121,11 +121,8 @@ Ext.onReady(function(){ iconCls: 'no-icon' }); -<<<<<<< HEAD actions = _addPluginActions([ {xtype: 'tbfill'}, _('ID_PROCESS'), comboProcess, '-', _('ID_STATUS'), comboStatus, _('ID_DELEGATE_DATE_FROM'), -======= - actions = _addPluginActions([ {xtype: 'tbfill'}, _('ID_PROCESS'), comboProcess, '-', /*_('ID_TYPE'), comboType, '-',*/ _('ID_STATUS'), comboStatus, _('ID_DELEGATE_DATE_FROM'), ->>>>>>> origin/BUG-10110 + dateFrom, ' ', _('ID_TO'), @@ -181,7 +178,6 @@ Ext.onReady(function(){ var expander = new Ext.ux.grid.RowExpander({ tpl : new Ext.Template( -<<<<<<< HEAD "
"+ _('ID_PREVIEW')+ ":
"+ @@ -191,17 +187,6 @@ Ext.onReady(function(){ "
 
"+ ""+ "

" -======= - '


'+_('ID_PREVIEW')+':
'+ - '
'+ - '
'+ - '
 
'+ - '
{APP_MSG_BODY}
'+ - '
 
'+ - '
'+ - '
'+ - '



' ->>>>>>> origin/BUG-10110 ) }); @@ -227,29 +212,15 @@ Ext.onReady(function(){ {header: _('ID_TASK'), dataIndex: 'TAS_TITLE', width: 100, hidden: false,renderer: columnRenderer, sortable: false}, {header: _('ID_TYPE'), dataIndex: 'APP_MSG_TYPE', width: 50, hidden: false,renderer: columnRenderer, sortable: true}, {header: _('ID_DATE_LABEL'), dataIndex: 'APP_MSG_DATE', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, -<<<<<<< HEAD {header: _('ID_SUBJECT'), dataIndex: 'APP_MSG_SUBJECT', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, {header: _('ID_FROM'), dataIndex: 'APP_MSG_FROM', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, {header: _('ID_TO'), dataIndex: 'APP_MSG_TO', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, -======= - //{header: _('ID_DERIVED'), dataIndex: 'APP_MSG_SEND_DATE', width: 80,hidden:false,hideable:false, renderer: columnRenderer, sortable: true}, - {header: _('ID_SUBJECT'), dataIndex: 'APP_MSG_SUBJECT', width: 80,hidden:false, renderer: columnRenderer, sortable: true}, - {header: _('ID_FROM'), dataIndex: 'APP_MSG_FROM', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, - {header: _('ID_TO'), dataIndex: 'APP_MSG_TO', width: 80,hidden:false,renderer: columnRenderer, sortable: true}, - //{header: _('ID_STATUS'), dataIndex: 'APP_MSG_STATUS', width: 50,hidden:false,hideable:false, renderer: columnRenderer, sortable: true} ->>>>>>> origin/BUG-10110 + { header: _('ID_STATUS'), dataIndex: 'APP_MSG_STATUS', width: 50, -<<<<<<< HEAD renderer: columnRenderer, -======= - //hidden:false, - //hideable:false, - renderer: columnRenderer, - //sortable: true, ->>>>>>> origin/BUG-10110 editor: new Ext.form.ComboBox({ listClass: 'x-combo-list-small', mode: 'local', From 4cdbd2668a51a27f90fc5693006617929a41bdc5 Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Wed, 28 Nov 2012 15:57:55 -0400 Subject: [PATCH 69/70] Changed references to deprecated file "cases_List" --- workflow/engine/classes/class.pmFunctions.php | 4 +- .../methods/cases/casesSaveDataView.php | 2 +- .../methods/cases/cases_DeleteDocument.php | 2 +- .../engine/methods/cases/cases_Derivate.php | 2 +- workflow/engine/methods/cases/cases_List.php | 183 +----------------- .../engine/methods/cases/cases_SaveData.php | 2 +- .../methods/cases/cases_SaveDocument.php | 2 +- workflow/engine/methods/cases/cases_Step.php | 2 +- 8 files changed, 10 insertions(+), 189 deletions(-) diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 937b8bdd5..f6cd3314a 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -1530,7 +1530,7 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu G::LoadClass( 'case' ); $oCase = new Cases(); - $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'cases_List' ); + $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' ); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); @@ -2109,7 +2109,7 @@ function jumping ($caseId, $delIndex) } catch (Exception $oException) { G::SendTemporalMessage( 'ID_NOT_DERIVATED', 'error', 'labels' ); } - G::header( 'Location: cases_List' ); + G::header( 'Location: casesListExtJs' ); } /** diff --git a/workflow/engine/methods/cases/casesSaveDataView.php b/workflow/engine/methods/cases/casesSaveDataView.php index b57cbe498..43ad3f696 100755 --- a/workflow/engine/methods/cases/casesSaveDataView.php +++ b/workflow/engine/methods/cases/casesSaveDataView.php @@ -31,7 +31,7 @@ G::LoadClass( 'case' ); //load the variables $oCase = new Cases(); -$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); +$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs' ); $Fields = $oCase->loadCase( $_SESSION['APPLICATION'] ); $Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); $Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], (array) $_POST['form'] ); diff --git a/workflow/engine/methods/cases/cases_DeleteDocument.php b/workflow/engine/methods/cases/cases_DeleteDocument.php index 6c3a589a8..26db38ec9 100755 --- a/workflow/engine/methods/cases/cases_DeleteDocument.php +++ b/workflow/engine/methods/cases/cases_DeleteDocument.php @@ -45,7 +45,7 @@ G::LoadClass( 'case' ); $oAppDocument = new AppDocument(); $oAppDocument->remove( $_GET['DOC'] ); $oCase = new Cases(); -$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List' ); +$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs' ); if ($_GET['TYPE'] == 'INPUT') { $aNextStep = $oCase->getNextStep( $_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['STEP_POSITION'] - 1 ); } diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index c9f89b657..2d8a6ea2c 100755 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -53,7 +53,7 @@ try { //load data $oCase = new Cases(); //warning: we are not using the result value of function thisIsTheCurrentUser, so I'm commenting to optimize speed. - //$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List'); + //$oCase->thisIsTheCurrentUser( $_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs'); $appFields = $oCase->loadCase( $_SESSION['APPLICATION'] ); $appFields['APP_DATA'] = array_merge( $appFields['APP_DATA'], G::getSystemConstants() ); //cleaning debug variables diff --git a/workflow/engine/methods/cases/cases_List.php b/workflow/engine/methods/cases/cases_List.php index 714c862f4..83a70c558 100755 --- a/workflow/engine/methods/cases/cases_List.php +++ b/workflow/engine/methods/cases/cases_List.php @@ -1,182 +1,3 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ - -/** - * Cases list (Refactored) - * By Erik A. - * O. - */ - -/* Permissions */ -if (($RBAC_Response = $RBAC->userCanAccess( "PM_CASES" )) != 1) { - return $RBAC_Response; -} - - /* Includes */ -G::LoadClass( 'case' ); -G::LoadClass( 'configuration' ); - -// $_GET['l'] has the type of cases list like todo,pause,cancel, all - - -$conf = new Configurations(); -if (! isset( $_GET['l'] )) { - $confCasesList = $conf->loadObject( 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); - if (is_array( $confCasesList )) { - $sTypeList = $confCasesList['sTypeList']; - } else { - $sTypeList = 'to_do'; - } -} else { - $sTypeList = $_GET['l']; - $confCasesList = array ('sTypeList' => $sTypeList - ); - $conf->saveObject( $confCasesList, 'ProcessMaker', 'cases_List', '', $_SESSION['USER_LOGGED'], '' ); -} - -$sUIDUserLogged = $_SESSION['USER_LOGGED']; -$_SESSION['CASES_MENU_OPTION'] = $sTypeList; - -$oCases = new Cases(); - -/** - * here we verify if there is a any case with a unpause on this day - */ -if ($sTypeList === 'to_do' or $sTypeList === 'draft' or $sTypeList === 'paused') { - $oCases->ThrowUnpauseDaemon( date( 'Y-m-d' ) ); -} - -/* * - * Prepare the addtional filters before to show - * By Erik - */ - -$aAdditionalFilter = Array (); - -if (isset( $_GET['PROCESS_UID'] ) and $_GET['PROCESS_UID'] != "0" && $_GET['PROCESS_UID'] != "") { - $PRO_UID = $_GET['PROCESS_UID']; - $aAdditionalFilter['PRO_UID'] = $PRO_UID; -} else { - $PRO_UID = "0"; -} -if (isset( $_GET['READ'] ) and $_GET['READ'] == "1") { - $aAdditionalFilter['READ'] = $_GET['READ']; -} -if (isset( $_GET['UNREAD'] ) and $_GET['UNREAD'] == "1") { - $aAdditionalFilter['UNREAD'] = $_GET['UNREAD']; -} - -if (isset( $_GET['APP_STATUS_FILTER'] ) and $_GET['APP_STATUS_FILTER'] != "ALL") { - $aAdditionalFilter['APP_STATUS_FILTER'] = $_GET['APP_STATUS_FILTER']; -} - -if (isset( $_GET['MINE'] ) and $_GET['MINE'] == "1") { - $aAdditionalFilter['MINE'] = $_GET['MINE']; -} - -switch ($sTypeList) { - case 'to_do': - if (defined( 'ENABLE_CASE_LIST_OPTIMIZATION' )) { - $aCriteria = $oCases->prepareCriteriaForToDo( $sUIDUserLogged ); - $xmlfile = 'cases/cases_ListTodoNew'; - } else { - list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); - } - break; - default: - list ($aCriteria, $xmlfile) = $oCases->getConditionCasesList( $sTypeList, $sUIDUserLogged, true, $aAdditionalFilter ); -} - -/* -$rs = ApplicationPeer::doSelectRS($aCriteria); - $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $aRows1 = Array(); - while($rs->next()) { - $aRows1[] = $rs->getRow(); - - } - -g::pr($aRows1);die;*/ -/* GET , POST & $_SESSION Vars */ - -if (! isset( $_GET['PROCESS_UID'] )) { - $oCase = new Cases(); - $rs = ApplicationPeer::doSelectRS( $aCriteria ); - $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - - $aProcess = Array (); - while ($rs->next()) { - $aRow = $rs->getRow(); - //g::pr($aRow); die; - if (! InAssocArray( $aRow, 'PRO_UID', $aRow['PRO_UID'] )) { - array_push( $aProcess, Array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['APP_PRO_TITLE'] ) ); - } - } - - $_DBArray['_PROCESSES'] = array_merge( Array (Array ('PRO_UID' => 'char','PRO_TITLE' => 'char' ) ), $aProcess ); - $_SESSION['_DBArray'] = $_DBArray; -} else { - $_DBArray = $_SESSION['_DBArray']; -} - -/* Render page */ -$G_PUBLISH = new Publisher(); -$G_PUBLISH->ROWS_PER_PAGE = 12; - -if ($sTypeList == 'to_reassign') { - $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'cases/cases_ReassignBy', '', array ('REASSIGN_BY' => 1 ) ); -} - -$aData = Array ('PROCESS_FILTER' => $PRO_UID,'APP_STATUS_FILTER' => (isset( $_GET['APP_STATUS_FILTER'] ) ? $_GET['APP_STATUS_FILTER'] : '0') -); - -$G_PUBLISH->AddContent( 'propeltable', 'paged-table', $xmlfile, $aCriteria, $aData ); - -G::RenderPage( 'publish', 'blank' ); - -function InAssocArray ($a, $k, $v) -{ - foreach ($a as $item) { - if (isset( $item[$k] ) && $v == $item[$k]) { - return true; - } - } - return false; -} - -?> - -thisIsTheCurrentUser( $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "cases_List" ); + $oCase->thisIsTheCurrentUser( $_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs" ); $Fields = $oCase->loadCase( $_SESSION["APPLICATION"] ); $Fields["APP_DATA"] = array_merge( $Fields["APP_DATA"], G::getSystemConstants() ); diff --git a/workflow/engine/methods/cases/cases_SaveDocument.php b/workflow/engine/methods/cases/cases_SaveDocument.php index 21f64884f..5e37770ea 100755 --- a/workflow/engine/methods/cases/cases_SaveDocument.php +++ b/workflow/engine/methods/cases/cases_SaveDocument.php @@ -69,7 +69,7 @@ $appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP $actionType = $_POST["form"]["actionType"]; $case = new Cases(); -$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "cases_List"); +$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs"); //Load the fields $arrayField = $case->loadCase($_SESSION["APPLICATION"]); diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 31d8f0328..92d484498 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -160,7 +160,7 @@ if (isset( $_GET['breakpoint'] )) { #end trigger debug session....... -//$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'cases_List'); +//$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], 'REDIRECT', 'casesListExtJs'); //Save data - Start From 0055a303fae5df63b5be0feca3429c59cc75d333 Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Wed, 28 Nov 2012 17:32:31 -0400 Subject: [PATCH 70/70] Improvement to avoid the old queries for get the cases list --- workflow/engine/methods/cases/cases_ReassignByUser.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow/engine/methods/cases/cases_ReassignByUser.php b/workflow/engine/methods/cases/cases_ReassignByUser.php index 7ae15e085..9f250cf37 100755 --- a/workflow/engine/methods/cases/cases_ReassignByUser.php +++ b/workflow/engine/methods/cases/cases_ReassignByUser.php @@ -93,11 +93,11 @@ try { $oTasks = new Tasks(); $oGroups = new Groups(); $oUser = new Users(); - G::LoadClass( 'case' ); - $oCases = new Cases(); - list ($oCriteriaToDo, $sXMLFile) = $oCases->getConditionCasesList( 'to_do', $sUserToReassign ); - list ($oCriteriaDraft, $sXMLFile) = $oCases->getConditionCasesList( 'draft', $sUserToReassign ); + $oAppCache = new AppCacheView(); + + $oCriteriaToDo = $oAppCache->getToDoListCriteria($sUserToReassign); + $oCriteriaDraft = $oAppCache->getDraftListCriteria($sUserToReassign); $aCasesList = Array ();