/** * Writes $auditName with $auditAttributes as content * to file name that will be fetched from ini settings by auditNameSettings() for logging. * * @param string $auditName * @param array $auditAttributes * @return bool */ static function writeAudit($auditName, $auditAttributes = array()) { $enabled = eZAudit::isAuditEnabled(); if (!$enabled) { return false; } $auditNameSettings = eZAudit::auditNameSettings(); if (!isset($auditNameSettings[$auditName])) { return false; } $ip = eZSys::clientIP(); if (!$ip) { $ip = eZSys::serverVariable('HOSTNAME', true); } $user = eZUser::currentUser(); $userID = $user->attribute('contentobject_id'); $userLogin = $user->attribute('login'); $message = "[{$ip}] [{$userLogin}:{$userID}]\n"; foreach (array_keys($auditAttributes) as $attributeKey) { $attributeValue = $auditAttributes[$attributeKey]; $message .= "{$attributeKey}: {$attributeValue}\n"; } $logName = $auditNameSettings[$auditName]['file_name']; $dir = $auditNameSettings[$auditName]['dir']; eZLog::write($message, $logName, $dir); return true; }
/** * @param int $objectID ContentObjectID */ public function __construct($objectID) { $userID = eZUser::currentUserID(); $message = ezpI18n::tr('design/standard/error/kernel', 'Access denied') . '. ' . ezpI18n::tr('design/standard/error/kernel', 'You do not have permission to access this area.'); eZLog::write("Access denied to content object #{$objectID} for user #{$userID}", 'error.log'); parent::__construct($message); }
/** * Generic method for logging a message * * @param string $msg * @param bool $bPrintMsg * @param string $logType */ public static function logMessage($msg, $bPrintMsg = true, $logType = self::NOTICELOG) { switch ($logType) { case self::ERRORLOG: $logFile = self::ERRORLOG_FILE; if ($bPrintMsg) { self::writeError($msg); } break; case self::WARNINGLOG: $logFile = self::WARNINGLOG_FILE; if ($bPrintMsg) { self::writeWarning($msg); } break; case self::NOTICELOG: default: $logFile = self::NOTICELOG_FILE; if ($bPrintMsg) { self::writeNotice($msg); } break; } eZLog::write($msg, $logFile); }
public static function write_invalid_checkcreditcard_log($order_id, $response = array("errorcode" => "unknown", "errormessage" => "unknown")) { $http = eZHTTPTool::instance(); //set fallbacks for direct ajax request if (!isset($order_id) or is_array($order_id) and count($order_id) == 0) { $order_id = $http->postVariable('order_id'); } if (!isset($response) or is_array($response) and count($response) == 0) { $response = $http->postVariable('response'); } eZLog::write("FAILED in step 1 ('checkcreditcard') for order ID " . $order_id . " with ERRORCODE " . $response["errorcode"] . " Message: " . $response["errormessage"], $logName = 'xrowpayone.log', $dir = 'var/log'); }
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement) { switch ($operatorName) { case 'hashcreate': $algorithm = $namedParameters['algorithm']; $hash_array = $namedParameters['hash_array']; $key = $namedParameters['key']; $operatorValue = xrowPayoneHelper::generate_hash($algorithm, $hash_array, $key); break; case 'payone_info_by_order': $order = $namedParameters['order']; $payone_info = array(); if ($order instanceof eZOrder) { $doc = new DOMDocument('1.0', 'utf-8'); $doc->loadXML($order->DataText1); //try to fetch txid $txid_element = $doc->getElementsByTagName('txid'); if ($txid_element->length >= 1) { $payone_info["txid"] = (string) $txid_element->item(0)->nodeValue; } //try to fetch txid $truncatedcardpan_element = $doc->getElementsByTagName('truncatedcardpan'); if ($txid_element->length >= 1) { $payone_info["truncatedcardpan"] = (string) $truncatedcardpan_element->item(0)->nodeValue; } //try to fetch userid $userid_element = $doc->getElementsByTagName('userid'); if ($userid_element->length >= 1) { $payone_info["userid"] = (string) $userid_element->item(0)->nodeValue; } //try to fetch 3d secure payment status $cc3d_reserved_element = $doc->getElementsByTagName('cc3d_reserved'); if ($cc3d_reserved_element->length >= 1) { $payone_info["cc3d_reserved"] = (string) $cc3d_reserved_element->item(0)->nodeValue; } //try to fetch the paymentgateway $paymentmethod_element = $doc->getElementsByTagName('paymentmethod'); if ($paymentmethod_element->length >= 1) { $payone_info["paymentmethod"] = (string) $paymentmethod_element->item(0)->nodeValue; } } else { eZLog::write("\$order is not an instance of eZOrder in extension/xrowpayone/autoloads/xrowpayoneoperator.php", $logName = 'xrowpayone.log', $dir = 'var/log'); } if (count($payone_info) == 0) { $operatorValue = false; } else { $operatorValue = $payone_info; } break; } }
public function generateCustomErrorString($order, $response) { $payoneINI = eZINI::instance('xrowpayone.ini'); $custom_error_node_id = $payoneINI->variable('GeneralSettings', 'CustomErrorNode'); $error_fallback = $payoneINI->variable('GeneralSettings', 'CustomErrorFallback'); $error_fallback = ezpI18n::tr('extension/xrowpayone', $error_fallback); if ($custom_error_node_id !== "disabled") { if (is_numeric($custom_error_node_id)) { $custom_error_node = eZContentObjectTreeNode::fetch($custom_error_node_id); if (isset($custom_error_node) and $custom_error_node instanceof eZContentObjectTreeNode) { $error_code = $response["errorcode"]; $data_map = $custom_error_node->dataMap(); $matrix_identifier = $payoneINI->variable('GeneralSettings', 'CustomErrorNodeMatrixIdentifier'); if (isset($data_map[$matrix_identifier])) { $matrix_attribute_content = $data_map[$matrix_identifier]->content(); $matrix_data = $matrix_attribute_content->Matrix; $matrix_rows = $matrix_data["rows"]; $matrix_rows = $matrix_rows["sequential"]; foreach ($matrix_rows as $row) { //now map the error code to the matrix code if ($row["columns"]["0"] == $error_code) { $custom_errormessage = $row["columns"]["1"]; //return the translated code from object return $custom_errormessage; } } } else { eZLog::write("No attribute identifier named " . $matrix_identifier . " found. Please check your configuration 'xrowpayone.ini', GeneralSettings', 'CustomErrorNode'", $logName = 'xrowpayone.log', $dir = 'var/log'); } } else { eZLog::write("Could not fetch node from settings 'xrowpayone.ini', GeneralSettings', 'CustomErrorNode' please check your configuration", $logName = 'xrowpayone.log', $dir = 'var/log'); } } } //the worst fallback return $error_fallback; }
/** * Checks if the .generating file was changed, which would mean that generation * timed out. If not timed out, refreshes the timestamp so that storage won't * be stolen */ public function checkCacheGenerationTimeout() { clearstatcache(); // file_exists = false: another process stole the lock and finished the generation // filemtime != stored one: another process is generating the file if ( !file_exists( $this->filePath ) or ( @filemtime( $this->filePath ) != $this->generationStartTimestamp ) ) { eZDebugSetting::writeDebug( 'kernel-clustering', "'$this->filePath' was changed during generation, looks like a generation timeout", __METHOD__ ); eZLog::write( "Generation of '$this->filePath' timed out", 'cluster.log' ); return false; } else { $mtime = time(); touch( $this->filePath, $mtime, $mtime ); return true; } }
public static function exception($object, $exception, $section = false) { if (self::ERROR <= self::$level) { $msg = sprintf('[Exception] %s on line %s in %s', $exception->getMessage(), $exception->getLine(), $exception->getFile()); eZLog::write(self::parse($object, $msg, $section) . '\n' . $exception->getTraceAsString(), self::$logname); if (self::$cli) { self::$cli->error(self::parse($object, $msg, $section)); } MMSynchMonitor::inc(MMSynchMonitor::EXCEPTION); } self::startSection($section); }
/** * Starts cache generation for the current file. * * This is done by creating a file named by the original file name, prefixed * with '.generating'. * * @return bool false if the file is being generated, true if it is not **/ public function startCacheGeneration() { $generatingFilePath = $this->filePath . '.generating'; $ret = $this->backend->_startCacheGeneration($this->filePath, $generatingFilePath); // generation granted if ($ret['result'] == 'ok') { $this->realFilePath = $this->filePath; $this->filePath = $generatingFilePath; $this->generationStartTimestamp = $ret['mtime']; return true; } elseif ($ret['result'] == 'ko') { return $ret['remaining']; } else { eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log'); return false; } }
/** * Writes a file log (severity below warning) * @param string $message Message to log * @param string $severity Severity of the log message */ protected static function fileLog($message, $severity) { if (!empty(self::$file)) { $messages = explode("\n", $message); foreach ($messages as $index => $m) { $messages[$index] = 'F : ' . self::$file . ' - P : ' . self::$publisher . " | $m"; } } else return; $index = array_search($severity, self::$severities); if ($index >= self::$reportLevel) { foreach ($messages as $message) { eZLog::write($message, self::$prefixLog . "$severity.log"); } } }
/** * Creates a profile * * @return array */ public function create() { if( SolrSafeOperatorHelper::featureIsActive( 'RegistrationSettings' ) && SolrSafeOperatorHelper::feature( 'RegistrationSettings', 'DisableRegistration' ) == true ) { return array( 'data' => array( 'errorCode'=> 9 ) ); } // 1st step - Checks fields $r = $this->checkUsername(); if ( $r !== true ) { return $r; } $r = $this->checkEmail(); if ( $r !== true ) { return $r; } $isHtmlEntitiesAlowed = self::isAddressEncodeAllowedOnCluster(); // 2nd step - Process fields $addressLine1 = $this->getBusinessNameMapping( 'addressLine1' ); if ( isset( $_POST[$addressLine1] ) && !empty( $_POST[$addressLine1] ) && $isHtmlEntitiesAlowed ) { $_POST[$addressLine1] = htmlentities( $_POST[$addressLine1], ENT_QUOTES, 'UTF-8' ); } $addressLine2 = $this->getBusinessNameMapping( 'addressLine2' ); if ( isset( $_POST[$addressLine2] ) && !empty( $_POST[$addressLine2] ) && $isHtmlEntitiesAlowed ) { $_POST[$addressLine2] = htmlentities( $_POST[$addressLine2], ENT_QUOTES, 'UTF-8' ); } /* @type $createParams array */ $params = array(); $createParams = SolrSafeOperatorHelper::clusterIni('EsbSettings', 'CreateParamsTypes', 'merck.ini' ); foreach ( $createParams as $key => $value ) { if ( isset( $_POST[$key] ) ) { $params[$key] = ( trim( $value ) == 'int' ) ? intval( $_POST[$key] ) : $_POST[$key]; } } $actId = $this->getBusinessNameMapping( 'actId' ); if ( isset( $_REQUEST[$actId] ) ) { $params[$actId] = $_REQUEST[$actId]; } if ( $this instanceof ServiceUserUUMP ) { $params['privacyPolicyDate'] = date('Ymdhis'); } // managing validation status cases // 1. Override taken from cluster settings. $defaultValidationStatus = SolrSafeOperatorHelper::clusterIni('DefaultValidationStatus', 'DefaultValidationStatus', 'merck.ini' ); $defaultValidationStatus = !empty( $defaultValidationStatus ) && isset( $defaultValidationStatus ) ? $defaultValidationStatus : 'PV' ; if( $this instanceof ServiceUserUUMP && !empty( $defaultValidationStatus ) && isset( $defaultValidationStatus ) ) { $params['validationStatus'] = $defaultValidationStatus; } // 2. Russian helpdesk-register validates user by default. if( isset( $_POST['register-helpdesk']) && $_POST['register-helpdesk'] == 1 && !isset( $_POST['termsOfUse'] )) { $params['validationStatus'] = 'VP'; $params['termsOfUse'] = isset( $_POST['helpdeskTermsOfUse']) ? 1 : 0; $params['privacyPolicy'] = isset( $_POST['helpdeskPrivacyPolicy']) ? 1 : 0; } // 3. German "kontakt" validation result. if ( $this instanceof ServiceUserUUMP && isset( $params['WEB_SERVICE_AJAX_FIELD_1'] ) ) { if( $params['WEB_SERVICE_AJAX_FIELD_1'] == "kontakt" ) { $params['validationStatus'] = 'PV'; } unset( $params['WEB_SERVICE_AJAX_FIELD_1'] ); } // 4. German "DocCheck" validation result. if ( $this instanceof ServiceUserUUMP && ( isset( $params['DocCheck_username'] ) && $params['DocCheck_username'] != "" ) && ( isset( $params['Password_doccheck'] ) && $params['Password_doccheck'] != "" ) ) { $params['validationStatus'] = 'VP'; unset( $params['DocCheck_username'] ); unset( $params['Password_doccheck'] ); } // 5. US 1.8 if user is validated by eshcp we have crmMemberId field stored, so we also must validate user with VP if ( SolrSafeOperatorHelper::featureIsActive( "Univadis18Redesign" ) && isset($params['crmMemberId']) && $params['crmMemberId'] != "" ) { $params['validationStatus'] = 'VP'; } // 3rd step - ESB Create $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_language' ); if( !is_null( $sl ) ) { $language = $sl; } else { $language = eZINI::instance( 'site.ini' )->variable( 'RegionalSettings', 'ContentObjectLocale' ); $merckIni = eZINI::instance( 'merck.ini' ); if ( $merckIni->hasVariable( 'EsbSettings', 'Language' ) ) { $language = $merckIni->variable( 'EsbSettings', 'Language' ); } } $apps = array(); $appsIds = CountryAppsBar::fetchAppsBarApplicationIds( $_POST[$this->getBusinessNameMapping( 'customerType' )] ); foreach ( $appsIds as $key => $value ) { $apps[] = array( $this->getBusinessNameMapping( 'appId' ) => $value, $this->getBusinessNameMapping( 'appOrder' ) => $key + 1 ); } $subsUni = $this->getUnivadisSubscriptions(); $subsMsd = $this->getMsdSubscriptions(); $subsSun = $this->getSunshineAct(); $consents = array_merge( $subsUni, $subsMsd ); if(!empty($subsSun)) { $consents = array_merge( $consents, $subsSun ); } if( $createParams[self::SUBSCRIPTION_PHONE_CONSENT] ) { $consents[] = array( 'consentCode' => self::SUBSCRIPTION_PHONE_CONSENT, 'consentStatus' => !empty( $_POST[self::SUBSCRIPTION_PHONE_CONSENT] ) ? self::SUBSCRIPTION_STATUS_SUBSCRIBED : self::SUBSCRIPTION_STATUS_UNSUBSCRIBED, 'consentLastUpdate' => time(), ); unset( $params[self::SUBSCRIPTION_PHONE_CONSENT] ); } // Add terms of use, private policies and OptIn consents if ( SolrSafeOperatorHelper::featureIsActive( 'ToUPPPopin' ) && ( $this instanceof ServiceUserUUMP ) ) { $touVersion = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentToUConsentVersion' ); $ppVersion = SolrSafeOperatorHelper::feature( 'ToUPPPopin', 'currentPPConsentVersion' ); $consents[] = array( 'consentCode' => 'termsOfUse_v' . $touVersion, 'consentStatus' => 'S', 'consentLastUpdate' => time(), ); $consents[] = array( 'consentCode' => 'privacyPolicy_v' . $ppVersion, 'consentStatus' => 'S', 'consentLastUpdate' => time() ); $subsOptIn = $this->getOptInSubscriptions(); if ( !empty( $subsOptIn ) ) { $consents = array_merge( $consents, $subsOptIn ); } } $username = $this->getUsername(); $userSpecialty = $_POST[$this->getBusinessNameMapping( 'userSpecialty' )]; $mainSpecialty = UserSpecialityContentSpeciality::getContentSpeciality( $userSpecialty ); $unifiedParameters = array( $this->getBusinessNameMapping( 'emailAddress' ) => $_POST[$this->getBusinessNameMapping( 'emailAddress' )], $this->getBusinessNameMapping( 'password' ) => $_POST[$this->getBusinessNameMapping( 'password' )], $this->getBusinessNameMapping( 'firstName' ) => $_POST[$this->getBusinessNameMapping( 'firstName' )], $this->getBusinessNameMapping( 'lastName' ) => $_POST[$this->getBusinessNameMapping( 'lastName' )], $this->getBusinessNameMapping( 'language' ) => $language, $this->getBusinessNameMapping( 'userSpecialty' ) => $userSpecialty, $this->getBusinessNameMapping( 'customerType' ) => $_POST[$this->getBusinessNameMapping( 'customerType' )], $this->getBusinessNameMapping( 'apps' ) => $apps, $this->getBusinessNameMapping( 'consents' ) => $consents, $this->getBusinessNameMapping( 'additionalSpecialties' ) => MMUserLogin::getAddSpecialties( $mainSpecialty ), $this->getBusinessNameMapping( 'countryOfRegistration' ) => $this->getCountryOfRegistration(), $this->getBusinessNameMapping( 'countryOfResidence' ) => $_POST[$this->getBusinessNameMapping( 'countryOfResidence' )], ); if ( isset( $_POST[$this->getBusinessNameMapping( 'secondName' )] ) ) { $unifiedParameters[$this->getBusinessNameMapping( 'secondName' )] = $_POST[$this->getBusinessNameMapping( 'secondName' )]; } if ( !is_null($username)) $unifiedParameters[$this->getBusinessNameMapping( 'userName' )] = $username; if ( $this instanceof ServiceUserUUMP ) { $parameters = array( 'data' => array( 'profile' => $unifiedParameters ) ); $formatDate = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'FormatDate', 'merck.ini' ); $availableDateParams = SolrSafeOperatorHelper::clusterIni('EsbDateConvert', 'AvailableDateParams', 'merck.ini' ); $skipParametersIfEmptyValue = SolrSafeOperatorHelper::clusterIni('SkipParametersIfEmptyValue', 'SkipParameter', 'merck.ini' ); foreach ( $params as $key => $value ) { if ( array_key_exists( $key, $parameters['data']['profile'] ) ) { unset( $params[$key] ); } if( !empty( $availableDateParams ) && isset( $availableDateParams[$key] ) && !empty($value) ) { $params[$key] = $this->convertDateforUUMP( $value, $formatDate ); } if( !empty( $skipParametersIfEmptyValue ) && isset( $skipParametersIfEmptyValue[$key] ) && empty($value) ) { unset( $params[$key] ); } } $parameters['data']['profile'] = array_merge( $parameters['data']['profile'], $params ); $sl = SystemLocale::fetchByClusterAndSystem( ClusterTool::clusterIdentifier(), 'esb_locale' ); if ( !is_null( $sl ) ) { $parameters['data']['profile']['locale'] = $sl; } } else { $parameters = array( 'Data' => array_merge( $unifiedParameters, array( 'Params' => $params ) ), 'cr' => $this->getCountryOfRegistration() ); } //LOG for locale field UUMP #36428 if ( $this instanceof ServiceUserUUMP ) { if( empty( $parameters['data']['profile']['locale'] ) ) { $errorLocalMsg = "\n\nEMPTY LOCALE:\nVALUES: " . json_encode( $parameters ); \eZLog::write( $errorLocalMsg, 'esb_uump_locale.log'); } } $result = $this->callWSHandler( $this->getEsbInterface( 'create' ), $parameters ); if( SolrSafeOperatorHelper::featureIsActive('RegistrationAutologin') && SolrSafeOperatorHelper::feature('RegistrationAutologin', 'DisallowPendingUsers') == true && !isset( $_POST['register-helpdesk'] )) { if( $result['data']['profile']['validationStatus'] == 'PV' ) { $result['RedirectPending'] = true; $result['RedirectPendingHref'] = eZINI::instance( 'site.ini' )->variable( 'SiteSettings', 'PendingUserStaticPage' ); return $result; } } // if the registration was successful, we need to log the user on eZ + Backend side too if ( $this instanceof ServiceUserUUMP ) { $noErrorOnCreate = ( isset( $result['data']['errorCode'] ) && $result['data']['errorCode'] == 0 ); } else { $noErrorOnCreate = ( isset( $result['Data']['ErrorCode'] ) && $result['Data']['ErrorCode'] == 0 ); } if ( $noErrorOnCreate ) { $allowRedirect = false; $availableRedirectContext = SolrSafeOperatorHelper::feature( 'RegistrationSettings', 'AvailableContextList' ); $context = $_POST['context'] != '' ? $_POST['context'] : null; if ( $context !== null && !empty( $availableRedirectContext ) ) { if ( is_array( $availableRedirectContext ) && in_array( $context, $availableRedirectContext ) ) { $allowRedirect = true; } } // BUT only there is no pending validation needed // OR if we are on that local validation page if ( ( !SolrSafeOperatorHelper::featureIsActive( 'OverrideWSHandler' ) || self::verifyHash() ) && !isset( $_POST['register-helpdesk'] )) { if ( $this instanceof ServiceUserUUMP ) { $userName = isset( $result['data']['profile']['userName'] ) ? $result['data']['profile']['userName'] : null; $userId = $result['data']['profile']['userId']; $userSpecialty = isset( $result['data']['profile']['userSpecialty'] ) ? preg_replace('#^A#', '', $result['data']['profile']['userSpecialty']) : null; } else { $readValues = $this->read( array( "User_specialty" ), $result['Data']['Username'] ); $parameters = $parameters['Data']['Params']; $userName = isset( $result['Data']['Username'] ) ? $result['Data']['Username'] : null; $userSpecialty = isset( $readValues['Data']['Params']['User_specialty'] ) ? $readValues['Data']['Params']['User_specialty'] : null; } $businessNames = $this->getBusinessNamesForTicket(); $ticketParams = array(); foreach ( $businessNames as $ticketParam => $businessName ) { if ( isset( $parameters['data']['profile'][$businessName] ) ) { $ticketParams[$ticketParam] = $parameters['data']['profile'][$businessName]; } elseif ( isset( $_POST[$businessName] ) ) { $ticketParams[$ticketParam] = $_POST[$businessName]; } elseif ( $businessName == $this->getBusinessNameMapping( 'countryOfRegistration' ) ) { $ticketParams[$ticketParam] = $this->getCountryOfRegistration(); } else { eZDebug::writeError( 'Could not get registration param: ' . $businessName ); } } if( $this instanceof ServiceUserUUMP ) { $ticketParams['Username'] = $userId; } elseif ( !empty($userName) ) { $ticketParams['Username'] = $userName; } if ( !empty($userSpecialty) ) { $ticketParams['User_specialty'] = $userSpecialty; } // used in response to log to the php backend $result['AllowRedirect'] = $allowRedirect; $ticketParams['toUValidated'] = true; MMUserLogin::loginUser( $ticketParams ); $mmUser = MMUsers::getCurrentUserObject(); $ticketParams['mmSettings'] = $mmUser->getMMSettings(); $ticketParams['unorderedAppList'] = $mmUser->getApplicationList(); $ticketParams['alterboxMsgReset'] = $mmUser->hasPreference('alterboxMsgReset') ? $mmUser->getPreferences('alterboxMsgReset') : true; $result['Ticket'] = MMUserLogin::encryptText( json_encode( $ticketParams ) ); } } // Consult Popin for France | mobile check disabled - it fails on STG if (/* ContextTool::instance()->isMobile() && */ in_array(ClusterTool::clusterIdentifier(), array('cluster_france'))) { CookieTool::destroyCookie('displayConsultMobile'); CookieTool::destroyCookie('displayConsultMobile', '/', null); CookieTool::setCookie('displayConsultMobile', $mmUser->getConsult(), time() + ( 2 * 24 * 60 * 60 )); } if( isset( $_POST['register-helpdesk'] )) { $result['helpdeskRegister'] = '1'; } return $result; }
/** * @param string $type * @param string $uumpId * @param bool|string $email * @param bool|string $url * @throws Exception */ protected function callLyris($type, $uumpId, $email = false, $url = false) { $serviceUrl = self::buildUrl($type, $uumpId, $url); eZLog::write("Email for URL: {$email}", 'resetpass.log'); eZLog::write("Service URL: {$url}", 'resetpass.log'); $response = eZHTTPTool::getDataByURL($serviceUrl); eZLog::write("EMAILSERVICE URL: {$serviceUrl}", 'esb_uump.log'); eZLog::write("EMAILSERVICE RESPONSE:\n" . $response, 'esb_uump.log'); eZLog::write("EMAILSERVICE URL: {$serviceUrl}", 'resetpass.log'); eZLog::write("EMAILSERVICE RESPONSE:\n" . $response, 'resetpass.log'); }
/** * Starts cache generation for the current file. * * This is done by creating a file named by the original file name, prefixed * with '.generating'. * * @return bool false if the file is being generated, true if it is not */ public function startCacheGeneration() { eZDebugSetting::writeDebug('kernel-clustering', "Starting cache generation", "dfs::startCacheGeneration( '{$this->filePath}' )"); $generatingFilePath = $this->filePath . '.generating'; try { $ret = self::$dbbackend->_startCacheGeneration($this->filePath, $generatingFilePath); } catch (RuntimeException $e) { eZDebug::writeError($e->getMessage()); return false; } // generation granted if ($ret['result'] == 'ok') { eZClusterFileHandler::addGeneratingFile($this); $this->realFilePath = $this->filePath; $this->filePath = $generatingFilePath; $this->generationStartTimestamp = $ret['mtime']; return true; } elseif ($ret['result'] == 'ko') { return $ret['remaining']; } else { eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log'); return false; } }
/** * @desc Add the new translation found in the existing file of translation * @author David LE RICHE <*****@*****.**> * @params string $file => the file where the translation is adding * @return bool * @copyright 2012 * @version 1.1 */ public function addTranslationIfNotExist($file) { $tsFile = new DOMDocument(); $tsFile->load($file); $xpath = new DOMXpath($tsFile); $ts = $tsFile->documentElement; foreach ($this->tabKey as $sourceName => $tabElement) { foreach ($tabElement as $element) { $query = "//context[name=" . (strpos($sourceName, "'") === false ? "'{$sourceName}'" : "\"{$sourceName}\"") . "]/message[source=" . (strpos($element, "'") === false ? "'{$element}'" : "\"{$element}\"") . "]"; try { if ($xpath->query($query) && !$xpath->query($query)->item(0)) { $querySourceName = "//context[name=" . (strpos($sourceName, "'") === false ? "'{$sourceName}'" : "\"{$sourceName}\"") . "]"; //create context if not exists if (!$xpath->query($querySourceName)->item(0)) { $context = $tsFile->createElement('context'); $ts->appendChild($context); $name = $tsFile->createELement('name', $sourceName); $context->appendChild($name); } else { $context = $xpath->query($querySourceName)->item(0); } $message = $tsFile->createElement('message'); $context->appendChild($message); $source = $tsFile->createElement('source', htmlspecialchars($element)); $message->appendChild($source); $translation = $tsFile->createElement('translation'); $message->appendChild($translation); } } catch (Exception $e) { eZLog::write($e, 'owtranslate.log'); } } } try { if ($unlinkFile = unlink($file)) { $saveXml = $tsFile->save($file, LIBXML_NOEMPTYTAG); } } catch (exception $e) { echo $e; } return $saveXml; }
/** * Runs the defined error module * Sets the state of the module object to \c failed and sets the error code. * * @param mixed $errorCode * @param mixed $errorType * @param array $parameters * @param mixed $userParameters * * @see setErrorModule(), errorModule() */ function handleError( $errorCode, $errorType = false, $parameters = array(), $userParameters = false ) { if ( !$errorType ) { eZDebug::writeWarning( "No error type specified for error code $errorCode, assuming kernel.\nA specific error type should be supplied, please check your code.", __METHOD__ ); $errorType = 'kernel'; } $errorModule = $this->errorModule(); $module = eZModule::findModule( $errorModule['module'], $this ); if ( $module === null ) { return false; } if ( $errorCode == eZError::KERNEL_ACCESS_DENIED ) { eZLog::setMaxLogSize( 10 * 1024 * 1024 ); eZLog::write("Request : " . var_export($_REQUEST, true), 'access_denied.log'); eZLog::write('Server : ' . var_export($_SERVER, true), 'access_denied.log'); eZLog::write("Env : " . var_export($_ENV, true), 'access_denied.log'); } elseif ( $errorCode == eZError::KERNEL_MODULE_NOT_FOUND ) { eZLog::setMaxLogSize( 10 * 1024 * 1024 ); eZLog::write("Request : " . var_export($_REQUEST, true), 'module_not_found.log'); eZLog::write('Server : ' . var_export($_SERVER, true), 'module_not_found.log'); eZLog::write("Env : " . var_export($_ENV, true), 'module_not_found.log'); } $result = $module->run( $errorModule['view'], array( $errorType, $errorCode, $parameters, $userParameters ) ); // The error module may want to redirect to another URL, see error.ini if ( $this->exitStatus() != eZModule::STATUS_REDIRECT and $this->exitStatus() != eZModule::STATUS_RERUN ) { $this->setExitStatus( eZModule::STATUS_FAILED ); $this->setErrorCode( $errorCode ); } return $result; }
/** * @return string */ private function setToken() { $token = array(); $staticDir = StaticData::directory(); $outputFile = $staticDir.'/'.$this->tokenFileName; if( file_exists( $outputFile ) ) { $token = json_decode( file_get_contents($outputFile), true ); } if( !file_exists( $outputFile ) || !isset($token['expiresIn']) || !isset($token['accessToken']) || ($token['expiresIn'] < time()) ) { if( file_exists( $outputFile ) ) { unlink($outputFile); } $requestData = array( "clientId" => $this->clientId, "clientSecret" => $this->clientSecret ); $query = http_build_query( $requestData ); $smsApiUrl = "{$this->tokenRequestUrl}?{$query}"; eZLog::write( "Sending request to: {$smsApiUrl}", 'sms.log' ); $curl = curl_init($this->tokenRequestUrl); curl_setopt_array($curl, array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $requestData, CURLOPT_RETURNTRANSFER => true, ) ); $token = curl_exec( $curl ); if( $token && isset($token['accessToken']) ) { $logMessage = 'Recieved SMS Service responses: ' . var_export($token, true); eZLog::write( $logMessage, 'sms.log' ); $token = json_decode($token, TRUE); $token['expiresIn'] += time() + 300; curl_close( $curl ); file_put_contents($outputFile, json_encode($token)); $this->smsToken = $token['accessToken']; return true; } else { $logMessage = 'Error - Problem with recieved SMS Service responses: ' . var_export($token, true); eZLog::write( $logMessage, 'sms.log' ); return false; } } $this->smsToken = $token['accessToken']; return true; }
<?php if ( MMUsers::getCurrentUserObject() ) { $service = ESBFactory::getUserService(); $user = $service->form(); if ( $user && $user['data']['errorCode'] == 0 && !is_null($user['data']['profile']['userId']) ){ $dt = new DateTime("Europe/Warsaw"); $url = isset($_POST['url']) ? $_POST['url'] : ''; $logMsg = array( 'uuid' => $user['data']['profile']['userId'], 'time' => $dt->format('Y-m-d H:i:s'), 'siteurl' => $url, ); eZLog::write(json_encode($logMsg), 'gtm.log'); } } ?>
} } } else { $sendingMail = false; // if the comments are not made by one subscriber, send mail foreach ($commentList as $comment) { if ($comment->attribute('email') != $subscriber->attribute('email')) { $sendingMail = true; break; } } if ($sendingMail) { $notificationManager->sendNotificationInOne($subscriber, $contentObject); if (!$isQuiet) { $cli->output('Email sent to ' . $subscriber->attribute('email')); } } } } } catch (Exception $ex) { $message = 'Sending notification error! Exception:' . $ex->getMessage() . '\\n'; eZLog::write($message, 'ezcomments.log'); if (!$isQuiet) { $cli->output($message); } } $db->query('DELETE FROM ezcomment_notification' . ' WHERE status = 1 AND' . ' contentobject_id = ' . $contentObjectID . ' AND language_id =' . $contentLanguage); } if (!$isQuiet) { $cli->output("Notification sending is finished."); }
<?php $Module =& $Params['Module']; $order_id = $Params["orderID"]; if (isset($order_id)) { eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card password ACCEPTED :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log'); //create the payment gateway - not the best position but at least it works here :) $payment = xrowPaymentObject::createNew((int) $order_id, xrowPayoneCreditCardGateway::GATEWAY_STRING); $payment->store(); //store paymentobject and approve it (required to finish the order) $paymentObj = xrowPaymentObject::fetchByOrderID($order_id); $paymentObj->approve(); eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card password REDIRECTING to orderview :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log'); //redirect into the shopping process => finishing the order! $Module->redirectTo('/shop/checkout/'); } else { return $Module->handleError(1, 'kernel'); } $Result = array();
public function write($message) { eZLog::write($message, $this->logFile, $this->logDir); }
/** * Installs the default Exception handler * * @params Exception the exception * @return void */ static public function defaultExceptionHandler( Exception $e ) { if( PHP_SAPI != 'cli' ) { header( 'HTTP/1.x 500 Internal Server Error' ); header( 'Content-Type: text/html' ); echo "An unexpected error has occurred. Please contact the webmaster.<br />"; if( eZDebug::isDebugEnabled() ) { echo $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine(); } } else { $cli = eZCLI::instance(); $cli->error( "An unexpected error has occurred. Please contact the webmaster."); if( eZDebug::isDebugEnabled() ) { $cli->error( $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() ); } } eZLog::write( 'Unexpected error, the message was : ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine(), 'error.log' ); eZExecution::cleanup(); eZExecution::setCleanExit(); exit( 1 ); }
public function monitor($text) { if ($this->opt == true) { eZLog::write("mem [{$text}]: " . memory_get_usage(), self::LOG_FILE); } }
function execute($process, $event) { $http = eZHTTPTool::instance(); $siteINI = eZINI::instance('site.ini'); $shopINI = eZINI::instance('shop.ini'); $payoneINI = eZINI::instance('xrowpayone.ini'); $processParams = $process->attribute('parameter_list'); $errors = array(); $process_id = $process->ID; //get the current order $order_id = $processParams['order_id']; $order = eZOrder::fetch($order_id); //checking if its only a redirect and so the preauthorisation is already finished $paymentObj = xrowPaymentObject::fetchByOrderID($order_id); if (is_object($paymentObj) && $paymentObj->approved()) { //now disapprove again because its 3d CC payment and its only paid when capture is successful $paymentObj->reject(); xrowPayoneCreditCardGateway::setPaymentMethod($order); eZLog::write("SUCCESS in step 2 ('preauthorisation') ::3D Secure Card detected - FINISHED :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log'); return eZWorkflowType::STATUS_ACCEPTED; } //STEP 2: preauthorisation if ($http->hasPostVariable('pseudocardpan')) { //fetching settings $pseudocardpan = $http->postVariable('pseudocardpan'); $site_url = $siteINI->variable('SiteSettings', 'SiteURL'); $aid = $payoneINI->variable('GeneralSettings', 'AID'); $mid = $payoneINI->variable('GeneralSettings', 'MID'); $portal_id = $payoneINI->variable('GeneralSettings', 'PortalID'); $mode = $payoneINI->variable('GeneralSettings', 'Mode'); $key = $payoneINI->variable('GeneralSettings', 'Key'); $algorithm = $payoneINI->variable('GeneralSettings', 'Algorithm'); $api_version = $payoneINI->variable('GeneralSettings', 'APIVersion'); $response_type = $payoneINI->variable('GeneralSettings', 'ResponseType'); $cc_3d_secure_enabled = $payoneINI->variable('CC3DSecure', 'Enabled'); $error_url = $payoneINI->variable('CC3DSecure', 'ErrorURL'); $success_url = $payoneINI->variable('CC3DSecure', 'SuccessURL'); $siteaccess = $GLOBALS['eZCurrentAccess']; $siteaccess = $siteaccess["name"]; //prepare some parameter values $error_url = "https://" . $site_url . "/" . $siteaccess . "/" . $error_url . "/orderID/" . $order_id; $success_url = "https://" . $site_url . "/" . $siteaccess . "/" . $success_url . "/orderID/" . $order_id; $order_total_in_cent = (string) $order->totalIncVAT() * 100; $currency_code = $order->currencyCode(); $order_xml = simplexml_load_string($order->DataText1); $country_alpha3 = (string) $order_xml->country; $country = eZCountryType::fetchCountry($country_alpha3, "Alpha3"); $country_alpha2 = $country["Alpha2"]; $last_name = (string) $order_xml->last_name; //create hash array $hash_array["aid"] = $aid; $hash_array["mid"] = $mid; $hash_array["portalid"] = $portal_id; $hash_array["api_version"] = $api_version; $hash_array["mode"] = $mode; $hash_array["request"] = "preauthorization"; $hash_array["responsetype"] = $response_type; $hash_array["clearingtype"] = "cc"; $hash_array["reference"] = $order_id; $hash_array["amount"] = $order_total_in_cent; $hash_array["currency"] = $currency_code; if ($cc_3d_secure_enabled == "true") { $hash_array["successurl"] = $success_url; $hash_array["errorurl"] = $error_url; } //please note: country, lastname and pseudocardpan are not needed to be added to the hash because they are not allwoed (p.25 client doc) //create param array $param_array["aid"] = $aid; $param_array["mid"] = $mid; $param_array["portalid"] = $portal_id; $param_array["api_version"] = $api_version; $param_array["mode"] = $mode; $param_array["request"] = "preauthorization"; $param_array["responsetype"] = $response_type; $param_array["hash"] = xrowPayoneHelper::generate_hash($algorithm, $hash_array, $key); $param_array["clearingtype"] = "cc"; $param_array["reference"] = $order_id; $param_array["amount"] = $order_total_in_cent; $param_array["currency"] = $currency_code; $param_array["lastname"] = urlencode($last_name); $param_array["country"] = $country_alpha2; $param_array["pseudocardpan"] = $pseudocardpan; if ($cc_3d_secure_enabled == "true") { $param_array["successurl"] = $success_url; $param_array["errorurl"] = $error_url; } //sort params in alphabetic order ksort($param_array); $parameter_string = "?"; foreach ($param_array as $key => $parameter) { $parameter_string .= $key . "=" . $parameter . "&"; } $url = "https://secure.pay1.de/client-api" . $parameter_string; if ($siteINI->hasVariable('ProxySettings', 'ProxyServer') && $siteINI->variable('ProxySettings', 'ProxyServer') != "") { $proxyserver = $siteINI->variable('ProxySettings', 'ProxyServer'); //now get the proxy url if (strpos($proxyserver, "://") !== false) { $proxy_parts = explode("://", $proxyserver); $proxyserver = $proxy_parts[1]; } $context_array = array('http' => array('method' => 'GET', 'proxy' => $proxyserver)); $context = stream_context_create($context_array); $json_response = file_get_contents($url, false, $context); } else { $json_response = file_get_contents($url); } if ($json_response) { $json_response = json_decode($json_response); if ($json_response->status != "ERROR" and isset($json_response->txid)) { //get 'txid' from response and keep it $txid = $json_response->txid; //get 'userid' from response and keep it $userid = $json_response->userid; //now store it into the order $db = eZDB::instance(); $db->begin(); $doc = new DOMDocument('1.0', 'utf-8'); $doc->loadXML($order->DataText1); $shop_account_element = $doc->getElementsByTagName('shop_account'); $shop_account_element = $shop_account_element->item(0); //handle and store the TXID //remove first if exists $txid_elements = $doc->getElementsByTagName('txid'); if ($txid_elements->length >= 1) { $txid_element = $txid_elements->item(0); $txid_element->parentNode->removeChild($txid_element); } //then create $txidNode = $doc->createElement("txid", $txid); $shop_account_element->appendChild($txidNode); //handle and store the userid //remove first if exists $userid_elements = $doc->getElementsByTagName('userid'); if ($userid_elements->length >= 1) { $userid_element = $userid_elements->item(0); $userid_element->parentNode->removeChild($userid_element); } //then create $useridNode = $doc->createElement("userid", $userid); $shop_account_element->appendChild($useridNode); //handle and store the pseudocardpan if ($http->hasPostVariable('truncatedcardpan')) { //remove first if exists $tpan_elements = $doc->getElementsByTagName('truncatedcardpan'); if ($tpan_elements->length >= 1) { $tpan_element = $tpan_elements->item(0); $tpan_element->parentNode->removeChild($tpan_element); } //then create $truncatedcardpan_node = $doc->createElement("truncatedcardpan", $http->postVariable('truncatedcardpan')); $shop_account_element->appendChild($truncatedcardpan_node); } if ($json_response->status === "REDIRECT") { //remove first if exists $cc3d_sec_elements = $doc->getElementsByTagName('cc3d_reserved'); if ($cc3d_sec_elements->length >= 1) { $cc3d_sec_element = $cc3d_sec_elements->item(0); $cc3d_sec_element->parentNode->removeChild($cc3d_sec_element); } //save reserved flag false for now $reservedFlag = $doc->createElement("cc3d_reserved", "false"); $shop_account_element->appendChild($reservedFlag); } else { //remove cc3d_reserved if exists. this case could occure if someone changed from 3d CC to normal CC. $cc3d_sec_elements = $doc->getElementsByTagName('cc3d_reserved'); if ($cc3d_sec_elements->length >= 1) { $cc3d_sec_element = $cc3d_sec_elements->item(0); $cc3d_sec_element->parentNode->removeChild($cc3d_sec_element); } } //i must store here redundant otherwise the order will not be stored since its stuck in a transaction $db->commit(); //store it $order->setAttribute('data_text_1', $doc->saveXML()); $order->store(); $db->commit(); if ($json_response->status === "REDIRECT") { eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card detected - REDIRECTING to creditcard institute check :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log'); //do redirect to 3d secure password confirm page http_redirect($json_response->redirecturl); exit; } else { xrowPayoneCreditCardGateway::setPaymentMethod($order); eZLog::write("SUCCESS in step 2 ('preauthorisation') for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log'); return eZWorkflowType::STATUS_ACCEPTED; } } else { eZLog::write("FAILED in step 2 ('preauthorisation') for order ID " . $order_id . " with ERRORCODE " . $json_response->errorcode . " Message: " . $json_response->errormessage, $logName = 'xrowpayone.log', $dir = 'var/log'); if ($payoneINI->variable('GeneralSettings', 'CustomErrorNode') === "disabled") { //use default error of payone $errors = array($json_response->customermessage); } else { //use customized errors $response["errorcode"] = $json_response->errorcode; $response["errormessage"] = $json_response->errormessage; $errors = array(xrowPayoneHelper::generateCustomErrorString($order, $response)); } } } else { eZLog::write("ERROR: Remote content not found in file " . __FILE__ . " on line " . __LINE__, $logName = 'xrowpayone.log', $dir = 'var/log'); } } else { if (is_object($paymentObj)) { //that means, that we have a paymentobject which is not approved. its not approved because the payment has failed so we return a array $errors = array(ezpI18n::tr('extension/xrowpayone', 'Error occured during payment process. Please choose your payment option again.')); $paymentObj->remove(); } } $process->Template = array(); $process->Template['templateName'] = xrowPayoneCreditCardGateway::TEMPLATE; $process->Template['path'] = array(array('url' => false, 'text' => ezpI18n::tr('extension/xrowpayone', 'Payment Information'))); $process->Template['templateVars'] = array('errors' => $errors, 'order' => $order, 'event' => $event); // return eZWorkflowType::STATUS_REJECTED; return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT; }
public function store() { if (!self::canStore()) { return; } $env = \eZINI::instance()->hasVariable('Environment', 'Type') ? \eZINI::instance()->variable( 'Environment', 'Type' ) : 'dev'; $data = $this->_logData; preg_replace('#\n#s', ' ', $data); $data['msg'] = '"' . addcslashes(preg_replace('#\n#s', ' ', $data['msg']), '"') . '"'; $out = implode(";", $data); if (in_array($env, array('prod', 'stg'))) { openlog('Sesame', LOG_PID, LOG_LOCAL1); syslog(LOG_INFO, $out); closelog(); } else { \eZLog::write($out, 'sesamelogin.log'); } }
/** * Log memory usage. * * @param string $text Text to use while logging. */ private function monitor($text) { if ($this->memoryMonitoring) { eZLog::write("mem [{$text}]: " . memory_get_usage(), $this->logFile); } }
$img_name = basename( $img ); $img_extension = strtolower( substr( strrchr( $img_name, "." ), 1 ) ); switch( $file_extension ) { case "gif": $img_type = "image/gif"; break; case "png": $img_type = "image/png"; break; case "jpeg": case "jpg": $img_type = "image/jpg"; break; default: $img_type = "image/jpg"; } $fp = fopen( $img, 'rb' ); header( 'Content-Type: ' . $img_type ); header( 'Content-Length: ' . filesize( $img ) ); fpassthru( $fp ); if( !file_exists( $img ) ) eZLog::write( "Image not found: $img", 'warning.log' ); eZExecution::cleanExit();
public function __construct($userID) { eZLog::write(__METHOD__ . " : Provided user #{$userID} was not found and could not be logged in", 'error.log'); parent::__construct('Provided user was not found'); }
/** * Starts cache generation for the current file. * * This is done by creating a file named by the original file name, prefixed * with '.generating'. * * @return bool false if the file is being generated, true if it is not */ public function startCacheGeneration() { $generatingFilePath = $this->filePath . '.generating'; $ret = self::$dbbackend->_startCacheGeneration( $this->filePath, $generatingFilePath ); // generation granted if ( $ret['result'] == 'ok' ) { eZClusterFileHandler::addGeneratingFile( $this ); $this->realFilePath = $this->filePath; $this->filePath = $generatingFilePath; $this->generationStartTimestamp = $ret['mtime']; return true; } // failure: the file is being generated elseif ( $ret['result'] == 'ko' ) { return $ret['remaining']; } // unhandled error case, should not happen else { eZLog::write( "An error occured starting cache generation on '$generatingFilePath'", 'cluster.log' ); return false; } }
* @subpackage content */ /** * This script, given a queued contentobject_id + version, will resume the publishing operation on it * @package kernel * @subpackage content */ require 'autoload.php'; $pid = getmypid(); $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => 'Asynchronous publishing handler, not meant to be used directly', 'use-session' => false, 'use-modules' => true, 'use-extensions' => true)); $script->startup(); $argumentConfig = '[OBJECT_ID] [VERSION_ID]'; $optionsConfig = ''; $options = $script->getOptions($optionsConfig, $argumentConfig); $script->initialize(); if (count($options['arguments']) != 2) { eZLog::write("Wrong arguments count", 'publishqueue.log'); $script->shutdown(1, 'wrong argument count'); } $objectId = $options['arguments'][0]; $version = $options['arguments'][1]; eZLog::write("[{$pid}] Publishing #{$objectId}/{$version}", 'async.log'); $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $objectId, 'version' => $version)); if (isset($operationResult['status']) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) { eZLog::write("[{$pid}] Published #{$objectId}/{$version}", 'async.log'); $script->shutdown(0); } else { eZLog::write("[{$pid}] Operation result for #{$objectId}/{$version}: " . print_r($operationResult, true), 'async.log'); $script->shutdown(2, 'Publishing did not complete'); }
protected function tl() { $eventName = isset( $_POST['eventName'] ) ? $_POST['eventName'] : null ; $time = isset( $_POST['time'] ) ? $_POST['time'] : null ; if ( $time ) { $newRelicApi = new \klpNrApi(); $logMsg = "eventName: Custom/SLA/global time: ".var_export($time, true); eZLog::write($logMsg, 'poc.log'); $newRelicApi->setCustomMetric( 'Custom/SLA/global', $time ); if ( $eventName ) { $logMsg = "eventName: ".var_export($eventName, true)." time: ".var_export($time, true); eZLog::write($logMsg, 'poc.log'); $newRelicApi->setCustomMetric( 'Custom/SLA/'.$eventName, $time ); } return true; } return false; }