Commit b2d03962 by Скуратович Александр

срок действия домена

1 parent 61d6dfcc
......@@ -67,8 +67,9 @@ class WhoisController extends Controller
foreach ($trArr as $tr) {
$domain = $tr->find('td')[0]->text;
$status = $tr->find('td')[1]->text;
$expired = $tr->find('td')[6]->text;
$hasAnswer[] = $domain;
$this->upWhois($domain, $status);
$this->upWhois($domain, $status, $expired);
}
foreach (array_diff($domainsArr, $hasAnswer) as $domainDisable) {
$this->upWhois($domainDisable);
......@@ -79,8 +80,11 @@ class WhoisController extends Controller
}
}
private function upWhois($domain, $statusStr = 'Занят')
private function upWhois($domain, $statusStr = 'Занят', $expired = '')
{
echo $domain . ' => ' . $statusStr . "\n";
switch ($statusStr) {
case 'Свободен':
$status = Host::STATUS_FREE;
......@@ -88,9 +92,15 @@ class WhoisController extends Controller
default:
$status = Host::STATUS_BUSY;
}
$update = ['wis_status' => $status, 'wis_date' => new Expression('NOW()')];
if ($expired) {
$expired = date("Y-m-d H:i:s", strtotime($expired));
if ($expired) {
$update['domain_expire'] = $expired;
}
}
Yii::$app->db->createCommand()
->update('{{%host}}', ['wis_status' => $status, 'wis_date' => new Expression('NOW()')], ['domain' => $domain])
->update('{{%host}}', $update, ['domain' => $domain])
->execute();
}
......
<?php
use yii\db\Migration;
/**
* Class m210602_172731_add
*/
class m210602_172731_add extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
// creates index for column `author_id`
$this->createIndex(
'idx-host-status',
'{{%host}}',
'wis_status'
);
$this->addColumn('{{%host}}', 'domain_expire', $this->dateTime()->null()->comment('Дата действия'));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropIndex(
'idx-host-status',
'{{%host}}'
);
$this->dropColumn('{{%host}}', 'domain_expire');
}
}
......@@ -53,7 +53,7 @@ class Host extends \yii\db\ActiveRecord
return [
[['domain'], 'required'],
['status_id', 'in', 'range' => array_keys(self::getStatus())],
[['created_at', 'csv_date', 'wis_date'], 'safe'],
[['created_at', 'csv_date', 'wis_date','domain_expire'], 'safe'],
[['wis_status', 'tix'], 'integer'],
[['domain'], 'string', 'max' => 256],
[['domain'], 'unique'],
......@@ -72,6 +72,7 @@ class Host extends \yii\db\ActiveRecord
'csv_date' => 'Date CSV',
'wis_date' => 'Date WHOIS',
'wis_status' => 'Status',
'domain_expire' => 'Date expired',
'tix' => 'TIX',
];
}
......
......@@ -18,7 +18,7 @@ class HostSearch extends Host
{
return [
[['id', 'wis_status', 'tix'], 'integer'],
[['domain', 'created_at', 'csv_date', 'wis_date','wis_status'], 'safe'],
[['domain', 'created_at', 'csv_date', 'wis_date','wis_status','domain_expire'], 'safe'],
];
}
......@@ -63,6 +63,7 @@ class HostSearch extends Host
//'csv_date' => $this->csv_date,
//'wis_date' => $this->wis_date,
'wis_status' => $this->wis_status,
'domain_expire' => $this->wis_status,
'tix' => $this->tix,
]);
......
......@@ -54,6 +54,7 @@ $this->params['breadcrumbs'][] = $this->title;
},
],
'wis_date',
'domain_expire',
'tix',
[
'class' => 'yii\grid\ActionColumn',
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!