applied seraphers proposed fixes & suggestions
This commit is contained in:
parent
c1290d5327
commit
981d73f988
@ -6,27 +6,43 @@
|
|||||||
chdir(dirname(__FILE__));
|
chdir(dirname(__FILE__));
|
||||||
|
|
||||||
// Include all settings and classes
|
// Include all settings and classes
|
||||||
require_once('shared.inc.php');
|
require_once('shared.inc.php');
|
||||||
|
|
||||||
if ( $bitcoin->can_connect() !== true )
|
if ( $bitcoin->can_connect() !== true )
|
||||||
die("Failed to connect to RPC server\n");
|
die("Failed to connect to RPC server\n");
|
||||||
|
|
||||||
echo "Validating blocks in database against coind..\n";
|
echo "Validating blocks in database against coind..\n";
|
||||||
|
|
||||||
|
$mask = "| %6s | %8s | %13s | %20s | %10s | \n";
|
||||||
|
printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status');
|
||||||
|
|
||||||
// fetch all blocks
|
// fetch all blocks
|
||||||
$allBlocks = $block->getAll();
|
$allBlocks = $block->getAll();
|
||||||
foreach ($allBlocks as $block)
|
foreach ($allBlocks as $block)
|
||||||
{
|
{
|
||||||
|
//print_r($block);
|
||||||
|
$status = 'VALID';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$blockInfo = $bitcoin->getblock($block['blockhash']);
|
$blockInfo = $bitcoin->getblock($block['blockhash']);
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
// don't report orphan blocks.
|
if($block['confirmations']== -1)
|
||||||
if($block['confirmations']!= -1 && $e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found')
|
|
||||||
{
|
{
|
||||||
echo "Block not found: database-id: $block[id] - height: $block[height].\n";
|
$status = 'ORPHAN';
|
||||||
|
}
|
||||||
|
else if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found')
|
||||||
|
{
|
||||||
|
$status = 'INVALID';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$status = 'UNKNOWN';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
printf($mask, $block['id'], $block['height'], $block['confirmations'], strftime("%Y-%m-%d %H:%M:%S", $block['time']), $status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
// Fetch all users
|
// Fetch all users
|
||||||
$users = $user->getAllAssoc();
|
$users = $user->getAllAssoc();
|
||||||
|
|
||||||
$mask = "| %6s | %20s | %16s | %10s | %-12.12s | %5s | %5s | %12s | %5s | \n";
|
$mask = "| %6s | %20s | %16s | %20s | %12.12s | %5s | %5s | %12s | %5s | \n";
|
||||||
printf($mask, 'ID', 'Username', 'LoggedIP', 'Last Login','Days Since', 'Ever', 'Trans', 'Balance','Stale');
|
printf($mask, 'ID', 'Username', 'LoggedIP', 'Last Login','Days Since', 'Ever', 'Trans', 'Balance','Stale');
|
||||||
|
|
||||||
$currentTime = time();
|
$currentTime = time();
|
||||||
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
$everLoggedIn = !empty($lastLogin);
|
$everLoggedIn = !empty($lastLogin);
|
||||||
$timeDelta = $currentTime - $lastLogin;
|
$timeDelta = $currentTime - $lastLogin;
|
||||||
$lastLoginInDays = abs($timeDelta)/60/60/24;
|
$lastLoginInDays = round(abs($timeDelta)/60/60/24, 0);
|
||||||
|
|
||||||
if($lastLoginInDays < $timeLimitInDays)
|
if($lastLoginInDays < $timeLimitInDays)
|
||||||
continue;
|
continue;
|
||||||
@ -47,8 +47,8 @@
|
|||||||
$staleAccount = $everLoggedIn == false && $transactions_exists == false;
|
$staleAccount = $everLoggedIn == false && $transactions_exists == false;
|
||||||
|
|
||||||
printf($mask, $id, $username,
|
printf($mask, $id, $username,
|
||||||
$loggedIp, $lastLogin, $lastLoginInDays, $everLoggedIn ? 'yes' : 'no',
|
$loggedIp, strftime("%Y-%m-%d %H:%M:%S", $lastLogin), $lastLoginInDays, $everLoggedIn ? 'yes' : 'no',
|
||||||
$transactions_exists ? 'yes' : 'no', $confirmedBalance,
|
$transactions_exists ? 'yes' : 'no', round($confirmedBalance,8),
|
||||||
$staleAccount ? 'yes' : 'no' );
|
$staleAccount ? 'yes' : 'no' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user