Code working only on localhost [closed]

-3

I've set up a code to use on a radio that I own, pulling the cover of the song that is currently playing, however, it only works on localhost. When I enter the site, only the default image I put appears (If the server does not find the album image).

Could someone help me to find out what the reason is?

No PHP or any other error appears. Only the cover image of the server is not loaded, and it stays in place by default ...

$ip = "radioculturanf.ddns.net";
$port = "8000";
$api = "d5b942eae610872b133ca1f73bcbd3fe"; // 70bf8c268d5ea9d7d78a4f47e3b8ef35 57ee3318536b23ee81d6b27e36997cde

$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) { 
    $title = "Rádio fora do ar!   ";
} else { 
    fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
    while (!feof($fp)) {
        $info = fgets($fp);
    }
    $info = str_replace('</body></html>', "", $info);
    $split = explode(',', $info);
    if (empty($split[6])) {
        $title = "Título não disponível   ";
    } else {
        $count = count($split);
        $i = "6";
        while($i<=$count) {
            if ($i > 6) {
                @$title .= ", " . $split[$i];
            } else {
                @$title .= $split[$i];
            }
            $i++;
        }
    }
}
$title = "@".substr($title, 0, -2)."#";

function get_string_between($string, $start, $end){
    $string = ' ' . $string;
    $ini = strpos($string, $start);
    if ($ini == 0) return '';
    $ini += strlen($start);
    $len = strpos($string, $end, $ini) - $ini;
    return substr($string, $ini, $len);
}

$artista1  = get_string_between($title, '@', '- ');
$faixa1 = get_string_between($title, ' -', '#');


$artista = str_replace(" ", "+", trim($artista1));
$artista_final = str_replace("&amp", "&", $artista);
$artista_final = str_replace(",", "", $artista_final);

$faixa = str_replace(" ", "+", trim($faixa1));
$faixa_final = str_replace("&amp", "&", $faixa);
$faixa_final = str_replace(",", "", $faixa_final);

$api_include =  file_get_contents('http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key='.$api.'&artist='.$artista_final.'&track='.$faixa_final.'', TRUE); 

 function get_string_between_api($string_api, $start_api, $end_api){
    $string_api = ' ' . $string_api;
    $ini_api = strpos($string_api, $start_api);
    if ($ini_api == 0) return '';
    $ini_api += strlen($start_api);
    $len_api = strpos($string_api, $end_api, $ini_api) - $ini_api;
    return substr($string_api, $ini_api, $len_api);
}

$imagem = get_string_between_api($api_include, '<image size="large">', '</image>');
if(empty($imagem)){
    $img_fin = "cd.jpg";
}else{
    $img_fin = $imagem; 
}

$img_total = str_replace("%20/%3E%3C/div%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cdiv%20class=", "", $img_fin);
$img_total2 = '<img src='.$img_total.' />';

echo '

<div class="media">
    <p>'.$img_total2.'</p>
    <p><span class="artista">'.$artista1.'</span></p>
    <p><span class="faixa">'.$faixa1.'</span></p>
</div>

';
    
asked by anonymous 03.05.2017 / 19:21

1 answer

1

Error resolved. It was just changing one ridiculously simple thing in "php.ini".

The enable url function was "off". Putting "On", everything is working perfectly! rsrs

allow_url_fopen = On

Hugs

    
03.05.2017 / 20:20