示例#1
0
    return $result;
}
//send auth detail to server
$authusername = substr(str_shuffle(MD5(microtime())), 0, 12);
$authpassword = substr(str_shuffle(MD5(microtime())), 0, 12);
$licen = '';
//license key
// 100-77087b83dcd4c4f7779587
// 100-1139e6899fdeda0db594a5
// 100-193dbd7a54da898a52f969
$post_data = array('authuser' => $authusername, 'authpass' => $authpassword, 'licensekey' => '100-193dbd7a54da898a52f969');
// $post_data = array('authuser'=> $authusername,'authpass' => $authpassword, 'licensekey' => '100-5454676903fc3060e4849a');
$post_data = json_encode($post_data);
if (true) {
    // False for local server deployment
    $rid = my_curl_request("https://c.vidya.io", $post_data);
    // REMOVE HTTP
    //$rid = "8000.vidya.io";
    //print_r( $rid);exit;//8000.vidya.io
    //$rid = "8002.vidya.io";
    // $rid = "8002.vidya.io";
    if (empty($rid) or strlen($rid) > 32) {
        echo "Chat server is unavailable!";
        exit;
    }
    //setcookie('auth_user', $authusername, 0, '/');
    //setcookie('auth_pass', $authpassword, 0, '/');
    //setcookie('path', $rid, 0, '/');
    $rid = "wss://{$rid}";
} else {
    $rid = "ws://127.0.0.1:8080";
示例#2
0
### OPTIMIZE THIS TO KNOW WHEN THE LAST BLOCK WAS?!
$sql = "INSERT INTO {$psqlschema}.stats_blocks (server, orig_id, time, user_id, solution, network_difficulty) select server, id, time, user_id, solution, (pow(10,((29-hex_to_int(substr(encode(solution,'hex'),145,2)))::double precision*2.4082399653118495617099111577959::double precision)+log(  (65535::double precision /  hex_to_int(substr(encode(solution,'hex'),147,6)))::double precision   )::double precision))::double precision as network_difficulty from shares where upstream_result=true and solution NOT IN (select solution from {$psqlschema}.stats_blocks);";
$result = pg_exec($link, $sql);
$sql = "select * from {$psqlschema}.stats_blocks where (confirmations < 120 and confirmations > 0) or (blockhash IS NULL) or ((acceptedshares is null or roundstart is null) and (confirmations > 0)) or (confirmations < 120 and time > NOW()-'1 day'::interval) order by time asc";
$result = pg_exec($link, $sql);
$numrows = pg_numrows($result);
for ($ri = 0; $ri < $numrows; $ri++) {
    $row = pg_fetch_array($result, $ri);
    $sol = $row["solution"];
    $sol = substr($sol, 2, 160);
    $sol = bigtolittle($sol);
    $blockhash = pack("H*", $sol);
    $blockhash = hash("sha256", hash("sha256", $blockhash, true));
    $blockhash = revhex($blockhash);
    $getblockjson = "{\"method\":\"getblock\", \"id\":\"1\", \"params\":[\"{$blockhash}\"]}";
    $getblock = my_curl_request($bitcoinrpcurl, $getblockjson);
    $height = 0;
    $dome = 0;
    if (isset($getblock["error"])) {
        $e = $getblock["error"];
        if ($e["message"] == "Block not found") {
            print "ORPHAN {$blockhash} {$row["id"]} {$row["orig_id"]}\n";
            $confs = 0;
        }
    } else {
        $jresult = $getblock["result"];
        $height = $jresult["height"];
        $confs = $jresult["confirmations"];
        if ($confs == 0) {
            print "ORPHAN {$blockhash}\n";
        } else {
示例#3
0
print "<TR><TD><B>Difficulty Achieved:</B></TD><TD>{$adiff} ({$adiffp}%)</TD></TR>";
print "<TR><TD><B>Bits:</B></TD><TD>{$block["bits"]}</TD></TR>";
$nonce = sprintf("%8x", $block["nonce"]);
print "<TR><TD><B>Nonce:</B></TD><TD>{$nonce}</TD></TR>";
print "<TR><TD><B>Version:</B></TD><TD>{$block["version"]}</TD></TR>";
$t = date("Y-m-d H:i:s", $block["time"]);
print "<TR><TD><B>Time:</B></TD><TD>{$t}</TD></TR>";
print "<TR><TD><B>Transactions:</B></TD><TD>{$txcount}</TD></TR>";
print "<TR><TD><B>Size:</B></TD><TD>{$block["size"]} bytes</TD></TR>";
print "<TR><TD><B>Coinbase transaction id:</B></TD><TD>{$block["tx"][0]}<BR><A HREF=\"http://blockchain.info/tx/{$block["tx"][0]}\" TARGET=\"_blank\">View on Blockchain.info</A> - <A HREF=\"http://blockexplorer.com/tx/{$block["tx"][0]}\" TARGET=\"_blank\">View on Blockexplorer.com</A></TD></TR>";
$cbtxid = $block["tx"][0];
$gettxnjson = "{\"method\":\"getrawtransaction\", \"id\":\"1\", \"params\":[\"{$cbtxid}\",1]}";
$query_hash = "blockinfo.php cbtx " . hash("sha256", "blockinfo.php {$gettxnjson}");
$gettxn = apc_fetch($query_hash);
if (!isset($gettxn["result"])) {
    $gettxn = my_curl_request($bitcoinrpcurl, $gettxnjson);
    apc_store($query_hash, $gettxn, 864000);
}
$cbtx = $gettxn["result"];
$cbtext = $cbtx["vin"][0]["coinbase"];
$cbouts = count($cbtx["vout"]);
print "<TR><TD><B>Addresses paid in coinbase tx:</B></TD><TD>{$cbouts}</TD></TR>";
print "</TABLE>";
print "<h2>Payouts in Coinbase Transaction</h2>";
print "<TABLE BORDER=1>";
$failsafe = 0;
$total = 0;
for ($i = 0; $i < $cbouts; $i++) {
    $out = $cbtx["vout"][$i];
    $ammt = $out["value"];
    $pammt = prettySatoshis($ammt * 100000000);