el3

currency.php

el3
Mar 11th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2. //!alias add currency web title http://www.cgraphic.dk/currency.php?val=$1&from=$2&to=$3
  3. $title = ":)";
  4.  
  5. if(isset($_GET['from']) && isset($_GET['to']) && isset($_GET['val'])){
  6. $from = $_GET['from'];
  7. $to = $_GET['to'];
  8. $val = $_GET['val'];
  9. $link = 'http://www.x-rates.com/calculator/?from='.$from.'&to='.$to.'&amount='.$val;
  10. $doc = new DomDocument;
  11. $doc->validateOnParse = true;
  12. $doc->loadHtml(file_get_contents($link));
  13. $spans = $doc->getElementsByTagName('span');
  14. $count = 0;
  15.  
  16. foreach ($spans as $book) {
  17.  
  18. if($count==3){
  19. echo $book->nodeValue. ' ' .$count.'<br>';
  20. $title = $book->nodeValue;
  21. }
  22. if($count==6 && $book->nodeValue=='---'){
  23. $title = 'Eighter '.$from.' is not a valid currency, or wrong syntax. Example \'!currency 1 USD EUR\'';
  24. }
  25. if($count==5 && $book->nodeValue=='---'){
  26. $title = 'Eighter '.$to.' is not a valid currency, or wrong syntax. Example \'!currency 1 USD EUR\'';
  27. }
  28. $count++;
  29. }
  30. }
  31.  
  32. ?>
  33. <html>
  34. <head>
  35. <title><?php echo htmlspecialchars($title);?></title>
  36. </head>
  37. <html>
Advertisement
Add Comment
Please, Sign In to add comment