/**
  * logs message to [PS ROOT]/log/YYYYMMDD_piwik.error.log
  * @param string $message
  */
 public static function ErrorLogger($message)
 {
     if (self::$_error_logger == NULL) {
         self::$_error_logger = new FileLogger(FileLogger::ERROR);
         self::$_error_logger->setFilename(_PS_ROOT_DIR_ . '/log/' . date('Ymd') . '_piwik.error.log');
     }
     self::$_error_logger->logError($message);
 }
Esempio n. 2
0
 public function setError($errors)
 {
     if (!is_array($errors)) {
         $errors = array($errors);
     }
     parent::setError($errors);
     foreach ($errors as $error) {
         $this->logger->logError($error);
     }
 }
Esempio n. 3
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     // Log requests from Privat API side in Debug mode.
     if (Configuration::get('PRIVAT24_DEBUG_MODE')) {
         $logger = new FileLogger();
         $logger->setFilename(_PS_ROOT_DIR_ . '/log/' . $this->module->name . '_' . date('Ymd_His') . '_response.log');
         $logger->logError($_POST);
     }
     $payment = array();
     parse_str(Tools::getValue('payment'), $payment);
     $hash = sha1(md5(Tools::getValue('payment') . $this->module->merchant_password));
     if ($payment && $hash === Tools::getValue('signature')) {
         if ($payment['state'] == 'ok') {
             $state = Configuration::get('PRIVAT24_WAITINGPAYMENT_OS');
             $cart_id = (int) $payment['order'];
             $order = new Order(Order::getOrderByCartId($cart_id));
             if (!Validate::isLoadedObject($order)) {
                 PrestaShopLogger::addLog('Privat24: cannot get order by cart id ' . $cart_id, 3);
                 die;
             }
             if ($order->getCurrentState() != $state) {
                 PrestaShopLogger::addLog(sprintf('Privat24: order id %s current state %s !== expected state %s', $order->id, $order->getCurrentState(), $state), 3);
                 die;
             }
             // Check paid currency and paid amount.
             $id_currency = Currency::getIdByIsoCode($payment['ccy']);
             if (!$id_currency) {
                 PrestaShopLogger::addLog(sprintf('Privat24: order id %s cannot get currency id by iso code: %s', $order->id, $payment['ccy']), 3);
                 die;
             }
             if ($order->id_currency != $id_currency) {
                 PrestaShopLogger::addLog(sprintf('Privat 24: order id %s, order currency id %s does not match with %s', $order->id, $order->id_currency, $id_currency), 3);
                 die;
             }
             if ((double) $order->total_paid != (double) $payment['amt']) {
                 PrestaShopLogger::addLog(sprintf('Privat 24: order id %s order total paid %s does not match %s', $order->id, $order->total_paid, $payment['amt']), 3);
                 die;
             }
             $order_history = new OrderHistory();
             $order_history->id_order = $order->id;
             $order_history->changeIdOrderState(_PS_OS_PAYMENT_, $order->id);
             $order_history->addWithemail();
             $this->setPaymentTransaction($order, $payment);
             $this->module->paymentNotify($order, $payment);
             PrestaShopLogger::addLog(sprintf('Privat24 payment accepted: order id: %s, amount: %s, ref: %s', $order->id, $payment['amt'], $payment['ref']), 1);
         } else {
             PrestaShopLogger::addLog(sprintf('Privat24 payment failed: state: %s, order: %s, ref: %s', $payment['state'], $payment['order'], $payment['ref']), 3, null, null, null, true);
         }
     } else {
         PrestaShopLogger::addLog('Privat24: Payment callback bad signature.', 3, null, null, null, true);
     }
     die;
 }
 /**
  * Log the error on the disk
  */
 protected function logError()
 {
     $logger = new FileLogger();
     $logger->setFilename(_PS_ROOT_DIR_ . '/log/' . date('Ymd') . '_exception.log');
     $logger->logError($this->getExtendedMessage(false));
 }
Esempio n. 5
0
 /**
  * Log the error on the disk
  */
 public function log($messages, $forceDebug = false)
 {
     $debugMode = $this->pfConfig->isDebugMode();
     if (!$debugMode && !$forceDebug) {
         return;
     }
     $logger = new FileLogger();
     $logger->setFilename($this->pfConfig->getLogFileDir());
     $logger->logError($messages);
 }
Esempio n. 6
0
if (!defined('_THEMES_DIR_')) {
    define('_THEMES_DIR_', __PS_BASE_URI__ . 'themes/');
}
if (!defined('_PS_IMG_')) {
    define('_PS_IMG_', __PS_BASE_URI__ . 'img/');
}
if (!defined('_PS_JS_DIR_')) {
    define('_PS_JS_DIR_', __PS_BASE_URI__ . 'js/');
}
if (!defined('_PS_CSS_DIR_')) {
    define('_PS_CSS_DIR_', __PS_BASE_URI__ . 'css/');
}
$oldversion = _PS_VERSION_;
$versionCompare = version_compare(_PS_INSTALL_VERSION_, $oldversion);
if ($versionCompare == '-1') {
    $logger->logError('This installer is too old.');
    $requests .= '<action result="fail" error="27" />' . "\n";
} elseif ($versionCompare == 0) {
    $logger->logError(sprintf('You already have the %s version.', _PS_INSTALL_VERSION_));
    $fail_result .= '<action result="fail" error="28" />' . "\n";
} elseif ($versionCompare === false) {
    $logger->logError('There is no older version. Did you delete or rename the config/settings.inc.php file?');
    $fail_result .= '<action result="fail" error="29" />' . "\n";
}
if (defined('_PS_CACHE_ENABLED_') && _PS_CACHE_ENABLED_) {
    $logger->logError('The cache is activated. Please deactivate it first before lauching this script.');
    $fail_result .= '<action result="fail" error="35" />' . "\n";
}
//check DB access
// include_once(_PS_INSTALL_PATH_.'/classes/ToolsInstall.php');
// $resultDB = ToolsInstall::checkDB(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_, false);