From d433dee80435e694901ba215ce265a5994936271 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 12 Mar 2024 16:28:18 +0300 Subject: [PATCH] if session is missing no record in page_statistics --- erp24/web/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erp24/web/index.php b/erp24/web/index.php index b2354ac..20583dc 100644 --- a/erp24/web/index.php +++ b/erp24/web/index.php @@ -20,7 +20,8 @@ $app = (new yii\web\Application($config)); $url = Yii::$app->request->url; if ( - !in_array($url, ['/notification/pending', '/site/menu-tree']) + isset($_SESSION['admin_id']) + && !in_array($url, ['/notification/pending', '/site/menu-tree']) && strpos($url, '/i/') !== 0 && strpos($url, '/debug/default/toolbar') !== 0 && strpos($url, '/assets/') !== 0 @@ -29,7 +30,7 @@ if ( unset($postJson["_csrf"]); $post = \yii\helpers\Json::encode($postJson); $app->db->createCommand( - 'INSERT INTO page_statistics (admin_id, url, post, created_at) VALUES ("' . ($_SESSION['admin_id'] ?? -1) . '", "' + 'INSERT INTO page_statistics (admin_id, url, post, created_at) VALUES ("' . $_SESSION['admin_id'] . '", "' . $url . '", :post, NOW())' )->bindParam(':post', $post, PDO::PARAM_STR)->execute(); } -- 2.39.5