From ce001d77e34dc33ba73ceccfae4b218df45f0869 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 11 Nov 2021 10:27:24 +0800 Subject: [PATCH 1/5] * Fix the problem of judging product permissions. --- module/product/model.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index d5cc1d4be2..6b00537d88 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -149,8 +149,7 @@ class productModel extends model if($productID == 0) $productID = key($products); if(!isset($products[$productID])) { - $product = $this->getById($productID); - if(empty($product)) $productID = key($products);; + $productID = key($products); if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false) $this->accessDenied(); } $this->session->set('product', $productID); From c08bd0faef2c758742fffb37aef7bd8c55da8f50 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 11 Nov 2021 10:30:29 +0800 Subject: [PATCH 2/5] * Fix the problem of judging product permissions. --- module/product/model.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index 6b00537d88..645a88d846 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -146,12 +146,9 @@ class productModel extends model public function saveState($productID, $products) { if($productID == 0 and $this->cookie->preProductID) $productID = (int)$this->cookie->preProductID; - if($productID == 0) $productID = key($products); - if(!isset($products[$productID])) - { - $productID = key($products); - if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false) $this->accessDenied(); - } + if($productID == 0 or !isset($products[$productID]) $productID = key($products); + if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false) $this->accessDenied(); + $this->session->set('product', $productID); setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); if($this->cookie->preProductID != $productID) From 160b1c9fca33d174e0a2966b59dbb4613991f6d7 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 11 Nov 2021 10:44:07 +0800 Subject: [PATCH 3/5] * Restore code. --- module/product/model.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index 645a88d846..e7d2ff710a 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -145,13 +145,17 @@ class productModel extends model */ public function saveState($productID, $products) { - if($productID == 0 and $this->cookie->preProductID) $productID = (int)$this->cookie->preProductID; - if($productID == 0 or !isset($products[$productID]) $productID = key($products); - if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false) $this->accessDenied(); + if($productID > 0) $this->session->set('product', (int)$productID); + if($productID == 0 and $this->cookie->preProductID) $this->session->set('product', (int)$this->cookie->preProductID); + if($productID == 0 and $this->session->product == '') $this->session->set('product', key($products)); + if(!isset($products[$this->session->product])) + { + $product = $this->getById($productID); + if(empty($product)) $this->session->set('product', key($products)); + if($productID && strpos(",{$this->app->user->view->products},", ",{$this->session->product},") === false) $this->accessDenied(); - $this->session->set('product', $productID); setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - if($this->cookie->preProductID != $productID) + if($this->cookie->preProductID != $this->session->productID) { $this->cookie->set('preBranch', 0); setcookie('preBranch', 0, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); From 8b9ee17312fa9fa997578ba4bbcb8638d11c9c51 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 11 Nov 2021 10:47:28 +0800 Subject: [PATCH 4/5] * Restore code. --- module/product/model.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index e7d2ff710a..ee92653c52 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -145,21 +145,21 @@ class productModel extends model */ public function saveState($productID, $products) { - if($productID > 0) $this->session->set('product', (int)$productID); - if($productID == 0 and $this->cookie->preProductID) $this->session->set('product', (int)$this->cookie->preProductID); - if($productID == 0 and $this->session->product == '') $this->session->set('product', key($products)); - if(!isset($products[$this->session->product])) - { - $product = $this->getById($productID); - if(empty($product)) $this->session->set('product', key($products)); - if($productID && strpos(",{$this->app->user->view->products},", ",{$this->session->product},") === false) $this->accessDenied(); - - setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - if($this->cookie->preProductID != $this->session->productID) + if($productID > 0) $this->session->set('product', (int)$productID); + if($productID == 0 and $this->cookie->preProductID) $this->session->set('product', (int)$this->cookie->preProductID); + if($productID == 0 and $this->session->product == '') $this->session->set('product', key($products)); + if(!isset($products[$this->session->product])) { - $this->cookie->set('preBranch', 0); - setcookie('preBranch', 0, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - } + $product = $this->getById($productID); + if(empty($product)) $this->session->set('product', key($products)); + if($productID && strpos(",{$this->app->user->view->products},", ",{$this->session->product},") === false) $this->accessDenied(); + + setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); + if($this->cookie->preProductID != $this->session->productID) + { + $this->cookie->set('preBranch', 0); + setcookie('preBranch', 0, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); + } return $this->session->product; } From ccf0c5998196639af1c91903c64ef525186a86f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=8E=89=E6=98=A5?= <563917701@qq.com> Date: Thu, 11 Nov 2021 02:56:33 +0000 Subject: [PATCH 5/5] Update model.php --- module/product/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/product/model.php b/module/product/model.php index ee92653c52..ea58225170 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -155,7 +155,7 @@ class productModel extends model if($productID && strpos(",{$this->app->user->view->products},", ",{$this->session->product},") === false) $this->accessDenied(); setcookie('preProductID', $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true); - if($this->cookie->preProductID != $this->session->productID) + if($this->cookie->preProductID != $this->session->product) { $this->cookie->set('preBranch', 0); setcookie('preBranch', 0, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);