예제 #1
0
파일: block.php 프로젝트: bitoncoin/Ozcoin
 function FindNewGenerations($bitcoinController)
 {
     $blockcount = 0;
     $username = '';
     //Get list of last 200 transactions
     $transactions = $bitcoinController->query("listtransactions", "*", "200");
     //Go through all the transactions check if there is 50BTC inside
     $numAccounts = count($transactions);
     for ($i = 0; $i < $numAccounts; $i++) {
         //Check for 50BTC inside only if they are in the generate category
         if ($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature") {
             //At this point we may or may not have found a block,
             //Check to see if this account addres is already added to `networkBlocks`
             $accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '" . $transactions[$i]["txid"] . "' ORDER BY blockNumber DESC LIMIT 0,1") or sqlerr(__FILE__, __LINE__);
             $accountExists = mysql_num_rows($accountExistsQ);
             //Insert txid into latest network block
             if (!$accountExists) {
                 //Get last winning block
                 $lastSuccessfullBlockQ = mysql_query("SELECT blockNumber, id, username FROM winning_shares ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
                 $lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ);
                 $timestamp = $transactions[$i]["time"];
                 $id = $lastSuccessfullBlockR->id;
                 $rpcType = "http";
                 // http or https
                 $rpcUsername = "******";
                 // username
                 $rpcPassword = "******";
                 // password
                 $rpcHost = "localhost";
                 $rpcPort = 9000;
                 $bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort);
                 $currentBlockNumber = $bitcoinController->getblocknumber();
                 $confirms = $transactions[$i]["confirmations"];
                 $lastBlockNumber = $currentBlockNumber + 1 - $confirms;
                 $stats = new Stats();
                 mysql_query("INSERT INTO networkBlocks (blockNumber, timestamp, accountAddress, confirms) " . "VALUES ('{$lastBlockNumber}', '{$timestamp}', '" . $transactions[$i]["txid"] . "', '" . $transactions[$i]["confirmations"] . "')") or sqlerr(__FILE__, __LINE__);
                 $stats = new Stats();
                 $lastwinningid = $stats->lastWinningShareId();
                 $shareQ = mysql_query("SELECT sum(shares) as total from rounddetails WHERE blockNumber = {$lastBlockNumber}");
                 $shareC = mysql_fetch_object($shareQ);
                 $winningShareQ = mysql_query("SELECT id, username FROM shares where upstream_result = 'Y' AND id > {$lastwinningid}") or sqlerr(__FILE__, __LINE__);
                 while ($winningShareR = mysql_fetch_object($winningShareQ)) {
                     mysql_query("INSERT INTO winning_shares (blockNumber, username, share_id) VALUES ({$lastBlockNumber},'{$winningShareR->username}',{$winningShareR->id})") or sqlerr(__FILE__, __LINE__);
                     removeCache("last_winning_share_id");
                 }
                 //					$q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '".$transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "', shares = ". $shareC->total . " WHERE blockNumber = $lastBlockNumber";
                 $q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '" . $transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "' WHERE blockNumber = {$lastBlockNumber}";
                 echo $q;
                 mysql_query($q) or sqlerr(__FILE__, __LINE__);
                 $username = $lastSuccessfullBlockR->username;
                 $splitUsername = explode(".", $username);
                 $realUsername = $splitUsername[0];
                 $blockcount = $blockcount + 1;
                 $username .= $realUsername . ' ';
             }
         }
     }
 }
예제 #2
0
	

?>
	<br/>
	<h3>Info</h3>
	<hr size="1" width="80%"></hr>

	<?

	$sitewallet = mysql_query("SELECT sum(balance) FROM `accountBalance` WHERE `balance` > 0") or sqlerr(__FILE__, __LINE__);
	$sitewalletq = mysql_fetch_row($sitewallet);
	$usersbalance = $sitewalletq[0];
	$balance = $bitcoinController->query("getbalance");
	$total = $balance - $usersbalance;

	echo "Block Number: ".$bitcoinController->getblocknumber()."<br>";
	echo "Difficulty: ".$bitcoinController->query("getdifficulty")."<br>";
	echo "Wallet Balance: ".$balance."<br>";
	echo "UnPaid: ".$usersbalance."<br>";
	echo "Total Left: <font color=red>$total</font><br>";

	echo "<a href=/wallet.php>Everything Wallet</a><br/>";

?>
	<br><h3>News Control</h3>
	<hr size="1" width="80%"></hr>
<?
$getnews = mysql_query("SELECT id, `timestamp`, `title`, `message` FROM `news` ORDER BY `timestamp` DESC LIMIT 3") or sqlerr(__FILE__, __LINE__);
while($news = mysql_fetch_array($getnews)){
	echo"$news[title] <form action=\"/news.php\" method=\"post\"><input type=\"hidden\" name=\"id\" value=\"$news[id]\"><input type=\"hidden\" name=\"action\" value=\"update\"><input type=\"submit\" value=\"Update News\"></form><br>";
}
예제 #3
0
파일: stats.php 프로젝트: bitoncoin/Ozcoin
}
if ($cookieValid && $user_found == false) {
    $rank_shares = $stats->userrankshares($userInfo->id);
    if (count($rank_shares) > 0) {
        echo "<tr class=\"user_position\"><td>" . $rank_shares[0] . "</td><td>" . $userInfo->username . "</td><td>" . number_format($rank_shares[1]) . "</td></tr>";
    }
}
?>
	</table>
</div>
<div id="stats_server">

<?php 
// START SERVER STATS *************************************************************************************************************************
$show_hashrate = $settings->getsetting('currenthashrate');
$current_block_no = $bitcoinController->getblocknumber();
$show_difficulty = round($difficulty, 2);
echo "<table class=\"stats_table server_width\">";
echo "<tr><th colspan=\"2\" scope=\"col\">Server Stats</td></tr>";
echo "<tr class=\"d0\"><td class=\"leftheader\">Pool Hash Rate</td><td>" . number_format($show_hashrate / 1000, 3) . " MHashes/s</td></tr>";
echo "<tr class=\"d1\"><td class=\"leftheader\">Pool Efficiency</td><td><span class=\"green\">" . number_format($stats->poolefficiency(), 2) . "%</span></td></tr>";
$res = $stats->userhashrates();
$hashcount = 0;
foreach ($res as $hash) {
    if ($hash > 0) {
        $hashcount++;
    }
}
echo "<tr class=\"d0\"><td class=\"leftheader\">Current Users Mining</td><td>" . number_format($hashcount) . "</td></tr>";
echo "<tr class=\"d1\"><td class=\"leftheader\">Current Total Miners</td><td>" . number_format($stats->currentworkers()) . "</td></tr>";
echo "<tr class=\"d0\"><td class=\"leftheader\">Current Block</td><td><a href=\"http://blockexplorer.com/b/" . $current_block_no . "\">";