Example #1
0
    public static function setNewConnection($cookie)
    {
        // The old connections details are removed from the database in order to spare some memory
        Connection::cleanConnectionsPages();
        // A new connection is created if the guest made no actions during 30 minutes
        $result = Db::getInstance()->getRow('
		SELECT c.`id_guest`
		FROM `' . _DB_PREFIX_ . 'connections` c
		LEFT JOIN `' . _DB_PREFIX_ . 'connections_page` cp ON c.`id_connections` = cp.`id_connections`
		WHERE c.`id_guest` = ' . intval($cookie->id_guest) . '
		AND DATE_ADD(cp.`time_start`, INTERVAL 30 MINUTE) > \'' . pSQL(date('Y-m-d H:i:s')) . '\'
		ORDER BY cp.`time_start` DESC');
        if (!$result['id_guest'] and intval($cookie->id_guest)) {
            $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
            $arrayUrl = parse_url($referer);
            if (!isset($arrayUrl['host']) or preg_replace('/^www./', '', $arrayUrl['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false))) {
                $referer = '';
            }
            $connection = new Connection();
            $connection->id_guest = intval($cookie->id_guest);
            $connection->id_page = Page::getCurrentId();
            $connection->ip_address = isset($_SERVER['REMOTE_ADDR']) ? ip2long($_SERVER['REMOTE_ADDR']) : '';
            if (Validate::isAbsoluteUrl($referer)) {
                $connection->http_referer = $referer;
            }
            $connection->add();
            $cookie->id_connections = $connection->id;
            return $connection->id_page;
        }
    }
Example #2
0
 public function getAuthorisation()
 {
     global $cookie, $cart;
     // Getting cart informations
     $currency = new Currency(intval($cookie->id_currency));
     if (!Validate::isLoadedObject($currency)) {
         $this->_logs[] = $this->l('Not a valid currency');
     }
     if (sizeof($this->_logs)) {
         return false;
     }
     // Making request
     $vars = '?fromPayPal=1';
     $returnURL = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'modules/paypalapi/payment/submit.php' . $vars;
     $cancelURL = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'order.php';
     $paymentAmount = floatval($cart->getOrderTotal());
     $currencyCodeType = strval($currency->iso_code);
     $paymentType = 'Sale';
     $request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1';
     if ($this->_pp_integral) {
         $request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing';
     } else {
         $request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login';
     }
     $request .= '&LOCALECODE=' . strval($this->getCountryCode());
     if ($this->_header) {
         $request .= '&HDRIMG=' . urlencode($this->_header);
     }
     // Calling PayPal API
     include _PS_MODULE_DIR_ . 'paypalapi/api/paypallib.php';
     $ppAPI = new PaypalLib();
     $result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request);
     $this->_logs = array_merge($this->_logs, $ppAPI->getLogs());
     return $result;
 }
 public static function logHttpReferer()
 {
     global $cookie;
     if (!isset($cookie->id_connections) or !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     if (!isset($_SERVER['HTTP_REFERER']) and !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     if (isset($_SERVER['HTTP_REFERER']) and Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         if (preg_replace('/^www./', '', parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) and !strncmp(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH), parse_url('http://' . Tools::getHttpHost(false, false) . __PS_BASE_URI__, PHP_URL_PATH), strlen(__PS_BASE_URI__))) {
             return false;
         }
         if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER']))) {
             $source->http_referer = strval($_SERVER['HTTP_REFERER']);
             $source->keywords = trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER'])));
             if (!Validate::isMessage($source->keywords)) {
                 return false;
             }
         }
     }
     $source->id_connections = intval($cookie->id_connections);
     $source->request_uri = Tools::getHttpHost(false, false);
     if (isset($_SERVER['REDIRECT_URL'])) {
         $source->request_uri .= strval($_SERVER['REDIRECT_URL']);
     } elseif (isset($_SERVER['REQUEST_URI'])) {
         $source->request_uri .= strval($_SERVER['REQUEST_URI']);
     }
     if (!Validate::isUrl($source->request_uri)) {
         unset($source->request_uri);
     }
     return $source->add();
 }
Example #4
0
 private function newMessage($type, $phone, $cname, $message, $email_theme, $email_param = "")
 {
     $host = Tools::getHttpHost();
     $phone = "+" . preg_replace('#\\D+#', '', $phone);
     // insert to DB
     $query = "insert into " . _DB_PREFIX_ . egmarketing::INSTALL_SQL_BD1NAME . " \r\n\t\t(`id_shop`, `host`, `type`, `phone`, `fname`, `lname`, `message`) \r\n\t\tvalues ('" . (int) $context->shop->id . "', '" . Tools::getHttpHost() . "', '" . $type . "', '" . $phone . "',\r\n\t\t\t'" . $cname . "', '" . $cname . "', '" . $message . "')";
     Db::getInstance()->execute(trim($query));
     // notify by email
     if ($email_param == "") {
         $email_param = Configuration::get('EGCALLME_EMAIL_NOTIFY');
     }
     if (trim($email_param) != "") {
         $context = Context::getContext();
         $param = array('{phone}' => $phone, '{message}' => $message, '{fname}' => $cname, '{shop_url}' => $host);
         $emails = explode(';', $email_param);
         foreach ($emails as $email) {
             Mail::Send((int) $context->language->id, $email_theme, Mail::l($type, " " . $phone . " " . $host), $param, $email, $cname, null, null, null, null, _PS_MAIL_DIR_, false, (int) $context->shop->id);
         }
     }
     // sms notification
     $sms_message = "%type %host %phone %cname %message";
     $sms_message = Meta::sprintf2($sms_message, array('host' => $host, 'type' => $type, 'phone' => $phone, 'cname' => $cname, 'message' => $message));
     //$this->sendSMS($sms_message,"79601652555",2);
     $param = array('{phone}' => str_replace('+', '', $phone), '{message}' => $message, '{fname}' => $cname, '{type}' => 'FastOrder', '{host}' => $host, '{shost}' => str_replace('.', '-', $host));
     $this->sendTelegramm($param, $sms_message);
 }
 public function renderView()
 {
     $this->initPageHeaderToolbar();
     $this->tpl_view_vars = array('version' => array('php' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time')), 'database' => array('version' => Db::getInstance()->getVersion(), 'prefix' => _DB_PREFIX_, 'engine' => _MYSQL_ENGINE_), 'uname' => function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('v') . ' ' . php_uname('m') : '', 'apache_instaweb' => Tools::apacheModExists('mod_instaweb'), 'shop' => array('ps' => _PS_VERSION_, 'url' => Tools::getHttpHost(true) . __PS_BASE_URI__, 'theme' => _THEME_NAME_), 'mail' => Configuration::get('PS_MAIL_METHOD') == 1, 'smtp' => array('server' => Configuration::get('PS_MAIL_SERVER'), 'user' => Configuration::get('PS_MAIL_USER'), 'password' => Configuration::get('PS_MAIL_PASSWD'), 'encryption' => Configuration::get('PS_MAIL_SMTP_ENCRYPTION'), 'port' => Configuration::get('PS_MAIL_SMTP_PORT')), 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
     $this->tpl_view_vars = array_merge($this->getTestResult(), $this->tpl_view_vars);
     return parent::renderView();
 }
Example #6
0
 /**
  * Send a mail
  *
  * @param string $subject
  * @param string $content
  * @return bool|string false is everything was fine, or error string
  */
 public function send($subject, $content)
 {
     try {
         // Test with custom SMTP connection
         if ($this->smtp_checked) {
             $smtp = new Swift_Connection_SMTP($this->server, $this->port, $this->encryption == "off" ? Swift_Connection_SMTP::ENC_OFF : ($this->encryption == "tls" ? Swift_Connection_SMTP::ENC_TLS : Swift_Connection_SMTP::ENC_SSL));
             $smtp->setUsername($this->login);
             $smtp->setpassword($this->password);
             $smtp->setTimeout(5);
             $swift = new Swift($smtp);
         } else {
             // Test with normal PHP mail() call
             $swift = new Swift(new Swift_Connection_NativeMail());
         }
         $message = new Swift_Message($subject, $content, 'text/html');
         if (@$swift->send($message, $this->email, 'no-reply@' . Tools::getHttpHost(false, false, true))) {
             $result = false;
         } else {
             $result = 'Could not send message';
         }
         $swift->disconnect();
     } catch (Swift_Exception $e) {
         $result = $e->getMessage();
     }
     return $result;
 }
 public function initContent()
 {
     parent::initContent();
     $id = $_GET['id'];
     $id_lang = $this->context->language->id;
     $product = new Product((int) $id);
     $link = new Link();
     $url = $link->getProductLink($product);
     $features = Db::getInstance()->ExecuteS('
 		SELECT fl.name feature_name, fvl.value feature_value
 		FROM ' . _DB_PREFIX_ . 'feature_product fp
 		LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' )
 		LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ')
 		WHERE fp.id_product=' . $id);
     //	print_r($features);
     $images = Image::getImages((int) $id_lang, (int) $product->id);
     //Limitamos el numero de fotos a cuatro solamente
     while (count($images) > 3) {
         $var = array_pop($images);
     }
     $this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND')));
     $html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl');
     $dompdf = new DOMPDF();
     $dompdf->set_option('enable_remote', TRUE);
     $dompdf->load_html($html);
     $dompdf->set_paper('a4', 'portrait');
     $dompdf->render();
     $dompdf->stream('producto');
     //$this->setTemplate('custom_template_content.tpl');
     //file_put_contents($filename, $dompdf->output());
     //$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty);
     //$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg';
     //$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
     //$pdf->render();
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'alias';
        $this->className = 'Alias';
        $this->lang = false;
        parent::__construct();
        // Alias fields
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        if (!Tools::getValue('realedit')) {
            $this->deleted = false;
        }
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->fields_list = array('alias' => array('title' => $this->l('Aliases')), 'search' => array('title' => $this->l('Search')), 'active' => array('title' => $this->l('Status'), 'class' => 'fixed-width-sm', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
        // Search options
        $current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
        $cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
        list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE product_shop.`visibility` IN ("both", "search") AND product_shop.`active` = 1');
        $this->fields_options = array('indexation' => array('title' => $this->l('Indexing'), 'icon' => 'icon-cogs', 'info' => '<p>' . $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of a Front Office search.') . '<br />
						' . $this->l('Indexed products') . ' <strong>' . (int) $indexed . ' / ' . (int) $total . '</strong>.
						</p>
						<p>' . $this->l('Building the product index may take a few minutes.') . $this->l('If your server stops before the process ends, you can resume the indexing by clicking "Add missing products."') . '</p>
						<a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&amp;redirect=1" class="btn-link"><i class="icon-external-link-sign"></i> ' . $this->l('Add missing products to the index.') . '</a><br />
						<a href="searchcron.php?full=1&amp;token=' . substr(_COOKIE_KEY_, 34, 8) . '&amp;redirect=1" class="btn-link"><i class="icon-external-link-sign"></i> ' . $this->l('Re-build the entire index.') . '</a><br /><br />
						' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . ' <a href="' . Tools::safeOutput($cron_url) . '"><i class="icon-external-link-sign"></i> ' . Tools::safeOutput($cron_url) . '</a>', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexing'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable the automatic indexing of products. If you enable this feature, the products will be indexed in the search automatically when they are saved. If the feature is disabled, you will have to index products manually by using the links provided in the field set.'))), 'submit' => array('title' => $this->l('Save'))), 'search' => array('title' => $this->l('Search'), 'icon' => 'icon-search', 'fields' => array('PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'hint' => array($this->l('Enable ajax search for your visitors.'), $this->l('With ajax search, the first 10 products matching the user query will appear in real time below the input field.'))), 'PS_INSTANT_SEARCH' => array('title' => $this->l('Instant search'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'hint' => array($this->l('Enable instant search for your visitors?'), $this->l('With instant search, the results will appear immediately as the user writes a query.'))), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'hint' => $this->l('Only words this size or larger will be indexed.'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'validation' => 'isGenericName', 'hint' => $this->l('Please enter the index words separated by a "|".'), 'type' => 'textLang')), 'submit' => array('title' => $this->l('Save'))), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'icon-cogs', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when completing a new search.') . '<br />
						' . $this->l('A word with a weight of eight will have four times more value than a word with a weight of two.') . '<br /><br />
						' . $this->l('We advise you to set a greater weight for words which appear in the name or reference of a product. This will allow the search results to be as precise and relevant as possible.') . '<br /><br />
						' . $this->l('Setting a weight to 0 will exclude that field from search index. Re-build of the entire index is required when changing to or from 0'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval')), 'submit' => array('title' => $this->l('Save'))));
    }
Example #9
0
 /**
  * Send a mail
  *
  * @param string $subject
  * @param string $content
  * @return bool|string false is everything was fine, or error string
  */
 public function send($subject, $content)
 {
     try {
         // Test with custom SMTP connection
         if ($this->smtp_checked) {
             // Retrocompatibility
             if (Tools::strtolower($this->encryption) === 'off') {
                 $this->encryption = false;
             }
             $smtp = Swift_SmtpTransport::newInstance($this->server, $this->port, $this->encryption);
             $smtp->setUsername($this->login);
             $smtp->setpassword($this->password);
             $smtp->setTimeout(5);
             $swift = Swift_Mailer::newInstance($smtp);
         } else {
             // Test with normal PHP mail() call
             $swift = Swift_Mailer::newInstance(Swift_MailTransport::newInstance());
         }
         $message = Swift_Message::newInstance();
         $message->setFrom($this->email)->setTo('no-reply@' . Tools::getHttpHost(false, false, true))->setSubject($subject)->setBody($content);
         $message = new Swift_Message($subject, $content, 'text/html');
         if (@$swift->send($message)) {
             $result = true;
         } else {
             $result = 'Could not send message';
         }
         $swift->disconnect();
     } catch (Swift_SwiftException $e) {
         $result = $e->getMessage();
     }
     return $result;
 }
Example #10
0
 function hookHeader($params)
 {
     global $smarty, $cookie;
     $id_category = intval(Tools::getValue('id_category'));
     if (!$id_category) {
         if (isset($_SERVER['HTTP_REFERER']) and preg_match('!^(.*)\\/([0-9]+)\\-(.*[^\\.])|(.*)id_category=([0-9]+)(.*)$!', $_SERVER['HTTP_REFERER'], $regs) and !strstr($_SERVER['HTTP_REFERER'], '.html')) {
             if (isset($regs[2]) and is_numeric($regs[2])) {
                 $id_category = intval($regs[2]);
             } elseif (isset($regs[5]) and is_numeric($regs[5])) {
                 $id_category = intval($regs[5]);
             }
         } elseif ($id_product = intval(Tools::getValue('id_product'))) {
             $product = new Product($id_product);
             $id_category = $product->id_category_default;
         }
     }
     $category = new Category($id_category);
     $orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');
     $orderWayValues = array(0 => 'ASC', 1 => 'DESC');
     $orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[intval(Configuration::get('PS_PRODUCTS_ORDER_BY'))]));
     $orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[intval(Configuration::get('PS_PRODUCTS_ORDER_WAY'))]));
     if (!in_array($orderBy, $orderByValues)) {
         $orderBy = $orderByValues[0];
     }
     if (!in_array($orderWay, $orderWayValues)) {
         $orderWay = $orderWayValues[0];
     }
     $smarty->assign(array('feedUrl' => 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/rss.php?id_category=' . $id_category . '&amp;orderby=' . $orderBy . '&amp;orderway=' . $orderWay));
     return $this->display(__FILE__, 'feederHeader.tpl');
 }
    public function __construct()
    {
        $this->table = 'alias';
        $this->className = 'Alias';
        $this->lang = false;
        parent::__construct();
        // Alias fields
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        if (!Tools::getValue('realedit')) {
            $this->deleted = false;
        }
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
        $this->fields_list = array('alias' => array('title' => $this->l('Aliases'), 'width' => 'auto'), 'search' => array('title' => $this->l('Search'), 'width' => 100), 'active' => array('title' => $this->l('Status'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
        // Search options
        $current_file_name = array_reverse(explode('/', $_SERVER['SCRIPT_NAME']));
        $cron_url = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($current_file_name['0'])) . 'searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
        list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(product_shop.indexed) as "1" FROM ' . _DB_PREFIX_ . 'product p ' . Shop::addSqlAssociation('product', 'p'));
        $this->fields_options = array('indexation' => array('title' => $this->l('Indexation'), 'icon' => 'search', 'info' => $this->l('The "indexed" products have been analyzed by PrestaShop and will appear in the results of the Front Office search.') . '<br />
						' . $this->l('Indexed products:') . ' <b>' . (int) $indexed . ' / ' . (int) $total . '</b>.
						</p>
						<p>' . $this->l('Building the product index can take a few minutes or more.') . $this->l('If your server stops the process before it ends, you can resume the indexation by clicking "Add missing products."') . '</p>
						-&gt; <a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Add missing products to index.') . '</a><br />
						-&gt; <a href="searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Re-build entire index.') . '</a><br /><br />
						' . $this->l('You can set a cron job that will rebuild your index using the following URL:') . ' <a href="' . $cron_url . '">' . $cron_url . '</a>', 'fields' => array('PS_SEARCH_INDEXATION' => array('title' => $this->l('Indexation'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable automatic indexation of the products. If you enable this feature, the products will be indexed in the search automatically when they are saved, but if the feature is disabled, you will have to index the products manually by using the links provided in this fieldset.')))), 'search' => array('title' => $this->l('Search'), 'icon' => 'search', 'fields' => array('PS_SEARCH_AJAX' => array('title' => $this->l('Ajax search'), 'validation' => 'isBool', 'type' => 'bool', 'cast' => 'intval', 'desc' => $this->l('Enable ajax search for your visitors.') . '<br />' . $this->l('With ajax search, the first 10 products matching the user query will appear in real time below the input field.')), 'PS_INSTANT_SEARCH' => array('title' => $this->l('Instant search'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'desc' => $this->l('Enable instant search for your visitors.') . '<br />' . $this->l('With instant search, the results will appear immediately as the user writes a query.')), 'PS_SEARCH_MINWORDLEN' => array('title' => $this->l('Minimum word length (in characters)'), 'desc' => $this->l('Only words this size or larger will be indexed.'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_BLACKLIST' => array('title' => $this->l('Blacklisted words'), 'size' => 35, 'validation' => 'isGenericName', 'desc' => $this->l('Please enter the words separated by a "|".'), 'type' => 'textLang')), 'submit' => array()), 'relevance' => array('title' => $this->l('Weight'), 'icon' => 'weight', 'info' => $this->l('The "weight" represents its importance and relevance for the ranking of the products when try a new search.') . '<br />
						' . $this->l('A word with a weight of 8 will have 4 times more value than a word with a weight of 2.') . '<br /><br />
						' . $this->l('That\'s why we advise to set a greater weight for words which appear in the name or reference of a product than the ones in the description. Thus, the search results will be as precise and relevant as possible.'), 'fields' => array('PS_SEARCH_WEIGHT_PNAME' => array('title' => $this->l('Product name weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_REF' => array('title' => $this->l('Reference weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_SHORTDESC' => array('title' => $this->l('Short description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_DESC' => array('title' => $this->l('Description weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_CNAME' => array('title' => $this->l('Category weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_MNAME' => array('title' => $this->l('Manufacturer weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_TAG' => array('title' => $this->l('Tags weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_ATTRIBUTE' => array('title' => $this->l('Attributes weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'), 'PS_SEARCH_WEIGHT_FEATURE' => array('title' => $this->l('Features weight'), 'size' => 4, 'validation' => 'isUnsignedInt', 'type' => 'text', 'cast' => 'intval'))));
    }
Example #12
0
    public function displayForm($isMainTab = true)
    {
        global $cookie, $currentIndex;
        parent::displayForm();
        $currentProfile = (int) $this->getCurrentProfileId();
        $tabs = Tab::getTabs($cookie->id_lang);
        $profiles = Profile::getProfiles((int) $cookie->id_lang);
        $accesses = Profile::getProfileAccesses((int) $currentProfile);
        echo '
		<script type="text/javascript">
			setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Update in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\'));
		</script>
		<div id="ajax_confirmation"></div>
		<table class="table" cellspacing="0">
			<tr>
				<th ' . ($currentProfile == (int) _PS_ADMIN_PROFILE_ ? 'colspan="6"' : '') . '>
					<select name="profile" onchange="redirect(\'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . (int) $profile['id_profile'] . '" ' . ((int) $profile['id_profile'] == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>';
            }
        }
        $tabsize = sizeof($tabs);
        foreach ($tabs as $tab) {
            if ($tab['id_tab'] > $tabsize) {
                $tabsize = $tab['id_tab'];
            }
        }
        echo '
					</select>
				</th>';
        if ($currentProfile != (int) _PS_ADMIN_PROFILE_) {
            echo '
				<th class="center">' . $this->l('View') . '<br /><input type="checkbox" name="1" id="viewall" onclick="ajax_power(this, \'view\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('Add') . '<br /><input type="checkbox" name="1" id="addall" onclick="ajax_power(this, \'add\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('Edit') . '<br /><input type="checkbox" name="1" id="editall" onclick="ajax_power(this, \'edit\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('Delete') . '<br /><input type="checkbox" name="1" id="deleteall" onclick="ajax_power(this, \'delete\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
				<th class="center">' . $this->l('All') . '<br /><input type="checkbox" name="1" id="allall" onclick="ajax_power(this, \'all\', -1, ' . $currentProfile . ', \'' . $this->token . '\', \'' . $tabsize . '\', \'' . sizeof($tabs) . '\')" /></th>
			</tr>';
        }
        if (!sizeof($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } elseif ($currentProfile == (int) _PS_ADMIN_PROFILE_) {
            echo '<tr><td colspan="5">' . $this->l('Administrator permissions cannot be modified.') . '</td></tr>';
        } else {
            foreach ($tabs as $tab) {
                if (!$tab['id_parent'] or (int) $tab['id_parent'] == -1) {
                    $this->printTabAccess((int) $currentProfile, $tab, $accesses[$tab['id_tab']], false, $tabsize, sizeof($tabs));
                    foreach ($tabs as $child) {
                        if ($child['id_parent'] === $tab['id_tab']) {
                            if (isset($accesses[$child['id_tab']])) {
                                $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true, $tabsize, sizeof($tabs));
                            }
                        }
                    }
                }
            }
        }
        echo '</table>';
    }
Example #13
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $shop_name = htmlentities(Configuration::get('PS_SHOP_NAME'), NULL, 'utf-8');
     $shop_url = Tools::getHttpHost(true, true);
     $customer = Context::getContext()->customer;
     if (!preg_match("#.*\\.html\$#Ui", Tools::getValue('mail')) or !preg_match("#.*\\.html\$#Ui", Tools::getValue('mail'))) {
         die(Tools::redirect());
     }
     $file = file_get_contents(dirname(__FILE__) . '/../../mails/' . strval(preg_replace('#\\.{2,}#', '.', Tools::getValue('mail'))));
     $file = str_replace('{shop_name}', $shop_name, $file);
     $file = str_replace('{shop_url}', $shop_url . __PS_BASE_URI__, $file);
     $file = str_replace('{shop_logo}', $shop_url . _PS_IMG_ . 'logo.jpg', $file);
     $file = str_replace('{firstname}', $customer->firstname, $file);
     $file = str_replace('{lastname}', $customer->lastname, $file);
     $file = str_replace('{email}', $customer->email, $file);
     $file = str_replace('{firstname_friend}', 'XXXXX', $file);
     $file = str_replace('{lastname_friend}', 'xxxxxx', $file);
     $file = str_replace('{link}', 'authentication.php?create_account=1', $file);
     $discount_type = (int) Configuration::get('REFERRAL_DISCOUNT_TYPE');
     if ($discount_type == 1) {
         $file = str_replace('{discount}', Discount::display((double) Configuration::get('REFERRAL_PERCENTAGE'), $discount_type, new Currency($this->context->currency->id)), $file);
     } else {
         $file = str_replace('{discount}', Discount::display((double) Configuration::get('REFERRAL_DISCOUNT_VALUE_' . $this->context->currency->id), $discount_type, new Currency($this->context->currency->id)), $file);
     }
     $this->context->smarty->assign(array('content' => $file));
     $this->setTemplate('email.tpl');
 }
Example #14
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 #15
0
 protected function getDomain($shared_urls = null)
 {
     $r = '!(?:(\\w+)://)?(?:(\\w+)\\:(\\w+)@)?([^/:]+)?(?:\\:(\\d*))?([^#?]+)?(?:\\?([^#]+))?(?:#(.+$))?!i';
     if (!preg_match($r, Tools::getHttpHost(false, false), $out) || !isset($out[4])) {
         return false;
     }
     if (preg_match('/^(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]|[1-9]).)' . '{1}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]).)' . '{2}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]){1}))$/', $out[4])) {
         return false;
     }
     if (!strstr(Tools::getHttpHost(false, false), '.')) {
         return false;
     }
     $domain = false;
     if ($shared_urls !== null) {
         foreach ($shared_urls as $shared_url) {
             if ($shared_url != $out[4]) {
                 continue;
             }
             if (preg_match('/^(?:.*\\.)?([^.]*(?:.{2,4})?\\..{2,3})$/Ui', $shared_url, $res)) {
                 $domain = '.' . $res[1];
                 break;
             }
         }
     }
     if (!$domain) {
         $domain = $out[4];
     }
     return $domain;
 }
Example #16
0
 private function newMessage($phone, $fname, $lname, $message, $context)
 {
     $host = Tools::getHttpHost();
     // insert to DB
     $query = "insert into " . _DB_PREFIX_ . egcallme::INSTALL_SQL_BD1NAME . " \n        (`id_shop`, `host`, `type`, `phone`, `fname`,`lname`, `message`) \n        values ('" . (int) $context->shop->id . "', '" . $host . "', 'callback', '" . $phone . "',\n            '" . $fname . "','" . $lname . "', '" . $message . "')";
     Db::getInstance()->execute(trim($query));
     // notify by email
     $emails_param = Configuration::get('EGCALLME_EMAIL_NOTIFY');
     if (trim($emails_param) != "") {
         $param = array('{phone}' => $phone, '{message}' => $message, '{fname}' => $fname, '{lname}' => $lname, '{host}' => $host);
         $emails = explode(';', $emails_param);
         $dir = egcallme::getModuleDir() . '/mails/';
         foreach ($emails as $email) {
             $email_theme = "email_notify";
             Mail::Send((int) $context->language->id, $email_theme, Mail::l("NEW Callback " . $phone, $this->context->language->id), $param, trim($email), "", null, null, null, null, $dir, false, (int) $context->shop->id);
         }
         $param['{phone}'] = preg_replace('#\\D+#', '', $param['{phone}']);
         $requests = Configuration::getMultiple(array('EGCALLME_HTTPNOT_1', 'EGCALLME_HTTPNOT_2', 'EGCALLME_HTTPNOT_3'));
         $texts = Configuration::getMultiple(array('EGCALLME_HTTPNOT_1_TXT', 'EGCALLME_HTTPNOT_2_TXT', 'EGCALLME_HTTPNOT_3_TXT'));
         foreach ($requests as $key => $request) {
             $request = $this->replaceKeywords($param, $request, $texts[$key . '_TXT']);
             $result = file_get_contents($request);
         }
     }
 }
 public function init()
 {
     if (parent::$initialized) {
         return;
     }
     $ret = parent::init();
     // This override is part of the cloudcache module, so the cloudcache.php file exists
     require_once dirname(__FILE__) . '/../../modules/cloudcache/cloudcache.php';
     // As parent::init() set the parent::$initialized flag, all below will be done only once.
     $module = new CloudCache();
     if (!$module->active || !Configuration::get('CLOUDCACHE_API_ACTIVE')) {
         return $ret;
     }
     // Use global because 1.4 only, 1.5 is in an other file
     global $smarty;
     $assignArray = array('img_ps_dir' => _PS_IMG_, 'img_cat_dir' => _THEME_CAT_DIR_, 'img_lang_dir' => _THEME_LANG_DIR_, 'img_prod_dir' => _THEME_PROD_DIR_, 'img_manu_dir' => _THEME_MANU_DIR_, 'img_sup_dir' => _THEME_SUP_DIR_, 'img_ship_dir' => _THEME_SHIP_DIR_, 'img_store_dir' => _THEME_STORE_DIR_, 'img_col_dir' => _THEME_COL_DIR_, 'img_dir' => _THEME_IMG_DIR_, 'css_dir' => _THEME_CSS_DIR_, 'js_dir' => _THEME_JS_DIR_, 'pic_dir' => _THEME_PROD_PIC_DIR_);
     $httHost = Tools::getHttpHost();
     $useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') && Tools::usingSecureMode() ? true : false;
     $protocol_content = $useSSL ? 'https://' : 'http://';
     foreach ($assignArray as $assignKey => $assignValue) {
         if (substr($assignValue, 0, 1) == '/' || $protocol_content == 'https://') {
             $smarty->assign($assignKey, $protocol_content . Tools::getMediaServer($assignValue) . $assignValue);
         } else {
             $smarty->assign($assignKey, $assignValue);
         }
     }
     return $ret;
 }
Example #18
0
    public function display()
    {
        $currentFileName = array_reverse(explode("/", $_SERVER['SCRIPT_NAME']));
        $cronUrl = Tools::getHttpHost(true, true) . __PS_BASE_URI__ . substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -strlen($currentFileName['0'])) . 'searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8);
        list($total, $indexed) = Db::getInstance()->getRow('SELECT COUNT(*) as "0", SUM(indexed) as "1" FROM ' . _DB_PREFIX_ . 'product');
        echo '
		<fieldset>
			<legend><img src="../img/admin/search.gif" alt="" /> ' . $this->l('Indexation') . '</legend>
			<p>
				' . $this->l('The "indexed" products have been analysed by PrestaShop and will appear in the results of the front office search.') . '<br />
				' . $this->l('Indexed products:') . ' <b>' . (int) $indexed . ' / ' . (int) $total . '</b>.
			</p>
			<p>' . $this->l('Building the product index can take a few minutes or more. If your server stop the process before it ends, you can resume the indexation by clicking "Add missing products".') . '</p>
			-&gt; <a href="searchcron.php?token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Add missing products to index.') . '</a><br />
			-&gt; <a href="searchcron.php?full=1&token=' . substr(_COOKIE_KEY_, 34, 8) . '&redirect=1" class="bold">' . $this->l('Re-build entire index.') . '</a><br /><br />
			' . $this->l('You can set a cron job that will re-build your index using the following URL:') . ' <a href="' . $cronUrl . '">' . $cronUrl . '</a>.
		</fieldset>
		<div class="clear">&nbsp;</div>';
        $this->_displayForm('search', $this->_fieldsSearch, $this->l('Search'), 'width2', 'search');
        echo '
		<div class="clear">&nbsp;</div>
		<fieldset>
			<legend><img src="../img/admin/search.gif" alt="" /> ' . $this->l('Relevance') . '</legend>
			' . $this->l('The "weight" represents its importance and relevance for the ranking of the products when try a new search.') . '<br />
			' . $this->l('A word with a weight of 8 will have 4 times more value than a word with a weight of 2.') . '<br /><br />
			' . $this->l('That\'s why we advize to set a greater weight for words which appear in the name or reference of a products than the ones of the description of category name. Thus, the search results will be as precised and releant as possible.') . '
		</fieldset>
		<div class="clear">&nbsp;</div>';
        $this->_displayForm('weight', $this->_fieldsWeight, $this->l('Weight'), 'width2', 'search');
    }
Example #19
0
function shop_url()
{
    if (!($host = Configuration::get('CANONICAL_URL'))) {
        $host = Tools::getHttpHost();
    }
    Configuration::updateValue('PS_SHOP_DOMAIN', $host);
    Configuration::updateValue('PS_SHOP_DOMAIN_SSL', $host);
    return true;
}
Example #20
0
    public function displayForm($isMainTab = true)
    {
        global $cookie, $currentIndex;
        parent::displayForm();
        $currentProfile = (int) Tools::getValue('id_profile');
        if (!$currentProfile) {
            $currentProfile = 1;
        }
        $tabs = Tab::getTabs((int) $cookie->id_lang);
        $profiles = Profile::getProfiles((int) $cookie->id_lang);
        $permissions = Profile::getProfileAccesses((int) $currentProfile);
        echo '
		<form action="' . $currentIndex . '&submitAddPermissions=1&token=' . $this->token . '" id="form_permissions" method="post">
			<input type="hidden" name="id_profile" value="' . (int) $currentProfile . '" />
			<table class="table" cellspacing="0">
				<tr>
					<th ' . ($currentProfile == (int) _PS_ADMIN_PROFILE_ ? 'colspan="6"' : '') . '>' . $this->l('Profile') . '&nbsp;
						<select name="id_profile" onchange="window.location = \'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&id_profile=\'+this.options[this.selectedIndex].value;">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . (int) $profile['id_profile'] . '" ' . ((int) $profile['id_profile'] == $currentProfile ? 'selected="selected"' : '') . '>' . Tools::safeOutput($profile['name']) . '</option>';
            }
        }
        echo '
					</select>
				</th>';
        if ($currentProfile != (int) _PS_ADMIN_PROFILE_) {
            echo '
				<th class="center">' . $this->l('View') . '<br /><input type="checkbox" name="1" id="viewall" /></th>
				<th class="center">' . $this->l('Add') . '<br /><input type="checkbox" name="1" id="addall" /></th>
				<th class="center">' . $this->l('Edit') . '<br /><input type="checkbox" name="1" id="editall" /></th>
				<th class="center">' . $this->l('Delete') . '<br /><input type="checkbox" name="1" id="deleteall" /></th>
				<th class="center">' . $this->l('All') . '<br /><input type="checkbox" name="1" id="allall" /></th>
			</tr>';
        }
        if (!count($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } elseif ($currentProfile == (int) _PS_ADMIN_PROFILE_) {
            echo '<tr><td colspan="5">' . $this->l('Administrator permissions cannot be modified.') . '</td></tr>';
        } else {
            foreach ($tabs as $tab) {
                if (!$tab['id_parent'] || (int) $tab['id_parent'] == -1) {
                    echo $this->printTabAccess((int) $currentProfile, $tab, isset($permissions[(int) $tab['id_tab']]) ? $permissions[(int) $tab['id_tab']] : 0, false);
                    foreach ($tabs as $child) {
                        if ($child['id_parent'] === $tab['id_tab']) {
                            echo $this->printTabAccess($currentProfile, $child, isset($permissions[(int) $child['id_tab']]) ? $permissions[(int) $child['id_tab']] : 0, true);
                        }
                    }
                }
            }
        }
        echo '</table>
			<p><input type="submit" value="' . $this->l('   Save   ') . '" name="submitAddPermissions" class="button" /></p>
		</form>
		<script type="text/javascript">managePermissions();</script>';
    }
Example #21
0
    public function hookTop($params)
    {
        if (!isset($_SERVER['HTTP_REFERER']) || strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false))) {
            return;
        }
        if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER'])) {
            Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'sekeyword` (`keyword`, `date_add`, `id_shop`, `id_shop_group`)
										VALUES (\'' . pSQL(Tools::strtolower(trim($keywords))) . '\', NOW(), ' . (int) $this->context->shop->id . ', ' . (int) $this->context->shop->id_shop_group . ')');
        }
    }
Example #22
0
    public function hookTop($params)
    {
        if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false) == 0)) {
            return;
        }
        if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER'])) {
            Db::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . 'sekeyword` (`keyword`, `date_add`)
			VALUES (\'' . pSQL(Tools::strtolower(trim($keywords))) . '\', NOW())');
        }
    }
 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();
 }
Example #24
0
 private function showError($subject)
 {
     $id_lang = intval($this->_order->id_lang);
     $to = $this->_customer->email;
     $toName = $this->_customer->firstname . ' ' . $this->_customer->lastname;
     $message = new Swift_Message('[' . Configuration::get('PS_SHOP_NAME') . '] ' . $subject);
     $data = array('{lastname}' => $this->_customer->lastname, '{firstname}' => $this->_customer->firstname, '{shop_url}' => 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__, '{shop_name}' => Configuration::get('PS_SHOP_NAME'), '{shop_logo}' => file_exists(_PS_IMG_DIR_ . 'logo.jpg') ? $message->attach(new Swift_Message_Image(new Swift_File(_PS_IMG_DIR_ . 'logo.jpg'))) : '', '{id_order}' => intval($this->_order->id));
     Mail::Send($id_lang, 'payment_error', $subject, $data, $to, $toName);
     // redirect to error with message
     Tools::redirectLink(__PS_BASE_URI__ . 'modules/fondy/result-error.php?message=' . urlencode($subject));
 }
 public static function getShopDomain()
 {
     // use built-in method if found
     if (method_exists('Tools', 'getShopDomain')) {
         return Tools::getShopDomain(true);
     }
     // discover the domain ourselves
     if (!($domain = Configuration::get('PS_SHOP_DOMAIN'))) {
         $domain = Tools::getHttpHost();
     }
     return 'http://' . $domain;
 }
Example #26
0
 /**
  * 
  */
 private function installCarriers()
 {
     $configBase = array('id_tax_rules_group' => 0, 'active' => true, 'deleted' => 0, 'shipping_handling' => false, 'range_behavior' => 0, 'delay' => array("br" => "Entrega pelos Correios."), 'id_zone' => 1, 'is_module' => true, 'shipping_external' => true, 'external_module_name' => $this->_moduleName, 'need_range' => true, 'url' => Tools::getHttpHost(true) . "/modules/correios/rastreio.php?objeto=@");
     $arrayConfigs = array();
     foreach ($this->servicos_todos as $codServico => $servico) {
         $arrayConfigs[] = array("name" => "Correios - {$servico}", "cod_servico" => $codServico);
     }
     foreach ($arrayConfigs as $config) {
         $config = array_merge($configBase, $config);
         $this->installExternalCarrier($config);
     }
 }
Example #27
0
 protected function getDomain()
 {
     $r = '!(?:(\\w+)://)?(?:(\\w+)\\:(\\w+)@)?([^/:]+)?(?:\\:(\\d*))?([^#?]+)?(?:\\?([^#]+))?(?:#(.+$))?!i';
     preg_match($r, Tools::getHttpHost(false, false), $out);
     if (preg_match('/^(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]|[1-9]).)' . '{1}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]).)' . '{2}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]){1}))$/', $out[4])) {
         return false;
     }
     if (!strstr(Tools::getHttpHost(false, false), '.')) {
         return false;
     }
     $domain = $out[4];
     return $domain;
 }
Example #28
0
function displayConfirm()
{
    global $cookie, $smarty, $ppPayment, $cart;
    if (!$cookie->isLogged()) {
        die('Not logged');
    }
    unset($cookie->paypal_token);
    // Display all and exit
    include _PS_ROOT_DIR_ . '/header.php';
    $smarty->assign(array('logo' => $ppPayment->getLogo(), 'cust_currency' => $cookie->id_currency, 'currency' => $ppPayment->getCurrency(), 'total' => $cart->getOrderTotal(true, 3), 'this_path_ssl' => Tools::getHttpHost(true, true) . __PS_BASE_URI__ . 'modules/' . $ppPayment->name . '/', 'mode' => 'payment/'));
    echo $ppPayment->display(_PS_MODULE_DIR_ . 'paypalapi/payment/PaypalPayment.php', '../confirm.tpl');
    include _PS_ROOT_DIR_ . '/footer.php';
    die;
}
Example #29
0
    function hookTop($params)
    {
        if (!isset($_SERVER['HTTP_REFERER']) or strstr($_SERVER['HTTP_REFERER'], Tools::getHttpHost(false, false))) {
            return;
        }
        if (!Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
            return;
        }
        if ($keywords = $this->getKeywords($_SERVER['HTTP_REFERER'])) {
            Db::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . 'sekeyword` (`keyword`,`date_add`)
			VALUES (\'' . pSQL(trim($keywords)) . '\',\'' . pSQL(date('Y-m-d H:i:s')) . '\')');
        }
    }
Example #30
0
    public function displayForm($isMainTab = true)
    {
        global $cookie, $currentIndex;
        parent::displayForm();
        $currentProfile = intval($this->getCurrentProfileId());
        $tabs = Tab::getTabs($cookie->id_lang);
        $profiles = Profile::getProfiles(intval($cookie->id_lang));
        $accesses = Profile::getProfileAccesses(intval($currentProfile));
        echo '
		<script type="text/javascript">
			setLang(Array(\'' . $this->l('Profile updated') . '\', \'' . $this->l('Request failed!') . '\', \'' . $this->l('Updating in progress. Please wait.') . '\', \'' . $this->l('Server connection failed!') . '\'));
		</script>
		<div id="ajax_confirmation"></div>
		<table class="table" cellspacing="0">
			<tr>
				<th>
					<select name="profile" onchange="redirect(\'' . Tools::getHttpHost(true, true) . $currentIndex . '&token=' . $this->token . '&profile=\'+this.options[this.selectedIndex].value)">';
        if ($profiles) {
            foreach ($profiles as $profile) {
                echo '<option value="' . intval($profile['id_profile']) . '" ' . (intval($profile['id_profile']) == $currentProfile ? 'selected="selected"' : '') . '>' . $profile['name'] . '</option>';
            }
        }
        echo '
					</select>
				</th>
				<th>' . $this->l('View') . '</th>
				<th>' . $this->l('Add') . '</th>
				<th>' . $this->l('Edit') . '</th>
				<th>' . $this->l('Delete') . '</th>
			</tr>';
        if (!sizeof($tabs)) {
            echo '<tr><td colspan="5">' . $this->l('No tab') . '</td></tr>';
        } else {
            if ($currentProfile == intval(_PS_ADMIN_PROFILE_)) {
                echo '<tr><td colspan="5">' . $this->l('Administrator permissions can\'t be modified.') . '</td></tr>';
            } else {
                foreach ($tabs as $tab) {
                    if (!$tab['id_parent'] or intval($tab['id_parent']) == -1) {
                        $this->printTabAccess(intval($currentProfile), $tab, $accesses[$tab['id_tab']], false);
                        foreach ($tabs as $child) {
                            if ($child['id_parent'] === $tab['id_tab']) {
                                $this->printTabAccess($currentProfile, $child, $accesses[$child['id_tab']], true);
                            }
                        }
                    }
                }
            }
        }
        echo '</table>';
    }