@@ -161,6 +161,50 @@ function wputools_diagnostic_check_domain_is_preproduction($domainName) {
161
161
}
162
162
$ is_test_extension = $ host_extension && in_array ($ host_extension , $ ignored_extensions );
163
163
164
+ /* ----------------------------------------------------------
165
+ Htaccess
166
+ ---------------------------------------------------------- */
167
+
168
+ $ temp_dir_name = 'wputools_temp_dir_ ' . uniqid ();
169
+ $ wputools_temp_dir = wp_upload_dir ()['basedir ' ] . '/ ' . $ temp_dir_name ;
170
+ $ wputools_temp_url = wp_upload_dir ()['baseurl ' ] . '/ ' . $ temp_dir_name ;
171
+ mkdir ($ wputools_temp_dir , 0755 , true );
172
+ if (!is_dir ($ wputools_temp_dir )) {
173
+ $ wputools_errors [] = sprintf ('The temporary directory %s could not be created ' , $ wputools_temp_dir );
174
+ } else {
175
+ /* Create temp files */
176
+ $ temp_files = array (
177
+ '.htaccess ' ,
178
+ 'test.txt '
179
+ );
180
+
181
+ foreach ($ temp_files as $ temp_file ) {
182
+ file_put_contents ($ wputools_temp_dir . '/ ' . $ temp_file , 'deny from all ' );
183
+ }
184
+
185
+ /* Test if the temporary directory is correctly blocked */
186
+ $ response = wp_remote_get ($ wputools_temp_url . '/test.txt ' );
187
+ if (is_wp_error ($ response ) || wp_remote_retrieve_response_code ($ response ) !== 403 ) {
188
+ $ wputools_errors [] = 'The temporary directory test did not return a 403 error as expected. ' ;
189
+ }
190
+
191
+ /* Clean up the temporary directory */
192
+ foreach ($ temp_files as $ temp_file ) {
193
+ unlink ($ wputools_temp_dir . '/ ' . $ temp_file );
194
+ }
195
+
196
+ /* Test if the temporary directory does not show an Apache index */
197
+ $ response = wp_remote_get ($ wputools_temp_url . '/ ' );
198
+ if (!is_wp_error ($ response )) {
199
+ $ body = wp_remote_retrieve_body ($ response );
200
+ if (strpos ($ body , '<title>Index of ' ) !== false ) {
201
+ $ wputools_errors [] = 'The temporary directory is publicly accessible and shows an Apache index. ' ;
202
+ }
203
+ }
204
+
205
+ rmdir ($ wputools_temp_dir );
206
+ }
207
+
164
208
/* ----------------------------------------------------------
165
209
Mail
166
210
---------------------------------------------------------- */
@@ -286,6 +330,17 @@ function wputools_diagnostic_check_domain_is_preproduction($domainName) {
286
330
}
287
331
}
288
332
333
+ /* ----------------------------------------------------------
334
+ Check execution time
335
+ ---------------------------------------------------------- */
336
+
337
+ if (!$ wputools_is_cli ) {
338
+ $ execution_time = ini_get ('max_execution_time ' );
339
+ if ($ execution_time < 5 || $ execution_time > 120 ) {
340
+ $ wputools_errors [] = sprintf ('WordPress : max_execution_time should be set roughly to 30 seconds. Current value is %s seconds. ' , $ execution_time );
341
+ }
342
+ }
343
+
289
344
/* ----------------------------------------------------------
290
345
Check for enabled auto file modification
291
346
---------------------------------------------------------- */
0 commit comments