public function postProcess()
 {
     if (Tools::isSubmit('submitLocalizationPack')) {
         $version = str_replace('.', '', _PS_VERSION_);
         $version = substr($version, 0, 2);
         if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
             $pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
             if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
                 $this->errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
             }
             if (!($selection = Tools::getValue('selection'))) {
                 $this->errors[] = Tools::displayError('Please select at least one item to import.');
             } else {
                 foreach ($selection as $selected) {
                     if (!Validate::isLocalizationPackSelection($selected)) {
                         $this->errors[] = Tools::displayError('Invalid selection');
                         return;
                     }
                 }
                 $localization_pack = new LocalizationPack();
                 if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
                     $this->errors = array_merge($this->errors, $localization_pack->getErrors());
                 } else {
                     Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
                 }
             }
         }
     }
     parent::postProcess();
 }
예제 #2
0
 public static function WebServiceCheck($vat_number)
 {
     if (empty($vat_number)) {
         return array();
     }
     $vat_number = str_replace(' ', '', $vat_number);
     $prefix = Tools::substr($vat_number, 0, 2);
     if (array_search($prefix, self::getPrefixIntracomVAT()) === false) {
         return array(Tools::displayError('Invalid VAT number'));
     }
     $vat = Tools::substr($vat_number, 2);
     $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($prefix) . '&iso=' . urlencode($prefix) . '&vat=' . urlencode($vat);
     @ini_set('default_socket_timeout', 2);
     for ($i = 0; $i < 3; $i++) {
         if ($page_res = Tools::file_get_contents($url)) {
             if (preg_match('/invalid VAT number/i', $page_res)) {
                 @ini_restore('default_socket_timeout');
                 return array(Tools::displayError('VAT number not found'));
             } else {
                 if (preg_match('/valid VAT number/i', $page_res)) {
                     @ini_restore('default_socket_timeout');
                     return array();
                 } else {
                     ++$i;
                 }
             }
         } else {
             sleep(1);
         }
     }
     @ini_restore('default_socket_timeout');
     return array(Tools::displayError('VAT number validation service unavailable'));
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitLocalizationPack')) {
         $version = str_replace('.', '', _PS_VERSION_);
         $version = substr($version, 0, 2);
         if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
             $pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
             if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
                 $this->errors[] = Tools::displayError('Cannot load the localization pack.');
             }
             if (!($selection = Tools::getValue('selection'))) {
                 $this->errors[] = Tools::displayError('Please select at least one item to import.');
             } else {
                 foreach ($selection as $selected) {
                     if (!Validate::isLocalizationPackSelection($selected)) {
                         $this->errors[] = Tools::displayError('Invalid selection');
                         return;
                     }
                 }
                 $localization_pack = new LocalizationPack();
                 if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
                     $this->errors = array_merge($this->errors, $localization_pack->getErrors());
                 } else {
                     Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
                 }
             }
         }
     }
     // Remove the module list cache if the default country changed
     if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
         @unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
     }
     parent::postProcess();
 }
예제 #4
0
 public function install()
 {
     $result = true;
     // We need CURL to function correctly
     if (!$this->curlExists()) {
         $this->context->controller->errors[] = $this->l('Riskified require CURL to be installed and enabled.');
         $result = false;
     }
     if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) {
         return false;
     } else {
         if (!($sql = Tools::file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))) {
             return false;
         }
     }
     $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql);
     $sql = preg_split("/;\\s*[\r\n]+/", trim($sql));
     foreach ($sql as $query) {
         if (!Db::getInstance()->execute(trim($query))) {
             return false;
         }
     }
     if (!parent::install() || !$this->registerHook('displayAdminOrder') || !$this->registerHook('displayBackOfficeHeader') || !$this->registerHook('displayBackOfficeTop') || !$this->registerHook('actionValidateOrder') || !$this->registerHook('header')) {
         $result = false;
     }
     RiskifiedLogger::insertLog(__METHOD__ . ' : ' . __LINE__, 'Riskified::install() = ' . $result);
     return $result;
 }
예제 #5
0
 public function exportCsv()
 {
     header("Content-Type: text/csv");
     header("Content-Disposition: attachment; filename=\"export-" . date("Ymd-His") . ".csv\"");
     $db = Db::getInstance();
     $is_cods = is_array(Tools::getValue('packetery_order_is_cod')) ? Tools::getValue('packetery_order_is_cod') : array();
     foreach ($is_cods as $id => $is_cod) {
         $db->execute('update `' . _DB_PREFIX_ . 'packetery_order` set is_cod=' . (int) $is_cod . ' where id_order=' . (int) $id);
     }
     $ids = array_map('floor', is_array(Tools::getValue('packetery_order_id')) && count(Tools::getValue('packetery_order_id')) > 0 ? Tools::getValue('packetery_order_id') : array(0));
     $data = $db->executeS('select
             o.id_order, a.firstname, a.lastname, a.phone, a.phone_mobile, c.email,
             o.total_paid total, po.id_branch, po.is_cod, o.id_currency, po.currency_branch,
             a.company, a.address1, a.address2, a.postcode, a.city
         from
             `' . _DB_PREFIX_ . 'orders` o
             join `' . _DB_PREFIX_ . 'packetery_order` po on(po.id_order=o.id_order)
             join `' . _DB_PREFIX_ . 'customer` c on(c.id_customer=o.id_customer)
             join `' . _DB_PREFIX_ . 'address` a on(a.id_address=o.id_address_delivery)
         where o.id_order in (' . implode(',', $ids) . ')');
     $cnb_rates = null;
     foreach ($data as $order) {
         $phone = "";
         foreach (array('phone', 'phone_mobile') as $field) {
             if (preg_match('/^(((?:\\+|00)?420)?[67][0-9]{8}|((?:\\+|00)?421|0)?9[0-9]{8})$/', preg_replace('/\\s+/', '', $order[$field]))) {
                 $phone = trim($order[$field]);
             }
         }
         $currency = new Currency($order['id_currency']);
         $total = $order['total'];
         if ($currency->iso_code != $order['currency_branch']) {
             $target_currency = Currency::getIdByIsoCode($order['currency_branch']);
             if ($target_currency) {
                 $target_currency = new Currency($target_currency);
                 $total = round($total * $target_currency->conversion_rate / $currency->conversion_rate, 2);
             } else {
                 if (!$cnb_rates) {
                     if ($data = @Tools::file_get_contents('http://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.txt')) {
                         $cnb_rates = array();
                         foreach (array_slice(explode("\n", $data), 2) as $rate) {
                             $rate = explode('|', $rate);
                             $cnb_rates[$rate[3]] = (double) preg_replace('/[^0-9.]*/', '', str_replace(',', '.', $rate[4]));
                         }
                         $cnb_rates['CZK'] = 1;
                     }
                 }
                 if ($cnb_rates) {
                     $total = round($total * $cnb_rates[$currency->iso_code] / $cnb_rates[$order['currency_branch']], 2);
                 }
             }
         }
         $cod_total = $total;
         if ($order['currency_branch'] == 'CZK') {
             $cod_total = round($total);
         }
         echo ';"' . $this->csvEscape($order['id_order']) . '";"' . $this->csvEscape($order['firstname']) . '";"' . $this->csvEscape($order['lastname']) . '";"' . $this->csvEscape($order['company']) . '";"' . $this->csvEscape($order['email']) . '";"' . $this->csvEscape($phone) . '";"' . ($order['is_cod'] == 1 ? $this->csvEscape($cod_total) : "0") . '";"' . $this->csvEscape($total) . '";"' . $this->csvEscape($order['id_branch']) . '";"' . Configuration::get('PACKETERY_ESHOP_DOMAIN') . '";"' . $this->csvEscape($order['address1'] . ($order['address2'] ? ", " . $order['address2'] : "")) . '";;"' . $this->csvEscape($order['city']) . '";"' . $this->csvEscape($order['postcode']) . '"' . "\r\n";
     }
     $db->execute('update `' . _DB_PREFIX_ . 'packetery_order` set exported=1 where id_order in(' . implode(',', $ids) . ')');
     exit;
 }
예제 #6
0
 /**
  * Operation on module installation
  * 
  * @return boolean
  */
 public function install()
 {
     //create log file
     KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Création du fichier de log");
     /** database tables creation * */
     $sqlfile = dirname(__FILE__) . '/install.sql';
     if (!file_exists($sqlfile) || !($sql = Tools::file_get_contents($sqlfile))) {
         return false;
     }
     $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
     $sql = str_replace('KWIXO_ORDER_TABLE_NAME', self::KWIXO_ORDER_TABLE_NAME, $sql);
     $queries = preg_split("/;\\s*[\r\n]+/", $sql);
     foreach ($queries as $query) {
         if (!Db::getInstance()->Execute(trim($query))) {
             KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Installation échouée, création base échouée : " . Db::getInstance()->getMsgError());
             return false;
         }
     }
     //waiting payment status creation
     $this->createKwixoPaymentStatus($this->kw_os_statuses, '#3333FF', '', false, false, '', false);
     //validate green payment status creation
     $this->createKwixoPaymentStatus($this->kw_os_payment_green_status, '#DDEEFF', 'payment', true, true, true, true);
     //validate red payment status creation
     $this->createKwixoPaymentStatus($this->kw_os_payment_red_status, '#DDEEFF', 'payment_error', false, true, false, true);
     //hook register
     return parent::install() && $this->registerHook('newOrder') && $this->registerHook('paymentConfirm') && $this->registerHook('adminOrder') && $this->registerHook('header') && $this->registerHook('leftColumn') && $this->registerHook('rightColumn') && $this->registerHook('payment') && $this->registerHook('extraRight') && $this->registerHook('paymentReturn') && $this->registerHook('top') && $this->registerHook('footer') && $this->registerHook('backOfficeHeader');
 }
 public function postProcess()
 {
     global $currentIndex;
     if (isset($_POST['submitLocalization' . $this->table])) {
         if ($this->tabAccess['edit'] === '1') {
             $this->_postConfig($this->_fieldsLocalization);
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitLocalizationPack')) {
         if (!($pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/' . Tools::getValue('iso_localization_pack') . '.xml')) and !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
             $this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
         } elseif (!($selection = Tools::getValue('selection'))) {
             $this->_errors[] = Tools::displayError('Please select at least one content item to import.');
         } else {
             foreach ($selection as $selected) {
                 if (!Validate::isLocalizationPackSelection($selected)) {
                     $this->_errors[] = Tools::displayError('Invalid selection');
                     return;
                 }
             }
             $localizationPack = new LocalizationPack();
             if (!$localizationPack->loadLocalisationPack($pack, $selection)) {
                 $this->_errors = array_merge($this->_errors, $localizationPack->getErrors());
             } else {
                 Tools::redirectAdmin($currentIndex . '&conf=23&token=' . $this->token);
             }
         }
     }
     parent::postProcess();
 }
예제 #8
0
 /**
  * @see InstallAbstractModel::processNextStep()
  */
 public function processNextStep()
 {
     if (Tools::isSubmit('shop_name')) {
         // Save shop configuration
         $this->session->shop_name = trim(Tools::getValue('shop_name'));
         $this->session->shop_activity = Tools::getValue('shop_activity');
         $this->session->install_type = Tools::getValue('db_mode');
         $this->session->shop_country = Tools::getValue('shop_country');
         $this->session->shop_timezone = Tools::getValue('shop_timezone');
         // Save admin configuration
         $this->session->admin_firstname = trim(Tools::getValue('admin_firstname'));
         $this->session->admin_lastname = trim(Tools::getValue('admin_lastname'));
         $this->session->admin_email = trim(Tools::getValue('admin_email'));
         $this->session->send_informations = Tools::getValue('send_informations');
         if ($this->session->send_informations) {
             $params = http_build_query(array('email' => $this->session->admin_email, 'method' => 'addMemberToNewsletter', 'language' => $this->session->lang, 'visitorType' => 1, 'source' => 'installer'));
             Tools::file_get_contents('http://www.prestashop.com/ajax/controller.php?' . $params);
         }
         // If password fields are empty, but are already stored in session, do not fill them again
         if (!$this->session->admin_password || trim(Tools::getValue('admin_password'))) {
             $this->session->admin_password = trim(Tools::getValue('admin_password'));
         }
         if (!$this->session->admin_password_confirm || trim(Tools::getValue('admin_password_confirm'))) {
             $this->session->admin_password_confirm = trim(Tools::getValue('admin_password_confirm'));
         }
     }
 }
예제 #9
0
 /**
  * WS call APP
  * @param type $data : data array
  * @return array : WS return JSON decoded
  */
 public static function send($url, $data)
 {
     // add data for trackers if not empty
     if (!empty(self::$trackers_data)) {
         $data['data']['trackers_data'] = self::$trackers_data;
     }
     $url = 'http://' . $url . 'ws/';
     $enc = self::encodeData($data);
     $dat = 'k=' . $enc['key'] . '&d=' . $enc['data'];
     if (function_exists('curl_init')) {
         // if curl active
         $c = curl_init($url);
         curl_setopt($c, CURLOPT_POST, true);
         curl_setopt($c, CURLOPT_POSTFIELDS, $dat);
         curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
         $res = curl_exec($c);
         curl_close($c);
     } else {
         // otherwise : file_get_contents
         $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $dat));
         $context = stream_context_create($opts);
         $res = Tools::file_get_contents($url, false, $context);
     }
     $ret = Tools::jsonDecode($res, true);
     if ($ret != null) {
         Configuration::updateValue('checkyourdata_last_errors', implode(', ', $ret['errors']));
     }
     if (!empty($ret['data']['demoEnd'])) {
         Configuration::updateValue('checkyourdata_demo_end', $ret['data']['demoEnd']);
     }
     return $ret;
 }
예제 #10
0
 public function process()
 {
     $body = Tools::file_get_contents('php://input');
     $data = trim($body);
     $result = OpenPayU_Order::consumeNotification($data);
     $response = $result->getResponse();
     SimplePayuLogger::addLog('notification', __FUNCTION__, print_r($result, true), $response->order->orderId, 'Incoming notification: ');
     if (isset($response->order->orderId)) {
         $payu = new PayU();
         $payu->payu_order_id = $response->order->orderId;
         $order_payment = $payu->getOrderPaymentBySessionId($payu->payu_order_id);
         $id_order = (int) $order_payment['id_order'];
         // if order not validated yet
         if ($id_order == 0 && $order_payment['status'] == PayU::PAYMENT_STATUS_NEW) {
             $id_order = $this->createOrder($order_payment, $payu, $response);
         }
         if (!empty($id_order)) {
             $payu->id_order = $id_order;
             $payu->updateOrderData($response);
         }
         if ($this->checkIfPaymentIdIsPresent($response) && $response->order->status == PayU::ORDER_V2_COMPLETED) {
             $this->addPaymentIdToOrder($response, $payu, $id_order);
         }
         //the response should be status 200
         header("HTTP/1.1 200 OK");
         exit;
     }
 }
예제 #11
0
 public static function sendInfo($url, $args)
 {
     $data = array('data' => $args);
     $postdata = http_build_query($data);
     $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
     $context = stream_context_create($opts);
     return Tools::file_get_contents($url, false, $context);
 }
예제 #12
0
 function getContent()
 {
     $ebay_country = EbayCountrySpec::getInstanceByKey($this->ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT'));
     $help_file = dirname(__FILE__) . '/../../help/help-' . Tools::strtolower($ebay_country->getDocumentationLang()) . '.html';
     if (!file_exists($help_file)) {
         $help_file = dirname(__FILE__) . '/../../help/help-en.html';
     }
     return Tools::file_get_contents($help_file);
 }
예제 #13
0
파일: EMS.php 프로젝트: antho-girard/syspay
 /**
  * Build an EMS handler
  * @param array   $secrets       An array where each key is your merchant login and the value is the related passphrase
  * @param boolean $skipAuthCheck Skip the checksum validation
  */
 public function __construct(array $secrets, $skipAuthCheck = false)
 {
     $this->secrets = $secrets;
     $this->skipAuthCheck = $skipAuthCheck;
     $this->headers['content-type'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : 'application/x-www-form-urlencoded';
     $this->headers['x-merchant'] = isset($_SERVER['HTTP_X_MERCHANT']) ? $_SERVER['HTTP_X_MERCHANT'] : null;
     $this->headers['x-checksum'] = isset($_SERVER['HTTP_X_CHECKSUM']) ? $_SERVER['HTTP_X_CHECKSUM'] : null;
     $this->content = Tools::file_get_contents('php://input');
 }
예제 #14
0
    public function install()
    {
        if (!function_exists('curl_version') || !extension_loaded('soap')) {
            $this->_errors[] = $this->l('Mondial Relay needs SOAP & cURL to be installed on your server.');
            return false;
        }
        if (!parent::install()) {
            return false;
        }
        if (!$this->registerHookByVersion()) {
            return false;
        }
        if (!file_exists(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE) || !($sql = Tools::file_get_contents(MondialRelay::$modulePath . MondialRelay::INSTALL_SQL_FILE))) {
            return false;
        }
        $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql);
        $sql = preg_split("/;\\s*[\r\n]+/", $sql);
        foreach ($sql as $query) {
            if (!empty($query)) {
                Db::getInstance()->execute(trim($query));
            }
        }
        $result = Db::getInstance()->getRow('
			SELECT id_tab
			FROM `' . _DB_PREFIX_ . 'tab`
			WHERE class_name="AdminMondialRelay"');
        if (!$result) {
            $tab = new Tab();
            $languages = Language::getLanguages(false);
            foreach ($languages as $language) {
                $tab->name[$language['id_lang']] = 'Mondial Relay';
            }
            $tab->class_name = 'AdminMondialRelay';
            $tab->module = 'mondialrelay';
            $tab->id_parent = Tab::getIdFromClassName('AdminOrders');
            if (!$tab->add()) {
                return false;
            }
            if (is_dir(_PS_MODULE_DIR_ . 'mondialrelay/')) {
                @copy(_PS_MODULE_DIR_ . 'mondialrelay/img/AdminMondialRelay.gif', _PS_IMG_DIR_ . '/AdminMondialRelay.gif');
            }
        }
        /* If module isn't installed, set default value */
        if (!Configuration::get('MONDIAL_RELAY')) {
            Configuration::updateValue('MONDIAL_RELAY', $this->version);
            Configuration::updateValue('MONDIAL_RELAY_SECURE_KEY', md5(_COOKIE_KEY_ . time()));
            Configuration::updateValue('MONDIAL_RELAY_MODE', 'widget');
        } else {
            $query = 'UPDATE `' . _DB_PREFIX_ . 'carrier` c, `' . _DB_PREFIX_ . 'mr_method` m
					SET c.`deleted` = 0
					WHERE c.`id_carrier` = m.`id_carrier`
					AND m.`is_deleted` = 0';
            /* Reactive transport if database wasn't remove at the last uninstall */
            Db::getInstance()->execute($query);
        }
        return true;
    }
 /**
  * query all pilibaba supported currency
  * 
  * @return array
  */
 public static function queryAll()
 {
     $result = Tools::file_get_contents(self::PILIPAY_CURRENCY_PATH);
     if (empty($result)) {
         return array();
     }
     $array = Tools::jsonDecode($result, true);
     return $array;
 }
 /**
  * query all warehouse addresses
  * @params $resultFormat string objectList or arrayList
  * @return array
  */
 public static function queryAll()
 {
     $result = Tools::file_get_contents(self::WAREHOUSE_ADDRESS_PATH);
     if (empty($result)) {
         return array();
     }
     $array = Tools::jsonDecode($result, true);
     return $array;
 }
예제 #17
0
 public static function isModuleOverridden($module_name)
 {
     $context = Context::getContext();
     $theme = new Theme($context->shop->id_theme);
     if (!(file_exists(_PS_ROOT_DIR_ . self::CACHE_FILE_OVERRIDEN_MODULES_LIST) && filesize(_PS_ROOT_DIR_ . self::CACHE_FILE_OVERRIDEN_MODULES_LIST) > 0 && strstr(Tools::file_get_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_OVERRIDEN_MODULES_LIST), $theme->name))) {
         self::generateOverriddenXml();
     }
     return (bool) strstr(Tools::file_get_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_OVERRIDEN_MODULES_LIST), $module_name);
 }
예제 #18
0
 public function postProcess()
 {
     $res = \CashWay\API::receiveNotification(Tools::file_get_contents('php://input'), getallheaders(), Configuration::get('CASHWAY_SHARED_SECRET'));
     if ($res[0] === false) {
         $this->terminateReply($res[2], $res[1]);
     }
     $event = $res[1];
     $this->data = $res[2];
     $handler = $this->snakeToCamel('on_' . $event);
     method_exists($this, $handler) ? $this->{$handler}() : $this->terminateReply(400, 'Do not know how to handle this event.');
 }
 public function initContent()
 {
     $parent_domain = Tools::getHttpHost(true) . substr($_SERVER['REQUEST_URI'], 0, -1 * strlen(basename($_SERVER['REQUEST_URI'])));
     $iso_lang = $this->context->language->iso_code;
     $iso_currency = $this->context->currency->iso_code;
     $iso_country = $this->context->country->iso_code;
     $addons_url = 'http://addons.prestashop.com/iframe/search-1.6.php?psVersion=' . _PS_VERSION_ . '&isoLang=' . $iso_lang . '&isoCurrency=' . $iso_currency . '&isoCountry=' . $iso_country . '&parentUrl=' . $parent_domain;
     $addons_content = Tools::file_get_contents($addons_url);
     $this->context->smarty->assign(array('iso_lang' => $iso_lang, 'iso_currency' => $iso_currency, 'iso_country' => $iso_country, 'display_addons_content' => $addons_content !== false, 'addons_content' => $addons_content, 'parent_domain' => $parent_domain));
     parent::initContent();
 }
예제 #20
0
 /**
  * Télecharger un fichier distant
  * Les données sont stockées dans le tampon $rawdata
  * @param string $url
  * @return boolean
  */
 public function load($url)
 {
     $file = $url;
     $file_headers = @get_headers($file);
     if ($file_headers[0] == 'HTTP/1.1 404 Not Found') {
         return false;
     } else {
         $this->rawdata = Tools::file_get_contents($url);
         return true;
     }
 }
 public function ajaxProcessInfoQuery()
 {
     $this->content_only = true;
     $result = array('status' => false);
     if (time() > (int) Configuration::get('PP_INFO_CHECK_TIME')) {
         $protocol = Tools::getCurrentUrlProtocolPrefix();
         $iso_lang = Context::getContext()->language->iso_code;
         $iso_country = Context::getContext()->country->iso_code;
         $stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 3)));
         $old_content = $this->getInfo();
         $msg = $old_content === false ? 0 : $old_content[0];
         $shop_url = ShopUrl::getShopUrls($this->context->shop->id)->where('main', '=', 1)->getFirst();
         $shop = $shop_url ? $shop_url->getURL() : Tools::getShopDomain();
         $date = Db::getInstance()->getValue('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = \'PSM_ID_' . Tools::strtoupper($this->module->name) . '\'');
         $psm_date = $date ? urlencode(date('Y-m-d H:i:s', strtotime($date))) : '';
         $plugins_string = '';
         $plugins = $this->module->plugins();
         foreach ($plugins as $name => $api_version) {
             if (Module::isInstalled($name)) {
                 $plugins_string .= '&' . $name . '=' . $this->moduleVersion($name);
             }
         }
         $url = $protocol . 'store.psandmore.com/query/?key=' . $this->module->name . '&ver=' . $this->module->version . '&psm=' . PSM::getPSMId($this->module) . '&psm_date=' . $psm_date . $plugins_string . '&msg=' . $msg . '&iso_country=' . $iso_country . '&iso_lang=' . $iso_lang . '&shop=' . urlencode($shop);
         $contents = Tools::file_get_contents($url, false, $stream_context);
         $check_info_offset = 3600;
         if ($contents !== false) {
             $content = explode('|', $contents);
             if (is_numeric($content[0])) {
                 if (!$this->infoIgnore(false, $content[0])) {
                     if (Validate::isCleanHtml($content[1])) {
                         $this->putInfo($contents);
                         $check_info_offset = 86400;
                     }
                 }
             } else {
                 if ($content[0] == 'hide') {
                     Configuration::deleteByName('PP_INFO_CONTENT');
                 }
             }
         }
         Configuration::updateValue('PP_INFO_CHECK_TIME', time() + $check_info_offset);
     }
     $content = $this->getInfo();
     if ($content !== false) {
         if (!$this->infoIgnore($content)) {
             if (Validate::isCleanHtml($content[1])) {
                 $result['status'] = 'success';
                 $result['content'] = $content[1];
             }
         }
     }
     $this->content = Tools::jsonEncode($result);
 }
 private static function loadSQLFile($sql_file)
 {
     $result = true;
     $sql_content = Tools::file_get_contents($sql_file);
     $sql_content = str_replace('PREFIX_', _DB_PREFIX_, $sql_content);
     $sql_requests = preg_split("/;\\s*[\r\n]+/", $sql_content);
     foreach ($sql_requests as $request) {
         if (!empty($request)) {
             $result &= Db::getInstance()->execute(trim($request));
         }
     }
     return $result;
 }
예제 #23
0
 protected function runTasksCrons()
 {
     $query = 'SELECT * FROM ' . _DB_PREFIX_ . $this->module->name . ' WHERE `active` = 1 AND `id_module` IS NULL';
     $crons = Db::getInstance()->executeS($query);
     if (is_array($crons) && count($crons) > 0) {
         foreach ($crons as &$cron) {
             if ($this->shouldBeExecuted($cron) == true) {
                 Tools::file_get_contents(urldecode($cron['task']), false);
                 $query = 'UPDATE ' . _DB_PREFIX_ . $this->module->name . ' SET `updated_at` = NOW(), `active` = IF (`one_shot` = TRUE, FALSE, `active`) WHERE `id_cronjob` = \'' . $cron['id_cronjob'] . '\'';
                 Db::getInstance()->execute($query);
             }
         }
     }
 }
 public function postProcess()
 {
     if (_PS_MODE_DEMO_) {
         $this->errors[] = $this->trans('This functionality has been disabled.', array(), 'Admin.Notifications.Error');
         return;
     }
     if (!extension_loaded('openssl')) {
         $this->displayWarning($this->l('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.'));
     }
     if (Tools::isSubmit('submitLocalizationPack')) {
         $version = str_replace('.', '', _PS_VERSION_);
         $version = substr($version, 0, 2);
         if (($iso_localization_pack = Tools::getValue('iso_localization_pack')) && Validate::isFileName($iso_localization_pack)) {
             if (Tools::getValue('download_updated_pack') == '1' || defined('_PS_HOST_MODE_')) {
                 $pack = @Tools::file_get_contents(_PS_API_URL_ . '/localization/' . $version . '/' . $iso_localization_pack . '.xml');
             } else {
                 $pack = false;
             }
             if (defined('_PS_HOST_MODE_')) {
                 $path = _PS_CORE_DIR_ . '/localization/' . $iso_localization_pack . '.xml';
             } else {
                 $path = _PS_ROOT_DIR_ . '/localization/' . $iso_localization_pack . '.xml';
             }
             if (!$pack && !($pack = @Tools::file_get_contents($path))) {
                 $this->errors[] = $this->trans('Cannot load the localization pack.', array(), 'Admin.International.Notification');
             }
             if (!($selection = Tools::getValue('selection'))) {
                 $this->errors[] = $this->trans('Please select at least one item to import.', array(), 'Admin.International.Notification');
             } else {
                 foreach ($selection as $selected) {
                     if (!Validate::isLocalizationPackSelection($selected)) {
                         $this->errors[] = $this->trans('Invalid selection', array(), 'Admin.Notifications.Error');
                         return;
                     }
                 }
                 $localization_pack = new LocalizationPack();
                 if (!$localization_pack->loadLocalisationPack($pack, $selection, false, $iso_localization_pack)) {
                     $this->errors = array_merge($this->errors, $localization_pack->getErrors());
                 } else {
                     Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
                 }
             }
         }
     }
     // Remove the module list cache if the default country changed
     if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
         @unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
     }
     parent::postProcess();
 }
예제 #25
0
 public function loadFromPath($path)
 {
     if ($path == null || !trim($path) || !is_readable($path)) {
         return $this;
     }
     $image_data = Tools::file_get_contents($path);
     if ($image_data === false) {
         return $this;
     }
     //correct image
     if (Tools::strlen($image_data) > 0) {
         $this->image = $this->resize($image_data, 300, 300, false);
     }
     return $this;
 }
예제 #26
0
 private function getP()
 {
     $default_lang = $this->context->language->id;
     $lang = Language::getIsoById($default_lang);
     $pl = array('es', 'fr');
     if (!in_array($lang, $pl)) {
         $lang = 'en';
     }
     $base = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https://' . $this->context->shop->domain_ssl : 'http://' . $this->context->shop->domain;
     $uri = $base . $this->context->shop->getBaseURI();
     $path = _PS_MODULE_DIR_ . 'lgconsultas' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'publi' . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . 'index.php';
     $object = Tools::file_get_contents($path);
     $object = str_replace('src="/modules/', 'src="' . $uri . 'modules/', $object);
     return $object;
 }
예제 #27
0
 /**
  * Uninstalls module from PrestaShop
  *
  * @return bool
  */
 public function uninstall()
 {
     $sql = str_replace(array('{{ db_prefix }}'), array(_DB_PREFIX_), Tools::file_get_contents(dirname(__FILE__) . '/install/down.sql'));
     if (!Db::getInstance()->execute($sql)) {
         return false;
     }
     // Deregister admin controller
     $id_tab = (int) Tab::getIdFromClassName('AdminCTTopMenuItem');
     $tab = new Tab($id_tab);
     if (!$tab->delete()) {
         return false;
     }
     Configuration::deleteByName('CT_TOP_MENU_SEARCH');
     Configuration::deleteByName('CT_TOP_MENU_ITEM_HOVER');
     return parent::uninstall();
 }
예제 #28
0
 /**
  * Assign summary template
  */
 public function webhook()
 {
     $stripe = new StripeJs();
     if ($stripe->active) {
         if (Tools::getIsset('token') && Configuration::get('STRIPE_WEBHOOK_TOKEN') == Tools::getValue('token')) {
             include $this->module->getLocalPath() . 'lib/Stripe.php';
             Stripe::setApiKey(Configuration::get('STRIPE_MODE') ? Configuration::get('STRIPE_PRIVATE_KEY_LIVE') : Configuration::get('STRIPE_PRIVATE_KEY_TEST'));
             $event_json = Tools::jsonDecode(@Tools::file_get_contents('php://input'));
             if (isset($event_json->id)) {
                 /* In case there is an issue with the event, Stripe throw an exception, just ignore it. */
                 try {
                     /* To double-check and for more security, we retrieve the original event directly from Stripe */
                     $event = Stripe_Event::retrieve($event_json->id);
                     /* We are only handling chargebacks, other events are ignored */
                     if ($event->type == 'charge.dispute.created') {
                         $id_order = (int) Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'stripe_transaction WHERE id_stripe_transaction = \'' . pSQL($event->id) . '\' AND `charge_back` = 0');
                         if ($id_order) {
                             $order = new Order((int) $id_order);
                             if (Validate::isLoadedObject($order)) {
                                 if (Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS') != -1) {
                                     if ($order->getCurrentState() != Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS')) {
                                         $order->changeIdOrderState((int) Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS'), (int) $id_order);
                                         Db::getInstance()->getValue('UPDATE `' . _DB_PREFIX_ . 'stipe_transaction` SET `charge_back` = 1 WHERE `id_stripe_transaction` = \'' . pSQL($event->id) . '\' AND `charge_back` = 0');
                                     }
                                 }
                                 $message = new Message();
                                 $message->message = $stripe->l('A chargeback occured on this order and was reported by Stripe on') . ' ' . date('Y-m-d H:i:s');
                                 $message->id_order = (int) $order->id;
                                 $message->id_employee = 1;
                                 $message->private = 1;
                                 $message->date_add = date('Y-m-d H:i:s');
                                 $message->add();
                             }
                         }
                     }
                 } catch (Exception $e) {
                     header('HTTP/1.1 200 OK');
                     exit;
                 }
                 header('HTTP/1.1 200 OK');
                 exit;
             }
         }
     }
     header('HTTP/1.1 200 OK');
     exit;
 }
예제 #29
0
 /**
  * Fetch information from the help website in order to know:
  * - if the help page exists
  * - his version
  * - the associated tooltip
  *
  * @static
  * @param $label
  * @param $iso_lang
  * @param $country
  * @param $version
  *
  * @return array
  */
 public static function retrieveInfos($label, $iso_lang, $country, $version)
 {
     $url = HelpAccess::URL . '/documentation/renderIcon?label=' . $label . '&iso_lang=' . $iso_lang . '&country=' . $country . '&version=' . $version;
     $tooltip = '';
     $ctx = @stream_context_create(array('http' => array('timeout' => 10)));
     $res = Tools::file_get_contents($url, false, $ctx);
     $infos = preg_split('/\\|/', $res);
     if (count($infos) > 0) {
         $version = trim($infos[0]);
         if (!empty($version)) {
             if (count($infos) > 1) {
                 $tooltip = trim($infos[1]);
             }
         }
     }
     return array('version' => $version, 'tooltip' => $tooltip);
 }
/**
 * 2007-2015 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <*****@*****.**>
 * @copyright 2007-2015 PrestaShop SA
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */
function ps1607_language_code_update()
{
    if (defined('_PS_VERSION_')) {
        $langs = Db::getInstance()->executeS('SELECT `id_lang`, `iso_code`, `language_code` FROM `' . _DB_PREFIX_ . 'lang`');
        if (is_array($langs) && $langs) {
            foreach ($langs as $lang) {
                if (Tools::strlen($lang['language_code']) == 2) {
                    $result = json_decode(Tools::file_get_contents('https://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . Tools::strtolower($lang['iso_code'])));
                    if ($result && !isset($result->error) && Tools::strlen($result->language_code) > 2) {
                        Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'lang` SET `language_code` = \'' . pSQL($result->language_code) . '\' WHERE `id_lang` = ' . (int) $lang['id_lang']) . ' LIMIT 1';
                    }
                }
            }
        }
    }
    return true;
}