Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ip_info = curl_init("http://api.ipinfodb.com/v3/ip-city/?key={$config['banner']['api']['ip']}&ip={$client['connection_client_ip']}&format=json");
- curl_setopt($ip_info, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ip_info, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ip_info, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ip_info, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- curl_setopt($ip_info, CURLOPT_CONNECTTIMEOUT, 1);
- curl_setopt($ip_info, CURLOPT_TIMEOUT, 0);
- $ip_info = curl_exec($ip_info);
- $ip_info = json_decode($ip_info);
- if($ip_info && $ip_info->statusCode == 'OK')
- {
- $weather = curl_init("http://api.openweathermap.org/data/2.5/weather?lat={$ip_info->latitude}&lon={$ip_info->longitude}&units=metric&appid={$config['banner']['api']['weather']}");
- curl_setopt($weather, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($weather, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($weather, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($weather, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- curl_setopt($weather, CURLOPT_CONNECTTIMEOUT, 1);
- curl_setopt($weather, CURLOPT_TIMEOUT, 0);
- curl_setopt($weather, CURLOPT_HTTPHEADER, ['Accept: application/json']);
- $weather = curl_exec($weather);
- $weather = json_decode($weather);
- }
- if($ip_info && $weather)
- {
- $weather_info = ['temp' => floor($weather->main->temp),'city_name' => $ip_info->cityName,'icon_name' => sbot::get_icon($weather->weather[0]->icon)];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement