Merge pull request #1944 from MPOS/development

[MASTER] Update from Development
This commit is contained in:
Sebastian Grewe 2014-03-15 11:55:18 +01:00
commit 885e9328bf
16 changed files with 196 additions and 80 deletions

View File

@ -29,47 +29,49 @@ if ($setting->getValue('disable_notifications') == 1) {
$monitoring->endCronjob($cron_name, 'E0009', 0, true, false);
}
$log->logDebug(" IDLE Worker Notifications ...");
// Find all IDLE workers
$aWorkers = $worker->getAllIdleWorkers();
if (empty($aWorkers)) {
$log->logDebug(" no idle workers found");
} else {
$log->logInfo(" found " . count($aWorkers) . " IDLE workers");
foreach ($aWorkers as $aWorker) {
$aData = $aWorker;
$aData['username'] = $user->getUserName($aWorker['account_id']);
$aData['subject'] = 'IDLE Worker : ' . $aWorker['username'];
$aData['worker'] = $aWorker['username'];
$aData['email'] = $user->getUserEmail($aData['username']);
$log->logDebug(" " . $aWorker['username'] . "...");
if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData))
$log->logDebug(" Failed sending notifications: " . $notification->getCronError());
}
}
$log->logDebug(" Reset IDLE Worker Notifications ...");
// We notified, lets check which recovered
$aNotifications = $notification->getAllActive('idle_worker');
if (!empty($aNotifications)) {
$log->logInfo(" found " . count($aNotifications) . " active notification(s)");
foreach ($aNotifications as $aNotification) {
$aData = json_decode($aNotification['data'], true);
$aWorker = $worker->getWorker($aData['id']);
$log->logDebug(" " . $aWorker['username'] . " ...");
if ($aWorker['hashrate'] > 0) {
if ($notification->setInactive($aNotification['id'])) {
$log->logDebug(" updated #" . $aNotification['id'] . " for " . $aWorker['username'] . " as inactive");
} else {
$log->logError(" failed to update #" . $aNotification['id'] . " for " . $aWorker['username']);
}
} else {
$log->logDebug(" still inactive");
if ($setting->getValue('notifications_disable_idle_worker') != 1) {
$log->logDebug(" IDLE Worker Notifications ...");
// Find all IDLE workers
$aWorkers = $worker->getAllIdleWorkers();
if (empty($aWorkers)) {
$log->logDebug(" no idle workers found");
} else {
$log->logInfo(" found " . count($aWorkers) . " IDLE workers");
foreach ($aWorkers as $aWorker) {
$aData = $aWorker;
$aData['username'] = $user->getUserName($aWorker['account_id']);
$aData['subject'] = 'IDLE Worker : ' . $aWorker['username'];
$aData['worker'] = $aWorker['username'];
$aData['email'] = $user->getUserEmail($aData['username']);
$log->logDebug(" " . $aWorker['username'] . "...");
if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData))
$log->logDebug(" Failed sending notifications: " . $notification->getCronError());
}
}
} else {
$log->logDebug(" no active IDLE worker notifications");
$log->logDebug(" Reset IDLE Worker Notifications ...");
// We notified, lets check which recovered
$aNotifications = $notification->getAllActive('idle_worker');
if (!empty($aNotifications)) {
$log->logInfo(" found " . count($aNotifications) . " active notification(s)");
foreach ($aNotifications as $aNotification) {
$aData = json_decode($aNotification['data'], true);
$aWorker = $worker->getWorker($aData['id']);
$log->logDebug(" " . $aWorker['username'] . " ...");
if ($aWorker['hashrate'] > 0) {
if ($notification->setInactive($aNotification['id'])) {
$log->logDebug(" updated #" . $aNotification['id'] . " for " . $aWorker['username'] . " as inactive");
} else {
$log->logError(" failed to update #" . $aNotification['id'] . " for " . $aWorker['username']);
}
} else {
$log->logDebug(" still inactive");
}
}
} else {
$log->logDebug(" no active IDLE worker notifications");
}
}
require_once('cron_end.inc.php');

View File

@ -181,8 +181,8 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
}
// Table header for account shares
$strLogMask = "| %5.5s | %-15.15s | %15.15s | %15.15s | %12.12s | %20.20s | %20.20s | %20.20s |";
$log->logInfo(sprintf($strLogMask, 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee'));
$strLogMask = "| %5.5s | %-15.15s | %15.15s | %15.15s | %12.12s | %15.15s | %15.15s | %15.15s | %15.15s |";
$log->logInfo(sprintf($strLogMask, 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee', 'Bonus'));
// Loop through all accounts that have found shares for this round
foreach ($aTotalAccountShares as $key => $aData) {
@ -201,16 +201,28 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
// Defaults
$aData['fee' ] = 0;
$aData['donation'] = 0;
$aData['pool_bonus'] = 0;
// Calculate pool fees
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8);
// Calculate pool bonus if it applies, will be paid from liquid assets!
if ($config['pool_bonus'] > 0) {
if ($config['pool_bonus_type'] == 'block') {
$aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $dReward, 8);
} else {
$aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $aData['payout'], 8);
}
}
// Calculate donation amount, fees not included
$aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8);
// Verbose output of this users calculations
$log->logInfo(
sprintf($strLogMask, $aData['id'], $aData['username'], $aData['pplns_valid'], $aData['pplns_invalid'],
number_format($aData['percentage'], 8), number_format($aData['payout'], 8), number_format($aData['donation'], 8), number_format($aData['fee'], 8)
number_format($aData['percentage'], 8), number_format($aData['payout'], 8), number_format($aData['donation'], 8), number_format($aData['fee'], 8), number_format($aData['pool_bonus'], 8)
)
);
@ -225,6 +237,10 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
if ($aData['donation'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation', $aBlock['id']))
$log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError() . 'on block ' . $aBlock['id']);
// Add new bonus credit
if ($aData['pool_bonus'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['pool_bonus'], 'Bonus', $aBlock['id']))
$log->logFatal('Failed to insert new Bonus transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
}
// Add full round share statistics

View File

@ -40,8 +40,8 @@ if (empty($aAllBlocks)) {
$count = 0;
// Table header for account shares
$strLogMask = "| %10.10s | %-5.5s | %15.15s | %15.15s | %12.12s | %20.20s | %20.20s | %20.20s |";
$log->logInfo(sprintf($strLogMask, 'Block', 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee'));
$strLogMask = "| %10.10s | %-5.5s | %15.15s | %15.15s | %12.12s | %12.12s | %15.15s | %15.15s | %15.15s | %15.15s |";
$log->logInfo(sprintf($strLogMask, 'Block', 'ID', 'Username', 'Valid', 'Invalid', 'Percentage', 'Payout', 'Donation', 'Fee', 'Bonus'));
foreach ($aAllBlocks as $iIndex => $aBlock) {
// If we have unaccounted blocks without share_ids, they might not have been inserted yet
if (!$aBlock['share_id']) {
@ -86,18 +86,30 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
// Defaults
$aData['fee' ] = 0;
$aData['donation'] = 0;
$aData['pool_bonus'] = 0;
$aData['percentage'] = round(( 100 / $iRoundShares ) * $aData['valid'], 8);
$aData['payout'] = round(( $aData['percentage'] / 100 ) * $dReward, 8);
// Calculate pool fees if they apply
if ($config['fees'] > 0 && $aData['no_fees'] == 0)
$aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8);
// Calculate pool bonus if it applies, will be paid from liquid assets!
if ($config['pool_bonus'] > 0) {
if ($config['pool_bonus_type'] == 'block') {
$aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $dReward, 8);
} else {
$aData['pool_bonus'] = round(( $config['pool_bonus'] / 100 ) * $aData['payout'], 8);
}
}
// Calculate donation amount, fees not included
$aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8);
// Verbose output of this users calculations
$log->logInfo(
sprintf($strLogMask, $aBlock['height'], $aData['id'], $aData['username'], $aData['valid'], $aData['invalid'],
number_format($aData['percentage'], 8), number_format($aData['payout'], 8), number_format($aData['donation'], 8), number_format($aData['fee'], 8))
number_format($aData['percentage'], 8), number_format($aData['payout'], 8), number_format($aData['donation'], 8), number_format($aData['fee'], 8), number_format($aData['pool_bonus'], 8))
);
// Update user share statistics
@ -114,6 +126,10 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
if ($aData['donation'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation', $aBlock['id']))
$log->logFatal('Failed to insert new Donation transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
// Add new bonus credit
if ($aData['pool_bonus'] > 0)
if (!$transaction->addTransaction($aData['id'], $aData['pool_bonus'], 'Bonus', $aBlock['id']))
$log->logFatal('Failed to insert new Bonus transaction to database for ' . $aData['username'] . ': ' . $transaction->getCronError());
}
// Add block as accounted for into settings table

View File

@ -6,25 +6,27 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
$notice = array();
$enotice = array();
$error = array();
// setup some basic stuff for checking - getuid/getpwuid not available on mac/windows
$apache_user = 'unknown';
if (substr_count(strtolower(PHP_OS), 'nix') > 0 || substr_count(strtolower(PHP_OS), 'linux') > 0) {
$apache_user = (function_exists('posix_getuid')) ? posix_getuid() : 'unknown';
$apache_user = (function_exists('posix_getpwuid')) ? posix_getpwuid($apache_user) : $apache_user;
}
// setup checks
// logging
if ($config['logging']['enabled']) {
if (!is_writable($config['logging']['path'])) {
$error[] = "Logging is enabled but we can't write in the logging path";
$error[] = "Logging is enabled but we can't write in the logfile path";
}
}
// check if memcache isn't available but enabled in config -> error
if (!class_exists('Memcached') && $config['memcache']['enabled']) {
$error[] = "You have memcache enabled in your config and it's not available. Install the package on your system.";
$error[] = "You have memcached enabled in your config and it's not available as a PHP module. Install the package on your system.";
}
// if it's not enabled, test it if it exists, if it works -> error tell them to enable, -> otherwise notice it's disabled
if (!$config['memcache']['enabled']) {
if (PHP_OS == 'WINNT') {
@ -38,16 +40,18 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
$memcache_test_get = @$memcache_test->get('test_mpos_setval');
}
if (class_exists('Memcached') && $memcache_test_get == $randmctv) {
$error[] = "You have memcache disabled in the config and it's available & works! Enable it.";
$error[] = "You have memcache disabled in the config but it's available and works! Enable it for best performance.";
} else {
$notice[] = "Memcache is disabled; Almost every linux distro has packages for it, you should be using it if you can.";
}
}
// check if htaccess exists
if (!file_exists(BASEPATH.".htaccess")) {
$htaccess_link = "<a href='https://github.com/MPOS/php-mpos/blob/next/public/.htaccess'>.htaccess</a>";
$notice[] = "You don't seem to have a .htaccess in your public folder, if you're using apache set it up $htaccess_link";
$notice[] = "You don't seem to have a .htaccess in your public folder, if you're using Apache set it up: $htaccess_link";
}
// check if we can write templates/cache and templates/compile -> error
if (!is_writable(THEME_DIR.'/cache')) {
$error[] = "templates/cache folder is not writable for uid {$apache_user['name']}";
@ -55,11 +59,13 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
if (!is_writable(THEME_DIR.'/compile')) {
$error[] = "templates/compile folder is not writable for uid {$apache_user['name']}";
}
// check if we can write the config files, we should NOT be able to -> error
if (is_writable(INCLUDE_DIR.'/config/global.inc.php') || is_writable(INCLUDE_DIR.'/config/global.inc.dist.php') ||
is_writable(INCLUDE_DIR.'/config/security.inc.php') || is_writable(INCLUDE_DIR.'/config/security.inc.dist.php')) {
$error[] = "Your config files <b>SHOULD NOT be writable to this user</b>!";
}
// check if daemon can connect -> error
try {
if ($bitcoin->can_connect() !== true) {
@ -76,7 +82,7 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
if (!$bitcoin->validateaddress($config['coldwallet']['address']))
$error[] = "Your cold wallet address is <u>SET and INVALID</u>";
}
// check if there is more than one account set on wallet
$accounts = $bitcoin->listaccounts();
if (count($accounts) > 1 && $accounts[''] <= 0) {
@ -85,34 +91,30 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
}
} catch (Exception $e) {
}
// if database connection fails -> error
$db_connect = new mysqli($config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['name'], $config['db']['port']);
if (mysqli_connect_errno() || !array_key_exists('client_info', $db_connect)) {
$error[] = "Unable to connect to mysql using provided credentials";
}
// check anti DOS protection, we need memcache for that
if ($config['mc_antidos'] && !$config['memcache']['enabled']) {
$error[] = "mc_antidos is enabled and memcache is not, <u>memcache is required</u> to use this";
}
// poke stratum using gettingstarted details -> enotice
if (substr_count(strtolower(PHP_OS), 'nix') > 0) {
// unix *poke*
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (function_exists('socket_create')) {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket !== false) {
$address = @gethostbyname($config['gettingstarted']['stratumurl']);
$result = @socket_connect($socket, $address, $config['gettingstarted']['stratumport']);
if ($result !== true) {
$enotice[] = "We tried to poke your Stratum server using config->gettingstarted details but it didn't respond";
$enotice[] = 'We tried to poke your Stratum server using your $config[\'gettingstarted\'] settings but it didn\'t respond';
}
$close = @socket_close($socket);
}
} else {
// mac/windows *poke*
if (! $fp = @fsockopen($config['gettingstarted']['stratumurl'],$config['gettingstarted']['stratumport'],$errCode,$errStr,1)) {
$enotice[] = "We tried to poke your Stratum server using config->gettingstarted details but it didn't respond";
// Connect via fsockopen as fallback
if (! $fp = @fsockopen($config['gettingstarted']['stratumurl'], $config['gettingstarted']['stratumport'], $errCode, $errStr, 1)) {
$enotice[] = 'We tried to poke your Stratum server using your $config[\'gettingstarted\'] settings but it didn\'t respond';
}
@fclose($fp);
}
// security checks
// salts too short -> notice, salts default -> error
if ((strlen($config['SALT']) < 24) || (strlen($config['SALTY']) < 24) || $config['SALT'] == 'PLEASEMAKEMESOMETHINGRANDOM' || $config['SALTY'] == 'THISSHOULDALSOBERRAANNDDOOM') {
@ -122,7 +124,7 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
$notice[] = "SALT or SALTY is too short, they should be more than 24 characters and changing them will require registering again";
}
}
// display the errors
foreach ($enotice as $en) {
$_SESSION['POPUP'][] = array('CONTENT' => $en, 'TYPE' => 'info');

View File

@ -3,6 +3,21 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
class Setting extends Base {
protected $table = 'settings';
private $cache = array();
/**
* Fetch all values available and cache them in this class
* That way we don't fetch them from DB for each call
*/
public function createCache() {
if ($aSettings = $this->getAllAssoc()) {
foreach ($aSettings as $key => $aData) {
$this->cache[$aData['name']] = $aData['value'];
}
return true;
}
return false;
}
/**
* Fetch a value from our table
@ -10,6 +25,8 @@ class Setting extends Base {
* @return value string Value
**/
public function getValue($name, $default="") {
// Try our class cache first
if (isset($this->cache[$name])) return $this->cache[$name];
$stmt = $this->mysqli->prepare("SELECT value FROM $this->table WHERE name = ? LIMIT 1");
if ($this->checkStmt($stmt) && $stmt->bind_param('s', $name) && $stmt->execute() && $result = $stmt->get_result()) {
if ($result->num_rows > 0) {
@ -30,6 +47,8 @@ class Setting extends Base {
* @return bool
**/
public function setValue($name, $value) {
// Update local cache too
$this->cache[$name] = $value;
$stmt = $this->mysqli->prepare("
INSERT INTO $this->table (name, value)
VALUES (?, ?)
@ -44,3 +63,5 @@ $setting = new Setting($debug, $mysqli);
$setting->setDebug($debug);
$setting->setMysql($mysqli);
$setting->setErrorCodes($aErrorCodes);
// Fill our class cache with data so we don't have to run SQL queries all the time
$setting->createCache();

View File

@ -469,7 +469,7 @@ class Statistics extends Base {
share_id,
IF(difficulty = 0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty) AS difficulty,
username
FROM shares_archive
FROM " . $this->share->getArchiveTableName() . "
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND) AND our_result = 'Y'
) AS t1
LEFT JOIN " . $this->user->getTableName() . " AS a

View File

@ -55,6 +55,8 @@ class Tools extends Base {
return 'btce';
} else if (preg_match('/cryptsy.com/', $url)) {
return 'cryptsy';
} else if (preg_match('/cryptorush.in/', $url)) {
return 'cryptorush';
}
$this->setErrorMessage("API URL unknown");
return false;
@ -84,6 +86,9 @@ class Tools extends Base {
case 'cryptsy':
return @$aData['return']['markets'][$strCurrency]['lasttradeprice'];
break;
case 'cryptorush':
return @$aData["$strCurrency/" . $this->config['price']['target']]['last_trade'];
break;
}
} else {
$this->setErrorMessage("Got an invalid response from ticker API");

View File

@ -425,3 +425,10 @@ $aSettings['notifications'][] = array(
'name' => 'notifications_disable_block', 'value' => $setting->getValue('notifications_disable_block'),
'tooltip' => 'Enable/Disable block notifications globally. Will remove the user option too.'
);
$aSettings['notifications'][] = array(
'display' => 'Disable IDLE Worker Notifications', 'type' => 'select',
'options' => array( 0 => 'No', 1 => 'Yes'),
'default' => 0,
'name' => 'notifications_disable_idle_worker', 'value' => $setting->getValue('notifications_disable_idle_worker'),
'tooltip' => 'Enable/Disable IDLE worker notifications globally. Will remove the user option too.'
);

View File

@ -128,12 +128,14 @@ $config['txfee_auto'] = 0.1;
$config['txfee_manual'] = 0.1;
/**
* Block Bonus
* Bonus in coins of block bonus
* Block & Pool Bonus
* Bonus coins for blockfinder or a pool bonus for everyone
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-block-bonus
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pool-bonus
*/
$config['block_bonus'] = 0;
$config['pool_bonus'] = 0;
$config['pool_bonus_type'] = 'payout';
/**
* Payout System

View File

@ -24,6 +24,7 @@ if ($user->isAuthenticated()) {
// Fetch global settings
$smarty->assign('DISABLE_BLOCKNOTIFICATIONS', $setting->getValue('notifications_disable_block'));
$smarty->assign('DISABLE_IDLEWORKERNOTIFICATIONS', $setting->getValue('notifications_disable_idle_worker'));
// Fetch user notification settings
$aSettings = $notification->getNotificationSettings($_SESSION['USERDATA']['id']);

View File

@ -40,6 +40,7 @@ if ($user->isAuthenticated()) {
break;
}
$smarty->assign('DISABLE_IDLEWORKERNOTIFICATIONS', $setting->getValue('notifications_disable_idle_worker'));
$aWorkers = $worker->getWorkers($_SESSION['USERDATA']['id']);
if (!$aWorkers) $_SESSION['POPUP'][] = array('CONTENT' => 'You have no workers configured', 'TYPE' => 'errormsg');

View File

@ -15,6 +15,7 @@ empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start'];
$aWorkers = $worker->getAllWorkers($iLimit, $interval, $start);
$smarty->assign('DISABLE_IDLEWORKERNOTIFICATIONS', $setting->getValue('notifications_disable_idle_worker'));
$smarty->assign('LIMIT', $iLimit);
$smarty->assign('WORKERS', $aWorkers);
$smarty->assign('CONTENT', 'default.tpl');

View File

@ -13,6 +13,7 @@
<th align="left">Type</th>
<th align="center">Active</th>
</tr>
{if $DISABLE_IDLEWORKERNOTIFICATIONS|default:"" != 1}
<tr>
<td align="left">IDLE Worker</td>
<td>
@ -25,6 +26,7 @@
</span>
</td>
</tr>
{/if}
{if $DISABLE_BLOCKNOTIFICATIONS|default:"" != 1}
<tr>
<td align="left">New Blocks</td>

View File

@ -37,7 +37,7 @@
<th align="left">Worker Login</th>
<th align="left">Worker Password</th>
<th align="center">Active</th>
{if $GLOBAL.config.disable_notifications != 1}<th align="center">Monitor</th>{/if}
{if $GLOBAL.config.disable_notifications != 1 && $DISABLE_IDLEWORKERNOTIFICATIONS != 1}<th align="center">Monitor</th>{/if}
<th align="right">Khash/s</th>
<th align="right">Difficulty</th>
<th align="center" style="padding-right: 25px;">Action</th>
@ -51,7 +51,7 @@
<td align="left"{if $WORKERS[worker].hashrate > 0} style="color: orange"{/if}>{$username.0|escape}.<input name="data[{$WORKERS[worker].id}][username]" value="{$username.1|escape}" size="10" required/></td>
<td align="left"><input type="text" name="data[{$WORKERS[worker].id}][password]" value="{$WORKERS[worker].password|escape}" size="10" required></td>
<td align="center"><i class="icon-{if $WORKERS[worker].hashrate > 0}ok{else}cancel{/if}"></i></td>
{if $GLOBAL.config.disable_notifications != 1}
{if $GLOBAL.config.disable_notifications != 1 && $DISABLE_IDLEWORKERNOTIFICATIONS != 1}
<td>
<span class="toggle">
<label for="data[{$WORKERS[worker].id}][monitor]">

View File

@ -25,8 +25,8 @@
<th align="left">Worker Name</th>
<th align="left">Password</th>
<th align="center">Active</th>
{if $GLOBAL.config.disable_notifications != 1}<th align="center">Monitor</th>{/if}
<th align="right">Khash/s</th>
{if $GLOBAL.config.disable_notifications != 1 && $DISABLE_IDLEWORKERNOTIFICATIONS != 1}<th align="center">Monitor</th>{/if}
<th align="right">Difficulty</th>
<th align="right" style="padding-right: 25px;">Avg Difficulty</th>
</tr>
@ -38,7 +38,7 @@
<td align="left">{$WORKERS[worker].username|escape}</td>
<td align="left">{$WORKERS[worker].password|escape}</td>
<td align="center"><i class="icon-{if $WORKERS[worker].hashrate > 0}ok{else}cancel{/if}"></i></td>
{if $GLOBAL.config.disable_notifications != 1}
{if $GLOBAL.config.disable_notifications != 1 && $DISABLE_IDLEWORKERNOTIFICATIONS != 1}
<td align="center"><i class="icon-{if $WORKERS[worker].monitor}ok{else}cancel{/if}"></i></td>
{/if}
<td align="right">{$WORKERS[worker].hashrate|number_format|default:"0"}</td>

View File

@ -29,9 +29,20 @@ chdir(dirname(__FILE__));
// Include all settings and classes
require_once('shared.inc.php');
// Command line options
$options = getopt("l:r:");
$options = getopt("hvl:r:t:");
isset($options['l']) ? $limit = (int)$options['l'] : $limit = (int)1000;
isset($options['r']) ? $rpclimit = (int)$options['r'] : $rpclimit = (int)10000;
isset($options['t']) ? $customtxfee = (float)$options['t'] : $customtxfee = (float)0.1;
isset($options['v']) ? $verbose = true : $verbose = false;
if (isset($options['h'])) {
echo "Usage " . basename($argv[0]) . " [-l #] [-c #]:" . PHP_EOL;
echo " -h : Show this help" . PHP_EOL;
echo " -v : Verbose mode, will show RPC transactions not matched against DB" . PHP_EOL;
echo " -l # : Limit to # last database debit AP/MP transactions, default 1000" . PHP_EOL;
echo " -c # : Limit to # last transactions, default 10000" . PHP_EOL;
echo " -t # : Check against a custom TX Fee too, default 0.1" . PHP_EOL;
exit(0);
}
// Fetch and merge MP and AP payouts
$aAllMPDebitTxs = $transaction->getTransactions(0, array('type' => 'Debit_MP'), $limit);
@ -50,6 +61,7 @@ foreach ($aListTransactions as $key => $aTransaction) {
// Initilize counters
$total=count($aListTransactions);
$aMissingRPCMatches = array();
$found=0;
$notfound=0;
@ -67,6 +79,7 @@ foreach ($aAllDebitTxs as $aDebitTx) {
((string)($aTransaction['amount'] + $aTransaction['fee']) == (string)($aDebitTx['amount'] * -1) || // Check against transaction - Fee total
(string)($aTransaction['amount'] + $config['txfee_manual']) == (string)($aDebitTx['amount'] * -1) || // Check against txfee_manual deducted
(string)($aTransaction['amount'] + $config['txfee_auto']) == (string)($aDebitTx['amount'] * -1) || // Check against txfee_auto deducted
(string)($aTransaction['amount'] + $customtxfee) == (string)($aDebitTx['amount'] * -1) || // Check against transaction - default fee in MPOS
(string)$aTransaction['amount'] == (string)($aDebitTx['amount'] * -1)) // Check against actual value
) {
unset($aListTransactions[$key]);
@ -76,12 +89,39 @@ foreach ($aAllDebitTxs as $aDebitTx) {
$txid = $aTransaction['txid'];
}
}
if (!$bFound) $status = 'MISSING';
if (!$bFound) {
$status = 'MISSING';
$aMissingRPCMatches[] = $aDebitTx;
}
printf($mask, $aDebitTx['id'], $aDebitTx['username'], $aDebitTx['coin_address'], $aDebitTx['amount'], $status, $txid);
}
// Small summary
echo PHP_EOL . 'Summary: ' . PHP_EOL;
echo ' Total Send TX Records: ' . $total . PHP_EOL;
echo ' Total Debit Records: ' . count($aAllDebitTxs) . PHP_EOL;
echo ' Total Records Found: ' . $found . PHP_EOL;
echo PHP_EOL . 'Please be aware that transaction prior to a transaction fee change may be marked as MISSING.' . PHP_EOL;
echo 'See help on how to apply a custom transaction fee that can also be checked against. You can also enable verbose mode.' . PHP_EOL;
echo PHP_EOL . 'Summary' . PHP_EOL;
echo ' DB Debit Transaction Limit: ' . $limit . PHP_EOL;
echo ' RPC Transaction Limit: ' . $rpclimit . PHP_EOL;
echo ' Custom TX Fee Checked: ' . $customtxfee . PHP_EOL;
echo ' Total Send TX Records: ' . $total . PHP_EOL;
echo ' Total Debit Records: ' . count($aAllDebitTxs) . PHP_EOL;
echo ' Total Records Found: ' . $found . PHP_EOL;
if ($verbose) {
if (count($aListTransactions) > 0) {
$mask = "| %-40.40s | %-15.15s | %-65.65s |" . PHP_EOL;
echo PHP_EOL . 'Here a list of RPC transactions that have not matched any DB records:' . PHP_EOL . PHP_EOL;
printf($mask, 'Address', 'Amount', 'TX ID');
foreach ($aListTransactions as $aTransaction) {
printf($mask, $aTransaction['address'], $aTransaction['amount'], $aTransaction['txid']);
}
}
if (count($aMissingRPCMatches) > 0) {
$mask = "| %-40.40s | %-15.15s | %-8.8s | %-35.35s |" . PHP_EOL;
echo PHP_EOL . 'Here a list of DB transactions that have not matched any RPC records:' . PHP_EOL . PHP_EOL;
printf($mask, 'Address', 'Amount', 'DB ID', 'Username');
foreach ($aMissingRPCMatches as $aDebitTx) {
printf($mask, $aDebitTx['coin_address'], $aDebitTx['amount'], $aDebitTx['id'], $aDebitTx['username']);
}
}
}