Created
October 11, 2015 20:01
-
-
Save GeertJohan/ad96c20a2935008b50a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '<div class="seeds">'; | |
function humanHashrate($value, $dec = 2) { | |
$size = array('H/s', 'kH/s', 'MH/s', 'GH/s', 'TH/s', 'PH/s', 'EH/s', 'ZH/s', 'YH/s'); | |
$factor = floor((strlen($value) - 1) / 3); | |
return sprintf("%.{$dec}f", $value / pow(1024, $factor)) . @$size[$factor]; | |
} | |
$json = file_get_contents('https://seeds.gulden.com/service/seedsOverview'); | |
$data = json_decode($json, true); | |
for( $data['nodes'] as $node ) { | |
$versionMajor = round(substr($node['version'], 0, len($node['version'])-6)); | |
$versionMinor = round(substr($node['version'], len($node['version'])-6), len($node['version'])-4)); | |
$versionPatch = round(substr($node['version'], len($node['version'])-4), len($node['version'])-2)); | |
$versionBuild = round(substr($node['version'], len($node['version'])-2), len($node['version']))); | |
$version = $versionMajor.'.'.$versionMinor.'.'.$versionPatch; | |
if($versionBuild != 0) { | |
$version .= '.'.$versionBuild; | |
} | |
echo ' | |
<div class="seeds-row"> | |
<div class="seeds-status seeds-status-'.$node['status'].'">'.$node['status'].'</div> | |
<div class="seeds-hostname">'.$node['hostname'].'</div> | |
<div class="seeds-version">'.$version.'</div> | |
<div class="seeds-connections">'.$node['connections'].'</div> | |
<div class="seeds-hashrate">'.humanHashrate($node['hashrate'], 3).'</div> | |
<div class="seeds-difficulty">'.$node['difficulty'].'</div> | |
<div class="seeds-height"> | |
<a href="https://explorer.gulden.com/#/block/'.$node['blockHash'].'" target="_blank">'.$node['blockNumber'].'</a> | |
</div> | |
<div class="seeds-blockHash"> | |
<span style="font-family:monospace;" >'.substr($node['blockHash'], 0, 15).'</span> | |
</div> | |
</div>'; | |
} | |
echo '</div>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment