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