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 1cceb9f9
authored
2021-06-16 16:45:12 +0300
by
san58
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
обвязка логированием
1 parent
4c88ee32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
commands/ScanController.php
components/Collection.php
commands/ScanController.php
View file @
1cceb9f
...
...
@@ -60,9 +60,12 @@ class ScanController extends Controller
$filters
=
[
'1'
=>
Collection
::
get_filter
(
Filter
::
TYPE_1
),
'2'
=>
Collection
::
get_filter
(
Filter
::
TYPE_2
),
'3'
=>
Collection
::
get_filter
(
Filter
::
TYPE_3
)];
$csv_datatime
=
''
;
$progress
=
0
;
while
((
$csv_data
=
fgetcsv
(
$csv_handle
,
1024
,
';'
))
!==
false
)
$time_start
=
0
;
while
((
$csv_data
=
fgetcsv
(
$csv_handle
,
1024
,
';'
))
!==
false
&&
$csv_row
<
2920
)
{
if
(
$csv_row
===
2900
){
$time_cuttent
=
microtime
(
true
);
echo
"
\n
"
.
't1 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
$file_pos
=
ftell
(
$csv_handle
);
if
(
$csv_row
===
2900
){
$time_cuttent
=
microtime
(
true
);
echo
't2 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
if
(
$file_pos
!==
false
&&
$file_size
>
0
)
{
$progress_current
=
(
int
)
round
(
10
*
$file_pos
/
$file_size
);
...
...
@@ -74,6 +77,7 @@ class ScanController extends Controller
unset
(
$progress_current
);
}
if
(
$csv_row
===
2900
){
$time_cuttent
=
microtime
(
true
);
echo
't3 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
$csv_row
++
;
if
(
$csv_row
===
1
)
$csv_datatime
=
date
(
...
...
@@ -84,17 +88,24 @@ class ScanController extends Controller
);
elseif
(
isset
(
$csv_data
[
1
])
===
true
)
{
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't4 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
$host
=
Collection
::
domain_filter
(
$csv_data
[
1
]);
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't5 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
if
(
$host
===
false
)
$csv_skip_row
++
;
{
$csv_skip_row
++
;
}
else
{
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't6 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
$status
=
[
'1'
=>
(
Collection
::
apply_filter
(
$host
,
$filters
[
'1'
])
===
false
?
Host
::
STATUS_OFF
:
Host
::
STATUS_ON
),
'2'
=>
(
Collection
::
apply_filter
(
$host
,
$filters
[
'2'
])
===
false
?
Host
::
STATUS_OFF
:
Host
::
STATUS_ON
),
'3'
=>
(
Collection
::
apply_filter
(
$host
,
$filters
[
'3'
])
===
false
?
Host
::
STATUS_OFF
:
Host
::
STATUS_ON
)
];
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't7 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
$db_request
=
Yii
::
$app
->
db
->
createCommand
();
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't8 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
if
(
$db_request
)
{
$host_bd
=
(
new
Query
())
...
...
@@ -103,6 +114,7 @@ class ScanController extends Controller
->
where
(
'domain=:host'
,
array
(
':host'
=>
$host
))
->
limit
(
1
)
->
one
();
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't9 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
if
(
$host_bd
===
false
)
{
$db_request
->
insert
(
...
...
@@ -118,9 +130,11 @@ class ScanController extends Controller
]
)
->
execute
();
$rec
[
'insert'
]
++
;
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't10 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
}
elseif
(
isset
(
$host_bd
[
'csv_date'
])
&&
$host_bd
[
'csv_date'
]
!==
$csv_datatime
)
{
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't11 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
$db_request
->
update
(
'{{%host}}'
,
[
...
...
@@ -134,19 +148,24 @@ class ScanController extends Controller
]
)
->
execute
();
$rec
[
'update'
]
++
;
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't12 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
}
unset
(
$host_bd
);
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't13 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
}
else
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Error create DB request'
);
unset
(
$db_request
);
unset
(
$status
);
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't14 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
}
unset
(
$host
);
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't15 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
}
else
$csv_skip_row
++
;
unset
(
$file_pos
);
if
(
$csv_row
===
2901
){
$time_cuttent
=
microtime
(
true
);
echo
't16 '
.
(
$time_cuttent
-
$time_start
)
.
"
\n
"
;
$time_start
=
$time_cuttent
;}
}
unset
(
$progress
);
unset
(
$csv_data
);
...
...
components/Collection.php
View file @
1cceb9f
...
...
@@ -32,11 +32,11 @@ class Collection extends Component
$host_parts
=
array_reverse
(
$host_parts
);
$host_parts
=
array_slice
(
$host_parts
,
0
,
2
);
$host_parts
=
array_reverse
(
$host_parts
);
if
(
count
(
$host_parts
)
===
2
)
$out
=
$host
;
$out
=
implode
(
'.'
,
$host_parts
)
;
unset
(
$host_parts
);
}
unset
(
$host
);
return
$out
;
}
...
...
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