예제 #1
0
 /**
  * Perform actual mapping
  * 
  * @return mixed
  */
 protected function performMap()
 {
     $response = json_decode($this->inputData->body);
     $result = null;
     if (isset($response->error)) {
         \XLite\Logger::logCustom("PitneyBowes", 'ConfirmOrder: ' . $response->error . ' - ' . $response->message, false);
     } else {
         $result = $response;
     }
     return $result;
 }
예제 #2
0
 /**
  * Perform actual mapping
  * 
  * @return mixed
  */
 protected function performMap()
 {
     $response = json_decode($this->inputData->body);
     $result = null;
     if (isset($response->error)) {
         \XLite\Logger::logCustom("PitneyBowes", 'CreateInboundParcels: ' . $response->error . ' - ' . $response->message, false);
     } elseif (isset($response->parcelIdentifiers) && is_array($response->parcelIdentifiers)) {
         $result = $response->parcelIdentifiers;
     } elseif (isset($response->parcelIdentifier)) {
         $result = array($response);
     }
     return $result;
 }
예제 #3
0
 /**
  * Perform actual mapping
  * 
  * @return mixed
  */
 protected function performMap()
 {
     $response = json_decode($this->inputData->body);
     $orders = array();
     $rates = array();
     if (isset($response->error)) {
         \XLite\Logger::logCustom("PitneyBowes", 'CreateOrder: ' . $response->error . ' - ' . $response->message, false);
     } elseif (isset($response->order) && is_array($response->order)) {
         foreach ($response->order as $quote) {
             $orders[] = $quote;
             $rates[] = $this->mapSingleQuote($quote->order);
         }
     }
     return array('orders' => array_filter($orders), 'rates' => array_filter($rates));
 }
예제 #4
0
파일: USPS.php 프로젝트: kewaunited/xcart
 /**
  * Performs request to USPS server and returns array of rates
  *
  * @param array   $data        Array of request parameters
  * @param boolean $ignoreCache Flag: if true then do not get rates from cache
  *
  * @return array
  */
 protected function doQuery($data, $ignoreCache)
 {
     $result = null;
     $rates = array();
     $availableMethods = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findMethodsByProcessor($this->getProcessorId());
     if ($availableMethods) {
         $xmlData = $this->getXMLData($data);
         $currencyRate = doubleval(\XLite\Core\Config::getInstance()->CDev->USPS->currency_rate);
         $currencyRate = 0 < $currencyRate ? $currencyRate : 1;
         $postURL = $this->getApiURL() . '?API=' . $this->getApiName() . '&XML=' . urlencode(preg_replace('/>(\\s+)</', '><', $xmlData));
         try {
             if (!$ignoreCache) {
                 $cachedRate = $this->getDataFromCache($postURL);
             }
             if (isset($cachedRate)) {
                 // Get rates from cache
                 $result = $cachedRate;
             } elseif (\XLite\Model\Shipping::isIgnoreLongCalculations()) {
                 // Ignore rates calculation
                 return array();
             } else {
                 // Calculate rate
                 $bouncer = new \XLite\Core\HTTP\Request($postURL);
                 $bouncer->requestTimeout = 5;
                 $response = $bouncer->sendRequest();
                 if ($response && 200 == $response->code) {
                     $result = $response->body;
                     $this->saveDataInCache($postURL, $result);
                     if (\XLite\Core\Config::getInstance()->CDev->USPS->debug_enabled) {
                         \XLite\Logger::logCustom('USPS', var_export(array('Request URL' => $postURL, 'Request XML' => $xmlData, 'Response' => \XLite\Core\XML::getInstance()->getFormattedXML($result)), true));
                     }
                 } else {
                     $this->errorMsg = sprintf('Error while connecting to the USPS host (%s)', $this->getApiURL());
                 }
             }
             $response = isset($this->errorMsg) ? array() : $this->parseResponse($result);
             $this->apiCommunicationLog[] = array('request' => $postURL, 'xml' => htmlentities(preg_replace('/(USERID=")([^"]+)/', '\\1***', $xmlData)), 'response' => htmlentities(\XLite\Core\XML::getInstance()->getFormattedXML($result)));
             if (!isset($this->errorMsg) && !isset($response['err_msg']) && !empty($response['postage'])) {
                 foreach ($response['postage'] as $postage) {
                     $rate = new \XLite\Model\Shipping\Rate();
                     $method = $this->getShippingMethod($postage['CLASSID'], $availableMethods);
                     if (!isset($method)) {
                         // Unknown method received: add this to the database with disabled status
                         $method = $this->addShippingMethod($postage);
                     }
                     if ($method && $method->getEnabled()) {
                         // Method is registered and enabled
                         $rate->setMethod($method);
                         $codPrice = 0;
                         $rateValue = doubleval($postage['Rate']);
                         if (!$this->isStaticCODPrice() && isset($postage['SpecialServices'])) {
                             if (isset($postage['SpecialServices'][6]) && 'true' == $postage['SpecialServices'][6]['Available']) {
                                 // Shipping service supports COD
                                 $extraData = new \XLite\Core\CommonCell();
                                 $extraData->cod_supported = true;
                                 $extraData->cod_rate = ($rateValue + doubleval($postage['SpecialServices'][6]['Price'])) * $currencyRate;
                                 $rate->setExtraData($extraData);
                                 if ($data['cod_enabled']) {
                                     // Calculate COD fee if COD payment method is selected
                                     $codPrice = doubleval($postage['SpecialServices'][6]['Price']);
                                 }
                             }
                         } elseif ($this->isStaticCODPrice() && $this->isMethodSupportCOD($method)) {
                             $codStaticPrice = doubleval(\XLite\Core\Config::getInstance()->CDev->USPS->cod_price);
                             if (0 < $codStaticPrice) {
                                 // Shipping service supports COD
                                 $extraData = new \XLite\Core\CommonCell();
                                 $extraData->cod_supported = true;
                                 $extraData->cod_rate = ($rateValue + $codStaticPrice) * $currencyRate;
                                 $rate->setExtraData($extraData);
                                 if ($data['cod_enabled']) {
                                     // Calculate COD fee if COD payment method is selected
                                     $codPrice = $codStaticPrice;
                                 }
                             }
                         }
                         // Base rate is a sum of base rate and COD fee
                         $rate->setBaseRate(($rateValue + $codPrice) * $currencyRate);
                         if (isset($rates[$postage['MailService']])) {
                             // Multipackaging: sum base rate and COD fee for each rated packages
                             $rates[$postage['MailService']]->setBaseRate($rates[$postage['MailService']]->getBaseRate() + $rate->getBaseRate());
                             if ($rate->getExtraData()->cod_rate) {
                                 $extra = $rates[$postage['MailService']]->getExtraData();
                                 $extra->cod_rate = $extra->cod_rate + $rate->getExtraData()->cod_rate;
                                 $rates[$postage['MailService']]->setExtraData($extra);
                             }
                         } else {
                             $rates[$postage['MailService']] = $rate;
                         }
                     }
                 }
             } elseif (!isset($this->errorMsg)) {
                 $this->errorMsg = isset($response['err_msg']) ? $response['err_msg'] : 'Unknown error';
             }
         } catch (\Exception $e) {
             $this->errorMsg = 'Exception: ' . $e->getMessage();
         }
     }
     return $rates;
 }
예제 #5
0
파일: Main.php 프로젝트: kewaunited/xcart
 /**
  * Add record to the module log file
  *
  * @param string $message Text message OPTIONAL
  * @param mixed  $data    Data (can be any type) OPTIONAL
  *
  * @return void
  */
 public static function addLog($message = null, $data = null)
 {
     if ($message && $data) {
         $msg = array('message' => $message, 'data' => $data);
     } else {
         $msg = $message ?: ($data ?: null);
     }
     if (!is_string($msg)) {
         $msg = var_export($msg, true);
     }
     \XLite\Logger::logCustom(self::getModuleName(), $msg);
 }
예제 #6
0
 /**
  * Logging the data under Velocity
  * Available if developer_mode is on in the config file
  *
  * @param mixed $data
  *
  * @return void
  */
 protected static function log($data)
 {
     if (LC_DEVELOPER_MODE) {
         \XLite\Logger::logCustom('Velocity', $data);
     }
 }
예제 #7
0
 /**
  * Retrieve shipping adress from dstAddress
  * 
  * @return array
  */
 protected function getShippingAdressByDstAddressArray(array $dstAddress)
 {
     $state = null;
     if ($dstAddress['state'] && is_numeric($dstAddress['state'])) {
         $stateObject = \XLite\Core\Database::getRepo('XLite\\Model\\State')->find($dstAddress['state']);
         if ($stateObject) {
             $state = $stateObject->getCode();
         }
     } elseif ($dstAddress['custom_state']) {
         $state = $dstAddress['custom_state'];
     }
     if (!$state) {
         \XLite\Logger::logCustom("PitneyBowes", 'Problem with state', false);
     }
     return array('street1' => $dstAddress['address'] ?: '', 'city' => $dstAddress['city'], 'provinceOrState' => $state, 'country' => $dstAddress['country'], 'postalOrZipCode' => $dstAddress['zipcode']);
 }
예제 #8
0
 /**
  * Debug logging
  * 
  * @param mixed $message Message
  * @param mixed $message Message
  * 
  * @return void
  */
 public static function logDebug($message, $backtrace = false)
 {
     if (static::getProcessorConfiguration()->debug_enabled) {
         \XLite\Logger::logCustom('PitneyBowesDebug', $message, $backtrace);
     }
 }
예제 #9
0
 /**
  * Add log message
  *
  * @param boolean $status   Status
  * @param array   $request  Request data
  * @param array   $response Response data
  *
  * @return void
  */
 protected function logResponse($status, $request, $response)
 {
     $config = $this->getConfiguration();
     if ($config->debugMode) {
         \XLite\Logger::logCustom('AuctionInc', array('status' => $status, 'request' => $request, 'response' => $response));
     }
 }
예제 #10
0
파일: AMZ.php 프로젝트: kirkbauer2/kirkxc
 public static function func_amazon_pa_error($message)
 {
     \XLite\Logger::logCustom('amazon_pa', $message);
     return true;
 }
예제 #11
0
파일: UPS.php 프로젝트: kewaunited/xcart
 /**
  * doQuery
  *
  * @param mixed   $data        Can be either \XLite\Model\Order instance or an array
  * @param boolean $ignoreCache Flag: if true then do not get rates from cache
  *
  * @return void
  */
 protected function doQuery($data, $ignoreCache)
 {
     $rates = array();
     // Get all available rates
     $availableMethods = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findMethodsByProcessor($this->getProcessorId(), !$ignoreCache);
     if ($availableMethods) {
         // Do rates calculation if there are enabled shipping methods or calculation test is running
         $xmlData = $this->getXMLData($data);
         $postData = preg_split("/(\r\n|\r|\n)/", $xmlData, -1, PREG_SPLIT_NO_EMPTY);
         $postURL = $this->getApiURL();
         try {
             if (!$ignoreCache) {
                 $cachedRate = $this->getDataFromCache($xmlData);
             }
             if (isset($cachedRate)) {
                 $result = $cachedRate;
             } elseif (\XLite\Model\Shipping::isIgnoreLongCalculations()) {
                 // Ignore rates calculation
                 return array();
             } else {
                 // Prepare request XML for logging
                 $xmlDataLog = preg_replace('|<AccessLicenseNumber>.+</AccessLicenseNumber>|i', '<AccessLicenseNumber>xxx</AccessLicenseNumber>', $xmlData);
                 $xmlDataLog = preg_replace('|<UserId>.+</UserId>|i', '<UserId>xxx</UserId>', $xmlDataLog);
                 $xmlDataLog = preg_replace('|<Password>.+</Password>|i', '<Password>xxx</Password>', $xmlDataLog);
                 $xmlDataLog = preg_replace('|<ShipperNumber>.+</ShipperNumber>|i', '<ShipperNumber>xxx</ShipperNumber>', $xmlDataLog);
                 // Do request
                 $bouncer = new \XLite\Core\HTTP\Request($postURL . '/Rate');
                 $bouncer->body = $xmlData;
                 $bouncer->verb = 'POST';
                 $bouncer->requestTimeout = 5;
                 $response = $bouncer->sendRequest();
                 if (200 == $response->code || !empty($response->body)) {
                     $result = $response->body;
                     if (200 == $response->code) {
                         $this->saveDataInCache($xmlData, $result);
                     }
                     if (\XLite\Core\Config::getInstance()->XC->UPS->debug_enabled) {
                         \XLite\Logger::logCustom('UPS', var_export(array('Request URL' => $postURL, 'Request XML' => $xmlDataLog, 'Response XML' => \XLite\Core\XML::getInstance()->getFormattedXML($result)), true));
                     }
                 } else {
                     $this->errorMsg = sprintf('Error while connecting to the UPS server (%s)', $this->getApiURL());
                 }
             }
             if (!isset($this->errorMsg)) {
                 $response = $this->parseResponse($result);
             } else {
                 $response = array();
             }
             // Save communication log for test request only (ignoreCache is set for test requests only)
             if ($ignoreCache === true) {
                 $this->apiCommunicationLog[] = array('post URL' => $postURL, 'request' => htmlentities($xmlDataLog), 'response' => htmlentities(\XLite\Core\XML::getInstance()->getFormattedXML($result)));
             }
             if (!isset($this->errorMsg) && !isset($response['err_msg'])) {
                 foreach ($response as $row) {
                     $method = $this->getShippingMethod($row['serviceCode'], $data['srcAddress']['country'], $availableMethods);
                     if ($method) {
                         $rate = new \XLite\Model\Shipping\Rate();
                         $rate->setBaseRate($row['totalCharges']);
                         $rate->setMethod($method);
                         $extraData = null;
                         if (!empty($row['deliveryTime'])) {
                             $extraData = new \XLite\Core\CommonCell();
                             $extraData->deliveryDays = $row['deliveryTime'];
                             $rate->setExtraData($extraData);
                         }
                         if ($data['cod_enabled'] && $this->isCODAllowed('all', $data['srcAddress']['country'], $data['dstAddress']['country'])) {
                             $extraData = $extraData ?: new \XLite\Core\CommonCell();
                             $extraData->cod_supported = true;
                             $extraData->cod_rate = $rate->getBaseRate();
                             $rate->setExtraData($extraData);
                         }
                         $rates[] = $rate;
                     }
                 }
             } elseif (!isset($this->errorMsg)) {
                 $this->errorMsg = isset($response['err_msg']) ? $response['err_msg'] : 'Unknown error';
             }
         } catch (\Exception $e) {
             $this->errorMsg = 'Exception: ' . $e->getMessage();
         }
     }
     return $rates;
 }
예제 #12
0
파일: FEDEX.php 프로젝트: kewaunited/xcart
 /**
  * Parses response and returns an associative array
  *
  * @param string $stringData Response received from FedEx
  *
  * @return array
  */
 protected function parseResponse($stringData)
 {
     $result = array();
     $xml = \XLite\Core\XML::getInstance();
     $xmlParsed = $xml->parse($stringData, $err);
     if (isset($xmlParsed['soapenv:Envelope']['#']['soapenv:Body'][0]['#']['soapenv:Fault'][0]['#'])) {
         // FedEx responses with error of request validation
         $result['err_msg'] = $xml->getArrayByPath($xmlParsed, 'soapenv:Envelope/#/soapenv:Body/0/#/soapenv:Fault/0/#/faultstring/0/#');
     } else {
         $rateReply = $xml->getArrayByPath($xmlParsed, 'SOAP-ENV:Envelope/#/SOAP-ENV:Body/0/#/RateReply/0/#');
         $errorCodes = array('FAILURE', 'ERROR');
         if (in_array($xml->getArrayByPath($rateReply, 'HighestSeverity/0/#'), $errorCodes)) {
             // FedEx failed to return valid rates
             $result['err_msg'] = $xml->getArrayByPath($rateReply, 'Notifications/0/#/Message/0/#');
             $result['err_code'] = $xml->getArrayByPath($rateReply, 'Notifications/0/#/Code/0/#');
         } else {
             // Success
             $rateDetails = $xml->getArrayByPath($rateReply, 'RateReplyDetails');
             if (!empty($rateDetails) && is_array($rateDetails)) {
                 $conversionRate = $this->getCurrencyConversionRate();
                 foreach ($rateDetails as $rate) {
                     $serviceType = $xml->getArrayByPath($rate, '#/ServiceType/0/#');
                     $result[$serviceType]['amount'] = $this->getRateAmount($rate);
                     $variableHandlingCharge = $xml->getArrayByPath($rate, '#/RatedShipmentDetails/ShipmentRateDetail/TotalVariableHandlingCharges/VariableHandlingCharge/Amount/0/#');
                     $result[$serviceType]['amount'] += floatval($variableHandlingCharge);
                     if (1 != $conversionRate) {
                         $result[$serviceType]['amount'] *= $conversionRate;
                     }
                 }
             }
         }
     }
     // Log error
     if (isset($result['err_msg'])) {
         \XLite\Logger::logCustom('FEDEX', var_export(array('Error' => $result['err_msg'], 'Response' => \XLite\Core\XML::getInstance()->getFormattedXML($stringData)), true));
     }
     return $result;
 }
예제 #13
0
 /**
  * Do request to AustraliaPost API and receive response
  *
  * @param string  $type        Request type
  * @param array   $params      Array of parameters
  * @param boolean $ignoreCache Flag: ignore cache
  *
  * @return array|null
  */
 protected function doRequest($type, $params = array(), $ignoreCache = false)
 {
     $result = null;
     $requestType = $this->getApiRequestType($type);
     $methodName = 'getRequestData' . $type;
     if (method_exists($this, $methodName)) {
         // Call method to prepare request data
         $data = $this->{$methodName}($params);
     } else {
         $data = array();
     }
     // Validate request data
     if ($this->validateRequestData($requestType, $data)) {
         // Prepare post data
         $postData = array();
         foreach ($data as $key => $value) {
             if (in_array($key, array('option_code', 'suboption_code'))) {
                 foreach ($value as $opcode) {
                     $postData[] = sprintf('%s=%s', $key, $opcode);
                 }
             } else {
                 $postData[] = sprintf('%s=%s', $key, $value);
             }
         }
         $postURL = $this->getApiURL() . $requestType['uri'] . '.json?' . implode('&', $postData);
         if (!$ignoreCache) {
             // Try to get cached result
             $cachedRate = $this->getDataFromCache($postURL . $this->getApiKey());
         }
         if (isset($cachedRate)) {
             // Get result from cache
             $result = $cachedRate;
         } elseif (\XLite\Model\Shipping::isIgnoreLongCalculations()) {
             // Ignore rates calculation
             return array();
         } else {
             // Get result from AustraliaPost server
             try {
                 $headers = array('AUTH-KEY: ' . $this->getApiKey());
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $postURL);
                 curl_setopt($ch, CURLOPT_HEADER, false);
                 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 15);
                 if (\XLite\Core\Config::getInstance()->CDev->AustraliaPost->test_mode) {
                     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                 }
                 $response = curl_exec($ch);
                 if (!empty($response)) {
                     $result = json_decode($response, true);
                     if (!empty($result['error'])) {
                         $this->errorMsg = $result['error']['errorMessage'];
                     } else {
                         $this->saveDataInCache($postURL . $this->getApiKey(), $result);
                     }
                 } else {
                     $this->errorMsg = sprintf('Error while connecting to the AustraliaPost host (%s)', $postURL);
                 }
                 if ($ignoreCache === true) {
                     // Prepare data to display on Test AustraliaPost page
                     $this->apiCommunicationLog[] = array('request' => $postURL, 'response' => htmlentities($response), 'parsed' => $result);
                 }
                 if (\XLite\Core\Config::getInstance()->CDev->AustraliaPost->debug_enabled) {
                     // Log request and response
                     $log = array('postURL' => $postURL, 'data' => $data, 'result' => $result);
                     \XLite\Logger::logCustom('AUSPOST', var_export($log, true));
                 }
             } catch (\Exception $e) {
                 $this->errorMsg = $e->getMessage();
             }
         }
     }
     return $result;
 }
예제 #14
0
 /**
  * Map single quote
  * 
  * @param mixed $quote Single quote line
  * 
  * @return \XLite\Model\Shipping\Rate
  */
 protected function mapSingleQuote($quote)
 {
     $rate = null;
     if (isset($quote->total->value)) {
         $rate = new \XLite\Model\Shipping\Rate();
         $rate->setBaseRate($this->getBaseRate($quote));
         $method = Processor\PitneyBowes::getMethod($this->getMethodCode($quote));
         $rate->setMethod($method);
         $rate->setMarkupRate($this->getMarkupRate($quote));
         if (isset($quote->totalTransportation->minDays) || isset($quote->totalTransportation->maxDays)) {
             $extraData = new \XLite\Core\CommonCell();
             $extraData->deliveryMinDays = $quote->totalTransportation->minDays + intval($this->config->min_delivery_adjustment);
             $extraData->deliveryMaxDays = $quote->totalTransportation->maxDays + intval($this->config->max_delivery_adjustment);
             $rate->setExtraData($extraData);
         }
     }
     if (isset($quote->errors)) {
         foreach ($quote->errors as $error) {
             \XLite\Logger::logCustom("PitneyBowes", $error->error, false);
         }
     }
     return $rate;
 }
예제 #15
0
 /**
  * Run catalog submission
  * 
  * @param boolean $diff Perform differential extraction (default: false, full extraction)
  * 
  * @return void
  */
 protected function runSubmit($diff = false)
 {
     \XLite\Logger::logCustom("PitneyBowes", 'Submitting catalog (diff: ' . var_export($diff, true) . ')', false);
     \XLite\Logic\Export\Generator::run(\XLite\Logic\Export\Generator::getPBExportOptions(array('differential' => $diff)));
     $running = \XLite\Logic\Export\Generator::runHeadless();
     //submit to pb
     if (!$running) {
         $config = $this->getConfiguration();
         $processor = new PitneyBowes\Logic\FileExchange\Processor($config);
         $generator = $this->getGenerator();
         if ($generator) {
             $processor->submitCatalog($generator->getCatalogFiles(), $generator->getOptions()->differential);
         }
     }
 }
예제 #16
0
 /**
  * @return mixed
  */
 public function getMapped()
 {
     $result = null;
     if ($this->isApplicable()) {
         $result = $this->postProcessMapped($this->performMap());
     } elseif ($this->nextMapper) {
         $this->nextMapper->setInputData($this->inputData);
         $result = $this->nextMapper->getMapped();
     } else {
         \XLite\Logger::logCustom("PitneyBowes", 'Internal error in mapper ' . get_class($this), false);
     }
     return $result;
 }
예제 #17
0
파일: XLite.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Get controller
  *
  * @return \XLite\Controller\AController
  */
 public static function getController()
 {
     if (null === static::$controller) {
         $class = static::getControllerClass();
         if (!$class) {
             \XLite\Core\Request::getInstance()->target = static::TARGET_DEFAULT;
             \XLite\Logger::logCustom('access', 'Controller class ' . $class . ' not found!');
             \XLite\Core\Request::getInstance()->target = static::TARGET_404;
             $class = static::getControllerClass();
         }
         if (!\XLite\Core\Request::getInstance()->isCLI() && \XLite::getInstance()->getRequestedScript() !== \XLite::getInstance()->getExpectedScript() && \XLite::getInstance()->getRequestedScript() !== \XLite::getInstance()->getExpectedScript(true)) {
             \XLite\Core\Request::getInstance()->target = static::TARGET_404;
             $class = static::getControllerClass();
         }
         static::$controller = new $class(\XLite\Core\Request::getInstance()->getData());
         static::$controller->init();
     }
     return static::$controller;
 }
예제 #18
0
 /**
  * Logs with an arbitrary level.
  * @param string $level The type of log.
  *						Should be 'error', 'warn', 'info', 'debug', 'trace'
  *						In normal mode, 'error' and 'warn' are logged
  *						In debug mode, all are logged
  * @param string $message The message of the log
  * @param int $depth How deep to go to find the calling function
  * @return void
  */
 public function log($level, $message, $depth = 0)
 {
     $level = strtoupper($level);
     $prefix = '[' . $level . ']';
     // Debug formatting
     if ($this->setting('debug') === '1') {
         $depth += 1;
         $prefix .= '{';
         $backtrace = debug_backtrace();
         if (isset($backtrace[$depth]['class'])) {
             $class = preg_replace('/[a-z]/', '', $backtrace[$depth]['class']);
             $prefix .= $class . $backtrace[$depth]['type'];
         }
         if (isset($backtrace[$depth]['function'])) {
             $prefix .= $backtrace[$depth]['function'];
         }
         $prefix .= '}';
     }
     if ('ERROR' === $level || 'WARN' === $level || $this->setting('debug') === '1') {
         \XLite\Logger::logCustom('bitpay', $prefix . ' ' . $message, false);
     }
 }
예제 #19
0
 /**
  * Logging the data under OgoneEcommerce
  * Available if developer_mode is on in the config file
  *
  * @param mixed $data Data
  *
  * @return void
  */
 protected static function log($data)
 {
     if (LC_DEVELOPER_MODE) {
         \XLite\Logger::logCustom('OgoneEcommerce', $data);
     }
 }
예제 #20
0
 /**
  * Logging the data under 2Checkout
  * Available if developer_mode is on in the config file
  *
  * @param mixed $data
  *
  * @return void
  */
 protected static function log($data)
 {
     if (LC_DEVELOPER_MODE) {
         \XLite\Logger::logCustom('TwoCheckout', $data);
     }
 }
예제 #21
0
파일: FormId.php 프로젝트: kewaunited/xcart
 /**
  * Generate public session id
  *
  * @param \XLite\Model\Session $session Session OPTIONAL
  *
  * @return string
  */
 public function generateFormId($session = null)
 {
     if (!isset($session)) {
         $session = \XLite\Core\Session::getInstance()->getModel();
     }
     $iterationLimit = 30;
     $limit = count($this->chars) - 1;
     do {
         $id = '';
         for ($i = 0; self::FORM_ID_LENGTH > $i; $i++) {
             $id .= $this->chars[mt_rand(0, $limit)];
         }
         $iterationLimit--;
     } while (0 < $this->countByFormIdAndSession($id, $session) && 0 < $iterationLimit);
     if (0 == $iterationLimit) {
         // TODO - add throw exception
         \XLite\Logger::logCustom('FORM_ID_GENERATOR', 'Iteration limit has been reached during the Form ID generation procedure. sessionID=' . $session->getId() . ', formId=' . $id);
     }
     return $id;
 }
예제 #22
0
파일: API.php 프로젝트: kewaunited/xcart
 /**
  * Save API call to the log file
  *
  * @param string $url          API endpoint
  * @param string $callName     Call name
  * @param string $requestData  Request XML
  * @param string $responseData Response XML
  *
  * @return void
  */
 public static function logApiCall($url, $callName, $requestData, $responseData)
 {
     \XLite\Logger::logCustom('CAPOST', var_export(array('Request URL' => $url, 'Request XML (' . $callName . ')' => $requestData, 'Response XML' => \XLite\Core\XML::getInstance()->getFormattedXML($responseData)), true));
 }
예제 #23
0
 /**
  * Add message to custom log
  *
  * @param mixed $message Message to log
  *
  * @return void
  */
 protected function log($message)
 {
     $message = is_scalar($message) ? (string) $message : var_export($message, true);
     \XLite\Logger::logCustom($this->getProcessorId(), $message);
 }
예제 #24
0
 /**
  * Add log message
  *
  * @param boolean $status   Status
  * @param array   $request  Request data
  * @param array   $response Response data
  *
  * @return void
  */
 protected function logResponse($status, $request, $response)
 {
     if (\XLite\Core\Config::getInstance()->XC->AuctionInc->debugMode) {
         \XLite\Logger::logCustom('AuctionInc', array('status' => $status, 'request' => $request, 'response' => $response));
     }
 }
예제 #25
0
 protected function loginToSFTP()
 {
     $this->includeLibrary();
     $result = true;
     $sftpClient = new \phpseclib\Net\SFTP(str_replace('sftp://', '', $this->config->sftp_endpoint));
     if (!$sftpClient->login($this->config->sftp_username, $this->config->sftp_password)) {
         $result = false;
         \XLite\Logger::logCustom("PitneyBowes", 'Error: Cound not start SFTP connection.', false);
     } else {
         $sftpClient->chdir($this->config->sftp_catalog_directory);
     }
     return $result ? $sftpClient : $result;
 }
예제 #26
0
파일: XLite.php 프로젝트: kewaunited/xcart
 /**
  * Get controller
  *
  * @return \XLite\Controller\AController
  */
 public static function getController()
 {
     if (!isset(static::$controller)) {
         $class = static::getControllerClass();
         if (!$class) {
             \XLite\Core\Request::getInstance()->target = static::TARGET_DEFAULT;
             \XLite\Logger::logCustom('access', 'Controller class ' . $class . ' not found!');
             \XLite\Core\Request::getInstance()->target = static::TARGET_404;
             $class = static::getControllerClass();
         }
         static::$controller = new $class(\XLite\Core\Request::getInstance()->getData());
         static::$controller->init();
     }
     return static::$controller;
 }
예제 #27
0
 /**
  * Generate packages array
  *
  * @param array $pendingItems Array of pending items
  * @param array $limits       Array of limits
  *
  * @return array
  */
 protected function generatePackages($pendingItems, $limits)
 {
     // Save backup of pending items to make error message (if any) more clear
     $backupPendingItems = $pendingItems;
     $errorMsg = null;
     // Generate packages from items which must be shipped in separate boxes
     $separatePackages = $this->getSeparatePackages($pendingItems, $limits, $errorMsg);
     if (!$errorMsg) {
         // Generate packages from the rest items
         $restPackages = $this->packItems($pendingItems, $limits, $errorMsg);
     }
     if (!empty($pendingItems)) {
         \XLite\Logger::getInstance()->log($this->getLogMessage($backupPendingItems, $errorMsg), $this->getLogLevel());
     }
     if (self::PACKAGE_DEBUG_ENABLED) {
         // Log package details into var/log/PACKING-...
         $data = array('pendingItems' => $pendingItems, 'separatePackages' => $separatePackages, 'restPackages' => $restPackages);
         \XLite\Logger::logCustom('PACKING', $data);
     }
     // Return empty array on failure (if pending items list is not empty) or aggregated packages lists on success
     return $pendingItems ? array() : $this->getAggregatedPackages($separatePackages, $restPackages);
 }