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 bf528dec
authored
2021-06-08 18:51:38 +0300
by
san58
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
реализация применения фильтров
1 parent
8289f5ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
commands/ScanController.php
controllers/AjaxController.php
commands/ScanController.php
View file @
bf528de
...
@@ -89,7 +89,7 @@ class ScanController extends Controller
...
@@ -89,7 +89,7 @@ class ScanController extends Controller
$csv_skip_row
++
;
$csv_skip_row
++
;
else
else
{
{
$status
=
(
Collection
::
apply_filter
(
$host
,
$filters
[
'after'
])
===
false
?
Filter
::
STATUS_OFF
:
Filter
::
STATUS_ON
);
$status
=
(
Collection
::
apply_filter
(
$host
,
$filters
[
'after'
])
===
false
?
Host
::
STATUS_OFF
:
Host
::
STATUS_ON
);
$db_request
=
Yii
::
$app
->
db
->
createCommand
();
$db_request
=
Yii
::
$app
->
db
->
createCommand
();
if
(
$db_request
)
if
(
$db_request
)
{
{
...
...
controllers/AjaxController.php
View file @
bf528de
...
@@ -51,11 +51,37 @@ class AjaxController extends Controller
...
@@ -51,11 +51,37 @@ class AjaxController extends Controller
*/
*/
public
function
actionCalcStatus
()
public
function
actionCalcStatus
()
{
{
$query
=
(
new
Query
())
->
from
(
'{{%host}}'
);
$update
=
[
foreach
(
$query
->
batch
(
10
)
as
$hosts
)
{
Host
::
STATUS_OFF
=>
[],
Host
::
STATUS_ON
=>
[]
}
];
$filters
=
Collection
::
get_filter
(
Filter
::
TYPE_AFTER
);
$query
=
(
new
Query
())
->
select
(
'id, domain'
)
->
from
(
'{{%host}}'
);
if
(
$query
)
foreach
(
$query
->
batch
(
1000
)
as
$hosts
)
{
foreach
(
$hosts
as
$host
)
$update
[(
Collection
::
apply_filter
(
$host
[
'domain'
],
$filters
)
===
false
?
Host
::
STATUS_OFF
:
Host
::
STATUS_ON
)][]
=
$host
[
'id'
];
unset
(
$host
);
if
(
count
(
$update
[
Filter
::
STATUS_OFF
])
>
0
)
{
Yii
::
$app
->
db
->
createCommand
()
->
update
(
'{{%host}}'
,
[
'status'
=>
Host
::
STATUS_OFF
],
[
'in'
,
'id'
,
$update
[
Host
::
STATUS_OFF
]])
->
execute
();
$update
[
Host
::
STATUS_OFF
]
=
[];
}
if
(
count
(
$update
[
Host
::
STATUS_ON
])
>
0
)
{
Yii
::
$app
->
db
->
createCommand
()
->
update
(
'{{%host}}'
,
[
'status'
=>
Host
::
STATUS_ON
],
[
'in'
,
'id'
,
$update
[
Host
::
STATUS_ON
]])
->
execute
();
$update
[
Host
::
STATUS_ON
]
=
[];
}
}
unset
(
$hosts
);
unset
(
$query
);
unset
(
$filters
);
unset
(
$update
);
return
[
return
[
'controller'
=>
'ajax'
,
'controller'
=>
'ajax'
,
'is_guest'
=>
Yii
::
$app
->
user
->
isGuest
,
'is_guest'
=>
Yii
::
$app
->
user
->
isGuest
,
...
...
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