The Bitsnoop API is crashing WHILE

Asked

Viewed 30 times

1

Hello, I’m using that API from Bitsnoop, but a part of it is "catching" 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;
                }

1 answer

2


First of all the function should not be implemented inside while, remove that snippet out and place 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;
}

Redo the tests and check if there has been any improvement in performance.

  • Hello, the problem has been fixed, but it is too slow to load everything, it takes about 20 seconds.

  • yes this happens really because it is used an infra exterior, this is normal even friend

  • Vlw for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.