Host.php
4.44 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?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_TIX_UNCHECK = 0; //не проверен
const STATUS_TIX_CHECK = 1; //Проверен
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'],
['wis_status', 'in', 'range' => array_keys(self::getWisStatus())],
['f1_status', 'in', 'range' => array_keys(self::getFStatus())],
['f2_status', 'in', 'range' => array_keys(self::getFStatus())],
['f3_status', 'in', 'range' => array_keys(self::getFStatus())],
[['created_at', 'csv_date', 'wis_date','domain_expire', 'tix_date'], 'safe'],
[['wis_status', 'tix', 'status', 'tix_status', 'f1_status', 'f2_status', 'f3_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',
'tix_status' => 'TIX status',
'tix_date' => 'Date TIX',
'f1_status' => 'Filter №1',
'f2_status' => 'Filter №2',
'f3_status' => 'Filter №3',
'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 getFStatus($status = false)
{
$arr = [
self::STATUS_OFF => 'Yes',
self::STATUS_ON => 'No'
];
if (is_numeric($status)) {
if (array_key_exists($status, $arr)) {
return $arr[$status];
}
return $status;
}
return $arr;
}
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;
}
public static function getTIXStatus($status = false)
{
$arr = [
self::STATUS_TIX_UNCHECK => 'No checked',
self::STATUS_TIX_CHECK => 'Checked',
];
if (is_numeric($status)) {
if (array_key_exists($status, $arr)) {
return $arr[$status];
}
return $status;
}
return $arr;
}
}