]> gitweb.erp-flowers.ru Git - yii-erp24/.git/commitdiff
if session is missing no record in page_statistics
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 12 Mar 2024 13:28:18 +0000 (16:28 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 12 Mar 2024 13:28:18 +0000 (16:28 +0300)
erp24/web/index.php

index b2354ac4a792ec24cdaa15915c967f1dce18d98e..20583dc2c9d0269d5d2d580e0bf0b3259ef01b85 100644 (file)
@@ -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();
 }