|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Retour plugin for Craft CMS |
|
4
|
|
|
* |
|
5
|
|
|
* Retour allows you to intelligently redirect legacy URLs, so that you don't |
|
6
|
|
|
* lose SEO value when rebuilding & restructuring a website |
|
7
|
|
|
* |
|
8
|
|
|
* @link https://nystudio107.com/ |
|
|
|
|
|
|
9
|
|
|
* @copyright Copyright (c) 2018 nystudio107 |
|
|
|
|
|
|
10
|
|
|
*/ |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace nystudio107\retour\models; |
|
13
|
|
|
|
|
14
|
|
|
use nystudio107\retour\validators\DbStringValidator; |
|
15
|
|
|
use yii\behaviors\AttributeTypecastBehavior; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
|
|
|
|
|
18
|
|
|
* @author nystudio107 |
|
|
|
|
|
|
19
|
|
|
* @package Retour |
|
|
|
|
|
|
20
|
|
|
* @since 3.0.0 |
|
|
|
|
|
|
21
|
|
|
*/ |
|
|
|
|
|
|
22
|
|
|
class Stats extends DbModel |
|
23
|
|
|
{ |
|
24
|
|
|
// Public Properties |
|
25
|
|
|
// ========================================================================= |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
|
|
|
|
|
28
|
|
|
* @var int |
|
29
|
|
|
*/ |
|
30
|
|
|
public int $id = 0; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
|
|
|
|
|
33
|
|
|
* @var null|int |
|
34
|
|
|
*/ |
|
35
|
|
|
public ?int $siteId = null; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
|
|
|
|
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
public string $redirectSrcUrl = ''; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
|
|
|
|
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
public string $referrerUrl = ''; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
|
|
|
|
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
public string $remoteIp = ''; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
|
|
|
|
|
53
|
|
|
* @var string |
|
54
|
|
|
*/ |
|
55
|
|
|
public string $userAgent = ''; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
|
|
|
|
|
58
|
|
|
* @var string |
|
59
|
|
|
*/ |
|
60
|
|
|
public string $exceptionMessage = ''; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
|
|
|
|
|
63
|
|
|
* @var string |
|
64
|
|
|
*/ |
|
65
|
|
|
public string $exceptionFilePath = ''; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
|
|
|
|
|
68
|
|
|
* @var int |
|
69
|
|
|
*/ |
|
70
|
|
|
public int $exceptionFileLine = 0; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
|
|
|
|
|
73
|
|
|
* @var int |
|
74
|
|
|
*/ |
|
75
|
|
|
public int $hitCount = 0; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
|
|
|
|
|
78
|
|
|
* @var string |
|
79
|
|
|
*/ |
|
80
|
|
|
public string $hitLastTime = ''; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
|
|
|
|
|
83
|
|
|
* @var int |
|
84
|
|
|
*/ |
|
85
|
|
|
public int $handledByRetour = 0; |
|
86
|
|
|
|
|
87
|
|
|
// Public Methods |
|
88
|
|
|
// ========================================================================= |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
|
|
|
|
|
91
|
|
|
* @inheritdoc |
|
92
|
|
|
*/ |
|
|
|
|
|
|
93
|
|
|
public function rules(): array |
|
94
|
|
|
{ |
|
95
|
|
|
return [ |
|
96
|
|
|
['id', 'integer'], |
|
97
|
|
|
['siteId', 'integer'], |
|
98
|
|
|
['siteId', 'default', 'value' => null], |
|
99
|
|
|
[ |
|
100
|
|
|
[ |
|
101
|
|
|
'redirectSrcUrl', |
|
102
|
|
|
'userAgent', |
|
103
|
|
|
'exceptionMessage', |
|
104
|
|
|
'exceptionFilePath', |
|
105
|
|
|
], |
|
106
|
|
|
DbStringValidator::class, |
|
107
|
|
|
'max' => 255, |
|
108
|
|
|
], |
|
109
|
|
|
[ |
|
110
|
|
|
[ |
|
111
|
|
|
'redirectSrcUrl', |
|
112
|
|
|
'userAgent', |
|
113
|
|
|
'exceptionMessage', |
|
114
|
|
|
'exceptionFilePath', |
|
115
|
|
|
], |
|
116
|
|
|
'string', |
|
117
|
|
|
], |
|
118
|
|
|
[ |
|
119
|
|
|
[ |
|
120
|
|
|
'redirectSrcUrl', |
|
121
|
|
|
'userAgent', |
|
122
|
|
|
'exceptionMessage', |
|
123
|
|
|
'exceptionFilePath', |
|
124
|
|
|
], |
|
125
|
|
|
'default', |
|
126
|
|
|
'value' => '', |
|
127
|
|
|
], |
|
128
|
|
|
['exceptionFileLine', 'integer'], |
|
129
|
|
|
['exceptionFileLine', 'default', 'value' => 0], |
|
130
|
|
|
['referrerUrl', DbStringValidator::class, 'max' => 2000], |
|
131
|
|
|
['referrerUrl', 'string'], |
|
132
|
|
|
['referrerUrl', 'default', 'value' => ''], |
|
133
|
|
|
['remoteIp', DbStringValidator::class, 'max' => 45], |
|
134
|
|
|
['remoteIp', 'string'], |
|
135
|
|
|
['remoteIp', 'default', 'value' => ''], |
|
136
|
|
|
['hitCount', 'integer'], |
|
137
|
|
|
['hitCount', 'default', 'value' => 0], |
|
138
|
|
|
['hitLastTime', 'safe'], |
|
139
|
|
|
['handledByRetour', 'integer', 'min' => 0, 'max' => 1], |
|
140
|
|
|
['handledByRetour', 'default', 'value' => 0], |
|
141
|
|
|
]; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
|
|
|
|
|
145
|
|
|
* @return array |
|
146
|
|
|
*/ |
|
147
|
|
|
public function behaviors(): array |
|
148
|
|
|
{ |
|
149
|
|
|
return [ |
|
150
|
|
|
'typecast' => [ |
|
151
|
|
|
'class' => AttributeTypecastBehavior::class, |
|
152
|
|
|
// 'attributeTypes' will be composed automatically according to `rules()` |
|
153
|
|
|
], |
|
154
|
|
|
]; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|