@@ -334,26 +334,24 @@ private function verifyBots($ip)
334
334
return false ;
335
335
}
336
336
337
- private function readMaintenanceIp ($ ip )
337
+ private function readMaintenanceIp ($ clientIps )
338
338
{
339
339
$ tag = self ::FASTLY_CACHE_MAINTENANCE_IP_FILE_TAG ;
340
- $ data = json_decode ($ this ->cache ->load ($ tag ));
341
- if (empty ($ data )) {
342
- $ data = [];
340
+ $ allowedIps = json_decode ($ this ->cache ->load ($ tag ));
341
+ if (empty ($ allowedIps )) {
342
+ $ allowedIps = [];
343
343
$ flagDir = $ this ->filesystem ->getDirectoryWrite (DirectoryList::VAR_DIR );
344
344
if ($ flagDir ->isExist ('.maintenance.ip ' )) {
345
345
$ temp = $ flagDir ->readFile ('.maintenance.ip ' );
346
- $ data = explode (', ' , trim ($ temp ));
347
- $ this ->cache ->save (json_encode ($ data ), $ tag , []);
346
+ $ allowedIps = explode (', ' , trim ($ temp ));
347
+ $ this ->cache ->save (json_encode ($ allowedIps ), $ tag , []);
348
348
}
349
349
}
350
350
351
- foreach ($ data as $ key => $ value ) {
352
- if (!empty ($ value ) && trim ($ value ) == $ ip ) {
353
- return true ;
354
- }
355
- }
356
- return false ;
351
+ $ ips = array_map ("trim " , explode (", " , $ clientIps ));
352
+ $ isAllowed = array_intersect ($ allowedIps , $ ips );
353
+
354
+ return !empty ($ isAllowed );
357
355
}
358
356
359
357
private function log ($ message )
0 commit comments