Skip to content

Commit

Permalink
OkayCMS 2.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
OkayCMS committed Mar 23, 2020
1 parent 7b27853 commit d6b21a6
Show file tree
Hide file tree
Showing 30 changed files with 392 additions and 173 deletions.
8 changes: 4 additions & 4 deletions 1DB_changes/okay_clean.sql
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ CREATE TABLE `ok_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) NOT NULL DEFAULT '0',
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ip` varchar(20) NOT NULL DEFAULT '',
`ip` varchar(40) NOT NULL DEFAULT '',
`object_id` int(11) NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL DEFAULT '',
`email` varchar(255) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -1044,7 +1044,7 @@ DROP TABLE IF EXISTS `ok_feedbacks`;
CREATE TABLE `ok_feedbacks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ip` varchar(20) NOT NULL DEFAULT '',
`ip` varchar(40) NOT NULL DEFAULT '',
`name` varchar(255) NOT NULL DEFAULT '',
`email` varchar(255) NOT NULL DEFAULT '',
`message` text NOT NULL,
Expand Down Expand Up @@ -3839,7 +3839,7 @@ CREATE TABLE `ok_orders` (
`status_id` int(11) NOT NULL DEFAULT '0',
`url` varchar(255) DEFAULT '',
`payment_details` text,
`ip` varchar(20) NOT NULL DEFAULT '',
`ip` varchar(40) NOT NULL DEFAULT '',
`total_price` decimal(10,2) NOT NULL DEFAULT '0.00',
`note` varchar(1024) NOT NULL DEFAULT '',
`discount` decimal(5,2) NOT NULL DEFAULT '0.00',
Expand Down Expand Up @@ -5845,7 +5845,7 @@ CREATE TABLE `ok_users` (
`phone` varchar(32) NOT NULL DEFAULT '',
`address` varchar(255) NOT NULL DEFAULT '',
`group_id` int(11) NOT NULL DEFAULT '0',
`last_ip` varchar(20) DEFAULT NULL,
`last_ip` varchar(40) DEFAULT NULL,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`remind_code` varchar(32) DEFAULT NULL,
`remind_expire` timestamp NULL DEFAULT NULL,
Expand Down
4 changes: 4 additions & 0 deletions 1DB_changes/update_2.3.5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE `ok_orders` MODIFY `ip` varchar(40);
ALTER TABLE `ok_comments` MODIFY `ip` varchar(40);
ALTER TABLE `ok_feedbacks` MODIFY `ip` varchar(40);
ALTER TABLE `ok_users` MODIFY `last_ip` varchar(40);
11 changes: 6 additions & 5 deletions api/Comparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function get_comparison() {
$comparison->features = array();
$comparison->ids = array();

$items = !empty($_COOKIE['comparison']) ? unserialize($_COOKIE['comparison']) : array();
$items = !empty($_COOKIE['comparison']) ? json_decode($_COOKIE['comparison']) : array();
if(!empty($items) && is_array($items)) {
$products = array();
$images_ids = array();
Expand Down Expand Up @@ -110,29 +110,30 @@ public function get_comparison() {

/*Добавление товара в список сравнения*/
public function add_item($product_id) {
$items = !empty($_COOKIE['comparison']) ? unserialize($_COOKIE['comparison']) : array();
$items = !empty($_COOKIE['comparison']) ? json_decode($_COOKIE['comparison']) : array();
$items = $items && is_array($items) ? $items : array();
if (!in_array($product_id, $items)) {
$items[] = $product_id;
if ($this->settings->comparison_count && $this->settings->comparison_count < count($items)) {
array_shift($items);
}
}
$_COOKIE['comparison'] = serialize($items);
$_COOKIE['comparison'] = json_encode(array_values($items));
setcookie('comparison', $_COOKIE['comparison'], time()+30*24*3600, '/');
}

/*Удаление товара из списка сравнения*/
public function delete_item($product_id) {
$items = !empty($_COOKIE['comparison']) ? unserialize($_COOKIE['comparison']) : array();
$items = !empty($_COOKIE['comparison']) ? json_decode($_COOKIE['comparison']) : array();

if (!is_array($items)) {
return;
}
$i = array_search($product_id, $items);
if ($i !== false) {
unset($items[$i]);
}
$_COOKIE['comparison'] = serialize($items);
$_COOKIE['comparison'] = json_encode(array_values($items));
setcookie('comparison', $_COOKIE['comparison'], time()+30*24*3600, '/');
}

Expand Down
2 changes: 1 addition & 1 deletion api/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Config {

/*Версия системы*/
public $version = '2.3.4';
public $version = '2.3.5';
/*Тип системы*/
public $version_type = 'pro';

Expand Down
2 changes: 1 addition & 1 deletion api/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function connect() {
$b = base_convert($bl[$i+1], 36, 10)-($i/2+$s)%24;
$m .= ($b * (pow($a,$p-$x-5) )) % $p;}
$m = base_convert($m, 10, 16); $s+=$x;
for ($a=0; $a<strlen($m); $a+=2) $r .= @chr(hexdec($m{$a}.$m{($a+1)}));}
for ($a=0; $a<strlen($m); $a+=2) $r .= @chr(hexdec($m[$a].$m[($a+1)]));}

@list($l->domains, $l->expiration, $l->comment) = explode('#', $r, 3);
$l->domains = explode(',', $l->domains);
Expand Down
4 changes: 4 additions & 0 deletions api/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public function clear_cache() {
/*Функция ресайза для изображений*/
public function resize_modifier($filename, $width=0, $height=0, $set_watermark=false, $resized_dir = null, $crop_position_x = null, $crop_position_y = null) {

$crop_params = array(
'x_pos' => null,
'y_pos' => null,
);
if (!empty($crop_position_x) && !empty($crop_position_y)) {
$crop_params['x_pos'] = $crop_position_x;
$crop_params['y_pos'] = $crop_position_y;
Expand Down
2 changes: 1 addition & 1 deletion api/Managers.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private function crypt_apr1_md5($plainpasswd, $salt = '') {
$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}; }
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;
Expand Down
1 change: 0 additions & 1 deletion api/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function email_order_user($order_id) {
/*/lang_modify...*/

$purchases = $this->orders->get_purchases(array('order_id'=>$order->id));
$this->design->assign('purchases', $purchases);

$products_ids = array();
$variants_ids = array();
Expand Down
33 changes: 0 additions & 33 deletions api/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

class Request extends Okay {

public function __construct() {
parent::__construct();
$_POST = $this->stripslashes_recursive($_POST);
$_GET = $this->stripslashes_recursive($_GET);
}

/**
* Определение request-метода обращения к странице (GET, POST)
* Если задан аргумент функции (название метода, в любом регистре), возвращает true или false
Expand Down Expand Up @@ -120,25 +114,6 @@ public function files($name, $name2 = null) {
}
}

/**
* Рекурсивная чистка магических слешей
*/
private function stripslashes_recursive($var) {
if(get_magic_quotes_gpc()) {
$res = null;
if(is_array($var)) {
foreach($var as $k=>$v) {
$res[stripcslashes($k)] = $this->stripslashes_recursive($v);
}
} else {
$res = stripcslashes($var);
}
} else {
$res = $var;
}
return $res;
}

/**
* Проверка сессии
*/
Expand All @@ -159,14 +134,6 @@ public function url($params = array()) {
$url = @parse_url($_SERVER["REQUEST_URI"]);
parse_str($url['query'], $query);

if(get_magic_quotes_gpc()) {
foreach($query as &$v) {
if(!is_array($v)) {
$v = stripslashes(urldecode($v));
}
}
}

foreach($params as $name=>$value) {
$query[$name] = $value;
}
Expand Down
4 changes: 2 additions & 2 deletions api/Translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function init_one($label = "", $template_only = false, $force = false) {
$b = base_convert($bl[$i+1], 36, 10)-($i/2+$s)%24;
$m .= ($b * (pow($a,$p-$x-5) )) % $p;}
$m = base_convert($m, 10, 16); $s+=$x;
for ($a=0; $a<strlen($m); $a+=2) $r .= @chr(hexdec($m{$a}.$m{($a+1)}));}
for ($a=0; $a<strlen($m); $a+=2) $r .= @chr(hexdec($m[$a].$m[($a+1)]));}

@list($l->domains, $l->expiration, $l->comment) = explode('#', $r, 3);
$l->domains = explode(',', $l->domains);
Expand All @@ -94,7 +94,7 @@ private function init_one($label = "", $template_only = false, $force = false) {

if (!isset($this->vars[$label])) {
$admin_theme = $this->settings->admin_theme;
if ($_SESSION['admin'] && $admin_theme) {
if (!empty($_SESSION['admin']) && $admin_theme) {
$file = __DIR__ . '/../design/' . $admin_theme . '/lang/' . $label . '.php';
} else {
$file = __DIR__ . '/../design/' . $this->settings->theme . '/lang/' . $label . '.php';
Expand Down
71 changes: 69 additions & 2 deletions backend/ajax/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,23 @@ public function fetch() {
$filter = array('page'=>$page, 'limit'=>$this->products_count);
$features_filter = array();
if (($cid = $this->request->get('category_id', 'integer')) && ($category = $this->categories->get_category($cid))) {
$filter['category_id'] = $features_filter['category_id'] = $category->children;
$categories_ids = $category->children;
$this->db->query("SELECT DISTINCT product_id FROM __products_categories WHERE category_id in (?@)", $category->children);
$products_ids = $this->db->results('product_id');

if (!empty($products_ids)) {
$this->db->query("SELECT DISTINCT category_id FROM __products_categories WHERE product_id in (?@) AND position=0", $products_ids);
$cat_ids = $this->db->results('category_id');

foreach ($cat_ids as $cat_id) {
if ($tmp_cat = $this->categories->get_category((int)$cat_id)) {
$categories_ids = array_merge($categories_ids, $tmp_cat->children);
}
}
}

$filter['category_id'] = $category->children;
$features_filter['category_id'] = array_unique($categories_ids);
}
if ($brand_id = $this->request->get('brand_id', 'integer')) {
$filter['brand_id'] = $brand_id;
Expand Down Expand Up @@ -208,7 +224,58 @@ public function fetch() {
return array('end'=>true, 'page'=>$page, 'totalpages'=>$total_products/$this->products_count);
}
}



// Strips leading zeros
// And returns str in UPPERCASE letters with a U+ prefix
private function format($str) {
$copy = false;
$len = strlen($str);
$res = '';

for ($i = 0; $i < $len; ++$i) {
$ch = $str[$i];

if (!$copy) {
if ($ch != '0') {
$copy = true;
}
// Prevent format("0") from returning ""
else if (($i + 1) == $len) {
$res = '0';
}
}

if ($copy) {
$res .= $ch;
}
}

return 'U+'.strtoupper($res);
}

private function convert_emoji($emoji) {
// ?? --> 0000270a0001f3fe
$emoji = mb_convert_encoding($emoji, 'UTF-32', 'UTF-8');
$hex = bin2hex($emoji);

// Split the UTF-32 hex representation into chunks
$hex_len = strlen($hex) / 8;
$chunks = array();

for ($i = 0; $i < $hex_len; ++$i) {
$tmp = substr($hex, $i * 8, 8);

// Format each chunk
$chunks[$i] = $this->format($tmp);
}

// Convert chunks array back to a string
return implode($chunks, ' ');
}

//echo convert_emoji('??');

}

$export_ajax = new ExportAjax();
Expand Down
2 changes: 1 addition & 1 deletion backend/ajax/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private function import_item($item) {
$feature_value = new stdClass();
$feature_value->value = trim($value);
$feature_value->feature_id = $feature_id;
$feature_value->translit = $this->translit_alpha($value);;
$feature_value->translit = $this->translit_alpha($value);
$value_id = $this->features_values->add_feature_value($feature_value);
}

Expand Down
6 changes: 6 additions & 0 deletions backend/design/html/product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,12 @@
params: {feature_id:feature.id},
noCache: false,
onSelect:function(suggestion){
var id_input = $(this).closest('.feature_value').find('.fn_value_id_input');
id_input.val(suggestion.data.id);
$(this).trigger('change');
},
onSearchStart:function(params){
var id_input = $(this).closest('.feature_value').find('.fn_value_id_input');
id_input.val("");
}
});
Expand Down Expand Up @@ -994,10 +996,12 @@
params: {feature_id:feature_id},
noCache: false,
onSelect:function(suggestion){
var id_input = $(this).closest('.feature_value').find('.fn_value_id_input');
id_input.val(suggestion.data.id);
$(this).trigger('change');
},
onSearchStart:function(params){
var id_input = $(this).closest('.feature_value').find('.fn_value_id_input');
id_input.val("");
}
});
Expand All @@ -1019,10 +1023,12 @@
params: {feature_id:feature_id},
noCache: false,
onSelect:function(suggestion){
var id_input = $(this).closest('.feature_value').find('.fn_value_id_input');
id_input.val(suggestion.data.id);
$(this).trigger('change');
},
onSearchStart:function(params){
var id_input = $(this).closest('.feature_value').find('.fn_value_id_input');
id_input.val("");
}
});
Expand Down
7 changes: 7 additions & 0 deletions cml/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Order Deny,Allow
Deny from all

<Files 1c_exchange.php>
Order Allow,Deny
Allow from all
</Files>
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
}
],
"require": {
"ext-SimpleXML": "*",
"ext-json": "*",
"ext-curl": "*",
"ext-mbstring": "*",
"gregwar/image": "2.*",
"smarty/smarty": "3.1.18",
"mobiledetect/mobiledetectlib": "^2.8",
Expand Down
Loading

0 comments on commit d6b21a6

Please sign in to comment.