@@ -64,30 +64,37 @@ public static function renderCrawlQueue() : void {
64
64
die ( 'Forbidden ' );
65
65
}
66
66
67
- if ( ! empty ( $ _GET ['action ' ] ) && ! empty ( $ _GET ['id ' ] ) && is_array ( $ _GET ['id ' ] ) ) {
68
- switch ( $ _GET ['action ' ] ) {
69
- case 'remove ' :
70
- CrawlQueue::rmUrlsById ( $ _GET ['id ' ] );
71
- break ;
72
- }
67
+ $ action = filter_input ( INPUT_GET , 'action ' );
68
+ /**
69
+ * @var string[] $url_id
70
+ */
71
+ $ url_id = filter_input ( INPUT_GET , 'id ' );
72
+
73
+ if ( $ action === 'remove ' && is_array ( $ url_id ) ) {
74
+ CrawlQueue::rmUrlsById ( $ url_id );
73
75
}
74
76
75
77
$ urls = CrawlQueue::getCrawlablePaths ();
76
78
// Apply search
77
- if ( ! empty ( $ _GET [ 's ' ] ) ) {
78
- $ s = $ _GET [ ' s ' ];
79
+ $ search_term = strval ( filter_input ( INPUT_GET , 's ' ) );
80
+ if ( $ search_term !== '' ) {
79
81
$ urls = array_filter (
80
82
$ urls ,
81
- function ( $ url ) use ( $ s ) {
82
- return stripos ( $ url , $ s ) !== false ;
83
+ function ( $ url ) use ( $ search_term ) {
84
+ return stripos ( $ url , $ search_term ) !== false ;
83
85
}
84
86
);
85
87
}
86
88
87
89
$ page_size = 200 ;
88
90
$ page = isset ( $ _GET ['paged ' ] ) ? max ( 1 , intval ( $ _GET ['paged ' ] ) ) : 1 ;
91
+ $ paginator = new Paginator ( $ urls , $ page_size , $ page );
89
92
$ view = [
90
- 'paginator ' => new Paginator ( $ urls , $ page_size , $ page ),
93
+ 'paginatorFirstPage ' => $ paginator ->firstPage (),
94
+ 'paginatorLastPage ' => $ paginator ->lastPage (),
95
+ 'paginatorPage ' => $ paginator ->page (),
96
+ 'paginatorRecords ' => $ paginator ->records (),
97
+ 'paginatorTotalRecords ' => $ paginator ->totalRecords (),
91
98
];
92
99
93
100
require_once WP2STATIC_PATH . 'views/crawl-queue-page.php ' ;
@@ -99,31 +106,37 @@ public static function renderCrawlCache() : void {
99
106
die ( 'Forbidden ' );
100
107
}
101
108
102
- if ( ! empty ( $ _GET ['action ' ] ) && ! empty ( $ _GET ['id ' ] ) && is_array ( $ _GET ['id ' ] ) ) {
103
- switch ( $ _GET ['action ' ] ) {
104
- case 'remove ' :
105
- CrawlCache::rmUrlsById ( $ _GET ['id ' ] );
106
- break ;
107
- }
109
+ $ action = filter_input ( INPUT_GET , 'action ' );
110
+ /**
111
+ * @var string[] $url_id
112
+ */
113
+ $ url_id = filter_input ( INPUT_GET , 'id ' );
114
+
115
+ if ( $ action === 'remove ' && is_array ( $ url_id ) ) {
116
+ CrawlCache::rmUrlsById ( $ url_id );
108
117
}
109
118
110
119
$ urls = CrawlCache::getURLs ();
111
-
112
120
// Apply search
113
- if ( ! empty ( $ _GET [ 's ' ] ) ) {
114
- $ s = $ _GET [ ' s ' ];
121
+ $ search_term = strval ( filter_input ( INPUT_GET , 's ' ) );
122
+ if ( $ search_term !== '' ) {
115
123
$ urls = array_filter (
116
124
$ urls ,
117
- function ( $ url ) use ( $ s ) {
118
- return stripos ( isset ( $ url ->url ) ? $ url -> url : '' , $ s ) !== false ;
125
+ function ( $ url ) use ( $ search_term ) {
126
+ return stripos ( $ url ->url ?? '' , $ search_term ) !== false ;
119
127
}
120
128
);
121
129
}
122
130
123
131
$ page_size = 200 ;
124
132
$ page = isset ( $ _GET ['paged ' ] ) ? max ( 1 , intval ( $ _GET ['paged ' ] ) ) : 1 ;
133
+ $ paginator = new Paginator ( $ urls , $ page_size , $ page );
125
134
$ view = [
126
- 'paginator ' => new Paginator ( $ urls , $ page_size , $ page ),
135
+ 'paginatorFirstPage ' => $ paginator ->firstPage (),
136
+ 'paginatorLastPage ' => $ paginator ->lastPage (),
137
+ 'paginatorPage ' => $ paginator ->page (),
138
+ 'paginatorRecords ' => $ paginator ->records (),
139
+ 'paginatorTotalRecords ' => $ paginator ->totalRecords (),
127
140
];
128
141
129
142
require_once WP2STATIC_PATH . 'views/crawl-cache-page.php ' ;
@@ -138,20 +151,25 @@ public static function renderPostProcessedSitePaths() : void {
138
151
$ paths = ProcessedSite::getPaths ();
139
152
140
153
// Apply search
141
- if ( ! empty ( $ _GET [ 's ' ] ) ) {
142
- $ s = $ _GET [ ' s ' ];
154
+ $ search_term = strval ( filter_input ( INPUT_GET , 's ' ) );
155
+ if ( $ search_term !== '' ) {
143
156
$ paths = array_filter (
144
157
$ paths ,
145
- function ( $ path ) use ( $ s ) {
146
- return stripos ( $ path , $ s ) !== false ;
158
+ function ( $ path ) use ( $ search_term ) {
159
+ return stripos ( $ path , $ search_term ) !== false ;
147
160
}
148
161
);
149
162
}
150
163
151
164
$ page_size = 200 ;
152
165
$ page = isset ( $ _GET ['paged ' ] ) ? max ( 1 , intval ( $ _GET ['paged ' ] ) ) : 1 ;
166
+ $ paginator = new Paginator ( $ paths , $ page_size , $ page );
153
167
$ view = [
154
- 'paginator ' => new Paginator ( $ paths , $ page_size , $ page ),
168
+ 'paginatorFirstPage ' => $ paginator ->firstPage (),
169
+ 'paginatorLastPage ' => $ paginator ->lastPage (),
170
+ 'paginatorPage ' => $ paginator ->page (),
171
+ 'paginatorRecords ' => $ paginator ->records (),
172
+ 'paginatorTotalRecords ' => $ paginator ->totalRecords (),
155
173
];
156
174
157
175
require_once WP2STATIC_PATH . 'views/post-processed-site-paths-page.php ' ;
@@ -166,20 +184,25 @@ public static function renderStaticSitePaths() : void {
166
184
$ paths = StaticSite::getPaths ();
167
185
168
186
// Apply search
169
- if ( ! empty ( $ _GET [ 's ' ] ) ) {
170
- $ s = $ _GET [ ' s ' ];
187
+ $ search_term = strval ( filter_input ( INPUT_GET , 's ' ) );
188
+ if ( $ search_term !== '' ) {
171
189
$ paths = array_filter (
172
190
$ paths ,
173
- function ( $ path ) use ( $ s ) {
174
- return stripos ( $ path , $ s ) !== false ;
191
+ function ( $ path ) use ( $ search_term ) {
192
+ return stripos ( $ path , $ search_term ) !== false ;
175
193
}
176
194
);
177
195
}
178
196
179
197
$ page_size = 200 ;
180
198
$ page = isset ( $ _GET ['paged ' ] ) ? max ( 1 , intval ( $ _GET ['paged ' ] ) ) : 1 ;
199
+ $ paginator = new Paginator ( $ paths , $ page_size , $ page );
181
200
$ view = [
182
- 'paginator ' => new Paginator ( $ paths , $ page_size , $ page ),
201
+ 'paginatorFirstPage ' => $ paginator ->firstPage (),
202
+ 'paginatorLastPage ' => $ paginator ->lastPage (),
203
+ 'paginatorPage ' => $ paginator ->page (),
204
+ 'paginatorRecords ' => $ paginator ->records (),
205
+ 'paginatorTotalRecords ' => $ paginator ->totalRecords (),
183
206
];
184
207
185
208
require_once WP2STATIC_PATH . 'views/static-site-paths-page.php ' ;
@@ -191,25 +214,31 @@ public static function renderDeployCache() : void {
191
214
die ( 'Forbidden ' );
192
215
}
193
216
194
- $ paths = isset ( $ _GET ['deploy_namespace ' ] )
195
- ? DeployCache::getPaths ( $ _GET ['deploy_namespace ' ] )
217
+ $ deploy_namespace = strval ( filter_input ( INPUT_GET , 'deploy_namespace ' ) );
218
+ $ paths = $ deploy_namespace !== ''
219
+ ? DeployCache::getPaths ( $ deploy_namespace )
196
220
: DeployCache::getPaths ();
197
221
198
222
// Apply search
199
- if ( ! empty ( $ _GET [ 's ' ] ) ) {
200
- $ s = $ _GET [ ' s ' ];
223
+ $ search_term = strval ( filter_input ( INPUT_GET , 's ' ) );
224
+ if ( $ search_term !== '' ) {
201
225
$ paths = array_filter (
202
226
$ paths ,
203
- function ( $ path ) use ( $ s ) {
204
- return stripos ( $ path , $ s ) !== false ;
227
+ function ( $ path ) use ( $ search_term ) {
228
+ return stripos ( $ path , $ search_term ) !== false ;
205
229
}
206
230
);
207
231
}
208
232
209
233
$ page_size = 200 ;
210
234
$ page = isset ( $ _GET ['paged ' ] ) ? max ( 1 , intval ( $ _GET ['paged ' ] ) ) : 1 ;
235
+ $ paginator = new Paginator ( $ paths , $ page_size , $ page );
211
236
$ view = [
212
- 'paginator ' => new Paginator ( $ paths , $ page_size , $ page ),
237
+ 'paginatorFirstPage ' => $ paginator ->firstPage (),
238
+ 'paginatorLastPage ' => $ paginator ->lastPage (),
239
+ 'paginatorPage ' => $ paginator ->page (),
240
+ 'paginatorRecords ' => $ paginator ->records (),
241
+ 'paginatorTotalRecords ' => $ paginator ->totalRecords (),
213
242
];
214
243
215
244
require_once WP2STATIC_PATH . 'views/deploy-cache-page.php ' ;
@@ -262,6 +291,9 @@ public static function renderCachesPage() : void {
262
291
);
263
292
264
293
foreach ( $ files as $ file ) {
294
+ /**
295
+ * @var \SplFileInfo $file
296
+ */
265
297
$ disk_space += $ file ->getSize ();
266
298
}
267
299
}
@@ -294,6 +326,9 @@ public static function renderCachesPage() : void {
294
326
);
295
327
296
328
foreach ( $ files as $ file ) {
329
+ /**
330
+ * @var \SplFileInfo $file
331
+ */
297
332
$ disk_space += $ file ->getSize ();
298
333
}
299
334
}
0 commit comments