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 d7537307
authored
2021-06-08 14:02:05 +0300
by
san58
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
отображение TIX везде
статистика при парсиге
1 parent
d5634021
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
7 deletions
commands/ScanController.php
components/Collection.php
models/Host.php
models/HostSearch.php
views/host/_form.php
views/host/index.php
views/host/view.php
commands/ScanController.php
View file @
d753730
...
@@ -44,18 +44,36 @@ class ScanController extends Controller
...
@@ -44,18 +44,36 @@ class ScanController extends Controller
$rec
=
[
'insert'
=>
0
,
'update'
=>
0
];
$rec
=
[
'insert'
=>
0
,
'update'
=>
0
];
$csv_row
=
0
;
$csv_row
=
0
;
$csv_skip_row
=
0
;
$csv_skip_row
=
0
;
echo
PHP_EOL
.
'Start datatime '
.
$this
->
ansiFormat
(
date
(
'Y.m.d H:i:s'
),
Console
::
FG_CYAN
);
echo
PHP_EOL
.
$this
->
ansiFormat
(
'Download file: '
.
Yii
::
$app
->
params
[
'csv_url'
],
Console
::
FG_CYAN
);
echo
PHP_EOL
.
$this
->
ansiFormat
(
'Download file: '
.
Yii
::
$app
->
params
[
'csv_url'
],
Console
::
FG_CYAN
);
$csv_file
=
Collection
::
download_file
(
Yii
::
$app
->
params
[
'csv_url'
]);
$csv_file
=
Collection
::
download_file
(
Yii
::
$app
->
params
[
'csv_url'
]);
if
(
$csv_file
!==
''
)
if
(
$csv_file
!==
''
)
{
{
echo
PHP_EOL
.
$this
->
ansiFormat
(
'Start parse file: '
.
$csv_file
,
Console
::
FG_CYAN
);
$file_size
=
filesize
(
$csv_file
);
if
(
$file_size
===
false
)
$file_size
=
0
;
echo
PHP_EOL
.
$this
->
ansiFormat
(
'Start parse file: '
.
$csv_file
.
' size: '
.
Collection
::
human_filesize
(
$file_size
),
Console
::
FG_CYAN
);
$csv_handle
=
fopen
(
$csv_file
,
'r'
);
$csv_handle
=
fopen
(
$csv_file
,
'r'
);
if
(
$csv_handle
!==
false
)
if
(
$csv_handle
!==
false
)
{
{
$filters
=
[
'before'
=>
Collection
::
get_filter
(
Filter
::
TYPE_BEFORE
),
'after'
=>
Collection
::
get_filter
(
Filter
::
TYPE_AFTER
)];
$filters
=
[
'before'
=>
Collection
::
get_filter
(
Filter
::
TYPE_BEFORE
),
'after'
=>
Collection
::
get_filter
(
Filter
::
TYPE_AFTER
)];
$csv_datatime
=
''
;
$csv_datatime
=
''
;
$progress
=
0
;
while
((
$csv_data
=
fgetcsv
(
$csv_handle
,
1024
,
';'
))
!==
false
)
while
((
$csv_data
=
fgetcsv
(
$csv_handle
,
1024
,
';'
))
!==
false
)
{
{
$file_pos
=
ftell
(
$csv_handle
);
if
(
$file_pos
!==
false
&&
$file_size
>
0
)
{
$progress_current
=
(
int
)
round
(
10
*
$file_pos
/
$file_size
);
if
(
$progress
!==
$progress_current
)
{
$progress
=
$progress_current
;
echo
PHP_EOL
.
'Time: '
.
date
(
'Y.m.d H:i:s'
)
.
' Progress: '
.
(
10
*
$progress
)
.
'% domains: '
.
$csv_row
;
}
unset
(
$progress_current
);
}
$csv_row
++
;
$csv_row
++
;
if
(
$csv_row
===
1
)
if
(
$csv_row
===
1
)
$csv_datatime
=
date
(
$csv_datatime
=
date
(
...
@@ -119,7 +137,9 @@ class ScanController extends Controller
...
@@ -119,7 +137,9 @@ class ScanController extends Controller
}
}
else
else
$csv_skip_row
++
;
$csv_skip_row
++
;
unset
(
$file_pos
);
}
}
unset
(
$progress
);
unset
(
$csv_data
);
unset
(
$csv_data
);
unset
(
$csv_datatime
);
unset
(
$csv_datatime
);
unset
(
$filters
);
unset
(
$filters
);
...
@@ -129,6 +149,7 @@ class ScanController extends Controller
...
@@ -129,6 +149,7 @@ class ScanController extends Controller
else
else
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Not file open for read'
);
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Not file open for read'
);
unset
(
$csv_handle
);
unset
(
$csv_handle
);
unset
(
$file_size
);
}
}
else
else
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Not file download'
);
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Not file download'
);
...
...
components/Collection.php
View file @
d753730
...
@@ -9,6 +9,13 @@ use yii\db\Query;
...
@@ -9,6 +9,13 @@ use yii\db\Query;
class
Collection
extends
Component
class
Collection
extends
Component
{
{
//Отображение размера файла
public
static
function
human_filesize
(
$bytes
,
$decimals
=
2
)
{
$sz
=
'BKMGTP'
;
$factor
=
floor
((
strlen
(
$bytes
)
-
1
)
/
3
);
return
sprintf
(
"%.
{
$decimals
}
f"
,
$bytes
/
pow
(
1024
,
$factor
))
.
@
$sz
[
$factor
];
}
//Фильтрация фомена
//Фильтрация фомена
public
static
function
domain_filter
(
$domain
,
$filters
)
public
static
function
domain_filter
(
$domain
,
$filters
)
...
...
models/Host.php
View file @
d753730
...
@@ -61,8 +61,8 @@ class Host extends \yii\db\ActiveRecord
...
@@ -61,8 +61,8 @@ class Host extends \yii\db\ActiveRecord
return
[
return
[
[[
'domain'
],
'required'
],
[[
'domain'
],
'required'
],
[
'wis_status'
,
'in'
,
'range'
=>
array_keys
(
self
::
getWisStatus
())],
[
'wis_status'
,
'in'
,
'range'
=>
array_keys
(
self
::
getWisStatus
())],
[[
'created_at'
,
'csv_date'
,
'wis_date'
,
'domain_expire'
],
'safe'
],
[[
'created_at'
,
'csv_date'
,
'wis_date'
,
'domain_expire'
,
'tix_date'
],
'safe'
],
[[
'wis_status'
,
'tix'
,
'status'
],
'integer'
],
[[
'wis_status'
,
'tix'
,
'status'
,
'tix_status'
],
'integer'
],
[[
'domain'
],
'string'
,
'max'
=>
256
],
[[
'domain'
],
'string'
,
'max'
=>
256
],
[[
'domain'
],
'unique'
],
[[
'domain'
],
'unique'
],
];
];
...
@@ -82,6 +82,8 @@ class Host extends \yii\db\ActiveRecord
...
@@ -82,6 +82,8 @@ class Host extends \yii\db\ActiveRecord
'wis_status'
=>
'Can registration'
,
'wis_status'
=>
'Can registration'
,
'domain_expire'
=>
'Date expired'
,
'domain_expire'
=>
'Date expired'
,
'tix'
=>
'TIX'
,
'tix'
=>
'TIX'
,
'tix_status'
=>
'TIX status'
,
'tix_date'
=>
'Date TIX'
,
'status'
=>
'Status'
'status'
=>
'Status'
];
];
}
}
...
@@ -125,4 +127,19 @@ class Host extends \yii\db\ActiveRecord
...
@@ -125,4 +127,19 @@ class Host extends \yii\db\ActiveRecord
}
}
return
$arr
;
return
$arr
;
}
}
public
static
function
getTIXStatus
(
$status
=
false
)
{
$arr
=
[
self
::
STATUS_TIX_UNCHECK
=>
'No checked'
,
self
::
STATUS_TIX_CHECK
=>
'Checked'
,
];
if
(
is_numeric
(
$status
))
{
if
(
array_key_exists
(
$status
,
$arr
))
{
return
$arr
[
$status
];
}
return
$status
;
}
return
$arr
;
}
}
}
models/HostSearch.php
View file @
d753730
...
@@ -17,8 +17,8 @@ class HostSearch extends Host
...
@@ -17,8 +17,8 @@ class HostSearch extends Host
public
function
rules
()
public
function
rules
()
{
{
return
[
return
[
[[
'id'
,
'wis_status'
,
'tix'
,
'status'
],
'integer'
],
[[
'id'
,
'wis_status'
,
'tix'
,
'status'
,
'tix_status'
],
'integer'
],
[[
'domain'
,
'created_at'
,
'csv_date'
,
'wis_date'
,
'wis_status'
,
'domain_expire'
,
'status'
],
'safe'
],
[[
'domain'
,
'created_at'
,
'csv_date'
,
'wis_date'
,
'wis_status'
,
'domain_expire'
,
'status'
,
'tix_date'
,
'tix_status'
],
'safe'
],
];
];
}
}
...
@@ -63,6 +63,7 @@ class HostSearch extends Host
...
@@ -63,6 +63,7 @@ class HostSearch extends Host
//'csv_date' => $this->csv_date,
//'csv_date' => $this->csv_date,
//'wis_date' => $this->wis_date,
//'wis_date' => $this->wis_date,
'wis_status'
=>
$this
->
wis_status
,
'wis_status'
=>
$this
->
wis_status
,
'tix_status'
=>
$this
->
tix_status
,
//'domain_expire' => $this->domain_expire,
//'domain_expire' => $this->domain_expire,
'tix'
=>
$this
->
tix
,
'tix'
=>
$this
->
tix
,
'status'
=>
$this
->
status
'status'
=>
$this
->
status
...
...
views/host/_form.php
View file @
d753730
...
@@ -25,9 +25,13 @@ use app\models\Host;
...
@@ -25,9 +25,13 @@ use app\models\Host;
<?=
$form
->
field
(
$model
,
'tix'
)
->
textInput
()
?>
<?=
$form
->
field
(
$model
,
'tix'
)
->
textInput
()
?>
<?=
$form
->
field
(
$model
,
'
wis_status'
,
[
'options'
=>
[
'class'
=>
'form-group col-xs-12'
]])
->
dropDownList
(
Host
::
getWisStatus
()
)
?>
<?=
$form
->
field
(
$model
,
'
tix_date'
)
->
textInput
(
)
?>
<?=
$form
->
field
(
$model
,
'status'
,
[
'options'
=>
[
'class'
=>
'form-group col-xs-12'
]])
->
dropDownList
(
Host
::
getStatus
())
?>
<?=
$form
->
field
(
$model
,
'tix_status'
,
[
'options'
=>
[
'class'
=>
'form-group'
]])
->
dropDownList
(
Host
::
getTIXStatus
())
?>
<?=
$form
->
field
(
$model
,
'wis_status'
,
[
'options'
=>
[
'class'
=>
'form-group'
]])
->
dropDownList
(
Host
::
getWisStatus
())
?>
<?=
$form
->
field
(
$model
,
'status'
,
[
'options'
=>
[
'class'
=>
'form-group'
]])
->
dropDownList
(
Host
::
getStatus
())
?>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Save'
,
[
'class'
=>
'btn btn-success'
])
?>
<?=
Html
::
submitButton
(
'Save'
,
[
'class'
=>
'btn btn-success'
])
?>
...
...
views/host/index.php
View file @
d753730
...
@@ -56,6 +56,16 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -56,6 +56,16 @@ $this->params['breadcrumbs'][] = $this->title;
'wis_date'
,
'wis_date'
,
'domain_expire'
,
'domain_expire'
,
'tix'
,
'tix'
,
'tix_status'
=>
[
'attribute'
=>
'tix_status'
,
'filter'
=>
\app\models\Host
::
getTIXStatus
(),
'format'
=>
'raw'
,
'value'
=>
function
(
$model
)
{
return
$model
::
getTIXStatus
(
$model
->
status
);
},
],
'tix_date'
,
'status'
=>
'status'
=>
[
[
'attribute'
=>
'status'
,
'attribute'
=>
'status'
,
...
...
views/host/view.php
View file @
d753730
...
@@ -44,6 +44,16 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -44,6 +44,16 @@ $this->params['breadcrumbs'][] = $this->title;
},
},
],
],
'tix'
,
'tix'
,
'tix_date'
,
'tix_status'
=>
[
'attribute'
=>
'tix_status'
,
'filter'
=>
Host
::
getTIXStatus
(),
'format'
=>
'raw'
,
'value'
=>
function
(
$model
)
{
return
$model
::
getTIXStatus
(
$model
->
status
);
},
],
[
[
'attribute'
=>
'status'
,
'attribute'
=>
'status'
,
'filter'
=>
Host
::
getStatus
(),
'filter'
=>
Host
::
getStatus
(),
...
...
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