@@ -105,6 +105,7 @@ public function find($ip, $language)
105
105
try
106
106
{
107
107
$ node = $ this ->findNode ($ ip );
108
+
108
109
if ($ node > 0 )
109
110
{
110
111
$ data = $ this ->resolve ($ node );
@@ -133,24 +134,24 @@ public function findMap($ip, $language)
133
134
return array_combine ($ this ->meta ['fields ' ], $ array );
134
135
}
135
136
137
+ private $ v4offset = 0 ;
138
+ private $ v6offsetCache = [];
139
+
136
140
/**
137
141
* @param $ip
138
142
* @return int
139
143
* @throws \Exception
140
144
*/
141
145
private function findNode ($ ip )
142
146
{
143
- static $ v4offset = 0 ;
144
- static $ v6offsetCache = [];
145
-
146
147
$ binary = inet_pton ($ ip );
147
148
$ bitCount = strlen ($ binary ) * 8 ; // 32 | 128
148
149
$ key = substr ($ binary , 0 , 2 );
149
150
$ node = 0 ;
150
151
$ index = 0 ;
151
152
if ($ bitCount === 32 )
152
153
{
153
- if ($ v4offset === 0 )
154
+ if ($ this -> v4offset === 0 )
154
155
{
155
156
for ($ i = 0 ; $ i < 96 && $ node < $ this ->nodeCount ; $ i ++)
156
157
{
@@ -168,19 +169,19 @@ private function findNode($ip)
168
169
return 0 ;
169
170
}
170
171
}
171
- $ v4offset = $ node ;
172
+ $ this -> v4offset = $ node ;
172
173
}
173
174
else
174
175
{
175
- $ node = $ v4offset ;
176
+ $ node = $ this -> v4offset ;
176
177
}
177
178
}
178
179
else
179
180
{
180
- if (isset ($ v6offsetCache [$ key ]))
181
+ if (isset ($ this -> v6offsetCache [$ key ]))
181
182
{
182
183
$ index = 16 ;
183
- $ node = $ v6offsetCache [$ key ];
184
+ $ node = $ this -> v6offsetCache [$ key ];
184
185
}
185
186
}
186
187
@@ -195,7 +196,7 @@ private function findNode($ip)
195
196
196
197
if ($ i == 15 )
197
198
{
198
- $ v6offsetCache [$ key ] = $ node ;
199
+ $ this -> v6offsetCache [$ key ] = $ node ;
199
200
}
200
201
}
201
202
0 commit comments