From af2ec6e71cef0cae8dc6f8a80a68cdde2f7779df Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Fri, 19 Oct 2018 17:01:49 -0400 Subject: [PATCH] HOR-4816 --- gulliver/system/class.g.php | 8 +- gulliver/system/class.table.php | 45 +--------- gulliver/system/class.xmlform.php | 3 +- .../classes/ActionsByEmailCoreClass.php | 19 +--- workflow/engine/classes/JavaBridgePM.php | 9 +- workflow/engine/classes/ProcessMap.php | 29 +----- workflow/engine/classes/WsBase.php | 2 +- .../engine/classes/model/OutputDocument.php | 15 +--- .../engine/controllers/InstallerModule.php | 2 +- .../engine/controllers/caseSchedulerProxy.php | 8 +- workflow/engine/controllers/webEntryProxy.php | 20 +---- .../cases/cases_SchedulerValidateUser.php | 34 +------ .../engine/methods/login/authentication.php | 2 +- .../processes/processes_webEntryGenerate.php | 17 ++-- .../processes/processes_webEntryValidate.php | 17 +--- .../methods/processes/webEntry_Val_Assig.php | 25 ++---- .../engine/methods/setup/webServicesSetup.php | 27 +----- .../BusinessModel/Cases/OutputDocument.php | 3 +- .../BusinessModel/ProjectUser.php | 14 ++- .../ProcessMaker/BusinessModel/WebEntry.php | 6 +- .../BusinessModel/WebEntryEvent.php | 29 +++--- .../engine/src/ProcessMaker/Core/System.php | 90 ++++++++++++++++++- .../templates/setup/webServicesTree.php | 27 +----- 23 files changed, 171 insertions(+), 280 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index f7bf48ac6..563fce0e5 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -5451,7 +5451,7 @@ class G } elseif ($configuration['MESS_ENGINE'] == 'PHPMAILER' && preg_match('/(.+)@(.+)\.(.+)/', $configuration['MESS_ACCOUNT'], $match)) { $from .= ' <' . $configuration['MESS_ACCOUNT'] . '>'; } else { - $from .= ' '; + $from .= ' '; } } } else { @@ -5460,15 +5460,15 @@ class G } elseif ($configuration['MESS_FROM_NAME'] != '' && $configuration['MESS_ENGINE'] == 'PHPMAILER' && preg_match('/(.+)@(.+)\.(.+)/', $configuration['MESS_ACCOUNT'], $match)) { $from = $configuration['MESS_FROM_NAME'] . ' <' . $configuration['MESS_ACCOUNT'] . '>'; } elseif ($configuration['MESS_FROM_NAME'] != '') { - $from = $configuration['MESS_FROM_NAME'] . ' '; + $from = $configuration['MESS_FROM_NAME'] . ' '; } elseif ($configuration['MESS_FROM_MAIL'] != '') { $from = $configuration['MESS_FROM_MAIL']; } elseif ($configuration['MESS_ENGINE'] == 'PHPMAILER' && preg_match('/(.+)@(.+)\.(.+)/', $configuration['MESS_ACCOUNT'], $match)) { $from = $configuration['MESS_ACCOUNT']; } elseif ($configuration['MESS_ENGINE'] == 'PHPMAILER' && $configuration['MESS_ACCOUNT'] != '' && !preg_match('/(.+)@(.+)\.(.+)/', $configuration['MESS_ACCOUNT'], $match)) { - $from = $configuration['MESS_ACCOUNT'] . ' '; + $from = $configuration['MESS_ACCOUNT'] . ' '; } else { - $from = 'info@' . ((isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] != '') ? $_SERVER['HTTP_HOST'] : 'processmaker.com'); + $from = 'info@' . System::getDefaultMailDomain(); } } return $from; diff --git a/gulliver/system/class.table.php b/gulliver/system/class.table.php index de33b99ce..1ab2c2def 100644 --- a/gulliver/system/class.table.php +++ b/gulliver/system/class.table.php @@ -1,45 +1,6 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ -/** - * - * - * - * - * - * - * Table class definition - * Render table - * - * @package gulliver.system - * @author Fernando Ontiveros Lira - * @copyright (C) 2002 by Colosa Development Team. - * - */ +use ProcessMaker\Core\System; class Table { @@ -125,8 +86,8 @@ class Table public function SetSource ($stQry = "", $stDefaultOrder = "UID", $stDefaultOrderDir = 'ASC') { //to fix missing value for variable orderDir, when between pages changes. - $url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?'; - $url2 = strstr( $_SERVER['HTTP_REFERER'] . '?', $_SERVER['HTTP_HOST'] ); + $url1 = System::getServerHost() . $_SERVER['REQUEST_URI'] . '?'; + $url2 = strstr($_SERVER['HTTP_REFERER'] . '?', System::getServerHost()); $url1 = substr( $url1, 0, strpos( $url1, '?' ) ); $url2 = substr( $url2, 0, strpos( $url2, '?' ) ); if ($url1 != $url2) { diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 23a0b7059..159d47479 100644 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -1,5 +1,6 @@ input) { $permission = true; - $url = ((G::is_https()) ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . dirname($_SERVER["REQUEST_URI"]) . "/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"]; + $url = System::getServerProtocolHost() . dirname($_SERVER["REQUEST_URI"]) . "/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"]; $sw = 1; } } diff --git a/workflow/engine/classes/ActionsByEmailCoreClass.php b/workflow/engine/classes/ActionsByEmailCoreClass.php index 6f956d48e..87eac721e 100644 --- a/workflow/engine/classes/ActionsByEmailCoreClass.php +++ b/workflow/engine/classes/ActionsByEmailCoreClass.php @@ -1,6 +1,6 @@ getConfiguration('SKIN_CRON', ''); - $envHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : SERVER_NAME; - $envProtocol = defined("REQUEST_SCHEME") && REQUEST_SCHEME === "https"; - if (isset($_SERVER['SERVER_PORT'])) { - $envPort = ($_SERVER['SERVER_PORT'] != "80") ? ":" . $_SERVER['SERVER_PORT'] : ""; - } else if (defined('SERVER_PORT')) { - $envPort = (SERVER_PORT . "" != "80") ? ":" . SERVER_PORT : ""; - } else { - $envPort = ""; // Empty by default - } - if (!empty($envPort) && strpos($envHost, $envPort) === false) { - $envHost = $envHost . $envPort; - } - $link = (G::is_https() || $envProtocol ? 'https://' : 'http://') . $envHost . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . $envSkin . '/services/ActionsByEmail'; + + $link = System::getServerMainPath() . '/services/ActionsByEmail'; switch ($configuration['ABE_TYPE']) { case 'CUSTOM': diff --git a/workflow/engine/classes/JavaBridgePM.php b/workflow/engine/classes/JavaBridgePM.php index ca64882ce..ea3d8ffc4 100644 --- a/workflow/engine/classes/JavaBridgePM.php +++ b/workflow/engine/classes/JavaBridgePM.php @@ -1,5 +1,7 @@ assign( 'heightDetail', count( $xmlFields ) * 15 + 20 ); $template->assign( 'PAGE_NUMBER', '{PAGE_NUMBER}' ); - $logoReporte = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/images/processmaker.logo.jpg'; + $logoReporte = System::getServerProtocolHost() . '/images/processmaker.logo.jpg'; $template->assign( 'logoReporte', $logoReporte ); foreach ($xmlFields as $key => $val) { diff --git a/workflow/engine/classes/ProcessMap.php b/workflow/engine/classes/ProcessMap.php index 3993b7822..d6df7fc35 100644 --- a/workflow/engine/classes/ProcessMap.php +++ b/workflow/engine/classes/ProcessMap.php @@ -1,5 +1,6 @@ load($task_uid); $task_name = $task->getTasTitle(); - if (G::is_https()) { - $http = 'https://'; - } else { - $http = 'http://'; - } - - $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sProcessUID . '/'; + $link = System::getServerMainPath() . '/' . $sProcessUID . '/'; $row = array(); $c = 0; - /* - $oTask = new Task ( ); - $TaskFields = $oTask->kgetassigType ( $sProcessUID , $tas=''); - */ $TaskFields['TAS_ASSIGN_TYPE'] = ''; - //$row [] = array ('W_TITLE' => '', 'W_DELETE' => '', 'TAS_ASSIGN_TYPE' => $TaskFields ['TAS_ASSIGN_TYPE'] ); - if (is_dir(PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . "public" . PATH_SEP . $sProcessUID)) { $dir = opendir(PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . "public" . PATH_SEP . $sProcessUID); $dynTitle = str_replace(' ', '_', str_replace('/', '_', $dynTitle)); $arlink = $link . $dynTitle . '.php'; - //$arlink = "" . $alink . ""; } } } $row = array('W_LINK' => $arlink, 'DYN_TITLE' => $dynTitle, 'TAS_TITLE' => $task_name, 'USR_UID' => $usr_uid_evn, 'DYN_UID' => $dynUid ); - // $oJSON = new Services_JSON ( ); - // $tmpData = $oJSON->encode( $row ) ; - // $tmpData = str_replace("\\/","/",'{success:true,data:'.$tmpData.'}'); // unescape the slashes - // $result = $tmpData; + $result = array(); $result['success'] = true; $result['data'] = $row; diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php index 52b10c612..d526e22b1 100644 --- a/workflow/engine/classes/WsBase.php +++ b/workflow/engine/classes/WsBase.php @@ -2487,7 +2487,7 @@ class WsBase $arrayUserData = $user->load($userId); if (trim($arrayUserData["USR_EMAIL"]) == "") { - $arrayUserData["USR_EMAIL"] = "info@" . $_SERVER["HTTP_HOST"]; + $arrayUserData["USR_EMAIL"] = "info@" . System::getDefaultMailDomain(); } $sFromName = "\"" . $arrayUserData["USR_FIRSTNAME"] . " " . $arrayUserData["USR_LASTNAME"] . "\" <" . $arrayUserData["USR_EMAIL"] . ">"; diff --git a/workflow/engine/classes/model/OutputDocument.php b/workflow/engine/classes/model/OutputDocument.php index 2b3283ae8..37da4fbf9 100644 --- a/workflow/engine/classes/model/OutputDocument.php +++ b/workflow/engine/classes/model/OutputDocument.php @@ -1,16 +1,7 @@ process((G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media); + $status = $pipeline->process(System::getServerProtocolHost() . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media); copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); diff --git a/workflow/engine/controllers/InstallerModule.php b/workflow/engine/controllers/InstallerModule.php index 51e3c2181..4da55e86d 100644 --- a/workflow/engine/controllers/InstallerModule.php +++ b/workflow/engine/controllers/InstallerModule.php @@ -555,7 +555,7 @@ class InstallerModule extends Controller public function forceTogenerateTranslationsFiles($url) { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, G::browserCacheFilesUrl((G::is_https() ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . "/js/ext/translation.en.js?r=" . rand(1, 10000))); + curl_setopt($ch, CURLOPT_URL, G::browserCacheFilesUrl(System::getServerProtocolHost() . "/js/ext/translation.en.js?r=" . rand(1, 10000))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); diff --git a/workflow/engine/controllers/caseSchedulerProxy.php b/workflow/engine/controllers/caseSchedulerProxy.php index 428a007ae..1ddc31c12 100644 --- a/workflow/engine/controllers/caseSchedulerProxy.php +++ b/workflow/engine/controllers/caseSchedulerProxy.php @@ -1,5 +1,6 @@ WS_USER ); $sWS_PASS = trim( $params->WS_PASS ); - if (G::is_https()) { - $http = 'https://'; - } else { - $http = 'http://'; - } - $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; + $endpoint = System::getServerMainPath() . '/services/wsdl2'; @$client = new SoapClient( $endpoint ); $user = $sWS_USER; diff --git a/workflow/engine/controllers/webEntryProxy.php b/workflow/engine/controllers/webEntryProxy.php index 20ea01856..fc6b40ed0 100644 --- a/workflow/engine/controllers/webEntryProxy.php +++ b/workflow/engine/controllers/webEntryProxy.php @@ -40,13 +40,7 @@ class webEntryProxy extends HttpProxyController $sWS_USER = trim( $params->WS_USER ); $sWS_PASS = trim( $params->WS_PASS ); - if (G::is_https()) { - $http = 'https://'; - } else { - $http = 'http://'; - } - - $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; + $endpoint = System::getServerMainPath() . '/services/wsdl2'; @$client = new SoapClient( $endpoint ); $user = $sWS_USER; @@ -137,12 +131,6 @@ class webEntryProxy extends HttpProxyController $oTask->load( $sTASKS ); $tas_title = $oTask->getTasTitle(); - if (G::is_https()) { - $http = 'https://'; - } else { - $http = 'http://'; - } - $sContent = ''; $SITE_PUBLIC_PATH = ''; if (file_exists( $SITE_PUBLIC_PATH . '' )) { @@ -167,8 +155,8 @@ class webEntryProxy extends HttpProxyController $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; $template = new TemplatePower( $pluginTpl ); $template->prepare(); - $template->assign( 'wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2' ); - $template->assign( 'wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload' ); + $template->assign( 'wsdlUrl', System::getServerMainPath() . '/services/wsdl2'); + $template->assign( 'wsUploadUrl', System::getServerMainPath() . '/services/upload'); $template->assign( 'processUid', $sPRO_UID ); $template->assign( 'dynaformUid', $sDYNAFORM ); $template->assign( 'taskUid', $sTASKS ); @@ -218,7 +206,7 @@ class webEntryProxy extends HttpProxyController $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update( $aDataEvent ); - $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; + $link = System::getServerMainPath() . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; $this->success = true; $this->msg = G::LoadTranslation( 'ID_WEB_ENTRY_SUCCESS_NEW' ); diff --git a/workflow/engine/methods/cases/cases_SchedulerValidateUser.php b/workflow/engine/methods/cases/cases_SchedulerValidateUser.php index 3edaa6f64..00f351c63 100644 --- a/workflow/engine/methods/cases/cases_SchedulerValidateUser.php +++ b/workflow/engine/methods/cases/cases_SchedulerValidateUser.php @@ -1,46 +1,16 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ -/** - * process_SchedulerValidate_User - * validates if the username and password are valid data and if the user assigned - * to the process and task has the rights and persmissions required to create a cron task - */ +use ProcessMaker\Core\System; $sWS_USER = trim( $_REQUEST['USERNAME'] ); $sWS_PASS = trim( $_REQUEST['PASSWORD'] ); $streamContext = []; - if (G::is_https()) { - $http = 'https://'; $streamContext = ['stream_context' => stream_context_create(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true]])]; -} else { - $http = 'http://'; } -$endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; +$endpoint = System::getServerMainPath() . '/services/wsdl2'; $client = new SoapClient($endpoint, $streamContext); $user = $sWS_USER; diff --git a/workflow/engine/methods/login/authentication.php b/workflow/engine/methods/login/authentication.php index 6ab0d36f8..b466e5e15 100644 --- a/workflow/engine/methods/login/authentication.php +++ b/workflow/engine/methods/login/authentication.php @@ -267,7 +267,7 @@ try { $aLog['LOG_SID'] = session_id(); $aLog['LOG_INIT_DATE'] = date('Y-m-d H:i:s'); //$aLog['LOG_END_DATE'] = '0000-00-00 00:00:00'; - $aLog['LOG_CLIENT_HOSTNAME']= $_SERVER['HTTP_HOST']; + $aLog['LOG_CLIENT_HOSTNAME']= System::getServerHost(); $aLog['USR_UID'] = $_SESSION['USER_LOGGED']; $weblog->create($aLog); /**end log**/ diff --git a/workflow/engine/methods/processes/processes_webEntryGenerate.php b/workflow/engine/methods/processes/processes_webEntryGenerate.php index 7bce76c1b..1bad65979 100644 --- a/workflow/engine/methods/processes/processes_webEntryGenerate.php +++ b/workflow/engine/methods/processes/processes_webEntryGenerate.php @@ -32,7 +32,6 @@ try { throw (new Exception( G::LoadTranslation('ID_TASK') . "'" . $TaskFields['TAS_TITLE'] . "'" . G::LoadTranslation('ID_NOT_HAVE_USERS'))); } - $http = (G::is_https())? "https://" : "http://"; $sContent = ''; $infoProcess = new Process(); @@ -68,8 +67,8 @@ try { $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl'; $template = new TemplatePower( $pluginTpl ); $template->prepare(); - $template->assign( 'wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2' ); - $template->assign( 'wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload' ); + $template->assign( 'wsdlUrl', System::getServerMainPath() . '/services/wsdl2' ); + $template->assign( 'wsUploadUrl', System::getServerMainPath() . '/services/upload' ); $template->assign( 'processUid', $sPRO_UID ); $template->assign( 'dynaformUid', $sDYNAFORM ); $template->assign( 'taskUid', $sTASKS ); @@ -134,18 +133,18 @@ try { $aDataEvent['EVN_CONDITIONS'] = $sWS_USER; $output = $oEvent->update( $aDataEvent ); //Show link - $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; + $link = System::getServerMainPath() . '/' . $sPRO_UID . '/' . $dynTitle . '.php'; print $link; //print "\n $link "; } else { $G_FORM = new Form( $sPRO_UID . '/' . $sDYNAFORM, PATH_DYNAFORM, SYS_LANG, false ); - $G_FORM->action = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/cases_StartExternal.php'; + $G_FORM->action = System::getServerMainPath() . '/services/cases_StartExternal.php'; $scriptCode = ''; $scriptCode = $G_FORM->render( PATH_CORE . 'templates/' . 'xmlform' . '.html', $scriptCode ); - $scriptCode = str_replace( '/controls/', $http . $_SERVER['HTTP_HOST'] . '/controls/', $scriptCode ); - $scriptCode = str_replace( '/js/maborak/core/images/', $http . $_SERVER['HTTP_HOST'] . '/js/maborak/core/images/', $scriptCode ); + $scriptCode = str_replace( '/controls/', System::getServerProtocolHost() . '/controls/', $scriptCode ); + $scriptCode = str_replace( '/js/maborak/core/images/', System::getServerProtocolHost() . '/js/maborak/core/images/', $scriptCode ); //render the template $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentry.tpl'; @@ -157,7 +156,7 @@ try { $template->assign("URL_MABORAK_JS", G::browserCacheFilesUrl("/js/maborak/core/maborak.js")); $template->assign("URL_TRANSLATION_ENV_JS", G::browserCacheFilesUrl("/jscore/labels/" . SYS_LANG . ".js")); - $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]); + $template->assign("siteUrl", System::getServerProtocolHost()); $template->assign("sysSys", config("system.workspace")); $template->assign("sysLang", SYS_LANG); $template->assign("sysSkin", SYS_SKIN); @@ -171,7 +170,7 @@ try { if (sizeof( $sUidGrids ) > 0) { foreach ($sUidGrids as $k => $v) { $template->newBlock( 'grid_uids' ); - $template->assign( 'siteUrl', $http . $_SERVER['HTTP_HOST'] ); + $template->assign( 'siteUrl', System::getServerProtocolHost() ); $template->assign( 'gridFileName', $sPRO_UID . '/' . $v ); } } diff --git a/workflow/engine/methods/processes/processes_webEntryValidate.php b/workflow/engine/methods/processes/processes_webEntryValidate.php index 5f8df8d22..c80a25151 100644 --- a/workflow/engine/methods/processes/processes_webEntryValidate.php +++ b/workflow/engine/methods/processes/processes_webEntryValidate.php @@ -1,9 +1,6 @@ PRO_UID; $sTASKS = $oData->TASKS; @@ -16,20 +13,12 @@ $sWS_PASS = trim( $oData->WS_PASS ); $sWS_ROUNDROBIN = $oData->WS_ROUNDROBIN; $sWE_USR = $oData->WE_USR; -//echo ($sPRO_UID."
"); -//echo ($sTASKS."
"); -//echo ($sDYNAFORM."
"); - $streamContext = []; - if (G::is_https()) { - $http = 'https://'; $streamContext = ['stream_context' => stream_context_create(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true]])]; //lsl -} else { - $http = 'http://'; } -$endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; +$endpoint = System::getServerMainPath() . '/services/wsdl2'; $client = new SoapClient( $endpoint, $streamContext ); $user = $sWS_USER; diff --git a/workflow/engine/methods/processes/webEntry_Val_Assig.php b/workflow/engine/methods/processes/webEntry_Val_Assig.php index c1b0ec0ea..e1cce4d7c 100644 --- a/workflow/engine/methods/processes/webEntry_Val_Assig.php +++ b/workflow/engine/methods/processes/webEntry_Val_Assig.php @@ -1,28 +1,19 @@ PRO_UID; $sTASKS = $oData->TASKS; $sDYNAFORM = $oData->DYNAFORM; -if (G::is_https()) - $http = 'https://'; -else - $http = 'http://'; - -$endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; -@$client = new SoapClient( $endpoint ); +$endpoint = System::getServerMainPath() . '/services/wsdl2'; +@$client = new SoapClient($endpoint); $oTask = new Task(); -$TaskFields = $oTask->kgetassigType( $sPRO_UID, $sTASKS ); +$TaskFields = $oTask->kgetassigType($sPRO_UID, $sTASKS); -if ($TaskFields['TAS_ASSIGN_TYPE'] == 'BALANCED') +if ($TaskFields['TAS_ASSIGN_TYPE'] == 'BALANCED') { echo 1; -else +} else { echo 0; - -?> +} diff --git a/workflow/engine/methods/setup/webServicesSetup.php b/workflow/engine/methods/setup/webServicesSetup.php index fc6b05036..c274b20f6 100644 --- a/workflow/engine/methods/setup/webServicesSetup.php +++ b/workflow/engine/methods/setup/webServicesSetup.php @@ -1,26 +1,7 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - */ + +use ProcessMaker\Core\System; + if (($RBAC_Response = $RBAC->userCanAccess( "PM_FACTORY" )) != 1) return $RBAC_Response; @@ -28,7 +9,7 @@ $dbc = new DBConnection(); $ses = new DBSession( $dbc ); if (! isset( $_SESSION['END_POINT'] )) { - $aFields['WS_HOST'] = $_SERVER['HTTP_HOST']; + $aFields['WS_HOST'] = System::getServerHost(); $aFields['WS_WORKSPACE'] = config("system.workspace"); } else { if (strpos( $_SESSION['END_POINT'], 'https' ) !== false) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index 48f7d44fd..ee9750850 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -1,6 +1,7 @@ process((\G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $sApplication . '/outdocs/' . $sFilename . '.html', $g_media); + $status = $pipeline->process(System::getServerProtocolHost() . '/files/' . $sApplication . '/outdocs/' . $sFilename . '.html', $g_media); copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf'); unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf'); unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html'); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php index 0c191b9ed..1208dfc45 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php @@ -1,7 +1,9 @@ $username, diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index f5e3f721d..e14c8a2c2 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -42,7 +42,7 @@ class WebEntry public function __construct() { $this->pathDataPublic = defined("PATH_DATA_PUBLIC") ? PATH_DATA_PUBLIC : \G::$pathDataPublic; - $this->httpHost = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : \G::$httpHost; + $this->httpHost = System::getServerHost(); $this->sysSys = !empty(config("system.workspace")) ? config("system.workspace") : \G::$sysSys; $this->sysSkin = defined("SYS_SKIN") ? SYS_SKIN : \G::$sysSkin; try { @@ -848,9 +848,7 @@ class WebEntry { try { if ((!isset($record['WE_LINK_GENERATION']) || $record['WE_LINK_GENERATION']==='DEFAULT') && $record["WE_METHOD"] == "WS") { - $http = (\G::is_https())? "https://" : "http://"; - $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . config("system.workspace") . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $record["PRO_UID"]; - + $url = System::getServerMainPath() . "/" . $record["PRO_UID"]; $record["WE_DATA"] = $url . "/" . $record["WE_DATA"]; } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php index 713bf91d1..c1cad3653 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryEvent.php @@ -2,30 +2,30 @@ namespace ProcessMaker\BusinessModel; -use WebEntryEventPeer; -use ProcessPeer; +use BasePeer; +use BpmnFlowPeer; +use Content; use Criteria; -use WebEntryPeer; use Exception; use G; -use BpmnFlowPeer; use ProcessMaker\BusinessModel\Process as BusinessModelProcess; use ProcessMaker\BusinessModel\Validator as BusinessModelValidator; +use ProcessMaker\Core\System; use ProcessMaker\Project\Workflow; -use WebEntryEvent as ModelWebEntryEvent; use ProcessMaker\Util\Common; -use Task as ModelTask; +use ProcessPeer; use Propel; -use BasePeer; -use Content; -use Tasks; -use Step; -use TaskPeer; -use StepPeer; use ResultSet; +use Step; +use StepPeer; +use Task as ModelTask; +use TaskPeer; +use Tasks; use TaskUser; use TaskUserPeer; - +use WebEntryEvent as ModelWebEntryEvent; +use WebEntryEventPeer; +use WebEntryPeer; class WebEntryEvent { @@ -1394,8 +1394,7 @@ class WebEntryEvent return $url . "/" . $weData; } else { - $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . config("system.workspace") . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $prj_uid; - + $url = System::getServerMainPath() . "/" . $prj_uid; return $url . "/" . $weData; } } diff --git a/workflow/engine/src/ProcessMaker/Core/System.php b/workflow/engine/src/ProcessMaker/Core/System.php index 1a5f7aea3..bc8f011ab 100644 --- a/workflow/engine/src/ProcessMaker/Core/System.php +++ b/workflow/engine/src/ProcessMaker/Core/System.php @@ -1321,7 +1321,7 @@ class System $serverProtocol = ($serverProtocol != '') ? $serverProtocol : ((G::is_https()) ? 'https' : 'http'); $serverHostname = $arraySystemConfiguration['server_hostname_requests_frontend']; - $serverHostname = ($serverHostname != '') ? $serverHostname : $_SERVER['HTTP_HOST']; + $serverHostname = ($serverHostname != '') ? $serverHostname : System::getServerHost(); //Return return $serverProtocol . '://' . $serverHostname; @@ -1523,5 +1523,93 @@ class System config(['connections.report.username' => $dbReportUser]); config(['connections.report.password' => $dbReportPass]); } + + /** + * Get current server protocol. + * + * @return string + */ + public static function getServerProtocol() + { + return G::is_https() ? "https://" : "http://"; + } + + /** + * Get current server host + * + * @return string + */ + public static function getServerHostname() + { + $host = ""; + if (!empty($_SERVER['SERVER_NAME'])) { + $host = $_SERVER['SERVER_NAME']; + } else if (defined('SERVER_NAME')) { + $host = SERVER_NAME; + } + return $host; + } + + /** + * Get current server port. + * + * @return string + */ + public static function getServerPort() + { + $port = ""; + if (isset($_SERVER['SERVER_PORT'])) { + $port = $_SERVER['SERVER_PORT']; + } else if (defined('SERVER_PORT')) { + $port = SERVER_PORT; + } + return $port; + } + + /** + * Get current host (hostname + port). + * + * @return string + */ + public static function getServerHost() + { + $port = self::getServerPort(); + if (!empty($port) && $port != '80') { + $port = ':' . $port; + } + return self::getServerHostname() . $port; + } + + /** + * Get current server protocol and host. + * + * @return string + */ + public static function getServerProtocolHost() + { + return self::getServerProtocol() . self::getServerHost(); + } + + /** + * Get server main path (protocol + host + port + workspace + lang + skin). + * + * @return string + */ + public static function getServerMainPath() + { + $conf = new Configurations(); + $skin = defined("SYS_SKIN") ? SYS_SKIN : $conf->getConfiguration('SKIN_CRON', ''); + return self::getServerProtocolHost() . '/sys' . config("system.workspace") . '/' . SYS_LANG . '/' . $skin; + } + + /** + * Get default domain mail. + * + * @return string + */ + public static function getDefaultMailDomain() + { + return !empty(self::getServerHostname()) ? self::getServerHostname() : 'processmaker.com'; + } } // end System class diff --git a/workflow/engine/templates/setup/webServicesTree.php b/workflow/engine/templates/setup/webServicesTree.php index 064e4b5da..9a02ea909 100644 --- a/workflow/engine/templates/setup/webServicesTree.php +++ b/workflow/engine/templates/setup/webServicesTree.php @@ -1,27 +1,6 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ + +use ProcessMaker\Core\System; $wsSessionId = ''; if (isset ($_SESSION ['WS_SESSION_ID'])) { @@ -38,7 +17,7 @@ if (isset ($_GET ['x'])) { } } else { if (!isset ($_SESSION ['END_POINT'])) { - $wsdl = 'http://' . $_SERVER ['HTTP_HOST']; + $wsdl = System::getServerProtocolHost(); $workspace = config("system.workspace"); } else { $wsdl = $_SESSION ['END_POINT'];