function spectra_address_detail($address)
{
    echo "\t<h1> " . $GLOBALS["currency"]["name"] . " Address Details </h1> \n\n";
    echo "\t<div class=\"panel_wide\"> \n\n";
    echo "\t\t<h2> Address Description </h2> \n\n";
    echo "\t\t<div class=\"detail_row\"> \n\n";
    spectra_detail_1($GLOBALS["currency"]["name"] . " Address", $address["address"]);
    echo "\t\t</div> \n\n";
    echo "\t\t<div class=\"detail_row\"> \n\n";
    $target = spectra_detail_link("block.php?hash=" . $address["firstblock"], "Address First Block", $address["firstblock"]);
    spectra_detail_1("Found In Block", $target);
    echo "\t\t</div> \n\n";
    echo "\t\t<div class=\"detail_row\"> \n\n";
    spectra_detail_2("Incoming TX Count", $address["tx_in"]);
    spectra_detail_2("Value Received", $address["received"]);
    echo "\t\t</div> \n\n";
    echo "\t\t<div class=\"detail_row\"> \n\n";
    spectra_detail_2("Outgoing TX Count", $address["tx_out"]);
    spectra_detail_2("Value Spent", $address["spent"]);
    echo "\t\t</div> \n\n";
    echo "\t\t<div class=\"detail_row\"> \n\n";
    spectra_detail_1("Current " . $GLOBALS["currency"]["code"] . " Balance", $address["balance"]);
    echo "\t\t</div> \n\n";
    if ($address["owner"] != "") {
        echo "\t\t<div class=\"detail_row\"> \n\n";
        spectra_detail_1("Address Claimed By", $address["owner"]);
        echo "\t\t</div> \n\n";
    }
    echo "\t</div> \n\n";
    //	Calculate values for the paginated query
    $page_in = spectra_page_describe("incoming", $address["tx_in"], 10);
    //	Retrieve inputs for this page
    $list_receive = mysqli_getset($GLOBALS["tables"]["vout"], "`addresses` LIKE '%" . $address["address"] . "%' ORDER BY `time` DESC LIMIT " . $page_in["per"] . " OFFSET " . $page_in["offset"]);
    //	Build the list of incoming transactions for this account
    echo "\t<div class=\"panel_wide\"> \n\n";
    echo "\t<h2> Incoming Transactions </h2> \n\n";
    //	Page controls for incoming transaction list
    spectra_page_control($page_in);
    //	Create a header row for the list
    echo "\t\t<div class=\"address_ledger_head\"> \n\n";
    echo "\t\t\t<div class=\"address_ledger_date_head\"> \n";
    echo "\t\t\t\tDate \n";
    echo "\t\t\t</div> \n\n";
    echo "\t\t\t<div class=\"address_ledger_txid_head\"> \n";
    echo "\t\t\t\tTransaction ID \n";
    echo "\t\t\t</div> \n\n";
    echo "\t\t\t<div class=\"address_ledger_value_head\"> \n";
    echo "\t\t\t\tValue \n";
    echo "\t\t\t</div> \n\n";
    echo "\t\t</div> \n\n";
    echo "\t\t<div class=\"address_ledger_wrap\"> \n\n";
    //	List and link each incoming transaction
    foreach ($list_receive["data"] as $received) {
        //	Enable alternating row colors
        if (isset($intype) && $intype == "even") {
            //	Odd row type
            echo "\t\t\t<div class=\"address_ledger_odd\"> \n\n";
            //	Reset the row type for the next row
            $intype = "odd";
        } else {
            //	Odd row type
            echo "\t\t\t<div class=\"address_ledger_even\"> \n\n";
            //	Reset the row type for the next row
            $intype = "even";
        }
        echo "\t\t\t\t<div class=\"address_ledger_date\"> \n";
        echo "\t\t\t\t\t" . date("m/d/Y H:i:s", $received["time"]) . " \n";
        echo "\t\t\t\t</div> \n\n";
        echo "\t\t\t\t<div class=\"address_ledger_txid\"> \n";
        echo "\t\t\t\t\t<a href=\"tx.php?tx=" . $received["in_tx"] . "\" title=\"Transaction Detail\"> \n";
        echo "\t\t\t\t\t\t" . $received["in_tx"] . " \n";
        echo "\t\t\t\t\t</a> \n";
        echo "\t\t\t\t</div> \n\n";
        echo "\t\t\t\t<div class=\"address_ledger_value\"> \n";
        echo "\t\t\t\t\t" . $received["value"] . " \n";
        echo "\t\t\t\t</div> \n\n";
        echo "\t\t\t</div> \n\n";
    }
    echo "\t\t</div> \n\n";
    echo "\t</div> \n\n";
    //	Calculate values for the paginated query
    $page_out = spectra_page_describe("outgoing", $address["tx_out"], 10);
    //	Retrieve outgoing transactions from the database
    $list_spent = mysqli_getset($GLOBALS["tables"]["vin"], "`src_address` LIKE '%" . $address["address"] . "%' ORDER BY `time` DESC LIMIT " . $page_out["per"] . " OFFSET " . $page_out["offset"]);
    //	Build the list of outgoing transactions for this account
    echo "\t<div class=\"panel_wide\"> \n\n";
    echo "\t<h2> Outgoing Transactions </h2> \n\n";
    //	Page controls for incoming transaction list
    spectra_page_control($page_out);
    //	Create a outgoing row for the list
    echo "\t\t<div class=\"address_ledger_head\"> \n\n";
    echo "\t\t\t<div class=\"address_ledger_date_head\"> \n";
    echo "\t\t\t\tDate \n";
    echo "\t\t\t</div> \n\n";
    echo "\t\t\t<div class=\"address_ledger_txid_head\"> \n";
    echo "\t\t\t\tTransaction ID \n";
    echo "\t\t\t</div> \n\n";
    echo "\t\t\t<div class=\"address_ledger_value_head\"> \n";
    echo "\t\t\t\tValue \n";
    echo "\t\t\t</div> \n\n";
    echo "\t\t</div> \n\n";
    echo "\t\t<div class=\"address_ledger_wrap\"> \n\n";
    //	List and link each outgoing transaction
    if (!isset($list_spent["data"]) || $list_spent["data"] == "") {
        echo "\t\t\t<div class=\"address_ledger_odd\"> \n";
        echo "\t\t\t\tNo Outgoing Transactions\n";
        echo "\t\t\t</div> \n\n";
    } else {
        foreach ($list_spent["data"] as $spent) {
            //	Enable alternating row colors
            if (isset($outtype) && $outtype == "even") {
                //	Odd row type
                echo "\t\t\t<div class=\"address_ledger_odd\"> \n\n";
                //	Reset the row type for the next row
                $outtype = "odd";
            } else {
                //	Odd row type
                echo "\t\t\t<div class=\"address_ledger_even\"> \n\n";
                //	Reset the row type for the next row
                $outtype = "even";
            }
            echo "\t\t\t\t<div class=\"address_ledger_date\"> \n";
            echo "\t\t\t\t\t" . date("m/d/Y H:i:s", $spent["time"]) . " \n";
            echo "\t\t\t\t</div> \n\n";
            echo "\t\t\t\t<div class=\"address_ledger_txid\"> \n";
            echo "\t\t\t\t\t<a href=\"tx.php?tx=" . $spent["in_tx"] . "\" title=\"Transaction Detail\"> \n";
            echo "\t\t\t\t\t\t" . $spent["in_tx"] . " \n";
            echo "\t\t\t\t\t</a> \n";
            echo "\t\t\t\t</div> \n\n";
            echo "\t\t\t\t<div class=\"address_ledger_value\"> \n";
            echo "\t\t\t\t\t" . $spent["src_value"] . " \n";
            echo "\t\t\t\t</div> \n\n";
            echo "\t\t\t</div> \n\n";
        }
    }
    echo "\t\t</div> \n\n";
    echo "\t</div> \n\n";
}
function spectra_money_top1000()
{
    if (system_flag_get("balance_rebuild") > 0) {
        $balance_calc["total"] = "Re-Balancing";
        $balance_calc["percent"] = "0.00";
        return $balance_calc;
    }
    $accounts = mysqli_getset($GLOBALS["tables"]["ledger"], "1 ORDER BY `balance` DESC LIMIT 1000 OFFSET 100");
    if ($accounts["success"] < 1 || $accounts["data"] == "") {
        $balance_calc["total"] = "Unavailable";
        $balance_calc["percent"] = "0.00";
        return $balance_calc;
    }
    //	Initialize Calculation Result
    $sum_balances = 0;
    foreach ($accounts["data"] as $account) {
        $sum_balances = bcadd($sum_balances, $account["balance"], 8);
    }
    $calc_perc = bcdiv($sum_balances, spectra_money_supply(), 8);
    $balance_calc["total"] = $sum_balances;
    $balance_calc["percent"] = $calc_perc * 100;
    return $balance_calc;
}
Esempio n. 3
0
 //	Retrieve the addresses
 $cycle = mysqli_getset($GLOBALS["tables"]["ledger"], "1=1 ORDER BY `sys_index` ASC LIMIT 1000 OFFSET " . $count_loop * 1000);
 foreach ($cycle["data"] as $entry) {
     //	Fetch the vins for the address
     $list_vin = mysqli_getset($GLOBALS["tables"]["vin"], "`src_address` LIKE '%" . $entry["address"] . "%'");
     //	Sum the vins
     $sum_vin = 0;
     $num_vin = 0;
     if ($list_vin["data"] != "") {
         foreach ($list_vin["data"] as $vin) {
             $sum_vin = bcadd($sum_vin, $vin["src_value"], 8);
             $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