diff --git a/1DB_changes/okay_clean.sql b/1DB_changes/okay_clean.sql index 3e21bb52..5bfd5b59 100644 --- a/1DB_changes/okay_clean.sql +++ b/1DB_changes/okay_clean.sql @@ -6,7 +6,6 @@ CREATE TABLE `ok_banners` ( `id` int(11) NOT NULL AUTO_INCREMENT, `group_id` varchar(32) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '', - `description` text NOT NULL, `position` int(11) NOT NULL DEFAULT '0', `visible` tinyint(1) NOT NULL DEFAULT '1', `show_all_pages` tinyint(1) NOT NULL DEFAULT '0', @@ -22,8 +21,8 @@ CREATE TABLE `ok_banners` ( KEY `brands` (`brands`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `ok_banners` (`id`, `group_id`, `name`, `description`, `position`, `visible`, `show_all_pages`, `categories`, `pages`, `brands`) VALUES -(1, 'group1', 'Главный баннер', '', 1, 1, 0, '0', '1', '0'); +INSERT INTO `ok_banners` (`id`, `group_id`, `name`, `position`, `visible`, `show_all_pages`, `categories`, `pages`, `brands`) VALUES +(1, 'group1', 'Главный баннер', 1, 1, 0, '0', '1', '0'); DROP TABLE IF EXISTS `ok_banners_images`; CREATE TABLE `ok_banners_images` ( @@ -3885,15 +3884,16 @@ CREATE TABLE `ok_orders_status` ( `is_close` tinyint(1) NOT NULL DEFAULT '0', `color` varchar(6) NOT NULL DEFAULT 'ffffff', `position` int(11) NOT NULL DEFAULT '0', + `status_1c` enum('not_use', 'new','accepted','to_delete') NULL DEFAULT 'not_use', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `ok_orders_status` (`id`, `name`, `is_close`, `color`, `position`) VALUES -(1, 'Новые', 0, '2015eb', 1), -(2, 'Приняты', 1, '2ccc1a', 2), -(3, 'У курьера', 1, 'ffd000', 3), -(4, 'Выполнены', 1, 'c400ff', 4), -(5, 'Удалены', 0, 'eb1212', 5); +INSERT INTO `ok_orders_status` (`id`, `name`, `is_close`, `color`, `position`, `status_1c`) VALUES +(1, 'Новые', 0, '2015eb', 1, 'new'), +(2, 'Приняты', 1, '2ccc1a', 2, 'accepted'), +(3, 'У курьера', 1, 'ffd000', 3, 'not_use'), +(4, 'Выполнены', 1, 'c400ff', 4, 'not_use'), +(5, 'Удалены', 0, 'eb1212', 5, 'to_delete'); DROP TABLE IF EXISTS `ok_pages`; CREATE TABLE `ok_pages` ( @@ -5765,7 +5765,8 @@ INSERT INTO `ok_settings` (`setting_id`, `param`, `value`) VALUES (161, 'max_filter_filter', '1'), (162, 'max_filter_features_values', '1'), (163, 'max_filter_features', '1'), -(164, 'max_filter_depth', '1'); +(164, 'max_filter_depth', '1'), +(200, 'recaptcha_scores', 'a:3:{s:7:\"product\";d:0.5;s:4:\"cart\";d:0.69999999999999996;s:5:\"other\";d:0.20000000000000001;}'); DROP TABLE IF EXISTS `ok_settings_lang`; CREATE TABLE `ok_settings_lang` ( diff --git a/1DB_changes/update_2.3.3.sql b/1DB_changes/update_2.3.3.sql new file mode 100644 index 00000000..09ef7e5b --- /dev/null +++ b/1DB_changes/update_2.3.3.sql @@ -0,0 +1,8 @@ +ALTER TABLE `ok_banners` DROP `description`; + +ALTER TABLE `ok_settings` ADD UNIQUE `param` (`param`); + +INSERT INTO `ok_settings` (`param`, `value`) VALUES +('recaptcha_scores', 'a:3:{s:7:\"product\";d:0.5;s:4:\"cart\";d:0.69999999999999996;s:5:\"other\";d:0.20000000000000001;}'); + +ALTER TABLE `ok_orders_status` ADD `status_1c` enum('new','accepted','to_delete', 'not_use') NULL DEFAULT 'not_use'; diff --git a/api/Banners.php b/api/Banners.php index 002e80c3..58889dfd 100644 --- a/api/Banners.php +++ b/api/Banners.php @@ -168,25 +168,76 @@ public function delete_banners_image($id) { } /*Выбираем все группы баннеров*/ - public function get_banners($filter = array()) { - $visible_filter = ''; - $banners = array(); - - if(isset($filter['visible'])) { - $visible_filter = $this->db->placehold('AND visible = ?', intval($filter['visible'])); + public function get_banners($filter = array(), $count = false) { + $limit = 100; // По умолчанию + $page = 1; + $joins = ''; + $where = '1'; + $group_by = ''; + $order = 'b.position DESC'; + $select = "b.*"; + if ($count === true) { + $select = "COUNT(DISTINCT b.id) as count"; } + + if(isset($filter['limit'])) { + $limit = max(1, intval($filter['limit'])); + } + + if(isset($filter['page'])) { + $page = max(1, intval($filter['page'])); + } + + $sql_limit = $this->db->placehold(' LIMIT ?, ? ', ($page-1)*$limit, $limit); - $query = "SELECT * FROM __banners WHERE 1 $visible_filter ORDER BY position"; - + if (isset($filter['visible'])) { + $where .= $this->db->placehold(' AND visible = ?', intval($filter['visible'])); + } + + // При подсчете нам эти переменные не нужны + if ($count === true) { + $order = ''; + $group_by = ''; + $sql_limit = ''; + } + + if (!empty($order)) { + $order = "ORDER BY $order"; + } + + // При подсчете нам эти переменные не нужны + if ($count === true) { + $order = ''; + $group_by = ''; + $sql_limit = ''; + } + + $query = $this->db->placehold("SELECT $select + FROM __banners b + $joins + WHERE + $where + $group_by + $order + $sql_limit + "); + $this->db->query($query); - - foreach($this->db->results() as $banner) { - $banners[$banner->id] = $banner; + if ($count === true) { + return $this->db->result('count'); + } else { + $banners = array(); + foreach($this->db->results() as $banner) { + $banners[$banner->id] = $banner; + } + return $banners; } - - return $banners; } + public function count_banners($filter = array()) { + return $this->get_banners($filter, true); + } + /*Выбираем определенную группу баннеров*/ public function get_banner($id, $visible = false, $show_filter_array = array()) { if (empty($id)) { diff --git a/api/Config.php b/api/Config.php index 0a3221fc..b6d1e366 100644 --- a/api/Config.php +++ b/api/Config.php @@ -10,15 +10,16 @@ class Config { /*Версия системы*/ - public $version = '2.3.2'; + public $version = '2.3.3'; /*Тип системы*/ public $version_type = 'pro'; /*Файл для хранения настроек*/ public $config_file = 'config/config.php'; - public $config_develop_file = 'config/config.local.php'; + public $config_local_file = 'config/config.local.php'; private $vars = array(); + private $local_vars = array(); /* * В конструкторе записываем настройки файла в переменные этого класса @@ -33,10 +34,10 @@ public function __construct() { } /*Заменяем настройки, если есть локальный конфиг*/ - if (file_exists(dirname(dirname(__FILE__)).'/'.$this->config_develop_file)) { - $ini = parse_ini_file(dirname(dirname(__FILE__)) . '/' . $this->config_develop_file); + if (file_exists(dirname(dirname(__FILE__)).'/'.$this->config_local_file)) { + $ini = parse_ini_file(dirname(dirname(__FILE__)) . '/' . $this->config_local_file); foreach ($ini as $var => $value) { - $this->vars[$var] = $value; + $this->local_vars[$var] = $this->vars[$var] = $value; } } @@ -99,10 +100,18 @@ public function __get($name) { /*Запись данных в конфиг*/ public function __set($name, $value) { - if(isset($this->vars[$name])) { - $conf = file_get_contents(dirname(dirname(__FILE__)).'/'.$this->config_file); + if(isset($this->vars[$name]) || isset($this->local_vars[$name])) { + + // Определяем в каком файле конфига переопределять значения + if (isset($this->local_vars[$name])) { + $config_file = $this->config_local_file; + } else { + $config_file = $this->config_file; + } + + $conf = file_get_contents(dirname(dirname(__FILE__)).'/'.$config_file); $conf = preg_replace("/".$name."\s*=.*\n/i", $name.' = '.$value."\r\n", $conf); - $cf = fopen(dirname(dirname(__FILE__)).'/'.$this->config_file, 'w'); + $cf = fopen(dirname(dirname(__FILE__)).'/'.$config_file, 'w'); fwrite($cf, $conf); fclose($cf); $this->vars[$name] = $value; diff --git a/api/Database.php b/api/Database.php index a491f428..7deee20d 100644 --- a/api/Database.php +++ b/api/Database.php @@ -38,7 +38,8 @@ public function connect() { // Выводим сообщение, в случае ошибки if($this->mysqli->connect_error) { - trigger_error("Could not connect to the database: ".$this->mysqli->connect_error, E_USER_WARNING); + ini_set('display_errors', 'on'); + trigger_error("Could not connect to the database: ".$this->mysqli->connect_error, E_USER_ERROR); return false; } // Или настраиваем соединение @@ -66,7 +67,14 @@ public function connect() { $l->domains = explode(',', $l->domains); $h = getenv("HTTP_HOST"); if(substr($h, 0, 4) == 'www.') {$h = substr($h, 4);} - if((!in_array($h, $l->domains) || (strtotime($l->expiration)expiration!='*'))) { + $sv = false;$da = explode('.', $h);$it = count($da); + for ($i=1;$i<=$it;$i++) { + unset($da[0]);$da = array_values($da);$d = '*.'.implode('.', $da); + if (in_array($d, $l->domains) || in_array('*.'.$h, $l->domains)) { + $sv = true;break; + } + } + if(((!in_array($h, $l->domains) && !$sv) || (strtotime($l->expiration)expiration!='*')) && strtolower(php_sapi_name()) != 'cli') { $this->rev = true; } return $this->mysqli; diff --git a/api/FeaturesValues.php b/api/FeaturesValues.php index 0465f4de..afa76b20 100644 --- a/api/FeaturesValues.php +++ b/api/FeaturesValues.php @@ -51,7 +51,17 @@ public function get_features_values($filter = array(), $count = false) { } if (isset($filter['yandex'])) { - $yandex_filter = $this->db->placehold("AND `f`.`yandex`=?", (int)$filter['yandex']); + $yandex_filter = $this->db->placehold("AND `f`.`yandex`=? AND `pf`.`product_id` IN ( + SELECT + distinct(p.id) + FROM ok_variants v + LEFT JOIN ok_products p ON v.product_id=p.id + WHERE + p.visible + AND v.feed = 1 + AND (v.stock >0 OR v.stock is NULL) + AND v.price >0 + )", (int)$filter['yandex']); } if(isset($filter['id'])) { @@ -192,11 +202,10 @@ public function get_features_values($filter = array(), $count = false) { $sql_limit = ""; } else { $select = $this->db->placehold(" - MAX(`fv`.`id`) AS `id`, - MAX(`fv`.`feature_id`) AS `feature_id`, - MAX(`fv`.`position`) AS `position`, + `fv`.`id`, + `fv`.`feature_id`, + `fv`.`position`, count(`pf`.`product_id`) AS `count`, - MAX(`f`.`id`) AS `feature_id`, MAX(`f`.`auto_name_id`) AS `auto_name_id`, MAX(`f`.`auto_value_id`) AS `auto_value_id`, MAX(`f`.`url`) AS `url`, @@ -388,20 +397,25 @@ public function add_feature_value($feature_value) { $feature_value->value = trim($feature_value->value); - if (!$feature_value->translit) { + if (empty($feature_value->translit)) { $feature_value->translit = $this->translit_alpha($feature_value->value); } $feature_value->translit = strtr(strtolower(trim($feature_value->translit)), $this->spec_pairs); - $result = $this->languages->get_description($feature_value, 'feature_value'); + $result = $this->languages->get_description($feature_value, 'feature_value', false); - if($this->db->query("INSERT INTO `__features_values` SET ?%", $feature_value)) { + if ($this->db->query("INSERT INTO `__features_values` SET ?%", $feature_value)) { $id = $this->db->insert_id(); if (empty($feature_value->position)) { $this->db->query("UPDATE `__features_values` SET `position`=`id` WHERE `id`=?", $id); } - if(!empty($result->description)) { + if (!empty($result->description)) { + + if (!empty($feature_value->feature_id)) { + $result->description->feature_id = $feature_value->feature_id; + } + $this->languages->action_description($id, $result->description, 'feature_value'); } return $id; @@ -418,7 +432,7 @@ public function update_feature_value($id, $feature_value) { $feature_value->value = trim($feature_value->value); } - if (!$feature_value->translit && $feature_value->value) { + if (empty($feature_value->translit) && !empty($feature_value->value)) { $feature_value->translit = $this->translit_alpha($feature_value->value); } @@ -428,15 +442,20 @@ public function update_feature_value($id, $feature_value) { $result = $this->languages->get_description($feature_value, 'feature_value'); - $query = $this->db->placehold("UPDATE `__features_values` SET ?% WHERE `id`=? LIMIT 1", $feature_value, (int)$id); - if($this->db->query($query)) { - if(!empty($result->description)) { - $this->languages->action_description($id, $result->description, 'feature_value', $this->languages->lang_id()); + if (!empty((array)$feature_value)) { + $query = $this->db->placehold("UPDATE `__features_values` SET ?% WHERE `id`=? LIMIT 1", $feature_value, (int)$id); + $this->db->query($query); + } + + if (!empty($result->description)) { + + if (!empty($feature_value->feature_id)) { + $result->description->feature_id = $feature_value->feature_id; } - return $id; - } else { - return false; + + $this->languages->action_description($id, $result->description, 'feature_value', $this->languages->lang_id()); } + return $id; } /*добавление значения свойства товара*/ diff --git a/api/Languages.php b/api/Languages.php index 4a82d2e4..d52b7335 100644 --- a/api/Languages.php +++ b/api/Languages.php @@ -57,7 +57,7 @@ public function get_fields($object = '') { $fields['orders_labels'] = array('name'); $fields['orders_status'] = array('name'); $fields['menu_items'] = array('name'); - $fields['features_values'] = array('value', 'translit', 'feature_id'); + $fields['features_values'] = array('value', 'translit'); $fields['seo_filter_patterns'] = array('h1', 'title', 'keywords', 'meta_description', 'description'); $fields['features_aliases'] = array('name'); $fields['features_aliases_values'] = array('value'); @@ -300,7 +300,7 @@ public function action_data($object_id, $data, $object) { } /*Выборка мультиязычных данных*/ - public function get_description($data, $object) { + public function get_description($data, $object, $clear = true) { if(!in_array($object, array_keys($this->tables)) || empty($this->languages)) { return false; } @@ -313,7 +313,7 @@ public function get_description($data, $object) { if (isset($data->$f)) { $description->$f = $data->$f; } - if($this->first_language->id != $this->lang_id()) { + if ($this->first_language->id != $this->lang_id() && $clear === true) { unset($data->$f); } } diff --git a/api/Managers.php b/api/Managers.php index 08d76ad0..ff60cbc7 100644 --- a/api/Managers.php +++ b/api/Managers.php @@ -9,7 +9,7 @@ class Managers extends Okay { 'users', 'groups', 'coupons', 'pages', 'blog', 'comments', 'feedbacks', 'import', 'export', 'stats', 'design', 'settings', 'currency', 'delivery', 'payment', 'managers', 'license', 'languages', 'banners', 'callbacks','robots', 'seo_patterns', 'support', 'subscribes', 'menu', 'seo_filter_patterns', - 'settings_counter', 'features_aliases' + 'settings_counter', 'features_aliases', 'integration_1c' ); diff --git a/api/Money.php b/api/Money.php index 0615e4d8..2a86bae0 100644 --- a/api/Money.php +++ b/api/Money.php @@ -130,7 +130,7 @@ public function delete_currency($id) { } /*Конвертация валюты в определнный формат*/ - public function convert($price, $currency_id = null, $format = true) { + public function convert($price, $currency_id = null, $format = true, $revers = false) { if(isset($currency_id)) { if(is_numeric($currency_id)) { $currency = $this->get_currency((integer)$currency_id); @@ -146,7 +146,11 @@ public function convert($price, $currency_id = null, $format = true) { $result = $price; if(!empty($currency)) { // Умножим на курс валюты - $result = $result*$currency->rate_from/$currency->rate_to; + if ($revers === true) { + $result = $result*$currency->rate_to/$currency->rate_from; + } else { + $result = $result*$currency->rate_from/$currency->rate_to; + } // Точность отображения, знаков после запятой $precision = isset($currency->cents)?$currency->cents:2; diff --git a/api/Okay.php b/api/Okay.php index f484affe..9255830d 100644 --- a/api/Okay.php +++ b/api/Okay.php @@ -50,6 +50,7 @@ class Okay { 'seo_filter_patterns' => 'SEOFilterPatterns', 'features_aliases' => 'FeaturesAliases', 'features_values' => 'FeaturesValues', + 'recaptcha' => 'Recaptcha', ); @@ -148,27 +149,6 @@ public function __get($name) { return self::$objects[$name]; } - public function recaptcha() { - $g_recaptcha_response = $this->request->post('g-recaptcha-response'); - $curl = curl_init(); - curl_setopt_array($curl, array( - CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify', - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POST => true, - CURLOPT_POSTFIELDS => http_build_query(array('secret'=>$this->settings->secret_recaptcha, - 'response'=>$g_recaptcha_response, - 'remoteip'=>$_SERVER['REMOTE_ADDR'])) - )); - $response = curl_exec($curl); - curl_close($curl); - - if (strpos($response, 'invalid-input-secret')){ - return true; - } else { - return !strpos($response, 'false'); - } - } - public function translit($text) { $res = $text; foreach ($this->translit_pairs as $pair) { diff --git a/api/OrderStatus.php b/api/OrderStatus.php index 4e5f9330..d0608716 100644 --- a/api/OrderStatus.php +++ b/api/OrderStatus.php @@ -88,7 +88,7 @@ public function update_status($id, $status) { /*Удаления статуса заказа*/ public function delete_status($id) { if(!empty($id)) { - $order_query = $this->db->placehold("SELECT COUNT(o.id) as count FROM __orders WHERE status_id = ?", intval($id)); + $order_query = $this->db->placehold("SELECT COUNT(id) as count FROM __orders WHERE status_id = ?", intval($id)); $this->db->query($order_query); $check_cnt = $this->db->result("count"); diff --git a/api/Recaptcha.php b/api/Recaptcha.php new file mode 100644 index 00000000..c8c4f7de --- /dev/null +++ b/api/Recaptcha.php @@ -0,0 +1,90 @@ +settings->captcha_type) { + case 'invisible': + $this->secret_key = $this->settings->secret_recaptcha_invisible; + break; + case 'v2': + $this->secret_key = $this->settings->secret_recaptcha; + break; + case 'v3': + $this->secret_key = $this->settings->secret_recaptcha_v3; + break; + } + } + + public function check() { + + $this->request(); + + // В случае инвалидных ключей пропускаем пользователя + if (isset($this->response['error-codes']) && reset($this->response['error-codes']) == 'invalid-input-secret') { + return true; // TODO add to events list + } + + if ($this->response['success'] == false) { + return false; + } + + // Для третей версии нужно дополнительно определить можно ли пропускать с таким уровнем "человечности" + if ($this->settings->captcha_type == 'v3') { + return $this->calc_is_human_v3(); + } + + return true; + } + + private function calc_is_human_v3() { + + $action = $this->response['action']; + $score = (float)$this->response['score']; + switch ($action) { + case 'cart': + $min_score = (float)$this->settings->recaptcha_scores['cart']; + break; + case 'product': + $min_score = (float)$this->settings->recaptcha_scores['product']; + break; + default: + $min_score = (float)$this->settings->recaptcha_scores['other']; + } + + return $min_score <= $score; + } + + private function request() { + $curl = curl_init($this->url); + + $params = http_build_query(array( + 'secret' => $this->secret_key, + 'response' => $this->get_response_key(), + 'remoteip' => $_SERVER['REMOTE_ADDR'] + )); + + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $params); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($curl); + curl_close($curl); + + $this->response = json_decode($response, true); + } + + private function get_response_key() { + if ($this->settings->captcha_type == 'v2' || $this->settings->captcha_type == 'invisible'){ + return $this->request->post('g-recaptcha-response'); + } elseif ($this->settings->captcha_type == 'v3'){ + return $this->request->post('recaptcha_token'); + } + } + +} diff --git a/api/Translations.php b/api/Translations.php index 609aed9d..c8803e10 100644 --- a/api/Translations.php +++ b/api/Translations.php @@ -84,7 +84,14 @@ private function init_one($label = "", $template_only = false, $force = false) { $l->domains = explode(',', $l->domains); $h = getenv("HTTP_HOST"); if(substr($h, 0, 4) == 'www.') {$h = substr($h, 4);} - + $sv = false;$da = explode('.', $h);$it = count($da); + for ($i=1;$i<=$it;$i++) { + unset($da[0]);$da = array_values($da);$d = '*.'.implode('.', $da); + if (in_array($d, $l->domains) || in_array('*.'.$h, $l->domains)) { + $sv = true;break; + } + } + if (!isset($this->vars[$label])) { $admin_theme = $this->settings->admin_theme; if ($_SESSION['admin'] && $admin_theme) { @@ -114,7 +121,7 @@ private function init_one($label = "", $template_only = false, $force = false) { } } - if((!in_array($h, $l->domains) || (strtotime($l->expiration)expiration!='*'))) { + if(((!in_array($h, $l->domains) && !$sv) || (strtotime($l->expiration)expiration!='*'))) { foreach ($lang as &$ln) {preg_match_all('/./us', $ln, $ar);$ln = implode(array_reverse($ar[0]));} unset($ln); } diff --git a/api/Validate.php b/api/Validate.php index 483999b4..9ae39cca 100644 --- a/api/Validate.php +++ b/api/Validate.php @@ -111,8 +111,10 @@ public function verify_captcha($form, $captcha_code = ''){ return false; } return true; - } elseif ($this->settings->captcha_type == 'v2' || $this->settings->captcha_type == 'invisible'){ - return $this->recaptcha(); + } elseif ($this->settings->captcha_type == 'v2' + || $this->settings->captcha_type == 'invisible' + || $this->settings->captcha_type == 'v3'){ + return $this->recaptcha->check(); } } return true; diff --git a/backend/ajax/import.php b/backend/ajax/import.php index e5349c7a..38ff194a 100644 --- a/backend/ajax/import.php +++ b/backend/ajax/import.php @@ -133,7 +133,7 @@ private function import_item($item) { } if (!empty($item['url'])) { - $product['url'] = trim($item['url']); + $product['url'] = $this->translit(trim($item['url'])); } // Если задан бренд @@ -330,6 +330,10 @@ private function import_item($item) { // Имя файла $image_filename = pathinfo($image, PATHINFO_BASENAME); + if (preg_match("~^https?://~", $image)) { + $image_filename = $this->image->correct_filename($image_filename); + $image = rawurlencode($image); + } // Добавляем изображение только если такого еще нет в этом товаре $this->db->query('SELECT id, filename FROM __images WHERE product_id=? AND (filename=? OR filename=?) LIMIT 1', $product_id, $image_filename, $image); $result = $this->db->result(); diff --git a/backend/core/BannersAdmin.php b/backend/core/BannersAdmin.php index 41fec92f..790a54f8 100644 --- a/backend/core/BannersAdmin.php +++ b/backend/core/BannersAdmin.php @@ -4,6 +4,21 @@ class BannersAdmin extends Okay { public function fetch() { + + $filter = array(); + $filter['page'] = max(1, $this->request->get('page', 'integer')); + + if ($filter['limit'] = $this->request->get('limit', 'integer')) { + $filter['limit'] = max(5, $filter['limit']); + $filter['limit'] = min(100, $filter['limit']); + $_SESSION['banners_num_admin'] = $filter['limit']; + } elseif (!empty($_SESSION['banners_num_admin'])) { + $filter['limit'] = $_SESSION['banners_num_admin']; + } else { + $filter['limit'] = 25; + } + $this->design->assign('current_limit', $filter['limit']); + /*Принимаем выбранные группы баннеров*/ if($this->request->method('post')) { $ids = $this->request->post('check'); @@ -42,7 +57,23 @@ public function fetch() { } } - $banners = $this->banners->get_banners(); + $banners_count = $this->banners->count_banners($filter); + // Показать все страницы сразу + if($this->request->get('page') == 'all') { + $filter['limit'] = $banners_count; + } + + if($filter['limit']>0) { + $pages_count = ceil($banners_count/$filter['limit']); + } else { + $pages_count = 0; + } + $filter['page'] = min($filter['page'], $pages_count); + $this->design->assign('banners_count', $banners_count); + $this->design->assign('pages_count', $pages_count); + $this->design->assign('current_page', $filter['page']); + + $banners = $this->banners->get_banners($filter); if($banners){ $categories = $this->categories->get_categories(); $brands = $this->brands->get_brands(); diff --git a/backend/core/BannersImagesAdmin.php b/backend/core/BannersImagesAdmin.php index 95769391..296b1ded 100644 --- a/backend/core/BannersImagesAdmin.php +++ b/backend/core/BannersImagesAdmin.php @@ -7,12 +7,17 @@ class BannersImagesAdmin extends Okay { public function fetch() { $filter = array(); $filter['page'] = max(1, $this->request->get('page', 'integer')); - - $filter['limit'] = 20; - - // Баннера - $banners = $this->banners->get_banners(); - $this->design->assign('banners', $banners); + + if ($filter['limit'] = $this->request->get('limit', 'integer')) { + $filter['limit'] = max(5, $filter['limit']); + $filter['limit'] = min(100, $filter['limit']); + $_SESSION['banners_images_num_admin'] = $filter['limit']; + } elseif (!empty($_SESSION['banners_images_num_admin'])) { + $filter['limit'] = $_SESSION['banners_images_num_admin']; + } else { + $filter['limit'] = 25; + } + $this->design->assign('current_limit', $filter['limit']); // Текущий баннер $banner_id = $this->request->get('banner_id', 'integer'); @@ -105,6 +110,13 @@ public function fetch() { foreach($this->banners->get_banners_images($filter) as $p) { $banners_images[$p->id] = $p; } + + if (!empty($banners_images)) { + // Баннера + $count_banners = $this->banners->count_banners(); + $banners = $this->banners->get_banners(array('limit' => $count_banners)); + $this->design->assign('banners', $banners); + } $this->design->assign('banners_images', $banners_images); diff --git a/backend/core/IndexAdmin.php b/backend/core/IndexAdmin.php index bfdb0e49..ca33ca2b 100644 --- a/backend/core/IndexAdmin.php +++ b/backend/core/IndexAdmin.php @@ -207,7 +207,14 @@ public function __construct() { preg_match_all('/./us', $bt, $ar);$bt = implode(array_reverse($ar[0]));} unset($bt); if(substr($h, 0, 4) == 'www.') $h = substr($h, 4); - if((!in_array($h, $l->domains) || (strtotime($l->expiration)expiration!='*')) && $module!='LicenseAdmin') { + $sv = false;$da = explode('.', $h);$it = count($da); + for ($i=1;$i<=$it;$i++) { + unset($da[0]);$da = array_values($da);$d = '*.'.implode('.', $da); + if (in_array($d, $l->domains) || in_array('*.'.$h, $l->domains)) { + $sv = true;break; + } + } + if(((!in_array($h, $l->domains) && !$sv) || (strtotime($l->expiration)expiration!='*')) && $module!='LicenseAdmin') { header('location: '.$this->config->root_url.'/backend/index.php?module=LicenseAdmin'); } else { $l->valid = true; diff --git a/backend/core/LicenseAdmin.php b/backend/core/LicenseAdmin.php index a01bfef3..7162a400 100644 --- a/backend/core/LicenseAdmin.php +++ b/backend/core/LicenseAdmin.php @@ -29,7 +29,14 @@ public function fetch() { $h = substr($h, 4); } $l->valid = true; - if(!in_array($h, $l->domains)) { + $sv = false;$da = explode('.', $h);$it = count($da); + for ($i=1;$i<=$it;$i++) { + unset($da[0]);$da = array_values($da);$d = '*.'.implode('.', $da); + if (in_array($d, $l->domains) || in_array('*.'.$h, $l->domains)) { + $sv = true;break; + } + } + if(!in_array($h, $l->domains) && !$sv) { $l->valid = false; } if(strtotime($l->expiration)expiration!='*') { diff --git a/backend/core/ManagerAdmin.php b/backend/core/ManagerAdmin.php index 68744ee3..cb41c0b2 100644 --- a/backend/core/ManagerAdmin.php +++ b/backend/core/ManagerAdmin.php @@ -102,6 +102,7 @@ public function fetch() { 'left_auto' => array( 'import' => $btr->left_import_title, 'export' => $btr->left_export_title, + 'integration_1c' => $btr->integration_1c, ), 'left_stats' => array( 'stats' => $btr->left_stats, diff --git a/backend/core/OrderSettingsAdmin.php b/backend/core/OrderSettingsAdmin.php index 49d73b41..956542ba 100644 --- a/backend/core/OrderSettingsAdmin.php +++ b/backend/core/OrderSettingsAdmin.php @@ -20,18 +20,17 @@ public function fetch() { /*Создание статуса*/ if($this->request->post('new_name')){ - $new_status = array(); - $new_params = array(); - $new_colors = array(); $new_status = $this->request->post('new_name'); $new_params = $this->request->post('new_is_close'); $new_colors = $this->request->post('new_color'); + $new_status_1c = $this->request->post('new_status_1c'); foreach ($new_status as $id=>$value) { if(!empty($value)) { $new_stat = new stdClass(); $new_stat->name = $value; $new_stat->is_close = $new_params[$id]; + $new_stat->status_1c = $new_status_1c[$id]; $new_stat->color = $new_colors[$id]; $this->orderstatus->add_status($new_stat); } @@ -40,10 +39,8 @@ public function fetch() { /*Обновление статуса*/ if($this->request->post('name')) { - $current_status = array(); - $is_close = array(); - $ids_status = array(); $current_status = $this->request->post('name'); + $status_1c = $this->request->post('status_1c'); $is_close = $this->request->post('is_close'); $ids_status = $this->request->post('id'); $colors_status = $this->request->post('color'); @@ -51,6 +48,7 @@ public function fetch() { $update_status = new stdClass(); $update_status->name = $value; $update_status->is_close = $is_close[$id]; + $update_status->status_1c = $status_1c[$id]; $update_status->color = $colors_status[$id]; $this->orderstatus->update_status($id,$update_status); } @@ -89,8 +87,6 @@ public function fetch() { /*Добавление метки*/ if($this->request->post('new_name')){ - $new_labels = array(); - $new_colors = array(); $new_labels = $this->request->post('new_name'); $new_colors = $this->request->post('new_color'); foreach ($new_labels as $id=>$value) { @@ -105,9 +101,6 @@ public function fetch() { /*Обновление метки*/ if($this->request->post('name')) { - $current_labels = array(); - $colors = array(); - $ids = array(); $current_labels = $this->request->post('name'); $colors = $this->request->post('color'); $ids = $this->request->post('id'); diff --git a/backend/core/ProductAdmin.php b/backend/core/ProductAdmin.php index fe1b223e..a828fd8d 100644 --- a/backend/core/ProductAdmin.php +++ b/backend/core/ProductAdmin.php @@ -283,29 +283,43 @@ public function fetch() { foreach ($features_values as $feature_id=>$feature_values) { foreach ($feature_values as $k=>$value_id) { - if (empty($value_id) && !empty($features_values_text[$feature_id][$k])) { + $value = trim($features_values_text[$feature_id][$k]); + if (!empty($value)) { + if (!empty($value_id)) { + $this->features_values->update_feature_value($value_id, array('value' => $value)); + } else { + /** + * Проверим может есть занчение с таким транслитом, + * дабы исключить дублирование значений "ТВ приставка" и "TV приставка" и подобных + */ + $translit = $this->translit_alpha($value); + + // Ищем значение по транслиту в основной таблице, если мы создаем значение не на основном языке + $query = $this->db->placehold("SELECT `id` FROM `__features_values` WHERE `feature_id`=? AND `translit`=? LIMIT 1", $feature_id, $translit); + $this->db->query($query); + $value_id = $this->db->result('id'); + + if (empty($value_id) && ($fv = $this->features_values->get_features_values(array('feature_id' => $feature_id, 'translit' => $translit)))) { + $fv = reset($fv); + $value_id = $fv->id; + } + + // Если такого значения еще нет, но его запостили тогда добавим + if (!$value_id) { - /** - * Проверим может есть занчение с таким транслитом, - * дабы исключить дублирование значений "ТВ приставка" и "TV приставка" и подобных - */ - $value = trim($features_values_text[$feature_id][$k]); - $translit = $this->translit_alpha($value); - if ($fv = $this->features_values->get_features_values(array('feature_id'=>$feature_id, 'translit'=>$translit))) { - $fv = reset($fv); - $value_id = $fv->id; - } - - // Если такого значения еще нет, но его запостили тогда добавим - if (!$value_id) { - $feature_value = new stdClass(); - $feature_value->value = $value; - $feature_value->feature_id = $feature_id; - $value_id = $this->features_values->add_feature_value($feature_value); + $this->db->query("SELECT `to_index_new_value` FROM `__features` WHERE `id`=? LIMIT 1", $feature_id); + $to_index = $this->db->result('to_index_new_value'); + + $feature_value = new stdClass(); + $feature_value->value = $value; + $feature_value->feature_id = $feature_id; + $feature_value->to_index = $to_index; + $value_id = $this->features_values->add_feature_value($feature_value); + } } } - if ($value_id) { + if (!empty($value_id)) { $this->features_values->add_product_value($product->id, $value_id); } } @@ -411,7 +425,7 @@ public function fetch() { // Свойства товара $features_values = array(); - if ($product->id) { + if (!empty($product->id)) { foreach ($this->features_values->get_features_values(array('product_id' => $product->id)) as $fv) { $features_values[$fv->feature_id][] = $fv; } diff --git a/backend/core/SettingsCatalogAdmin.php b/backend/core/SettingsCatalogAdmin.php index 644234f0..a4449c2f 100644 --- a/backend/core/SettingsCatalogAdmin.php +++ b/backend/core/SettingsCatalogAdmin.php @@ -5,13 +5,11 @@ class SettingsCatalogAdmin extends Okay { private $allowed_image_extentions = array('png', 'gif', 'jpg', 'jpeg', 'ico'); - public $passwd_file_1c = "cml/.passwd"; /*Настройки каталога*/ public function fetch() { $managers = $this->managers->get_managers(); $this->design->assign('managers', $managers); - $user_1c = $this->get_user_1c(); if($this->request->method('POST')) { $this->settings->decimals_point = $this->request->post('decimals_point'); @@ -77,44 +75,14 @@ public function fetch() { $this->clear_files_dirs($this->config->resized_categories_dir); } $this->design->assign('message_success', 'saved'); - - $pass_1c = $this->request->post('pass_1c'); - if (!empty($pass_1c)) { - $login_1c = $this->request->post('login_1c'); - if (!empty($login_1c)) { - $user_1c = $this->update_user_1c($login_1c, $pass_1c); - } - } + } - $this->design->assign('login_1c', isset($user_1c[0]) ? $user_1c[0] : ''); + return $this->design->fetch('settings_catalog.tpl'); } private function truncate_tables() { - $this->db->query("DELETE FROM `__comments` WHERE `type`='product'"); - $this->db->query("UPDATE `__purchases` SET `product_id`=0, `variant_id`=0"); - $this->db->query("TRUNCATE TABLE `__brands`"); - $this->db->query("TRUNCATE TABLE `__categories`"); - $this->db->query("TRUNCATE TABLE `__categories_features`"); - $this->db->query("TRUNCATE TABLE `__features`"); - $this->db->query("TRUNCATE TABLE `__features_aliases_values`"); - $this->db->query("TRUNCATE TABLE `__features_values`"); - $this->db->query("TRUNCATE TABLE `__images`"); - $this->db->query("TRUNCATE TABLE `__import_log`"); - $this->db->query("TRUNCATE TABLE `__lang_brands`"); - $this->db->query("TRUNCATE TABLE `__lang_categories`"); - $this->db->query("TRUNCATE TABLE `__lang_features`"); - $this->db->query("TRUNCATE TABLE `__lang_features_aliases_values`"); - $this->db->query("TRUNCATE TABLE `__lang_features_values`"); - $this->db->query("TRUNCATE TABLE `__lang_products`"); - $this->db->query("TRUNCATE TABLE `__lang_variants`"); - $this->db->query("TRUNCATE TABLE `__options_aliases_values`"); - $this->db->query("TRUNCATE TABLE `__products`"); - $this->db->query("TRUNCATE TABLE `__products_categories`"); - $this->db->query("TRUNCATE TABLE `__products_features_values`"); - $this->db->query("TRUNCATE TABLE `__related_blogs`"); - $this->db->query("TRUNCATE TABLE `__related_products`"); - $this->db->query("TRUNCATE TABLE `__variants`"); + $this->clear_catalog(); $this->clear_files_dirs($this->config->original_images_dir); $this->clear_files_dirs($this->config->resized_images_dir); @@ -141,49 +109,4 @@ private function clear_files_dirs($dir = '') { } } - private function get_user_1c() { - $line = explode("\n", @file_get_contents($this->passwd_file_1c)); - $line = reset($line); - $line = explode(':', $line); - return $line; - } - - private function update_user_1c($login, $pass) { - $pass = $this->crypt_apr1_md5($pass); - $line = $login.':'.$pass; - file_put_contents($this->passwd_file_1c, $line); - return explode(':', $line); - } - - private function crypt_apr1_md5($plainpasswd, $salt = '') { - if (empty($salt)) { - $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8); - } - $len = strlen($plainpasswd); - $text = $plainpasswd.'$apr1$'.$salt; - $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd)); - for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); } - for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; } - $bin = pack("H32", md5($text)); - for($i = 0; $i < 1000; $i++) { - $new = ($i & 1) ? $plainpasswd : $bin; - if ($i % 3) $new .= $salt; - if ($i % 7) $new .= $plainpasswd; - $new .= ($i & 1) ? $bin : $plainpasswd; - $bin = pack("H32", md5($new)); - } - $tmp = ''; - for ($i = 0; $i < 5; $i++) { - $k = $i + 6; - $j = $i + 12; - if ($j == 16) $j = 5; - $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp; - } - $tmp = chr(0).chr(0).$bin[11].$tmp; - $tmp = strtr(strrev(substr(base64_encode($tmp), 2)), - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); - return "$"."apr1"."$".$salt."$".$tmp; - } - } diff --git a/backend/core/SettingsGeneralAdmin.php b/backend/core/SettingsGeneralAdmin.php index 7cecf8b5..d10980d2 100644 --- a/backend/core/SettingsGeneralAdmin.php +++ b/backend/core/SettingsGeneralAdmin.php @@ -26,6 +26,17 @@ public function fetch() { $this->settings->captcha_type = $this->request->post('captcha_type'); $this->settings->iframe_map_code = $this->request->post('iframe_map_code'); $this->settings->gather_enabled = $this->request->post('gather_enabled', 'boolean'); + $this->settings->public_recaptcha_v3 = $this->request->post('public_recaptcha_v3'); + $this->settings->secret_recaptcha_v3 = $this->request->post('secret_recaptcha_v3'); + + if ($recaptcha_scores = $this->request->post('recaptcha_scores')) { + foreach ($recaptcha_scores as $k=>$score) { + $score = (float)str_replace(',', '.', $score); + $recaptcha_scores[$k] = round($score, 1); + } + } + $this->settings->recaptcha_scores = $recaptcha_scores; + if(is_null($this->request->post('site_logo'))) { if(file_exists($this->config->root_dir .'/design/'. $this->settings->theme . '/images/'.$this->settings->site_logo)) { @unlink($this->config->root_dir .'/design/'. $this->settings->theme . '/images/'.$this->settings->site_logo); @@ -34,7 +45,7 @@ public function fetch() { } else { $this->settings->site_logo = $this->request->post('site_logo'); } - + if(!empty($_FILES['site_logo']['tmp_name']) && !empty($_FILES['site_logo']['name'])) { $tmp_name = $_FILES['site_logo']['tmp_name']; $site_logo_name = $_FILES['site_logo']['name']; diff --git a/backend/core/UserAdmin.php b/backend/core/UserAdmin.php index fb3a8295..911b380f 100644 --- a/backend/core/UserAdmin.php +++ b/backend/core/UserAdmin.php @@ -21,7 +21,7 @@ public function fetch() { } elseif(empty($user->email)) { $this->design->assign('message_error', 'empty_email'); } elseif(($u = $this->users->get_user($user->email)) && $u->id!=$user->id) { - $this->design->assign('message_error', 'login_existed'); + $this->design->assign('message_error', 'login_exists'); } else { /*Обновление пользователя*/ $user->id = $this->users->update_user($user->id, $user); diff --git a/backend/design/html/banners.tpl b/backend/design/html/banners.tpl index 5369af74..802288f7 100644 --- a/backend/design/html/banners.tpl +++ b/backend/design/html/banners.tpl @@ -5,7 +5,7 @@
- {$btr->banners_groups|escape} + {$btr->banners_groups|escape} - {$banners_count}
@@ -22,118 +22,148 @@
{if $banners}
+
+
+
+ +
+
+
+ +
+
+
+
+
+
-
- {*Шапка таблицы*} -
-
-
- - -
-
{$btr->banners_group_name|escape}
-
{$btr->banners_display|escape}
-
{$btr->general_enable|escape}
-
+
+ {*Шапка таблицы*} +
+
+
+ +
- {*Параметры элемента*} -
- {foreach $banners as $banner} -
-
- +
{$btr->banners_group_name|escape}
+
{$btr->banners_display|escape}
+
{$btr->general_enable|escape}
+
+
+ {*Параметры элемента*} +
+ {foreach $banners as $banner} +
+
+ -
- {include file='svg_icon.tpl' svgId='drag_vertical'} -
+
+ {include file='svg_icon.tpl' svgId='drag_vertical'} +
-
- - -
+
+ + +
- + -
-
- {if $banner->show_all_pages} - {$btr->general_all_pages|escape} - {/if} - {if !$banner->show_all_pages && $banner->category_show} -
- {$btr->general_categories|escape} - {foreach $banner->category_show as $cat_show} - {$cat_show->name|escape} - {/foreach} -
- {/if} - {if !$banner->show_all_pages && $banner->brands_show} -
- {$btr->general_brands|escape} - {foreach $banner->brands_show as $brand_show} - {$brand_show->name|escape} - {/foreach} -
- {/if} - {if !$banner->show_all_pages && $banner->page_show} -
- {$btr->general_pages|escape} - {foreach $banner->page_show as $page_show} - {$page_show->name|escape} - {/foreach} -
- {/if} -
+
+
+ {if $banner->show_all_pages} + {$btr->general_all_pages|escape} + {/if} + {if !$banner->show_all_pages && $banner->category_show} +
+ {$btr->general_categories|escape} + {foreach $banner->category_show as $cat_show} + {$cat_show->name|escape} + {/foreach} +
+ {/if} + {if !$banner->show_all_pages && $banner->brands_show} +
+ {$btr->general_brands|escape} + {foreach $banner->brands_show as $brand_show} + {$brand_show->name|escape} + {/foreach} +
+ {/if} + {if !$banner->show_all_pages && $banner->page_show} +
+ {$btr->general_pages|escape} + {foreach $banner->page_show as $page_show} + {$page_show->name|escape} + {/foreach} +
+ {/if}
+
-
- {*visible*} -
- -
-
-
- {*delete*} - +
+ {*visible*} +
+
-
- {/foreach} -
- {*Блок массовых действий*} - + {*Блок массовых действий*} + - +
+ +
+
+ {include file='pagination.tpl'} +
+
{else}
diff --git a/backend/design/html/banners_images.tpl b/backend/design/html/banners_images.tpl index cdf474e8..ddb54c2c 100644 --- a/backend/design/html/banners_images.tpl +++ b/backend/design/html/banners_images.tpl @@ -39,29 +39,40 @@
-
-
-
- -
-
- {if $banners} +
- +
+ +
- {/if} + {if $banners} +
+ +
+ {/if} +
+
+ +
+
+
-
@@ -179,6 +190,9 @@
+
+ {include file='pagination.tpl'} +
{else}
{$btr->banners_images_none|escape}
diff --git a/backend/design/html/feature.tpl b/backend/design/html/feature.tpl index de4b7a3e..98105e7e 100644 --- a/backend/design/html/feature.tpl +++ b/backend/design/html/feature.tpl @@ -165,7 +165,19 @@ {$btr->feature_message|escape}
- + + + +
+
+ + +
+
+ {elseif $settings->captcha_type == "v2"}
diff --git a/design/okay_shop/html/product.tpl b/design/okay_shop/html/product.tpl index 08a5dc6c..edcbe2e4 100644 --- a/design/okay_shop/html/product.tpl +++ b/design/okay_shop/html/product.tpl @@ -141,7 +141,7 @@
- +
{* Old price *}
@@ -362,7 +362,13 @@ {* Captcha *} {if $settings->captcha_product} - {if $settings->captcha_type == "v2"} + {if $settings->captcha_type == "v3"} + + {elseif $settings->captcha_type == "v2"}
diff --git a/design/okay_shop/html/register.tpl b/design/okay_shop/html/register.tpl index 8b6bdc51..0035ba2f 100644 --- a/design/okay_shop/html/register.tpl +++ b/design/okay_shop/html/register.tpl @@ -65,7 +65,13 @@
{if $settings->captcha_register} - {if $settings->captcha_type == "v2"} + {if $settings->captcha_type == "v3"} + + {elseif $settings->captcha_type == "v2"}
diff --git a/design/okay_shop/js/okay.js b/design/okay_shop/js/okay.js index e7588219..0207aa2a 100644 --- a/design/okay_shop/js/okay.js +++ b/design/okay_shop/js/okay.js @@ -241,7 +241,7 @@ function price_slider_init() { $('.fn_selected_features').html(data.selected_features); $('.products_item').matchHeight(); // Выпадающие блоки - $('.fn_switch').click(function(e){ + $('.fn_features .fn_switch').click(function(e){ e.preventDefault(); $(this).next().slideToggle(300); diff --git a/feed.php b/feed.php index 91bf9d6f..903c34c5 100644 --- a/feed.php +++ b/feed.php @@ -103,7 +103,7 @@ // Получаем список свойств для фида $features_values = array(); -foreach ($okay->features_values->get_features_values(array('product_id'=>$p_ids, 'yandex'=>1)) as $fv) { +foreach ($okay->features_values->get_features_values(array('yandex'=>1)) as $fv) { $features_values[$fv->id] = $fv; } diff --git a/index.php b/index.php index f4524f52..a5697d71 100644 --- a/index.php +++ b/index.php @@ -56,7 +56,16 @@ if(substr($h, 0, 4) == 'www.') { $h = substr($h, 4); } -if((!in_array($h, $l->domains) || (strtotime($l->expiration)expiration!='*'))) { + +$sv = false;$da = explode('.', $h);$it = count($da); +for ($i=1;$i<=$it;$i++) { + unset($da[0]);$da = array_values($da);$d = '*.'.implode('.', $da); + if (in_array($d, $l->domains) || in_array('*.'.$h, $l->domains)) { + $sv = true;break; + } +} + +if(((!in_array($h, $l->domains) && !$sv) || (strtotime($l->expiration)expiration!='*'))) { print "
Лицензия недействительна
Скрипт интернет-магазина Okay
"; } diff --git a/view/ProductView.php b/view/ProductView.php index c8446841..b23dbaf9 100644 --- a/view/ProductView.php +++ b/view/ProductView.php @@ -208,7 +208,18 @@ public function fetch() { $parts['{$'.$feature->auto_name_id.'}'] = $feature->name; } if ($feature->auto_value_id) { - $parts['{$'.$feature->auto_value_id.'}'] = $feature->value; + + if (count($feature->values) > 1) { + $value = array(); + foreach ($feature->values as $fv) { + $value[] = $fv->value; + } + $value = implode(', ', $value); + } else { + $value = $feature->value; + } + + $parts['{$'.$feature->auto_value_id.'}'] = $value; } } diff --git a/view/ProductsView.php b/view/ProductsView.php index 955478f0..35c30420 100644 --- a/view/ProductsView.php +++ b/view/ProductsView.php @@ -476,6 +476,13 @@ public function fetch() { $prices = array(); $prices['current'] = $this->request->get('p'); + if (isset($prices['current']['min'])) { + $prices['current']['min'] = $this->money->convert($prices['current']['min'], null, false, true); + } + if (isset($prices['current']['max'])) { + $prices['current']['max'] = $this->money->convert($prices['current']['max'], null, false, true); + } + if (isset($prices['current']['min']) && isset($prices['current']['max']) && $prices['current']['max'] != '' && $prices['current']['min'] != '') { $filter['price'] = $prices['current']; } else { @@ -542,6 +549,14 @@ public function fetch() { $prices['current'] = $filter['price'] = $price_filter['price_range']; } + if (!empty($filter['price']['min'])) { + $filter['price']['min'] = round($this->money->convert($filter['price']['min'], null, false)); + } + + if (!empty($filter['price']['max'])) { + $filter['price']['max'] = round($this->money->convert($filter['price']['max'], null, false)); + } + // Если задано ключевое слово $keyword = $this->request->get('keyword'); if (!empty($keyword)) { @@ -715,6 +730,14 @@ public function fetch() { $range_filter['get_price'] = 1; $prices->range = $this->products->get_products($range_filter); + if (isset($prices->current->min)) { + $prices->current->min = round($this->money->convert($prices->current->min, null, false)); + } + + if (isset($prices->current->max)) { + $prices->current->max = round($this->money->convert($prices->current->max, null, false)); + } + // Вдруг вылезли за диапазон доступного... if ($prices->range->min != '' && $prices->current->min < $prices->range->min) { $prices->current->min = $filter['price']['min'] = $prices->range->min;