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 #2
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $urlfeed = strval(Tools::getValue('urlfeed'));
         $title = strval(Tools::getValue('title'));
         $nbr = intval(Tools::getValue('nbr'));
         if ($urlfeed and !Validate::isUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } else {
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->displayForm();
 }
Example #3
0
 /**
  * Resolves an file path for a row
  */
 public function resolveFile($row = array(), $column = '', $default = '')
 {
     if (!empty($column) && array_key_exists($column, $row)) {
         $value = trim($row[$column]);
         if (!empty($value) && Validate::isUrl($row[$column]) !== true) {
             $row[$column] = Server::getBaseUrl($row[$column]);
         }
     }
     return $row;
 }
    /**
     * Check database configuration and try a connection
     *
     * @param string $server
     * @param string $database
     * @param string $login
     * @param string $password
     * @param string $prefix
     * @param string $engine
     * @param bool $clear
     * @return array List of errors
     */
    public function testDatabaseSettings($server, $database, $login, $password, $prefix, $clear = false)
    {
        $errors = array();
        // Check if fields are correctly typed
        if (!$server || !Validate::isUrl($server)) {
            $errors[] = $this->language->l('Server name is not valid');
        }
        if (!$database) {
            $errors[] = $this->language->l('You must enter a database name');
        }
        if (!$login) {
            $errors[] = $this->language->l('You must enter a database login');
        }
        if ($prefix && !Validate::isTablePrefix($prefix)) {
            $errors[] = $this->language->l('Tables prefix is invalid');
        }
        if (!$errors) {
            $dbtype = ' (' . Db::getClass() . ')';
            // Try to connect to database
            switch (Db::checkConnection($server, $login, $password, $database, true)) {
                case 0:
                    if (!Db::checkEncoding($server, $login, $password)) {
                        $errors[] = $this->language->l('Cannot convert database data to utf-8') . $dbtype;
                    }
                    // Check if a table with same prefix already exists
                    if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) {
                        $errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
                    }
                    if (!Db::checkAutoIncrement($server, $login, $password)) {
                        $errors[] = $this->language->l('The values of auto_increment increment and offset must be set to 1');
                    }
                    if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix)) !== true) {
                        $errors[] = $this->language->l(sprintf('Your database login does not have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
                        if ($create_error != false) {
                            $errors[] = $create_error;
                        }
                    }
                    break;
                case 1:
                    $errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields') . $dbtype;
                    break;
                case 2:
                    $error = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database) . $dbtype;
                    if ($this->createDatabase($server, $database, $login, $password, true)) {
                        $error .= '<p>' . sprintf('<input type="button" value="%s" class="button" id="btCreateDB">', $this->language->l('Attempt to create the database automatically')) . '</p>
						<script type="text/javascript">bindCreateDB();</script>';
                    }
                    $errors[] = $error;
                    break;
            }
        }
        return $errors;
    }
Example #5
0
 /**
  * Check database configuration and try a connection
  *
  * @param string $server
  * @param string $database
  * @param string $login
  * @param string $password
  * @param string $prefix
  * @param string $engine
  * @param bool $clear
  * @return array List of errors
  */
 public function testDatabaseSettings($server, $database, $login, $password, $prefix, $engine, $clear = false)
 {
     $errors = array();
     // Check if fields are correctly typed
     if (!$server || !Validate::isUrl($server)) {
         $errors[] = $this->language->l('Server name is not valid');
     }
     if (!$database) {
         $errors[] = $this->language->l('You must enter a database name');
     }
     if (!$login) {
         $errors[] = $this->language->l('You must enter a database login');
     }
     if ($prefix && !Validate::isTablePrefix($prefix)) {
         $errors[] = $this->language->l('Tables prefix is invalid');
     }
     if (!Validate::isMySQLEngine($engine)) {
         $errors[] = $this->language->l('Wrong engine chosen for MySQL');
     }
     if (!$errors) {
         $dbtype = ' (' . Db::getClass() . ')';
         // Try to connect to database
         switch (Db::checkConnection($server, $login, $password, $database, true, $engine)) {
             case 0:
                 if (!Db::checkEncoding($server, $login, $password)) {
                     $errors[] = $this->language->l('Cannot convert database data to utf-8') . $dbtype;
                 }
                 // Check if a table with same prefix already exists
                 if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) {
                     $errors[] = $this->language->l('At least one table with same prefix was already found, please change your prefix or drop your database');
                 }
                 if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix, $engine)) !== true) {
                     $errors[] = $this->language->l(sprintf('Your database login don\'t have the privileges to create table on the database "%s". Ask your hosting provider:', $database));
                     if ($create_error != false) {
                         $errors[] = $create_error;
                     }
                 }
                 break;
             case 1:
                 $errors[] = $this->language->l('Database Server is not found. Please verify the login, password and server fields') . $dbtype;
                 break;
             case 2:
                 $errors[] = $this->language->l('Connection to MySQL server succeeded, but database "%s" not found', $database) . $dbtype;
                 break;
             case 4:
                 $errors[] = $this->language->l('Engine innoDB is not supported by your MySQL server, please use MyISAM') . $dbtype;
                 break;
         }
     }
     return $errors;
 }
Example #6
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $errors = array();
         $urlfeed = strval(Tools::getValue('urlfeed'));
         $title = strval(Tools::getValue('title'));
         $nbr = (int) Tools::getValue('nbr');
         if ($urlfeed and !Validate::isUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } elseif (stristr($urlfeed, $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
             $errors[] = $this->l('You have selected a feed URL on your own website. Please choose another URL');
         } elseif (!($contents = @file_get_contents($urlfeed))) {
             $errors[] = $this->l('Feed is unreachable, check your URL');
         } else {
             try {
                 $xmlFeed = new XML_Feed_Parser($contents);
             } catch (XML_Feed_Parser_Exception $e) {
                 $errors[] = $this->l('Invalid feed:') . ' ' . $e->getMessage();
             }
         }
         if (!sizeof($errors)) {
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         } else {
             $output .= $this->displayError(implode('<br />', $errors));
         }
     } else {
         $errors = array();
         if (stristr(Configuration::get('RSS_FEED_URL'), $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
             $errors[] = $this->l('You have selected a feed URL on your own website. Please choose another URL');
         }
         if (sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         }
     }
     return $output . $this->displayForm();
 }
 public static function logHttpReferer(Cookie $cookie = null)
 {
     if (!$cookie) {
         $cookie = Context::getContext()->cookie;
     }
     if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     // If the referrer is not correct, we drop the connection
     if (isset($_SERVER['HTTP_REFERER']) && !Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         return false;
     }
     // If there is no referrer and we do not want to save direct traffic (as opposed to referral traffic), we drop the connection
     if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     // There are a few more operations if there is a referrer
     if (isset($_SERVER['HTTP_REFERER'])) {
         // If the referrer is internal (i.e. from your own website), then we drop the connection
         $parsed = parse_url($_SERVER['HTTP_REFERER']);
         $parsed_host = parse_url(Tools::getProtocol() . Tools::getHttpHost(false, false) . __PS_BASE_URI__);
         if (!isset($parsed['host']) || (!isset($parsed['path']) || !isset($parsed_host['path']))) {
             return false;
         }
         if (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__))) {
             return false;
         }
         $source->http_referer = substr($_SERVER['HTTP_REFERER'], 0, ConnectionsSource::$uri_max_size);
         $source->keywords = substr(trim(SearchEngine::getKeywords($_SERVER['HTTP_REFERER'])), 0, ConnectionsSource::$uri_max_size);
     }
     $source->id_connections = (int) $cookie->id_connections;
     $source->request_uri = Tools::getHttpHost(false, false);
     if (isset($_SERVER['REQUEST_URI'])) {
         $source->request_uri .= $_SERVER['REQUEST_URI'];
     } elseif (isset($_SERVER['REDIRECT_URL'])) {
         $source->request_uri .= $_SERVER['REDIRECT_URL'];
     }
     if (!Validate::isUrl($source->request_uri)) {
         $source->request_uri = '';
     }
     $source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
     return $source->add();
 }
Example #8
0
 /**
  * checkDB will call to the 
  * 
  * @param string $srv 
  * @param string $login 
  * @param string $password 
  * @param string $name 
  * @param string $posted 
  * @return void
  */
 public static function checkDB($srv, $login, $password, $name, $posted = true)
 {
     // Don't include theses files if classes are already defined
     if (!class_exists('Validate', false)) {
         include_once INSTALL_PATH . '/../classes/Validate.php';
         eval('class Validate extends ValidateCore{}');
     }
     if (!class_exists('Db', false)) {
         include_once INSTALL_PATH . '/../classes/Db.php';
         eval('abstract class Db extends DbCore{}');
     }
     if (!class_exists('MySQL', false)) {
         include_once INSTALL_PATH . '/../classes/MySQL.php';
         eval('class MySQL extends MySQLCore{}');
     }
     if ($posted) {
         // Check POST data...
         $data_check = array(!isset($_GET['server']) or empty($_GET['server']) or !Validate::isUrl($_GET['server']), !isset($_GET['engine']) or empty($_GET['engine']) or !Validate::isMySQLEngine($_GET['engine']), !isset($_GET['name']) or empty($_GET['name']) or !Validate::isUnixName($_GET['name']), !isset($_GET['login']) or empty($_GET['login']) or !Validate::isUnixName($_GET['login']), !isset($_GET['password']), (!isset($_GET['tablePrefix']) or !Validate::isTablePrefix($_GET['tablePrefix'])) && !empty($_GET['tablePrefix']));
         foreach ($data_check as $data) {
             if ($data) {
                 return 8;
             }
         }
     }
     switch (MySQL::tryToConnect(trim($srv), trim($login), trim($password), trim($name))) {
         case 0:
             if (MySQL::tryUTF8(trim($srv), trim($login), trim($password))) {
                 return true;
             }
             return 49;
             break;
         case 1:
             return 25;
             break;
         case 2:
             return 24;
             break;
         case 3:
             return 50;
             break;
     }
 }
Example #9
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($opt = $arguments->getOpt('list-metas', false)) {
         $this->list_metas();
     } elseif ($arguments->getOpt('show-status', false)) {
         $this->show_status();
     } elseif ($baseUri = $arguments->getOpt('base-uri', null)) {
         if (!Validate::isUrl($baseUri)) {
             echo "Error: '{$baseUri}' is not a valid URI\n";
             exit(1);
         }
         $status = $this->update_base_uri($baseUri);
     } else {
         $arguments->show_command_usage('seo');
         exit(1);
     }
     exit(0);
 }
 public static function logHttpReferer(Cookie $cookie = null)
 {
     if (!$cookie) {
         $cookie = Context::getContext()->cookie;
     }
     if (!isset($cookie->id_connections) || !Validate::isUnsignedId($cookie->id_connections)) {
         return false;
     }
     if (!isset($_SERVER['HTTP_REFERER']) && !Configuration::get('TRACKING_DIRECT_TRAFFIC')) {
         return false;
     }
     $source = new ConnectionsSource();
     if (isset($_SERVER['HTTP_REFERER']) && Validate::isAbsoluteUrl($_SERVER['HTTP_REFERER'])) {
         $parsed = parse_url($_SERVER['HTTP_REFERER']);
         $parsed_host = parse_url(Tools::getProtocol() . Tools::getHttpHost(false, false) . __PS_BASE_URI__);
         if (preg_replace('/^www./', '', $parsed['host']) == preg_replace('/^www./', '', Tools::getHttpHost(false, false)) && !strncmp($parsed['path'], $parsed_host['path'], strlen(__PS_BASE_URI__))) {
             return false;
         }
         if (Validate::isAbsoluteUrl(strval($_SERVER['HTTP_REFERER']))) {
             $source->http_referer = substr(strval($_SERVER['HTTP_REFERER']), 0, ConnectionsSource::$uri_max_size);
             $source->keywords = trim(SearchEngine::getKeywords(strval($_SERVER['HTTP_REFERER'])));
             if (!Validate::isMessage($source->keywords)) {
                 return false;
             }
         }
     }
     $source->id_connections = (int) $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)) {
         $source->request_uri = '';
     }
     $source->request_uri = substr($source->request_uri, 0, ConnectionsSource::$uri_max_size);
     return $source->add();
 }
Example #11
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $urlfeed = strval(Tools::getValue('urlfeed'));
         $title = strval(Tools::getValue('title'));
         $nbr = (int) Tools::getValue('nbr');
         if ($urlfeed and !Validate::isUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } else {
             if (stristr($urlfeed, $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
                 $errors[] = $this->l('Error: You have selected a feed URL on your own website. Please choose another URL (eg. http://news.google.com/?output=rss).');
             }
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     } else {
         $errors = array();
         if (stristr(Configuration::get('RSS_FEED_URL'), $_SERVER['HTTP_HOST'] . __PS_BASE_URI__)) {
             $errors[] = $this->l('Error: You have selected a feed URL on your own website. Please choose another URL (eg. http://news.google.com/?output=rss).');
         }
         if (sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         }
     }
     return $output . $this->displayForm();
 }
*  @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
require_once dirname(__FILE__) . '/../../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../../init.php';
if (class_exists('SeurLib') == false) {
    include_once _PS_MODULE_DIR_ . 'seur/classes/SeurLib.php';
}
$token = Tools::getValue('token');
$admin_token = Tools::getAdminToken('AdminSeur' . (int) Tab::getIdFromClassName('AdminSeur') . (int) Tools::getValue('id_employee'));
$admin_token_15 = Tools::getAdminToken('AdminSeur15' . (int) Tab::getIdFromClassName('AdminSeur15') . (int) Tools::getValue('id_employee'));
if ($token != $admin_token && $token != $admin_token_15) {
    exit;
}
$back = Tools::getValue('back');
if (!Validate::isUrl($back)) {
    exit;
}
try {
    $sc_options = array('connection_timeout' => 30);
    $soap_client = new SoapClient((string) Configuration::get('SEUR_URLWS_M'), $sc_options);
    $merchant_data = SeurLib::getMerchantData();
    $data = array('in0' => $merchant_data['nif_dni'], 'in1' => $merchant_data['franchise'], 'in2' => $merchant_data['user'], 'in3' => $merchant_data['pass']);
    $response = $soap_client->generacionPDFDetalleNoFecha($data);
    if ($response->out == 'NO SE PUDIERON RECUPERAR DATOS PARA LA GENERACION DEL MANIFIESTO') {
        $url = $back . '&token=' . urlencode(Tools::getValue('token')) . '&codigo=-1&error=' . urlencode((string) $response->out);
        die(Tools::redirectAdmin($url));
    } elseif ($response->out == 'ERROR USUARIO/PASSWORD ERRONEOS') {
        $url = $back . '&token=' . urlencode(Tools::getValue('token')) . '&codigo=-1&error=' . urlencode((string) $response->out);
        die(Tools::redirectAdmin($url));
    } else {
 public function getContent()
 {
     $this->_html = '';
     // Add a link
     if (Tools::isSubmit('submitLinkAdd')) {
         if (Tools::getValue('text_' . Configuration::get('PS_LANG_DEFAULT')) != true || Tools::getValue('url') != true) {
             $this->_html .= $this->displayError($this->l('You must fill in all fields.'));
         } elseif (!Validate::isUrl(str_replace('http://', '', Tools::getValue('url')))) {
             $this->_html .= $this->displayError($this->l('Bad URL'));
         } else {
             if ($this->addLink()) {
                 $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
             } else {
                 $this->_html .= $this->displayError($this->l('An error occurred during link creation.'));
             }
         }
     } elseif (Tools::isSubmit('submitTitle')) {
         if (Tools::getValue('title_' . Configuration::get('PS_LANG_DEFAULT')) != true) {
             $this->_html .= $this->displayError($this->l('"title" field cannot be empty.'));
         } elseif (!preg_match('/\\b(?:(?:https?|ftp):\\/\\/|www\\.)[-a-z0-9+&@#\\/%?=~_|!:,.;]*[-a-z0-9+&@#\\/%=~_|]/i', Tools::getValue('title_url')) && !preg_match('/#/', Tools::getValue('title_url'))) {
             $this->_html .= $this->displayError($this->l('The \'URL\' field is invalid'));
         } elseif (!Validate::isGenericName(Tools::getValue('title_' . Configuration::get('PS_LANG_DEFAULT')))) {
             $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
         } elseif (!$this->updateTitle()) {
             $this->_html .= $this->displayError($this->l('An error occurred during title updating.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The block title has been updated.'));
         }
     } elseif (Tools::isSubmit('deletetmblocklink1') && Tools::getValue('id')) {
         if (!is_numeric(Tools::getValue('id')) || !$this->deleteLink()) {
             $this->_html .= $this->displayError($this->l('An error occurred during link deletion.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The link has been deleted.'));
         }
     }
     if (Tools::getValue('submitOrderWay') != false) {
         if (Configuration::updateValue('PS_TMBLOCKLINK1_ORDERWAY', (int) Tools::getValue('orderWay'))) {
             $this->_html .= $this->displayConfirmation($this->l('Sort order updated'));
         } else {
             $this->_html .= $this->displayError($this->l('An error occurred during sort order set-up.'));
         }
     }
     $this->_html .= $this->renderForm();
     $this->_html .= $this->renderList();
     return $this->_html;
 }
Example #14
0
 private function _postProcess()
 {
     //Проверяем отправлена ли форма
     if (Tools::isSubmit('submitTutorial')) {
         //Получаем значение поля формы tutorial_url
         $tutorial_url = Tools::getValue('tutorial_url');
         //Проверяем валидность ссылки
         if (Validate::isUrl($tutorial_url)) {
             //Сохраняем настройку
             Configuration::updateValue('TUTORIAL_URL', $tutorial_url);
             //Выводим сообщение об успешном сохранении
             $this->_html .= $this->displayConfirmation($this->l('Настройки обновлены.'));
         } else {
             //Выводим сообщение об ошибке
             $this->_html .= $this->displayError($this->l('Неверная ссылка.'));
         }
     }
     //Проверяем отправлена ли форма с номером каталога
     if (Tools::isSubmit('exportPrintCatalog')) {
         //Получаем значение поля формы num_catalog
         $num_catalog = Tools::getValue('num_catalog');
         //Проверяем валидность номера
         if (Validate::isInt($num_catalog)) {
             //Выполняем запрос
             //SELECT p.id_product, f9.author, pl.name, pl.description, CONCAT_WS(' ',f14.izdat, f10.god, f11.pereplet, f12.stranits, IFNULL(CONCAT('€ ',ROUND(p.price,2)), NULL)) as info, p.reference, /*lcp.id_category, lcp.level_depth,*/ cl.name, /*fp.id_feature, fl.name, fvl.value */
             //SELECT p.id_product, f9.author, pl.name as prod_name, pl.description, CONCAT_WS(' ',f14.izdat, f10.god, f11.pereplet, f12.stranits, IFNULL(CONCAT('€ ',ROUND(p.price,2)), NULL)) as info, p.reference, cl.name as cat_name
             $sql = "\n\t\t\t\t\tSELECT p.id_product, f9.author, pl.name as prod_name, pl.description, f14.izdat, f10.god, f11.pereplet, f12.stranits, p.price, p.reference, cl.name as cat_name\n\t\t\t\t\t\n\t\t\t\t\tFROM " . _DB_PREFIX_ . "product as p\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tON fp.id_product = p.id_product\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_lang AS fl \n\t\t\t\t\tON fl.id_feature = fp.id_feature\n\t\t\t\t\tINNER JOIN \n\t\t\t\t\t" . _DB_PREFIX_ . "feature_value_lang AS fvl \n\t\t\t\t\tON fp.id_feature_value = fvl.id_feature_value\n\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT fp.id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, ','), NULL) as izdat FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 14) as f14\n\t\t\t\t\tON p.id_product = f14.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, '.'), NULL) as god FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 10) as f10\n\t\t\t\t\tON p.id_product = f10.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, '.'), NULL)  as pereplet FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 11) as f11\n\t\t\t\t\tON p.id_product = f11.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, IFNULL(CONCAT(fvl.value, ' с.'), NULL) as stranits FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 12) as f12\n\t\t\t\t\tON p.id_product = f12.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT id_product, fvl.id_feature_value, fvl.value as author FROM\n\t\t\t\t\t" . _DB_PREFIX_ . "feature_product AS fp\n\t\t\t\t\tLEFT JOIN " . _DB_PREFIX_ . "feature_value_lang AS fvl ON fp.id_feature_value = fvl.id_feature_value\n\t\t\t\t\tWHERE fvl.id_lang =1 AND fp.id_feature = 9) as f9\n\t\t\t\t\tON p.id_product = f9.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "product_lang as pl\n\t\t\t\t\tON p.id_product = pl.id_product \n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "category_product as cp\n\t\t\t\t\tON p.id_product = cp.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t(SELECT *\n\t\t\t\t\tFROM (\n\t\t\t\t\tSELECT c.level_depth, c.id_category, cp.id_product\n\t\t\t\t\t    FROM " . _DB_PREFIX_ . "category as c\n\t\t\t\t\t    LEFT JOIN " . _DB_PREFIX_ . "category_product as cp \n\t\t\t\t\t    ON cp.id_category=c.id_category\n\t\t\t\t\tORDER BY level_depth desc\n\t\t\t\t\t) as lcp\n\t\t\t\t\tGROUP BY id_product\n\t\t\t\t\t)as lcp\n\t\t\t\t\tON cp.id_product = lcp.id_product\n\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . _DB_PREFIX_ . "category_lang as cl\n\t\t\t\t\tON lcp.id_category = cl.id_category\n\n\t\t\t\t\tWHERE pl.id_lang = 1 AND pl.id_shop = 1 AND fvl.id_lang =1 AND fp.id_feature = 8 AND fvl.value='" . $num_catalog . "'\n\t\t\t\t\tGROUP BY p.id_product\n\t\t\t\t";
             var_dump($sql);
             if ($results = Db::getInstance()->ExecuteS($sql)) {
                 //Формируем CSV файл и выводим в браузер
                 $delimiter = ";";
                 $tmp_file = dirname(__FILE__) . "/Print_catalog_export.csv";
                 $tmp_url = "http" . (!empty($_SERVER['HTTPS']) ? "s" : "") . "://" . $_SERVER['SERVER_NAME'] . "/modules/" . $this->name . "/Print_catalog_export.csv";
                 $f = fopen($tmp_file, 'w');
                 if ($f === false) {
                     $this->_html .= $this->displayError($this->l('Не удалось записать файл.'));
                     break;
                 } else {
                     $this->tmp_url = '<a href="' . $tmp_url . '">Скачать</a>';
                     $num_products = 0;
                     require_once __DIR__ . '/html2text/lib/Html2Text/Html2Text.php';
                     foreach ($results as $line) {
                         //$line['description'] = convert_html_to_text($line['description']);
                         $this->_html .= $line['description'] . "<br/>";
                         $html2text = new \Html2Text\Html2Text($line['description'], false, array('do_links' => 'none', 'width' => 0));
                         $line['description'] = $html2text->get_text();
                         $id_product = $line['id_product'];
                         $price_withtaxes = Product::getPriceStatic($id_product);
                         $line['price'] = "€ " . $price_withtaxes;
                         fputcsv($f, $line, $delimiter);
                         $num_products++;
                     }
                     fclose($f);
                 }
                 //Выводим сообщение об успешном сохранении
                 $this->_html .= $this->displayConfirmation($this->l('Печатный каталог ' . $num_catalog . ' выгружен. ' . $num_products . ' товаров.'));
             } else {
                 //Выводим сообщение об ошибке
                 $this->_html .= $this->displayError($this->l('Не найдены товары для каталога № ' . $num_catalog . '.'));
             }
         } else {
             //Выводим сообщение об ошибке
             $this->_html .= $this->displayError($this->l('Неверный номер каталога.'));
         }
     }
 }
Example #15
0
 private function _postProcess()
 {
     global $currentIndex, $cookie;
     if (Tools::isSubmit('submitPayPal')) {
         $template_available = array('A', 'B', 'C');
         if (!Validate::isUnsignedInt(Tools::getValue('payment_method')) or (int) Tools::getValue('payment_method') > 2) {
             $this->_errors[] = $this->l('Invalid solution');
         }
         if (Tools::getValue('email_paypal') == NULL and Tools::getValue('api_username') == NULL and Tools::getValue('api_signature') == NULL) {
             $this->_errors[] = $this->l('Indicate account information.');
         }
         if (Tools::getValue('email_paypal') != NULL and !Validate::isEmail(Tools::getValue('email_paypal'))) {
             $this->_errors[] = $this->l('E-mail invalid');
         }
         if (Tools::getValue('banner_url') != NULL and !Validate::isUrl(Tools::getValue('banner_url'))) {
             $this->_errors[] = $this->l('URL for banner is invalid');
         } elseif (Tools::getValue('banner_url') != NULL and strpos(Tools::getValue('banner_url'), 'https://') === false) {
             $this->_errors[] = $this->l('URL for banner must use HTTPS protocol');
         }
         if (!in_array(Tools::getValue('template_paypal'), $template_available)) {
             $this->_errors[] = $this->l('PayPal template invalid.');
         }
         if (Tools::getValue('paypal_capture') == 1 and (Tools::getValue('api_username') == NULL or Tools::getValue('api_signature') == NULL)) {
             $this->_errors[] = $this->l('Cannot use Authorization / capture without API Credentials.');
         }
         if (Tools::getValue('payment_method') == _PAYPAL_INTEGRAL_EVOLUTION_ and (Tools::getValue('api_username') == NULL or Tools::getValue('api_signature') == NULL)) {
             $this->_errors[] = $this->l('Cannot use this solution without API Credentials.');
         }
         if (Tools::isSubmit('paypal_express') and (Tools::getValue('api_username') == NULL or Tools::getValue('api_signature') == NULL)) {
             $this->_errors[] = $this->l('Cannot use PayPal Express without API Credentials.');
         }
         if (!sizeof($this->_errors)) {
             Configuration::updateValue('PAYPAL_SANDBOX', (int) Tools::getValue('sandbox_mode'));
             Configuration::updateValue('PAYPAL_BUSINESS', trim(Tools::getValue('email_paypal')));
             Configuration::updateValue('PAYPAL_HEADER', Tools::getValue('banner_url'));
             Configuration::updateValue('PAYPAL_API_USER', trim(Tools::getValue('api_username')));
             Configuration::updateValue('PAYPAL_API_PASSWORD', trim(Tools::getValue('api_password')));
             Configuration::updateValue('PAYPAL_API_SIGNATURE', trim(Tools::getValue('api_signature')));
             Configuration::updateValue('PAYPAL_EXPRESS_CHECKOUT', (int) Tools::isSubmit('paypal_express'));
             Configuration::updateValue('PAYPAL_DEBUG_MODE', (int) Tools::isSubmit('paypal_debug'));
             Configuration::updateValue('PAYPAL_CAPTURE', (int) Tools::getValue('paypal_capture'));
             Configuration::updateValue('PAYPAL_PAYMENT_METHOD', (int) Tools::getValue('payment_method'));
             Configuration::updateValue('PAYPAL_TEMPLATE', Tools::getValue('template_paypal'));
             if (Tools::getValue('payment_method') == _PAYPAL_INTEGRAL_EVOLUTION_) {
                 $method = 'Paypal Integrale Evolution';
             } elseif (Tools::getValue('payment_method') == _PAYPAL_INTEGRAL_) {
                 $method = 'Paypal Integrale';
             } elseif (Tools::getValue('payment_method') == _PAYPAL_OPTION_PLUS_) {
                 $method = 'Paypal Integrale';
             } else {
                 $method = '';
             }
             $this->_html = $this->displayConfirmation($this->l('Settings updated') . '<img src="http://www.prestashop.com/modules/paypal.png?email=' . urlencode(Tools::getValue('email_paypal')) . '&mode=' . (Tools::getValue('sandbox_mode') ? 0 : 1) . '&method=' . urlencode($method) . '" style="float:right" />');
         } else {
             $error_msg = '';
             foreach ($this->_errors as $error) {
                 $error_msg .= $error . '<br />';
             }
             $this->_html = $this->displayError($error_msg);
         }
     }
     if (Tools::isSubmit('submitPayPalValidation')) {
         if (!($response = $this->_updatePaymentStatusOfOrder((int) Tools::getValue('id_order'))) or !sizeof($response)) {
             $this->_html .= '<p style="color:red;">' . $this->l('Error obtaining payment status.') . '</p>';
         } else {
             if ($response['ACK'] == 'Success') {
                 if ($response['PAYMENTSTATUS'] == 'Completed' or $response['PAYMENTSTATUS'] == 'Reversed' or $response['PAYMENTSTATUS'] == 'Pending' and $response['PENDINGREASON'] == 'authorization') {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=validationOk&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 } else {
                     $this->_html .= '<p><b>' . $this->l('Status') . ':</b> ' . $response['PAYMENTSTATUS'] . ' (' . $this->l('Reason:') . ' ' . $response['PENDINGREASON'] . ')</p>';
                 }
             } else {
                 $this->_html .= '<p style="color:red;">' . $this->l('Error from PayPal: ') . $response['L_LONGMESSAGE0'] . ' (#' . $response['L_ERRORCODE0'] . ')</p>';
             }
         }
     }
     if (Tools::isSubmit('submitPayPalCapture')) {
         if (!($response = $this->_doCapture((int) Tools::getValue('id_order'))) or !sizeof($response)) {
             $this->_html .= '<p style="color:red;">' . $this->l('Error when making capture request') . '</p>';
         } else {
             if ($response['ACK'] == 'Success') {
                 if ($response['PAYMENTSTATUS'] == 'Completed') {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=captureOk&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 } else {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=captureError&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 }
             } else {
                 $this->_html .= '<p style="color:red;">' . $this->l('Error from PayPal: ') . $response['L_LONGMESSAGE0'] . ' (#' . $response['L_ERRORCODE0'] . ')</p>';
             }
         }
     }
     if (Tools::isSubmit('submitPayPalRefund')) {
         if (!($response = $this->_doTotalRefund((int) Tools::getValue('id_order'))) or !sizeof($response)) {
             $this->_html .= '<p style="color:red;">' . $this->l('Error when making refund request') . '</p>';
         } else {
             if ($response['ACK'] == 'Success') {
                 if ($response['REFUNDTRANSACTIONID'] != '') {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=refundOk&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 } else {
                     Tools::redirectAdmin($currentIndex . '&id_order=' . (int) Tools::getValue('id_order') . '&vieworder&paypal=refundError&token=' . Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
                 }
             } else {
                 $this->_html .= '<p style="color:red;">' . $this->l('Error from PayPal: ') . $response['L_LONGMESSAGE0'] . ' (#' . $response['L_ERRORCODE0'] . ')</p>';
             }
         }
     }
 }
Example #16
0
 private function preProcess()
 {
     if (Tools::isSubmit('submitModule')) {
         self::$ID_MERCHANT = Tools::getValue('idMerchant') !== '' ? Tools::getValue('idMerchant') : self::$ID_MERCHANT;
         self::$ACCEPTED_URL = Validate::isUrl(Tools::getValue('acceptedUrl')) ? Tools::getValue('acceptedUrl') : self::$ACCEPTED_URL;
         self::$CANCELLED_URL = Validate::isUrl(Tools::getValue('cancelledUrl')) ? Tools::getValue('cancelledUrl') : self::$CANCELLED_URL;
         self::$TESTING = (int) isset($_POST['testing']);
         self::$MORE_SETTINGS['flexwin_color'] = Tools::getValue('flexwin_color');
         self::$MORE_SETTINGS['logo_color'] = Tools::getValue('logo_color');
         self::$MORE_SETTINGS['k1'] = Tools::getValue('k1');
         self::$MORE_SETTINGS['k2'] = Tools::getValue('k2');
         Configuration::updateValue('DIBS_ID_MERCHANT', self::$ID_MERCHANT);
         Configuration::updateValue('DIBS_ACCEPTED_URL', self::$ACCEPTED_URL);
         Configuration::updateValue('DIBS_CANCELLED_URL', self::$CANCELLED_URL);
         Configuration::updateValue('DIBS_TESTING', self::$TESTING);
         Configuration::updateValue('DIBS_MORE_SETTINGS', Tools::htmlentitiesUTF8(serialize(self::$MORE_SETTINGS)));
         $data_sync = '';
         if (self::$ID_MERCHANT !== '' and self::$TESTING !== 1 and self::$MORE_SETTINGS['k1'] !== '' and self::$MORE_SETTINGS['k2'] !== '') {
             $data_sync = '<img src="http://api.prestashop.com/modules/dibs.png?site_id=' . urlencode(self::$ID_MERCHANT) . '" style="float:right" />';
         }
         return '<div class="conf confirm"><img src="../img/admin/ok.gif"/>' . $this->l('Configuration updated') . $data_sync . '</div>';
     }
     return '';
 }
 function hookTop($params)
 {
     if (strstr($_SERVER['REQUEST_URI'], '404.php') and isset($_SERVER['REDIRECT_URL'])) {
         $_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_URL'];
     }
     if (!Validate::isUrl($request_uri = $_SERVER['REQUEST_URI']) or strstr($_SERVER['REQUEST_URI'], '-admin404')) {
         return;
     }
     if (strstr($_SERVER['PHP_SELF'], '404.php') and !strstr($_SERVER['REQUEST_URI'], '404.php')) {
         $http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
         if (empty($http_referer) or Validate::isAbsoluteUrl($http_referer)) {
             Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'pagenotfound` (`request_uri`,`http_referer`,`date_add`) VALUES (\'' . pSQL($request_uri) . '\',\'' . pSQL($http_referer) . '\',NOW())');
         }
     }
 }
Example #18
0
 public function update_configuration_value($key, $value)
 {
     $interface = PS_CLI_Interface::getInterface();
     $validValue = true;
     switch ($key) {
         case 'PS_MAIL_EMAIL_MESSAGE':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_MAIL_METHOD':
             $validValue = Validate::isUnsignedInt($value) && $value <= 3;
             break;
         case 'PS_MAIL_DOMAIN':
             $validValue = Validate::isUrl($value);
             break;
         case 'PS_MAIL_SERVER':
         case 'PS_MAIL_USER':
             $validValue = Validate::isGenericName($value);
             break;
         case 'PS_MAIL_PASSWD':
             $validValue = Validate::isAnything($value);
             break;
         case 'PS_MAIL_SMTP_ENCRYPTION':
             switch ($value) {
                 case 'off':
                 case 'tls':
                 case 'ssl':
                     $validValue = true;
                     break;
                 default:
                     $validValue = false;
                     break;
             }
             break;
         case 'PS_MAIL_SMTP_PORT':
             $validValue = Validate::isUnsignedInt($value);
             break;
         case 'PS_MAIL_TYPE':
             switch ($value) {
                 case Mail::TYPE_HTML:
                 case Mail::TYPE_TEXT:
                 case Mail::TYPE_BOTH:
                     break;
                 default:
                     $validValue = false;
                     break;
             }
             break;
         case 'PS_SHOP_EMAIL':
             $validValue = Validate::isEmail($value);
             break;
         case 'PS_LOG_EMAILS':
             $validValue = Validate::isBool($value);
             break;
         default:
             $interface->error("the configuration key {$key} is not managed by this plugin !");
             break;
     }
     if (!$validValue) {
         $interface->error("'{$value}' is not a valid value for '{$key}'");
     }
     // all seems ok, update configuration
     if (PS_CLI_Utils::update_configuration_value($key, $value)) {
         $interface->success("Successfully updated configuration {$key}");
     } else {
         $interface->error("Could not update configuration {$key}!");
     }
 }
    public function getContent()
    {
        $this->_html = '<h2>' . $this->displayName . '</h2>
		<script type="text/javascript" src="' . $this->_path . 'blocklink.js"></script>';
        /* Add a link */
        if (isset($_POST['submitLinkAdd'])) {
            if (empty($_POST['text_' . Configuration::get('PS_LANG_DEFAULT')]) or empty($_POST['url'])) {
                $this->_html .= $this->displayError($this->l('You must fill in all fields'));
            } elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url']))) {
                $this->_html .= $this->displayError($this->l('Bad URL'));
            } else {
                if ($this->addLink()) {
                    $this->_html .= $this->displayConfirmation($this->l('The link has been added successfully'));
                } else {
                    $this->_html .= $this->displayError($this->l('An error occured during link creation'));
                }
            }
        } elseif (isset($_POST['submitLinkUpdate'])) {
            if (empty($_POST['text_' . Configuration::get('PS_LANG_DEFAULT')]) or empty($_POST['url'])) {
                $this->_html .= $this->displayError($this->l('You must fill in all fields'));
            } elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url']))) {
                $this->_html .= $this->displayError($this->l('Bad URL'));
            } else {
                if (empty($_POST['id']) or !is_numeric($_POST['id']) or !$this->updateLink()) {
                    $this->_html .= $this->displayError($this->l('An error occured during link updating'));
                } else {
                    $this->_html .= $this->displayConfirmation($this->l('The link has been updated successfully'));
                }
            }
        } elseif (isset($_POST['submitTitle'])) {
            if (empty($_POST['title_' . Configuration::get('PS_LANG_DEFAULT')])) {
                $this->_html .= $this->displayError($this->l('The field "title" can\'t be empty'));
            } elseif (!empty($_POST['title_url']) and !Validate::isUrl(str_replace('http://', '', $_POST['title_url']))) {
                $this->_html .= $this->displayError($this->l('The field "title_url" is invalid'));
            } elseif (!Validate::isGenericName($_POST['title_' . Configuration::get('PS_LANG_DEFAULT')])) {
                $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
            } elseif (!$this->updateTitle()) {
                $this->_html .= $this->displayError($this->l('An error occurred during title updating'));
            } else {
                $this->_html .= $this->displayConfirmation($this->l('The block title has been successfully updated'));
            }
        } elseif (isset($_GET['id'])) {
            if (!is_numeric($_GET['id']) or !$this->deleteLink()) {
                $this->_html .= $this->displayError($this->l('An error occurred during link deletion'));
            } else {
                $this->_html .= $this->displayConfirmation($this->l('The link has been deleted successfully'));
            }
        } elseif (isset($_POST['submitOrderWay'])) {
            if (Configuration::updateValue('PS_BLOCKLINK_ORDERWAY', intval($_POST['orderWay']))) {
                $this->_html .= $this->displayConfirmation($this->l('Sort order successfully updated'));
            } else {
                $this->_html .= $this->displayError($this->l('An error occurred during sort order set-up'));
            }
        }
        $this->_displayForm();
        $this->_list();
        return $this->_html;
    }
Example #20
0
 private function _postValidation()
 {
     $errors = array();
     /* Validation for Slider configuration */
     if (Tools::isSubmit('submitSlider')) {
         if (!Validate::isInt(Tools::getValue('CATESLIDER_SPEED')) || !Validate::isInt(Tools::getValue('CATESLIDER_PAUSE')) || !Validate::isInt(Tools::getValue('CATESLIDER_WIDTH')) || !Validate::isInt(Tools::getValue('CATESLIDER_HEIGHT'))) {
             $errors[] = $this->l('Invalid values');
         }
     } elseif (Tools::isSubmit('changeStatus')) {
         if (!Validate::isInt(Tools::getValue('id_slide'))) {
             $errors[] = $this->l('Invalid slide');
         }
     } elseif (Tools::isSubmit('submitSlide')) {
         /* Checks state (active) */
         if (!Validate::isInt(Tools::getValue('active_slide')) || Tools::getValue('active_slide') != 0 && Tools::getValue('active_slide') != 1) {
             $errors[] = $this->l('Invalid slide state');
         }
         /* Checks position */
         if (!Validate::isInt(Tools::getValue('position')) || Tools::getValue('position') < 0) {
             $errors[] = $this->l('Invalid slide position');
         }
         /* If edit : checks id_slide */
         if (Tools::isSubmit('id_slide')) {
             if (!Validate::isInt(Tools::getValue('id_slide')) && !$this->slideExists(Tools::getValue('id_slide'))) {
                 $errors[] = $this->l('Invalid id_slide');
             }
         }
         /* Checks title/url/legend/description/image */
         $languages = Language::getLanguages(false);
         foreach ($languages as $language) {
             if (Tools::strlen(Tools::getValue('title_' . $language['id_lang'])) > 255) {
                 $errors[] = $this->l('The title is too long.');
             }
             if (Tools::strlen(Tools::getValue('legend_' . $language['id_lang'])) > 255) {
                 $errors[] = $this->l('The legend is too long.');
             }
             if (Tools::strlen(Tools::getValue('url_' . $language['id_lang'])) > 255) {
                 $errors[] = $this->l('The URL is too long.');
             }
             if (Tools::strlen(Tools::getValue('description_' . $language['id_lang'])) > 4000) {
                 $errors[] = $this->l('The description is too long.');
             }
             if (Tools::strlen(Tools::getValue('url_' . $language['id_lang'])) > 0 && !Validate::isUrl(Tools::getValue('url_' . $language['id_lang']))) {
                 $errors[] = $this->l('The URL format is not correct.');
             }
             if (Tools::getValue('image_' . $language['id_lang']) != null && !Validate::isFileName(Tools::getValue('image_' . $language['id_lang']))) {
                 $errors[] = $this->l('Invalid filename');
             }
             if (Tools::getValue('image_old_' . $language['id_lang']) != null && !Validate::isFileName(Tools::getValue('image_old_' . $language['id_lang']))) {
                 $errors[] = $this->l('Invalid filename');
             }
         }
         /* Checks title/url/legend/description for default lang */
         $id_lang_default = (int) Configuration::get('PS_LANG_DEFAULT');
         if (Tools::strlen(Tools::getValue('title_' . $id_lang_default)) == 0) {
             $errors[] = $this->l('The title is not set.');
         }
         if (Tools::strlen(Tools::getValue('legend_' . $id_lang_default)) == 0) {
             $errors[] = $this->l('The legend is not set.');
         }
         if (Tools::strlen(Tools::getValue('url_' . $id_lang_default)) == 0) {
             $errors[] = $this->l('The URL is not set.');
         }
         if (!Tools::isSubmit('has_picture') && (!isset($_FILES['image_' . $id_lang_default]) || empty($_FILES['image_' . $id_lang_default]['tmp_name']))) {
             $errors[] = $this->l('The image is not set.');
         }
         if (Tools::getValue('image_old_' . $id_lang_default) && !Validate::isFileName(Tools::getValue('image_old_' . $id_lang_default))) {
             $errors[] = $this->l('The image is not set.');
         }
     } elseif (Tools::isSubmit('delete_id_slide') && (!Validate::isInt(Tools::getValue('delete_id_slide')) || !$this->slideExists((int) Tools::getValue('delete_id_slide')))) {
         $errors[] = $this->l('Invalid id_slide');
     }
     /* Display errors if needed */
     if (count($errors)) {
         $this->_html .= $this->displayError(implode('<br />', $errors));
         return false;
     }
     /* Returns if validation is ok */
     return true;
 }
Example #21
0
 /**
  *  Perform PagSeguro request and return url from PagSeguro
  *  if ok, $this->module->pagSeguroReturnUrl is created with url returned from Pagseguro
  */
 private function _performPagSeguroRequest()
 {
     try {
         /* Retrieving PagSeguro configurations */
         $this->_retrievePagSeguroConfiguration();
         /* Set PagSeguro Prestashop module version */
         $this->_setPagSeguroModuleVersion();
         /* Set PagSeguro PrestaShop CMS version */
         $this->_setPagSeguroCMSVersion();
         /* Performing request */
         $credentials = new PagSeguroAccountCredentials(Configuration::get('PAGSEGURO_EMAIL'), Configuration::get('PAGSEGURO_TOKEN'));
         $url = $this->_payment_request->register($credentials);
         /* Redirecting to PagSeguro */
         if (Validate::isUrl($url)) {
             Tools::redirectLink(Tools::truncate($url, 255, ''));
         }
     } catch (PagSeguroServiceException $e) {
         die($e->getMessage());
     }
 }
Example #22
0
 public function getContent()
 {
     if (isset($_POST['submitGopay'])) {
         if (empty($_POST['goId'])) {
             $this->_postErrors[] = $this->l('EshopGoID je povinná položka.');
         } elseif (empty($_POST['gopaySecret'])) {
             $this->_postErrors[] = $this->l('Secret je povinná položka.');
         } elseif (empty($_POST['infopageUrl'])) {
             $this->_postErrors[] = $this->l('Info URL je povinná položka.');
         } elseif (!Validate::isUrl($_POST['infopageUrl'])) {
             $this->_postErrors[] = $this->l('Špatný formát Info URL.');
         }
         if (!sizeof($this->_postErrors)) {
             Configuration::updateValue('GOID', strval($_POST['goId']));
             Configuration::updateValue('GOPAY_SECRET', strval($_POST['gopaySecret']));
             Configuration::updateValue('GOPAY_SUCCESS_URL', strval($_POST['successUrl']));
             Configuration::updateValue('GOPAY_FAILED_URL', strval($_POST['failedUrl']));
             Configuration::updateValue('GOPAY_GW_URL', strval($_POST['gwUrl']));
             Configuration::updateValue('GOPAY_WS_URL', strval($_POST['wsUrl']));
             Configuration::updateValue('GOPAY_INFOPAGE_URL', strval($_POST['infopageUrl']));
             Configuration::updateValue('GOPAY_PAY_MODE', strval($_POST['payMode']));
             Configuration::updateValue('GOPAY_PRECONF_METHOD', strval($_POST['preconfMethod']));
             Configuration::updateValue('GOPAY_CUSTOMER_DATA', strval($_POST['customerData']));
             $paymentMethodList = GopaySoap::paymentMethodList();
             for ($i = 0; $i < count($paymentMethodList); $i++) {
                 Configuration::updateValue($paymentMethodList[$i]->code, $_POST[$paymentMethodList[$i]->code]);
             }
             $serverURL = 'http';
             if (isset($_SERVER["HTTPS"])) {
                 if ($_SERVER["HTTPS"] == "on") {
                     $serverURL .= "s";
                 }
             }
             $serverURL .= "://";
             if ($_SERVER["SERVER_PORT"] != "80") {
                 $serverURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
             } else {
                 $serverURL .= $_SERVER["SERVER_NAME"];
             }
             Configuration::updateValue('GOPAY_SUCCESS_URL', $serverURL . __PS_BASE_URI__ . 'modules/gopay/validation.php');
             Configuration::updateValue('GOPAY_FAILED_URL', $serverURL . __PS_BASE_URI__ . '?gp_errors=canceled');
             Configuration::updateValue('GOPAY_INFOPAGE_URL', $serverURL . __PS_BASE_URI__);
             $this->displayConf();
         } else {
             $this->displayErrors();
         }
     }
     $this->displayFormSettings();
     return $this->_html;
 }
Example #23
0
    private function _postProcess()
    {
        $errors = array();
        if (Tools::isSubmit('submitSecuvadEdit')) {
            return false;
        }
        if (Tools::isSubmit('submitSecuvadConfiguration')) {
            if (Tools::getValue('forme') != 'SARL' and Tools::getValue('forme') != 'SA' and Tools::getValue('forme') != 'EURL' and Tools::getValue('forme') != 'SAS' and Tools::getValue('forme') != 'Entreprise individuelle' and Tools::getValue('forme') != 'SNC') {
                $errors[] = $this->l('Company type is invalid');
            }
            if (Tools::getValue('societe') == NULL or !Validate::isName(Tools::getValue('societe'))) {
                $errors[] = $this->l('Company name is invalid');
            }
            if (Tools::getValue('capital') != NULL and !Validate::isGenericName(Tools::getValue('capital'))) {
                $errors[] = $this->l('Capital is invalid');
            }
            if (Tools::getValue('web_site') == NULL or !Validate::isUrl(Tools::getValue('web_site'))) {
                $errors[] = $this->l('WebSite is invalid');
            }
            if (Tools::getValue('address') != NULL and !Validate::isAddress(Tools::getValue('address'))) {
                $errors[] = $this->l('Address is invalid');
            }
            if (Tools::getValue('code_postal') != NULL and !Validate::isPostCode(Tools::getValue('code_postal'))) {
                $errors[] = $this->l('Zip/ Postal Code is invalid');
            }
            if (Tools::getValue('ville') != NULL and !Validate::isCityName(Tools::getValue('ville'))) {
                $errors[] = $this->l('City is invalid');
            }
            if (Tools::getValue('pays') != NULL and !Validate::isCountryName(Tools::getValue('pays'))) {
                $errors[] = $this->l('Country is invalid');
            }
            if (Tools::getValue('rcs') != NULL and !Validate::isGenericName(Tools::getValue('rcs'))) {
                $errors[] = $this->l('RCS is invalid');
            }
            if (Tools::getValue('siren') != NULL and !Validate::isGenericName(Tools::getValue('siren'))) {
                $errors[] = $this->l('Siren is invalid');
            }
            if (!is_array(Tools::getValue('categories')) or !sizeof(Tools::getValue('categories'))) {
                $errors[] = $this->l('You must select at least one category.');
            }
            if (Tools::getValue('civilite') != 'M' and Tools::getValue('civilite') != 'Mme' and Tools::getValue('civilite') != 'Mlle') {
                $errors[] = $this->l('Title is invalid');
            }
            if (Tools::getValue('nom') == NULL or !Validate::isName(Tools::getValue('nom'))) {
                $errors[] = $this->l('Last name is invalid');
            }
            if (Tools::getValue('prenom') == NULL or !Validate::isName(Tools::getValue('prenom'))) {
                $errors[] = $this->l('First name is invalid');
            }
            if (Tools::getValue('fonction') != NULL and !Validate::isGenericName(Tools::getValue('fonction'))) {
                $errors[] = $this->l('Function name is invalid');
            }
            if (Tools::getValue('email') == NULL or !Validate::isEmail(Tools::getValue('email'))) {
                $errors[] = $this->l('E-mail name is invalid');
            }
            if (Tools::getValue('telephone') == NULL or !Validate::isPhoneNumber(Tools::getValue('telephone'))) {
                $errors[] = $this->l('Telephone is invalid');
            }
            if (!sizeof($errors)) {
                return true;
            } else {
                $this->_html .= $this->displayError(implode('<br />', $errors));
                return false;
            }
        }
        if (Tools::isSubmit('submitSecuvadPostConfiguration')) {
            $errors = array();
            if (!Validate::isGenericName(Tools::getValue('secuvad_login'))) {
                $errors[] = $this->l('Invalid login');
            }
            if (!Validate::isGenericName(Tools::getValue('secuvad_password'))) {
                $errors[] = $this->l('Invalid password');
            }
            if (!in_array(Tools::getValue('secuvad_mode'), $this->_allowed_modes)) {
                $errors[] = $this->l('Invalid Mode');
            }
            if (!Validate::isInt(Tools::getValue('secuvad_id'))) {
                $errors[] = $this->l('Invalid ID');
            }
            if (!sizeof($errors)) {
                // update configuration
                Configuration::updateValue('SECUVAD_LOGIN', Tools::getValue('secuvad_login'));
                Configuration::updateValue('SECUVAD_MDP', Tools::getValue('secuvad_password'));
                Configuration::updateValue('SECUVAD_MODE', Tools::getValue('secuvad_mode'));
                Configuration::updateValue('SECUVAD_ID', Tools::getValue('secuvad_id'));
                Configuration::updateValue('SECUVAD_ACTIVATION', 1);
                $this->_html .= $this->displayConfirmation($this->l('Settings are updated') . '<img src="http://www.prestashop.com/modules/secuvad.png?id=' . urlencode(Tools::getValue('secuvad_id')) . '&login='******'secuvad_login')) . '&mode=' . (Tools::getValue('secuvad_mode') == 'TEST' ? 0 : 1) . '" style="float:right" />');
            } else {
                $this->_html .= $this->displayError(implode('<br />', $errors));
            }
        }
        if (Tools::isSubmit('submitSecuvadCategory')) {
            Db::getInstance()->Execute('
			DELETE FROM `' . _DB_PREFIX_ . 'secuvad_assoc_category`
			');
            $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'secuvad_assoc_category` VALUES';
            foreach ($_POST as $k => $category_id) {
                if (preg_match('/secuvad_cat_([0-9]+)$/Ui', $k, $result)) {
                    $id_category = $result[1];
                    $sql .= '(NULL, ' . (int) $id_category . ', ' . (int) $category_id . '),';
                }
            }
            $sql = rtrim($sql, ',');
            if (Db::getInstance()->Execute($sql)) {
                $this->_html .= $this->displayConfirmation($this->l('Settings are updated'));
            } else {
                $this->_html .= $this->displayError($this->l('Error during update'));
            }
        }
        if (Tools::isSubmit('submitSecuvadPayment')) {
            Db::getInstance()->Execute('
			DELETE FROM `' . _DB_PREFIX_ . 'secuvad_assoc_payment`
			');
            $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'secuvad_assoc_payment` VALUES';
            foreach ($_POST as $k => $code) {
                if (preg_match('/secuvad_payment_([0-9]+)$/Ui', $k, $result)) {
                    $id_module = $result[1];
                    $sql .= '(NULL, ' . (int) $id_module . ', \'' . pSQL($code) . '\'),';
                }
            }
            $sql = rtrim($sql, ',');
            if (Db::getInstance()->Execute($sql)) {
                $this->_html .= $this->displayConfirmation($this->l('Settings are updated'));
            } else {
                $this->_html .= $this->displayError($this->l('Error during update'));
            }
        }
        if (Tools::isSubmit('submitSecuvadCarrier')) {
            Db::getInstance()->Execute('
			DELETE FROM `' . _DB_PREFIX_ . 'secuvad_assoc_transport`
			');
            $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'secuvad_assoc_transport` VALUES';
            foreach ($_POST as $k => $value) {
                if (preg_match('/secuvad_carrier_type_([0-9]+)$/Ui', $k, $result)) {
                    $id_carrier = $result[1];
                    $sql .= '(NULL, ' . (int) $id_carrier . ', ' . (int) $value . ', ' . (int) $_POST['secuvad_carrier_delay_' . (int) $id_carrier] . '),';
                }
            }
            $sql = rtrim($sql, ',');
            if (Db::getInstance()->Execute($sql)) {
                $this->_html .= $this->displayConfirmation($this->l('Settings are updated'));
            } else {
                $this->_html .= $this->displayError($this->l('Error during update'));
            }
        }
    }
 private function processFormsUpdate()
 {
     $_html = "";
     if (Tools::isSubmit('submitUpdate' . $this->name)) {
         if (Tools::getIsset(PKHelper::CPREFIX . 'HOST')) {
             $tmp = Tools::getValue(PKHelper::CPREFIX . 'HOST', '');
             if (!empty($tmp)) {
                 if (Validate::isUrl($tmp) || Validate::isUrl('http://' . $tmp)) {
                     $tmp = str_replace(array('http://', 'https://', '//'), "", $tmp);
                     if (substr($tmp, -1) != "/") {
                         $tmp .= "/";
                     }
                     Configuration::updateValue(PKHelper::CPREFIX . 'HOST', $tmp);
                 } else {
                     $_html .= $this->displayError($this->l('Piwik host url is not valid'));
                 }
             } else {
                 $_html .= $this->displayError($this->l('Piwik host cannot be empty'));
             }
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'SITEID')) {
             $tmp = (int) Tools::getValue(PKHelper::CPREFIX . 'SITEID', 0);
             Configuration::updateValue(PKHelper::CPREFIX . 'SITEID', $tmp);
             if ($tmp <= 0) {
                 $_html .= $this->displayError($this->l('Piwik site id is lower or equal to "0"'));
             }
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'TOKEN_AUTH')) {
             $tmp = Tools::getValue(PKHelper::CPREFIX . 'TOKEN_AUTH', '');
             Configuration::updateValue(PKHelper::CPREFIX . 'TOKEN_AUTH', $tmp);
             if (empty($tmp)) {
                 $_html .= $this->displayError($this->l('Piwik auth token is empty'));
             }
         }
         /* setReferralCookieTimeout */
         if (Tools::getIsset(PKHelper::CPREFIX . 'RCOOKIE_TIMEOUT')) {
             // the default is 6 months
             $tmp = (int) Tools::getValue(PKHelper::CPREFIX . 'RCOOKIE_TIMEOUT', self::PK_RC_TIMEOUT);
             $tmp = (int) ($tmp * 60);
             //* convert to seconds
             Configuration::updateValue(PKHelper::CPREFIX . 'RCOOKIE_TIMEOUT', $tmp);
         }
         /* setVisitorCookieTimeout */
         if (Tools::getIsset(PKHelper::CPREFIX . 'COOKIE_TIMEOUT')) {
             // the default is 13 months
             $tmp = (int) Tools::getValue(PKHelper::CPREFIX . 'COOKIE_TIMEOUT', self::PK_VC_TIMEOUT);
             $tmp = (int) ($tmp * 60);
             //* convert to seconds
             Configuration::updateValue(PKHelper::CPREFIX . 'COOKIE_TIMEOUT', $tmp);
         }
         /* setSessionCookieTimeout */
         if (Tools::getIsset(PKHelper::CPREFIX . 'SESSION_TIMEOUT')) {
             // the default is 30 minutes
             $tmp = (int) Tools::getValue(PKHelper::CPREFIX . 'SESSION_TIMEOUT', self::PK_SC_TIMEOUT);
             $tmp = (int) ($tmp * 60);
             //* convert to seconds
             Configuration::updateValue(PKHelper::CPREFIX . 'SESSION_TIMEOUT', $tmp);
         }
         /*
          * @todo VALIDATE!!!, YES VALIDATE!!! thank you ...
          */
         if (Tools::getIsset(PKHelper::CPREFIX . 'USE_PROXY')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'USE_PROXY', Tools::getValue(PKHelper::CPREFIX . 'USE_PROXY'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'USE_CURL')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'USE_CURL', Tools::getValue(PKHelper::CPREFIX . 'USE_CURL'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'EXHTML')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'EXHTML', Tools::getValue(PKHelper::CPREFIX . 'EXHTML'), TRUE);
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'COOKIE_DOMAIN')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'COOKIE_DOMAIN', Tools::getValue(PKHelper::CPREFIX . 'COOKIE_DOMAIN'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'SET_DOMAINS')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'SET_DOMAINS', Tools::getValue(PKHelper::CPREFIX . 'SET_DOMAINS'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'DNT')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'DNT', Tools::getValue(PKHelper::CPREFIX . 'DNT', 0));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'PROXY_SCRIPT')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'PROXY_SCRIPT', str_replace(array("http://", "https://", '//'), '', Tools::getValue(PKHelper::CPREFIX . 'PROXY_SCRIPT')));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'CRHTTPS')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'CRHTTPS', Tools::getValue(PKHelper::CPREFIX . 'CRHTTPS', 0));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'PRODID_V1')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'PRODID_V1', Tools::getValue(PKHelper::CPREFIX . 'PRODID_V1', '{ID}-{ATTRID}#{REFERENCE}'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'PRODID_V2')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'PRODID_V2', Tools::getValue(PKHelper::CPREFIX . 'PRODID_V2', '{ID}#{REFERENCE}'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'PRODID_V3')) {
             Configuration::updateValue(PKHelper::CPREFIX . 'PRODID_V3', Tools::getValue(PKHelper::CPREFIX . 'PRODID_V3', '{ID}#{ATTRID}'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'DEFAULT_CURRENCY')) {
             Configuration::updateValue(PKHelper::CPREFIX . "DEFAULT_CURRENCY", Tools::getValue(PKHelper::CPREFIX . 'DEFAULT_CURRENCY', 'EUR'));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'USRNAME')) {
             Configuration::updateValue(PKHelper::CPREFIX . "USRNAME", Tools::getValue(PKHelper::CPREFIX . 'USRNAME', ''));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'USRPASSWD') && Tools::getValue(PKHelper::CPREFIX . 'USRPASSWD', '') != "") {
             Configuration::updateValue(PKHelper::CPREFIX . "USRPASSWD", Tools::getValue(PKHelper::CPREFIX . 'USRPASSWD', Configuration::get(PKHelper::CPREFIX . 'USRPASSWD')));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'PAUTHUSR')) {
             Configuration::updateValue(PKHelper::CPREFIX . "PAUTHUSR", Tools::getValue(PKHelper::CPREFIX . 'PAUTHUSR', ''));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'PAUTHPWD') && Tools::getValue(PKHelper::CPREFIX . 'PAUTHPWD', '') != "") {
             Configuration::updateValue(PKHelper::CPREFIX . "PAUTHPWD", Tools::getValue(PKHelper::CPREFIX . 'PAUTHPWD', Configuration::get(PKHelper::CPREFIX . 'PAUTHPWD')));
         }
         if (Tools::getIsset(PKHelper::CPREFIX . 'DREPDATE')) {
             Configuration::updateValue(PKHelper::CPREFIX . "DREPDATE", Tools::getValue(PKHelper::CPREFIX . 'DREPDATE', 'day|tody'));
         }
         $_html .= $this->displayConfirmation($this->l('Configuration Updated'));
     }
     return $_html;
 }
Example #25
0
 /**
  * Check url validity (allowed empty string)
  *
  * @param string $url Url to validate
  * @return boolean Validity is ok or not
  */
 public static function isUrlOrEmpty($url)
 {
     return empty($url) || Validate::isUrl($url);
 }
 public function validateSettings()
 {
     if (!Tools::getValue(DpdPolandConfiguration::LOGIN)) {
         self::$errors[] = $this->l('Login can not be empty');
     }
     if (!Tools::getValue(DpdPolandConfiguration::PASSWORD)) {
         self::$errors[] = $this->l('Password can not be empty');
     } elseif (!Validate::isPasswd(Tools::getValue(DpdPolandConfiguration::PASSWORD))) {
         self::$errors[] = $this->l('Password is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::CLIENT_NUMBER)) {
         self::$errors[] = $this->l('Default client number must be set');
     }
     if (!Tools::getValue(DpdPolandConfiguration::COMPANY_NAME)) {
         self::$errors[] = $this->l('Company name can not be empty');
     } elseif (!Validate::isLabel(Tools::getValue(DpdPolandConfiguration::COMPANY_NAME))) {
         self::$errors[] = $this->l('Company name is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::NAME_SURNAME)) {
         self::$errors[] = $this->l('Name and Surname can not be empty');
     } elseif (!Validate::isName(Tools::getValue(DpdPolandConfiguration::NAME_SURNAME))) {
         self::$errors[] = $this->l('Name and surname are not valid. Please use only letters and separate first name from last name with white space.');
     }
     if (!Tools::getValue(DpdPolandConfiguration::ADDRESS)) {
         self::$errors[] = $this->l('Address can not be empty');
     } elseif (!Validate::isAddress(Tools::getValue(DpdPolandConfiguration::ADDRESS))) {
         self::$errors[] = $this->l('Address is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::POSTCODE)) {
         self::$errors[] = $this->l('Postal code not be empty');
     } elseif (!Validate::isPostCode(Tools::getValue(DpdPolandConfiguration::POSTCODE))) {
         self::$errors[] = $this->l('Postal code is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::CITY)) {
         self::$errors[] = $this->l('City can not be empty');
     } elseif (!Validate::isCityName(Tools::getValue(DpdPolandConfiguration::CITY))) {
         self::$errors[] = $this->l('City is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::EMAIL)) {
         self::$errors[] = $this->l('Email can not be empty');
     } elseif (!Validate::isEmail(Tools::getValue(DpdPolandConfiguration::EMAIL))) {
         self::$errors[] = $this->l('Email is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::PHONE)) {
         self::$errors[] = $this->l('Tel. No. can not be empty');
     } elseif (!Validate::isPhoneNumber(Tools::getValue(DpdPolandConfiguration::PHONE))) {
         self::$errors[] = $this->l('Tel. No. is not valid');
     }
     if (Tools::isSubmit(DpdPolandConfiguration::CARRIER_STANDARD_COD)) {
         $checked = false;
         foreach (DpdPoland::getPaymentModules() as $payment_module) {
             if (Tools::isSubmit(DpdPolandConfiguration::COD_MODULE_PREFIX . $payment_module['name'])) {
                 $checked = true;
             }
         }
         if (!$checked) {
             self::$errors[] = $this->l('At least one COD payment method must be checked');
         }
     }
     if (!Tools::getValue(DpdPolandConfiguration::WEIGHT_CONVERSATION_RATE)) {
         self::$errors[] = $this->l('Weight conversation rate can not be empty');
     } elseif (!Validate::isUnsignedFloat(Tools::getValue(DpdPolandConfiguration::WEIGHT_CONVERSATION_RATE))) {
         self::$errors[] = $this->l('Weight conversation rate is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::DIMENSION_CONVERSATION_RATE)) {
         self::$errors[] = $this->l('Dimension conversation rate can not be empty');
     } elseif (!Validate::isUnsignedFloat(Tools::getValue(DpdPolandConfiguration::DIMENSION_CONVERSATION_RATE))) {
         self::$errors[] = $this->l('Dimension conversation rate is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_COMPANY)) {
         self::$errors[] = $this->l('Customer company name can not be empty');
     } elseif (!Validate::isLabel(Tools::getValue(DpdPolandConfiguration::CUSTOMER_COMPANY))) {
         self::$errors[] = $this->l('Customer company name is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_NAME)) {
         self::$errors[] = $this->l('Customer name and surname can not be empty');
     } elseif (!Validate::isName(Tools::getValue(DpdPolandConfiguration::CUSTOMER_NAME))) {
         self::$errors[] = $this->l('Customer name and surname is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_PHONE)) {
         self::$errors[] = $this->l('Customer tel. No. can not be empty');
     } elseif (!Validate::isPhoneNumber(Tools::getValue(DpdPolandConfiguration::CUSTOMER_PHONE))) {
         self::$errors[] = $this->l('Customer tel. No. is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::CUSTOMER_FID)) {
         self::$errors[] = $this->l('Customer FID can not be empty');
     } elseif (!ctype_alnum(Tools::getValue(DpdPolandConfiguration::CUSTOMER_FID))) {
         self::$errors[] = $this->l('Customer FID is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::MASTER_FID)) {
         self::$errors[] = $this->l('Master FID can not be empty');
     } elseif (!ctype_alnum(Tools::getValue(DpdPolandConfiguration::MASTER_FID))) {
         self::$errors[] = $this->l('Master FID is not valid');
     }
     if (!Tools::getValue(DpdPolandConfiguration::WS_URL)) {
         self::$errors[] = $this->l('Web Services URL can not be empty');
     } elseif (!Validate::isUrl(Tools::getValue(DpdPolandConfiguration::WS_URL))) {
         self::$errors[] = $this->l('Web Services URL is not valid');
     }
 }
 public function getContent()
 {
     $this->_html = '';
     // Add a link
     if (Tools::isSubmit('submitLinkAdd')) {
         if (empty($_POST['text_' . Configuration::get('PS_LANG_DEFAULT')]) || empty($_POST['url'])) {
             $this->_html .= $this->displayError($this->l('You must fill in all fields.'));
         } elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url']))) {
             $this->_html .= $this->displayError($this->l('Bad URL'));
         } else {
             if ($this->addLink()) {
                 $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
             } else {
                 $this->_html .= $this->displayError($this->l('An error occurred during link creation.'));
             }
         }
     } elseif (Tools::isSubmit('submitTitle')) {
         if (empty($_POST['title_' . Configuration::get('PS_LANG_DEFAULT')])) {
             $this->_html .= $this->displayError($this->l('"title" field cannot be empty.'));
         } elseif (!empty($_POST['title_url']) && !Validate::isUrl(str_replace('http://', '', $_POST['title_url']))) {
             $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
         } elseif (!Validate::isGenericName($_POST['title_' . Configuration::get('PS_LANG_DEFAULT')])) {
             $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
         } elseif (!$this->updateTitle()) {
             $this->_html .= $this->displayError($this->l('An error occurred during title updating.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The block title has been updated.'));
         }
     } elseif (Tools::isSubmit('deleteblocklink') && Tools::getValue('id')) {
         if (!is_numeric(Tools::getValue('id')) || !$this->deleteLink()) {
             $this->_html .= $this->displayError($this->l('An error occurred during link deletion.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The link has been deleted.'));
         }
     }
     if (isset($_POST['submitOrderWay'])) {
         if (Configuration::updateValue('PS_BLOCKLINK_ORDERWAY', (int) Tools::getValue('orderWay'))) {
             $this->_html .= $this->displayConfirmation($this->l('Sort order updated'));
         } else {
             $this->_html .= $this->displayError($this->l('An error occurred during sort order set-up.'));
         }
     }
     $this->_html .= $this->renderForm();
     $this->_html .= $this->renderList();
     return $this->_html;
 }
Example #28
0
 public function getContent()
 {
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     // Add a link
     if (Tools::isSubmit('submitLinkAdd')) {
         if (empty($_POST['text_' . Configuration::get('PS_LANG_DEFAULT')]) || empty($_POST['url_' . Configuration::get('PS_LANG_DEFAULT')])) {
             $this->_html .= $this->displayError($this->l('You must fill in all fields'));
         } elseif (!Validate::isUrl(str_replace('http://', '', $_POST['url_' . Configuration::get('PS_LANG_DEFAULT')]))) {
             $this->_html .= $this->displayError($this->l('Bad URL'));
         } else {
             if ($this->addLink()) {
                 $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
             } else {
                 $this->_html .= $this->displayError($this->l('An error occurred during link creation.'));
             }
         }
         $this->_clearCache('headerlinks.tpl');
     } elseif (Tools::isSubmit('submitTitle')) {
         $this->_clearCache('headerlinks.tpl');
         if (!Validate::isGenericName($_POST['title_' . Configuration::get('PS_LANG_DEFAULT')])) {
             $this->_html .= $this->displayError($this->l('The \'title\' field is invalid'));
         } elseif (!$this->updateTitle()) {
             $this->_html .= $this->displayError($this->l('An error occurred during title updating.'));
         } else {
             Configuration::updateValue('PS_headerlinks_contact', (int) Tools::getValue("contactlink"));
             Configuration::updateValue('PS_headerlinks_sitemap', (int) Tools::getValue("sitemaplink"));
             $this->_html .= $this->displayConfirmation($this->l('The block title has been updated.'));
         }
     } elseif (Tools::isSubmit('deleteheaderlinks') && Tools::getValue('id')) {
         $this->_clearCache('headerlinks.tpl');
         if (!is_numeric($_GET['id']) || !$this->deleteLink()) {
             $this->_html .= $this->displayError($this->l('An error occurred during link deletion.'));
         } else {
             $this->_html .= $this->displayConfirmation($this->l('The link has been deleted.'));
         }
     }
     if (isset($_POST['submitOrderWay'])) {
         $this->_clearCache('headerlinks.tpl');
         if (Configuration::updateValue('PS_headerlinks_ORDERWAY', (int) Tools::getValue('orderWay'))) {
             $this->_html .= $this->displayConfirmation($this->l('Sort order updated'));
         } else {
             $this->_html .= $this->displayError($this->l('An error occurred during sort order set-up.'));
         }
     }
     $this->_html .= $this->renderForm();
     $this->_html .= $this->renderList();
     return $this->_html;
 }
Example #29
0
 protected function canonicalRedirection($canonical_url = '')
 {
     if (!$canonical_url || !Configuration::get('PS_CANONICAL_REDIRECT') || strtoupper($_SERVER['REQUEST_METHOD']) != 'GET' || Tools::getValue('live_edit')) {
         return;
     }
     $match_url = rawurldecode(Tools::getCurrentUrlProtocolPrefix() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     if (!preg_match('/^' . Tools::pRegexp(rawurldecode($canonical_url), '/') . '([&?].*)?$/', $match_url)) {
         $params = array();
         $str_params = '';
         $url_details = parse_url($canonical_url);
         if (!empty($url_details['query'])) {
             parse_str($url_details['query'], $query);
             foreach ($query as $key => $value) {
                 $params[Tools::safeOutput($key)] = Tools::safeOutput($value);
             }
         }
         $excluded_key = array('isolang', 'id_lang', 'controller', 'fc', 'id_product', 'id_category', 'id_manufacturer', 'id_supplier', 'id_cms');
         foreach ($_GET as $key => $value) {
             if (!in_array($key, $excluded_key) && Validate::isUrl($key) && Validate::isUrl($value)) {
                 $params[Tools::safeOutput($key)] = Tools::safeOutput($value);
             }
         }
         $str_params = http_build_query($params, '', '&');
         if (!empty($str_params)) {
             $final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url) . '?' . $str_params;
         } else {
             $final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url);
         }
         // Don't send any cookie
         Context::getContext()->cookie->disallowWriting();
         if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__) {
             die('[Debug] This page has moved<br />Please use the following URL instead: <a href="' . $final_url . '">' . $final_url . '</a>');
         }
         $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302';
         header('HTTP/1.0 ' . $redirect_type . ' Moved');
         header('Cache-Control: no-cache');
         Tools::redirectLink($final_url);
     }
 }
    public function hookTop($params)
    {
        if (strstr($_SERVER['REQUEST_URI'], '404.php') && isset($_SERVER['REDIRECT_URL'])) {
            $_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_URL'];
        }
        if (!Validate::isUrl($request_uri = $_SERVER['REQUEST_URI']) || strstr($_SERVER['REQUEST_URI'], '-admin404')) {
            return;
        }
        if (get_class(Context::getContext()->controller) == 'PageNotFoundController') {
            $http_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
            if (empty($http_referer) || Validate::isAbsoluteUrl($http_referer)) {
                Db::getInstance()->execute('
										INSERT INTO `' . _DB_PREFIX_ . 'pagenotfound` (`request_uri`, `http_referer`, `date_add`, `id_shop`, `id_shop_group`)
					VALUES (\'' . pSQL($request_uri) . '\', \'' . pSQL($http_referer) . '\', NOW(), ' . (int) $this->context->shop->id . ', ' . (int) $this->context->shop->id_shop_group . ')
				');
            }
        }
    }