Example #1
1
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'image_folder_path' => '', 'limit' => 12, 'columns' => 4);
     $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
     $url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__);
     $setting = array_merge($t, $setting);
     $oimages = array();
     if ($setting['image_folder_path']) {
         $path = _PS_ROOT_DIR_ . '/' . trim($setting['image_folder_path']) . '/';
         $path = str_replace("//", "/", $path);
         if (is_dir($path)) {
             $images = glob($path . '*.*');
             $exts = array('jpg', 'gif', 'png');
             foreach ($images as $cnt => $image) {
                 $ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image));
                 if (in_array(Tools::strtolower($ext), $exts)) {
                     if ($cnt < (int) $setting['limit']) {
                         $i = str_replace("\\", "/", '' . $setting['image_folder_path'] . "/" . basename($image));
                         $i = str_replace("//", "/", $i);
                         $oimages[] = $url . $i;
                     }
                 }
             }
         }
     }
     $images = array();
     $setting['images'] = $oimages;
     $output = array('type' => 'image', 'data' => $setting);
     return $output;
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitStoreConf')) {
         Configuration::updateValue('PRODUCTPAYMENTLOGOS_LINK', Tools::getValue('PRODUCTPAYMENTLOGOS_LINK'));
         Configuration::updateValue('PRODUCTPAYMENTLOGOS_TITLE', Tools::getValue('PRODUCTPAYMENTLOGOS_TITLE'));
         if (isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']) && isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name']) && !empty($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'])) {
             if (ImageManager::validateUpload($_FILES['PRODUCTPAYMENTLOGOS_IMG'], 4000000)) {
                 return $this->displayError($this->l('Invalid image'));
             } else {
                 $ext = Tools::substr($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], Tools::strrpos($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], '.') + 1);
                 $file_name = md5($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name']) . '.' . $ext;
                 if (!move_uploaded_file($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'], dirname(__FILE__) . '/img/' . $file_name)) {
                     return $this->displayError($this->l('An error occurred while attempting to upload the file.'));
                 } else {
                     $file_path = dirname(__FILE__) . '/img/' . Configuration::get('PRODUCTPAYMENTLOGOS_IMG');
                     if (Configuration::hasContext('PRODUCTPAYMENTLOGOS_IMG', null, Shop::getContext()) && Configuration::get('PRODUCTPAYMENTLOGOS_IMG') != $file_name && file_exists($file_path)) {
                         unlink($file_path);
                     }
                     Configuration::updateValue('PRODUCTPAYMENTLOGOS_IMG', $file_name);
                     $this->_clearCache('productpaymentlogos.tpl');
                     Tools::redirectAdmin('index.php?tab=AdminModules&conf=6&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'));
                 }
             }
         }
         $this->_clearCache('productpaymentlogos.tpl');
     }
     return '';
 }
 function getContent()
 {
     // Check if the module is configured
     if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
         return '<p class="error"><b>' . $this->ebay->l('Please configure the \'General settings\' tab before using this tab') . '</b></p><br /><script type="text/javascript">$("#menuTab4").addClass("wrong")</script>';
     }
     $iso = $this->context->language->iso_code;
     $iso_tiny_mce = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     // Display Form
     $url_vars = array('id_tab' => '4', 'section' => 'template');
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $url_vars['controller'] = Tools::getValue('controller');
     } else {
         $url_vars['tab'] = Tools::getValue('tab');
     }
     $action_url = $this->_getUrl($url_vars);
     if (Tools::getValue('reset_template')) {
         $ebay_product_template = EbayProductTemplate::getContent($this->ebay, $this->smarty);
     } else {
         $ebay_product_template = Tools::getValue('ebay_product_template', $this->ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE'));
     }
     $ebay_product_template_title = $this->ebay_profile->getConfiguration('EBAY_PRODUCT_TEMPLATE_TITLE');
     $smarty_vars = array('action_url' => $action_url, 'ebay_product_template' => $ebay_product_template, 'ebay_product_template_title' => $ebay_product_template_title, 'features_product' => Feature::getFeatures($this->context->language->id), 'ad' => dirname($_SERVER['PHP_SELF']), 'base_uri' => __PS_BASE_URI__, 'is_one_dot_three' => Tools::substr(_PS_VERSION_, 0, 3) == '1.3', 'is_one_dot_five' => version_compare(_PS_VERSION_, '1.5', '>'), 'theme_css_dir' => _THEME_CSS_DIR_);
     if (Tools::substr(_PS_VERSION_, 0, 3) == '1.3') {
         $smarty_vars['theme_name'] = _THEME_NAME_;
         $smarty_vars['language'] = file_exists(_PS_ROOT_DIR_ . '/js/tinymce/jscripts/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     } elseif (version_compare(_PS_VERSION_, '1.5', '>')) {
         $smarty_vars['iso'] = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
     } else {
         $smarty_vars['iso_type_mce'] = $iso_tiny_mce;
         $smarty_vars['ps_js_dir'] = _PS_JS_DIR_;
     }
     return $this->display('formTemplateManager.tpl', $smarty_vars);
 }
 public function setShop($name, $company, $url)
 {
     $this->shop['name'] = $this->prepareField($name);
     $this->shop['name'] = Tools::substr($this->shop['name'], 0, 20);
     $this->shop['company'] = $this->prepareField($company);
     $this->shop['url'] = $this->prepareField($url);
 }
Example #5
0
 protected function getFilterQuery($keys_array = array(), $table)
 {
     $sql = '';
     foreach ($keys_array as $key) {
         if ($this->context->cookie->{$table . 'Filter_' . $key} !== '' && $this->context->cookie->{$table . 'Filter_' . $key} !== false) {
             $value = $this->context->cookie->{$table . 'Filter_' . $key};
             if ($key == 'id_manifest') {
                 $sql .= '`id_manifest` ' . ($value ? '!=' : '=') . ' "0" AND ';
             } elseif (is_array(Tools::jsonDecode($value))) {
                 $date = Tools::jsonDecode($value);
                 $date = array_filter($date);
                 if (!$date) {
                     continue;
                 }
                 if (!empty($date[0])) {
                     $sql .= '`' . bqSQL($key) . '` > "' . pSQL($date[0]) . '" AND ';
                 }
                 if (!empty($date[1])) {
                     $sql .= '`' . bqSQL($key) . '` < "' . pSQL($date[1]) . '" AND ';
                 }
             } else {
                 $sql .= '`' . bqSQL($key) . '` LIKE "%' . pSQL($value) . '%" AND ';
             }
         }
     }
     if ($sql) {
         $sql = ' HAVING ' . Tools::substr($sql, 0, -4);
     }
     // remove 'AND ' from the end of query
     return $sql;
 }
Example #6
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'));
 }
Example #7
0
 protected function getFilterQuery($keys_array = array(), $table)
 {
     $sql = '';
     foreach ($keys_array as $key) {
         if ($this->context->cookie->__isset($table . 'Filter_' . $key)) {
             $value = $this->context->cookie->{$table . 'Filter_' . $key};
             if (Validate::isSerializedArray($value)) {
                 $date = $this->module_instance->unSerialize($value);
                 if (!empty($date[0])) {
                     $sql .= '`' . bqSQL($key) . '` > "' . pSQL($date[0]) . '" AND ';
                 }
                 if (!empty($date[1])) {
                     $sql .= '`' . bqSQL($key) . '` < "' . pSQL($date[1]) . '" AND ';
                 }
             } else {
                 if ($value != '') {
                     $sql .= '`' . bqSQL($key) . '` LIKE "%' . pSQL($value) . '%" AND ';
                 }
             }
         }
     }
     if ($sql) {
         $sql = ' HAVING ' . Tools::substr($sql, 0, -4);
     }
     // remove 'AND ' from the end of query
     return $sql;
 }
Example #8
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     //parent::initContent();
     $so = new SCfields('API');
     $fields = $so->getFields();
     /* Build back the fields list for SoColissimo, gift infos are send using the JS */
     $inputs = array();
     foreach ($_GET as $key => $value) {
         if (in_array($key, $fields)) {
             $inputs[$key] = trim(Tools::getValue($key));
         }
     }
     /* for belgium number specific format */
     if (Tools::getValue('cePays') == 'BE') {
         if (isset($inputs['cePhoneNumber']) && strpos($inputs['cePhoneNumber'], '324') === 0) {
             $inputs['cePhoneNumber'] = '+324' . Tools::substr($inputs['cePhoneNumber'], 3);
         }
     }
     $param_plus = array(Tools::getValue('trParamPlus'), Tools::getValue('gift'), $so->replaceAccentedChars(Tools::getValue('gift_message')));
     $inputs['trParamPlus'] = implode('|', $param_plus);
     /* Add signature to get the gift and gift message in the trParamPlus */
     $inputs['signature'] = $so->generateKey($inputs);
     // automatic settings api protocol for ssl
     $protocol = 'http://';
     if (Configuration::get('PS_SSL_ENABLED')) {
         $protocol = 'https://';
     }
     $socolissimo_url = $protocol . Configuration::get('SOCOLISSIMO_URL_MOBILE');
     Context::getContext()->smarty->assign(array('inputs' => $inputs, 'socolissimo_url' => $socolissimo_url, 'logo' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/socolissimo/logo.gif', 'loader' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/socolissimo/img/ajax-loader.gif'));
     $this->setTemplate('redirect.tpl');
 }
Example #9
0
 public function __construct()
 {
     $this->name = 'payplug';
     $this->tab = 'payments_gateways';
     $this->version = '1.0.1';
     $this->author = 'PayPlug';
     $this->module_key = '1ee28a8fb5e555e274bd8c2e1c45e31a';
     parent::__construct();
     // For 1.6
     $this->bootstrap = true;
     // Backward compatibility
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
     }
     // Add warning if prestashop is an older version than 1.4
     if (version_compare(_PS_VERSION_, '1.4', '<')) {
         $this->warning = $this->l('Sorry Payplug is not compatible with Prestashop for versions < 1.4. Please delete the payplug directory in the Prestashop modules directory for your Prestashop system to get back to normal.');
     }
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     // Change descriptionn and display name
     $this->displayName = $this->l('PayPlug – Simple and secure online payments');
     $this->description = $this->l('The simplest online payment solution: no setup fees, no fixed fees, and no merchant account required!');
     $this->confirmUninstall = $this->l('Are you sure you wish to uninstall this module and delete your settings?');
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $cookie_admin = new Cookie('psAdmin', Tools::substr($_SERVER['PHP_SELF'], Tools::strlen(__PS_BASE_URI__), -10));
         if (Tools::getValue('tab') == 'AdminPayment' && Tools::getValue('token') != Tools::getAdminTokenLite('AdminPayment')) {
             // Force admin status
             $this->context->cookie->profile = $cookie_admin->profile;
             $url = 'index.php?tab=AdminPayment';
             $url .= '&token=' . Tools::getAdminTokenLite('AdminPayment');
             Tools::redirectAdmin($url);
         }
     }
 }
Example #10
0
 function psmFindSignature($content, $start_signature, $end_signature)
 {
     if (($start = strpos($content, $start_signature)) !== false && ($end = strpos($content, $end_signature, $start)) !== false) {
         $length = Tools::strlen($start_signature);
         return Tools::substr($content, $start + $length, $end - $start - $length);
     }
     return false;
 }
 /**
  * create a new user account
  * --
  */
 public function createAccount()
 {
     //user
     $gender = 1;
     $id_default_group = (int) Configuration::get('PS_CUSTOMER_GROUP');
     $firstname = pSQL($this->auth_user->givenName);
     $lastname = pSQL($this->auth_user->familyName);
     $email = $this->auth_user->email;
     // generate passwd
     srand((double) microtime() * 1000000);
     $passwd = Tools::substr(uniqid(rand()), 0, 12);
     $real_passwd = $passwd;
     $passwd = md5(pSQL(_COOKIE_KEY_ . $passwd));
     //dates
     $last_passwd_gen = date('Y-m-d H:i:s', strtotime('-' . Configuration::get('PS_PASSWD_TIME_FRONT') . 'minutes'));
     $secure_key = md5(uniqid(rand(), true));
     $active = 1;
     $date_add = date('Y-m-d H:i:s');
     //'2011-04-04 18:29:15';
     $date_upd = $date_add;
     //gen sql
     $sql = 'insert into `' . _DB_PREFIX_ . 'customer` SET 
     id_gender = ' . (int) $gender . ', id_default_group = ' . (int) $id_default_group . ',
     firstname = \'' . pSQL($firstname) . '\', lastname = \'' . pSQL($lastname) . '\',
     email = \'' . pSQL($email) . '\', passwd = \'' . pSQL($passwd) . '\',
     last_passwd_gen = \'' . pSQL($last_passwd_gen) . '\',
     secure_key = \'' . pSQL($secure_key) . '\', active = ' . (int) $active . ',
     date_add = \'' . pSQL($date_add) . '\', date_upd = \'' . pSQL($date_upd) . '\', optin = 1 ';
     //make the insert and return the last id
     Db::getInstance()->Execute($sql);
     $insert_id = Db::getInstance()->Insert_ID();
     $sql = 'INSERT into `' . _DB_PREFIX_ . 'customer_group` SET ' . 'id_customer = ' . (int) $insert_id . ', id_group = ' . (int) $id_default_group . ' ';
     Db::getInstance()->Execute($sql);
     // auth customer
     $cookie = $this->context->cookie;
     $customer = new Customer();
     //atempt
     $authentication = $customer->getByEmail(trim($email), trim($real_passwd));
     if (!$authentication || !$customer->id) {
         $this->authenticationFailed();
     } else {
         $cookie->id_customer = (int) $customer->id;
         $cookie->customer_lastname = $customer->lastname;
         $cookie->customer_firstname = $customer->firstname;
         $cookie->logged = 1;
         $cookie->passwd = $customer->passwd;
         $cookie->email = $customer->email;
         if (Configuration::get('PS_CART_FOLLOWING') && (empty($cookie->id_cart) || Cart::getNbProducts($cookie->id_cart) == 0)) {
             $cookie->id_cart = (int) Cart::lastNoneOrderedCart((int) $customer->id);
         }
         Hook::exec('actionAuthentication');
         //check if the wecome email exists
         if (Configuration::get('PS_CUSTOMER_CREATION_EMAIL')) {
             Mail::Send($this->context->language->id, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => trim($real_passwd)), $customer->email, $customer->firstname . ' ' . $customer->lastname);
         }
         $this->login($customer->id);
     }
 }
 public function __construct()
 {
     $this->name = 'adminmarketingestep1';
     $this->bootstrap = true;
     $this->module = 'expressmailing';
     $this->context = Context::getContext();
     $this->lang = true;
     $this->default_form_language = $this->context->language->id;
     $this->campaign_id = (int) Tools::getValue('campaign_id');
     if (empty($this->campaign_id)) {
         Tools::redirectAdmin('index.php?controller=AdminMarketingX&token=' . Tools::getAdminTokenLite('AdminMarketingX'));
         exit;
     }
     parent::__construct();
     $online = true;
     $ip_string = (string) Tools::getRemoteAddr();
     $ip_long = ip2long($ip_string);
     if (Tools::substr(Configuration::get('PS_SHOP_DOMAIN'), 0, 9) == 'localhost') {
         $online = false;
     }
     if ($ip_long >= ip2long('10.0.0.0') && $ip_long <= ip2long('10.255.255.255')) {
         $online = false;
     }
     if ($ip_long >= ip2long('127.0.0.0') && $ip_long <= ip2long('127.255.255.255')) {
         $online = false;
     }
     if ($ip_long >= ip2long('172.16.0.0') && $ip_long <= ip2long('172.31.255.255')) {
         $online = false;
     }
     if ($ip_long >= ip2long('192.168.0.0') && $ip_long <= ip2long('192.168.255.255')) {
         $online = false;
     } elseif ($ip_string == '::1') {
         $online = false;
     }
     /* IPv6 */
     if (!$online) {
         $a = $this->module->l('You are currently testing your Prestashop on a local server :', 'adminmarketingestep1');
         $b = $this->module->l('To enjoy the full IMAGE & TRACKING features, you need use a Prestashop online server !', 'adminmarketingestep1');
         $this->warnings[] = $a . ' ' . Tools::getRemoteAddr();
         $this->warnings[] = $b;
     }
     // API initialization
     // ------------------
     include _PS_MODULE_DIR_ . $this->module->name . '/controllers/admin/session_api.php';
     $this->session_api = new SessionApi();
     if ($this->session_api->connectFromCredentials('email')) {
         // On retrouve le max_daily depuis l'API Express-Mailing
         // -----------------------------------------------------
         $parameters = array('account_id' => $this->session_api->account_id);
         $response_array = array();
         if ($this->session_api->call('email', 'account', 'get_formula', $parameters, $response_array)) {
             if ((int) $response_array['broadcast_max_campaign'] > 0) {
                 $this->default_max_daily = $response_array['broadcast_max_campaign'];
             }
         }
     }
 }
 public static function decrypt($plaintext)
 {
     $token = Tools::substr($plaintext, 0, 5);
     $id = Configuration::get('PAGSEGURO_ID');
     if (strcmp($id, $token) == 0) {
         return Tools::substr($plaintext, 5);
     }
     return $plaintext;
 }
Example #14
0
 public function init()
 {
     parent::init();
     if (Tools::isSubmit('storedelivery') && (int) Tools::getValue('storedelivery') != 0) {
         //Save cookie only if previous id_adress wasn't a store
         $cookie = new Cookie('storedelivery');
         $cookie->__set('id_address_delivery', $this->context->cart->id_address_delivery);
         $store = new Store(Tools::getValue('storedelivery'));
         //Test if store address exist in address table
         Tools::strlen($store->name) > 32 ? $storeName = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($storeName = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
         $sql = 'SELECT id_address FROM ' . _DB_PREFIX_ . 'address WHERE alias=\'' . addslashes($storeName) . '\' AND address1=\'' . addslashes($store->address1) . '\' AND address2=\'' . addslashes($store->address2) . '\' AND postcode=\'' . $store->postcode . '\' AND city=\'' . addslashes($store->city) . '\' AND id_country=\'' . addslashes($store->id_country) . '\' AND active=1 AND deleted=0';
         $id_address = Db::getInstance()->getValue($sql);
         //Create store adress if not exist for this user
         if (empty($id_address)) {
             $country = new Country($store->id_country, $this->context->language->id);
             $address = new Address();
             $address->id_country = $store->id_country;
             $address->id_state = $store->id_state;
             $address->country = $country->name;
             Tools::strlen($store->name) > 32 ? $address->alias = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->alias = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             Tools::strlen($store->name) > 32 ? $address->lastname = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->lastname = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             $address->firstname = " ";
             $address->address1 = $store->address1;
             $address->address2 = $store->address2;
             $address->postcode = $store->postcode;
             $address->city = $store->city;
             $address->phone = $store->phone;
             $address->deleted = 0;
             //create an address non deleted to register them in order
             $address->add();
             $id_address = $address->id;
         }
         //Update cart info
         $cart = $this->context->cart;
         $cart->id_address_delivery = $id_address;
         $cart->update();
         //Change address of all product in cart else we are redirect on step Carrier because of function autostep or OrderController
         Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $id_address), $where = 'id_cart = ' . $this->context->cart->id);
         //Change post carrier option else bad default carrier is saved by fonction processCarrier of ParentOrderController
         $array = array_values(Tools::getValue('delivery_option'));
         $_POST['delivery_option'] = array($id_address => $array[0]);
     } else {
         $cookie = new Cookie('storedelivery');
         $id_address_delivery = $cookie->__get('id_address_delivery');
         if ($id_address_delivery != false && $this->context->cart->id_address_delivery != $id_address_delivery && Tools::isSubmit('storedelivery')) {
             $this->context->cart->id_address_delivery = $cookie->__get('id_address_delivery');
             $this->context->cart->update();
             //Change address of all product in cart else we are redirect on step Carrier because of function autostep or OrderController
             Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $cookie->__get('id_address_delivery')), $where = 'id_cart = ' . $this->context->cart->id);
             //Change post carrier option else bad default carrier is saved by fonction processCarrier of ParentOrderController
             $array = array_values(Tools::getValue('delivery_option'));
             $_POST['delivery_option'] = array($cookie->__get('id_address_delivery') => $array[0]);
             $cookie->__unset('id_address_delivery');
         }
     }
 }
Example #15
0
 private function getallheaders()
 {
     $headers = '';
     foreach ($_SERVER as $name => $value) {
         if (Tools::substr($name, 0, 5) == 'HTTP_') {
             $headers[str_replace(' ', '-', ucwords(Tools::strtolower(str_replace('_', ' ', Tools::substr($name, 5)))))] = $value;
         }
     }
     return $headers;
 }
Example #16
0
 public function renderContent($args, $setting)
 {
     $default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'));
     //Context::getContext()->controller->addJS('http'.((Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')) ? 's' : '').'://maps.google.com/maps/api/js?sensor=true&amp;region='.Tools::substr($default_country->iso_code, 0, 2));
     $t = array('latitude' => "21.010904", 'longitude' => '105.787736', 'zoom' => 11, 'width' => 250, 'height' => 200, 'show_market' => 1, 'iso_code' => Tools::substr($default_country->iso_code, 0, 2));
     $setting = array_merge($t, $setting);
     $setting['height'] = $setting['height'] . 'px';
     $setting['width'] = $setting['width'] == "100%" ? "100%" : $setting['width'] . 'px';
     $output = array('type' => 'map', 'data' => $setting);
     return $output;
 }
Example #17
0
 public static function protectDirectory($dir, $excludes = false)
 {
     if (is_dir($dir)) {
         if (is_array($excludes)) {
             foreach ($excludes as &$d) {
                 if (Tools::substr($d, -1, 1) == '/') {
                     $d = Tools::substr($d, 0, Tools::strlen($d) - 1);
                 }
                 $d = self::normalizePath($d);
             }
         }
         return self::protectDirectoryInternal($dir, $excludes);
     }
 }
Example #18
0
 public function __construct()
 {
     $this->name = 'topshop';
     $this->tab = 'smart_shopping';
     $this->version = '1.7.7';
     $this->author = 'Roman Prokofyev';
     $this->need_instance = 1;
     $this->display = 'view';
     $this->bootstrap = true;
     //$this->ps_versions_compliancy = array('min' => '1.5.0.0', 'max' => '1.6');
     $this->module_key = '2149d8638f786d69c1a762f1fbfb8124';
     $this->custom_attributes = array('YAMARKET_COMPANY_NAME', 'YAMARKET_DELIVERY_PRICE', 'YAMARKET_SALES_NOTES', 'YAMARKET_COUNTRY_OF_ORIGIN', 'YAMARKET_EXPORT_TYPE', 'YAMARKET_MODEL_NAME', 'YAMARKET_DESC_TYPE', 'YAMARKET_DELIVERY_DELIVERY', 'YAMARKET_DELIVERY_PICKUP', 'YAMARKET_DELIVERY_STORE');
     $this->country_of_origin_attr = Configuration::get('YAMARKET_COUNTRY_OF_ORIGIN');
     $this->model_name_attr = Configuration::get('YAMARKET_MODEL_NAME');
     parent::__construct();
     $this->displayName = $this->l('Yandex Market');
     if ($this->id && !Configuration::get('YAMARKET_COMPANY_NAME')) {
         $this->warning = $this->l('You have not yet set your Company Name');
     }
     $this->description = $this->l('Provides price list export to Yandex Market');
     $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
     // Variables fro price list
     $this->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $this->proto_prefix = _PS_BASE_URL_;
     // Get groups
     $attribute_groups = AttributeGroup::getAttributesGroups($this->id_lang);
     $this->attibute_groups = array();
     foreach ($attribute_groups as $group) {
         $this->attibute_groups[$group['id_attribute_group']] = $group['public_name'];
     }
     // Get categories
     $this->excluded_cats = explode(',', Configuration::get('TOPSHOP_EXCLUDED_CATS'));
     if (!$this->excluded_cats) {
         $this->excluded_cats = array();
     }
     $all_cats = Category::getSimpleCategories($this->id_lang);
     $this->selected_cats = array();
     $this->all_cats = array();
     foreach ($all_cats as $cat) {
         $this->all_cats[] = $cat['id_category'];
         if (!in_array($cat['id_category'], $this->excluded_cats)) {
             $this->selected_cats[] = $cat['id_category'];
         }
     }
     //determine image type
     $this->image_type = 'large_default';
     if (Tools::substr(_PS_VERSION_, 0, 5) == '1.5.0') {
         $this->image_type = 'large';
     }
 }
 public function makeConnection($host, $script, $body, $simple_mode = false)
 {
     $this->_logs[] = $this->paypal->l('Making new connection to') . ' \'' . $host . $script . '\'';
     if (function_exists('curl_exec')) {
         $return = $this->_connectByCURL($host . $script, $body);
     }
     if (isset($return) && $return) {
         return $return;
     }
     $tmp = $this->_connectByFSOCK($host, $script, $body);
     if (!$simple_mode || !preg_match('/[A-Z]+=/', $tmp, $result)) {
         return $tmp;
     }
     return Tools::substr($tmp, strpos($tmp, $result[0]));
 }
 public static function className($class)
 {
     // Useful for namespaces: Foo\Stripe_Charge
     if ($postfix = strrchr($class, '\\')) {
         $class = Tools::substr($postfix, 1);
     }
     /* PrestaShop */
     if (Tools::substr($class, 0, Tools::strlen('Stripe')) == 'Stripe') {
         $class = Tools::substr($class, Tools::strlen('Stripe'));
     }
     $class = str_replace('_', '', $class);
     $name = urlencode($class);
     $name = Tools::strtolower($name);
     return $name;
 }
Example #21
0
 public function init()
 {
     parent::init();
     if (Tools::isSubmit('storedelivery') && (int) Tools::getValue('storedelivery') != 0) {
         $cookie = new Cookie('storedelivery');
         $cookie->__set('id_address_delivery', $this->context->cart->id_address_delivery);
         $store = new Store(Tools::getValue('storedelivery'));
         Tools::strlen($store->name) > 32 ? $storeName = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($storeName = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
         $sql = 'SELECT id_address FROM ' . _DB_PREFIX_ . 'address WHERE alias=\'' . addslashes($storeName) . '\' AND address1=\'' . addslashes($store->address1) . '\' AND address2=\'' . addslashes($store->address2) . '\' AND postcode=\'' . $store->postcode . '\' AND city=\'' . addslashes($store->city) . '\' AND id_country=\'' . addslashes($store->id_country) . '\' AND active=1 AND deleted=0';
         $id_address = Db::getInstance()->getValue($sql);
         if (empty($id_address)) {
             $country = new Country($store->id_country, $this->context->language->id);
             $address = new Address();
             $address->id_country = $store->id_country;
             $address->id_state = $store->id_state;
             $address->country = $country->name;
             Tools::strlen($store->name) > 32 ? $address->alias = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->alias = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             Tools::strlen($store->name) > 32 ? $address->lastname = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->lastname = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             $address->firstname = " ";
             $address->address1 = $store->address1;
             $address->address2 = $store->address2;
             $address->postcode = $store->postcode;
             $address->city = $store->city;
             $address->phone = $store->phone;
             $address->deleted = 0;
             $address->add();
             $id_address = $address->id;
         }
         $cart = $this->context->cart;
         $cart->id_address_delivery = $id_address;
         $cart->update();
         Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $id_address), $where = 'id_cart = ' . $this->context->cart->id);
         $array = array_values(Tools::getValue('delivery_option'));
         $_POST['delivery_option'] = array($id_address => $array[0]);
     } else {
         $cookie = new Cookie('storedelivery');
         $id_address_delivery = $cookie->__get('id_address_delivery');
         if ($id_address_delivery != false && $this->context->cart->id_address_delivery != $id_address_delivery && Tools::isSubmit('storedelivery')) {
             $this->context->cart->id_address_delivery = $cookie->__get('id_address_delivery');
             $this->context->cart->update();
             Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $cookie->__get('id_address_delivery')), $where = 'id_cart = ' . $this->context->cart->id);
             $array = array_values(Tools::getValue('delivery_option'));
             $_POST['delivery_option'] = array($cookie->__get('id_address_delivery') => $array[0]);
             $cookie->__unset('id_address_delivery');
         }
     }
 }
 public static function sortData($text)
 {
     $token = preg_split('/[-,\\n]/', $text);
     for ($i = 0; $i < Tools::strlen($token[0]); $i++) {
         if (is_numeric(Tools::substr($token[0], $i, 1))) {
             return array(Tools::substr($token[0], 0, $i), Tools::substr($token[0], $i), $token[1]);
         }
     }
     $text = preg_replace('/\\s/', ' ', $text);
     $textlen = Tools::strlen($text);
     $find = Tools::substr($text, -$textlen);
     for ($i = 0; $i < Tools::strlen($text); $i++) {
         if (is_numeric(Tools::substr($find, $i, 1))) {
             return array(Tools::substr($text, 0, -Tools::strlen($text) + $i), Tools::substr($text, -Tools::strlen($text) + $i), '');
         }
     }
 }
 public function display()
 {
     global $cookie;
     if (isset($_GET['view' . $this->table]) and !empty($_GET['id_order']) and $_GET['id_order'] != '--') {
         Tools::redirectAdmin('index.php?tab=AdminOrders&id_order=' . intval($_GET['id_order']) . '&vieworder' . '&token=' . Tools::getAdminToken('AdminOrders' . intval(Tab::getIdFromClassName('AdminOrders')) . intval($cookie->id_employee)));
     } else {
         if (isset($_GET['id_order']) and (empty($_GET['id_order']) or $_GET['id_order'] == '--')) {
             echo '<p class="warning bold"><img src="../img/admin/warning.gif" alt="" class="middle" /> &nbsp;' . Tools::displayError('Cannot display this message because the customer has not finalized its order') . '</p>';
         }
         foreach ($this->_list as $k => $item) {
             if (Tools::strlen($item['last_message']) > 150 + Tools::strlen('...')) {
                 $this->_list[$k]['last_message'] = Tools::substr(html_entity_decode($item['last_message'], ENT_QUOTES, 'UTF-8'), 0, 150, 'UTF-8') . '...';
             }
         }
         $this->displayList();
         $this->displayOptionsList();
     }
 }
Example #24
0
 public static function isLuhnNum($num, $length = null)
 {
     if (empty($length)) {
         $length = Tools::strlen($num);
     }
     $tot = 0;
     for ($i = $length - 1; $i >= 0; $i--) {
         $digit = Tools::substr($num, $i, 1);
         if (($length - $i) % 2 == 0) {
             $digit = $digit * 2;
             if ($digit > 9) {
                 $digit = $digit - 9;
             }
         }
         $tot += $digit;
     }
     return $tot % 10 == 0;
 }
Example #25
0
 public function initParams()
 {
     $tax = (double) self::$cart->getOrderTotal() - (double) self::$cart->getOrderTotal(false);
     $base = (double) self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS) + (double) self::$cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS) - (double) $tax;
     if ($tax == 0) {
         $base = 0;
     }
     $currency = new Currency(self::$cart->id_currency);
     $language = new Language(self::$cart->id_lang);
     $customer = new Customer(self::$cart->id_customer);
     $ref = 'payU_' . Configuration::get('PS_SHOP_NAME') . '_' . (int) self::$cart->id;
     $token = md5(Tools::safeOutput(Configuration::get('PAYU_API_KEY')) . '~' . Tools::safeOutput(Configuration::get('PAYU_MERCHANT_ID')) . '~' . $ref . '~' . (double) self::$cart->getOrderTotal() . '~' . Tools::safeOutput($currency->iso_code));
     $params = array(array('value' => Configuration::get('PAYU_DEMO') == 'yes' ? 1 : 0, 'name' => 'test'), array('value' => Tools::safeOutput(Configuration::get('PAYU_MERCHANT_ID')), 'name' => 'merchantId'), array('value' => $ref, 'name' => 'referenceCode'), array('value' => Tools::substr(Configuration::get('PS_SHOP_NAME') . ' Order', 0, 255), 'name' => 'description'), array('value' => (double) self::$cart->getOrderTotal(), 'name' => 'amount'), array('value' => Tools::safeOutput($customer->email), 'name' => 'buyerEmail'), array('value' => (double) $tax, 'name' => 'tax'), array('value' => 'PRESTASHOP', 'name' => 'extra1'), array('value' => (double) $base, 'name' => 'taxReturnBase'), array('value' => Tools::safeOutput($currency->iso_code), 'name' => 'currency'), array('value' => Tools::safeOutput($language->iso_code), 'name' => 'lng'), array('value' => Tools::safeOutput($token), 'name' => 'signature'), array('value' => 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'history.php', 'name' => 'responseUrl'), array('value' => 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/payulatam/validation.php', 'name' => 'confirmationUrl'));
     if (Configuration::get('PAYU_ACCOUNT_ID') != 0) {
         $params[] = array('value' => (int) Configuration::get('PAYU_ACCOUNT_ID'), 'name' => 'accountId');
     }
     return $params;
 }
Example #26
0
 public static function passwdGen($length = 8, $flag = 'ALPHANUMERIC')
 {
     switch ($flag) {
         case 'NUMERIC':
             $str = '0123456789';
             break;
         case 'NO_NUMERIC':
             $str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
             break;
         default:
             $str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
             break;
     }
     for ($i = 0, $passwd = ''; $i < $length; $i++) {
         $passwd .= Tools::substr($str, mt_rand(0, Tools::strlen($str) - 1), 1);
     }
     return $passwd;
 }
 public function hookdisplayPayment($params)
 {
     if (!$this->active) {
         return;
     }
     //!$cart->OrderExists();
     $customer = new Customer($params['cart']->id_customer);
     $email_address = $customer->email;
     $currency = trim($this->getCurrency()->iso_code);
     $Amount = $params['cart']->getOrderTotal(true, 3) * 100;
     $cartId = $params['cart']->id;
     $address = new Address($params['cart']->id_address_invoice);
     $products = $params['cart']->getProducts();
     $quantity = '';
     $product_name = '';
     $product_count = count($products);
     for ($i = 0; $i < $product_count; $i++) {
         $quantity .= $products[$i]['cart_quantity'] . ',';
         $product_name .= $products[$i]['name'] . ',';
     }
     $product_name = Tools::strlen($product_name) > 100 ? Tools::substr($product_name, 0, 100) : $product_name;
     $complete_address = $address->address1 . ' ' . $address->address2;
     $complete_address = Tools::strlen($complete_address) > 100 ? Tools::substr($complete_address, 0, 100) : $complete_address;
     $module_version = Tools::strlen($module_version) > 20 ? Tools::substr($module_version, 0, 20) : $module_version;
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' && $_SERVER['HTTPS'] != 'OFF') {
         //TODO:: callback url, validate
         $redirect_url = 'https://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/instamojo/validation.php';
     } else {
         $redirect_url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/instamojo/validation.php';
     }
     $imname = $address->firstname . ' ' . $address->lastname;
     $imemail = $email_address;
     $imphone = $address->phone_mobile;
     $imamount = $Amount;
     $imtid = $cartId . '||' . date('his');
     $this->smarty->assign('imname', $imname);
     $this->smarty->assign('imemail', $imemail);
     $this->smarty->assign('imphone', $imphone);
     $this->smarty->assign('imkey', $imkey);
     $this->smarty->assign('imtid', $imtid);
     $this->smarty->assign('imcustom', IM_Config::TXN_ID_NAME);
     $this->smarty->assign('imamount', $params['cart']->getOrderTotal(true, 3));
     return $this->display(__FILE__, '/views/templates/front/instamojo.tpl');
 }
Example #28
0
 private function validation()
 {
     $params = array('TPE' => Tools::getValue('TPE'), 'date' => Tools::getValue('date'), 'montant' => Tools::getValue('montant'), 'reference' => Tools::getValue('reference'), 'texte-libre' => Tools::getValue('texte-libre'), 'version' => Configuration::get('DESJARDINS_VERSION'), 'code-retour' => Tools::getValue('code-retour'), 'motifrefus' => Tools::getValue('motifrefus'), 'cvx' => Tools::getValue('cvx'), 'vld' => Tools::getValue('vld'), 'brand' => Tools::getValue('brand'), 'status3ds' => Tools::getValue('status3ds'), 'numauto' => Tools::getValue('numauto'), 'originecb' => Tools::getValue('originecb'), 'bincb' => Tools::getValue('bincb'), 'hpancb' => Tools::getValue('hpancb'), 'ipclient' => Tools::getValue('ipclient'), 'originetr' => Tools::getValue('originetr'), 'veres' => Tools::getValue('veres'), 'pares' => Tools::getValue('pares'), 'modepaiement' => Tools::getValue('modepaiement'));
     if ($this->generateHash($params) == Tools::getValue('MAC')) {
         $cart = new Cart($params['reference']);
         $customer = new Customer((int) $cart->id_customer);
         // Payment approved (or TEST mode is on)
         if (in_array(Tools::getValue('code-retour'), array('paiement', 'payetest'))) {
             $order_result = array('status' => (int) Configuration::get('PS_OS_PAYMENT'), 'code' => 'VALID');
         } else {
             $order_result = array('status' => (int) Configuration::get('PS_OS_ERROR'), 'code' => 'NOT VALID');
         }
         $amount = Tools::substr(Tools::getValue('montant'), 0, -3);
         if ($this->desjardins->validateOrder((int) $cart->id, (int) $order_result['status'], (double) $amount, $this->desjardins->displayName, null, array(), null, false, $customer->secure_key)) {
             die('version=2' . "\n" . 'cdr=0');
         }
     } else {
         die('version=2' . "\n" . 'cdr=1');
     }
 }
Example #29
0
 /**
  * Autoloader for this module classes
  */
 function currencyByCountryAutoload($class_name)
 {
     $module_name = 'currencybycountry';
     $class_name = ltrim($class_name, '\\');
     $file_name = '';
     $namespace = '';
     if ($last_ns_post = strrpos($class_name, '\\')) {
         $namespace = Tools::substr($class_name, 0, $last_ns_post);
         $class_name = Tools::substr($class_name, $last_ns_post + 1);
         $file_name = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
     }
     $file_name .= str_replace('_', DIRECTORY_SEPARATOR, $class_name) . '.php';
     $file_name = _PS_MODULE_DIR_ . $module_name . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $file_name;
     if (file_exists($file_name)) {
         return require_once $file_name;
     } elseif (version_compare(_PS_VERSION_, '1.4.0.0', '>=') && function_exists('__autoload')) {
         return __autoload($class_name);
     } elseif (version_compare(_PS_VERSION_, '1.4.0.0', '<') && is_readable(_PS_ROOT_DIR_ . '/classes/' . $class_name . '.php')) {
         require_once _PS_ROOT_DIR_ . '/classes/' . $class_name . '.php';
     }
 }
Example #30
0
 function getallheaders()
 {
     $headers = array();
     foreach ($_SERVER as $name => $value) {
         if (Tools::substr($name, 0, 5) == 'HTTP_') {
             $name = str_replace(' ', '-', ucwords(Tools::strtolower(str_replace('_', ' ', Tools::substr($name, 5)))));
             $headers[$name] = $value;
         } else {
             if ($name == 'CONTENT_TYPE') {
                 $headers['Content-Type'] = $value;
             } else {
                 if ($name == 'CONTENT_LENGTH') {
                     $headers['Content-Length'] = $value;
                 } else {
                     $headers[$name] = $value;
                 }
             }
         }
     }
     return $headers;
 }