@@ -65,24 +65,23 @@ class GeoIP {
6565 "country " => "United States " ,
6666 "city " => "New Haven " ,
6767 "state " => "CT " ,
68- "postal_code " => "06510 " ,
68+ "postal_code " => "06510 " ,
6969 "lat " => 41.31 ,
7070 "lon " => -72.92 ,
7171 "timezone " => "America/New_York " ,
7272 "continent " => "NA " ,
73- "default " => true
73+ "default " => true
7474 );
7575
7676 /**
7777 * Create a new GeoIP instance.
7878 *
7979 * @param \Illuminate\Config\Repository $config
80- * @param \Illuminate\Session\Store $session
81- * @return void
80+ * @param \Illuminate\Session\Store $session
8281 */
8382 public function __construct (Repository $ config , SessionStore $ session )
8483 {
85- $ this ->config = $ config ;
84+ $ this ->config = $ config ;
8685 $ this ->session = $ session ;
8786
8887 $ this ->remote_ip = $ this ->default_location ['ip ' ] = $ this ->getClientIP ();
@@ -104,13 +103,13 @@ function saveLocation()
104103 * @param string $ip Optional
105104 * @return array
106105 */
107- function getLocation ( $ ip = null )
106+ function getLocation ($ ip = null )
108107 {
109108 // Get location data
110- $ this ->location = $ this ->find ( $ ip );
109+ $ this ->location = $ this ->find ($ ip );
111110
112111 // Save user's location
113- if ( $ ip === null ) {
112+ if ($ ip === null ) {
114113 $ this ->saveLocation ();
115114 }
116115
@@ -123,10 +122,10 @@ function getLocation( $ip = null )
123122 * @param string $ip Optional
124123 * @return array
125124 */
126- private function find ( $ ip = null )
125+ private function find ($ ip = null )
127126 {
128127 // Check Session
129- if ( $ ip === null && $ position = $ this ->session ->get ('geoip-location ' ) )
128+ if ($ ip === null && $ position = $ this ->session ->get ('geoip-location ' ))
130129 {
131130 // TODO: Remove default check on 2/28/14
132131 if (isset ($ position ['default ' ]) && $ position ['ip ' ] === $ this ->remote_ip ) {
@@ -135,12 +134,12 @@ private function find( $ip = null )
135134 }
136135
137136 // If IP not set, user remote IP
138- if ( $ ip === null ) {
137+ if ($ ip === null ) {
139138 $ ip = $ this ->remote_ip ;
140139 }
141140
142141 // Check if the ip is not local or empty
143- if ( $ this ->checkIp ( $ ip ) ) {
142+ if ($ this ->checkIp ($ ip) ) {
144143
145144 // Call default service
146145 $ service = 'locate_ ' .$ this ->config ->get ('geoip::service ' );
@@ -157,7 +156,7 @@ private function find( $ip = null )
157156 * @param string $ip
158157 * @return array
159158 */
160- private function locate_maxmind ( $ ip )
159+ private function locate_maxmind ($ ip )
161160 {
162161 $ settings = $ this ->config ->get ('geoip::maxmind ' );
163162
@@ -183,12 +182,12 @@ private function locate_maxmind( $ip )
183182 "country " => $ record ->country ->name ,
184183 "city " => $ record ->city ->name ,
185184 "state " => $ record ->mostSpecificSubdivision ->isoCode ,
186- "postal_code " => $ record ->postal ->code ,
185+ "postal_code " => $ record ->postal ->code ,
187186 "lat " => $ record ->location ->latitude ,
188187 "lon " => $ record ->location ->longitude ,
189188 "timezone " => $ record ->location ->timeZone ,
190189 "continent " => $ record ->continent ->code ,
191- "default " => false
190+ "default " => false
192191 );
193192
194193 unset($ record );
@@ -221,7 +220,7 @@ private function getClientIP()
221220 else if (getenv ('REMOTE_ADDR ' )) {
222221 $ ipaddress = getenv ('REMOTE_ADDR ' );
223222 }
224- else if ( isset ($ _SERVER ['REMOTE_ADDR ' ]) ) {
223+ else if (isset ($ _SERVER ['REMOTE_ADDR ' ])) {
225224 $ ipaddress = $ _SERVER ['REMOTE_ADDR ' ];
226225 }
227226 else {
@@ -236,20 +235,22 @@ private function getClientIP()
236235 *
237236 * @return bool
238237 */
239- private function checkIp ( $ ip )
238+ private function checkIp ($ ip )
240239 {
241240 $ longip = ip2long ($ ip );
242241
243- if ( !empty ($ ip ) ) {
242+ if (!empty ($ ip )) {
244243
245- foreach ($ this ->reserved_ips as $ r ) {
244+ foreach ($ this ->reserved_ips as $ r )
245+ {
246246 $ min = ip2long ($ r [0 ]);
247247 $ max = ip2long ($ r [1 ]);
248248
249249 if ($ longip >= $ min && $ longip <= $ max ) {
250250 return false ;
251251 }
252252 }
253+
253254 return true ;
254255 }
255256
0 commit comments