[MERGE] Development, merge conflicts fixed

This commit is contained in:
Sebastian Grewe 2014-03-03 10:50:58 +01:00
commit b59f878c22
11 changed files with 127 additions and 8 deletions

View File

@ -39,6 +39,7 @@ These people have supported this project with a donation:
* [PCFiL](https://github.com/PCFiL)
* [rog1121](https://github.com/rog1121)(https://rapidhash.net)
* [Wow, Much Pool](http://www.wowmuchpool.com/)
* webxassDE (https://www.suchcoins.com/)
Pools running MPOS
==================

View File

@ -54,10 +54,18 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
$log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $aBlockInfo['confirmations'], $status));
continue;
}
if ($aBlock['confirmations'] == $aBlockInfo['confirmations']) {
if (isset($aBlockInfo['confirmations'])) {
$iRPCConfirmations = $aBlockInfo['confirmations'];
} else if (isset($aTxDetails['confirmations'])) {
$iRPCConfirmations = $aTxDetails['confirmations'];
} else {
$log->logFatal(' RPC does not return any usable block confirmation information');
$monitoring->endCronjob($cron_name, 'E0082', 1, true);
}
if ($iRPCConfirmations == $aBlock['confirmations']) {
continue;
} else {
if (!$block->setConfirmations($aBlock['id'], $aBlockInfo['confirmations'])) {
if (!$block->setConfirmations($aBlock['id'], $iRPCConfirmations)) {
$log->logError(' Failed to update block confirmations: ' . $block->getCronMessage());
$status = 'ERROR';
} else {
@ -67,7 +75,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
$log->logInfo(sprintf($strLogMask, 'ID', 'Height', 'Blockhash', 'Old', 'New', 'Status'));
$header = true;
}
$log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $aBlockInfo['confirmations'], $status));
$log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $iRPCConfirmations, $status));
}
}

View File

@ -74,6 +74,10 @@ class BitcoinWrapper extends BitcoinClient {
if (is_array($dNetworkHashrate)) {
if (array_key_exists('networkhashps', $dNetworkHashrate)) {
$dNetworkHashrate = $dNetworkHashrate['networkhashps'];
} else if (array_key_exists('networkmhps', $dNetworkHashrate)) {
$dNetworkHashrate = $dNetworkHashrate['networkmhps'] * 1000;
} else if (array_key_exists('networkghps', $dNetworkHashrate)) {
$dNetworkHashrate = $dNetworkHashrate['networkghps'] * 1000 * 1000;
} else if (array_key_exists('hashespersec', $dNetworkHashrate)) {
$dNetworkHashrate = $dNetworkHashrate['hashespersec'];
} else if (array_key_exists('netmhashps', $dNetworkHashrate)) {

0
public/include/classes/notification.class.php Normal file → Executable file
View File

View File

@ -413,6 +413,7 @@ $aSettings['monitoring'][] = array(
);
$aSettings['notifications'][] = array(
'display' => 'Notification Cleanup Time', 'type' => 'text',
'size' => 10,
'default' => 7,
'name' => 'notifications_cleanup_time', 'value' => $setting->getValue('notifications_cleanup_time'),
'tooltip' => 'Maximum age in days of notifications before cleaned from database.'

View File

@ -77,4 +77,5 @@ $aErrorCodes['E0078'] = 'RPC method did not return 200 OK';
$aErrorCodes['E0079'] = 'Wallet does not cover payouts total amount';
$aErrorCodes['E0080'] = 'No new unaccounted shares since last run';
$aErrorCodes['E0081'] = 'Failed to insert new block into database';
$aErrorCodes['E0082'] = 'Block does not supply any usable confirmation information';
?>

2
public/include/pages/account/notifications.inc.php Normal file → Executable file
View File

@ -19,7 +19,7 @@ if ($user->isAuthenticated()) {
}
// Fetch notifications
$aNotifications = $notification->getNofifications($_SESSION['USERDATA']['id']);
$aNotifications = $notification->getNotifications($_SESSION['USERDATA']['id']);
if (!$aNotifications) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any notifications', 'TYPE' => 'alert alert-danger');
// Fetch global settings

View File

@ -8,13 +8,13 @@ $api->isActive();
$user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']);
// Fetch transactions
if (isset($_REQUEST['limit']) && $_REQUEST['limit'] < 30) {
if (isset($_REQUEST['limit']) && $_REQUEST['limit'] <= 100) {
$limit = $_REQUEST['limit'];
} else {
// Force limit
$limit = 5;
$limit = 100;
}
$data['transactions'] = $transaction->getTransactions(0, NULL, 30, $user_id);
$data['transactions'] = $transaction->getTransactions(0, NULL, $limit, $user_id);
// Fetch summary if enabled
if (!$setting->getValue('disable_transactionsummary')) {

View File

@ -142,6 +142,7 @@ if (@$_SESSION['USERDATA']['id']) {
$aGlobal['userdata']['rawhashrate'] = $aUserMiningStats['hashrate'];
$aGlobal['userdata']['hashrate'] = $aGlobal['userdata']['rawhashrate'] * $dPersonalHashrateModifier;
$aGlobal['userdata']['sharerate'] = $aUserMiningStats['sharerate'];
$aGlobal['userdata']['sharedifficulty'] = $aUserMiningStats['avgsharediff'];
switch ($config['payout_system']) {
case 'prop':
@ -163,7 +164,6 @@ if (@$_SESSION['USERDATA']['id']) {
$aGlobal['userdata']['pps']['unpaidshares'] = $statistics->getUserUnpaidPPSShares($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id'], $setting->getValue('pps_last_share_id'));
$aGlobal['ppsvalue'] = number_format($statistics->getPPSValue(), 12);
$aGlobal['poolppsvalue'] = $aGlobal['ppsvalue'] * pow(2, $config['difficulty'] - 16);
$aGlobal['userdata']['sharedifficulty'] = $statistics->getUserShareDifficulty($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id']);
$aGlobal['userdata']['estimates'] = $statistics->getUserEstimates($aGlobal['userdata']['sharerate'], $aGlobal['userdata']['sharedifficulty'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees'], $aGlobal['ppsvalue']);
break;
}

48
scripts/validate_blocks.php Executable file
View File

@ -0,0 +1,48 @@
#!/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". PHP_EOL);
echo "Validating blocks in database against coind..". PHP_EOL;
$mask = "| %6s | %8s | %13s | %20s | %10s |". PHP_EOL;;
printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status');
// fetch all blocks
$allBlocks = $block->getAll();
foreach ($allBlocks as $block)
{
try {
if($block['confirmations']== -1) // mark orphan blocks.
$status = 'ORPHAN';
else
{
$blockInfo = $bitcoin->getblock($block['blockhash']);
$status = 'VALID'; // if the getblock() call didn't throw an exception, it's a valid block then.
}
}
catch(Exception $e)
{
if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found')
{
$status = 'INVALID';
}
else
{
$status = 'UNKNOWN';
}
}
printf($mask, $block['id'], $block['height'], $block['confirmations'], strftime("%Y-%m-%d %H:%M:%S", $block['time']), $status);
}
echo "Done..". PHP_EOL;
?>

56
scripts/validate_users.php Executable file
View 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 | %20s | %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 = round(abs($timeDelta)/60/60/24, 0);
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, strftime("%Y-%m-%d %H:%M:%S", $lastLogin), $lastLoginInDays, $everLoggedIn ? 'yes' : 'no',
$transactions_exists ? 'yes' : 'no', round($confirmedBalance,8),
$staleAccount ? 'yes' : 'no' );
}
echo "Total balance of stale accounts: $totalSavings" . PHP_EOL;
?>