Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     $this->logger = new FileLogger();
     if (is_writable(_PS_ROOT_DIR_ . '/log/')) {
         $this->logger->setFilename(_PS_ROOT_DIR_ . '/log/' . @date('Ymd') . '_installation.log');
     }
 }
 /**
  * logs message to [PS ROOT]/log/YYYYMMDD_piwik.debug.log
  * @param string $message
  */
 public static function DebugLogger($message)
 {
     if (PKHelper::DEBUGLOG != 1) {
         return;
     }
     if (self::$_debug_logger == NULL) {
         self::$_debug_logger = new FileLogger(FileLogger::DEBUG);
         self::$_debug_logger->setFilename(_PS_ROOT_DIR_ . '/log/' . date('Ymd') . '_piwik.debug.log');
     }
     self::$_debug_logger->logDebug($message);
 }
Exemplo 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;
 }
Exemplo n.º 4
0
 public function setError($errors)
 {
     static $logger = null;
     if (null === $logger) {
         $cacheDir = _PS_ROOT_DIR_ . '/app/logs/';
         $file = $cacheDir . (_PS_MODE_DEV_ ? 'dev' : 'prod') . '_' . @date('Ymd') . '_installation.log';
         $logger = new FileLogger();
         $logger->setFilename($file);
         $this->logger = $logger;
     }
     if (!is_array($errors)) {
         $errors = array($errors);
     }
     parent::setError($errors);
     foreach ($errors as $error) {
         $this->logger->logError($error);
     }
 }
 /**
  * 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));
 }
Exemplo n.º 6
0
define('INSTALL_VERSION', '1.4.7.0');
define('INSTALL_PATH', dirname(__FILE__));
define('PS_INSTALLATION_IN_PROGRESS', true);
require_once INSTALL_PATH . '/classes/ToolsInstall.php';
define('SETTINGS_FILE', INSTALL_PATH . '/../config/settings.inc.php');
define('DEFINES_FILE', INSTALL_PATH . '/../config/defines.inc.php');
define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/') + 1))));
define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://' . ToolsInstall::getHttpHost(false, true) . INSTALLER__PS_BASE_URI);
// XML Header
header('Content-Type: text/xml');
// Switching method
if (isset($_GET['method'])) {
    if (in_array($_GET['method'], array('doUpgrade', 'createDB', 'checkShopInfos'))) {
        global $logger;
        $logger = new FileLogger();
        $logger->setFilename(dirname(__FILE__) . '/../log/' . @date('Ymd') . '_installation.log');
    }
    switch ($_GET['method']) {
        case 'checkConfig':
            require_once 'xml/checkConfig.php';
            break;
        case 'checkDB':
            require_once 'xml/checkDB.php';
            break;
        case 'createDB':
            require_once 'xml/createDB.php';
            break;
        case 'checkMail':
            require_once 'xml/checkMail.php';
            break;
        case 'checkShopInfos':
Exemplo n.º 7
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);
 }
 /**
  * Put Message to log file
  *
  * @param  $message (string) - message who need put to file
  * @param  $logFileName (string) - file name where put
  * @param  $logFilePath (string) - file location from PS ROOT
  * @return $this (mix) - this class
  */
 public static function log($message, $logFileName = 'dpd.log', $logFilePath = 'log')
 {
     $logger = new FileLogger(0);
     //0 == debug level, logDebug() won’t work without this.
     $logger->setFilename(_PS_ROOT_DIR_ . '/' . $logFilePath . '/' . $logFileName);
     $logger->logDebug(date('Y-m-d H:i:s') . ':' . $message);
     return __CLASS__;
 }
Exemplo n.º 9
0
// need for upgrade before 1.5
if (!defined('__PS_BASE_URI__')) {
    define('__PS_BASE_URI__', str_replace('//', '/', '/' . trim(preg_replace('#/(install(-dev)?)$#', '/', str_replace('\\', '/', dirname($_SERVER['REQUEST_URI']))), '/') . '/'));
}
// need for upgrade before 1.5
if (!defined('_THEME_NAME_')) {
    define('_THEME_NAME_', 'default');
}
require_once dirname(__FILE__) . '/../init.php';
// set logger
require_once _PS_INSTALL_PATH_ . 'upgrade/classes/AbstractLogger.php';
eval('abstract class AbstractLogger extends AbstractLoggerCore{}');
require_once _PS_INSTALL_PATH_ . 'upgrade/classes/FileLogger.php';
eval('class FileLogger extends FileLoggerCore{}');
$logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_ . '/log/' . @date('Ymd') . '_upgrade.log');
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('Europe/Paris');
}
// if _PS_ROOT_DIR_ is defined, use it instead of "guessing" the module dir.
if (defined('_PS_ROOT_DIR_') and !defined('_PS_MODULE_DIR_')) {
    define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/modules/');
} elseif (!defined('_PS_MODULE_DIR_')) {
    define('_PS_MODULE_DIR_', _PS_INSTALL_PATH_ . '/../modules/');
}
if (!defined('_PS_INSTALLER_PHP_UPGRADE_DIR_')) {
    define('_PS_INSTALLER_PHP_UPGRADE_DIR_', _PS_INSTALL_PATH_ . 'upgrade/php/');
}
if (!defined('_PS_INSTALLER_SQL_UPGRADE_DIR_')) {
    define('_PS_INSTALLER_SQL_UPGRADE_DIR_', _PS_INSTALL_PATH_ . 'upgrade/sql/');
}
Exemplo n.º 10
0
 /**
  * model_doUpgrade prepare the call to doUpgrade.php file (like model.php)
  *
  * @return void
  */
 public function _modelDoUpgrade()
 {
     // a. set logger
     // it will be used later
     global $logger;
     $logger = new FileLogger();
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set('Europe/Paris');
     }
     // use autoupgrade as log dir
     $logger->setFilename($this->latestRootDir . '/' . date('Ymd') . '_autoupgrade.log');
     // init env.
     @set_time_limit(0);
     @ini_set('max_execution_time', '0');
     // setting the memory limit to 128M only if current is lower
     $memory_limit = ini_get('memory_limit');
     if (substr($memory_limit, -1) != 'G' and (substr($memory_limit, -1) == 'M' and substr($memory_limit, 0, -1) < 128 or is_numeric($memory_limit) and intval($memory_limit) < 131072)) {
         @ini_set('memory_limit', '128M');
     }
     /* Redefine REQUEST_URI if empty (on some webservers...) */
     if (!isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '') {
         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
     }
     if ($tmp = strpos($_SERVER['REQUEST_URI'], '?')) {
         $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $tmp);
     }
     $_SERVER['REQUEST_URI'] = str_replace('//', '/', $_SERVER['REQUEST_URI']);
     ///////////////////////
     // Copy from model.php
     ///////////////////////
     $upgrader = $this->upgrader;
     $upgrader->checkPSVersion();
     define('INSTALL_VERSION', $upgrader->version_num);
     // now the install dir to use is in a subdirectory of the admin dir
     define('INSTALL_PATH', realpath($this->latestRootDir . DIRECTORY_SEPARATOR . 'install'));
     define('PS_INSTALLATION_IN_PROGRESS', true);
     // Note : we don't need ToolsInstall.php
     // include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
     define('SETTINGS_FILE', $this->prodRootDir . '/config/settings.inc.php');
     define('DEFINES_FILE', $this->prodRootDir . '/config/defines.inc.php');
     define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/') + 1))));
     // Note : INSTALLER__PS_BASE_URI_ABSOLUTE is not used for upgrade
     // define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://'.ToolsInstall::getHttpHost(false, true).INSTALLER__PS_BASE_URI);
     // XML Header
     header('Content-Type: text/xml');
     require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'doUpgrade.php';
     //////////////////////////////
     // End of copy from model.php
     //////////////////////////////
 }
Exemplo n.º 11
0
}
// need for upgrade before 1.5
if (!defined('_THEME_NAME_')) {
    define('_THEME_NAME_', 'default');
}
require_once dirname(__FILE__) . '/../init.php';
Migrate::migrateSettingsFile();
require_once _PS_CONFIG_DIR_ . 'bootstrap.php';
// set logger
require_once _PS_INSTALL_PATH_ . 'upgrade/classes/AbstractLogger.php';
eval('abstract class AbstractLogger extends AbstractLoggerCore{}');
require_once _PS_INSTALL_PATH_ . 'upgrade/classes/FileLogger.php';
eval('class FileLogger extends FileLoggerCore{}');
$cacheDir = _PS_ROOT_DIR_ . '/' . (_PS_MODE_DEV_ ? 'dev' : 'prod') . '/log/' . @date('Ymd') . '_upgrade.log';
$logger = new FileLogger();
$logger->setFilename($cacheDir);
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('Europe/Paris');
}
// if _PS_ROOT_DIR_ is defined, use it instead of "guessing" the module dir.
if (defined('_PS_ROOT_DIR_') and !defined('_PS_MODULE_DIR_')) {
    define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/modules/');
} elseif (!defined('_PS_MODULE_DIR_')) {
    define('_PS_MODULE_DIR_', _PS_INSTALL_PATH_ . '/../modules/');
}
if (!defined('_PS_INSTALLER_PHP_UPGRADE_DIR_')) {
    define('_PS_INSTALLER_PHP_UPGRADE_DIR_', _PS_INSTALL_PATH_ . 'upgrade/php/');
}
if (!defined('_PS_INSTALLER_SQL_UPGRADE_DIR_')) {
    define('_PS_INSTALLER_SQL_UPGRADE_DIR_', _PS_INSTALL_PATH_ . 'upgrade/sql/');
}
 public function _modelDo($method)
 {
     @set_time_limit(0);
     @ini_set('max_execution_time', '0');
     // setting the memory limit to 128M only if current is lower
     $memory_limit = ini_get('memory_limit');
     if (substr($memory_limit, -1) != 'G' and (substr($memory_limit, -1) == 'M' and substr($memory_limit, 0, -1) < 128 or is_numeric($memory_limit) and intval($memory_limit) < 131072)) {
         @ini_set('memory_limit', '128M');
     }
     require_once $this->prodRootDir . '/config/autoload.php';
     /* Redefine REQUEST_URI if empty (on some webservers...) */
     if (!isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '') {
         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
     }
     if ($tmp = strpos($_SERVER['REQUEST_URI'], '?')) {
         $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $tmp);
     }
     $_SERVER['REQUEST_URI'] = str_replace('//', '/', $_SERVER['REQUEST_URI']);
     define('INSTALL_VERSION', $this->currentParams['install_version']);
     define('INSTALL_PATH', realpath($this->latestRootDir . DIRECTORY_SEPARATOR . 'install'));
     define('PS_INSTALLATION_IN_PROGRESS', true);
     require_once INSTALL_PATH . '/classes/ToolsInstall.php';
     define('SETTINGS_FILE', $this->prodRootDir . '/config/settings.inc.php');
     define('DEFINES_FILE', $this->prodRootDir . '/config/defines.inc.php');
     define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/') + 1))));
     define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://' . ToolsInstall::getHttpHost(false, true) . INSTALLER__PS_BASE_URI);
     // XML Header
     header('Content-Type: text/xml');
     // Switching method
     if (in_array($method, array('doUpgrade', 'createDB', 'checkShopInfos'))) {
         global $logger;
         $logger = new FileLogger();
         $logger->setFilename($this->prodRootDir . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . @date('Ymd') . '_installation.log');
     }
     switch ($method) {
         case 'checkConfig':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkConfig.php';
             die;
             break;
         case 'checkDB':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkDB.php';
             break;
         case 'createDB':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'createDB.php';
             break;
         case 'checkMail':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkMail.php';
             break;
         case 'checkShopInfos':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkShopInfos.php';
             break;
         case 'doUpgrade':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'doUpgrade.php';
             break;
         case 'getVersionFromDb':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'getVersionFromDb.php';
             break;
     }
 }