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 61d6dfcc
authored
2021-06-02 20:16:34 +0300
by
Скуратович Александр
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
обновление статуса домена
1 parent
e0b1fd55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
4 deletions
commands/WhoisController.php
components/Collection.php
commands/WhoisController.php
View file @
61d6dfc
...
...
@@ -2,6 +2,8 @@
namespace
app\commands
;
use
PHPHtmlParser\Dom
;
use
yii\db\Query
;
use
yii
;
use
yii\console\Controller
;
use
yii\db\Expression
;
...
...
@@ -14,7 +16,7 @@ use app\models\Host;
*/
class
WhoisController
extends
Controller
{
public
$
file
=
''
;
public
$
count
=
30
;
public
function
beforeAction
(
$action
)
{
...
...
@@ -39,7 +41,57 @@ class WhoisController extends Controller
*/
public
function
actionIndex
()
{
$hosts
=
(
new
Query
())
->
select
(
'id, domain'
)
->
from
(
'{{%host}}'
)
->
where
([
'in'
,
'wis_status'
,
[
Host
::
STATUS_NONE
,
Host
::
STATUS_BUSY
]])
->
orderBy
(
'rand()'
)
->
limit
(
$this
->
count
)
->
all
();
$domainsArr
=
[];
foreach
(
$hosts
as
$h
)
{
$domainsArr
[]
=
$h
[
'domain'
];
}
if
(
$domainsArr
)
{
$result
=
Collection
::
getRawData
(
Yii
::
$app
->
params
[
'registrators_urls'
][
0
],
$domainsArr
);
if
(
!
$result
[
'errorno'
])
{
//без ошибок
$dom
=
new
Dom
;
$dom
->
loadStr
(
$result
[
'data'
]);
$trArr
=
$dom
->
find
(
'.tablesorter tbody tr'
);
if
(
!
count
(
$trArr
))
{
foreach
(
$domainsArr
as
$d
)
{
$this
->
upWhois
(
$d
);
}
}
$hasAnswer
=
[];
foreach
(
$trArr
as
$tr
)
{
$domain
=
$tr
->
find
(
'td'
)[
0
]
->
text
;
$status
=
$tr
->
find
(
'td'
)[
1
]
->
text
;
$hasAnswer
[]
=
$domain
;
$this
->
upWhois
(
$domain
,
$status
);
}
foreach
(
array_diff
(
$domainsArr
,
$hasAnswer
)
as
$domainDisable
)
{
$this
->
upWhois
(
$domainDisable
);
}
}
else
{
echo
$result
[
'errorno'
]
.
' '
.
$result
[
'errormessage'
];
}
}
}
private
function
upWhois
(
$domain
,
$statusStr
=
'Занят'
)
{
switch
(
$statusStr
)
{
case
'Свободен'
:
$status
=
Host
::
STATUS_FREE
;
break
;
default
:
$status
=
Host
::
STATUS_BUSY
;
}
Yii
::
$app
->
db
->
createCommand
()
->
update
(
'{{%host}}'
,
[
'wis_status'
=>
$status
,
'wis_date'
=>
new
Expression
(
'NOW()'
)],
[
'domain'
=>
$domain
])
->
execute
();
}
}
\ No newline at end of file
components/Collection.php
View file @
61d6dfc
...
...
@@ -33,12 +33,13 @@ class Collection extends Component
public
static
function
getRawData
(
$url
,
$domain
)
{
$post
=
[
'a'
=>
'act'
,
'ip'
=>
$domain
,
'doms'
=>
implode
(
"
\r\n
"
,
$domain
),
];
$ch
=
curl_init
(
'https://2ip.ua/ru/services/information-service/domain-information'
);
$ch
=
curl_init
(
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$post
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
0
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
0
);
$response
=
curl_exec
(
$ch
);
$errorNum
=
curl_errno
(
$ch
);
...
...
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