DEV: Работа с логами поисковых запросов
This commit is contained in:
parent
edc49d0ddd
commit
697f48f077
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2021 AreaDev
|
Copyright (c) 2022 Evgeny Konchik
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -255,6 +255,7 @@ $data = [
|
||||||
'zh-language' => 'Chinesisch (ZH)',
|
'zh-language' => 'Chinesisch (ZH)',
|
||||||
'md-language' => 'Moldauisch (MD)',
|
'md-language' => 'Moldauisch (MD)',
|
||||||
|
|
||||||
|
'close?' => 'Nah dran?',
|
||||||
'repeat.password' => 'Repeat password',
|
'repeat.password' => 'Repeat password',
|
||||||
'post.closed' => 'Post closed',
|
'post.closed' => 'Post closed',
|
||||||
'forgot.password' => 'Forgot your password',
|
'forgot.password' => 'Forgot your password',
|
||||||
|
|
|
@ -254,6 +254,7 @@ $data = [
|
||||||
'zh-language' => 'Chinese (ZH)',
|
'zh-language' => 'Chinese (ZH)',
|
||||||
'md-language' => 'Moldovan (MD)',
|
'md-language' => 'Moldovan (MD)',
|
||||||
|
|
||||||
|
'close?' => 'Close?',
|
||||||
'repeat.password' => 'Repeat password',
|
'repeat.password' => 'Repeat password',
|
||||||
'post.closed' => 'Post closed',
|
'post.closed' => 'Post closed',
|
||||||
'forgot.password' => 'Forgot your password',
|
'forgot.password' => 'Forgot your password',
|
||||||
|
|
|
@ -254,6 +254,7 @@ $data = [
|
||||||
'zh-language' => 'Chinois (ZH)',
|
'zh-language' => 'Chinois (ZH)',
|
||||||
'md-language' => 'Moldave (MD)',
|
'md-language' => 'Moldave (MD)',
|
||||||
|
|
||||||
|
'close?' => 'Fermer?',
|
||||||
'repeat.password' => 'Repeat password',
|
'repeat.password' => 'Repeat password',
|
||||||
'post.closed' => 'Post closed',
|
'post.closed' => 'Post closed',
|
||||||
'forgot.password' => 'Forgot your password',
|
'forgot.password' => 'Forgot your password',
|
||||||
|
|
|
@ -248,6 +248,7 @@ $data = [
|
||||||
'zh-language' => 'Chineză (ZH)',
|
'zh-language' => 'Chineză (ZH)',
|
||||||
'md-language' => 'Moldovenesc (MD)',
|
'md-language' => 'Moldovenesc (MD)',
|
||||||
|
|
||||||
|
'close?' => 'Închide?',
|
||||||
'repeat.password' => 'Repetati parola',
|
'repeat.password' => 'Repetati parola',
|
||||||
'post.closed' => 'Postarea este închisă',
|
'post.closed' => 'Postarea este închisă',
|
||||||
'forgot.password' => 'Am uitat parola',
|
'forgot.password' => 'Am uitat parola',
|
||||||
|
|
|
@ -247,6 +247,7 @@ $data = [
|
||||||
'add-favorites' => 'В закладки',
|
'add-favorites' => 'В закладки',
|
||||||
'remove-favorites' => 'Убрать из закладок',
|
'remove-favorites' => 'Убрать из закладок',
|
||||||
|
|
||||||
|
'close?' => 'Закрыть?',
|
||||||
'repeat.password' => 'Повторите пароль',
|
'repeat.password' => 'Повторите пароль',
|
||||||
'post.closed' => 'Пост закрыт',
|
'post.closed' => 'Пост закрыт',
|
||||||
'forgot.password' => 'Забыли пароль',
|
'forgot.password' => 'Забыли пароль',
|
||||||
|
|
|
@ -253,6 +253,7 @@ $data = [
|
||||||
'zh-language' => '中文 (ZH)',
|
'zh-language' => '中文 (ZH)',
|
||||||
'md-language' => '摩爾多瓦 (MD)',
|
'md-language' => '摩爾多瓦 (MD)',
|
||||||
|
|
||||||
|
'close?' => '關閉?',
|
||||||
'repeat.password' => '重複輸入密碼',
|
'repeat.password' => '重複輸入密碼',
|
||||||
'post.closed' => '帖子已關閉',
|
'post.closed' => '帖子已關閉',
|
||||||
'forgot.password' => '忘記密碼了嗎',
|
'forgot.password' => '忘記密碼了嗎',
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Home
|
||||||
'posts_no_topic' => FacetModel::getNoTopic(),
|
'posts_no_topic' => FacetModel::getNoTopic(),
|
||||||
'users_count' => UserModel::getUsersCount('all'),
|
'users_count' => UserModel::getUsersCount('all'),
|
||||||
'last_visit' => UserModel::getLastVisit(),
|
'last_visit' => UserModel::getLastVisit(),
|
||||||
|
'logs' => (new \Modules\Search\App\Search())->getLogs(15),
|
||||||
'bytes' => $bytes,
|
'bytes' => $bytes,
|
||||||
'type' => 'admin',
|
'type' => 'admin',
|
||||||
'sheet' => 'admin',
|
'sheet' => 'admin',
|
||||||
|
@ -29,7 +30,7 @@ class Home
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function css()
|
public function css()
|
||||||
{
|
{
|
||||||
return view(
|
return view(
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
<div class="gray">
|
<div class="gray">
|
||||||
<span class="gray-400 text-sm">id<?= $user['id']; ?></span>
|
<span class="gray-400 text-sm">id<?= $user['id']; ?></span>
|
||||||
<a href="<?= getUrlByName('profile', ['login' => $user['login']]); ?>"><?= $user['login']; ?></a>
|
<a href="<?= getUrlByName('profile', ['login' => $user['login']]); ?>"><?= $user['login']; ?></a>
|
||||||
<span class="gray-400"> — <?= lang_date($user['latest_date']); ?> (<?= $user['os']; ?>)</span>
|
<span class="gray-400 lowercase"> — <?= lang_date($user['latest_date']); ?> (<?= $user['os']; ?>)</span>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -88,8 +88,18 @@
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<div class="mt10 p15 gray-600">
|
<div class="gray-600 ml10">
|
||||||
<h3 class="uppercase-box"><?= Translate::get('useful.resources'); ?></h3>
|
<h3 class="uppercase-box"><?= Translate::get('search'); ?></h3>
|
||||||
|
<?php foreach ($data['logs'] as $log) { ?>
|
||||||
|
<div class="gray">
|
||||||
|
<?= $log['request']; ?> <sup class="gray-400"><?= $log['count_results']; ?></sup>
|
||||||
|
<span class="gray-400 lowercase">
|
||||||
|
— (<?= Translate::get($log['action_type']); ?>) <?= lang_date($log['add_date']); ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<h3 class="uppercase-box mt15"><?= Translate::get('useful.resources'); ?></h3>
|
||||||
<p><i class="bi bi-link-45deg mr5"></i> <a href="https://agouti.ru">Agouti.ru</a></p>
|
<p><i class="bi bi-link-45deg mr5"></i> <a href="https://agouti.ru">Agouti.ru</a></p>
|
||||||
<p><i class="bi bi-github mr5"></i> <a href="https://discord.gg/dw47aNx5nU">Discord</a></p>
|
<p><i class="bi bi-github mr5"></i> <a href="https://discord.gg/dw47aNx5nU">Discord</a></p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
@ -46,7 +46,6 @@ class SearchModel extends \Hleb\Scheme\App\Models\MainModel
|
||||||
return DB::run($sql, ['qa' => "%" . $query . "%"])->rowCount();
|
return DB::run($sql, ['qa' => "%" . $query . "%"])->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getSearchTags($query, $limit)
|
public static function getSearchTags($query, $limit)
|
||||||
{
|
{
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
|
|
|
@ -45,6 +45,16 @@ class Search
|
||||||
$results[$ind] = $row;
|
$results[$ind] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(new \Modules\Search\App\Search())->setLogs(
|
||||||
|
[
|
||||||
|
'request' => $query,
|
||||||
|
'action_type' => 'website',
|
||||||
|
'add_ip' => Request::getRemoteAddress(),
|
||||||
|
'user_id' => $this->user['id'],
|
||||||
|
'count_results' => $quantity ?? 0,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'/view/default/search',
|
'/view/default/search',
|
||||||
[
|
[
|
||||||
|
|
|
@ -106,4 +106,34 @@ class SearchModel extends \Hleb\Scheme\App\Models\MainModel
|
||||||
|
|
||||||
return DB::run($sql, ['qa1' => "%" . $query . "%", 'qa2' => "%" . $query . "%"])->fetchAll();
|
return DB::run($sql, ['qa1' => "%" . $query . "%", 'qa2' => "%" . $query . "%"])->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setSearchLogs($params)
|
||||||
|
{
|
||||||
|
$sql = "INSERT INTO search_logs(request,
|
||||||
|
action_type,
|
||||||
|
add_ip,
|
||||||
|
user_id,
|
||||||
|
count_results)
|
||||||
|
VALUES(:request,
|
||||||
|
:action_type,
|
||||||
|
:add_ip,
|
||||||
|
:user_id,
|
||||||
|
:count_results)";
|
||||||
|
|
||||||
|
DB::run($sql, $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSearchLogs($limit)
|
||||||
|
{
|
||||||
|
$sql = "SELECT
|
||||||
|
request,
|
||||||
|
action_type,
|
||||||
|
add_date,
|
||||||
|
add_ip,
|
||||||
|
user_id,
|
||||||
|
count_results
|
||||||
|
FROM search_logs ORDER BY id DESC LIMIT $limit";
|
||||||
|
|
||||||
|
return DB::run($sql)->fetchAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,16 @@ class Search
|
||||||
$result = $result ?? null;
|
$result = $result ?? null;
|
||||||
$quantity = $count ?? null;
|
$quantity = $count ?? null;
|
||||||
|
|
||||||
|
self::setLogs(
|
||||||
|
[
|
||||||
|
'request' => $query,
|
||||||
|
'action_type' => 'post',
|
||||||
|
'add_ip' => Request::getRemoteAddress(),
|
||||||
|
'user_id' => $this->user['id'],
|
||||||
|
'count_results' => $quantity ?? 0,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'/view/default/search',
|
'/view/default/search',
|
||||||
[
|
[
|
||||||
|
@ -62,6 +72,16 @@ class Search
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setLogs($params)
|
||||||
|
{
|
||||||
|
return SearchModel::setSearchLogs($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getLogs($limit)
|
||||||
|
{
|
||||||
|
return SearchModel::getSearchLogs($limit);
|
||||||
|
}
|
||||||
|
|
||||||
public static function stemmer($query)
|
public static function stemmer($query)
|
||||||
{
|
{
|
||||||
require_once __DIR__ . '/../vendor/autoload.php';
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
'name' => 'post_feature',
|
'name' => 'post_feature',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => Translate::get('close'),
|
'title' => Translate::get('close?'),
|
||||||
'name' => 'closed',
|
'name' => 'closed',
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
'content' => $post['post_content'],
|
'content' => $post['post_content'],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?php if ($post['post_draft'] > 2) { ?>
|
<?php if ($post['post_draft'] > UserData::USER_FIRST_LEVEL) { ?>
|
||||||
<?= Tpl::import('/_block/form/radio', [
|
<?= Tpl::import('/_block/form/radio', [
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
'checked' => $post['post_feature']
|
'checked' => $post['post_feature']
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => Translate::get('close'),
|
'title' => Translate::get('close?'),
|
||||||
'name' => 'closed',
|
'name' => 'closed',
|
||||||
'checked' => $post['post_closed']
|
'checked' => $post['post_closed']
|
||||||
],
|
],
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
]
|
]
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?php if ($user['trust_level'] > 3) { ?>
|
<?php if ($user['trust_level'] == UserData::REGISTERED_ADMIN) { ?>
|
||||||
<?= Tpl::import('/_block/form/radio', [
|
<?= Tpl::import('/_block/form/radio', [
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
'name' => 'post_feature',
|
'name' => 'post_feature',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => Translate::get('close'),
|
'title' => Translate::get('close?'),
|
||||||
'name' => 'closed',
|
'name' => 'closed',
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
]); ?>
|
]); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if ($user['trust_level'] > 2) { ?>
|
<?php if ($user['trust_level'] > > UserData::USER_FIRST_LEVEL) { ?>
|
||||||
<?= Tpl::import('/_block/form/select/content-tl', [
|
<?= Tpl::import('/_block/form/select/content-tl', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'data' => $post['post_tl']
|
'data' => $post['post_tl']
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
'checked' => $post['post_feature']
|
'checked' => $post['post_feature']
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'title' => Translate::get('close'),
|
'title' => Translate::get('close?'),
|
||||||
'name' => 'closed',
|
'name' => 'closed',
|
||||||
'checked' => $post['post_closed']
|
'checked' => $post['post_closed']
|
||||||
],
|
],
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
]
|
]
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?php if ($user['trust_level'] > 3) { ?>
|
<?php if ($user['trust_level'] == UserData::REGISTERED_ADMIN) { ?>
|
||||||
<?= Tpl::import('/_block/form/radio', [
|
<?= Tpl::import('/_block/form/radio', [
|
||||||
'data' => [
|
'data' => [
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in a new issue