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 f695cd54
authored
2021-06-07 16:24:04 +0300
by
san58
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
проверка TIX
1 parent
c3ad4cd5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
1 deletions
commands/TixController.php
components/Collection.php
config/params.php
models/Host.php
commands/TixController.php
0 → 100644
View file @
f695cd5
<?php
namespace
app\commands
;
use
PHPHtmlParser\Dom
;
use
yii\db\Query
;
use
yii
;
use
yii\console\Controller
;
use
yii\db\Expression
;
use
yii\helpers\Console
;
use
app\components\Collection
;
use
app\models\Host
;
use
app\models\Filter
;
/**
* Парсинг запрещенных ресурсов в РФ.
*/
class
TixController
extends
Controller
{
public
$count
=
10
;
public
function
beforeAction
(
$action
)
{
if
(
!
parent
::
beforeAction
(
$action
))
{
return
false
;
}
return
true
;
}
public
function
options
(
$actionID
)
{
return
[
'count'
];
}
public
function
optionAliases
()
{
return
[
'c'
=>
'count'
];
}
/**
* Парсинг запрещенных ресурсов в РФ.
*/
public
function
actionIndex
()
{
$hosts
=
(
new
Query
())
->
select
(
'id, domain'
)
->
from
(
'{{%host}}'
)
->
where
(
[
'wis_status'
=>
Host
::
STATUS_WIS_FREE
,
'tix_status'
=>
Host
::
STATUS_TIX_UNCHECK
]
)
->
orderBy
([
'status'
=>
SORT_DESC
,
'rand()'
=>
SORT_ASC
])
->
limit
(
$this
->
count
)
->
all
();
foreach
(
$hosts
as
$h
)
{
$host
=
$h
[
'domain'
];
$result
=
Collection
::
getTixRawData
(
Yii
::
$app
->
params
[
'tix_url'
]
.
$host
);
if
(
$result
[
'errorno'
])
echo
$result
[
'errorno'
]
.
' '
.
$result
[
'errormessage'
];
else
if
(
$result
[
'data'
][
'status'
]
===
'OK'
)
$this
->
upTix
(
$result
[
'data'
][
'domain'
],
$result
[
'data'
][
'govalue'
]);
else
echo
'! '
.
$host
.
' - '
.
$result
[
'data'
][
'message'
]
.
' ('
.
$result
[
'data'
][
'status'
]
.
')'
;
unset
(
$host
);
usleep
(
1000
);
}
unset
(
$h
);
unset
(
$hosts
);
}
private
function
upTix
(
$domain
,
$value
=
0
)
{
echo
$domain
.
' => '
.
$value
.
"
\n
"
;
$update
=
[
'tix'
=>
(
int
)
$value
,
'tix_status'
=>
Host
::
STATUS_TIX_CHECK
,
'tix_date'
=>
new
Expression
(
'NOW()'
)];
Yii
::
$app
->
db
->
createCommand
()
->
update
(
'{{%host}}'
,
$update
,
[
'domain'
=>
$domain
])
->
execute
();
}
}
\ No newline at end of file
\ No newline at end of file
components/Collection.php
View file @
f695cd5
...
@@ -112,5 +112,22 @@ class Collection extends Component
...
@@ -112,5 +112,22 @@ class Collection extends Component
return
[
'data'
=>
$response
,
'errorno'
=>
$errorNum
,
'errormessage'
=>
$errorMsg
];
return
[
'data'
=>
$response
,
'errorno'
=>
$errorNum
,
'errormessage'
=>
$errorMsg
];
}
}
public
static
function
getTixRawData
(
$url
)
{
$ch
=
curl_init
(
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
0
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
0
);
$response
=
curl_exec
(
$ch
);
$errorNum
=
curl_errno
(
$ch
);
$errorMsg
=
curl_error
(
$ch
);
curl_close
(
$ch
);
return
[
'data'
=>
json_decode
(
$response
,
true
),
'errorno'
=>
$errorNum
,
'errormessage'
=>
$errorMsg
];
}
}
}
config/params.php
View file @
f695cd5
...
@@ -8,5 +8,6 @@ return [
...
@@ -8,5 +8,6 @@ return [
'registrators_urls'
=>
[
'registrators_urls'
=>
[
//'https://2ip.ua/ru/services/information-service/domain-information'
//'https://2ip.ua/ru/services/information-service/domain-information'
'https://www.cy-pr.com/tools/masswhois/'
'https://www.cy-pr.com/tools/masswhois/'
]
],
'tix_url'
=>
'https://api.godaddy.com/v1/appraisal/'
];
];
models/Host.php
View file @
f695cd5
...
@@ -24,6 +24,9 @@ class Host extends \yii\db\ActiveRecord
...
@@ -24,6 +24,9 @@ class Host extends \yii\db\ActiveRecord
const
STATUS_WIS_FREE
=
1
;
//Свободный
const
STATUS_WIS_FREE
=
1
;
//Свободный
const
STATUS_WIS_BUSY
=
2
;
//Занятый
const
STATUS_WIS_BUSY
=
2
;
//Занятый
const
STATUS_TIX_UNCHECK
=
0
;
//не проверен
const
STATUS_TIX_CHECK
=
1
;
//Проверен
const
STATUS_OFF
=
0
;
//выключен
const
STATUS_OFF
=
0
;
//выключен
const
STATUS_ON
=
1
;
//Включен
const
STATUS_ON
=
1
;
//Включен
...
...
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