The Bitsnoop API is catching WHILE

1

Hello, I'm using this Bitsnoop API , but a part of it is "locking" WHILE. WHILE only runs once and nothing below it loads.

Code:

if($sql = mysqli_query($coneccao, "SELECT * FROM arquivos_downloads WHERE nome LIKE '%$palavra_chave%' ORDER BY id DESC"))
    {   
        while($linha = mysqli_fetch_array($sql))
        {
            if($i == $linha['id'] || $i != $linha['id'])
            {   
                $arq = $linha['nome'];

                $arq_title = $arq;

                $arq_nome = substr($linha['nome'], 0, 50);
                $arq_nome = str_replace("_", " ", $arq_nome);

                for($icont = 0; $icont <= 10000; $icont++)
                {
                    $arq_nome = str_replace("[".$icont."]", "", $arq_nome);
                    $arq_title = str_replace("[".$icont."]", "", $arq_title);
                }

                error_reporting(E_STRICT);

                ini_set('user_agent', 'PHP');

                function obterSeedLeech($hash)
                {
                    $apiURL = "http://bitsnoop.com/api/trackers.php?hash={$hash}&json=1";
                    $resultado = file_get_contents($apiURL);
                    return $resultado;
                }

                $torrent = new Torrent("Uploads/".$arq.".torrent");
                $torrentHash = $torrent->hash_info();

                $SeedsLeechs = obterSeedLeech($torrentHash);
                $SeedsLeechs = json_decode($SeedsLeechs);

                if (is_array($SeedsLeechs))
                {
                    foreach($SeedsLeechs as $anuncios)
                    {
                        $seeds = $seeds + $anuncios->NUM_SEEDERS;
                        $leechers = $leechers + $anuncios->NUM_LEECHERS;
                    }
                }   
        ?>      
                <div id="lista_arquivos_painel">
                    <div id="lista_arquivos_informacoes">
                        <div id="nome_arquivo_div">
                            <span id="nome_arquivo" title="<? echo $arq_title ?>"><b><? echo $arq_nome; ?></b></span>
                        </div>
                        <div id="tamanho_arquivo_div">
                            <span id="tamanho_arquivo" class="informacoes"><b><? echo $torrent->size(2); ?></b></span>
                        </div>
                        <div id="arquivos_arquivo_div">
                            <span id="arquivos_arquivo" class="informacoes"><b>3</b></span>
                        </div>
                        <div id="tempo_arquivo_div">
                            <span id="tempo_arquivo" class="informacoes"><b>9 dias</b></span>
                        </div>
                        <div id="seeds_arquivo_div">
                            <span id="seeds_arquivo" class="informacoes"><b><? echo $seeds ?></b></span>
                        </div>
                        <div id="leechs_arquivo_div">
                            <span id="leechs_arquivo" class="informacoes"><b><? echo $leechers ?></b></span>
                        </div>
                    </div>

                    <div id="lista_arquivos_botoes" href="#" id="botao_magnet">
                        <div id="botao_magnet_div">
                            <a href="<? echo $torrent->magnet(); ?>" target="_top" id="botao_magnet"><b>MAGNET</b></a>
                        </div>
                        <div id="botao_torrent_div">    
                            <a id="botao_torrent" href="<? echo "baixar.php?arquivo=Uploads/".$arq.".torrent" ?>"><b>.TORRENT</b></a>
                        </div>
                    </div>
                </div>
        <?       
            }
        }
    }
    ?>

Part that is catching WHILE

                    function obterSeedLeech($hash)
                {
                    $apiURL = "http://bitsnoop.com/api/trackers.php?hash={$hash}&json=1";
                    $resultado = file_get_contents($apiURL);
                    return $resultado;
                }
    
asked by anonymous 12.05.2015 / 23:30

1 answer

2

First of all, the function should not be implemented within while, remove it and put it before the while:

function obterSeedLeech($hash)
{
    $apiURL = "http://bitsnoop.com/api/trackers.php?hash={$hash}&json=1";
    $resultado = file_get_contents($apiURL);
    return $resultado;
}

Re-run the tests and check for any performance improvements.

    
12.05.2015 / 23:36