bitcoinutopia -
Liittynyt: 07 Huh 2013 Viestejä: 7
|
Lähetetty: 14.5.2013 11:46 Viestin aihe: PHP-ongelma sivuillani. Joskus toimii oikein, joskus ei |
|
|
Minulle tulee hyvin usein tällainen virheilmoitus (ei kuitenkaan aina):
Lainaus: | Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/virtual/bitcoinutopia.com/htdocs/index.php on line 395 Warning: file_get_contents(http://blockchain.info/q/getreceivedbyaddress/1GwmtTcHbdMxQ2mCVQJq9hWuHYr3rUencd): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/virtual/bitcoinutopia.com/htdocs/index.php on line 395 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/virtual/bitcoinutopia.com/htdocs/index.php on line 397 Warning: file_get_contents(http://blockchain.info/ticker): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/virtual/bitcoinutopia.com/htdocs/index.php on line 397 |
Tässä on PHP-koodini, joka on tiedostossa index.php:
Koodi: | <?php
$file1 = 'tilitiedot.txt';
$file2 = 'kurssitiedot.txt';
$file3 = 'aikatiedot.txt';
$last_run = file_get_contents($file3);
if(time() >= $last_run + (60*5)) {
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\nUser-Agent: custom script\r\n",
'timeout'=>10
)
);
$context = stream_context_create($options);
$jsonfile = file_get_contents('http://blockchain.info/q/getreceivedbyaddress/1GwmtTcHbdMxQ2mCVQJq9hWuHYr3rUencd', false, $context);
file_put_contents($file1, $jsonfile);
$tickers_file_usd = file_get_contents('http://blockchain.info/ticker', false, $context);
file_put_contents($file2, $tickers_file_usd);
file_put_contents($file3, time());
}
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\nUser-Agent: custom script\r\n",
'timeout'=>10
)
);
$context = stream_context_create($options);
$jsonfile = file_get_contents($file1, false, $context);
$ADDRESS_BALANCE = file_get_contents($file1);
$ADDRESS_BALANCE = $ADDRESS_BALANCE/100000000;
$tickers_file_usd = file_get_contents($file2, false, $context);
$decoded_ticker = json_decode($tickers_file_usd, true);
$MTGOX_BTCUSD_LAST = $decoded_ticker['USD']['last'];
$BALANCE_USD = round($ADDRESS_BALANCE * $MTGOX_BTCUSD_LAST,2);
$GOAL_USD = round(10000.00,2);
echo '<p>Crowdfunding received: ',$ADDRESS_BALANCE, ' BTC (',$BALANCE_USD,' USD)</p>';
echo '<p>Crowdfunding goal: ',$GOAL_USD, ' USD</p>';
echo '<p>Status: ',$BALANCE_USD,'/',$GOAL_USD,' (',$BALANCE_USD/$GOAL_USD*100, ' % funded)</p>';
echo '<div class="progress progress-striped active">';
echo '<div class="bar" style="width: ',round($BALANCE_USD/$GOAL_USD*100,0),'%"></div>';
echo '</div>';
?> |
Mistä vika johtuu? Sivun lataaminen kestää useita sekunteja ja sitten tuo virheilmoitus tulee ruutuun. Silloin joskus, kun sivun lataaminen ei kestä kuin sekunnin tai kaksi, niin virheilmoitusta ei tule ja kaikki toimii juuri niin kuin pitääkin... |
|