@@ -39,38 +39,31 @@ public function redirectIndex() : void
3939 public function hasAccess () : bool
4040 {
4141 $ ip = $ this ->getServerIp ();
42- $ access = false ;
4342
4443 // Allow local access
45- if ( $ this ->hasString (['127.0.0.1 ' , '::1 ' ], $ ip ) ) {
46- $ access = true ;
44+ if ( $ this ->isDebug () && $ this ->hasString (['127.0.0.1 ' , '::1 ' ], $ ip ) ) {
45+ return true ;
46+ }
47+
48+ // Check allowed IPs
49+ $ access = false ;
50+ $ allowed = $ this ->getAllowedAccess ();
51+ $ allowed = $ this ->applyFilter ('access-allowed-ip ' , $ allowed );
52+
53+ if ( !empty ($ allowed ) ) {
54+ $ access = $ this ->hasString ($ allowed , $ ip );
4755
4856 } else {
4957
50- // Check allowed IPs
51- $ allowed = $ this ->applyFilter ('access-allowed-ip ' , $ this ->getAllowedAccess ());
52- if ( !empty ($ allowed ) ) {
53- if ( $ this ->hasString ($ allowed , $ ip ) ) {
54- $ access = true ;
55-
56- } else {
57- $ access = false ;
58- }
59-
60- } else {
61- // Deny access
62- $ denied = $ this ->applyFilter ('access-denied-ip ' , $ this ->getDeniedAccess ());
63- if ( $ this ->hasString ($ denied , $ ip ) ) {
64- $ access = false ;
65-
66- } else {
67- $ access = true ;
68- }
69- }
58+ // Deny access
59+ $ denied = $ this ->getDeniedAccess ();
60+ $ denied = $ this ->applyFilter ('access-denied-ip ' , $ denied );
61+ $ access = !$ this ->hasString ($ denied , $ ip );
7062 }
7163
7264 $ data = ['ip ' => $ ip , 'access ' => $ access ];
7365 $ this ->doAction ('ip-access ' , $ data );
66+
7467 return $ access ;
7568 }
7669
0 commit comments