Guest User

doviz.php

a guest
May 31st, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.24 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <?php
  11. //$url='http://twitter.com/statuses/user_timeline/16387631.json'; //rss link for the twitter timeline
  12. //print_r(get_data($url)); //dumps the content, you can manipulate as you wish to
  13.  
  14. /* gets the data from a URL */
  15.  
  16. function get_data($url)
  17. {
  18. $ch = curl_init();
  19. $timeout = 5;
  20. curl_setopt($ch,CURLOPT_URL,$url);
  21. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  22. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  23. $data = curl_exec($ch);
  24. curl_close($ch);
  25. return $data;
  26. }
  27. $url='http://www.tcmb.gov.tr/kurlar/today.xml';
  28.  
  29. $content=get_data($url);
  30. //$content = file_get_contents("http://www.tcmb.gov.tr/kurlar/today.xml");
  31. $dolar_bul = explode('<Currency Kod="USD" CurrencyCode="USD">' ,$content);
  32. $dolar_bul = explode('</ForexBuying>',$dolar_bul[1]);
  33. $dolar_alis = explode('<ForexBuying>',$dolar_bul[0]);
  34. $dolar_bul = explode('</ForexSelling>',$dolar_bul[1]);
  35. $dolar_satis = explode('<ForexSelling>',$dolar_bul[0]);
  36. $dolar_alis = $dolar_alis[1];
  37. $dolar_satis = $dolar_satis[1];
  38.  
  39. $euro_bul = explode('<Currency Kod="EUR" CurrencyCode="EUR">' ,$content);
  40. $euro_bul = explode('</ForexBuying>',$euro_bul[1]);
  41. $euro_alis = explode('<ForexBuying>',$euro_bul[0]);
  42. $euro_bul = explode('</ForexSelling>',$euro_bul[1]);
  43. $euro_satis = explode('<ForexSelling>',$euro_bul[0]);
  44. $euro_alis = $euro_alis[1];
  45. $euro_satis = $euro_satis[1];
  46. ?>
  47.  
  48. <span style="color: #FFF; text-decoration: none;">Dolar Alış:</span> <span style="color: #C60;"><?php echo $dolar_alis; ?>, </span>&nbsp;&nbsp;&nbsp;&nbsp;
  49. <span style="color: #FFF; text-decoration: none;">Dolar Satış:</span> <span style="color: #C60;"><?php echo $dolar_satis; ?>, </span>&nbsp;&nbsp;&nbsp;&nbsp;
  50. <span style="color: #FFF; text-decoration: none;">Euro Alış:</span> <span style="color: #C60;"><?php echo $euro_alis; ?>, </span>&nbsp;&nbsp;&nbsp;&nbsp;
  51. <span style="color: #FFF; text-decoration: none;">Euro Satış:</span> <span style="color: #C60;"><?php echo $euro_satis; ?></span>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment