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 c1a617cb
authored
2021-06-04 17:14:27 +0300
by
san58
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
отладка фильтрации
1 parent
5de22083
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
14 deletions
commands/ScanController.php
components/Collection.php
models/Filter.php
commands/ScanController.php
View file @
c1a617c
...
@@ -64,13 +64,10 @@ class ScanController extends Controller
...
@@ -64,13 +64,10 @@ class ScanController extends Controller
);
);
elseif
(
isset
(
$csv_data
[
1
])
===
true
)
elseif
(
isset
(
$csv_data
[
1
])
===
true
)
{
{
$host
=
str_replace
(
$host
=
Collection
::
domain_filter
(
$csv_data
[
1
]);
'*.'
,
if
(
$host
===
false
)
''
,
$csv_skip_row
++
;
utf8_encode
(
$csv_data
[
1
])
else
);
$host_level
=
count
(
explode
(
'.'
,
$host
)
);
if
(
$host_level
===
2
)
{
{
$db_request
=
Yii
::
$app
->
db
->
createCommand
();
$db_request
=
Yii
::
$app
->
db
->
createCommand
();
if
(
$db_request
)
if
(
$db_request
)
...
@@ -112,9 +109,6 @@ class ScanController extends Controller
...
@@ -112,9 +109,6 @@ class ScanController extends Controller
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Error create DB request'
);
echo
PHP_EOL
.
$this
->
ansiFormat
(
'! Error create DB request'
);
unset
(
$db_request
);
unset
(
$db_request
);
}
}
else
$csv_skip_row
++
;
unset
(
$host_level
);
unset
(
$host
);
unset
(
$host
);
}
}
else
else
...
...
components/Collection.php
View file @
c1a617c
...
@@ -3,10 +3,60 @@
...
@@ -3,10 +3,60 @@
namespace
app\components
;
namespace
app\components
;
use
Yii
;
use
Yii
;
use
app\models\Filter
;
use
yii\base\Component
;
use
yii\base\Component
;
use
yii\db\Query
;
class
Collection
extends
Component
class
Collection
extends
Component
{
{
//Скачиваине URL файла и передача пути к нему
public
static
function
domain_filter
(
$domain
)
{
$out
=
false
;
$host
=
str_replace
(
'*.'
,
''
,
utf8_encode
(
$domain
)
);
$host_level
=
count
(
explode
(
'.'
,
$host
)
);
if
(
$host_level
===
2
)
{
$filtes_bd
=
(
new
Query
())
->
select
(
'`pattern`, `include`'
)
->
from
(
'{{%filters}}'
)
->
where
(
'type=:type AND status=:status'
,
array
(
':type'
=>
Filter
::
TYPE_BEFORE
,
':status'
=>
Filter
::
STATUS_ON
))
->
all
();
if
(
$filtes_bd
!==
false
)
{
$fiter_check
=
true
;
foreach
(
$filtes_bd
as
$filter
)
{
$find
=
preg_match
(
$filter
[
'pattern'
],
$host
);
if
(
$host
===
'002cc20.icu'
)
echo
' > i:'
.
$filter
[
'include'
]
.
' result:'
.
$find
.
' if1:'
.
((
$find
===
1
&&
$filter
[
'include'
]
===
Filter
::
INCLUDE_OFF
)
?
1
:
0
)
.
' if2:'
.
((
$find
===
0
&&
$filter
[
'include'
]
===
Filter
::
INCLUDE_ON
)
?
1
:
0
)
.
"
\n
"
;
if
(
(
$find
===
1
&&
$filter
[
'include'
]
===
Filter
::
INCLUDE_OFF
)
||
(
$find
===
0
&&
$filter
[
'include'
]
===
Filter
::
INCLUDE_ON
)
)
{
$fiter_check
=
false
;
break
;
}
unset
(
$find
);
}
unset
(
$filter
);
if
(
$fiter_check
===
true
)
$out
=
(
string
)
$host
;
unset
(
$fiter_check
);
}
unset
(
$filtes_bd
);
}
unset
(
$host_level
);
unset
(
$host
);
return
$out
;
}
//Скачиваине URL файла и передача пути к нему
//Скачиваине URL файла и передача пути к нему
public
static
function
download_file
(
$csvFile
)
public
static
function
download_file
(
$csvFile
)
{
{
...
...
models/Filter.php
View file @
c1a617c
...
@@ -18,8 +18,8 @@ use yii\db\Expression;
...
@@ -18,8 +18,8 @@ use yii\db\Expression;
*/
*/
class
Filter
extends
\yii\db\ActiveRecord
class
Filter
extends
\yii\db\ActiveRecord
{
{
const
INCLUDE_O
N
=
0
;
//включая
const
INCLUDE_O
FF
=
0
;
//включая
const
INCLUDE_O
FF
=
1
;
//выключая
const
INCLUDE_O
N
=
1
;
//выключая
const
STATUS_OFF
=
0
;
//выкл
const
STATUS_OFF
=
0
;
//выкл
const
STATUS_ON
=
1
;
//вкл
const
STATUS_ON
=
1
;
//вкл
...
@@ -92,8 +92,8 @@ class Filter extends \yii\db\ActiveRecord
...
@@ -92,8 +92,8 @@ class Filter extends \yii\db\ActiveRecord
public
static
function
getIncludes
(
$inc
=
false
)
public
static
function
getIncludes
(
$inc
=
false
)
{
{
$arr
=
[
$arr
=
[
self
::
INCLUDE_ON
=>
'
Before
'
,
self
::
INCLUDE_ON
=>
'
Yes
'
,
self
::
INCLUDE_OFF
=>
'
After
'
self
::
INCLUDE_OFF
=>
'
No
'
];
];
if
(
is_numeric
(
$inc
))
{
if
(
is_numeric
(
$inc
))
{
if
(
array_key_exists
(
$inc
,
$arr
))
{
if
(
array_key_exists
(
$inc
,
$arr
))
{
...
...
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