sanjiisan

Untitled

Apr 7th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport"
  6. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8. <title>Zadanie 1</title>
  9. </head>
  10. <body>
  11. <?php
  12.  
  13. $c = curl_init();
  14.  
  15. curl_setopt($c, CURLOPT_URL, 'http://api.coderslab.pl/curl.php');
  16. curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  17. curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30');
  18.  
  19. $result = curl_exec($c);
  20.  
  21. $httpCode = curl_getinfo($c, CURLINFO_HTTP_CODE);
  22. if ($httpCode == 404) {
  23. echo '404 - brak stronyu!';
  24. }
  25.  
  26. if ($result) {
  27.  
  28. /**
  29. * IP: adres_ip
  30. * SUMA: suma_pobranych_20_liczb
  31. * DEVICE: komputer/telefon
  32. */
  33. $resArr = explode('#', $result);
  34.  
  35.  
  36. echo 'IP: ' . $resArr[0] . '<br>';
  37. echo 'SUMA: ' . array_sum(explode(',', $resArr[1])) . '<br>';
  38. echo 'DEVICE: ' . $resArr[2] . '<br>';
  39.  
  40.  
  41. } else {
  42. echo 'Błąd: ' . curl_error($c);
  43. }
  44.  
  45. curl_close($c);
  46.  
  47. ?>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment