Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $name = "cosmic gate";
- $array = array(
- '/./' =>'',
- '/( feat)(.*)/' =>'',
- '/( Ft)(.*)/' =>'',
- '/( ft)(.*)/' =>'',
- '/( Feat)(.*)/' =>'',
- '/( pres)(.*)/' =>'',
- '/( Pres)(.*)/' =>'',
- '/( vs)(.*)/' =>'',
- '/( Vs)(.*)/' =>''
- );
- $artist = preg_replace(array_keys($array),array_values($array),$name);
- $url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&api_key=57ee3318536b23ee81d6b27e36997cde&artist='.$artist;
- $xml = @simplexml_load_file($url);
- $poster_def = "<img src="images/logo.png"/>";
- if ($xml === false) {
- echo $poster_def;
- } else {
- if(!empty($xml->artist->image[3])) {
- $poster_last = $xml->artist[0]->image[3];
- $poster_name = uniqid() . ".png";
- $poster_dir = "images";
- $poster_pach = $poster_dir . "/" . $poster_name;
- echo $xml->artist[0]->image[3];
- file_put_contents($poster_pach, file_get_contents($poster_last));
- } else {
- echo $poster_def;
- }
- }
- ?>
- $na_bazu = $poster_def;
- if (isset($xml) && !empty($xml->artist->image[3])) {
- $poster_last = $xml->artist[0]->image[3];
- $poster_name = uniqid() . ".png";
- $poster_dir = "images";
- $poster_pach = $poster_dir . "/" . $poster_name;
- $na_bazu = $xml->artist[0]->image[3];
- file_put_contents($poster_pach, file_get_contents($poster_last));
- }
- // Сохранить $$na_bazu на базу
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement