Host.php
3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
namespace app\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;
/**
* This is the model class for table "{{%host}}".
*
* @property int $id
* @property string $domain Домен
* @property string|null $created_at Дата записи
* @property string|null $csv_date Дата CSV
* @property string|null $wis_date Дата проверки домена
* @property int|null $wis_status Статус Who Is
* @property int $status Статус
* @property int $tix Показатель
*/
class Host extends \yii\db\ActiveRecord
{
const STATUS_WIS_NONE = 0; //неизвестный
const STATUS_WIS_FREE = 1; //Свободный
const STATUS_WIS_BUSY = 2; //Занятый
const STATUS_OFF = 0; //выключен
const STATUS_ON = 1; //Включен
public $cnt;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return '{{%host}}';
}
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => null,
'value' => new Expression('NOW()'),
],
];
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['domain'], 'required'],
['status_id', 'in', 'range' => array_keys(self::getWisStatus())],
[['created_at', 'csv_date', 'wis_date','domain_expire'], 'safe'],
[['wis_status', 'tix', 'status'], 'integer'],
[['domain'], 'string', 'max' => 256],
[['domain'], 'unique'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'domain' => 'Domain',
'created_at' => 'Date',
'csv_date' => 'Date CSV',
'wis_date' => 'Date WHOIS',
'wis_status' => 'Can registration',
'domain_expire' => 'Date expired',
'tix' => 'TIX',
'status' => 'Status'
];
}
/**
* {@inheritdoc}
* @return HostQuery the active query used by this AR class.
*/
public static function find()
{
return new HostQuery(get_called_class());
}
public static function getStatus($status = false)
{
$arr = [
self::STATUS_OFF => 'Disable',
self::STATUS_ON => 'Enable'
];
if (is_numeric($status)) {
if (array_key_exists($status, $arr)) {
return $arr[$status];
}
return $status;
}
return $arr;
}
public static function getWisStatus($status = false)
{
$arr = [
self::STATUS_WIS_NONE => 'No checked',
self::STATUS_WIS_FREE => 'FREE',
self::STATUS_WIS_BUSY => 'BUSY',
];
if (is_numeric($status)) {
if (array_key_exists($status, $arr)) {
return $arr[$status];
}
return $status;
}
return $arr;
}
}