Exemplo n.º 1
0
function spectra_api_response($data, $status = 1, $message = "")
{
    //	Build the response array
    $response["status"] = $status;
    $response["message"] = $message;
    $response["data"] = $data;
    //	Apply the expected JSON format
    echo json_encode($response);
    //	Update the rate flag timer
    system_flag_set(hash_hmac("sha256", $_SERVER["REMOTE_ADDR"], $_SERVER["HTTP_USER_AGENT"]), time());
    exit;
}
Exemplo n.º 2
0
function spectra_block_setformat()
{
    if (!spectra_node_isalive()) {
        spectra_log_write(1, "Unable to connect to " . $GLOBALS["currency"]["name"] . " node.");
    }
    //	Retrieve the first block from the chain without specifying
    //	verbose mode
    $hash = getblockhash(1);
    $block = getblock($hash);
    //	Determine the format of the returned block data
    if (is_array($block)) {
        system_flag_set("block_req_verbose", 0);
        spectra_log_write(0, "Block format set to ignore verbose mode.");
    } else {
        system_flag_set("block_req_verbose", 1);
        spectra_log_write(0, "Block format set to require verbose mode.");
    }
}
Exemplo n.º 3
0
        //	Increment the explorer height to indicate the next desired block
        $start++;
        spectra_log_write(0, "Loading Block: " . $start);
        //	The next block is loaded
        spectra_block_load($start);
        //	Increment the block count
        $count_loaded++;
    }
    //	Log the number of blocks loaded
    spectra_log_write(0, "Loaded " . $count_loaded . " Blocks.");
}
/******************************************************************************
	Rebuild Balances If Indicated
******************************************************************************/
//	Check for the balances flag and rebuild if requested
if (system_flag_get("balance_rebuild") > 0) {
    //	There is another script that will handle this
    include "maint_rebalance.php";
}
/******************************************************************************
	Reset Maintenance Flags
******************************************************************************/
//	Reset the maintenance mode flag
system_flag_set("maintenance", 0);
//	Log the time of completion
spectra_log_write(0, "Script maint_crontab.php complete.");
/******************************************************************************
	Developed By Jake Paysnoe - Copyright © 2015 SPEC Development Team
	SPEC Block Explorer is released under the MIT Software License.
	For additional details please read license.txt in this package.
******************************************************************************/
Exemplo n.º 4
0
                $num_vin++;
            }
        }
        //	Fetch the vouts for the address
        $list_vout = mysqli_getset($GLOBALS["tables"]["vout"], "`addresses` LIKE '%" . $entry["address"] . "%'");
        //	Sum the vouts
        $sum_vout = 0;
        $num_vout = 0;
        if ($list_vout["data"] != "") {
            foreach ($list_vout["data"] as $vout) {
                $sum_vout = bcadd($sum_vout, $vout["value"], 8);
                $num_vout++;
            }
        }
        //	Calculate the balance
        $balance = bcsub($sum_vout, $sum_vin, 8);
        //	Update the ledger record
        $result = $GLOBALS["db"]["obj"]->query("UPDATE `" . $GLOBALS["tables"]["ledger"] . "` SET `tx_in` = '" . $num_vout . "', `received` = '" . $sum_vout . "', `tx_out` = '" . $num_vin . "', `spent` = '" . $sum_vin . "', `balance` = '" . $balance . "' WHERE `address` = '" . $entry["address"] . "'");
    }
    //	Increment the set counter
    $count_loop++;
}
//	Reset the balance rebuild flag
system_flag_set("balance_rebuild", 0);
//	Some data for the log
spectra_log_write(0, "Rebalance Complete");
/******************************************************************************
	Developed By Jake Paysnoe - Copyright © 2015 SPEC Development Team
	SPEC Block Explorer is released under the MIT Software License.
	For additional details please read license.txt in this package.
******************************************************************************/