--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m240312_111331_create_table_page_statistics
+ */
+class m240312_111331_create_table_page_statistics extends Migration
+{
+ const TABLE_NAME = "page_statistics";
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->primaryKey(),
+ 'admin_id' => $this->integer()->notNull()->comment('ID в таблице admins'),
+ 'url' => $this->string()->notNull()->comment('api request url'),
+ 'post' => $this->text()->null()->comment('POST параметры, если имеются'),
+ 'created_at' => $this->datetime()->notNull()->comment('дата создания лога'),
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropTable(self::TABLE_NAME);
+ }
+}
$app = (new yii\web\Application($config));
+$url = Yii::$app->request->url;
+if (
+ !in_array($url, ['/notification/pending', '/site/menu-tree'])
+ && strpos($url, '/i/') !== 0
+ && strpos($url, '/debug/default/toolbar') !== 0
+ && strpos($url, '/assets/') !== 0
+) {
+ $postJson = Yii::$app->request->post();
+ 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'] . '", "'
+ . $url . '", :post, NOW())'
+ )->bindParam(':post', $post, PDO::PARAM_STR)->execute();
+}
+
//$app->params['API2_TOKEN'] = $app->db->createCommand(
// 'SELECT access_token FROM api_user WHERE "login"=\'erp\' LIMIT 1;')->queryAll()[0]['access_token'] ?? null;