File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,8 @@ private function find($ip = null)
161161 return $ this ->default_location ;
162162 }
163163
164+ private $ maxmind ;
165+
164166 /**
165167 * Maxmind Service.
166168 *
@@ -171,15 +173,17 @@ private function locate_maxmind($ip)
171173 {
172174 $ settings = $ this ->config ->get ('geoip.maxmind ' );
173175
174- if ($ settings ['type ' ] === 'web_service ' ) {
175- $ maxmind = new Client ($ settings ['user_id ' ], $ settings ['license_key ' ]);
176- }
177- else {
178- $ maxmind = new Reader ($ settings ['database_path ' ]);
176+ if (empty ($ this ->maxmind )) {
177+ if ($ settings ['type ' ] === 'web_service ' ) {
178+ $ this ->maxmind = new Client ($ settings ['user_id ' ], $ settings ['license_key ' ]);
179+ }
180+ else {
181+ $ this ->maxmind = new Reader ($ settings ['database_path ' ]);
182+ }
179183 }
180184
181185 try {
182- $ record = $ maxmind ->city ($ ip );
186+ $ record = $ this -> maxmind ->city ($ ip );
183187
184188 $ location = array (
185189 "ip " => $ ip ,
You can’t perform that action at this time.
0 commit comments