From: Alexander Smirnov Date: Tue, 12 Mar 2024 13:28:18 +0000 (+0300) Subject: if session is missing no record in page_statistics X-Git-Tag: 1.1~177^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d433dee80435e694901ba215ce265a5994936271;p=erp24_rep%2Fyii-erp24%2F.git if session is missing no record in page_statistics --- diff --git a/erp24/web/index.php b/erp24/web/index.php index b2354ac4..20583dc2 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(); }