Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1.  
  2. $ip_info = curl_init("http://api.ipinfodb.com/v3/ip-city/?key={$config['banner']['api']['ip']}&ip={$client['connection_client_ip']}&format=json");
  3. curl_setopt($ip_info, CURLOPT_RETURNTRANSFER, 1);
  4. curl_setopt($ip_info, CURLOPT_SSL_VERIFYPEER, 0);
  5. curl_setopt($ip_info, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  6. curl_setopt($ip_info, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  7. curl_setopt($ip_info, CURLOPT_CONNECTTIMEOUT, 1);
  8. curl_setopt($ip_info, CURLOPT_TIMEOUT, 0);
  9. $ip_info = curl_exec($ip_info);
  10. $ip_info = json_decode($ip_info);
  11.  
  12. if($ip_info && $ip_info->statusCode == 'OK')
  13. {
  14. $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']}");
  15. curl_setopt($weather, CURLOPT_RETURNTRANSFER, 1);
  16. curl_setopt($weather, CURLOPT_SSL_VERIFYPEER, 0);
  17. curl_setopt($weather, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  18. curl_setopt($weather, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  19. curl_setopt($weather, CURLOPT_CONNECTTIMEOUT, 1);
  20. curl_setopt($weather, CURLOPT_TIMEOUT, 0);
  21. curl_setopt($weather, CURLOPT_HTTPHEADER, ['Accept: application/json']);
  22. $weather = curl_exec($weather);
  23. $weather = json_decode($weather);
  24. }
  25.  
  26. if($ip_info && $weather)
  27. {
  28. $weather_info = ['temp' => floor($weather->main->temp),'city_name' => $ip_info->cityName,'icon_name' => sbot::get_icon($weather->weather[0]->icon)];
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement