added block validation and account validation scripts
This commit is contained in:
parent
cf8a10d9b0
commit
c1290d5327
34
scripts/validate_blocks.php
Normal file
34
scripts/validate_blocks.php
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/* script to validate blocks */
|
||||
|
||||
// Change to working directory
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Include all settings and classes
|
||||
require_once('shared.inc.php');
|
||||
|
||||
if ( $bitcoin->can_connect() !== true )
|
||||
die("Failed to connect to RPC server\n");
|
||||
|
||||
echo "Validating blocks in database against coind..\n";
|
||||
|
||||
// fetch all blocks
|
||||
$allBlocks = $block->getAll();
|
||||
foreach ($allBlocks as $block)
|
||||
{
|
||||
try {
|
||||
$blockInfo = $bitcoin->getblock($block['blockhash']);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
// don't report orphan blocks.
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "Done..\n";
|
||||
?>
|
||||
56
scripts/validate_users.php
Normal file
56
scripts/validate_users.php
Normal file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/* script to validate accounts */
|
||||
|
||||
// Change to working directory
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Include all settings and classes
|
||||
require_once('shared.inc.php');
|
||||
|
||||
$timeLimitInDays = 90;
|
||||
|
||||
// Fetch all users
|
||||
$users = $user->getAllAssoc();
|
||||
|
||||
$mask = "| %6s | %20s | %16s | %10s | %-12.12s | %5s | %5s | %12s | %5s | \n";
|
||||
printf($mask, 'ID', 'Username', 'LoggedIP', 'Last Login','Days Since', 'Ever', 'Trans', 'Balance','Stale');
|
||||
|
||||
$currentTime = time();
|
||||
$totalSavings = 0;
|
||||
|
||||
foreach ($users as $user)
|
||||
{
|
||||
$id = $user['id'];
|
||||
$isAdmin = $user['is_admin'];
|
||||
$username = $user['username'];
|
||||
$loggedIp = $user['loggedIp'];
|
||||
$lastLogin = $user['last_login'];
|
||||
$coinAddress = $user['coin_address'];
|
||||
|
||||
$everLoggedIn = !empty($lastLogin);
|
||||
$timeDelta = $currentTime - $lastLogin;
|
||||
$lastLoginInDays = abs($timeDelta)/60/60/24;
|
||||
|
||||
if($lastLoginInDays < $timeLimitInDays)
|
||||
continue;
|
||||
|
||||
// get transactions summary for the user
|
||||
$summary = $transaction->getTransactionSummary($id);
|
||||
$transactions_exists = !empty($summary);
|
||||
|
||||
// get balances
|
||||
$balances = $transaction->getBalance($id);
|
||||
$confirmedBalance = $balances['confirmed'];
|
||||
$totalSavings += $confirmedBalance;
|
||||
|
||||
$staleAccount = $everLoggedIn == false && $transactions_exists == false;
|
||||
|
||||
printf($mask, $id, $username,
|
||||
$loggedIp, $lastLogin, $lastLoginInDays, $everLoggedIn ? 'yes' : 'no',
|
||||
$transactions_exists ? 'yes' : 'no', $confirmedBalance,
|
||||
$staleAccount ? 'yes' : 'no' );
|
||||
}
|
||||
|
||||
echo "Total balance of stale accounts: $totalSavings \n";
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user