Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Alto
/
rkn
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit b036aba8
authored
2021-06-02 16:48:50 +0300
by
san58
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Обновление даты CSV у доменов
1 parent
2659413c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
27 deletions
commands/ScanController.php
config/web.php
models/Host.php
modules/admin/views/host/index.php
modules/admin/views/layouts/admin.php
commands/ScanController.php
View file @
b036aba
...
...
@@ -7,7 +7,7 @@ use yii\console\Controller;
use
yii\db\Expression
;
use
yii\helpers\Console
;
use
app\components\Collection
;
use
app\
jobs\HostJob
;
use
app\
models\Host
;
/**
* Парсинг запрещенных ресурсов в РФ.
...
...
@@ -40,17 +40,30 @@ class ScanController extends Controller
public
function
actionIndex
()
{
$hosts
=
Collection
::
getHostsByCsv
(
Yii
::
$app
->
params
[
'csv_url'
]);
$grabUrls
=
Yii
::
$app
->
params
[
'registrators_urls'
];
foreach
(
$hosts
[
'data'
]
as
$host
)
{
$res
=
Yii
::
$app
->
db
->
createCommand
()
->
insert
(
'{{%host}}'
,
[
'domain'
=>
utf8
(
$host
),
$csv_date
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
$hosts
[
'csv_date'
]));
foreach
(
$hosts
[
'data'
]
as
$host
)
{
$host_utf8
=
utf8_encode
(
$host
);
$res
=
Yii
::
$app
->
db
->
createCommand
();
if
(
Host
::
find
()
->
where
([
'domain'
=>
$host_utf8
])
->
count
()
)
$res
->
update
(
'{{%host}}'
,
[
'csv_date'
=>
$csv_date
],
[
'domain'
=>
$host_utf8
]
);
else
$res
->
insert
(
'{{%host}}'
,
[
'domain'
=>
$host_utf8
,
'created_at'
=>
new
Expression
(
'NOW()'
),
'csv_date'
=>
date
(
"Y-m-d H:i:s"
,
strtotime
(
$hosts
[
'csv_date'
])),
])
->
execute
();
/* $ids[] = (int)Yii::$app->queue->push(new HostJob([
'host' => $host,
'grabSource' => $grabUrls[array_rand($grabUrls)]
]));*/
'csv_date'
=>
$csv_date
,
]
);
$res
->
execute
();
}
echo
"
\n
"
.
$this
->
ansiFormat
(
'Количество полученных хостов'
,
Console
::
FG_CYAN
)
.
' => '
.
$this
->
ansiFormat
(
count
(
$hosts
[
'data'
]),
Console
::
BOLD
,
Console
::
FG_GREEN
)
.
"
\n
"
;
...
...
config/web.php
View file @
b036aba
...
...
@@ -5,7 +5,7 @@ $db = require __DIR__ . '/db.php';
$config
=
[
'id'
=>
'basic'
,
'name'
=>
'
Новый проект
'
,
'name'
=>
'
РКН
'
,
'basePath'
=>
dirname
(
__DIR__
),
'bootstrap'
=>
[
'log'
],
'language'
=>
'en-EN'
,
...
...
models/Host.php
View file @
b036aba
...
...
@@ -67,12 +67,12 @@ class Host extends \yii\db\ActiveRecord
{
return
[
'id'
=>
'ID'
,
'domain'
=>
'
Домен
'
,
'created_at'
=>
'
Дата записи
'
,
'csv_date'
=>
'
Дата
CSV'
,
'wis_date'
=>
'
Дата проверки домена
'
,
'wis_status'
=>
'
Статус
'
,
'tix'
=>
'
Показатель
'
,
'domain'
=>
'
Domain
'
,
'created_at'
=>
'
Date
'
,
'csv_date'
=>
'
Date
CSV'
,
'wis_date'
=>
'
Date WHOIS
'
,
'wis_status'
=>
'
Status
'
,
'tix'
=>
'
TIX
'
,
];
}
...
...
@@ -89,9 +89,9 @@ class Host extends \yii\db\ActiveRecord
public
static
function
getStatus
(
$status
=
false
)
{
$arr
=
[
self
::
STATUS_NONE
=>
'
Неизвестный
'
,
self
::
STATUS_FREE
=>
'
Свободный
'
,
self
::
STATUS_BUSY
=>
'
Занятый
'
,
self
::
STATUS_NONE
=>
'
No checked
'
,
self
::
STATUS_FREE
=>
'
FREE
'
,
self
::
STATUS_BUSY
=>
'
BUSY
'
,
];
if
(
is_numeric
(
$status
))
{
if
(
array_key_exists
(
$status
,
$arr
))
{
...
...
modules/admin/views/host/index.php
View file @
b036aba
...
...
@@ -8,16 +8,16 @@ use yii\widgets\Pjax;
/* @var $searchModel app\models\HostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this
->
title
=
'
Host
s'
;
$this
->
title
=
'
List of domain
s'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<div
class=
"host-index"
>
<h1>
<?=
Html
::
encode
(
$this
->
title
)
?>
</h1>
<p>
<
!--
p>
<?=
Html
::
a
(
'Create Host'
,
[
'create'
],
[
'class'
=>
'btn btn-success'
])
?>
</p>
</p
--
>
<?php
Pjax
::
begin
();
?>
<?php
// echo $this->render('_search', ['model' => $searchModel]); ?>
...
...
modules/admin/views/layouts/admin.php
View file @
b036aba
...
...
@@ -38,8 +38,8 @@ AdminAsset::register($this);
echo
Nav
::
widget
([
'options'
=>
[
'class'
=>
'navbar-nav navbar-right'
],
'items'
=>
[
[
'label'
=>
'
Главная
'
,
'url'
=>
[
'/site/index'
]],
[
'label'
=>
'
Выйти
('
.
Yii
::
$app
->
user
->
identity
->
name
.
')'
,
'url'
=>
[
'/auth/logout'
]],
[
'label'
=>
'
Home
'
,
'url'
=>
[
'/site/index'
]],
[
'label'
=>
'
Logout
('
.
Yii
::
$app
->
user
->
identity
->
name
.
')'
,
'url'
=>
[
'/auth/logout'
]],
],
]);
NavBar
::
end
();
...
...
@@ -69,7 +69,7 @@ AdminAsset::register($this);
<div
class=
"container"
>
<p
class=
"pull-left"
>
©
<?php
echo
Yii
::
$app
->
name
;
?>
<?php
$d
=
date
(
'Y'
);
echo
((
$d
-
202
0
)
?
'2020
- '
.
$d
:
$d
);
?>
echo
((
$d
-
202
1
)
?
'2021
- '
.
$d
:
$d
);
?>
</p>
</div>
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment