From d02b15d642ee03b4ff5c671908b33ec1cac5da70 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 16 Feb 2018 11:06:19 +0200 Subject: [PATCH] Handle service failure --- app/Ninja/Repositories/AccountRepository.php | 41 ++++++++++---------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index fe45ace9f3..9ec579aede 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -64,29 +64,30 @@ class AccountRepository // Set default language/currency based on IP if (\Cache::get('currencies')) { - $data = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $account->ip)); - $currencyCode = strtolower($data['geoplugin_currencyCode']); - $countryCode = strtolower($data['geoplugin_countryCode']); + if ($data = unserialize(@file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $account->ip))) { + $currencyCode = strtolower($data['geoplugin_currencyCode']); + $countryCode = strtolower($data['geoplugin_countryCode']); - $currency = \Cache::get('currencies')->filter(function ($item) use ($currencyCode) { - return strtolower($item->code) == $currencyCode; - })->first(); - if ($currency) { - $account->currency_id = $currency->id; - } + $currency = \Cache::get('currencies')->filter(function ($item) use ($currencyCode) { + return strtolower($item->code) == $currencyCode; + })->first(); + if ($currency) { + $account->currency_id = $currency->id; + } - $country = \Cache::get('countries')->filter(function ($item) use ($countryCode) { - return strtolower($item->iso_3166_2) == $countryCode || strtolower($item->iso_3166_3) == $countryCode; - })->first(); - if ($country) { - $account->country_id = $country->id; - } + $country = \Cache::get('countries')->filter(function ($item) use ($countryCode) { + return strtolower($item->iso_3166_2) == $countryCode || strtolower($item->iso_3166_3) == $countryCode; + })->first(); + if ($country) { + $account->country_id = $country->id; + } - $language = \Cache::get('languages')->filter(function ($item) use ($countryCode) { - return strtolower($item->locale) == $countryCode; - })->first(); - if ($language) { - $account->language_id = $language->id; + $language = \Cache::get('languages')->filter(function ($item) use ($countryCode) { + return strtolower($item->locale) == $countryCode; + })->first(); + if ($language) { + $account->language_id = $language->id; + } } }