예제 #1
0
function spectra_network_statistics()
{
    echo "\t<h1> Network Statistics </h1> \n\n";
    echo "\t<div id=\"network_panel\">\n\n";
    $network_info = getinfo();
    if (isset($network_info["blocks"]) && $network_info["blocks"] != "") {
        echo "\t\t<div class=\"network_detail\">\n";
        echo "\t\t\t<div class=\"network_detail_label\"> \n";
        echo "\t\t\t\tBlock Count: \n";
        echo "\t\t\t</div> \n";
        echo "\t\t\t<div class=\"network_detail_value\"> \n";
        echo "\t\t\t\t" . $network_info["blocks"] . "\n";
        echo "\t\t\t</div> \n";
        echo "\t\t</div> \n\n";
    }
    if (isset($network_info["difficulty"]) && $network_info["difficulty"] != "") {
        echo "\t\t<div class=\"network_detail\">\n";
        echo "\t\t\t<div class=\"network_detail_label\"> \n";
        echo "\t\t\t\tDifficulty: \n";
        echo "\t\t\t</div> \n";
        echo "\t\t\t<div class=\"network_detail_value\"> \n";
        echo "\t\t\t\t" . $network_info["difficulty"] . "\n";
        echo "\t\t\t</div> \n";
        echo "\t\t</div> \n\n";
    }
    if (isset($network_info["connections"]) && $network_info["connections"] != "") {
        echo "\t\t<div class=\"network_detail\">\n";
        echo "\t\t\t<div class=\"network_detail_label\"> \n";
        echo "\t\t\t\tConnections: \n";
        echo "\t\t\t</div> \n";
        echo "\t\t\t<div class=\"network_detail_value\"> \n";
        echo "\t\t\t\t" . $network_info["connections"] . "\n";
        echo "\t\t\t</div> \n";
        echo "\t\t</div> \n\n";
    }
    $net_speed = getnetworkhashps();
    if ($net_speed != "" && !is_array($net_speed)) {
        echo "\t\t<div class=\"network_detail\">\n";
        echo "\t\t\t<div class=\"network_detail_label\"> \n";
        echo "\t\t\t\tNetwork H/s: \n";
        echo "\t\t\t</div> \n";
        echo "\t\t\t<div class=\"network_detail_value\"> \n";
        echo "\t\t\t\t" . $net_speed . "\n";
        echo "\t\t\t</div> \n";
        echo "\t\t</div>\n\n";
    }
    //	Sort out the time of the last block in the node
    $node_height = getblockcount();
    $node_hash = getblockhash($node_height);
    $node_block = getblock($node_hash);
    if (!is_numeric($node_block["time"])) {
        $node_block["time"] = strtotime($node_block["time"]);
    }
    //	Calculate the time since the last block
    $last_time = floor((time() - $node_block["time"]) / 60);
    echo "\t\t<div class=\"network_detail\">\n";
    echo "\t\t\t<div class=\"network_detail_label\"> \n";
    echo "\t\t\t\tLast Block: \n";
    echo "\t\t\t</div> \n";
    echo "\t\t\t<div class=\"network_detail_value\"> \n";
    echo "\t\t\t\t" . $last_time . " Minutes\n";
    echo "\t\t\t</div> \n";
    echo "\t\t</div> \n\n";
    echo "\t</div>\n\n";
}
예제 #2
0
 echo "\t\t<div class=\"node_detail\">\n";
 echo "\t\t\t<span class=\"node_desc\">Block Count:</span><br>\n";
 echo "\t\t\t" . $network_info["blocks"] . "\n";
 echo "\t\t</div>\n";
 echo "\n";
 echo "\t\t<div class=\"node_detail\">\n";
 echo "\t\t\t<span class=\"node_desc\">Difficulty:</span><br>\n";
 echo "\t\t\t" . $network_info["difficulty"] . "\n";
 echo "\t\t</div>\n";
 echo "\n";
 echo "\t\t<div class=\"node_detail\">\n";
 echo "\t\t\t<span class=\"node_desc\">Connections:</span><br>\n";
 echo "\t\t\t" . $network_info["connections"] . "\n";
 echo "\t\t</div>\n";
 echo "\n";
 $net_speed = getnetworkhashps();
 if ($net_speed != "") {
     echo "\t\t<div class=\"node_detail\">\n";
     echo "\t\t\t<span class=\"node_desc\">Network H/s:</span><br>\n";
     echo "\t\t\t" . $net_speed . "\n";
     echo "\t\t</div>\n";
     echo "\n";
 }
 echo "\t</div>\n";
 echo "\n";
 echo "\t<div id=\"site_menu\">\n";
 echo "\n";
 echo "\t\t<div class=\"menu_item\">\n";
 echo "\t\t\t<span class=\"menu_desc\">Enter a Block Index / Height</span><br>\n";
 echo "\t\t\t<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"post\">\n";
 echo "\t\t\t\t<input type=\"text\" name=\"block_height\" size=\"40\">\n";
예제 #3
0
echo "\t\t</div> \n\n";
echo "\t\t<p> \n";
echo "\t\t\tSample 'getdifficulty' API response: \n";
echo "\t\t</p> \n\n";
echo "\t\t<div class=\"api_sample\"> \n";
echo "\t\t\t<pre> \n";
echo "Array \n";
echo "( \n";
echo "    [status] => 1 \n";
echo "    [message] =>  \n";
echo "    [data] => 62.45401651 \n";
echo ") \n";
echo "\t\t\t</pre> \n";
echo "\t\t</div> \n\n";
//*****************************************************************************
if (!is_array(getnetworkhashps())) {
    echo "\t\t<h2> Method: getnetworkhashps </h2> \n\n";
    echo "\t\t<p> \n";
    echo "\t\t\tSample 'getnetworkhashps' API request: \n";
    echo "\t\t</p> \n\n";
    echo "\t\t<ul> \n";
    echo "\t\t\t<li>No Parameter Is Required</li>\n";
    echo "\t\t</ul> \n\n";
    echo "\t\t<div class=\"api_sample\"> \n";
    echo "\t\t\t" . $GLOBALS["url"]["home"] . "api_fetch.php?method=getnetworkhashps \n";
    echo "\t\t</div> \n\n";
    echo "\t\t<p> \n";
    echo "\t\t\tSample 'getnetworkhashps' API response: \n";
    echo "\t\t</p> \n\n";
    echo "\t\t<div class=\"api_sample\"> \n";
    echo "\t\t\t<pre> \n";
예제 #4
0
    if (isset($requested["error"]) && $requested["error"] != "") {
        spectra_api_response("", 0, $requested["error"]["message"]);
    } else {
        spectra_api_response($requested);
    }
}
if ($_REQUEST["method"] == "getdifficulty") {
    $requested = getdifficulty();
    if (isset($requested["error"]) && $requested["error"] != "") {
        spectra_api_response("", 0, $requested["error"]["message"]);
    } else {
        spectra_api_response($requested);
    }
}
if ($_REQUEST["method"] == "getnetworkhashps") {
    $requested = getnetworkhashps();
    if (isset($requested["error"]) && $requested["error"] != "") {
        spectra_api_response("", 0, $requested["error"]["message"]);
    } else {
        spectra_api_response($requested);
    }
}
if ($_REQUEST["method"] == "getpeerinfo") {
    $requested = getpeerinfo();
    if (isset($requested["error"]) && $requested["error"] != "") {
        spectra_api_response("", 0, $requested["error"]["message"]);
    } else {
        spectra_api_response($requested);
    }
}
/******************************************************************************