Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <?php
  2.  
  3. $name = "cosmic gate";
  4.  
  5. $array = array(
  6. '/./' =>'',
  7. '/( feat)(.*)/' =>'',
  8. '/( Ft)(.*)/' =>'',
  9. '/( ft)(.*)/' =>'',
  10. '/( Feat)(.*)/' =>'',
  11. '/( pres)(.*)/' =>'',
  12. '/( Pres)(.*)/' =>'',
  13. '/( vs)(.*)/' =>'',
  14. '/( Vs)(.*)/' =>''
  15.  
  16. );
  17.  
  18. $artist = preg_replace(array_keys($array),array_values($array),$name);
  19. $url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&api_key=57ee3318536b23ee81d6b27e36997cde&artist='.$artist;
  20. $xml = @simplexml_load_file($url);
  21. $poster_def = "<img src="images/logo.png"/>";
  22.  
  23. if ($xml === false) {
  24. echo $poster_def;
  25.  
  26. } else {
  27.  
  28. if(!empty($xml->artist->image[3])) {
  29.  
  30. $poster_last = $xml->artist[0]->image[3];
  31. $poster_name = uniqid() . ".png";
  32. $poster_dir = "images";
  33. $poster_pach = $poster_dir . "/" . $poster_name;
  34. echo $xml->artist[0]->image[3];
  35.  
  36. file_put_contents($poster_pach, file_get_contents($poster_last));
  37.  
  38. } else {
  39.  
  40. echo $poster_def;
  41. }
  42. }
  43.  
  44.  
  45.  
  46. ?>
  47.  
  48. $na_bazu = $poster_def;
  49.  
  50. if (isset($xml) && !empty($xml->artist->image[3])) {
  51.  
  52. $poster_last = $xml->artist[0]->image[3];
  53. $poster_name = uniqid() . ".png";
  54. $poster_dir = "images";
  55. $poster_pach = $poster_dir . "/" . $poster_name;
  56. $na_bazu = $xml->artist[0]->image[3];
  57.  
  58. file_put_contents($poster_pach, file_get_contents($poster_last));
  59.  
  60. }
  61.  
  62. // Сохранить $$na_bazu на базу
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement